Skip to content
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

Viewfinder toggle #137

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -210,6 +210,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 @@ -659,6 +659,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 @@ -711,6 +712,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
Loading