Commit 7dad38cb authored by Amirjanyan's avatar Amirjanyan
Browse files

To next/previous item actions

parent b4b0b404
Showing with 38 additions and 0 deletions
+38 -0
......@@ -118,6 +118,10 @@ CVUAction Function({Map<String, CVUValue>? vars})? cvuAction(String named) {
return ({Map? vars}) => CVUActionSelectAll(vars: vars);
case "deselectall":
return ({Map? vars}) => CVUActionDeselectAll(vars: vars);
case "tonextitem":
return ({Map? vars}) => CVUActionToNextItem(vars: vars);
case "topreviousitem":
return ({Map? vars}) => CVUActionToPreviousItem(vars: vars);
default:
return null;
}
......@@ -839,6 +843,40 @@ class CVUActionSetSetting extends CVUAction {
}
}
class CVUActionToNextItem extends CVUAction {
Map<String, CVUValue> vars;
CVUActionToNextItem({vars}) : this.vars = vars ?? {};
@override
void execute(SceneController sceneController, CVUContext context) {
if (sceneController.topMostContext == null) {
return;
}
var index = sceneController.topMostContext!.focusedIndex;
sceneController.topMostContext?.focusedIndex =
index <= 0 ? sceneController.topMostContext!.items.length - 1 : index - 1;
sceneController.scheduleUIUpdate();
}
}
class CVUActionToPreviousItem extends CVUAction {
Map<String, CVUValue> vars;
CVUActionToPreviousItem({vars}) : this.vars = vars ?? {};
@override
void execute(SceneController sceneController, CVUContext context) {
if (sceneController.topMostContext == null) {
return;
}
var index = sceneController.topMostContext!.focusedIndex;
sceneController.topMostContext?.focusedIndex =
index >= sceneController.topMostContext!.items.length - 1 ? 0 : index + 1;
sceneController.scheduleUIUpdate();
}
}
class CVUActionNoop extends CVUAction {
Map<String, CVUValue> vars;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment