mirror of
https://github.com/onyx-and-iris/voicemeeter-compact.git
synced 2024-11-21 20:30:56 +00:00
wrap button callbacks with {cls}.pause_updates()
This commit is contained in:
parent
3e68488231
commit
82cf0e914b
@ -249,7 +249,13 @@ class ChannelLabelFrameBuilder(AbstractBuilder):
|
|||||||
self.scale.bind("<Double-Button-1>", self.labelframe.reset_gain)
|
self.scale.bind("<Double-Button-1>", self.labelframe.reset_gain)
|
||||||
self.scale.bind("<Button-1>", self.labelframe.scale_press)
|
self.scale.bind("<Button-1>", self.labelframe.scale_press)
|
||||||
self.scale.bind("<ButtonRelease-1>", self.labelframe.scale_release)
|
self.scale.bind("<ButtonRelease-1>", self.labelframe.scale_release)
|
||||||
self.scale.bind("<MouseWheel>", self.labelframe._on_mousewheel)
|
self.scale.bind(
|
||||||
|
"<MouseWheel>",
|
||||||
|
partial(
|
||||||
|
self.labelframe.pause_updates,
|
||||||
|
self.labelframe._on_mousewheel,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def add_gain_label(self):
|
def add_gain_label(self):
|
||||||
self.labelframe.gain_label = ttk.Label(
|
self.labelframe.gain_label = ttk.Label(
|
||||||
@ -263,7 +269,7 @@ class ChannelLabelFrameBuilder(AbstractBuilder):
|
|||||||
self.button_mute = ttk.Checkbutton(
|
self.button_mute = ttk.Checkbutton(
|
||||||
self.labelframe,
|
self.labelframe,
|
||||||
text="MUTE",
|
text="MUTE",
|
||||||
command=partial(self.labelframe.toggle_mute, "mute"),
|
command=partial(self.labelframe.pause_updates, self.labelframe.toggle_mute),
|
||||||
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{self.identifier}Mute{self.index}.TButton'}",
|
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{self.identifier}Mute{self.index}.TButton'}",
|
||||||
variable=self.labelframe.mute,
|
variable=self.labelframe.mute,
|
||||||
)
|
)
|
||||||
@ -283,7 +289,7 @@ class ChannelLabelFrameBuilder(AbstractBuilder):
|
|||||||
self.button_on = ttk.Checkbutton(
|
self.button_on = ttk.Checkbutton(
|
||||||
self.labelframe,
|
self.labelframe,
|
||||||
text="ON",
|
text="ON",
|
||||||
command=self.labelframe.set_on,
|
command=partial(self.labelframe.pause_updates, self.labelframe.set_on),
|
||||||
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{self.identifier}On{self.index}.TButton'}",
|
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{self.identifier}On{self.index}.TButton'}",
|
||||||
variable=self.labelframe.on,
|
variable=self.labelframe.on,
|
||||||
)
|
)
|
||||||
@ -486,7 +492,9 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
ttk.Checkbutton(
|
ttk.Checkbutton(
|
||||||
self.configframe,
|
self.configframe,
|
||||||
text=param,
|
text=param,
|
||||||
command=partial(self.configframe.toggle_a, param),
|
command=partial(
|
||||||
|
self.configframe.pause_updates, self.configframe.toggle_a, param
|
||||||
|
),
|
||||||
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
||||||
variable=self.configframe.phys_out_params_vars[
|
variable=self.configframe.phys_out_params_vars[
|
||||||
self.configframe.phys_out_params.index(param)
|
self.configframe.phys_out_params.index(param)
|
||||||
@ -507,7 +515,9 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
ttk.Checkbutton(
|
ttk.Checkbutton(
|
||||||
self.configframe,
|
self.configframe,
|
||||||
text=param,
|
text=param,
|
||||||
command=partial(self.configframe.toggle_b, param),
|
command=partial(
|
||||||
|
self.configframe.pause_updates, self.configframe.toggle_b, param
|
||||||
|
),
|
||||||
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
||||||
variable=self.configframe.virt_out_params_vars[
|
variable=self.configframe.virt_out_params_vars[
|
||||||
self.configframe.virt_out_params.index(param)
|
self.configframe.virt_out_params.index(param)
|
||||||
@ -528,7 +538,9 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
ttk.Checkbutton(
|
ttk.Checkbutton(
|
||||||
self.configframe,
|
self.configframe,
|
||||||
text=param,
|
text=param,
|
||||||
command=partial(self.configframe.toggle_p, param),
|
command=partial(
|
||||||
|
self.configframe.pause_updates, self.configframe.toggle_p, param
|
||||||
|
),
|
||||||
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
||||||
variable=self.configframe.param_vars[i],
|
variable=self.configframe.param_vars[i],
|
||||||
)
|
)
|
||||||
@ -578,10 +590,16 @@ class BusConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
column=0, row=0, columnspan=2, sticky=(tk.W)
|
column=0, row=0, columnspan=2, sticky=(tk.W)
|
||||||
)
|
)
|
||||||
self.configframe.busmode_button.bind(
|
self.configframe.busmode_button.bind(
|
||||||
"<Button-1>", self.configframe.rotate_bus_modes_right
|
"<Button-1>",
|
||||||
|
partial(
|
||||||
|
self.configframe.pause_updates, self.configframe.rotate_bus_modes_right
|
||||||
|
),
|
||||||
)
|
)
|
||||||
self.configframe.busmode_button.bind(
|
self.configframe.busmode_button.bind(
|
||||||
"<Button-3>", self.configframe.rotate_bus_modes_left
|
"<Button-3>",
|
||||||
|
partial(
|
||||||
|
self.configframe.pause_updates, self.configframe.rotate_bus_modes_left
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def create_param_buttons(self):
|
def create_param_buttons(self):
|
||||||
@ -589,7 +607,9 @@ class BusConfigFrameBuilder(ChannelConfigFrameBuilder):
|
|||||||
ttk.Checkbutton(
|
ttk.Checkbutton(
|
||||||
self.configframe,
|
self.configframe,
|
||||||
text=param,
|
text=param,
|
||||||
command=partial(self.configframe.toggle_p, param),
|
command=partial(
|
||||||
|
self.configframe.pause_updates, self.configframe.toggle_p, param
|
||||||
|
),
|
||||||
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}",
|
||||||
variable=self.configframe.param_vars[i],
|
variable=self.configframe.param_vars[i],
|
||||||
)
|
)
|
||||||
|
@ -88,17 +88,27 @@ class ChannelLabelFrame(ttk.LabelFrame):
|
|||||||
self.parent.target.event.add("ldirty")
|
self.parent.target.event.add("ldirty")
|
||||||
self.after(500, self.resume_updates)
|
self.after(500, self.resume_updates)
|
||||||
|
|
||||||
|
def pause_updates(self, func, *args):
|
||||||
|
"""function wrapper, adds a 50ms delay on updates"""
|
||||||
|
_base_values.run_update = False
|
||||||
|
|
||||||
|
func(*args)
|
||||||
|
|
||||||
|
self.after(50, self.resume_updates)
|
||||||
|
|
||||||
def resume_updates(self):
|
def resume_updates(self):
|
||||||
_base_values.run_update = True
|
_base_values.run_update = True
|
||||||
|
|
||||||
def _on_mousewheel(self, event):
|
def _on_mousewheel(self, event):
|
||||||
_base_values.run_update = False
|
|
||||||
self.gain.set(
|
self.gain.set(
|
||||||
self.gain.get()
|
round(
|
||||||
+ (
|
self.gain.get()
|
||||||
_configuration.mwscroll_step
|
+ (
|
||||||
if event.delta > 0
|
_configuration.mwscroll_step
|
||||||
else -_configuration.mwscroll_step
|
if event.delta > 0
|
||||||
|
else -_configuration.mwscroll_step
|
||||||
|
),
|
||||||
|
1,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self.gain.get() > 12:
|
if self.gain.get() > 12:
|
||||||
@ -106,7 +116,7 @@ class ChannelLabelFrame(ttk.LabelFrame):
|
|||||||
elif self.gain.get() < -60:
|
elif self.gain.get() < -60:
|
||||||
self.gain.set(-60)
|
self.gain.set(-60)
|
||||||
self.setter("gain", self.gain.get())
|
self.setter("gain", self.gain.get())
|
||||||
self.after(1, self.resume_updates)
|
self.gainlabel.set(round(self.gain.get(), 1))
|
||||||
|
|
||||||
def open_config(self):
|
def open_config(self):
|
||||||
if self.conf.get():
|
if self.conf.get():
|
||||||
|
@ -68,6 +68,14 @@ class Config(ttk.Frame):
|
|||||||
self.parent.target.event.add("ldirty")
|
self.parent.target.event.add("ldirty")
|
||||||
self.after(350, self.resume_updates)
|
self.after(350, self.resume_updates)
|
||||||
|
|
||||||
|
def pause_updates(self, func, *args):
|
||||||
|
"""function wrapper, adds a 50ms delay on updates"""
|
||||||
|
_base_values.run_update = False
|
||||||
|
|
||||||
|
func(*args)
|
||||||
|
|
||||||
|
self.after(50, self.resume_updates)
|
||||||
|
|
||||||
def resume_updates(self):
|
def resume_updates(self):
|
||||||
_base_values.run_update = True
|
_base_values.run_update = True
|
||||||
|
|
||||||
|
@ -78,6 +78,14 @@ class GainLayer(ttk.LabelFrame):
|
|||||||
self.parent.target.event.add("ldirty")
|
self.parent.target.event.add("ldirty")
|
||||||
self.after(500, self.resume_updates)
|
self.after(500, self.resume_updates)
|
||||||
|
|
||||||
|
def pause_updates(self, func, *args):
|
||||||
|
"""function wrapper, adds a 50ms delay on updates"""
|
||||||
|
_base_values.run_update = False
|
||||||
|
|
||||||
|
func(*args)
|
||||||
|
|
||||||
|
self.after(50, self.resume_updates)
|
||||||
|
|
||||||
def resume_updates(self):
|
def resume_updates(self):
|
||||||
_base_values.run_update = True
|
_base_values.run_update = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user