Skip to content

Commit

Permalink
update label in Area Color Mapping section to reflect whether it is a…
Browse files Browse the repository at this point in the history
…ctive
  • Loading branch information
ralfbrown committed Aug 10, 2024
1 parent 35eddc6 commit a12abd0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4132,6 +4132,7 @@ void dt_gui_new_collapsible_section(dt_gui_collapsible_section_t *cs,
GtkWidget *destdisp_head = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_BAUHAUS_SPACE);
GtkWidget *header_evb = gtk_event_box_new();
GtkWidget *destdisp = dt_ui_section_label_new(label);
cs->label = destdisp;
dt_gui_add_class(destdisp_head, "dt_section_expander");
gtk_container_add(GTK_CONTAINER(header_evb), destdisp);

Expand Down Expand Up @@ -4161,6 +4162,16 @@ void dt_gui_new_collapsible_section(dt_gui_collapsible_section_t *cs,
G_CALLBACK(_collapse_expander_click), cs);
}

void dt_gui_collapsible_section_set_label(dt_gui_collapsible_section_t *cs,
const char *label)
{
if (!cs || !cs->label || !label)
return;
gtk_label_set_text(GTK_LABEL(cs->label), label);
// dt_control_queue_redraw_widget(cs->label);
dt_control_queue_redraw();
}

gboolean dt_gui_long_click(const int second,
const int first)
{
Expand Down
4 changes: 4 additions & 0 deletions src/gui/gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ typedef struct _gui_collapsible_section_t
gchar *confname; // configuration name for the toggle status
GtkWidget *toggle; // toggle button
GtkWidget *expander; // the expanded
GtkWidget *label; // the label containing the section's title text
GtkBox *container; // the container for all widgets into the section
struct dt_action_t *module; // the lib or iop module that contains this section
} dt_gui_collapsible_section_t;
Expand Down Expand Up @@ -514,6 +515,9 @@ void dt_gui_new_collapsible_section(dt_gui_collapsible_section_t *cs,
const char *label,
GtkBox *parent,
struct dt_action_t *module);
// update the collapsible section's label text
void dt_gui_collapsible_section_set_label(dt_gui_collapsible_section_t *cs,
const char *label);
// routine to be called from gui_update
void dt_gui_update_collapsible_section(dt_gui_collapsible_section_t *cs);

Expand Down
16 changes: 15 additions & 1 deletion src/iop/channelmixerrgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,18 @@ void init_presets(dt_iop_module_so_t *self)
self->version(), &p, sizeof(p), 1, DEVELOP_BLEND_CS_RGB_SCENE);
}

static gboolean _area_mapping_active(const dt_iop_channelmixer_rgb_gui_data_t *g)
{
return g && g->spot_mode && dt_bauhaus_combobox_get(g->spot_mode) != DT_SPOT_MODE_MEASURE &&
((g->lightness_spot && dt_bauhaus_slider_get_val(g->lightness_spot) != 50.0f) ||
(g->hue_spot && dt_bauhaus_slider_get_val(g->hue_spot) != 0.0f) ||
(g->chroma_spot && dt_bauhaus_slider_get_val(g->chroma_spot) != 0.0f));
}

static const char *_area_mapping_section_text(const dt_iop_channelmixer_rgb_gui_data_t *g)
{
return _area_mapping_active(g) ? _("area color mapping (active)") : _("area color mapping");
}

static gboolean _get_white_balance_coeff(struct dt_iop_module_t *self,
dt_aligned_pixel_t custom_wb)
Expand Down Expand Up @@ -3872,6 +3884,7 @@ void gui_update(struct dt_iop_module_t *self)
g->last_bb_temperature = d->temperature;

dt_gui_hide_collapsible_section(&g->cs);
dt_gui_collapsible_section_set_label(&g->csspot, _area_mapping_section_text(g));
dt_gui_update_collapsible_section(&g->csspot);

g->spot_RGB[0] = 0.f;
Expand Down Expand Up @@ -4577,7 +4590,7 @@ void gui_init(struct dt_iop_module_t *self)
dt_gui_new_collapsible_section
(&g->csspot,
"plugins/darkroom/channelmixerrgb/expand_picker_mapping",
_("area color mapping"),
_area_mapping_section_text(g),
GTK_BOX(self->widget),
DT_ACTION(self));

Expand Down Expand Up @@ -4685,6 +4698,7 @@ void gui_init(struct dt_iop_module_t *self)
gtk_box_pack_start(GTK_BOX(hhbox), GTK_WIDGET(vvbox), TRUE, TRUE, DT_BAUHAUS_SPACE);

gtk_box_pack_start(GTK_BOX(g->csspot.container), GTK_WIDGET(hhbox), FALSE, FALSE, 0);
dt_gui_collapsible_section_set_label(&g->csspot, _area_mapping_section_text(g));

GtkWidget *first, *second, *third;
#define NOTEBOOK_PAGE(var, short, label, tooltip, section, swap, soft_range, sr_min, sr_max) \
Expand Down

0 comments on commit a12abd0

Please sign in to comment.