diff --git a/src/gui/color_picker_proxy.c b/src/gui/color_picker_proxy.c index e131a8fed818..0b1d343035fb 100644 --- a/src/gui/color_picker_proxy.c +++ b/src/gui/color_picker_proxy.c @@ -73,6 +73,11 @@ gboolean dt_iop_color_picker_is_visible(const dt_develop_t *dev) return module_picker || primary_picker; } +gboolean dt_iop_color_picker_is_area_empty(const dt_pickerbox_t box) +{ + return (fabsf(box[2] - box[0]) < 1e-3f || fabsf(box[3] - box[1]) < 1e-3f); +} + static gboolean _record_point_area(dt_iop_color_picker_t *self) { const dt_colorpicker_sample_t *const sample = @@ -204,8 +209,16 @@ static gboolean _color_picker_callback_button_press(GtkWidget *button, if( self->pick_box[0] == 0.0f && self->pick_box[1] == 0.0f && self->pick_box[2] == 1.0f && self->pick_box[3] == 1.0f) { - dt_boundingbox_t reset = { 0.02f, 0.02f, 0.98f, 0.98f }; - dt_color_picker_backtransform_box(darktable.develop, 2, reset, self->pick_box); + if(flags & DT_COLOR_PICKER_NO_AUTO) + { + // reset coordinates to 0.0f to create a zero-area box, + // requiring the user to drag-select manually + memset(self->pick_box, 0, sizeof(self->pick_box)); + } + else { + dt_boundingbox_t reset = { 0.02f, 0.02f, 0.98f, 0.98f }; + dt_color_picker_backtransform_box(darktable.develop, 2, reset, self->pick_box); + } } dt_lib_colorpicker_set_box_area(darktable.lib, self->pick_box); } @@ -317,6 +330,13 @@ static void _iop_color_picker_pickerdata_ready_callback(gpointer instance, // iops only need new picker data if the pointer has moved if(_record_point_area(picker)) { + // in Area mode, ignore updates where the area is empty (e.g. when using DT_COLOR_PICKER_NO_AUTO + // and the user has not started dragging yet) + if((picker->flags & DT_COLOR_PICKER_AREA) && dt_iop_color_picker_is_area_empty(picker->pick_box)) + { + return; + } + if(!module->blend_data || !blend_color_picker_apply(module, picker->colorpick, pipe)) { if(module->color_picker_apply) diff --git a/src/gui/color_picker_proxy.h b/src/gui/color_picker_proxy.h index 6b58e685daed..7cc0f0454a33 100644 --- a/src/gui/color_picker_proxy.h +++ b/src/gui/color_picker_proxy.h @@ -40,7 +40,9 @@ typedef enum _iop_color_picker_flags_t // only works with 4-channel images DT_COLOR_PICKER_DENOISE = 1 << 2, // all pickers sample input, only ones with this flag set sample output - DT_COLOR_PICKER_IO = 1 << 3 + DT_COLOR_PICKER_IO = 1 << 3, + // don't auto-expand the area, wait for user selection via dragging + DT_COLOR_PICKER_NO_AUTO = 1 << 4 } dt_iop_color_picker_flags_t; typedef struct dt_iop_color_picker_t @@ -71,6 +73,8 @@ typedef struct dt_iop_color_picker_t gboolean dt_iop_color_picker_is_visible(const dt_develop_t *dev); +gboolean dt_iop_color_picker_is_area_empty(const dt_pickerbox_t box); + //* reset current color picker if not keep-active or not keep */ void dt_iop_color_picker_reset(dt_iop_module_t *module, const gboolean keep); diff --git a/src/iop/agx.c b/src/iop/agx.c index 1c1229b7011b..0676dd7be840 100644 --- a/src/iop/agx.c +++ b/src/iop/agx.c @@ -1170,6 +1170,12 @@ static void _read_exposure_params_callback(GtkWidget *widget, // move only the pivot's relative (input) exposure, and recalculate its output based on mid-gray static void _apply_auto_pivot_xy(dt_iop_module_t *self, const dt_iop_order_iccprofile_info_t *profile) { + printf("_apply_auto_pivot_xy, %d\n", darktable.control->button_down); + // don't update while the user is dragging the mouse + if (darktable.control->button_down) { + return; + } + dt_iop_agx_params_t *p = self->params; const dt_iop_agx_gui_data_t *g = self->gui_data; @@ -1824,7 +1830,7 @@ static GtkWidget* _create_basic_curve_controls_box(dt_iop_module_t *self, "used to set the pivot relative to mid-gray")); // curve_pivot_y_linear - 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")); + 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")); controls->curve_pivot_y_linear = slider; dt_bauhaus_slider_set_format(slider, "%"); dt_bauhaus_slider_set_digits(slider, 2); diff --git a/src/views/darkroom.c b/src/views/darkroom.c index 79024b965534..21d487cdb234 100644 --- a/src/views/darkroom.c +++ b/src/views/darkroom.c @@ -310,6 +310,10 @@ static void _darkroom_pickers_draw(dt_view_t *self, // overlays are aligned with pixels for a clean look if(sample->size == DT_LIB_COLORPICKER_SIZE_BOX) { + // do not draw if the area is empty + if(dt_iop_color_picker_is_area_empty(sample->box)) + continue; + dt_boundingbox_t fbox; dt_color_picker_transform_box(dev, 2, sample->box, fbox, FALSE); x = fbox[0]; @@ -3442,6 +3446,10 @@ int button_released(dt_view_t *self, int handled = 0; if(dt_iop_color_picker_is_visible(dev) && which == GDK_BUTTON_PRIMARY) { + // force an update on release so modules can detect the finish event + if(darktable.lib->proxy.colorpicker.picker_proxy) + darktable.lib->proxy.colorpicker.picker_proxy->changed = TRUE; + // only sample box picker at end, for speed if(darktable.lib->proxy.colorpicker.primary_sample->size == DT_LIB_COLORPICKER_SIZE_BOX) {