diff --git a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue
index 6b6e97cd9..c60c3f507 100644
--- a/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue
+++ b/girder/girder_large_image/web_client/vue/components/CompositeLayers.vue
@@ -5,7 +5,7 @@ import { CHANNEL_COLORS, OTHER_COLORS } from '../utils/colors'
import HistogramEditor from './HistogramEditor.vue';
export default {
- props: ['itemId', 'currentFrame', 'layers', 'layerMap'],
+ props: ['itemId', 'currentFrame', 'layers', 'layerMap', 'active'],
emits: ['updateStyle'],
components: {
'color-picker': Chrome,
@@ -27,10 +27,33 @@ export default {
resample: false,
style: '{}',
roundRange: true,
- }
+ },
+ showKeyboardShortcuts: false,
}
},
methods: {
+ keyHandler(e) {
+ let numericKey = parseFloat(e.key)
+ if (e.ctrlKey && !isNaN(numericKey)) {
+ e.preventDefault()
+ if (numericKey === 0) {
+ numericKey += 10
+ }
+ if (e.altKey) {
+ numericKey += 10
+ }
+ const layerIndex = numericKey - 1
+ if (layerIndex < this.layers.length) {
+ const targetLayer = this.layers[layerIndex]
+ if (this.compositeLayerInfo[targetLayer].enabled) {
+ this.enabledLayers = this.enabledLayers.filter((v) => v !== targetLayer)
+ } else {
+ this.enabledLayers.push(targetLayer)
+ }
+ this.updateActiveLayers()
+ }
+ }
+ },
initializeLayerInfo() {
const usedColors = []
this.compositeLayerInfo = {}
@@ -211,126 +234,165 @@ export default {
}
this.updateActiveLayers()
this.updateStyle()
+ if (this.active) {
+ document.addEventListener('keydown', this.keyHandler)
+ }
+ },
+ watch: {
+ active() {
+ if (this.active) {
+ document.addEventListener('keydown', this.keyHandler)
+ } else {
+ document.removeEventListener('keydown', this.keyHandler)
+ }
+ }
}
}
-
@@ -456,6 +518,17 @@ export default {
margin: 30px 0px 0px;
height: 40px;
}
+.icon-keyboard {
+ font-size: 2rem;
+}
+.shortcuts {
+ padding-bottom: 10px;
+}
+.monospace {
+ font-family: monospace;
+ background-color: rgba(0, 0, 0, 0.2);
+ padding: 1px;
+}