void gui_init(struct dt_iop_module_t *self) { self->gui_data = malloc(sizeof(dt_iop_channelmixer_gui_data_t)); dt_iop_channelmixer_gui_data_t *g = (dt_iop_channelmixer_gui_data_t *)self->gui_data; dt_iop_channelmixer_params_t *p = (dt_iop_channelmixer_params_t *)self->params; self->widget = GTK_WIDGET(gtk_vbox_new(FALSE, DT_GUI_IOP_MODULE_CONTROL_SPACING)); g->dtlabel1 = DTGTK_LABEL( dtgtk_label_new(_("output channel"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT) ); g->combo1 = GTK_COMBO_BOX( gtk_combo_box_new_text() ); gtk_combo_box_append_text(g->combo1,_("hue")); gtk_combo_box_append_text(g->combo1,_("saturation")); gtk_combo_box_append_text(g->combo1,_("lightness")); gtk_combo_box_append_text(g->combo1,_("red")); gtk_combo_box_append_text(g->combo1,_("green")); gtk_combo_box_append_text(g->combo1,_("blue")); gtk_combo_box_append_text(g->combo1,_("gray")); gtk_combo_box_set_active(g->combo1, CHANNEL_RED ); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->dtlabel1), TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->combo1), TRUE, TRUE, 5); g->dtlabel2 = DTGTK_LABEL( dtgtk_label_new(_("source channels"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT) ); GtkBox *hbox = GTK_BOX( gtk_hbox_new(FALSE, 0)); g->vbox = GTK_VBOX(gtk_vbox_new(FALSE, DT_GUI_IOP_MODULE_CONTROL_SPACING)); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(g->vbox), TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(g->dtlabel2), TRUE, TRUE, 5); g->scale1 = DTGTK_SLIDER(dtgtk_slider_new_with_range(DARKTABLE_SLIDER_BAR,-2.0, 2.0, 0.005, p->red[CHANNEL_RED] , 3)); g_object_set (GTK_OBJECT(g->scale1), "tooltip-text", _("amount of red channel in the output channel"), (char *)NULL); dtgtk_slider_set_label(g->scale1,_("red")); g->scale2 = DTGTK_SLIDER(dtgtk_slider_new_with_range(DARKTABLE_SLIDER_BAR,-2.0, 2.0, 0.005, p->green[CHANNEL_RED] , 3)); g_object_set (GTK_OBJECT(g->scale2), "tooltip-text", _("amount of green channel in the output channel"), (char *)NULL); dtgtk_slider_set_label(g->scale2,_("green")); g->scale3 = DTGTK_SLIDER(dtgtk_slider_new_with_range(DARKTABLE_SLIDER_BAR,-2.0, 2.0, 0.005, p->blue[CHANNEL_RED] , 3)); g_object_set (GTK_OBJECT(g->scale3), "tooltip-text", _("amount of blue channel in the output channel"), (char *)NULL); dtgtk_slider_set_label(g->scale3,_("blue")); gtk_box_pack_start(GTK_BOX(g->vbox), GTK_WIDGET(g->scale1), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(g->vbox), GTK_WIDGET(g->scale2), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(g->vbox), GTK_WIDGET(g->scale3), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 5); g_signal_connect (G_OBJECT (g->scale1), "value-changed", G_CALLBACK (red_callback), self); g_signal_connect (G_OBJECT (g->scale2), "value-changed", G_CALLBACK (green_callback), self); g_signal_connect (G_OBJECT (g->scale3), "value-changed", G_CALLBACK (blue_callback), self); g_signal_connect (G_OBJECT (g->combo1), "changed", G_CALLBACK (output_callback), self); }
static gboolean _label_expose(GtkWidget *widget, GdkEventExpose *event) { g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(DTGTK_IS_LABEL(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); GtkStyle *style=gtk_rc_get_style_by_paths(gtk_settings_get_default(), NULL,"GtkButton", GTK_TYPE_BUTTON); if(!style) style = gtk_rc_get_style(widget); // uninitialized? if(style->depth == -1) return FALSE; int state = gtk_widget_get_state(widget); GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); int x = allocation.x; int y = allocation.y; int width = allocation.width; int height = allocation.height; // Formating the display of text and draw it... PangoLayout *layout; layout = gtk_widget_create_pango_layout(widget,NULL); pango_layout_set_font_description(layout,style->font_desc); const gchar *text=gtk_label_get_text(GTK_LABEL(widget)); pango_layout_set_text(layout,text,-1); GdkRectangle t= {x,y,x+width,y+height}; int pw,ph; pango_layout_get_pixel_size(layout,&pw,&ph); // Begin cairo drawing cairo_t *cr; cr = gdk_cairo_create(gtk_widget_get_window(widget)); cairo_set_source_rgba(cr, /* style->fg[state].red/65535.0, style->fg[state].green/65535.0, style->fg[state].blue/65535.0,*/ 1,1,1, 0.10 ); cairo_set_antialias(cr,CAIRO_ANTIALIAS_NONE); cairo_set_line_width(cr,1.0); cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND); if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_UNDERLINED ) { cairo_move_to(cr,x,y+height-2); cairo_line_to(cr,x+width,y+height-2); cairo_stroke(cr); } else if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_BACKFILLED ) { cairo_rectangle(cr,x,y,width,height); cairo_fill(cr); } else if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_TAB ) { int rx=x,rw=pw+2; if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_ALIGN_RIGHT ) rx=x+width-pw-8; cairo_rectangle(cr,rx,y,rw+4,height-1); cairo_fill(cr); if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_ALIGN_RIGHT ) { // /| cairo_move_to(cr,x+width-rw-6,y); cairo_line_to(cr,x+width-rw-6-15,y+height-2); cairo_line_to(cr,x+width-rw-6,y+height-2); cairo_fill(cr); // hline cairo_move_to(cr,x,y+height-1); cairo_line_to(cr,x+width-rw-6,y+height-1); cairo_stroke(cr); } else { // | cairo_move_to(cr,x+rw+4,y); cairo_line_to(cr,x+rw+4+15,y+height-2); cairo_line_to(cr,x+rw+4,y+height-2); cairo_fill(cr); // hline cairo_move_to(cr,x+rw+4,y+height-1); cairo_line_to(cr,x+width,y+height-1); cairo_stroke(cr); } } cairo_set_antialias(cr,CAIRO_ANTIALIAS_DEFAULT); cairo_destroy(cr); // draw text int lx=x+4, ly=y+((height/2.0)-(ph/2.0)); if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_ALIGN_RIGHT ) lx=x+width-pw-6; else if( DTGTK_LABEL(widget)->flags&DARKTABLE_LABEL_ALIGN_CENTER ) lx=(width/2.0)-(pw/2.0); gtk_paint_layout(style, gtk_widget_get_window(widget), state,TRUE,&t,widget,"label",lx,ly,layout); return FALSE; }