void gui_init(dt_iop_module_t *self) { self->gui_data = g_malloc(sizeof(dt_iop_invert_gui_data_t)); dt_iop_invert_gui_data_t *g = (dt_iop_invert_gui_data_t *)self->gui_data; dt_iop_invert_params_t *p = (dt_iop_invert_params_t *)self->params; self->widget = gtk_hbox_new(FALSE, 5); GtkWidget *tb; g->label = DTGTK_RESET_LABEL(dtgtk_reset_label_new ("", self, &p->color, 3*sizeof(float))); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->label), TRUE, TRUE, 0); g->pickerbuttons = GTK_HBOX(gtk_hbox_new(FALSE, 5)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->pickerbuttons), TRUE, TRUE, 0); g->colorpicker = DTGTK_BUTTON(dtgtk_button_new(dtgtk_cairo_paint_color, CPF_IGNORE_FG_STATE|CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER)); gtk_widget_set_size_request(GTK_WIDGET(g->colorpicker), 75, 24); g_signal_connect (G_OBJECT (g->colorpicker), "clicked", G_CALLBACK (colorpicker_callback), self); gtk_box_pack_start(GTK_BOX(g->pickerbuttons), GTK_WIDGET(g->colorpicker), TRUE, TRUE, 0); tb = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT); g_object_set(G_OBJECT(tb), "tooltip-text", _("pick color of film material from image"), (char *)NULL); gtk_widget_set_size_request(tb, 24, 24); g_signal_connect(G_OBJECT(tb), "toggled", G_CALLBACK(request_pick_toggled), self); gtk_box_pack_start(GTK_BOX(g->pickerbuttons), tb, TRUE, TRUE, 5); g_signal_connect (G_OBJECT(self->widget), "expose-event", G_CALLBACK(expose), self); }
void gui_update(dt_iop_module_t *self) { self->request_color_pick = DT_REQUEST_COLORPICK_OFF; dt_iop_invert_gui_data_t *g = (dt_iop_invert_gui_data_t *)self->gui_data; dt_iop_invert_params_t *p = (dt_iop_invert_params_t *)self->params; gtk_widget_set_visible(GTK_WIDGET(g->pickerbuttons), TRUE); dtgtk_reset_label_set_text(g->label, _("color of film material")); GdkRGBA color = (GdkRGBA){.red = p->color[0], .green = p->color[1], .blue = p->color[2], .alpha = 1.0 }; gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(g->colorpicker), &color); } void gui_init(dt_iop_module_t *self) { self->gui_data = g_malloc0(sizeof(dt_iop_invert_gui_data_t)); dt_iop_invert_gui_data_t *g = (dt_iop_invert_gui_data_t *)self->gui_data; dt_iop_invert_params_t *p = (dt_iop_invert_params_t *)self->params; self->widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); g->label = DTGTK_RESET_LABEL(dtgtk_reset_label_new("", self, &p->color, 3 * sizeof(float))); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->label), TRUE, TRUE, 0); g->pickerbuttons = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->pickerbuttons), TRUE, TRUE, 0); GdkRGBA color = (GdkRGBA){.red = p->color[0], .green = p->color[1], .blue = p->color[2], .alpha = 1.0 }; g->colorpicker = gtk_color_button_new_with_rgba(&color); gtk_widget_set_size_request(GTK_WIDGET(g->colorpicker), DT_PIXEL_APPLY_DPI(75), DT_PIXEL_APPLY_DPI(24)); gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(g->colorpicker), FALSE); gtk_color_button_set_title(GTK_COLOR_BUTTON(g->colorpicker), _("select color of film material")); g_signal_connect(G_OBJECT(g->colorpicker), "color-set", G_CALLBACK(colorpicker_callback), self); gtk_box_pack_start(GTK_BOX(g->pickerbuttons), GTK_WIDGET(g->colorpicker), TRUE, TRUE, 0); g->picker = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT); g_object_set(G_OBJECT(g->picker), "tooltip-text", _("pick color of film material from image"), (char *)NULL); gtk_widget_set_size_request(g->picker, DT_PIXEL_APPLY_DPI(24), DT_PIXEL_APPLY_DPI(24)); g_signal_connect(G_OBJECT(g->picker), "toggled", G_CALLBACK(request_pick_toggled), self); gtk_box_pack_start(GTK_BOX(g->pickerbuttons), g->picker, TRUE, TRUE, 5); g_signal_connect(G_OBJECT(self->widget), "draw", G_CALLBACK(draw), self); } void gui_cleanup(dt_iop_module_t *self) { g_free(self->gui_data); self->gui_data = NULL; }