Skip to content

Commit 0b7292e

Browse files
committed
agx: new picker flag: DT_COLOR_PICKER_CALLBACK_ONLY_WHEN_DONE; no box around initial point in NO_AUTO mode
1 parent 74c8227 commit 0b7292e

4 files changed

Lines changed: 29 additions & 11 deletions

File tree

src/gui/color_picker_proxy.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ gboolean dt_iop_color_picker_is_visible(const dt_develop_t *dev)
7575

7676
gboolean dt_iop_color_picker_is_area_empty(const dt_pickerbox_t box)
7777
{
78-
return (fabsf(box[2] - box[0]) < 1e-5f || fabsf(box[3] - box[1]) < 1e-5f);
78+
return (fabsf(box[2] - box[0]) < 1e-3f || fabsf(box[3] - box[1]) < 1e-3f);
7979
}
8080

8181
static gboolean _record_point_area(dt_iop_color_picker_t *self)
@@ -325,6 +325,11 @@ static void _iop_color_picker_pickerdata_ready_callback(gpointer instance,
325325
pipe->changed |= DT_DEV_PIPE_REMOVE;
326326
pipe->cache_obsolete = TRUE;
327327

328+
if((picker->flags & DT_COLOR_PICKER_CALLBACK_ONLY_WHEN_DONE) && darktable.control->button_down)
329+
{
330+
return;
331+
}
332+
328333
// iops only need new picker data if the pointer has moved
329334
if(_record_point_area(picker))
330335
{

src/gui/color_picker_proxy.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ typedef enum _iop_color_picker_flags_t
4242
// all pickers sample input, only ones with this flag set sample output
4343
DT_COLOR_PICKER_IO = 1 << 3,
4444
// don't auto-expand the area, wait for user selection via dragging
45-
DT_COLOR_PICKER_NO_AUTO = 1 << 4
45+
DT_COLOR_PICKER_NO_AUTO = 1 << 4,
46+
// only invoke the callback when the user releases the button
47+
DT_COLOR_PICKER_CALLBACK_ONLY_WHEN_DONE = 1 << 5
4648
} dt_iop_color_picker_flags_t;
4749

4850
typedef struct dt_iop_color_picker_t

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_COLOR_PICKER_NO_AUTO, 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_COLOR_PICKER_CALLBACK_ONLY_WHEN_DONE, 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_COLOR_PICKER_NO_AUTO, 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_COLOR_PICKER_CALLBACK_ONLY_WHEN_DONE, 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: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,13 +3550,24 @@ int button_pressed(dt_view_t *self,
35503550
}
35513551
else
35523552
{
3553-
const float dx = 0.02f;
3554-
const float dy = dx * (float)dev->full.pipe->processed_width / (float)dev->full.pipe->processed_height;
3555-
const dt_boundingbox_t fbox = { zoom_x - dx,
3556-
zoom_y - dy,
3557-
zoom_x + dx,
3558-
zoom_y + dy };
3559-
dt_color_picker_backtransform_box(dev, 2, fbox, sample->box);
3553+
dt_iop_color_picker_t *picker = darktable.lib->proxy.colorpicker.picker_proxy;
3554+
3555+
if(picker && (picker->flags & DT_COLOR_PICKER_NO_AUTO))
3556+
{
3557+
// don't create a box around the starting point; the user has to explicitly select an area by dragging
3558+
const dt_boundingbox_t fbox = { zoom_x, zoom_y, zoom_x, zoom_y };
3559+
dt_color_picker_backtransform_box(dev, 2, fbox, sample->box);
3560+
}
3561+
else
3562+
{
3563+
const float dx = 0.02f;
3564+
const float dy = dx * (float)dev->full.pipe->processed_width / (float)dev->full.pipe->processed_height;
3565+
const dt_boundingbox_t fbox = { zoom_x - dx,
3566+
zoom_y - dy,
3567+
zoom_x + dx,
3568+
zoom_y + dy };
3569+
dt_color_picker_backtransform_box(dev, 2, fbox, sample->box);
3570+
}
35603571
}
35613572
dt_control_change_cursor(GDK_FLEUR);
35623573
}

0 commit comments

Comments
 (0)