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

✨ keybinds #43

Merged
merged 23 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c627254
✨ adds keybinds for annotation tools
danton267 Jul 14, 2023
8404d03
🔇 remove click logs
danton267 Jul 26, 2023
fa136ff
🔀 Merge branch 'main' of into keybinds
danton267 Jul 31, 2023
00dbcb5
✨ add all new existing controls to keybinds
danton267 Jul 31, 2023
3507f3a
Merge branch 'main' of https://github.com/mlexchange/mlex_highres_seg…
danton267 Aug 2, 2023
8aa51de
♻️ improve code structure
danton267 Aug 2, 2023
f8fa7ee
♻️ ✨ adds notification, simplifies code
danton267 Aug 2, 2023
a5a9465
✨ info hover card about keybinds
danton267 Aug 3, 2023
ef58387
✨ select classs using keybinds
danton267 Aug 3, 2023
2ed9fcf
🔀 Merge branch 'main' into keybinds
danton267 Aug 3, 2023
afb7c1e
🐛 fix functionality when drawer is closed
danton267 Aug 8, 2023
0512c86
✨ adds notification with color
danton267 Aug 8, 2023
03030a6
🔀 Merge branch 'annotation-feature-revamp' in
danton267 Aug 9, 2023
7edd573
🐛 place info card on top
danton267 Aug 9, 2023
bd36732
✨ add notification color label name
danton267 Aug 9, 2023
42e5064
🐛 prevent keybinds from triggering
danton267 Aug 9, 2023
b0d8d8d
✨ delete all annot keybind
danton267 Aug 9, 2023
13b9bcc
🔀 Merge branch 'main' into keybinds
danton267 Aug 10, 2023
bee81d2
✏️ text typos
danton267 Aug 11, 2023
d43d43c
🐛 fix shift, change it to alt keybinding
danton267 Aug 11, 2023
6d40add
🐛 change alt to ctrl
danton267 Aug 11, 2023
c9c3387
🐛 improve control
danton267 Aug 11, 2023
79c582a
🐛 🔥 remove ctrl/shift keybinds
danton267 Aug 11, 2023
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
41 changes: 35 additions & 6 deletions callbacks/control_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
Input("circle", "n_clicks"),
Input("rectangle", "n_clicks"),
Input("drawing-off", "n_clicks"),
Input("keybind-event-listener", "event"),
State("annotation-store", "data"),
prevent_initial_call=True,
)
def annotation_mode(open, closed, circle, rect, off_mode, annotation_store):
def annotation_mode(
open, closed, circle, rect, off_mode, keybind_event_listener, annotation_store
):
"""This callback determines which drawing mode the graph is in"""
if not annotation_store["visible"]:
raise PreventUpdate
Expand All @@ -43,23 +46,49 @@ def annotation_mode(open, closed, circle, rect, off_mode, annotation_store):
rect_style = {"border": "1px solid"}
pan_style = {"border": "1px solid"}

if triggered == "open-freeform" and open > 0:
(
key_open_freeform,
key_closed_freeform,
key_circle,
key_rectangle,
key_drawing_off,
) = (
False,
False,
False,
False,
False,
)
if triggered == "keybind-event-listener":
pressed_key = keybind_event_listener["key"]
if pressed_key == "1":
key_open_freeform = True
elif pressed_key == "2":
key_closed_freeform = True
elif pressed_key == "3":
key_circle = True
elif pressed_key == "4":
key_rectangle = True
elif pressed_key == "5":
key_drawing_off = True

if key_open_freeform or (triggered == "open-freeform" and open > 0):
patched_figure["layout"]["dragmode"] = "drawopenpath"
annotation_store["dragmode"] = "drawopenpath"
open_style = {"border": "3px solid black"}
if triggered == "closed-freeform" and closed > 0:
if key_closed_freeform or (triggered == "closed-freeform" and closed > 0):
patched_figure["layout"]["dragmode"] = "drawclosedpath"
annotation_store["dragmode"] = "drawclosedpath"
close_style = {"border": "3px solid black"}
if triggered == "circle" and circle > 0:
if key_circle or (triggered == "circle" and circle > 0):
patched_figure["layout"]["dragmode"] = "drawcircle"
annotation_store["dragmode"] = "drawcircle"
circle_style = {"border": "3px solid black"}
if triggered == "rectangle" and rect > 0:
if key_rectangle or (triggered == "rectangle" and rect > 0):
patched_figure["layout"]["dragmode"] = "drawrect"
annotation_store["dragmode"] = "drawrect"
rect_style = {"border": "3px solid black"}
if triggered == "drawing-off" and off_mode > 0:
if key_drawing_off or (triggered == "drawing-off" and off_mode > 0):
patched_figure["layout"]["dragmode"] = "pan"
annotation_store["dragmode"] = "pan"
pan_style = {"border": "3px solid black"}
Expand Down
11 changes: 11 additions & 0 deletions components/control_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from dash import html, dcc
from dash_iconify import DashIconify
from utils import data_utils
from dash_extensions import EventListener

COMPONENT_STYLE = {
"width": "25vw",
Expand Down Expand Up @@ -250,5 +251,15 @@ def layout():
),
dcc.Store(id="project-data"),
html.Div(id="dummy-output"),
EventListener(
events=[
{
"event": "keydown",
"props": ["key"],
}
],
logging=True,
danton267 marked this conversation as resolved.
Show resolved Hide resolved
id="keybind-event-listener",
),
],
)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ tiled[client]==0.1.0a96
gunicorn==20.1.0
requests==2.26.0
python-dotenv
dash-extensions==1.0.1