From 2c290e2632bd8bf728cc64e7fa15ee96feb48044 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Fri, 16 Sep 2022 09:44:47 +0100 Subject: [PATCH] now using event toggles when dragging sliders patch bump --- CHANGELOG.md | 16 +++++++++++++++- pyproject.toml | 2 +- vmcompact/app.py | 13 +++++-------- vmcompact/builders.py | 3 +++ vmcompact/channels.py | 22 ++++++++++++++++++---- vmcompact/config.py | 17 +++++++++++++++-- vmcompact/data.py | 4 ++-- vmcompact/gainlayer.py | 21 ++++++++++++++++++--- vmcompact/navigation.py | 2 +- 9 files changed, 78 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8beff08..c47ca66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [ ] Add support for forest theme (should be coming soon) -## [1.4.0] - 2022-09-03 +## [1.5.1] - 2022-09-16 + +### Added + +- 1.5.1 binary to releases + +### Changed + +- sv_ttk updated to v2.0. +- event toggles used to pause updates when dragging sliders. + +### Removed + +## [1.4.2] - 2022-09-03 ### Added - tomli/tomllib compatibility layer to support python 3.10 +- 1.4.2 binary to releases ## [1.3.0] - 2022-07-14 diff --git a/pyproject.toml b/pyproject.toml index 9b21e25..7fe9dc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "voicemeeter-compact" -version = "1.5.0" +version = "1.5.1" description = "A Compact Voicemeeter Remote App" authors = ["onyx-and-iris "] license = "MIT" diff --git a/vmcompact/app.py b/vmcompact/app.py index 29c3298..11a4775 100644 --- a/vmcompact/app.py +++ b/vmcompact/app.py @@ -93,11 +93,10 @@ class App(tk.Tk): def on_update(self, subject): """called whenever notified of update""" - if not _base_values.in_scale_button_1: - if subject == "pdirty": - self.after(1, self.subject.notify, "pdirty") - elif subject == "ldirty" and not _base_values.dragging: - self.after(1, self.subject.notify, "ldirty") + if subject == "pdirty" and _base_values.run_update: + self.after(1, self.subject.notify, "pdirty") + elif subject == "ldirty" and not _base_values.dragging: + self.after(1, self.subject.notify, "ldirty") def _destroy_top_level_frames(self): """ @@ -118,16 +117,14 @@ class App(tk.Tk): def dragging(self, event, *args): if event.widget is self: if self.drag_id == "": - _base_values.in_scale_button_1 = True _base_values.dragging = True else: self.after_cancel(self.drag_id) self.drag_id = self.after(100, self.stop_drag) def stop_drag(self): - _base_values.dragging = False - _base_values.in_scale_button_1 = False self.drag_id = "" + _base_values.dragging = False _apps = {kind.name: App.make(kind) for kind in _kinds_all} diff --git a/vmcompact/builders.py b/vmcompact/builders.py index 0738cdb..ea93652 100644 --- a/vmcompact/builders.py +++ b/vmcompact/builders.py @@ -41,6 +41,9 @@ class MainFrameBuilder(AbstractBuilder): sv_ttk.set_theme(_configuration.theme_mode) print(f"Sunvalley {sv_ttk.get_theme().capitalize()} Theme applied") + self.app.target.event.remove("mdirty") + self.app.target.event.remove("midi") + def create_channelframe(self, type_): if type_ == "strip": self.app.strip_frame = _make_channelframe(self.app, type_) diff --git a/vmcompact/channels.py b/vmcompact/channels.py index b57fa47..541819e 100644 --- a/vmcompact/channels.py +++ b/vmcompact/channels.py @@ -64,15 +64,29 @@ class ChannelLabelFrame(ttk.LabelFrame): def reset_gain(self, *args): self.setter("gain", 0) self.gain.set(0) + self.gainlabel.set(self.gain.get()) def scale_press(self, *args): - _base_values.in_scale_button_1 = True + self.after(1, self.remove_events) + + def remove_events(self): + self.parent.target.event.remove("pdirty") + self.parent.target.event.remove("ldirty") def scale_release(self, *args): - _base_values.in_scale_button_1 = False + _base_values.run_update = False + self.after(1, self.add_events) + + def add_events(self): + self.parent.target.event.add("pdirty") + self.parent.target.event.add("ldirty") + self.after(500, self.resume_updates) + + def resume_updates(self): + _base_values.run_update = True def _on_mousewheel(self, event): - _base_values.in_scale_button_1 = True + _base_values.run_update = False self.gain.set( self.gain.get() + ( @@ -86,7 +100,7 @@ class ChannelLabelFrame(ttk.LabelFrame): elif self.gain.get() < -60: self.gain.set(-60) self.setter("gain", self.gain.get()) - _base_values.in_scale_button_1 = False + self.after(1, self.resume_updates) def open_config(self): if self.conf.get(): diff --git a/vmcompact/config.py b/vmcompact/config.py index d3a1bdd..e1eeb16 100644 --- a/vmcompact/config.py +++ b/vmcompact/config.py @@ -37,10 +37,23 @@ class Config(ttk.Frame): setattr(self.target, param, value) def scale_press(self, *args): - _base_values.in_scale_button_1 = True + self.after(1, self.remove_events) + + def remove_events(self): + self.parent.target.event.remove("pdirty") + self.parent.target.event.remove("ldirty") def scale_release(self, *args): - _base_values.in_scale_button_1 = False + _base_values.run_update = False + self.after(1, self.add_events) + + def add_events(self): + self.parent.target.event.add("pdirty") + self.parent.target.event.add("ldirty") + self.after(350, self.resume_updates) + + def resume_updates(self): + _base_values.run_update = True def scale_enter(self, param, *args): val = self.slider_vars[self.slider_params.index(param)].get() diff --git a/vmcompact/data.py b/vmcompact/data.py index 407c167..9a466ca 100644 --- a/vmcompact/data.py +++ b/vmcompact/data.py @@ -45,8 +45,8 @@ class Configurations(metaclass=SingletonMeta): @dataclass class BaseValues(metaclass=SingletonMeta): - # are we dragging a scale with mouse 1 - in_scale_button_1: bool = False + # pause updates after releasing scale + run_update: bool = True # are we dragging main window with mouse 1 dragging: bool = False # a vban connection established diff --git a/vmcompact/gainlayer.py b/vmcompact/gainlayer.py index 393125b..b00bb75 100644 --- a/vmcompact/gainlayer.py +++ b/vmcompact/gainlayer.py @@ -52,7 +52,7 @@ class GainLayer(ttk.LabelFrame): def reset_gain(self, *args): self.setter("gain", 0) self.gain.set(0) - self.gainlabel.set(0) + self.gainlabel.set(self.gain.get()) def scale_callback(self, *args): """callback function for scale widget""" @@ -61,12 +61,26 @@ class GainLayer(ttk.LabelFrame): self.gainlabel.set(round(self.gain.get(), 1)) def scale_press(self, *args): - _base_values.in_scale_button_1 = True + self.after(1, self.remove_events) + + def remove_events(self): + self.parent.target.event.remove("pdirty") + self.parent.target.event.remove("ldirty") def scale_release(self, *args): - _base_values.in_scale_button_1 = False + _base_values.run_update = False + self.after(1, self.add_events) + + def add_events(self): + self.parent.target.event.add("pdirty") + self.parent.target.event.add("ldirty") + self.after(500, self.resume_updates) + + def resume_updates(self): + _base_values.run_update = True def _on_mousewheel(self, event): + _base_values.run_update = False self.gain.set( self.gain.get() + ( @@ -80,6 +94,7 @@ class GainLayer(ttk.LabelFrame): elif self.gain.get() < -60: self.gain.set(-60) self.setter("gain", self.gain.get()) + self.after(1, self.resume_updates) def set_on(self): """enables a gainlayer. sets its button colour""" diff --git a/vmcompact/navigation.py b/vmcompact/navigation.py index 66d7893..8e77393 100644 --- a/vmcompact/navigation.py +++ b/vmcompact/navigation.py @@ -84,4 +84,4 @@ class Navigation(ttk.Frame): background=f'{"purple" if self.submix.get() else "white"}', ) - self.extend_text.set("REDUCE" if self.extend.get() else "EXTEND") + self.extend_text.set("REDUCE" if self.extend.get() else "EXTEND")