Skip to content

Commit 49a94e2

Browse files
authored
Merge pull request #19606 from dterrahe/rotor_fallback
Rotor fallback and <focused> works in QAP
2 parents f18918f + bc783eb commit 49a94e2

File tree

8 files changed

+56
-23
lines changed

8 files changed

+56
-23
lines changed

src/bauhaus/bauhaus.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,7 +3928,7 @@ static float _action_process_combo(gpointer target,
39283928
? DT_VALUE_PATTERN_ACTIVE : 0);
39293929
}
39303930

3931-
static gboolean _find_nth_bauhaus(GtkWidget **w,
3931+
static gboolean _find_nth_bauhaus(gpointer *w,
39323932
int *num,
39333933
const dt_bauhaus_type_t type)
39343934
{
@@ -3961,40 +3961,37 @@ static gboolean _find_nth_bauhaus(GtkWidget **w,
39613961
return *num < 0;
39623962
}
39633963

3964-
static float _action_process_focus_slider(gpointer target,
3964+
static float _action_process_focus_slider(gpointer widget,
39653965
dt_action_element_t element,
39663966
const dt_action_effect_t effect,
39673967
const float move_size)
39683968
{
3969-
GtkWidget *widget = ((dt_iop_module_t *)target)->widget;
39703969
if(_find_nth_bauhaus(&widget, &element, DT_BAUHAUS_SLIDER))
39713970
return _action_process_slider(widget, DT_ACTION_ELEMENT_VALUE, effect, move_size);
39723971

39733972
if(DT_PERFORM_ACTION(move_size))
3974-
dt_action_widget_toast(target, NULL, _("not that many sliders"));
3973+
dt_action_widget_toast(&darktable.control->actions_focus, NULL, _("not that many sliders"));
39753974
return DT_ACTION_NOT_VALID;
39763975
}
39773976

3978-
static float _action_process_focus_combo(gpointer target,
3977+
static float _action_process_focus_combo(gpointer widget,
39793978
dt_action_element_t element,
39803979
const dt_action_effect_t effect,
39813980
const float move_size)
39823981
{
3983-
GtkWidget *widget = ((dt_iop_module_t *)target)->widget;
39843982
if(_find_nth_bauhaus(&widget, &element, DT_BAUHAUS_COMBOBOX))
39853983
return _action_process_combo(widget, DT_ACTION_ELEMENT_SELECTION, effect, move_size);
39863984

39873985
if(DT_PERFORM_ACTION(move_size))
3988-
dt_action_widget_toast(target, NULL, _("not that many dropdowns"));
3986+
dt_action_widget_toast(&darktable.control->actions_focus, NULL, _("not that many dropdowns"));
39893987
return DT_ACTION_NOT_VALID;
39903988
}
39913989

3992-
static float _action_process_focus_button(gpointer target,
3990+
static float _action_process_focus_button(gpointer widget,
39933991
dt_action_element_t element,
39943992
const dt_action_effect_t effect,
39953993
const float move_size)
39963994
{
3997-
GtkWidget *widget = ((dt_iop_module_t *)target)->widget;
39983995
if(_find_nth_bauhaus(&widget, &element, DT_BAUHAUS_BUTTON))
39993996
{
40003997
if(DT_PERFORM_ACTION(move_size))
@@ -4004,7 +4001,7 @@ static float _action_process_focus_button(gpointer target,
40044001
}
40054002

40064003
if(DT_PERFORM_ACTION(move_size))
4007-
dt_action_widget_toast(target, NULL, _("not that many buttons"));
4004+
dt_action_widget_toast(&darktable.control->actions_focus, NULL, _("not that many buttons"));
40084005
return DT_ACTION_NOT_VALID;
40094006
}
40104007

src/gui/accelerators.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3591,6 +3591,33 @@ gboolean dt_action_widget_invisible(GtkWidget *w)
35913591
#define ADD_EXPLANATION(cause, effect, extra, ...) if(*fb_log) \
35923592
dt_util_str_cat(&*fb_log, "\n%s \u2192 %s" extra, cause, effect, ##__VA_ARGS__)
35933593

3594+
static gboolean _unmatched_move(dt_shortcut_t *c,
3595+
dt_shortcut_t *s,
3596+
const dt_action_element_def_t **elements,
3597+
char **fb_log)
3598+
{
3599+
if(c->move == s->move) return FALSE;
3600+
if(!darktable.control->enable_fallbacks ||
3601+
!c->move_device || c->move > s->move) return TRUE; // don't try to match mouse moves
3602+
*elements = _action_find_elements(c->action);
3603+
if(!*elements) return TRUE;
3604+
int skipped = s->move - c->move;
3605+
if((*elements)[c->element].effects == (*elements)[c->element+1].effects)
3606+
s->element = c->element + skipped;
3607+
else
3608+
{
3609+
s->action = c->action;
3610+
dt_action_type_t tp = s->action->type;
3611+
while(skipped && (s->action = s->action->next))
3612+
if(s->action->type == tp) --skipped;
3613+
if(skipped) return TRUE;
3614+
}
3615+
ADD_EXPLANATION(_("move not assigned"), _("fallback to earlier move"), " %d -> %d", s->move, c->move);
3616+
3617+
s->move = c->move;
3618+
return FALSE;
3619+
}
3620+
35943621
static gboolean _shortcut_closest_match(GSequenceIter **current,
35953622
dt_shortcut_t *s,
35963623
gboolean *fully_matched,
@@ -3608,7 +3635,8 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
36083635
c->key != s->key ||
36093636
c->press < (s->press & ~DT_SHORTCUT_LONG) ||
36103637
((c->move_device || c->move) &&
3611-
(c->move_device != s->move_device || c->move != s->move)) ||
3638+
(c->move_device != s->move_device ||
3639+
_unmatched_move(c, s, elements, fb_log))) ||
36123640
(s->action &&
36133641
s->action->type == DT_ACTION_TYPE_FALLBACK &&
36143642
s->action->target != c->action->target))
@@ -3622,7 +3650,6 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
36223650
(c->button != s->button || c->click != s->click)) ||
36233651
(c->mods && c->mods != s->mods) ||
36243652
(c->direction & ~s->direction ) ||
3625-
(c->element && s->element ) ||
36263653
(c->effect > 0 && s->effect > 0 ) ||
36273654
(c->instance && s->instance ) ||
36283655
(c->element && s->effect > 0 && *elements &&
@@ -3645,10 +3672,10 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
36453672
}
36463673
if(!s->action || c->effect != DT_ACTION_EFFECT_DEFAULT_KEY)
36473674
s->effect = c->effect;
3648-
if(c->element) s->element = c->element;
3675+
if(!s->element) s->element = c->element;
36493676
if(c->instance) s->instance = c->instance;
36503677

3651-
s->action = c->action;
3678+
if(!s->action) s->action = c->action;
36523679
if(!*elements) *elements = _action_find_elements(s->action);
36533680

36543681
if(ELEMENT_IS(value, s, *elements) && c->effect == DT_ACTION_EFFECT_SET)
@@ -3780,19 +3807,20 @@ static float _process_action(dt_action_t *action,
37803807
{
37813808
// find module instance
37823809
dt_iop_module_so_t *module = (dt_iop_module_so_t *)owner;
3810+
dt_iop_module_t *mod = NULL;
37833811

37843812
if(owner == &darktable.control->actions_focus)
37853813
{
3786-
action_target = dt_dev_gui_module();
3814+
action_target = dt_dev_modulegroups_test_activated(darktable.develop)
3815+
? (mod = dt_dev_gui_module()) ? (gpointer)mod->widget : NULL
3816+
: dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER);
37873817
if(!action_target)
37883818
return return_value;
37893819
}
37903820
else if(instance)
37913821
{
37923822
int current_instance = abs(instance);
37933823

3794-
dt_iop_module_t *mod = NULL;
3795-
37963824
for(GList *iop_mods = instance >= 0
37973825
? darktable.develop->iop
37983826
: g_list_last(darktable.develop->iop);

src/gui/gtk.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,7 +3676,7 @@ static float _action_process_tabs(const gpointer target,
36763676
static void _find_notebook(GtkWidget *widget,
36773677
GtkWidget **p)
36783678
{
3679-
if(*p) return;
3679+
if(*p || !gtk_widget_get_visible(widget)) return;
36803680
if(GTK_IS_NOTEBOOK(widget))
36813681
*p = widget;
36823682
else if(GTK_IS_CONTAINER(widget))
@@ -3688,14 +3688,14 @@ static float _action_process_focus_tabs(const gpointer target,
36883688
const dt_action_effect_t effect,
36893689
const float move_size)
36903690
{
3691-
GtkWidget *widget = ((dt_iop_module_t *)target)->widget, *notebook = NULL;
3692-
_find_notebook(widget, &notebook);
3691+
GtkWidget *notebook = NULL;
3692+
_find_notebook(target, &notebook);
36933693

36943694
if(notebook)
36953695
return _action_process_tabs(notebook, element, effect, move_size);
36963696

36973697
if(DT_PERFORM_ACTION(move_size))
3698-
dt_action_widget_toast(target, NULL, _("does not contain pages"));
3698+
dt_action_widget_toast(&darktable.control->actions_focus, NULL, _("does not contain pages"));
36993699
return NAN;
37003700
}
37013701

src/iop/atrous.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,8 @@ static float _action_process_equalizer(gpointer target,
16391639
const dt_action_effect_t effect,
16401640
float move_size)
16411641
{
1642+
if(element > BANDS) return DT_ACTION_NOT_VALID;
1643+
16421644
dt_iop_module_t *self = g_object_get_data(G_OBJECT(target), "iop-instance");
16431645
dt_iop_atrous_gui_data_t *g = self->gui_data;
16441646
dt_iop_atrous_params_t *p = self->params;

src/iop/colorequal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,6 +2941,8 @@ static float _action_process_colorequal(const gpointer target,
29412941
const dt_action_effect_t effect,
29422942
const float move_size)
29432943
{
2944+
if(element >= NODES) return DT_ACTION_NOT_VALID;
2945+
29442946
const dt_iop_module_t *self = g_object_get_data(G_OBJECT(target), "iop-instance");
29452947
const dt_iop_colorequal_gui_data_t *g = self->gui_data;
29462948

src/iop/colorzones.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2497,14 +2497,16 @@ static float _action_process_zones(gpointer target,
24972497
dt_action_effect_t effect,
24982498
float move_size)
24992499
{
2500+
if(element >= DT_IOP_COLORZONES_BANDS) return DT_ACTION_NOT_VALID;
2501+
25002502
dt_iop_module_t *self = g_object_get_data(G_OBJECT(target), "iop-instance");
25012503
dt_iop_colorzones_gui_data_t *g = self->gui_data;
25022504
dt_iop_colorzones_params_t *p = self->params;
25032505

25042506
const int ch = g->channel;
25052507
const int nodes = p->curve_num_nodes[ch];
25062508
dt_iop_colorzones_node_t *curve = p->curve[ch];
2507-
const float x = (float)element / 8.0;
2509+
const float x = (float)element / DT_IOP_COLORZONES_BANDS;
25082510

25092511
gboolean close_enough = FALSE;
25102512
int node = 0;

src/iop/rgblevels.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,8 @@ static float _action_process(gpointer target,
969969
const dt_action_effect_t effect,
970970
float move_size)
971971
{
972+
if(element >= DT_IOP_RGBLEVELS_MAX_CHANNELS) return DT_ACTION_NOT_VALID;
973+
972974
dt_iop_module_t *self = g_object_get_data(G_OBJECT(target), "iop-instance");
973975
dt_iop_rgblevels_gui_data_t *g = self->gui_data;
974976
dt_iop_rgblevels_params_t *p = self->params;

src/libs/filters/colors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static gboolean _colors_enter_notify(GtkWidget *widget, GdkEventCrossing *event,
220220

221221
static float _action_process_colors(gpointer target, dt_action_element_t element, dt_action_effect_t effect, float move_size)
222222
{
223-
if(!target) return DT_ACTION_NOT_VALID;
223+
if(!target || element >= DT_COLORLABELS_LAST + 2) return DT_ACTION_NOT_VALID;
224224

225225
_widgets_colors_t *colors = g_object_get_data(G_OBJECT(target), "colors_self");
226226
GtkWidget *w = element ? colors->colors[element - 1] : colors->operator;

0 commit comments

Comments
 (0)