Skip to content

Commit 87257e3

Browse files
committed
moved effects/eq changes from Pro repo
1 parent 28789ec commit 87257e3

5 files changed

Lines changed: 69 additions & 31 deletions

File tree

ui/src/app/sections/effects/equalizers/equalizers.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<div fxLayout="row" class="toolbar w-100" [style.min-height.px]="toolbarHeight" fxLayoutAlign="space-between center" >
22
<div fxFlex="20" fxLayoutGap="10px" fxLayout="row" fxLayoutAlign="start center">
3-
<eqm-toggle [enabled]="app.enabled" class="on-off" [(state)]="enabled" (stateChange)="setEnabled()"></eqm-toggle>
4-
<eqm-icon [@FadeInOut] *ngIf="activeEqualizer && activeEqualizer.settings.length" (click)="enabled && openSettings()" eqmTooltip="Settings" eqmTooltipPositionSide="bottom" name="cog" color="#8E8E93" [size]="16"></eqm-icon>
3+
<eqm-toggle [enabled]="app.enabled" [highlighted]="enabledToggleHighlighted" [(state)]="enabled" (stateChange)="setEnabled()"></eqm-toggle>
4+
<eqm-icon [@FadeInOut] *ngIf="activeEqualizer && activeEqualizer.settings.length" (click)="openSettings()" eqmTooltip="Settings" eqmTooltipPositionSide="bottom" name="cog" color="#8E8E93" [size]="16"></eqm-icon>
55
</div>
66

7-
<div fxLayout="row" fxLayoutAlign="space-around center" fxLayoutGap="10px">
7+
<div fxLayout="row" fxLayoutAlign="center center" fxLayoutGap="5px">
88
<eqm-label>Equalizer: </eqm-label>
99
<eqm-label class="type" [class.active]="type === 'Basic'" (click)="setType('Basic')">Basic</eqm-label>
1010
<eqm-label class="type" [class.active]="type === 'Advanced'" (click)="setType('Advanced')">Advanced</eqm-label>
1111
</div>
1212

13-
<div fxFlex="20" fxLayoutGap="5px" fxLayout="row" fxLayoutAlign="end center">
13+
<div fxFlex="10" fxLayoutGap="5px" fxLayout="row" fxLayoutAlign="end center">
1414
<eqm-icon (click)="toggleVisibility()" [name]="show ? 'hide' : 'show'"></eqm-icon>
1515
</div>
1616
</div>
1717

1818
<eqm-loading *ngIf="show && !loaded"></eqm-loading>
1919

20-
<eqm-equalizer-presets *ngIf="show && loaded"
20+
<eqm-equalizer-presets *ngIf="show && loaded" (click)="clicked()"
2121
[enabled]="enabled && app.enabled"
2222
class="presets"
2323
[presets]="presets" [selectedPreset]="selectedPreset"
@@ -28,14 +28,14 @@
2828
[additionalRightOption]="activeEqualizer?.additionalPresetOptionRight"
2929
></eqm-equalizer-presets>
3030

31-
<eqm-basic-equalizer *ngIf="show && loaded && type === 'Basic'" #basicEqualizer
31+
<eqm-basic-equalizer *ngIf="show && loaded && type === 'Basic'" #basicEqualizer (click)="clicked()"
3232
[enabled]="enabled && app.enabled" class="equalizer"
3333
(presetsChange)="presets = $event" (selectedPresetChange)="selectedPreset = $event"
3434
[animationDuration]="animationDuration" [animationFps]="animationFps"
3535
[settingsDialog]="settingsDialog"
3636
></eqm-basic-equalizer>
3737

38-
<eqm-advanced-equalizer *ngIf="show && loaded && type === 'Advanced'" #advancedEqualizer
38+
<eqm-advanced-equalizer *ngIf="show && loaded && type === 'Advanced'" #advancedEqualizer (click)="clicked()"
3939
[enabled]="enabled && app.enabled" class="equalizer"
4040
(presetsChange)="presets = $event" (selectedPresetChange)="selectedPreset = $event"
4141
[animationDuration]="animationDuration" [animationFps]="animationFps"

ui/src/app/sections/effects/equalizers/equalizers.component.ts

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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'
22
import { EqualizersService, EqualizersTypeChangedEventCallback, EqualizerType } from './equalizers.service'
33
import { BasicEqualizerComponent } from './basic-equalizer/basic-equalizer.component'
44
import { AdvancedEqualizerComponent } from './advanced-equalizer/advanced-equalizer.component'
@@ -9,8 +9,8 @@ import { OptionsDialogComponent } from '../../../components/options-dialog/optio
99
import { EqualizerPreset } from './presets/equalizer-presets.component'
1010
import { UIService } from '../../../services/ui.service'
1111
import { EffectEnabledChangedEventCallback } from '../effect.service'
12-
import { UtilitiesService } from '../../../services/utilities.service'
1312
import { 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
}

ui/src/app/sections/effects/equalizers/equalizers.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Injectable } from '@angular/core'
22
import { EffectService } from '../effect.service'
3+
import { EqualizersComponent } from './equalizers.component'
34

45
export const EqualizersTypes = [
56
'Basic',
@@ -13,6 +14,8 @@ export type EqualizerType = typeof EqualizersTypes[number]
1314
export class EqualizersService extends EffectService {
1415
route = `${this.route}/equalizers`
1516

17+
ref?: EqualizersComponent
18+
1619
async getType (): Promise<EqualizerType> {
1720
const resp = await this.request({ method: 'GET', endpoint: '/type' })
1821
return resp.type

ui/src/app/sections/effects/equalizers/presets/equalizer-presets.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<eqm-dropdown
2424
[enabled]="enabled"
2525
[editable]="false" noItemsPlaceholder="No Presets" placeholder="Select Preset"
26-
[items]="presets"
26+
[items]="orderedPresets"
2727
[selectedItem]="selectedPreset"
2828
labelParam="name"
2929
(itemSelected)="presetSelected.emit($event)"

ui/src/app/sections/effects/equalizers/presets/equalizer-presets.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ export class EqualizerPresetsComponent implements OnInit {
9898
this.presetDeleted.emit()
9999
}
100100
}
101+
102+
get orderedPresets () {
103+
return this.presets.sort((a, b) => a.isDefault ? 1 : a.name.localeCompare(b.name))
104+
}
101105
}

0 commit comments

Comments
 (0)