-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor slice selection toolbar with toggle groups #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,14 @@ | |
| DENSITY = { | ||
| "adjust-layout": "compact", | ||
| "adjust-databounds": "default", | ||
| "select-slice-time": "default", | ||
| "select-slice-time": "compact", | ||
| "animation-controls": "compact", | ||
| } | ||
|
|
||
| SIZES = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should that be removed all together? |
||
| "adjust-layout": 49, | ||
| "adjust-databounds": 65, | ||
| "select-slice-time": 70, | ||
| "select-slice-time": 49, | ||
| "animation-controls": 49, | ||
| } | ||
|
|
||
|
|
@@ -447,102 +447,99 @@ def __init__(self): | |
| ) | ||
| super().__init__(**style) | ||
|
|
||
| self.state.setdefault("expanded_slice_track", None) | ||
|
|
||
| with self: | ||
| with v3.VTooltip( | ||
| text=( | ||
| "slice_slider_edit ? 'Toggle to text edit' : 'Toggle to slider edit'", | ||
| ), | ||
| ): | ||
| with v3.Template(v_slot_activator="{ props }"): | ||
| v3.VIcon( | ||
| "mdi-tune-variant", | ||
| v_bind="props", | ||
| classes="ml-3 mr-2 opacity-50", | ||
| click="slice_slider_edit = !slice_slider_edit", | ||
| ) | ||
| v3.VIcon("mdi-tune-variant", classes="ml-3 mr-2 opacity-50") | ||
|
|
||
| with v3.VRow( | ||
| classes="ma-0 pr-2 flex-wrap flex-grow-1", | ||
| dense=True, | ||
| v_if=("slice_slider_edit", True), | ||
| with html.Div( | ||
| classes="d-flex align-center flex-wrap flex-grow-1 ga-1 py-1 pr-2" | ||
| ): | ||
| # Debug: Show animation_tracks array | ||
| # html.Div( | ||
| # "Animation Tracks: {{ JSON.stringify(available_animation_tracks) }}", | ||
| # classes="col-12", | ||
| # ) | ||
| # Each track gets a column (3 per row) | ||
| with v3.VCol( | ||
| cols=("utils.quickview.cols(available_animation_tracks.length)",), | ||
| with html.Template( | ||
| v_for="(track, idx) in available_animation_tracks", | ||
| key="idx", | ||
| classes="pa-2", | ||
| ): | ||
| with client.Getter(name=("track",), value_name="t_values"): | ||
| with client.Getter( | ||
| name=("track + '_idx'",), value_name="t_idx" | ||
| ): | ||
| with v3.VRow(classes="ma-0 align-center", dense=True): | ||
| v3.VLabel( | ||
| "{{track}}", | ||
| classes="text-subtitle-2", | ||
| ) | ||
| v3.VSpacer() | ||
| v3.VLabel( | ||
| "{{ dim_units[track] ? parseFloat(t_values[t_idx]).toFixed(2) + ' ' + dim_units[track] : 'Index value: ' + t_idx }} (k={{ t_idx }})", | ||
| classes="text-body-2", | ||
| ) | ||
| v3.VSlider( | ||
| model_value=("t_idx",), | ||
| update_modelValue=( | ||
| self.on_update_slider, | ||
| "[track, $event]", | ||
| # --- Per-variable group --- | ||
| with v3.VSheet( | ||
| classes="d-flex align-center rounded px-1 ga-1", | ||
| color=( | ||
| "expanded_slice_track === track ? 'grey-lighten-3' : 'grey-lighten-4'", | ||
| ), | ||
| min=0, | ||
| # max=100,#("get(track.value).length - 1",), | ||
| max=("t_values.length - 1",), | ||
| step=1, | ||
| density="compact", | ||
| hide_details=True, | ||
| ) | ||
| with v3.VRow( | ||
| classes="ma-0 pl-6 pr-2 align-center ga-4", | ||
| v_if="!slice_slider_edit", | ||
| ): | ||
| with v3.VCol( | ||
| v_for="(track, idx) in available_animation_tracks", | ||
| key="idx", | ||
| ): | ||
| with client.Getter(name=("track",), value_name="t_values"): | ||
| with client.Getter( | ||
| name=("track + '_idx'",), value_name="t_idx" | ||
| ): | ||
| with v3.VRow(classes="ma-0 align-center", dense=True): | ||
| v3.VNumberInput( | ||
| model_value=("Number(t_idx)",), | ||
| update_modelValue=( | ||
| self.on_update_slider, | ||
| "[track, Number($event)]", | ||
| ), | ||
| key=("track + '_' + t_idx",), | ||
| min=[0], | ||
| max=["t_values ? t_values.length - 1 : 0"], | ||
| step=[1], | ||
| hide_details=True, | ||
| density="comfortable", | ||
| variant="plain", | ||
| ): | ||
| # Toggle button with track name | ||
| v3.VBtn( | ||
| "{{ track }}", | ||
| v_tooltip_bottom="'Toggle ' + track + ' controls'", | ||
| flat=True, | ||
| control_variant="stacked", | ||
| style="max-width: 100px;", | ||
| reverse=True, | ||
| variant=( | ||
| "expanded_slice_track === track ? 'flat' : 'outlined'", | ||
| ), | ||
| rounded=True, | ||
| click="expanded_slice_track = expanded_slice_track === track ? null : track", | ||
| color=( | ||
| "expanded_slice_track === track ? 'primary' : ''", | ||
| ), | ||
| style=( | ||
| "'text-transform: none;' + (expanded_slice_track === track ? '' : ' background-color: white;')", | ||
| ), | ||
| ) | ||
| # Expanded controls | ||
| with html.Div( | ||
| v_if="expanded_slice_track === track", | ||
| classes="d-flex align-center ga-1", | ||
| style="height: 36px; overflow: visible;", | ||
| ): | ||
| v3.VDivider(vertical=True, classes="mx-1") | ||
| # Text input | ||
| html.Input( | ||
| type="number", | ||
| value=("t_idx",), | ||
| min=[0], | ||
| max=["t_values ? t_values.length - 1 : 0"], | ||
| step=[1], | ||
| change=( | ||
| self.on_update_slider, | ||
| "[track, Number($event.target.value)]", | ||
| ), | ||
| style="width: 60px; height: 28px; padding: 16px 4px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; box-sizing: border-box; text-align: right;", | ||
| ) | ||
| # Slider | ||
| v3.VSlider( | ||
| v_tooltip_bottom=( | ||
| "dim_units[track] ? parseFloat(t_values[t_idx]).toFixed(2) + ' ' + dim_units[track] : 'Index: ' + t_idx", | ||
| ), | ||
| model_value=("t_idx",), | ||
| update_modelValue=( | ||
| self.on_update_slider, | ||
| "[track, $event]", | ||
| ), | ||
| min=0, | ||
| max=("t_values.length - 1",), | ||
| step=1, | ||
| show_ticks="always", | ||
| hide_details=True, | ||
| density="compact", | ||
| style="min-width: 200px; max-width: 400px;", | ||
| ) | ||
| # Index label (shown when collapsed) | ||
| v3.VLabel( | ||
| "{{track}}", | ||
| classes="text-subtitle-2 ml-2 mt-1", | ||
| v_if="expanded_slice_track !== track", | ||
| v_html="'<b>(' + t_idx + ')</b>'", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow, are you sure you want to write that in this fashion? |
||
| style="opacity: 1; color: rgba(0,0,0,0.87);", | ||
| ) | ||
| # Value + units label | ||
| v3.VLabel( | ||
| "{{ dim_units[track] ? parseFloat(t_values[Number(t_idx)]).toFixed(2) + ' ' + dim_units[track] : 'Index value: ' + t_idx }}", | ||
| classes="text-body-2 text-no-wrap ml-2 mt-1", | ||
| v_if=( | ||
| "dim_units[track] && isNaN(Number(dim_units[track]))", | ||
| ), | ||
| v_html=( | ||
| "'<i style=\\x27opacity:0.5\\x27>' + parseFloat(t_values[t_idx]).toFixed(2) + ' ' + dim_units[track] + '</i>'", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow, are you sure you want to write that in this fashion? |
||
| ), | ||
| style="opacity: 1; color: rgba(0,0,0,0.87);", | ||
| ) | ||
|
|
||
| def on_update_slider(self, dimension, index, *_, **__): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still bother keeping track of SIZES and top_padding if they are not used anymore?
Let's clean the code rather than keeping dead code around.