Skip to content

Commit 58389e5

Browse files
committed
fix(topPadding): better size handling
1 parent d0bbec7 commit 58389e5

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

src/e3sm_quickview/app2.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def _build_ui(self, **_):
127127
ProjectionEquidistant="projection = ['Cyl. Equidistant']",
128128
ProjectionRobinson="projection = ['Robinson']",
129129
ProjectionMollweide="projection = ['Mollweide']",
130+
ToggleViewLock="lock_views = !lock_views",
130131
) as mt:
131132
mt.bind(["r"], "ResetCamera")
132133
mt.bind(["alt+0", "0"], "SizeAuto")
@@ -146,7 +147,9 @@ def _build_ui(self, **_):
146147
mt.bind("f", "ToolbarAnimation")
147148
mt.bind("g", "ToggleGroups")
148149

149-
mt.bind("space", "ToggleVariableSelection")
150+
mt.bind("?", "ToggleVariableSelection")
151+
152+
mt.bind("space", "ToggleViewLock", stop_propagation=True)
150153

151154
mt.bind("esc", "RemoveAllToolbars")
152155

@@ -163,12 +166,7 @@ def _build_ui(self, **_):
163166
with v3.VContainer(classes="h-100 pa-0", fluid=True):
164167
with client.SizeObserver("main_size"):
165168
# Take space to push content below the fixed overlay
166-
for value in toolbars.VALUES:
167-
v3.VToolbar(
168-
v_show=js.is_active(value),
169-
density=toolbars.DENSITY[value],
170-
**toolbars.DEFAULT_STYLES,
171-
)
169+
html.Div(style=("`height: ${top_padding}px`",))
172170

173171
# Fixed overlay for toolbars
174172
with html.Div(style=css.TOOLBARS_FIXED_OVERLAY):
@@ -432,6 +430,14 @@ async def _on_projection(self, projection, **_):
432430
await asyncio.sleep(0.1)
433431
self.view_manager.reset_camera()
434432

433+
@change("active_tools")
434+
def _on_toolbar_change(self, active_tools, **_):
435+
top_padding = 0
436+
for name in active_tools:
437+
top_padding += toolbars.SIZES.get(name, 0)
438+
439+
self.state.top_padding = top_padding
440+
435441
@change(
436442
"variables_loaded",
437443
"time_idx",

src/e3sm_quickview/components/doc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self):
3838
""",
3939
)
4040
with self, v3.Template(v_slot_append=True):
41-
v3.VHotkey(keys="space", variant="contained", inline=True)
41+
v3.VHotkey(keys="?", variant="contained", inline=True)
4242

4343

4444
class ToolResetCamera(Tool):
@@ -215,6 +215,11 @@ def __init__(self):
215215
v3.VSpacer()
216216
v3.VHotkey(keys="r", variant="contained", inline=True)
217217

218+
with v3.VRow(classes="ma-0 pb-4"):
219+
v3.VLabel("Toggle view interaction lock")
220+
v3.VSpacer()
221+
v3.VHotkey(keys="space", variant="contained", inline=True)
222+
218223
v3.VDivider(classes="mb-4")
219224

220225
with v3.VRow(classes="ma-0 pb-4"):
@@ -244,7 +249,7 @@ def __init__(self):
244249
with v3.VRow(classes="ma-0 pb-4"):
245250
v3.VLabel("Toggle variable selection drawer")
246251
v3.VSpacer()
247-
v3.VHotkey(keys="space", variant="contained", inline=True)
252+
v3.VHotkey(keys="?", variant="contained", inline=True)
248253

249254
v3.VDivider(classes="mb-4")
250255

src/e3sm_quickview/components/toolbars.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
"animation-controls": "compact",
1414
}
1515

16+
SIZES = {
17+
"adjust-layout": 49,
18+
"adjust-databounds": 65,
19+
"select-slice-time": 65,
20+
"animation-controls": 49,
21+
}
22+
1623
VALUES = list(DENSITY.keys())
1724

1825
DEFAULT_STYLES = {

src/e3sm_quickview/view_manager2.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def _build_ui(self):
183183
self.ui.root.classes = "h-100"
184184
with v3.VCard(
185185
variant="tonal",
186-
classes=(
187-
"active_layout !== 'auto_layout' ? 'h-100' : 'overflow-hidden'",
186+
style=(
187+
"active_layout !== 'auto_layout' ? `height: calc(100% - ${top_padding}px;` : 'overflow-hidden'",
188188
),
189189
tile=("active_layout !== 'auto_layout'",),
190190
):
@@ -312,6 +312,12 @@ def _build_ui(self):
312312
),
313313
)
314314

315+
v3.VIcon(
316+
"mdi-lock-outline",
317+
size="x-small",
318+
v_show=("lock_views", False),
319+
)
320+
315321
v3.VSpacer()
316322
html.Div(
317323
"t = {{ time_idx }}",
@@ -344,6 +350,7 @@ def _build_ui(self):
344350
{
345351
aspectRatio: active_layout === 'auto_layout' ? aspect_ratio : null,
346352
height: active_layout !== 'auto_layout' ? 'calc(100% - 2.4rem)' : null,
353+
pointerEvents: lock_views ? 'none': null,
347354
}
348355
""",
349356
),

0 commit comments

Comments
 (0)