Skip to content

Commit 971ad2c

Browse files
committed
agx: don't activate the pivot pickers until the user starts dragging the mouse, to avoid first picking a pivot based on the whole image
1 parent df1ea2d commit 971ad2c

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

src/gui/color_picker_proxy.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ gboolean dt_iop_color_picker_is_visible(const dt_develop_t *dev)
7373
return module_picker || primary_picker;
7474
}
7575

76+
gboolean dt_iop_color_picker_is_area_empty(const dt_pickerbox_t box)
77+
{
78+
return (fabsf(box[2] - box[0]) < 1e-5f || fabsf(box[3] - box[1]) < 1e-5f);
79+
}
80+
7681
static gboolean _record_point_area(dt_iop_color_picker_t *self)
7782
{
7883
const dt_colorpicker_sample_t *const sample =
@@ -201,7 +206,13 @@ static gboolean _color_picker_callback_button_press(GtkWidget *button,
201206
// pull picker's last recorded positions
202207
if(kind & DT_COLOR_PICKER_AREA)
203208
{
204-
if( self->pick_box[0] == 0.0f && self->pick_box[1] == 0.0f
209+
if(flags & DT_COLOR_PICKER_NO_AUTO)
210+
{
211+
// reset coordinates to 0.0f to create a zero-area box,
212+
// requiring the user to drag-select manually
213+
memset(self->pick_box, 0, sizeof(self->pick_box));
214+
}
215+
else if( self->pick_box[0] == 0.0f && self->pick_box[1] == 0.0f
205216
&& self->pick_box[2] == 1.0f && self->pick_box[3] == 1.0f)
206217
{
207218
dt_boundingbox_t reset = { 0.02f, 0.02f, 0.98f, 0.98f };
@@ -317,6 +328,13 @@ static void _iop_color_picker_pickerdata_ready_callback(gpointer instance,
317328
// iops only need new picker data if the pointer has moved
318329
if(_record_point_area(picker))
319330
{
331+
// in Area mode, ignore updates where the area is empty (e.g. when using DT_COLOR_PICKER_NO_AUTO
332+
// and the user has not started dragging yet)
333+
if((picker->flags & DT_COLOR_PICKER_AREA) && dt_iop_color_picker_is_area_empty(picker->pick_box))
334+
{
335+
return;
336+
}
337+
320338
if(!module->blend_data || !blend_color_picker_apply(module, picker->colorpick, pipe))
321339
{
322340
if(module->color_picker_apply)

src/gui/color_picker_proxy.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ typedef enum _iop_color_picker_flags_t
4040
// only works with 4-channel images
4141
DT_COLOR_PICKER_DENOISE = 1 << 2,
4242
// all pickers sample input, only ones with this flag set sample output
43-
DT_COLOR_PICKER_IO = 1 << 3
43+
DT_COLOR_PICKER_IO = 1 << 3,
44+
// don't auto-expand the area, wait for user selection via dragging
45+
DT_COLOR_PICKER_NO_AUTO = 1 << 4
4446
} dt_iop_color_picker_flags_t;
4547

4648
typedef struct dt_iop_color_picker_t
@@ -71,6 +73,8 @@ typedef struct dt_iop_color_picker_t
7173

7274
gboolean dt_iop_color_picker_is_visible(const dt_develop_t *dev);
7375

76+
gboolean dt_iop_color_picker_is_area_empty(const dt_pickerbox_t box);
77+
7478
//* reset current color picker if not keep-active or not keep */
7579
void dt_iop_color_picker_reset(dt_iop_module_t *module,
7680
const gboolean keep);

src/iop/agx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ static GtkWidget* _create_basic_curve_controls_box(dt_iop_module_t *self,
18151815
dt_iop_basic_curve_controls_t *controls = &g->basic_curve_controls;
18161816

18171817
// curve_pivot_x_relative_ev with picker
1818-
slider = dt_color_picker_new(self, DT_COLOR_PICKER_AREA | DT_COLOR_PICKER_DENOISE, dt_bauhaus_slider_from_params(section, "curve_pivot_x"));
1818+
slider = dt_color_picker_new(self, DT_COLOR_PICKER_AREA | DT_COLOR_PICKER_DENOISE | DT_COLOR_PICKER_NO_AUTO, dt_bauhaus_slider_from_params(section, "curve_pivot_x"));
18191819
controls->curve_pivot_x = slider;
18201820
dt_bauhaus_slider_set_format(slider, _(" EV"));
18211821
dt_bauhaus_slider_set_digits(slider, 2);
@@ -1824,7 +1824,7 @@ static GtkWidget* _create_basic_curve_controls_box(dt_iop_module_t *self,
18241824
"used to set the pivot relative to mid-gray"));
18251825

18261826
// curve_pivot_y_linear
1827-
slider = dt_color_picker_new(self, DT_COLOR_PICKER_AREA | DT_COLOR_PICKER_DENOISE, dt_bauhaus_slider_from_params(section, "curve_pivot_y_linear_output"));
1827+
slider = dt_color_picker_new(self, DT_COLOR_PICKER_AREA | DT_COLOR_PICKER_DENOISE | DT_COLOR_PICKER_NO_AUTO, dt_bauhaus_slider_from_params(section, "curve_pivot_y_linear_output"));
18281828
controls->curve_pivot_y_linear = slider;
18291829
dt_bauhaus_slider_set_format(slider, "%");
18301830
dt_bauhaus_slider_set_digits(slider, 2);

src/views/darkroom.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ static void _darkroom_pickers_draw(dt_view_t *self,
310310
// overlays are aligned with pixels for a clean look
311311
if(sample->size == DT_LIB_COLORPICKER_SIZE_BOX)
312312
{
313+
// do not draw if the area is empty
314+
if(dt_iop_color_picker_is_area_empty(sample->box))
315+
continue;
316+
313317
dt_boundingbox_t fbox;
314318
dt_color_picker_transform_box(dev, 2, sample->box, fbox, FALSE);
315319
x = fbox[0];

0 commit comments

Comments
 (0)