1- import { Component , OnInit , EventEmitter , Output , ViewChild , Input , ChangeDetectorRef , OnDestroy , HostBinding } from '@angular/core'
1+ import { Component , OnInit , EventEmitter , Output , ViewChild , Input , ChangeDetectorRef , OnDestroy , HostBinding , HostListener } from '@angular/core'
22import { EqualizersService , EqualizersTypeChangedEventCallback , EqualizerType } from './equalizers.service'
33import { BasicEqualizerComponent } from './basic-equalizer/basic-equalizer.component'
44import { AdvancedEqualizerComponent } from './advanced-equalizer/advanced-equalizer.component'
@@ -9,8 +9,8 @@ import { OptionsDialogComponent } from '../../../components/options-dialog/optio
99import { EqualizerPreset } from './presets/equalizer-presets.component'
1010import { UIService } from '../../../services/ui.service'
1111import { EffectEnabledChangedEventCallback } from '../effect.service'
12- import { UtilitiesService } from '../../../services/utilities.service'
1312import { ApplicationService } from '../../../services/app.service'
13+ import { UtilitiesService } from '../../../services/utilities.service'
1414
1515@Component ( {
1616 selector : 'eqm-equalizers' ,
@@ -32,9 +32,25 @@ export class EqualizersComponent implements OnInit, OnDestroy {
3232 return this . toolbarHeight + ( this . show ? ( ( this . activeEqualizer ?. height ?? 0 ) + this . presetsHeight ) : 0 )
3333 }
3434
35+ @HostBinding ( 'style.max-height.px' ) get maxHeight ( ) {
36+ let maxHeight = this . toolbarHeight
37+
38+ if ( this . show ) {
39+ const eqMaxHeight = ( ( ) => {
40+ switch ( this . type ) {
41+ default : return this . activeEqualizer ?. height ?? 0
42+ }
43+ } ) ( )
44+ maxHeight += this . presetsHeight + eqMaxHeight
45+ }
46+
47+ return maxHeight
48+ }
49+
3550 loaded = false
3651 enabled = true
3752 show = true
53+ enabledToggleHighlighted = false
3854
3955 activeEqualizer ? = this . getEqualizerFromType ( 'Basic' )
4056 presets : EqualizerPreset [ ] = [ ]
@@ -43,19 +59,9 @@ export class EqualizersComponent implements OnInit, OnDestroy {
4359 _type : EqualizerType
4460 set type ( newType : EqualizerType ) {
4561 if ( this . _type === newType ) return
46- const oldMinHeight = this . height
47- const oldType = this . type
4862 this . _type = newType
4963 this . changeRef . detectChanges ( )
5064 this . activeEqualizer = this . getEqualizerFromType ( this . type )
51- if ( oldType !== undefined ) {
52- setTimeout ( ( ) => {
53- const newMinHeight = this . height
54- const minHeightDiff = newMinHeight - oldMinHeight
55- console . log ( { minHeightDiff } )
56- this . ui . changeHeight ( { diff : minHeightDiff } )
57- } )
58- }
5965 }
6066
6167 get type ( ) { return this . _type }
@@ -65,14 +71,16 @@ export class EqualizersComponent implements OnInit, OnDestroy {
6571 public settingsDialog : MatDialogRef < OptionsDialogComponent >
6672
6773 constructor (
68- public equalizersService : EqualizersService ,
74+ public service : EqualizersService ,
6975 public dialog : MatDialog ,
7076 public ui : UIService ,
7177 public app : ApplicationService ,
7278 private readonly changeRef : ChangeDetectorRef ,
7379 private readonly utils : UtilitiesService ,
7480 public colors : ColorsService
75- ) { }
81+ ) {
82+ this . service . ref = this
83+ }
7684
7785 async ngOnInit ( ) {
7886 await this . sync ( )
@@ -88,8 +96,8 @@ export class EqualizersComponent implements OnInit, OnDestroy {
8896 enabled ,
8997 uiSettings
9098 ] = await Promise . all ( [
91- this . equalizersService . getType ( ) ,
92- this . equalizersService . getEnabled ( ) ,
99+ this . service . getType ( ) ,
100+ this . service . getEnabled ( ) ,
93101 this . ui . getSettings ( )
94102 ] )
95103 this . type = type
@@ -103,26 +111,26 @@ export class EqualizersComponent implements OnInit, OnDestroy {
103111 this . onEnabledChangedEventCallback = ( { enabled } ) => {
104112 this . enabled = enabled
105113 }
106- this . equalizersService . onEnabledChanged ( this . onEnabledChangedEventCallback )
114+ this . service . onEnabledChanged ( this . onEnabledChangedEventCallback )
107115
108116 this . onTypeChangedEventCallback = ( { type } ) => {
109117 this . type = type
110118 }
111- this . equalizersService . onTypeChanged ( this . onTypeChangedEventCallback )
119+ this . service . onTypeChanged ( this . onTypeChangedEventCallback )
112120 }
113121
114122 private destroyEvents ( ) {
115- this . equalizersService . offEnabledChanged ( this . onEnabledChangedEventCallback )
116- this . equalizersService . offTypeChanged ( this . onTypeChangedEventCallback )
123+ this . service . offEnabledChanged ( this . onEnabledChangedEventCallback )
124+ this . service . offTypeChanged ( this . onTypeChangedEventCallback )
117125 }
118126
119127 setEnabled ( ) {
120- this . equalizersService . setEnabled ( this . enabled )
128+ this . service . setEnabled ( this . enabled )
121129 }
122130
123131 async setType ( type : EqualizerType ) {
124132 if ( ! this . app . enabled ) return
125- await this . equalizersService . setType ( type )
133+ await this . service . setType ( type )
126134 this . type = type
127135 await this . utils . delay ( this . animationDuration )
128136 this . ui . dimensionsChanged . next ( )
@@ -139,10 +147,16 @@ export class EqualizersComponent implements OnInit, OnDestroy {
139147 this . show = ! this . show
140148 this . ui . setSettings ( { showEqualizers : this . show } )
141149 this . visibilityToggled . emit ( this . show )
142- setTimeout ( ( ) => { this . activeEqualizer = this . getEqualizerFromType ( this . type ) } )
150+
151+ setTimeout ( ( ) => {
152+ this . activeEqualizer = this . getEqualizerFromType ( this . type )
153+ } )
143154 }
144155
145156 openSettings ( ) {
157+ if ( ! this . app . enabled || ! this . enabled ) {
158+ return this . clicked ( )
159+ }
146160 const width = '90vw'
147161 this . settingsDialog = this . dialog . open ( OptionsDialogComponent , {
148162 hasBackdrop : true ,
@@ -169,6 +183,23 @@ export class EqualizersComponent implements OnInit, OnDestroy {
169183 return this . activeEqualizer . selectPreset ( preset )
170184 }
171185
186+ clicked ( ) {
187+ if ( ! this . enabled ) {
188+ this . blinkEnabledToggle ( )
189+ }
190+ }
191+
192+ private async blinkEnabledToggle ( ) {
193+ this . enabledToggleHighlighted = true
194+ await this . utils . delay ( 100 )
195+ this . enabledToggleHighlighted = false
196+ await this . utils . delay ( 100 )
197+ this . enabledToggleHighlighted = true
198+ await this . utils . delay ( 100 )
199+ this . enabledToggleHighlighted = false
200+ await this . utils . delay ( 100 )
201+ }
202+
172203 ngOnDestroy ( ) {
173204 this . destroyEvents ( )
174205 }
0 commit comments