Skip to content

Commit

Permalink
fix: avoid user selecting a second item while the screen is being tra…
Browse files Browse the repository at this point in the history
…nsitioned
  • Loading branch information
sassanh committed Jul 12, 2024
1 parent dc39d7c commit 29a0d3d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 0.11.17

- feat: add `_visual_snapshot` to visualize the state of stack for debugging purposes
- fix: avoid user selecting a second item while the screen is being transitioned

## Version 0.11.16

Expand Down
4 changes: 3 additions & 1 deletion ubo_gui/menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ def select(self: MenuWidget, index: int) -> None:
if not self.screen_manager.current_screen:
warnings.warn('`current_screen` is `None`', RuntimeWarning, stacklevel=1)
return
current_page = cast(PageWidget, self.screen_manager.current_screen)
if self._is_preparation_in_progress:
return
current_page = cast(PageWidget, self.current_screen)
item = current_page.get_item(index)
if item:
self.select_item(item)
Expand Down
3 changes: 3 additions & 0 deletions ubo_gui/menu/transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TransitionsMixin:
]
screen_manager: ScreenManager
_is_transition_in_progress: bool = False
_is_preparation_in_progress: bool = False
_transition_progress_lock: threading.Lock

def __init__(self: TransitionsMixin, **kwargs: dict[str, Any]) -> None:
Expand Down Expand Up @@ -130,6 +131,7 @@ def _perform_switch(
duration=duration,
**({} if direction is None else {'direction': direction}),
)
self._is_preparation_in_progress = False

def _switch_to(
self: TransitionsMixin,
Expand All @@ -150,6 +152,7 @@ def _switch_to(
if headless_widget:
headless_widget.activate_high_fps_mode()
self._is_transition_in_progress = transition is not self._no_transition
self._is_preparation_in_progress = True
self._perform_switch(
screen,
transition=transition,
Expand Down

0 comments on commit 29a0d3d

Please sign in to comment.