From a51a54bc5979a2491f152abc47ad54e6b63f27c8 Mon Sep 17 00:00:00 2001 From: Dylam De La Torre Date: Tue, 23 Nov 2021 05:21:56 +0100 Subject: Restructure source and resource files (#46) importantly, res is now res/res and css is now res/css --- src/components/draglistbox.hpp | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/components/draglistbox.hpp (limited to 'src/components/draglistbox.hpp') diff --git a/src/components/draglistbox.hpp b/src/components/draglistbox.hpp new file mode 100644 index 0000000..9f204be --- /dev/null +++ b/src/components/draglistbox.hpp @@ -0,0 +1,45 @@ +#pragma once +#include + +class DragListBox : public Gtk::ListBox { +public: + DragListBox(); + + void row_drag_begin(Gtk::Widget *widget, const Glib::RefPtr &context); + + bool on_drag_motion(const Glib::RefPtr &context, gint x, gint y, guint time) override; + + void on_drag_leave(const Glib::RefPtr &context, guint time) override; + + void check_scroll(gint y); + + bool scroll(); + + void on_drag_data_received(const Glib::RefPtr &context, int x, int y, const Gtk::SelectionData &selection_data, guint info, guint time) override; + + void add_draggable(Gtk::ListBoxRow *widget); + +private: + Gtk::ListBoxRow *m_hover_row = nullptr; + Gtk::ListBoxRow *m_drag_row = nullptr; + bool m_top = false; + int m_hover_top = 0; + int m_hover_bottom = 0; + bool m_should_scroll = false; + bool m_scrolling = false; + bool m_scroll_up = false; + + constexpr static int SCROLL_STEP_SIZE = 8; + constexpr static int SCROLL_DISTANCE = 30; + constexpr static int SCROLL_DELAY = 50; + + const std::vector m_entries = { + Gtk::TargetEntry("GTK_LIST_BOX_ROW", Gtk::TARGET_SAME_APP, 0), + }; + + using type_signal_on_drop = sigc::signal; + type_signal_on_drop m_signal_on_drop; + +public: + type_signal_on_drop signal_on_drop(); // return true to prevent drop +}; -- cgit v1.2.3