Refactored hooks to specify events and reworked the dropdowns to be significantly faster and more responsive. (#304)

* Updated events to be more specific

* Update more events

* Update globalmousepos

* Update themes and submap module to show submap name.

* Type fixes

* Reworked menu position calculation logic to be much more efficient.

* Revert import file location

* We luv arrow functions

* Remove globalMousePos remnants since it's unused.

* Added the ability to configure menu dropdown transition and duration.

* Fix type
This commit is contained in:
Jas Singh
2024-10-06 00:22:27 -07:00
committed by GitHub
parent 8a727a080e
commit ee7d19320c
71 changed files with 2175 additions and 1796 deletions

View File

@@ -12,27 +12,30 @@ const renderActiveInput = (): Box<Child, Attribute>[] => {
vexpand: false,
vpack: 'end',
setup: (self) => {
self.hook(audio, () => {
const updateClass = (): void => {
const mic = audio.microphone;
const className = `menu-active-button input ${mic.is_muted ? 'muted' : ''}`;
return (self.class_name = className);
});
self.class_name = className;
};
self.hook(audio.microphone, updateClass, 'notify::is-muted');
},
on_primary_click: () => (audio.microphone.is_muted = !audio.microphone.is_muted),
child: Widget.Icon({
class_name: 'menu-active-icon input',
setup: (self) => {
self.hook(audio, () => {
const updateIcon = (): void => {
const isMicMuted =
audio.microphone.is_muted !== null ? audio.microphone.is_muted : true;
if (audio.microphone.volume > 0) {
self.icon = getIcon(audio.microphone.volume, isMicMuted)['mic'];
return;
} else {
self.icon = getIcon(100, true)['mic'];
}
self.icon = getIcon(100, false)['mic'];
});
};
self.hook(audio.microphone, updateIcon, 'notify::volume');
self.hook(audio.microphone, updateIcon, 'notify::is-muted');
},
}),
}),
@@ -44,9 +47,9 @@ const renderActiveInput = (): Box<Child, Attribute>[] => {
hpack: 'start',
truncate: 'end',
wrap: true,
label: audio
.bind('microphone')
.as((v) => (v.description === null ? 'No input device found...' : v.description)),
label: audio.bind('microphone').as((v) => {
return v.description === null ? 'No input device found...' : v.description;
}),
}),
Widget.Slider({
value: audio.microphone.bind('volume').as((v) => v),

View File

@@ -12,20 +12,24 @@ const renderActivePlayback = (): Box<Child, Attribute>[] => {
vexpand: false,
vpack: 'end',
setup: (self) => {
self.hook(audio, () => {
const updateClass = (): void => {
const spkr = audio.speaker;
const className = `menu-active-button playback ${spkr.is_muted ? 'muted' : ''}`;
return (self.class_name = className);
});
self.class_name = className;
};
self.hook(audio.speaker, updateClass, 'notify::is-muted');
},
on_primary_click: () => (audio.speaker.is_muted = !audio.speaker.is_muted),
child: Widget.Icon({
class_name: 'menu-active-icon playback',
setup: (self) => {
self.hook(audio, () => {
const updateIcon = (): void => {
const isSpeakerMuted = audio.speaker.is_muted !== null ? audio.speaker.is_muted : true;
self.icon = getIcon(audio.speaker.volume, isSpeakerMuted)['spkr'];
});
};
self.hook(audio.speaker, updateIcon, 'notify::volume');
self.hook(audio.speaker, updateIcon, 'notify::is-muted');
},
}),
}),