Skip to content

Commit

Permalink
Navigate to previous/next cart page via OSC/MIDI (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoCeruti committed Jan 11, 2025
1 parent 6610dee commit 3d84c1e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lisp/layout/cue_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def standby_index(self):
def set_standby_index(self, index):
"""Set the current index"""

def current_page(self):
"""Return the current page"""
return 0

def set_current_page(self, page_number):
"""Set the current page"""

@abstractmethod
def selected_cues(self, cue_type=Cue):
"""Iterate the selected cues, filtered by type.
Expand Down
7 changes: 7 additions & 0 deletions lisp/plugins/cart_layout/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ def remove_page(self, index):
if pattern.fullmatch(self._cart_view.tabText(n)):
self._cart_view.setTabText(n, text.format(number=n + 1))

def set_current_page(self, page_number):
page_number = max(0, min(page_number, self._cart_view.count()))
self._cart_view.setCurrentIndex(page_number)

def current_page(self):
return self._cart_view.currentIndex()

@tabs.get
def _get_tabs(self):
return self._cart_view.tabTexts()
Expand Down
9 changes: 9 additions & 0 deletions lisp/plugins/controller/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class LayoutAction(Enum):
StandbyForward = "StandbyForward"
StandbyBack = "StandbyBack"

PreviousPage = "PreviousPage"
NextPage = "NextPage"


LayoutActionsStrings = {
LayoutAction.Go: QT_TRANSLATE_NOOP("GlobalAction", "Go"),
Expand All @@ -60,6 +63,12 @@ class LayoutAction(Enum):
LayoutAction.StandbyBack: QT_TRANSLATE_NOOP(
"GlobalAction", "Move standby back"
),
LayoutAction.PreviousPage: QT_TRANSLATE_NOOP(
"GlobalAction", "Switch to previous page"
),
LayoutAction.NextPage: QT_TRANSLATE_NOOP(
"GlobalAction", "Switch to next page"
),
}


Expand Down
14 changes: 13 additions & 1 deletion lisp/plugins/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,20 @@ def perform_session_action(self, key):
self.app.layout.set_standby_index(
self.app.layout.standby_index() - 1
)
elif action is LayoutAction.NextPage:
self.app.layout.set_current_page(
self.app.layout.current_page() + 1
)
elif action is LayoutAction.PreviousPage:
self.app.layout.set_current_page(
self.app.layout.current_page() - 1
)
else:
self.app.finalize()
logger.warning(
translate(
"Controller", 'Unrecognized layout action: "{}"'
).format(action)
)

def __cue_added(self, cue):
cue.property_changed.connect(self.cue_changed)
Expand Down

0 comments on commit 3d84c1e

Please sign in to comment.