diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-13 21:43:32 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-13 21:43:32 +0100 |
commit | 3ce80bec97551bbcd850ce3e457fca1c06c48439 (patch) | |
tree | 5723f47ec0204e8b891d14ec67f272899fd4558f /Libraries/LibGUI/Widget.cpp | |
parent | 7590270e138b38960d6f71f1c120808270bf3794 (diff) | |
download | serenity-3ce80bec97551bbcd850ce3e457fca1c06c48439.zip |
WindowServer+LibGUI: Add a "drag move" event
This allows windows/widgets to learn when something is being dragged
over them. They can then repaint themselves somehow to indicate that
they are willing to accept a drop.
Currently this is piggybacking somewhat on the mouse event mechanism
in WindowServer. I'm not sure that's the best design but it seemed
easier to do it this way right now.
Diffstat (limited to 'Libraries/LibGUI/Widget.cpp')
-rw-r--r-- | Libraries/LibGUI/Widget.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp index b4b2ccc084..0997b52773 100644 --- a/Libraries/LibGUI/Widget.cpp +++ b/Libraries/LibGUI/Widget.cpp @@ -26,8 +26,6 @@ #include <AK/Assertions.h> #include <AK/JsonObject.h> -#include <LibGfx/Bitmap.h> -#include <LibGfx/Palette.h> #include <LibGUI/Action.h> #include <LibGUI/Application.h> #include <LibGUI/Button.h> @@ -46,6 +44,8 @@ #include <LibGUI/Widget.h> #include <LibGUI/Window.h> #include <LibGUI/WindowServerConnection.h> +#include <LibGfx/Bitmap.h> +#include <LibGfx/Palette.h> #include <unistd.h> namespace GUI { @@ -182,6 +182,8 @@ void Widget::event(Core::Event& event) return handle_mouseup_event(static_cast<MouseEvent&>(event)); case Event::MouseWheel: return mousewheel_event(static_cast<MouseEvent&>(event)); + case Event::DragMove: + return drag_move_event(static_cast<DragEvent&>(event)); case Event::Drop: return drop_event(static_cast<DropEvent&>(event)); case Event::Enter: @@ -379,6 +381,12 @@ void Widget::change_event(Event&) { } +void Widget::drag_move_event(DragEvent& event) +{ + dbg() << class_name() << "{" << this << "} DRAG MOVE position: " << event.position() << ", data_type: '" << event.data_type() << "'"; + event.ignore(); +} + void Widget::drop_event(DropEvent& event) { dbg() << class_name() << "{" << this << "} DROP position: " << event.position() << ", text: '" << event.text() << "'"; |