Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce dt_iop_has_focus() #17882

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/develop/blend.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,7 @@ void dt_develop_blend_process(dt_iop_module_t *self,
const dt_iop_roi_t *const roi_in,
const dt_iop_roi_t *const roi_out)
{
if(piece->pipe->bypass_blendif
&& self->dev->gui_attached
&& (self == self->dev->gui_module))
if(piece->pipe->bypass_blendif && dt_iop_has_focus(self))
return;

const dt_develop_blend_params_t *const d = piece->blendop_data;
Expand Down Expand Up @@ -545,10 +543,7 @@ void dt_develop_blend_process(dt_iop_module_t *self,
return;
}

const gboolean valid_request =
self->dev->gui_attached
&& (self == self->dev->gui_module)
&& (piece->pipe == self->dev->full.pipe);
const gboolean valid_request = dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe);

// does user want us to display a specific channel?
const dt_dev_pixelpipe_display_mask_t request_mask_display =
Expand Down Expand Up @@ -934,9 +929,7 @@ gboolean dt_develop_blend_process_cl(dt_iop_module_t *self,
const dt_iop_roi_t *roi_in,
const dt_iop_roi_t *roi_out)
{
if(piece->pipe->bypass_blendif
&& self->dev->gui_attached
&& (self == self->dev->gui_module))
if(piece->pipe->bypass_blendif && dt_iop_has_focus(self))
return TRUE;

dt_develop_blend_params_t *const d = piece->blendop_data;
Expand Down Expand Up @@ -971,10 +964,7 @@ gboolean dt_develop_blend_process_cl(dt_iop_module_t *self,
// only non-zero if mask_display was set by an _earlier_ module
const dt_dev_pixelpipe_display_mask_t mask_display = piece->pipe->mask_display;

const gboolean valid_request =
self->dev->gui_attached
&& (self == self->dev->gui_module)
&& (piece->pipe == self->dev->full.pipe);
const gboolean valid_request = dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe);

// does user want us to display a specific channel?
const dt_dev_pixelpipe_display_mask_t request_mask_display =
Expand Down
9 changes: 9 additions & 0 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,15 @@ static gboolean _presets_scroll_callback(GtkWidget *widget,
return TRUE;
}

gboolean dt_iop_has_focus(dt_iop_module_t *module)
{
return module
&& module->dev
&& module->dev->gui_attached
&& module == module->dev->gui_module
&& dt_dev_modulegroups_test_activated(darktable.develop);
}

void dt_iop_request_focus(dt_iop_module_t *module)
{
dt_develop_t *dev = darktable.develop;
Expand Down
2 changes: 2 additions & 0 deletions src/develop/imageop.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ GtkWidget *dt_iop_gui_header_button(dt_iop_module_t *module,

/** requests the focus for this plugin (to draw overlays over the center image) */
void dt_iop_request_focus(dt_iop_module_t *module);
/** returns TRUE if tested module has focus */
gboolean dt_iop_has_focus(dt_iop_module_t *module);
/** allocate and load default settings from introspection. */
void dt_iop_default_init(dt_iop_module_t *module);
/** loads default settings from database. */
Expand Down
13 changes: 3 additions & 10 deletions src/iop/ashift.c
Original file line number Diff line number Diff line change
Expand Up @@ -4054,13 +4054,6 @@ static gboolean _get_points(dt_iop_module_t *self,
return FALSE;
}

// does this gui have focus?
static gboolean _gui_has_focus(dt_iop_module_t *self)
{
return (self->dev->gui_module == self
&& dt_dev_modulegroups_test_activated(darktable.develop));
}

/* this function replaces this sentence, it calls distort_transform()
for this module on the pipe
if(!dt_dev_distort_transform_plus(self->dev, self->dev->preview_pipe,
Expand Down Expand Up @@ -4154,7 +4147,7 @@ void gui_post_expose(dt_iop_module_t *self,

// we draw the cropping area; we need x_off/y_off/width/height which is only available
// after g->buf has been processed
if(g->buf && self->enabled && _gui_has_focus(self))
if(g->buf && self->enabled && dt_iop_has_focus(self))
{
// roi data of the preview pipe input buffer

Expand Down Expand Up @@ -4354,7 +4347,7 @@ void gui_post_expose(dt_iop_module_t *self,
if(g->fitting) return;

// no structural data or visibility switched off? -> stop here
if(g->lines == NULL || !_gui_has_focus(self)) return;
if(g->lines == NULL || !dt_iop_has_focus(self)) return;

// get hash value that reflects distortions from here to the end of the pixelpipe
const dt_hash_t hash = dt_dev_hash_distort_plus(dev,
Expand Down Expand Up @@ -5630,7 +5623,7 @@ void commit_params(dt_iop_module_t *self,
d->orthocorr = (p->mode == ASHIFT_MODE_GENERIC) ? 0.0f : p->orthocorr;
d->aspect = (p->mode == ASHIFT_MODE_GENERIC) ? 1.0f : p->aspect;

if(_gui_has_focus(self)
if(dt_iop_has_focus(self)
|| dt_isnan(p->cl)
|| dt_isnan(p->cr)
|| dt_isnan(p->ct)
Expand Down
8 changes: 1 addition & 7 deletions src/iop/clipping.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,6 @@ dt_iop_colorspace_type_t default_colorspace(dt_iop_module_t *self,
return IOP_CS_RGB;
}

static int gui_has_focus(dt_iop_module_t *self)
{
return (self->dev->gui_module == self
&& dt_dev_modulegroups_test_activated(darktable.develop));
}

static void keystone_get_matrix(const dt_boundingbox_t k_space, float kxa, float kxb, float kxc, float kxd, float kya,
float kyb, float kyc, float kyd, float *a, float *b, float *d, float *e,
float *g, float *h)
Expand Down Expand Up @@ -1328,7 +1322,7 @@ void commit_params(dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_
d->k_apply = 0;
}

if(gui_has_focus(self))
if(dt_iop_has_focus(self))
{
d->cx = 0.0f;
d->cy = 0.0f;
Expand Down
2 changes: 1 addition & 1 deletion src/iop/colorequal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2537,7 +2537,7 @@ static gboolean _iop_colorequalizer_draw(GtkWidget *widget,

dt_free_align(g->LUT);

if(self->enabled && (self == self->dev->gui_module) && g->picking)
if(self->enabled && dt_iop_has_focus(self) && g->picking)
_draw_color_picker(self, cr, p, g, (double)graph_width, (double)graph_height);

cairo_restore(cr);
Expand Down
7 changes: 4 additions & 3 deletions src/iop/colorzones.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,9 @@ void process(dt_iop_module_t *self,
// display selection if requested
if((piece->pipe->type & DT_DEV_PIXELPIPE_FULL)
&& g
&& g->display_mask && self->dev->gui_attached
&& (self == self->dev->gui_module) && (piece->pipe == self->dev->full.pipe))
&& g->display_mask
&& dt_iop_has_focus(self)
&& (piece->pipe == self->dev->full.pipe))
process_display(self, piece, ivoid, ovoid, roi_in, roi_out);
else if(d->mode == DT_IOP_COLORZONES_MODE_SMOOTH)
process_v3(self, piece, ivoid, ovoid, roi_in, roi_out);
Expand All @@ -604,7 +605,7 @@ int process_cl(dt_iop_module_t *self,
dt_iop_colorzones_data_t *d = piece->data;
dt_iop_colorzones_global_data_t *gd = self->global_data;
cl_mem dev_L, dev_a, dev_b = NULL;
cl_int err = DT_OPENCL_DEFAULT_ERROR;
cl_int err = CL_MEM_OBJECT_ALLOCATION_FAILURE;

const int devid = piece->pipe->devid;
const int width = roi_in->width;
Expand Down
8 changes: 1 addition & 7 deletions src/iop/crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ dt_iop_colorspace_type_t default_colorspace(dt_iop_module_t *self,
return IOP_CS_RGB;
}

static int _gui_has_focus(dt_iop_module_t *self)
{
return (self->dev->gui_module == self
&& dt_dev_modulegroups_test_activated(darktable.develop));
}

static void _commit_box(dt_iop_module_t *self,
dt_iop_crop_gui_data_t *g,
dt_iop_crop_params_t *p)
Expand Down Expand Up @@ -421,7 +415,7 @@ void commit_params(dt_iop_module_t *self,
dt_iop_crop_params_t *p = (dt_iop_crop_params_t *)p1;
dt_iop_crop_data_t *d = piece->data;

if(_gui_has_focus(self) && (pipe->type & DT_DEV_PIXELPIPE_BASIC))
if(dt_iop_has_focus(self) && (pipe->type & DT_DEV_PIXELPIPE_BASIC))
{
d->cx = 0.0f;
d->cy = 0.0f;
Expand Down
2 changes: 0 additions & 2 deletions src/iop/demosaicing/rcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,6 @@ static cl_int process_rcd_cl(dt_iop_module_t *self,
const int width = roi_in->width;
const int height = roi_in->height;

err = CL_MEM_OBJECT_ALLOCATION_FAILURE;

dev_tmp = dt_opencl_alloc_device(devid, roi_in->width, roi_in->height, sizeof(float) * 4);
if(dev_tmp == NULL) goto error;

Expand Down
24 changes: 9 additions & 15 deletions src/iop/retouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -3861,9 +3861,7 @@ void process(dt_iop_module_t *self,
retouch_user_data_t usr_data = { 0 };
dwt_params_t *dwt_p = NULL;

const int gui_active = (self->dev) ? (self == self->dev->gui_module) : 0;
const gboolean display_wavelet_scale =
(g && gui_active) ? g->display_wavelet_scale : FALSE;
const gboolean display_wavelet_scale = g && dt_iop_has_focus(self) ? g->display_wavelet_scale : FALSE;

// we will do all the clone, heal, etc on the input image,
// this way the source for one algorithm can be the destination from a previous one
Expand All @@ -3882,8 +3880,7 @@ void process(dt_iop_module_t *self,
usr_data.mask_display = FALSE;
usr_data.suppress_mask = (g
&& g->suppress_mask
&& self->dev->gui_attached
&& (self == self->dev->gui_module)
&& dt_iop_has_focus(self)
&& (piece->pipe == self->dev->full.pipe));
usr_data.display_scale = p->curr_scale;

Expand All @@ -3899,8 +3896,8 @@ void process(dt_iop_module_t *self,

// check if this module should expose mask.
if((piece->pipe->type & DT_DEV_PIXELPIPE_FULL) && g
&& (g->mask_display || display_wavelet_scale) && self->dev->gui_attached
&& (self == self->dev->gui_module) && (piece->pipe == self->dev->full.pipe))
&& (g->mask_display || display_wavelet_scale)
&& dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe))
{
for(size_t j = 0; j < (size_t)roi_rt->width * roi_rt->height * 4; j += 4)
in_retouch[j + 3] = 0.f;
Expand All @@ -3914,7 +3911,7 @@ void process(dt_iop_module_t *self,
if(piece->pipe->type & DT_DEV_PIXELPIPE_FULL)
{
// check if the image support this number of scales
if(gui_active)
if(dt_iop_has_focus(self))
{
const int max_scales = dwt_get_max_scale(dwt_p);
if(dwt_p->scales > max_scales)
Expand Down Expand Up @@ -4673,8 +4670,7 @@ int process_cl(dt_iop_module_t *self,
retouch_user_data_t usr_data = { 0 };
dwt_params_cl_t *dwt_p = NULL;

const gboolean gui_active = (self->dev) ? (self == self->dev->gui_module) : FALSE;
const gboolean display_wavelet_scale = g && gui_active ? g->display_wavelet_scale : FALSE;
const gboolean display_wavelet_scale = g && dt_iop_has_focus(self) ? g->display_wavelet_scale : FALSE;

// we will do all the clone, heal, etc on the input image, this way
// the source for one algorithm can be the destination from a
Expand All @@ -4698,8 +4694,7 @@ int process_cl(dt_iop_module_t *self,
usr_data.mask_display = FALSE;
usr_data.suppress_mask = (g
&& g->suppress_mask
&& self->dev->gui_attached
&& (self == self->dev->gui_module)
&& dt_iop_has_focus(self)
&& (piece->pipe == self->dev->full.pipe));
usr_data.display_scale = p->curr_scale;

Expand All @@ -4720,8 +4715,7 @@ int process_cl(dt_iop_module_t *self,
// check if this module should expose mask.
if((piece->pipe->type & DT_DEV_PIXELPIPE_FULL)
&& g && g->mask_display
&& self->dev->gui_attached
&& (self == self->dev->gui_module)
&& dt_iop_has_focus(self)
&& (piece->pipe == self->dev->full.pipe))
{
const int kernel = gd->kernel_retouch_clear_alpha;
Expand All @@ -4740,7 +4734,7 @@ int process_cl(dt_iop_module_t *self,
if(piece->pipe->type & DT_DEV_PIXELPIPE_FULL)
{
// check if the image support this number of scales
if(gui_active)
if(dt_iop_has_focus(self))
{
const int max_scales = dwt_get_max_scale_cl(dwt_p);
if(dwt_p->scales > max_scales)
Expand Down
Loading