From b50ffe802f85e58713cf09e232621e77568dd5f0 Mon Sep 17 00:00:00 2001 From: mar77i Date: Mon, 22 Sep 2025 19:45:30 +0200 Subject: [PATCH] integrate draggable in ui library --- create_desktop_file.sh | 11 ++++++++--- keyboard/layout.py | 3 +-- ui/__init__.py | 2 ++ keyboard/draggable.py => ui/draggable_button.py | 7 +++++-- 4 files changed, 16 insertions(+), 7 deletions(-) rename keyboard/draggable.py => ui/draggable_button.py (93%) diff --git a/create_desktop_file.sh b/create_desktop_file.sh index 77dc1ac..c749c43 100755 --- a/create_desktop_file.sh +++ b/create_desktop_file.sh @@ -3,13 +3,14 @@ script_dir="$(realpath -Pe "$(dirname "${0}")")" executable="${script_dir}/zenbook_conf.py" icon="${script_dir}/laptop-single.svg" +name="Zenbook Duo Settings" help() { echo " ${0} [--executable PATH] [--icon PATH] [--virtual-env PATH] | -h|--help" echo "Create a desktop launcher for zenbook_conf.py" echo " --executable PATH specify the executable" echo " --icon PATH specify the icon" - echo " --virtual-env PATH specify a VIRTUAL_ENV path" + echo " --name NAME specify the name" echo " -h | --help show this help message" exit 0 } @@ -26,6 +27,10 @@ while (( $# )); do icon="${2}" shift ;; + --name) + name="${2}" + shift + ;; -h|--help) help=1 ;; @@ -45,6 +50,6 @@ fi echo "[Desktop Entry]" echo "Type=Application" echo "Exec=$(realpath -Pe "${executable}")" -echo "Icon=$(realpath -Pe "${icon}")" +echo "Icon=${icon}" echo "" -echo "Name=Zenbook Duo settings" +echo "Name=${name}" diff --git a/keyboard/layout.py b/keyboard/layout.py index 73c1bc4..6f4f399 100644 --- a/keyboard/layout.py +++ b/keyboard/layout.py @@ -3,10 +3,9 @@ from functools import partial import pygame -from ui import Child, LabelledRect, QuittableModal, Rect +from ui import Child, DraggableButton, LabelledRect, QuittableModal, Rect from .clock import ClockWidget -from .draggable import DraggableButton from .key import apply_y_spans, get_key_size from .mousepad import MousePadWidget from .touchbutton import TouchButton diff --git a/ui/__init__.py b/ui/__init__.py index 8b2ecc1..b664dd1 100644 --- a/ui/__init__.py +++ b/ui/__init__.py @@ -1,6 +1,7 @@ from .button import Button from .child import Child from .color_button import ColorButton +from .draggable_button import DraggableButton from .drop_down import DropDown from .event_method_dispatcher import EventMethodDispatcher from .fps_widget import FPSWidget @@ -24,6 +25,7 @@ __all__ = [ "Button", "Child", "ColorButton", + "DraggableButton", "DropDown", "EventMethodDispatcher", "FloatSpinner", diff --git a/keyboard/draggable.py b/ui/draggable_button.py similarity index 93% rename from keyboard/draggable.py rename to ui/draggable_button.py index c3d76d4..396ed5e 100644 --- a/keyboard/draggable.py +++ b/ui/draggable_button.py @@ -5,14 +5,17 @@ from ui.multitouch import MultitouchHandler class DraggableButton(Child): - def __init__(self, parent, rect, surf, dests, callback, highlight=False): + def __init__(self, parent, rect, surf, dests, callback): + """ + dests is a list of rects, or a tuple (check_func, rect) + that allows defining as drop zone that differs from the actual destination + """ super().__init__(parent) assert rect.size == surf.get_size() self.rect = rect self.surface = surf self.dests = dests self.callback = callback - self.highlight = highlight self.pushed = None self.drag_pos = None self.drag_rel = None -- 2.51.0