Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/bauhaus/bauhaus.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,21 @@ static gboolean _popup_scroll(GtkWidget *widget,
gpointer user_data)
{
dt_bauhaus_widget_t *w = darktable.bauhaus->current;
int delta_y = 0;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
if(w->type == DT_BAUHAUS_COMBOBOX)
{
if(w->type == DT_BAUHAUS_COMBOBOX)
_combobox_next_sensitive(w, delta_y, 0, w->combobox.mute_scrolling);
else
_slider_zoom_range(w, delta_y);
// match keyboard: right & down -> next
int delta_x = 0, delta_y = 0;
if(dt_gui_get_scroll_unit_deltas(event, &delta_x, &delta_y))
{
int delta = abs(delta_x) > abs(delta_y) ? delta_x : delta_y;
_combobox_next_sensitive(w, delta, 0, w->combobox.mute_scrolling);
}
}
else
{
int delta = 0;
if(dt_gui_get_scroll_unit_delta(event, &delta))
_slider_zoom_range(w, delta);
}
return TRUE;
}
Expand Down Expand Up @@ -3087,14 +3095,17 @@ static void _widget_scroll(GtkEventControllerScroll *controller,
{
gtk_widget_grab_focus(widget);

int delta = dx + dy;
if(delta != 0)
int magnitude_x = fabs(dx);
int magnitude_y = fabs(dy);

if(magnitude_x || magnitude_y)
{
dt_bauhaus_widget_t *w = (dt_bauhaus_widget_t *)widget;
_request_focus(w);

if(w->type == DT_BAUHAUS_SLIDER)
{
int delta = magnitude_x > magnitude_y ? -dx : dy;
const gboolean force = darktable.control->element == DT_ACTION_ELEMENT_FORCE
&& event->scroll.window == gtk_widget_get_window(widget);
if(force && dt_modifier_is(event->scroll.state, GDK_SHIFT_MASK | GDK_CONTROL_MASK))
Expand All @@ -3106,7 +3117,12 @@ static void _widget_scroll(GtkEventControllerScroll *controller,
_slider_add_step(widget, - delta, event->scroll.state, force);
}
else
{
// match keyboard: right & down -> next
int delta = magnitude_x > magnitude_y ? dx : dy;

_combobox_next_sensitive(w, delta, 0, FALSE);
}
}
}
if(event) gdk_event_free(event);
Expand Down
10 changes: 7 additions & 3 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2368,9 +2368,13 @@ static gboolean _presets_scroll_callback(GtkWidget *widget,
{
if(dt_gui_ignore_scroll(event)) return FALSE;

int delta_y = 0;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
dt_gui_presets_apply_adjacent_preset(module, delta_y);
// preset cycling: right==down==next
int delta_x = 0, delta_y = 0;
if(dt_gui_get_scroll_unit_deltas(event, &delta_x, &delta_y))
{
const int delta = abs(delta_x) > abs(delta_y) ? delta_x : delta_y;
dt_gui_presets_apply_adjacent_preset(module, delta);
}

return TRUE;
}
Expand Down
17 changes: 11 additions & 6 deletions src/dtgtk/culling.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,11 @@ static gboolean _event_scroll(GtkWidget *widget,
gdouble dx = 0.0, dy = 0.0;
if(dt_gui_get_scroll_deltas(e, &dx, &dy) && (dx != 0.0 || dy != 0.0))
{
// dt_gui_get_scroll_deltas gives the raw fractional platform delta.
// dt_gui_get_scroll_deltas gives the raw fractional platform delta.
// Scale so that one full unit of scroll (delta_y == 1.0) matches the
// 0.5 zoom_delta of a discrete mouse-wheel click.
const float zoom_delta = (float)(-(dx + dy) * 0.5);
// 0.5 zoom_delta of a discrete mouse-wheel click. right==up==zoom-in
const gdouble delta = fabs(dx) > fabs(dy) ? -dx : dy;
const float zoom_delta = (float)(-delta * 0.5);
// convert screen to culling coordinates
int ox = 0, oy = 0;
GdkWindow *win = gtk_widget_get_window(table->widget);
Expand Down Expand Up @@ -750,12 +751,14 @@ static gboolean _event_scroll(GtkWidget *widget,
}
}

int delta;
if(dt_gui_get_scroll_unit_delta(e, &delta))
int delta_x = 0, delta_y = 0;
if(dt_gui_get_scroll_unit_deltas(e, &delta_x, &delta_y))
{
const gboolean is_horizontal = abs(delta_x) > abs(delta_y);
if(dt_modifiers_include(e->state, GDK_CONTROL_MASK))
{
// zooming
// zooming: right==up==zoom-in
const int delta = is_horizontal ? -delta_x : delta_y;
const float zoom_delta = delta < 0 ? 0.5f : -0.5f;
// convert screen to culling coordinates
int ox = 0, oy = 0;
Expand All @@ -775,6 +778,8 @@ static gboolean _event_scroll(GtkWidget *widget,
}
else
{
// navigation: right==down==next
const int delta = is_horizontal ? delta_x : delta_y;
const int move = delta < 0 ? -1 : 1;
dt_print(DT_DEBUG_INPUT, "[culling scroll] navigate move=%d", move);
_thumbs_move(table, move);
Expand Down
6 changes: 4 additions & 2 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ gboolean dt_gui_get_scroll_delta(const GdkEventScroll *event,
gdouble delta_x, delta_y;
if(dt_gui_get_scroll_deltas(event, &delta_x, &delta_y))
{
*delta = delta_x + delta_y;
// treat right like up, left like down
*delta = fabs(delta_x) > fabs(delta_y) ? -delta_x : delta_y;
return TRUE;
}
return FALSE;
Expand All @@ -615,7 +616,8 @@ gboolean dt_gui_get_scroll_unit_delta(const GdkEventScroll *event,
int delta_x, delta_y;
if(dt_gui_get_scroll_unit_deltas(event, &delta_x, &delta_y))
{
*delta = delta_x + delta_y;
// treat right like up, left like down
*delta = abs(delta_x) > abs(delta_y) ? -delta_x : delta_y;
return TRUE;
}
return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ gboolean dt_gui_get_scroll_unit_deltas(const GdkEventScroll *event, int *delta_x
* So if Shift changes scrolling effect, both scrolls should be handled the same.
* For this case (or if it's otherwise useful) use the following 2 functions. */

/* Return sum of scroll deltas from event. Return TRUE if any deltas
/* Return delta of larger magnitude from the event. Return TRUE if any deltas
* can be retrieved. Handles both GDK_SCROLL_UP/DOWN/LEFT/RIGHT and
* GDK_SCROLL_SMOOTH style scroll events. */
gboolean dt_gui_get_scroll_delta(const GdkEventScroll *event, gdouble *delta);
Expand Down
2 changes: 1 addition & 1 deletion src/iop/atrous.c
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ static gboolean area_scrolled(GtkWidget *widget,
int delta_y;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
{
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.25 / BANDS, 1.0);
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.25 / BANDS, 1.0);
gtk_widget_queue_draw(widget);
}
return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/iop/colorzones.c
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ static gboolean _area_scrolled_callback(GtkWidget *widget,
if(g->edit_by_area)
{
const int bands = p->curve_num_nodes[g->channel];
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.2 / bands, 1.0);
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.2 / bands, 1.0);
gtk_widget_queue_draw(widget);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/iop/denoiseprofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3548,7 +3548,7 @@ static gboolean denoiseprofile_scrolled(GtkWidget *widget,
int delta_y;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
{
g->mouse_radius = CLAMP(g->mouse_radius * (1.f + 0.1f * delta_y),
g->mouse_radius = CLAMP(g->mouse_radius * (1.f - 0.1f * delta_y),
0.2f / DT_IOP_DENOISE_PROFILE_BANDS, 1.f);
gtk_widget_queue_draw(widget);
}
Expand Down
2 changes: 1 addition & 1 deletion src/iop/lowlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ static gboolean lowlight_scrolled(GtkWidget *widget, GdkEventScroll *event, dt_i
int delta_y;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
{
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.2 / DT_IOP_LOWLIGHT_BANDS, 1.0);
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.2 / DT_IOP_LOWLIGHT_BANDS, 1.0);
gtk_widget_queue_draw(widget);
}

Expand Down
2 changes: 1 addition & 1 deletion src/iop/monochrome.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ static gboolean _monochrome_scrolled(GtkWidget *widget, GdkEventScroll *event, d
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
{
const float old_size = p->size;
p->size = CLAMP(p->size + delta_y * 0.1, 0.5f, 3.0f);
p->size = CLAMP(p->size - delta_y * 0.1, 0.5f, 3.0f);
if(old_size != p->size) dt_dev_add_history_item(darktable.develop, self, TRUE);
gtk_widget_queue_draw(widget);
}
Expand Down
2 changes: 1 addition & 1 deletion src/iop/rawdenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ static gboolean rawdenoise_scrolled(GtkWidget *widget, GdkEventScroll *event, dt
int delta_y;
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
{
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 + 0.1 * delta_y), 0.2 / DT_IOP_RAWDENOISE_BANDS, 1.0);
g->mouse_radius = CLAMP(g->mouse_radius * (1.0 - 0.1 * delta_y), 0.2 / DT_IOP_RAWDENOISE_BANDS, 1.0);
gtk_widget_queue_draw(widget);
}

Expand Down
7 changes: 4 additions & 3 deletions src/libs/tools/timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,10 +1342,11 @@ static gboolean _lib_timeline_scroll_callback(GtkWidget *w, GdkEventScroll *e, d
}
else
{
int delta;
if(dt_gui_get_scroll_unit_delta(e, &delta))
// timeline panning: right==down==forward
int delta_x = 0, delta_y = 0;
if(dt_gui_get_scroll_unit_deltas(e, &delta_x, &delta_y))
{
int move = delta;
int move = abs(delta_x) > abs(delta_y) ? delta_x : delta_y;
if(dt_modifier_is(e->state, GDK_SHIFT_MASK)) move *= 2;

_time_add(&(strip->time_pos), move, strip->zoom);
Expand Down