static gboolean _lib_histogram_button_press_callback(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_histogram_t *d = (dt_lib_histogram_t *)self->data; /* check if exposure hooks are available */ gboolean hooks_available = dt_dev_exposure_hooks_available(darktable.develop); if(!hooks_available) return TRUE; if(event->type == GDK_2BUTTON_PRESS) { dt_dev_exposure_reset_defaults(darktable.develop); } else { d->dragging = 1; if(d->highlight == 2) d->white = dt_dev_exposure_get_white(darktable.develop); if(d->highlight == 1) d->black = dt_dev_exposure_get_black(darktable.develop); d->button_down_x = event->x; d->button_down_y = event->y; } return TRUE; }
static gboolean _lib_histogram_button_press_callback(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_histogram_t *d = (dt_lib_histogram_t *)self->data; /* check if exposure hooks are available */ gboolean hooks_available = dt_dev_exposure_hooks_available(darktable.develop); if(!hooks_available) return TRUE; if(event->type == GDK_2BUTTON_PRESS) { dt_dev_exposure_reset_defaults(darktable.develop); } else { if(d->highlight == 3) // mode button { darktable.develop->histogram_type = (darktable.develop->histogram_type + 1) % DT_DEV_HISTOGRAM_N; dt_conf_set_string("plugins/darkroom/histogram/mode", dt_dev_histogram_type_names[darktable.develop->histogram_type]); } else if(d->highlight == 4) // red button { d->red = !d->red; dt_conf_set_bool("plugins/darkroom/histogram/show_red", d->red); } else if(d->highlight == 5) // green button { d->green = !d->green; dt_conf_set_bool("plugins/darkroom/histogram/show_green", d->green); } else if(d->highlight == 6) // blue button { d->blue = !d->blue; dt_conf_set_bool("plugins/darkroom/histogram/show_blue", d->blue); } else { d->dragging = 1; if(d->highlight == 2) d->white = dt_dev_exposure_get_white(darktable.develop); if(d->highlight == 1) d->black = dt_dev_exposure_get_black(darktable.develop); d->button_down_x = event->x; d->button_down_y = event->y; } } // update for good measure dt_control_queue_redraw_widget(self->widget); return TRUE; }
static gboolean _lib_histogram_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_histogram_t *d = (dt_lib_histogram_t *)self->data; /* check if exposure hooks are available */ gboolean hooks_available = dt_dev_exposure_hooks_available(darktable.develop); if(!hooks_available) return TRUE; if (d->dragging && d->highlight == 2) { float white = d->white - (event->x - d->button_down_x)* 1.0f/(float)widget->allocation.width; dt_dev_exposure_set_white(darktable.develop, white); } else if(d->dragging && d->highlight == 1) { float black = d->black - (event->x - d->button_down_x)* .1f/(float)widget->allocation.width; dt_dev_exposure_set_black(darktable.develop, black); } else { const float offs = 4*DT_HIST_INSET; const float pos = (event->x-offs)/(float)(widget->allocation.width - 2*offs); if(pos < 0 || pos > 1.0); else if(pos < 0.2) { d->highlight = 1; g_object_set(G_OBJECT(widget), "tooltip-text", _("drag to change black point,\ndoubleclick resets"), (char *)NULL); } else { d->highlight = 2; g_object_set(G_OBJECT(widget), "tooltip-text", _("drag to change exposure,\ndoubleclick resets"), (char *)NULL); } gtk_widget_queue_draw(widget); } gint x, y; // notify gtk for motion_hint. gdk_window_get_pointer(event->window, &x, &y, NULL); return TRUE; }
static gboolean _lib_histogram_motion_notify_callback(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_histogram_t *d = (dt_lib_histogram_t *)self->data; /* check if exposure hooks are available */ gboolean hooks_available = dt_dev_exposure_hooks_available(darktable.develop); if(!hooks_available) return TRUE; GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); if(d->dragging && d->highlight == 2) { float exposure = d->exposure + (event->x - d->button_down_x) * 4.0f / (float)allocation.width; dt_dev_exposure_set_exposure(darktable.develop, exposure); } else if(d->dragging && d->highlight == 1) { float black = d->black - (event->x - d->button_down_x) * .1f / (float)allocation.width; dt_dev_exposure_set_black(darktable.develop, black); } else { const float offs = 4 * DT_HIST_INSET; const float x = event->x - offs; const float y = event->y - DT_HIST_INSET; const float pos = x / (float)(allocation.width - 2 * offs); if(pos < 0 || pos > 1.0) ; else if(x > d->mode_x && x < d->mode_x + d->mode_w && y > d->button_y && y < d->button_y + d->button_h) { d->highlight = 3; switch(darktable.develop->histogram_type) { case DT_DEV_HISTOGRAM_LOGARITHMIC: g_object_set(G_OBJECT(widget), "tooltip-text", _("set histogram mode to linear"), (char *)NULL); break; case DT_DEV_HISTOGRAM_LINEAR: g_object_set(G_OBJECT(widget), "tooltip-text", _("set histogram mode to waveform"), (char *)NULL); break; case DT_DEV_HISTOGRAM_WAVEFORM: g_object_set(G_OBJECT(widget), "tooltip-text", _("set histogram mode to logarithmic"), (char *)NULL); break; case DT_DEV_HISTOGRAM_N: g_assert_not_reached(); } } else if(x > d->red_x && x < d->red_x + d->color_w && y > d->button_y && y < d->button_y + d->button_h) { d->highlight = 4; g_object_set(G_OBJECT(widget), "tooltip-text", d->red ? _("click to hide red channel") : _("click to show red channel"), (char *)NULL); } else if(x > d->green_x && x < d->green_x + d->color_w && y > d->button_y && y < d->button_y + d->button_h) { d->highlight = 5; g_object_set(G_OBJECT(widget), "tooltip-text", d->red ? _("click to hide green channel") : _("click to show green channel"), (char *)NULL); } else if(x > d->blue_x && x < d->blue_x + d->color_w && y > d->button_y && y < d->button_y + d->button_h) { d->highlight = 6; g_object_set(G_OBJECT(widget), "tooltip-text", d->red ? _("click to hide blue channel") : _("click to show blue channel"), (char *)NULL); } else if(pos < 0.2) { d->highlight = 1; g_object_set(G_OBJECT(widget), "tooltip-text", _("drag to change black point,\ndoubleclick resets"), (char *)NULL); } else { d->highlight = 2; g_object_set(G_OBJECT(widget), "tooltip-text", _("drag to change exposure,\ndoubleclick resets"), (char *)NULL); } gtk_widget_queue_draw(widget); } gint x, y; // notify gtk for motion_hint. gdk_window_get_device_position(event->window, gdk_device_manager_get_client_pointer( gdk_display_get_device_manager(gdk_window_get_display(event->window))), &x, &y, NULL); return TRUE; }