Skip to content

Commit 9fb12ff

Browse files
committed
fix scroll direction: collapse dx/dy to dominant axis, correct radius/size polarity
1 parent cb0eb56 commit 9fb12ff

9 files changed

Lines changed: 35 additions & 17 deletions

File tree

src/bauhaus/bauhaus.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,21 @@ static gboolean _popup_scroll(GtkWidget *widget,
508508
gpointer user_data)
509509
{
510510
dt_bauhaus_widget_t *w = darktable.bauhaus->current;
511-
int delta_y = 0;
512-
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
511+
if(w->type == DT_BAUHAUS_COMBOBOX)
513512
{
514-
if(w->type == DT_BAUHAUS_COMBOBOX)
515-
_combobox_next_sensitive(w, delta_y, 0, w->combobox.mute_scrolling);
516-
else
517-
_slider_zoom_range(w, delta_y);
513+
// match keyboard: right & down -> next
514+
int delta_x = 0, delta_y = 0;
515+
if(dt_gui_get_scroll_unit_deltas(event, &delta_x, &delta_y))
516+
{
517+
int delta = abs(delta_x) > abs(delta_y) ? delta_x : delta_y;
518+
_combobox_next_sensitive(w, delta, 0, w->combobox.mute_scrolling);
519+
}
520+
}
521+
else
522+
{
523+
int delta = 0;
524+
if(dt_gui_get_scroll_unit_delta(event, &delta))
525+
_slider_zoom_range(w, delta);
518526
}
519527
return TRUE;
520528
}
@@ -3087,14 +3095,17 @@ static void _widget_scroll(GtkEventControllerScroll *controller,
30873095
{
30883096
gtk_widget_grab_focus(widget);
30893097

3090-
int delta = dx + dy;
3091-
if(delta != 0)
3098+
int magnitude_x = fabs(dx);
3099+
int magnitude_y = fabs(dy);
3100+
3101+
if(magnitude_x || magnitude_y)
30923102
{
30933103
dt_bauhaus_widget_t *w = (dt_bauhaus_widget_t *)widget;
30943104
_request_focus(w);
30953105

30963106
if(w->type == DT_BAUHAUS_SLIDER)
30973107
{
3108+
int delta = magnitude_x > magnitude_y ? -dx : dy;
30983109
const gboolean force = darktable.control->element == DT_ACTION_ELEMENT_FORCE
30993110
&& event->scroll.window == gtk_widget_get_window(widget);
31003111
if(force && dt_modifier_is(event->scroll.state, GDK_SHIFT_MASK | GDK_CONTROL_MASK))
@@ -3106,7 +3117,12 @@ static void _widget_scroll(GtkEventControllerScroll *controller,
31063117
_slider_add_step(widget, - delta, event->scroll.state, force);
31073118
}
31083119
else
3120+
{
3121+
// match keyboard: right & down -> next
3122+
int delta = magnitude_x > magnitude_y ? dx : dy;
3123+
31093124
_combobox_next_sensitive(w, delta, 0, FALSE);
3125+
}
31103126
}
31113127
}
31123128
if(event) gdk_event_free(event);

src/gui/gtk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ gboolean dt_gui_get_scroll_delta(const GdkEventScroll *event,
603603
gdouble delta_x, delta_y;
604604
if(dt_gui_get_scroll_deltas(event, &delta_x, &delta_y))
605605
{
606-
*delta = delta_x + delta_y;
606+
// treat right like up, left like down
607+
*delta = fabs(delta_x) > fabs(delta_y) ? -delta_x : delta_y;
607608
return TRUE;
608609
}
609610
return FALSE;
@@ -615,7 +616,8 @@ gboolean dt_gui_get_scroll_unit_delta(const GdkEventScroll *event,
615616
int delta_x, delta_y;
616617
if(dt_gui_get_scroll_unit_deltas(event, &delta_x, &delta_y))
617618
{
618-
*delta = delta_x + delta_y;
619+
// treat right like up, left like down
620+
*delta = abs(delta_x) > abs(delta_y) ? -delta_x : delta_y;
619621
return TRUE;
620622
}
621623
return FALSE;

src/gui/gtk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ gboolean dt_gui_get_scroll_unit_deltas(const GdkEventScroll *event, int *delta_x
236236
* So if Shift changes scrolling effect, both scrolls should be handled the same.
237237
* For this case (or if it's otherwise useful) use the following 2 functions. */
238238

239-
/* Return sum of scroll deltas from event. Return TRUE if any deltas
239+
/* Return delta of larger magnitude from the event. Return TRUE if any deltas
240240
* can be retrieved. Handles both GDK_SCROLL_UP/DOWN/LEFT/RIGHT and
241241
* GDK_SCROLL_SMOOTH style scroll events. */
242242
gboolean dt_gui_get_scroll_delta(const GdkEventScroll *event, gdouble *delta);

src/iop/atrous.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ static gboolean area_scrolled(GtkWidget *widget,
15231523
int delta_y;
15241524
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
15251525
{
1526-
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.25 / BANDS, 1.0);
1526+
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.25 / BANDS, 1.0);
15271527
gtk_widget_queue_draw(widget);
15281528
}
15291529
return TRUE;

src/iop/colorzones.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ static gboolean _area_scrolled_callback(GtkWidget *widget,
19061906
if(g->edit_by_area)
19071907
{
19081908
const int bands = p->curve_num_nodes[g->channel];
1909-
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.2 / bands, 1.0);
1909+
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.2 / bands, 1.0);
19101910
gtk_widget_queue_draw(widget);
19111911
}
19121912
else

src/iop/denoiseprofile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3548,7 +3548,7 @@ static gboolean denoiseprofile_scrolled(GtkWidget *widget,
35483548
int delta_y;
35493549
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
35503550
{
3551-
g->mouse_radius = CLAMP(g->mouse_radius * (1.f + 0.1f * delta_y),
3551+
g->mouse_radius = CLAMP(g->mouse_radius * (1.f - 0.1f * delta_y),
35523552
0.2f / DT_IOP_DENOISE_PROFILE_BANDS, 1.f);
35533553
gtk_widget_queue_draw(widget);
35543554
}

src/iop/lowlight.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static gboolean lowlight_scrolled(GtkWidget *widget, GdkEventScroll *event, dt_i
776776
int delta_y;
777777
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
778778
{
779-
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.2 / DT_IOP_LOWLIGHT_BANDS, 1.0);
779+
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.2 / DT_IOP_LOWLIGHT_BANDS, 1.0);
780780
gtk_widget_queue_draw(widget);
781781
}
782782

src/iop/monochrome.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static gboolean _monochrome_scrolled(GtkWidget *widget, GdkEventScroll *event, d
538538
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
539539
{
540540
const float old_size = p->size;
541-
p->size = CLAMP(p->size + delta_y * 0.1, 0.5f, 3.0f);
541+
p->size = CLAMP(p->size - delta_y * 0.1, 0.5f, 3.0f);
542542
if(old_size != p->size) dt_dev_add_history_item(darktable.develop, self, TRUE);
543543
gtk_widget_queue_draw(widget);
544544
}

src/iop/rawdenoise.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ static gboolean rawdenoise_scrolled(GtkWidget *widget, GdkEventScroll *event, dt
857857
int delta_y;
858858
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
859859
{
860-
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.2 / DT_IOP_RAWDENOISE_BANDS, 1.0);
860+
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.2 / DT_IOP_RAWDENOISE_BANDS, 1.0);
861861
gtk_widget_queue_draw(widget);
862862
}
863863

0 commit comments

Comments
 (0)