Skip to content

Commit bc783eb

Browse files
committed
midi rotors shortcut fallback via lower assigned one
You only need to assign the first rotor to <focused>/sliders or lua/x-touch/knob 1 and the following ones are automatically assigned in increasing order. Also works for graph nodes.
1 parent 0a470cb commit bc783eb

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

src/gui/accelerators.c

Lines changed: 31 additions & 4 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)

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)