Skip to content

Commit

Permalink
Merge pull request #137 from mlexchange/viewfinder-toggle
Browse files Browse the repository at this point in the history
Viewfinder toggle
  • Loading branch information
hannahker authored Oct 6, 2023
2 parents 38bde76 + 13861c2 commit db5b0fb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
10 changes: 10 additions & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,14 @@ body {
.mantine-Text-root.mantine-Modal-title {
font-weight: 700 !important;

}

/* used to display viewfinder */
.visible {
display: block;
}

/* used to hide viewfinder */
.hidden {
display: none;
}
11 changes: 11 additions & 0 deletions callbacks/image_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ def keybind_image_slider(
return new_slice, notification


@callback(
Output("image-viewfinder", "className", allow_duplicate=True),
Input("toggle-viewfinder", "checked"),
prevent_initial_call=True,
)
def toggle_viewdinfer(viewfinder_enabled):
if viewfinder_enabled:
return "visible"
return "hidden"


@callback(
Output("image-viewfinder", "figure", allow_duplicate=True),
Input("image-viewer", "relayoutData"),
Expand Down
20 changes: 20 additions & 0 deletions components/control_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ def drawer_section(children):
),
create_reset_view_affix(),
create_info_card_affix(),
create_viewfinder_affix(),
dmc.NotificationsProvider(html.Div(id="notifications-container")),
dcc.Download(id="export-annotation-metadata"),
dcc.Download(id="export-annotation-mask"),
Expand Down Expand Up @@ -737,6 +738,25 @@ def create_reset_view_affix():
)


def create_viewfinder_affix():
return dmc.Affix(
position={"top": 10, "right": 10},
zIndex=9999999,
children=_tooltip(
"Toggle viewfinder",
dmc.Switch(
size="md",
radius="lg",
id="toggle-viewfinder",
checked=True,
onLabel="ON",
offLabel="OFF",
color="gray",
),
),
)


def create_info_card_affix():
return dmc.Affix(
position={"bottom": 20, "right": 20},
Expand Down
5 changes: 2 additions & 3 deletions components/image_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def layout():
"width": "100vw",
"height": "100vh",
"position": "fixed",
"zIndex": 1,
},
),
],
Expand All @@ -49,8 +48,8 @@ def layout():
config={"displayModeBar": False},
style={
"position": "absolute",
"top": "30px",
"right": "10px",
"top": "35px",
"right": "15px",
},
),
],
Expand Down

0 comments on commit db5b0fb

Please sign in to comment.