From 3aa5be814dcf31e02c3942700042194cfc3bf5d8 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 6 Jul 2020 11:29:23 +0100 Subject: [PATCH] Added tab increment/descrement methods --- .../api/static/src/components/appContent.vue | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/openflexure_microscope/api/static/src/components/appContent.vue b/openflexure_microscope/api/static/src/components/appContent.vue index 319ddc35..24439529 100644 --- a/openflexure_microscope/api/static/src/components/appContent.vue +++ b/openflexure_microscope/api/static/src/components/appContent.vue @@ -218,6 +218,18 @@ export default { } } return pluginGuis; + }, + tabOrder: function() { + // TODO: There must be a better way to do this, somehow reading the order of the HTML elements? + var ind = ["view", "gallery", "navigate", "capture", "settings"]; + for (const plugin of this.pluginsGuiList) { + ind.push(plugin.id); + } + ind.push("about"); + return ind; + }, + currentTabIndex: function() { + return this.tabOrder.indexOf(this.currentTab); } }, @@ -246,6 +258,14 @@ export default { this.$root.$on("globalSwitchTab", tabID => { this.currentTab = tabID; }); + // A global signal listener to increment tab + this.$root.$on("globalIncrementTab", () => { + this.incrementTabBy(1); + }); + // A global signal listener to decrement tab + this.$root.$on("globalDecrementTab", () => { + this.incrementTabBy(-1); + }); }, beforeDestroy() { @@ -274,6 +294,14 @@ export default { this.currentTab = tab; } }, + incrementTabBy: function(n) { + const newIndex = + (((this.currentTabIndex + n) % this.tabOrder.length) + + this.tabOrder.length) % + this.tabOrder.length; + const newId = this.tabOrder[newIndex]; + this.currentTab = newId; + }, startModals: function() { this.$refs["calibrationModal"].show(); },