forked from spacetelescope/jdaviz
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Horizontal layer buttons (spacetelescope#2566)
* Layers now represented as horizontal buttons Color change and multiselect working Move logic to LayerSelect * Fix codestyle * Fix codestlye and remove comments * Viewer multiselect mixed state working * Working on handling edge cases of mixed state * Use messages in LayerSelect to call parts of _on_layers_changed * Remove unused elements * Fix button colors not updating after unmix state * Fix codestyle * Attempt 2 at fixing code style * Fix CI, put buttons in icon order * Code style again * Fix more tests * Everything handled by _on_layers_changed * button styling/tooltip based on (mixed)-color/visibility * improve tab styling * avoid second loop when applying RGB presets * improved handling of colormap and mixed colormode * remove elevation * redundant and conflicting with tab backgrounds * use all_color_to_label in tab styling * Mixed visibility and color represented in button * improved handling of subset color when in colormap * improved dark-theme support * tooltip and RGB preset support for mixed visibility * Visible is set to layer visible and bitmap visible * avoid displacement when no tabs selected * Fix CI tests * RGB presets: handle unmixing state * Address review comments * Forgot one change * for styling, always check if item in list, not as substring * Update changelog * Add tests --------- Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
- Loading branch information
Showing
9 changed files
with
778 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<template> | ||
<div> | ||
<span class="suppress-scrollbar" style="display: inline-block; white-space: nowrap; margin-left: -24px; width: calc(100% + 48px); overflow-x: scroll; overflow-y: hidden"> | ||
<span v-for="(item, index) in items" :class="selectedAsList.includes(item.label) ? 'layer-tab-selected' : ''" :style="'display: inline-block; padding: 12px; '+(selectedAsList.includes(item.label) ? 'border-top: 2px solid #c75109' : 'border-top: 2px solid transparent')"> | ||
<j-tooltip :tooltipcontent="tooltipContent(item)"> | ||
<v-btn | ||
:rounded="item.is_subset" | ||
@click="() => {if (!multiselect){$emit('update:selected', item.label)} else if(!selectedAsList.includes(item.label)) {$emit('update:selected', selected.concat(item.label))} else {$emit('update:selected', selected.filter(select => select != item.label))} }" | ||
:style="'padding: 0px; margin-bottom: 4px; background: '+visibilityStyle(item)+', '+colorStyle(item)" | ||
width="30px" | ||
min-width="30px" | ||
height="30px" | ||
> | ||
<span style="color: white; text-shadow: 0px 0px 3px black"> | ||
{{ item.icon }} | ||
</span> | ||
</v-btn> | ||
</j-tooltip> | ||
</span> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
props: ['items', 'selected', 'multiselect', 'colormode'], | ||
computed: { | ||
selectedAsList() { | ||
if (this.$props.multiselect) { | ||
return this.$props.selected | ||
} | ||
return [this.$props.selected] | ||
} | ||
}, | ||
methods: { | ||
tooltipContent(item) { | ||
var tooltip = item.label | ||
if (item.mixed_visibility) { | ||
tooltip += '<br/>Visible: mixed' | ||
} else if (!item.visible) { | ||
tooltip += '<br/>Visible: false' | ||
} | ||
if (this.$props.colormode === 'Colormaps' && !item.is_subset) { | ||
tooltip += '<br/>Color mode: colormap' | ||
} else if (this.$props.colormode === 'mixed' && !item.is_subset) { | ||
tooltip += '<br/>Color mode: mixed' | ||
} | ||
if (item.mixed_color && (this.$props.colormode !== 'Colormaps' || item.is_subset)) { | ||
tooltip += '<br/>Color: mixed' | ||
} | ||
return tooltip | ||
}, | ||
visibilityStyle(item) { | ||
if (item.mixed_visibility){ | ||
return 'repeating-linear-gradient(30deg, rgba(0,0,0,0.3), rgba(0,0,0,0.3) 3px, transparent 3px, transparent 3px, transparent 10px)' | ||
} | ||
else if (item.visible) { | ||
return 'repeating-linear-gradient(30deg, transparent, transparent 10px)' | ||
} else { | ||
return 'repeating-linear-gradient(30deg, rgba(0,0,0,0.8), rgba(0,0,0,0.8) 7px, transparent 7px, transparent 7px, transparent 10px)' | ||
} | ||
}, | ||
colorStyle(item) { | ||
if (this.$props.colormode == 'Colormaps' && !item.is_subset) { | ||
return 'repeating-linear-gradient( -45deg, gray, gray 20px)' | ||
} | ||
if (item.mixed_color) { | ||
colors = item.all_colors_to_label | ||
const strip_width = 42 / colors.length | ||
var style = 'repeating-linear-gradient( -45deg, ' | ||
for ([ind, color] of colors.entries()) { | ||
style += color + ' '+ind*strip_width+'px, ' + color + ' '+(ind+1)*strip_width+'px' | ||
if (ind !== colors.length-1) { | ||
style += ', ' | ||
} | ||
} | ||
style += ')' | ||
return style | ||
} | ||
return 'repeating-linear-gradient( -45deg, '+item.color+', '+item.color+' 20px)' | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.