Exemple #1
0
static gboolean _lib_histogram_scroll_callback(GtkWidget *widget, GdkEventScroll *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;

    float cw = dt_dev_exposure_get_white(darktable.develop);
    float cb = dt_dev_exposure_get_black(darktable.develop);

    if(event->direction == GDK_SCROLL_UP && d->highlight == 2)
        dt_dev_exposure_set_white(darktable.develop, cw - 0.1);

    if(event->direction == GDK_SCROLL_DOWN && d->highlight == 2)
        dt_dev_exposure_set_white(darktable.develop, cw + 0.1);

    if(event->direction == GDK_SCROLL_UP && d->highlight == 1)
        dt_dev_exposure_set_black(darktable.develop, cb - 0.001);

    if(event->direction == GDK_SCROLL_DOWN && d->highlight == 1)
        dt_dev_exposure_set_black(darktable.develop, cb + 0.001);

    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;
}
Exemple #3
0
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 white = d->white - (event->x - d->button_down_x) * 1.0f / (float)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)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;
}