Skip to content

Commit

Permalink
scroll module during d&d even if not valid move
Browse files Browse the repository at this point in the history
  • Loading branch information
dterrahe committed Sep 13, 2024
1 parent 363bbb4 commit f6aee33
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2975,6 +2975,7 @@ GtkWidget *dt_iop_gui_header_button(dt_iop_module_t *module,
static gboolean _on_drag_motion(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint time, dt_iop_module_t *dest)
{
gdk_drag_status(dc, 0, time);
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), time, FALSE, TRUE);

GtkWidget *src_widget = gtk_widget_get_ancestor(gtk_drag_get_source_widget(dc),
DTGTK_TYPE_EXPANDER);
Expand Down Expand Up @@ -3004,7 +3005,7 @@ static gboolean _on_drag_motion(GtkWidget *widget, GdkDragContext *dc, gint x, g
gboolean allow = src->iop_order < dest->iop_order
? dt_ioppr_check_can_move_after_iop(darktable.develop->iop, src, dest)
: dt_ioppr_check_can_move_before_iop(darktable.develop->iop, src, dest);
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), allow, !above);
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), time, allow, !above);
if(allow) gdk_drag_status(dc, GDK_ACTION_COPY, time);
}
else
Expand Down
12 changes: 7 additions & 5 deletions src/dtgtk/expander.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,25 @@ static void _expander_resize(GtkWidget *widget, GdkRectangle *allocation, gpoint
+ dt_conf_get_int("darkroom/ui/transition_duration") * 1000), NULL);
}

void dtgtk_expander_set_drag_hover(GtkDarktableExpander *expander, gboolean hover, gboolean below)
void dtgtk_expander_set_drag_hover(GtkDarktableExpander *expander, guint time, gboolean hover, gboolean below)
{
GtkWidget *widget = expander ? GTK_WIDGET(expander) : _drop_widget;
// don't remove drop zone when switching between last expander and empty space to avoid jitter
static guint hovertime;
guint time = gtk_get_current_event_time();
if(!widget || (!hover && widget == _drop_widget && time == hovertime)) return;

dt_gui_remove_class(widget, "module_drop_after");
dt_gui_remove_class(widget, "module_drop_before");

if(hover)
if(hover || below)
{
_drop_widget = widget;
_last_expanded = NULL;
hovertime = time;

if(below)
if(!hover)
gtk_widget_queue_resize(widget);
else if(below)
dt_gui_add_class(widget, "module_drop_before");
else
dt_gui_add_class(widget, "module_drop_after");
Expand All @@ -211,7 +213,7 @@ static void _expander_drag_leave(GtkDarktableExpander *widget,
guint time,
gpointer user_data)
{
dtgtk_expander_set_drag_hover(widget, FALSE, FALSE);
dtgtk_expander_set_drag_hover(widget, time, FALSE, FALSE);
}

// FIXME: default highlight for the dnd is barely visible
Expand Down
2 changes: 1 addition & 1 deletion src/dtgtk/expander.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GtkWidget *dtgtk_expander_get_body_event_box(GtkDarktableExpander *expander);

void dtgtk_expander_set_expanded(GtkDarktableExpander *expander, gboolean expanded);
gboolean dtgtk_expander_get_expanded(GtkDarktableExpander *expander);
void dtgtk_expander_set_drag_hover(GtkDarktableExpander *expander, gboolean hover, gboolean below);
void dtgtk_expander_set_drag_hover(GtkDarktableExpander *expander, guint time, gboolean hover, gboolean below);

GtkWidget *dtgtk_expander_new(GtkWidget *header, GtkWidget *body);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ static gboolean _on_drag_motion_drop(GtkWidget *empty, GdkDragContext *dc, gint

static void _on_drag_leave(GtkWidget *widget, GdkDragContext *dc, guint time, gpointer user_data)
{
dtgtk_expander_set_drag_hover(NULL, FALSE, FALSE);
dtgtk_expander_set_drag_hover(NULL, time, FALSE, FALSE);
}

static gboolean _remove_modules_visibility(gpointer key,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ static gboolean _on_drag_motion(GtkWidget *widget,
}
else
{
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), FALSE, FALSE);
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), time, FALSE, TRUE);
gdk_drag_status(dc, 0, time);

GtkWidget *src_widget = gtk_widget_get_ancestor(gtk_drag_get_source_widget(dc),
Expand Down Expand Up @@ -1132,7 +1132,7 @@ static gboolean _on_drag_motion(GtkWidget *widget,

if(x != DND_DROP)
{
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), TRUE, below);
dtgtk_expander_set_drag_hover(DTGTK_EXPANDER(widget), time, TRUE, below);
gdk_drag_status(dc, GDK_ACTION_COPY, time);

return TRUE;
Expand Down

0 comments on commit f6aee33

Please sign in to comment.