2002-09-08 01:27:32 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2004-06-21 06:04:10 +08:00
|
|
|
|
2002-12-01 22:53:17 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "base/gimphistogram.h"
|
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
#include "gimpcolorbar.h"
|
2002-09-08 01:27:32 +08:00
|
|
|
#include "gimphistogrambox.h"
|
|
|
|
#include "gimphistogramview.h"
|
2003-12-12 01:24:18 +08:00
|
|
|
#include "gimppropwidgets.h"
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
/* #define DEBUG_VIEW */
|
2003-12-12 01:24:18 +08:00
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
#define GRADIENT_HEIGHT 12
|
2004-06-21 04:51:23 +08:00
|
|
|
#define CONTROL_HEIGHT 8
|
|
|
|
|
|
|
|
#define HISTOGRAM_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
2004-06-21 06:04:10 +08:00
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_BUTTON_MOTION_MASK)
|
2002-10-15 09:15:43 +08:00
|
|
|
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
static void gimp_histogram_box_init (GimpHistogramBox *box);
|
2002-10-15 21:36:28 +08:00
|
|
|
|
|
|
|
static void gimp_histogram_box_low_adj_update (GtkAdjustment *adj,
|
|
|
|
GimpHistogramBox *box);
|
|
|
|
static void gimp_histogram_box_high_adj_update (GtkAdjustment *adj,
|
|
|
|
GimpHistogramBox *box);
|
|
|
|
static void gimp_histogram_box_histogram_range (GimpHistogramView *view,
|
|
|
|
gint start,
|
|
|
|
gint end,
|
|
|
|
GimpHistogramBox *box);
|
2004-02-20 03:56:04 +08:00
|
|
|
static void gimp_histogram_box_channel_notify (GimpHistogramView *view,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorBar *bar);
|
|
|
|
static void gimp_histogram_box_border_notify (GimpHistogramView *view,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorBar *bar);
|
2004-06-21 04:51:23 +08:00
|
|
|
static gboolean gimp_histogram_slider_area_event (GtkWidget *widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GimpHistogramBox *box);
|
2004-06-21 04:51:23 +08:00
|
|
|
static gboolean gimp_histogram_slider_area_expose (GtkWidget *widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GimpHistogramBox *box);
|
2004-06-21 04:51:23 +08:00
|
|
|
static void gimp_histogram_draw_slider (GtkWidget *widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
GdkGC *border_gc,
|
|
|
|
GdkGC *fill_gc,
|
|
|
|
gint xpos);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_histogram_box_get_type (void)
|
|
|
|
{
|
|
|
|
static GType box_type = 0;
|
|
|
|
|
|
|
|
if (! box_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo box_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpHistogramBoxClass),
|
2004-06-21 06:04:10 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) NULL,
|
2004-02-20 03:56:04 +08:00
|
|
|
NULL, /* class_finalize */
|
2004-06-21 06:04:10 +08:00
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpHistogramBox),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_histogram_box_init,
|
2002-09-08 01:27:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
box_type = g_type_register_static (GTK_TYPE_VBOX,
|
2003-10-24 14:22:53 +08:00
|
|
|
"GimpHistogramBox",
|
2002-09-08 01:27:32 +08:00
|
|
|
&box_info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return box_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_box_init (GimpHistogramBox *box)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
2004-06-21 04:51:23 +08:00
|
|
|
GtkWidget *vbox;
|
2002-09-08 01:27:32 +08:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkObject *adjustment;
|
|
|
|
GtkWidget *frame;
|
2002-10-15 09:15:43 +08:00
|
|
|
GtkWidget *view;
|
2004-02-20 03:56:04 +08:00
|
|
|
GtkWidget *bar;
|
2004-06-21 04:51:23 +08:00
|
|
|
GtkWidget *slider_area;
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2003-11-02 01:39:09 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (box), 2);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
/* The histogram */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-10-15 09:15:43 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0);
|
2002-09-08 01:27:32 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2003-11-02 01:39:09 +08:00
|
|
|
view = gimp_histogram_view_new (TRUE);
|
2002-10-15 09:15:43 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), view);
|
|
|
|
gtk_widget_show (view);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view, "range_changed",
|
2002-09-08 01:27:32 +08:00
|
|
|
G_CALLBACK (gimp_histogram_box_histogram_range),
|
|
|
|
box);
|
2002-10-15 09:15:43 +08:00
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
box->view = GIMP_HISTOGRAM_VIEW (view);
|
2002-10-15 09:15:43 +08:00
|
|
|
|
|
|
|
/* The gradient below the histogram */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2004-06-21 04:51:23 +08:00
|
|
|
box->slider_area = slider_area = gtk_event_box_new ();
|
|
|
|
gtk_widget_set_size_request (slider_area, -1,
|
|
|
|
GRADIENT_HEIGHT + CONTROL_HEIGHT);
|
|
|
|
gtk_widget_add_events (slider_area, HISTOGRAM_EVENT_MASK);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), slider_area);
|
|
|
|
gtk_widget_show (slider_area);
|
|
|
|
|
|
|
|
g_signal_connect (slider_area, "event",
|
|
|
|
G_CALLBACK (gimp_histogram_slider_area_event),
|
|
|
|
box);
|
|
|
|
g_signal_connect_after (slider_area, "expose_event",
|
|
|
|
G_CALLBACK (gimp_histogram_slider_area_expose),
|
|
|
|
box);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (slider_area), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
bar = g_object_new (GIMP_TYPE_COLOR_BAR,
|
2004-02-21 20:25:09 +08:00
|
|
|
"histogram-channel", box->view->channel,
|
|
|
|
"xpad", box->view->border_width,
|
|
|
|
"ypad", box->view->border_width,
|
2004-02-20 03:56:04 +08:00
|
|
|
NULL);
|
2002-10-15 09:15:43 +08:00
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
gtk_widget_set_size_request (bar,
|
|
|
|
-1,
|
|
|
|
GRADIENT_HEIGHT + 2 * box->view->border_width);
|
2004-06-21 04:51:23 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0);
|
2004-02-20 03:56:04 +08:00
|
|
|
gtk_widget_show (bar);
|
2003-01-26 02:58:45 +08:00
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
g_signal_connect (view, "notify::histogram-channel",
|
|
|
|
G_CALLBACK (gimp_histogram_box_channel_notify),
|
|
|
|
bar);
|
|
|
|
g_signal_connect (view, "notify::border-width",
|
|
|
|
G_CALLBACK (gimp_histogram_box_border_notify),
|
|
|
|
bar);
|
2003-10-24 14:22:53 +08:00
|
|
|
|
|
|
|
/* The range selection */
|
2004-06-03 01:56:02 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
2003-10-24 14:22:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* low spinbutton */
|
|
|
|
spinbutton = gimp_spin_button_new (&adjustment,
|
|
|
|
0.0, 0.0, 255.0, 1.0, 16.0, 0.0,
|
|
|
|
1.0, 0);
|
|
|
|
box->low_adj = GTK_ADJUSTMENT (adjustment);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
g_signal_connect (adjustment, "value_changed",
|
|
|
|
G_CALLBACK (gimp_histogram_box_low_adj_update),
|
|
|
|
box);
|
|
|
|
|
|
|
|
/* high spinbutton */
|
|
|
|
spinbutton = gimp_spin_button_new (&adjustment,
|
|
|
|
255.0, 0.0, 255.0, 1.0, 16.0, 0.0,
|
|
|
|
1.0, 0);
|
|
|
|
box->high_adj = GTK_ADJUSTMENT (adjustment);
|
2004-06-21 04:51:23 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
2003-10-24 14:22:53 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
g_signal_connect (adjustment, "value_changed",
|
|
|
|
G_CALLBACK (gimp_histogram_box_high_adj_update),
|
|
|
|
box);
|
2003-12-12 01:24:18 +08:00
|
|
|
|
|
|
|
#ifdef DEBUG_VIEW
|
|
|
|
spinbutton = gimp_prop_spin_button_new (G_OBJECT (box->view), "border-width",
|
|
|
|
1, 5, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
spinbutton = gimp_prop_spin_button_new (G_OBJECT (box->view), "subdivisions",
|
|
|
|
1, 5, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
#endif
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_box_low_adj_update (GtkAdjustment *adjustment,
|
|
|
|
GimpHistogramBox *box)
|
|
|
|
{
|
2003-11-01 10:39:34 +08:00
|
|
|
if ((gdouble) box->view->start == adjustment->value)
|
2002-10-15 09:15:43 +08:00
|
|
|
return;
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2002-10-15 09:15:43 +08:00
|
|
|
box->high_adj->lower = adjustment->value;
|
|
|
|
gtk_adjustment_changed (box->high_adj);
|
2003-10-24 14:22:53 +08:00
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
gimp_histogram_view_set_range (box->view,
|
|
|
|
adjustment->value, box->view->end);
|
2004-06-21 04:51:23 +08:00
|
|
|
gtk_widget_queue_draw (box->slider_area);
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_box_high_adj_update (GtkAdjustment *adjustment,
|
|
|
|
GimpHistogramBox *box)
|
|
|
|
{
|
2003-11-01 10:39:34 +08:00
|
|
|
if ((gdouble) box->view->end == adjustment->value)
|
2002-10-15 09:15:43 +08:00
|
|
|
return;
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2002-10-15 09:15:43 +08:00
|
|
|
box->low_adj->upper = adjustment->value;
|
|
|
|
gtk_adjustment_changed (box->low_adj);
|
2003-10-24 14:22:53 +08:00
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
gimp_histogram_view_set_range (box->view,
|
|
|
|
box->view->start, adjustment->value);
|
2004-06-21 04:51:23 +08:00
|
|
|
gtk_widget_queue_draw (box->slider_area);
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-02-20 03:56:04 +08:00
|
|
|
gimp_histogram_box_histogram_range (GimpHistogramView *view,
|
2002-09-08 01:27:32 +08:00
|
|
|
gint start,
|
|
|
|
gint end,
|
|
|
|
GimpHistogramBox *box)
|
|
|
|
{
|
|
|
|
box->high_adj->lower = start;
|
|
|
|
box->low_adj->upper = end;
|
|
|
|
gtk_adjustment_changed (box->high_adj);
|
|
|
|
gtk_adjustment_changed (box->low_adj);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (box->low_adj, start);
|
|
|
|
gtk_adjustment_set_value (box->high_adj, end);
|
2004-06-21 04:51:23 +08:00
|
|
|
gtk_widget_queue_draw (box->slider_area);
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
static void
|
2004-02-20 03:56:04 +08:00
|
|
|
gimp_histogram_box_channel_notify (GimpHistogramView *view,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorBar *bar)
|
2002-10-15 21:36:28 +08:00
|
|
|
{
|
2004-02-20 03:56:04 +08:00
|
|
|
gimp_color_bar_set_channel (bar, view->channel);
|
2002-10-15 21:36:28 +08:00
|
|
|
}
|
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_box_border_notify (GimpHistogramView *view,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorBar *bar)
|
2002-10-15 09:15:43 +08:00
|
|
|
{
|
2004-02-20 03:56:04 +08:00
|
|
|
g_object_set (bar,
|
|
|
|
"xpad", view->border_width,
|
|
|
|
"ypad", view->border_width,
|
|
|
|
NULL);
|
2003-10-24 14:22:53 +08:00
|
|
|
|
2004-02-20 03:56:04 +08:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (bar),
|
|
|
|
-1, GRADIENT_HEIGHT + 2 * view->border_width);
|
2002-10-15 09:15:43 +08:00
|
|
|
}
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
GtkWidget *
|
2004-06-21 06:04:10 +08:00
|
|
|
gimp_histogram_box_new (void)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
2004-06-21 06:04:10 +08:00
|
|
|
return GTK_WIDGET (g_object_new (GIMP_TYPE_HISTOGRAM_BOX, NULL));
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
2002-10-15 09:15:43 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_histogram_box_set_channel (GimpHistogramBox *box,
|
|
|
|
GimpHistogramChannel channel)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_HISTOGRAM_BOX (box));
|
|
|
|
|
2003-12-12 01:24:18 +08:00
|
|
|
if (box->view)
|
|
|
|
gimp_histogram_view_set_channel (box->view, channel);
|
2002-10-15 09:15:43 +08:00
|
|
|
}
|
2004-06-21 04:51:23 +08:00
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
static gboolean
|
2004-06-21 04:51:23 +08:00
|
|
|
gimp_histogram_slider_area_event (GtkWidget *widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GimpHistogramBox *box)
|
2004-06-21 04:51:23 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
|
|
|
gint x, distance;
|
|
|
|
gint i;
|
|
|
|
gboolean update = FALSE;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
distance = G_MAXINT;
|
|
|
|
for (i = 0; i < 2; i++)
|
2004-06-21 06:04:10 +08:00
|
|
|
if (fabs (bevent->x - box->slider_pos[i]) < distance)
|
|
|
|
{
|
|
|
|
box->active_slider = i;
|
|
|
|
distance = fabs (bevent->x - box->slider_pos[i]);
|
|
|
|
}
|
2004-06-21 04:51:23 +08:00
|
|
|
|
|
|
|
x = bevent->x;
|
|
|
|
update = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
switch (box->active_slider)
|
2004-06-21 06:04:10 +08:00
|
|
|
{
|
|
|
|
case 3: /* low output */
|
|
|
|
gtk_adjustment_set_value (box->low_adj, box->low_slider_val);
|
|
|
|
break;
|
|
|
|
case 4: /* high output */
|
|
|
|
gtk_adjustment_set_value (box->high_adj, box->high_slider_val);
|
|
|
|
break;
|
|
|
|
}
|
2004-06-21 04:51:23 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
gdk_window_get_pointer (widget->window, &x, NULL, NULL);
|
|
|
|
update = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
{
|
|
|
|
gint width;
|
|
|
|
gint border;
|
|
|
|
|
|
|
|
g_object_get (box->view, "border-width", &border, NULL);
|
|
|
|
|
|
|
|
width = widget->allocation.width - 2 * border;
|
|
|
|
|
|
|
|
if (width < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (box->active_slider)
|
2004-06-21 06:04:10 +08:00
|
|
|
{
|
|
|
|
case 0: /* low output */
|
|
|
|
box->low_adj->value =
|
2004-06-21 04:51:23 +08:00
|
|
|
((gdouble) (x - border) / (gdouble) width) * 255.0;
|
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
box->low_adj->value =
|
2004-06-21 04:51:23 +08:00
|
|
|
CLAMP (box->low_adj->value, 0, 255);
|
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
gimp_histogram_box_low_adj_update (box->low_adj, box);
|
|
|
|
break;
|
2004-06-21 04:51:23 +08:00
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
case 1: /* high output */
|
|
|
|
box->high_adj->value =
|
2004-06-21 04:51:23 +08:00
|
|
|
((gdouble) (x - border) / (gdouble) width) * 255.0;
|
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
box->high_adj->value =
|
2004-06-21 04:51:23 +08:00
|
|
|
CLAMP (box->high_adj->value, 0, 255);
|
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
gimp_histogram_box_high_adj_update (box->high_adj, box);
|
|
|
|
break;
|
|
|
|
}
|
2004-06-21 04:51:23 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-06-21 06:04:10 +08:00
|
|
|
static gboolean
|
2004-06-21 04:51:23 +08:00
|
|
|
gimp_histogram_slider_area_expose (GtkWidget *widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GimpHistogramBox *box)
|
2004-06-21 04:51:23 +08:00
|
|
|
{
|
|
|
|
gint width = widget->allocation.width;
|
|
|
|
gint border;
|
|
|
|
|
|
|
|
g_object_get (box->view, "border-width", &border, NULL);
|
|
|
|
|
|
|
|
width -= 2 * border;
|
|
|
|
|
|
|
|
box->slider_pos[0] = ROUND ((gdouble) width *
|
|
|
|
box->high_adj->lower /
|
|
|
|
256.0) + border;
|
|
|
|
|
|
|
|
box->slider_pos[1] = ROUND ((gdouble) width *
|
|
|
|
box->low_adj->upper /
|
|
|
|
256.0) + border;
|
|
|
|
|
|
|
|
gimp_histogram_draw_slider (widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
widget->style->black_gc,
|
|
|
|
widget->style->black_gc,
|
|
|
|
box->slider_pos[0]);
|
2004-06-21 04:51:23 +08:00
|
|
|
gimp_histogram_draw_slider (widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
widget->style->black_gc,
|
|
|
|
widget->style->white_gc,
|
|
|
|
box->slider_pos[1]);
|
2004-06-21 04:51:23 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_draw_slider (GtkWidget *widget,
|
2004-06-21 06:04:10 +08:00
|
|
|
GdkGC *border_gc,
|
|
|
|
GdkGC *fill_gc,
|
|
|
|
gint xpos)
|
2004-06-21 04:51:23 +08:00
|
|
|
{
|
|
|
|
gint y;
|
|
|
|
|
|
|
|
for (y = 0; y < CONTROL_HEIGHT; y++)
|
|
|
|
gdk_draw_line (widget->window, fill_gc,
|
|
|
|
xpos - y / 2, GRADIENT_HEIGHT + y,
|
|
|
|
xpos + y / 2, GRADIENT_HEIGHT + y);
|
|
|
|
|
|
|
|
gdk_draw_line (widget->window, border_gc,
|
|
|
|
xpos,
|
|
|
|
GRADIENT_HEIGHT,
|
2004-06-21 06:04:10 +08:00
|
|
|
xpos - (CONTROL_HEIGHT - 1) / 2,
|
2004-06-21 04:51:23 +08:00
|
|
|
GRADIENT_HEIGHT + CONTROL_HEIGHT - 1);
|
|
|
|
|
|
|
|
gdk_draw_line (widget->window, border_gc,
|
|
|
|
xpos,
|
|
|
|
GRADIENT_HEIGHT,
|
2004-06-21 06:04:10 +08:00
|
|
|
xpos + (CONTROL_HEIGHT - 1) / 2,
|
2004-06-21 04:51:23 +08:00
|
|
|
GRADIENT_HEIGHT + CONTROL_HEIGHT - 1);
|
|
|
|
|
|
|
|
gdk_draw_line (widget->window, border_gc,
|
|
|
|
xpos - (CONTROL_HEIGHT - 1) / 2,
|
|
|
|
GRADIENT_HEIGHT + CONTROL_HEIGHT - 1,
|
2004-06-21 06:04:10 +08:00
|
|
|
xpos + (CONTROL_HEIGHT - 1) / 2,
|
2004-06-21 04:51:23 +08:00
|
|
|
GRADIENT_HEIGHT + CONTROL_HEIGHT - 1);
|
|
|
|
}
|
|
|
|
|