mirror of https://github.com/GNOME/gimp.git
app/widgets/Makefile.am app/widgets/widgets-types.h added new widget
2004-02-19 Sven Neumann <sven@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpcolorbar.[ch]: added new widget GimpColorBar. * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/widgets/gimphistogrambox.[ch]: use GimpColorBar widgets. * app/widgets/gimpcolorframe.[ch]: fixed typos.
This commit is contained in:
parent
c2b4867b71
commit
924acb2b0d
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2004-02-19 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpcolorbar.[ch]: added new widget GimpColorBar.
|
||||
|
||||
* app/tools/gimpcurvestool.c
|
||||
* app/tools/gimplevelstool.c
|
||||
* app/widgets/gimphistogrambox.[ch]: use GimpColorBar widgets.
|
||||
|
||||
* app/widgets/gimpcolorframe.[ch]: fixed typos.
|
||||
|
||||
2004-02-19 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* themes/Default/images/Makefile.am
|
||||
|
|
|
@ -23,14 +23,8 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
@ -50,6 +44,7 @@
|
|||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpcolorbar.h"
|
||||
#include "widgets/gimpcursor.h"
|
||||
#include "widgets/gimpenummenu.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
@ -64,10 +59,9 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define XRANGE_TOP (1 << 0)
|
||||
#define XRANGE_BOTTOM (1 << 1)
|
||||
#define YRANGE (1 << 2)
|
||||
#define ALL (XRANGE_TOP | XRANGE_BOTTOM | YRANGE)
|
||||
#define XRANGE (1 << 0)
|
||||
#define YRANGE (1 << 1)
|
||||
#define ALL (XRANGE | YRANGE)
|
||||
|
||||
/* NB: take care when changing these values: make sure the curve[] array in
|
||||
* base/curves.h is large enough.
|
||||
|
@ -482,6 +476,8 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
GtkWidget *menu;
|
||||
GtkWidget *table;
|
||||
GtkWidget *button;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *bar;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
|
||||
|
@ -538,8 +534,8 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
GTK_EXPAND, GTK_EXPAND, 0, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
c_tool->yrange = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (c_tool->yrange), YRANGE_WIDTH, YRANGE_HEIGHT);
|
||||
c_tool->yrange = gimp_color_bar_new (GTK_ORIENTATION_VERTICAL);
|
||||
gtk_widget_set_size_request (c_tool->yrange, YRANGE_WIDTH, YRANGE_HEIGHT);
|
||||
gtk_container_add (GTK_CONTAINER (frame), c_tool->yrange);
|
||||
gtk_widget_show (c_tool->yrange);
|
||||
|
||||
|
@ -583,11 +579,20 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
GTK_EXPAND, GTK_EXPAND, 0, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
c_tool->xrange = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (c_tool->xrange), XRANGE_WIDTH, XRANGE_HEIGHT);
|
||||
gtk_container_add (GTK_CONTAINER (frame), c_tool->xrange);
|
||||
vbox2 = gtk_vbox_new (TRUE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox2);
|
||||
gtk_widget_show (vbox2);
|
||||
|
||||
c_tool->xrange = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_widget_set_size_request (c_tool->xrange,
|
||||
XRANGE_WIDTH, XRANGE_HEIGHT / 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), c_tool->xrange, TRUE, TRUE, 0);
|
||||
gtk_widget_show (c_tool->xrange);
|
||||
|
||||
bar = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (bar);
|
||||
|
||||
gtk_widget_show (table);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
|
@ -657,7 +662,7 @@ gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
|
|||
channel++)
|
||||
curves_channel_reset (c_tool->curves, channel);
|
||||
|
||||
curves_update (c_tool, XRANGE_TOP);
|
||||
curves_update (c_tool, XRANGE);
|
||||
gtk_widget_queue_draw (c_tool->graph);
|
||||
}
|
||||
|
||||
|
@ -667,126 +672,46 @@ static void
|
|||
curves_update (GimpCurvesTool *c_tool,
|
||||
gint update)
|
||||
{
|
||||
GimpHistogramChannel sel_channel;
|
||||
gint i, j;
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
if (c_tool->color)
|
||||
{
|
||||
sel_channel = c_tool->channel;
|
||||
channel = c_tool->channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c_tool->channel == 2)
|
||||
sel_channel = GIMP_HISTOGRAM_ALPHA;
|
||||
channel = GIMP_HISTOGRAM_ALPHA;
|
||||
else
|
||||
sel_channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel = GIMP_HISTOGRAM_VALUE;
|
||||
}
|
||||
|
||||
if (update & XRANGE_TOP)
|
||||
if (update & XRANGE)
|
||||
{
|
||||
guchar buf[XRANGE_WIDTH * 3];
|
||||
|
||||
switch (sel_channel)
|
||||
switch (channel)
|
||||
{
|
||||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA:
|
||||
for (i = 0; i < XRANGE_HEIGHT / 2; i++)
|
||||
{
|
||||
for (j = 0; j < XRANGE_WIDTH ; j++)
|
||||
{
|
||||
buf[j * 3 + 0] = c_tool->curves->curve[sel_channel][j];
|
||||
buf[j * 3 + 1] = c_tool->curves->curve[sel_channel][j];
|
||||
buf[j * 3 + 2] = c_tool->curves->curve[sel_channel][j];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (c_tool->xrange),
|
||||
buf, 0, i, XRANGE_WIDTH);
|
||||
}
|
||||
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (c_tool->xrange),
|
||||
c_tool->curves->curve[channel],
|
||||
c_tool->curves->curve[channel],
|
||||
c_tool->curves->curve[channel]);
|
||||
break;
|
||||
|
||||
case GIMP_HISTOGRAM_RED:
|
||||
case GIMP_HISTOGRAM_GREEN:
|
||||
case GIMP_HISTOGRAM_BLUE:
|
||||
{
|
||||
for (i = 0; i < XRANGE_HEIGHT / 2; i++)
|
||||
{
|
||||
for (j = 0; j < XRANGE_WIDTH; j++)
|
||||
{
|
||||
buf[j * 3 + 0] = c_tool->curves->curve[GIMP_HISTOGRAM_RED][j];
|
||||
buf[j * 3 + 1] = c_tool->curves->curve[GIMP_HISTOGRAM_GREEN][j];
|
||||
buf[j * 3 + 2] = c_tool->curves->curve[GIMP_HISTOGRAM_BLUE][j];
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (c_tool->xrange),
|
||||
buf, 0, i, XRANGE_WIDTH);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
g_warning ("unknown channel type %d, can't happen!?!?",
|
||||
c_tool->channel);
|
||||
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (c_tool->xrange),
|
||||
c_tool->curves->curve[GIMP_HISTOGRAM_RED],
|
||||
c_tool->curves->curve[GIMP_HISTOGRAM_GREEN],
|
||||
c_tool->curves->curve[GIMP_HISTOGRAM_BLUE]);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw_area (c_tool->xrange,
|
||||
0, 0,
|
||||
XRANGE_WIDTH, XRANGE_HEIGHT / 2);
|
||||
}
|
||||
|
||||
if (update & XRANGE_BOTTOM)
|
||||
{
|
||||
guchar buf[XRANGE_WIDTH * 3];
|
||||
|
||||
for (i = 0; i < XRANGE_WIDTH; i++)
|
||||
{
|
||||
buf[i * 3 + 0] = i;
|
||||
buf[i * 3 + 1] = i;
|
||||
buf[i * 3 + 2] = i;
|
||||
}
|
||||
|
||||
for (i = XRANGE_HEIGHT / 2; i < XRANGE_HEIGHT; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (c_tool->xrange),
|
||||
buf, 0, i, XRANGE_WIDTH);
|
||||
|
||||
gtk_widget_queue_draw_area (c_tool->xrange,
|
||||
0, XRANGE_HEIGHT / 2,
|
||||
XRANGE_WIDTH, XRANGE_HEIGHT / 2);
|
||||
}
|
||||
|
||||
if (update & YRANGE)
|
||||
{
|
||||
guchar buf[YRANGE_WIDTH * 3];
|
||||
guchar pix[3];
|
||||
|
||||
for (i = 0; i < YRANGE_HEIGHT; i++)
|
||||
{
|
||||
switch (sel_channel)
|
||||
{
|
||||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA:
|
||||
pix[0] = pix[1] = pix[2] = (255 - i);
|
||||
break;
|
||||
|
||||
case GIMP_HISTOGRAM_RED:
|
||||
case GIMP_HISTOGRAM_GREEN:
|
||||
case GIMP_HISTOGRAM_BLUE:
|
||||
pix[0] = pix[1] = pix[2] = 0;
|
||||
pix[sel_channel - 1] = (255 - i);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("unknown channel type %d, can't happen!?!?",
|
||||
c_tool->channel);
|
||||
break;
|
||||
}
|
||||
|
||||
for (j = 0; j < YRANGE_WIDTH * 3; j++)
|
||||
buf[j] = pix[j%3];
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW (c_tool->yrange),
|
||||
buf, 0, i, YRANGE_WIDTH);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (c_tool->yrange);
|
||||
gimp_color_bar_set_channel (GIMP_COLOR_BAR (c_tool->yrange), channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -806,7 +731,7 @@ curves_channel_callback (GtkWidget *widget,
|
|||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type),
|
||||
c_tool->curves->curve_type[c_tool->channel]);
|
||||
|
||||
curves_update (c_tool, XRANGE_TOP | YRANGE);
|
||||
curves_update (c_tool, ALL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -817,7 +742,7 @@ curves_channel_reset_callback (GtkWidget *widget,
|
|||
|
||||
curves_channel_reset (c_tool->curves, c_tool->channel);
|
||||
|
||||
curves_update (c_tool, XRANGE_TOP);
|
||||
curves_update (c_tool, XRANGE);
|
||||
gtk_widget_queue_draw (c_tool->graph);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));
|
||||
|
@ -874,7 +799,7 @@ curves_curve_type_callback (GtkWidget *widget,
|
|||
|
||||
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
||||
|
||||
curves_update (c_tool, XRANGE_TOP);
|
||||
curves_update (c_tool, XRANGE);
|
||||
gtk_widget_queue_draw (c_tool->graph);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));
|
||||
|
@ -959,7 +884,7 @@ curves_graph_events (GtkWidget *widget,
|
|||
|
||||
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
||||
|
||||
curves_update (c_tool, XRANGE_TOP);
|
||||
curves_update (c_tool, XRANGE);
|
||||
gtk_widget_queue_draw (c_tool->graph);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1058,7 +983,7 @@ curves_graph_events (GtkWidget *widget,
|
|||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
}
|
||||
|
||||
curves_update (c_tool, XRANGE_TOP);
|
||||
curves_update (c_tool, XRANGE);
|
||||
|
||||
c_tool->cursor_x = tx - RADIUS;
|
||||
c_tool->cursor_y = ty - RADIUS;
|
||||
|
|
|
@ -23,11 +23,6 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
@ -49,6 +44,7 @@
|
|||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpcolorbar.h"
|
||||
#include "widgets/gimpenummenu.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimphistogramview.h"
|
||||
|
@ -79,12 +75,9 @@
|
|||
#define GRADIENT_HEIGHT 12
|
||||
#define CONTROL_HEIGHT 8
|
||||
|
||||
#define LEVELS_DRAWING_AREA_MASK (GDK_EXPOSURE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
#define LEVELS_DRAWING_AREA_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_POINTER_MOTION_HINT_MASK)
|
||||
GDK_BUTTON_MOTION_MASK)
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
@ -105,7 +98,7 @@ static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool);
|
|||
static void gimp_levels_tool_reset (GimpImageMapTool *image_map_tool);
|
||||
|
||||
static void levels_update (GimpLevelsTool *l_tool,
|
||||
gint update);
|
||||
guint update);
|
||||
static void levels_channel_callback (GtkWidget *widget,
|
||||
GimpLevelsTool *l_tool);
|
||||
static void levels_channel_reset_callback (GtkWidget *widget,
|
||||
|
@ -137,9 +130,7 @@ static gint levels_input_area_event (GtkWidget *widget,
|
|||
static gboolean levels_input_area_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
GimpLevelsTool *l_tool);
|
||||
static void levels_input_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
GimpLevelsTool *l_tool);
|
||||
|
||||
static gint levels_output_area_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpLevelsTool *l_tool);
|
||||
|
@ -147,9 +138,6 @@ static gboolean levels_output_area_expose (GtkWidget *widget,
|
|||
GdkEventExpose *event,
|
||||
GimpLevelsTool *l_tool);
|
||||
|
||||
static void levels_output_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
GimpLevelsTool *l_tool);
|
||||
static void file_dialog_create (GimpLevelsTool *l_tool);
|
||||
static void file_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
|
@ -416,7 +404,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
GtkWidget *hbbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *spinbutton;
|
||||
GtkWidget *bar;
|
||||
GtkObject *data;
|
||||
gint border;
|
||||
|
||||
vbox = image_map_tool->main_vbox;
|
||||
|
||||
|
@ -471,34 +461,49 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options),
|
||||
GIMP_HISTOGRAM_VIEW (l_tool->hist_view));
|
||||
|
||||
g_object_get (l_tool->hist_view, "border-width", &border, NULL);
|
||||
|
||||
/* The input levels drawing area */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox3 = gtk_vbox_new (FALSE, 2);
|
||||
vbox3 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox3);
|
||||
gtk_widget_show (vbox3);
|
||||
|
||||
l_tool->input_area[0] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (l_tool->input_area[0]),
|
||||
HISTOGRAM_WIDTH, GRADIENT_HEIGHT);
|
||||
gtk_preview_set_expand (GTK_PREVIEW (l_tool->input_area[0]), TRUE);
|
||||
gtk_widget_set_events (l_tool->input_area[0], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->input_area[0],
|
||||
TRUE, TRUE, 0);
|
||||
l_tool->input_area[0] = g_object_new (GIMP_TYPE_COLOR_BAR,
|
||||
"xpad", border,
|
||||
"ypad", 0,
|
||||
"input", TRUE,
|
||||
NULL);
|
||||
gtk_widget_set_size_request (l_tool->input_area[0], -1, GRADIENT_HEIGHT / 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->input_area[0], TRUE, TRUE, 0);
|
||||
gtk_widget_show (l_tool->input_area[0]);
|
||||
|
||||
g_signal_connect (l_tool->input_area[0], "event",
|
||||
G_CALLBACK (levels_input_area_event),
|
||||
l_tool);
|
||||
|
||||
bar = g_object_new (GIMP_TYPE_COLOR_BAR,
|
||||
"xpad", border,
|
||||
"ypad", 0,
|
||||
"input", TRUE,
|
||||
NULL);
|
||||
gtk_widget_set_size_request (bar, -1, GRADIENT_HEIGHT / 2);
|
||||
gtk_widget_add_events (bar, LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (bar);
|
||||
|
||||
g_signal_connect (bar, "event",
|
||||
G_CALLBACK (levels_input_area_event),
|
||||
l_tool);
|
||||
|
||||
l_tool->input_area[1] = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (l_tool->input_area[1], -1, CONTROL_HEIGHT);
|
||||
gtk_widget_set_events (l_tool->input_area[1], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->input_area[1],
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_add_events (l_tool->input_area[1], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->input_area[1], TRUE, TRUE, 1);
|
||||
gtk_widget_show (l_tool->input_area[1]);
|
||||
|
||||
g_signal_connect (l_tool->input_area[1], "event",
|
||||
|
@ -507,9 +512,6 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
g_signal_connect (l_tool->input_area[1], "expose_event",
|
||||
G_CALLBACK (levels_input_area_expose),
|
||||
l_tool);
|
||||
g_signal_connect (l_tool->input_area[1], "size_allocate",
|
||||
G_CALLBACK (levels_input_area_size_allocate),
|
||||
l_tool);
|
||||
|
||||
/* Horizontal box for input levels spinbuttons */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
@ -588,30 +590,28 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox3 = gtk_vbox_new (FALSE, 2);
|
||||
vbox3 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox3);
|
||||
gtk_widget_show (vbox3);
|
||||
|
||||
l_tool->output_area[0] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (l_tool->output_area[0]),
|
||||
HISTOGRAM_WIDTH, GRADIENT_HEIGHT);
|
||||
gtk_preview_set_expand (GTK_PREVIEW (l_tool->output_area[0]), TRUE);
|
||||
gtk_widget_set_events (l_tool->output_area[0], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->output_area[0],
|
||||
TRUE, TRUE, 0);
|
||||
l_tool->output_area[0] = g_object_new (GIMP_TYPE_COLOR_BAR,
|
||||
"xpad", border,
|
||||
"ypad", 0,
|
||||
"input", TRUE,
|
||||
NULL);
|
||||
gtk_widget_set_size_request (l_tool->output_area[0], -1, GRADIENT_HEIGHT);
|
||||
gtk_widget_add_events (l_tool->output_area[0], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->output_area[0], TRUE, TRUE, 0);
|
||||
gtk_widget_show (l_tool->output_area[0]);
|
||||
|
||||
g_signal_connect (l_tool->output_area[0], "event",
|
||||
G_CALLBACK (levels_output_area_event),
|
||||
l_tool);
|
||||
|
||||
l_tool->output_area[1] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (l_tool->output_area[1]),
|
||||
HISTOGRAM_WIDTH, CONTROL_HEIGHT);
|
||||
gtk_preview_set_expand (GTK_PREVIEW (l_tool->output_area[1]), TRUE);
|
||||
gtk_widget_set_events (l_tool->output_area[1], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->output_area[1],
|
||||
TRUE, TRUE, 0);
|
||||
l_tool->output_area[1] = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (l_tool->output_area[1], -1, CONTROL_HEIGHT);
|
||||
gtk_widget_add_events (l_tool->output_area[1], LEVELS_DRAWING_AREA_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->output_area[1], TRUE, TRUE, 1);
|
||||
gtk_widget_show (l_tool->output_area[1]);
|
||||
|
||||
g_signal_connect (l_tool->output_area[1], "event",
|
||||
|
@ -620,9 +620,6 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
g_signal_connect (l_tool->output_area[1], "expose_event",
|
||||
G_CALLBACK (levels_output_area_expose),
|
||||
l_tool);
|
||||
g_signal_connect (l_tool->output_area[1], "size_allocate",
|
||||
G_CALLBACK (levels_output_area_size_allocate),
|
||||
l_tool);
|
||||
|
||||
/* Horizontal box for levels spin widgets */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
@ -738,7 +735,7 @@ levels_draw_slider (GtkWidget *widget,
|
|||
gint xpos)
|
||||
{
|
||||
GdkWindow *window = widget->window;
|
||||
gint y;
|
||||
gint y;
|
||||
|
||||
for (y = 0; y < CONTROL_HEIGHT; y++)
|
||||
gdk_draw_line (window, fill_gc,
|
||||
|
@ -760,21 +757,20 @@ levels_draw_slider (GtkWidget *widget,
|
|||
|
||||
static void
|
||||
levels_update (GimpLevelsTool *l_tool,
|
||||
gint update)
|
||||
guint update)
|
||||
{
|
||||
gint i;
|
||||
gint sel_channel;
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
if (l_tool->color)
|
||||
{
|
||||
sel_channel = l_tool->channel;
|
||||
channel = l_tool->channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l_tool->channel == 2)
|
||||
sel_channel = GIMP_HISTOGRAM_ALPHA;
|
||||
channel = GIMP_HISTOGRAM_ALPHA;
|
||||
else
|
||||
sel_channel = GIMP_HISTOGRAM_VALUE;
|
||||
channel = GIMP_HISTOGRAM_VALUE;
|
||||
}
|
||||
|
||||
/* Recalculate the transfer arrays */
|
||||
|
@ -809,121 +805,57 @@ levels_update (GimpLevelsTool *l_tool,
|
|||
|
||||
if (update & INPUT_LEVELS)
|
||||
{
|
||||
GtkWidget *widget = l_tool->input_area[0];
|
||||
guchar *buf;
|
||||
gint width;
|
||||
|
||||
width = widget->allocation.width;
|
||||
buf = g_alloca (width * 3);
|
||||
|
||||
switch (sel_channel)
|
||||
switch (channel)
|
||||
{
|
||||
default:
|
||||
g_warning ("unknown channel type, can't happen\n");
|
||||
/* fall through */
|
||||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA:
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
gint v = l_tool->levels->input[sel_channel][(i * 256) / width];
|
||||
|
||||
buf[3 * i + 0] = v;
|
||||
buf[3 * i + 1] = v;
|
||||
buf[3 * i + 2] = v;
|
||||
}
|
||||
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (l_tool->input_area[0]),
|
||||
l_tool->levels->input[channel],
|
||||
l_tool->levels->input[channel],
|
||||
l_tool->levels->input[channel]);
|
||||
break;
|
||||
|
||||
case GIMP_HISTOGRAM_RED:
|
||||
case GIMP_HISTOGRAM_GREEN:
|
||||
case GIMP_HISTOGRAM_BLUE:
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
gint j = (i * 256) / width;
|
||||
|
||||
buf[3 * i + 0] = l_tool->levels->input[GIMP_HISTOGRAM_RED][j];
|
||||
buf[3 * i + 1] = l_tool->levels->input[GIMP_HISTOGRAM_GREEN][j];
|
||||
buf[3 * i + 2] = l_tool->levels->input[GIMP_HISTOGRAM_BLUE][j];
|
||||
}
|
||||
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (l_tool->input_area[0]),
|
||||
l_tool->levels->input[GIMP_HISTOGRAM_RED],
|
||||
l_tool->levels->input[GIMP_HISTOGRAM_GREEN],
|
||||
l_tool->levels->input[GIMP_HISTOGRAM_BLUE]);
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < GRADIENT_HEIGHT / 2; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), buf, 0, i, width);
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
gint j = (i * 256) / width;
|
||||
|
||||
buf[3 * i + 0] = j;
|
||||
buf[3 * i + 1] = j;
|
||||
buf[3 * i + 2] = j;
|
||||
}
|
||||
|
||||
for (i = GRADIENT_HEIGHT / 2; i < GRADIENT_HEIGHT; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), buf, 0, i, width);
|
||||
|
||||
if (update & DRAW)
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
|
||||
if (update & OUTPUT_LEVELS)
|
||||
{
|
||||
GtkWidget *widget = l_tool->output_area[0];
|
||||
guchar *buf;
|
||||
guchar r, g, b;
|
||||
gint width;
|
||||
|
||||
width = widget->allocation.width;
|
||||
buf = g_alloca (width * 3);
|
||||
|
||||
r = g = b = 0;
|
||||
switch (sel_channel)
|
||||
{
|
||||
default:
|
||||
g_warning ("unknown channel type, can't happen\n");
|
||||
/* fall through */
|
||||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA: r = g = b = 1; break;
|
||||
case GIMP_HISTOGRAM_RED: r = 1; break;
|
||||
case GIMP_HISTOGRAM_GREEN: g = 1; break;
|
||||
case GIMP_HISTOGRAM_BLUE: b = 1; break;
|
||||
}
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
gint j = (i * 256) / width;
|
||||
|
||||
buf[3 * i + 0] = j * r;
|
||||
buf[3 * i + 1] = j * g;
|
||||
buf[3 * i + 2] = j * b;
|
||||
}
|
||||
|
||||
for (i = 0; i < GRADIENT_HEIGHT; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), buf, 0, i, width);
|
||||
|
||||
if (update & DRAW)
|
||||
gtk_widget_queue_draw (widget);
|
||||
gimp_color_bar_set_channel (GIMP_COLOR_BAR (l_tool->output_area[0]),
|
||||
channel);
|
||||
}
|
||||
|
||||
if (update & INPUT_SLIDERS)
|
||||
{
|
||||
Levels *levels = l_tool->levels;
|
||||
gint width = l_tool->input_area[0]->allocation.width;
|
||||
gint width = l_tool->input_area[1]->allocation.width;
|
||||
gdouble delta, mid, tmp;
|
||||
gint border;
|
||||
|
||||
g_object_get (l_tool->hist_view, "border-width", &border, NULL);
|
||||
|
||||
width -= 2 * border;
|
||||
|
||||
l_tool->slider_pos[0] = ROUND ((gdouble) width *
|
||||
levels->low_input[l_tool->channel] /
|
||||
256.0);
|
||||
256.0) + border;
|
||||
|
||||
l_tool->slider_pos[2] = ROUND ((gdouble) width *
|
||||
levels->high_input[l_tool->channel] /
|
||||
256.0);
|
||||
256.0) + border;
|
||||
|
||||
delta = (gdouble) (l_tool->slider_pos[2] - l_tool->slider_pos[0]) / 2.0;
|
||||
mid = l_tool->slider_pos[0] + delta;
|
||||
tmp = log10 (1.0 / levels->gamma[l_tool->channel]);
|
||||
|
||||
l_tool->slider_pos[1] = (gint) (mid + delta * tmp + 0.5);
|
||||
l_tool->slider_pos[1] = ROUND (mid + delta * tmp) + border;
|
||||
|
||||
gtk_widget_queue_draw (l_tool->input_area[1]);
|
||||
}
|
||||
|
@ -931,15 +863,20 @@ levels_update (GimpLevelsTool *l_tool,
|
|||
if (update & OUTPUT_SLIDERS)
|
||||
{
|
||||
Levels *levels = l_tool->levels;
|
||||
gint width = l_tool->output_area[0]->allocation.width;
|
||||
gint width = l_tool->output_area[1]->allocation.width;
|
||||
gint border;
|
||||
|
||||
g_object_get (l_tool->hist_view, "border-width", &border, NULL);
|
||||
|
||||
width -= 2 * border;
|
||||
|
||||
l_tool->slider_pos[3] = ROUND ((gdouble) width *
|
||||
levels->low_output[l_tool->channel] /
|
||||
256.0);
|
||||
256.0) + border;
|
||||
|
||||
l_tool->slider_pos[4] = ROUND ((gdouble) width *
|
||||
levels->high_output[l_tool->channel] /
|
||||
256.0);
|
||||
256.0) + border;
|
||||
|
||||
gtk_widget_queue_draw (l_tool->output_area[1]);
|
||||
}
|
||||
|
@ -1006,9 +943,8 @@ static void
|
|||
levels_low_input_adjustment_update (GtkAdjustment *adjustment,
|
||||
GimpLevelsTool *l_tool)
|
||||
{
|
||||
gint value;
|
||||
gint value = ROUND (adjustment->value);
|
||||
|
||||
value = (gint) (adjustment->value + 0.5);
|
||||
value = CLAMP (value, 0, l_tool->levels->high_input[l_tool->channel]);
|
||||
|
||||
/* enforce a consistent displayed value (low_input <= high_input) */
|
||||
|
@ -1040,9 +976,8 @@ static void
|
|||
levels_high_input_adjustment_update (GtkAdjustment *adjustment,
|
||||
GimpLevelsTool *l_tool)
|
||||
{
|
||||
gint value;
|
||||
gint value = ROUND (adjustment->value);
|
||||
|
||||
value = (gint) (adjustment->value + 0.5);
|
||||
value = CLAMP (value, l_tool->levels->low_input[l_tool->channel], 255);
|
||||
|
||||
/* enforce a consistent displayed value (high_input >= low_input) */
|
||||
|
@ -1061,9 +996,7 @@ static void
|
|||
levels_low_output_adjustment_update (GtkAdjustment *adjustment,
|
||||
GimpLevelsTool *l_tool)
|
||||
{
|
||||
gint value;
|
||||
|
||||
value = (gint) (adjustment->value + 0.5);
|
||||
gint value = ROUND (adjustment->value);
|
||||
|
||||
if (l_tool->levels->low_output[l_tool->channel] != value)
|
||||
{
|
||||
|
@ -1078,9 +1011,7 @@ static void
|
|||
levels_high_output_adjustment_update (GtkAdjustment *adjustment,
|
||||
GimpLevelsTool *l_tool)
|
||||
{
|
||||
gint value;
|
||||
|
||||
value = (gint) (adjustment->value + 0.5);
|
||||
gint value = ROUND (adjustment->value);
|
||||
|
||||
if (l_tool->levels->high_output[l_tool->channel] != value)
|
||||
{
|
||||
|
@ -1176,14 +1107,20 @@ levels_input_area_event (GtkWidget *widget,
|
|||
{
|
||||
gdouble delta, mid, tmp;
|
||||
gint width;
|
||||
gint border;
|
||||
|
||||
width = widget->allocation.width;
|
||||
g_object_get (l_tool->hist_view, "border-width", &border, NULL);
|
||||
|
||||
width = widget->allocation.width - 2 * border;
|
||||
|
||||
if (width < 1)
|
||||
return FALSE;
|
||||
|
||||
switch (l_tool->active_slider)
|
||||
{
|
||||
case 0: /* low input */
|
||||
l_tool->levels->low_input[l_tool->channel] =
|
||||
((gdouble) x / (gdouble) width) * 255.0;
|
||||
((gdouble) (x - border) / (gdouble) width) * 255.0;
|
||||
|
||||
l_tool->levels->low_input[l_tool->channel] =
|
||||
CLAMP (l_tool->levels->low_input[l_tool->channel],
|
||||
|
@ -1206,7 +1143,7 @@ levels_input_area_event (GtkWidget *widget,
|
|||
|
||||
case 2: /* high input */
|
||||
l_tool->levels->high_input[l_tool->channel] =
|
||||
((gdouble) x / (gdouble) width) * 255.0;
|
||||
((gdouble) (x - border) / (gdouble) width) * 255.0;
|
||||
|
||||
l_tool->levels->high_input[l_tool->channel] =
|
||||
CLAMP (l_tool->levels->high_input[l_tool->channel],
|
||||
|
@ -1242,14 +1179,6 @@ levels_input_area_expose (GtkWidget *widget,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
levels_input_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
GimpLevelsTool *l_tool)
|
||||
{
|
||||
levels_update (l_tool, INPUT_LEVELS | INPUT_SLIDERS);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
levels_output_area_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
|
@ -1304,13 +1233,21 @@ levels_output_area_event (GtkWidget *widget,
|
|||
|
||||
if (update)
|
||||
{
|
||||
gint width = widget->allocation.width;
|
||||
gint width;
|
||||
gint border;
|
||||
|
||||
g_object_get (l_tool->hist_view, "border-width", &border, NULL);
|
||||
|
||||
width = widget->allocation.width - 2 * border;
|
||||
|
||||
if (width < 1)
|
||||
return FALSE;
|
||||
|
||||
switch (l_tool->active_slider)
|
||||
{
|
||||
case 3: /* low output */
|
||||
l_tool->levels->low_output[l_tool->channel] =
|
||||
((gdouble) x / (gdouble) width) * 255.0;
|
||||
((gdouble) (x - border) / (gdouble) width) * 255.0;
|
||||
|
||||
l_tool->levels->low_output[l_tool->channel] =
|
||||
CLAMP (l_tool->levels->low_output[l_tool->channel], 0, 255);
|
||||
|
@ -1318,7 +1255,7 @@ levels_output_area_event (GtkWidget *widget,
|
|||
|
||||
case 4: /* high output */
|
||||
l_tool->levels->high_output[l_tool->channel] =
|
||||
((gdouble) x / (gdouble) width) * 255.0;
|
||||
((gdouble) (x - border) / (gdouble) width) * 255.0;
|
||||
|
||||
l_tool->levels->high_output[l_tool->channel] =
|
||||
CLAMP (l_tool->levels->high_output[l_tool->channel], 0, 255);
|
||||
|
@ -1348,14 +1285,6 @@ levels_output_area_expose (GtkWidget *widget,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
levels_output_area_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
GimpLevelsTool *l_tool)
|
||||
{
|
||||
levels_update (l_tool, OUTPUT_LEVELS | OUTPUT_SLIDERS);
|
||||
}
|
||||
|
||||
static void
|
||||
levels_input_adjust_by_color (Levels *levels,
|
||||
guint value,
|
||||
|
|
|
@ -31,6 +31,8 @@ libappwidgets_a_sources = \
|
|||
gimpcellrendererviewable.h \
|
||||
gimpchanneltreeview.c \
|
||||
gimpchanneltreeview.h \
|
||||
gimpcolorbar.c \
|
||||
gimpcolorbar.h \
|
||||
gimpcolordisplayeditor.c \
|
||||
gimpcolordisplayeditor.h \
|
||||
gimpcoloreditor.c \
|
||||
|
|
|
@ -0,0 +1,442 @@
|
|||
/* 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"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpconfig-params.h"
|
||||
|
||||
#include "gimpcolorbar.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_ORIENTATION,
|
||||
PROP_INPUT,
|
||||
PROP_COLOR,
|
||||
PROP_CHANNEL
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_color_bar_class_init (GimpColorBarClass *klass);
|
||||
static void gimp_color_bar_init (GimpColorBar *bar);
|
||||
static void gimp_color_bar_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_bar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gimp_color_bar_realize (GtkWidget *widget);
|
||||
static void gimp_color_bar_unrealize (GtkWidget *widget);
|
||||
static void gimp_color_bar_map (GtkWidget *widget);
|
||||
static void gimp_color_bar_unmap (GtkWidget *widget);
|
||||
|
||||
static gboolean gimp_color_bar_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event);
|
||||
|
||||
|
||||
static GtkMiscClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_color_bar_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
static const GTypeInfo bar_info =
|
||||
{
|
||||
sizeof (GimpColorBarClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_color_bar_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpColorBar),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_color_bar_init,
|
||||
};
|
||||
|
||||
type = g_type_register_static (GTK_TYPE_MISC,
|
||||
"GimpColorBar", &bar_info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_class_init (GimpColorBarClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GimpRGB white = { 1.0, 1.0, 1.0, 1.0 };
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->set_property = gimp_color_bar_set_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ORIENTATION,
|
||||
g_param_spec_enum ("orientation",
|
||||
NULL, NULL,
|
||||
GTK_TYPE_ORIENTATION,
|
||||
GTK_ORIENTATION_HORIZONTAL,
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (object_class, PROP_INPUT,
|
||||
g_param_spec_boolean ("input",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (object_class, PROP_COLOR,
|
||||
gimp_param_spec_color ("color",
|
||||
NULL, NULL,
|
||||
&white,
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class, PROP_ORIENTATION,
|
||||
g_param_spec_enum ("channel",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_HISTOGRAM_CHANNEL,
|
||||
GIMP_HISTOGRAM_VALUE,
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
widget_class->size_allocate = gimp_color_bar_size_allocate;
|
||||
widget_class->realize = gimp_color_bar_realize;
|
||||
widget_class->unrealize = gimp_color_bar_unrealize;
|
||||
widget_class->map = gimp_color_bar_map;
|
||||
widget_class->unmap = gimp_color_bar_unmap;
|
||||
widget_class->expose_event = gimp_color_bar_expose;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_init (GimpColorBar *bar)
|
||||
{
|
||||
GTK_WIDGET_SET_FLAGS (bar, GTK_NO_WINDOW);
|
||||
|
||||
bar->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
bar->input = FALSE;
|
||||
bar->input_window = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_bar_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
bar->orientation = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_INPUT:
|
||||
bar->input = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
gimp_color_bar_set_color (bar, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
gimp_color_bar_set_channel (bar, g_value_get_enum (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
|
||||
|
||||
if (bar->input_window)
|
||||
gdk_window_move_resize (bar->input_window,
|
||||
widget->allocation.x,
|
||||
widget->allocation.y,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_realize (GtkWidget *widget)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||
|
||||
if (bar->input && ! bar->input_window)
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
|
||||
attributes.x = widget->allocation.x;
|
||||
attributes.y = widget->allocation.y;
|
||||
attributes.width = widget->allocation.width;
|
||||
attributes.height = widget->allocation.height;
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
attributes.wclass = GDK_INPUT_ONLY;
|
||||
attributes.override_redirect = TRUE;
|
||||
attributes.event_mask = (GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
gtk_widget_get_events (widget));
|
||||
|
||||
bar->input_window = gdk_window_new (widget->window,
|
||||
&attributes,
|
||||
(GDK_WA_X |
|
||||
GDK_WA_Y |
|
||||
GDK_WA_NOREDIR));
|
||||
|
||||
gdk_window_set_user_data (bar->input_window, widget);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
|
||||
|
||||
if (bar->input_window)
|
||||
{
|
||||
gdk_window_set_user_data (bar->input_window, NULL);
|
||||
gdk_window_destroy (bar->input_window);
|
||||
bar->input_window = NULL;
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_map (GtkWidget *widget)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->map (widget);
|
||||
|
||||
if (bar->input_window)
|
||||
gdk_window_show (bar->input_window);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_bar_unmap (GtkWidget *widget)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
|
||||
|
||||
if (bar->input_window)
|
||||
gdk_window_hide (bar->input_window);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_color_bar_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
{
|
||||
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
|
||||
guchar *buf;
|
||||
guchar *b;
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
gint i, j;
|
||||
|
||||
x = GTK_MISC (bar)->xpad;
|
||||
y = GTK_MISC (bar)->ypad;
|
||||
|
||||
width = widget->allocation.width - 2 * x;
|
||||
height = widget->allocation.height - 2 * y;
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return TRUE;
|
||||
|
||||
buf = g_alloca (width * height * 3);
|
||||
|
||||
switch (bar->orientation)
|
||||
{
|
||||
case GTK_ORIENTATION_HORIZONTAL:
|
||||
for (i = 0, b = buf; i < width; i++, b += 3)
|
||||
{
|
||||
guchar *src = bar->buf + 3 * ((i * 256) / width);
|
||||
|
||||
b[0] = src[0];
|
||||
b[1] = src[1];
|
||||
b[2] = src[2];
|
||||
}
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
memcpy (buf + i * width * 3, buf, width * 3);
|
||||
|
||||
break;
|
||||
|
||||
case GTK_ORIENTATION_VERTICAL:
|
||||
for (i = 0, b = buf; i < height; i++, b += 3 * width)
|
||||
{
|
||||
guchar *src = bar->buf + 3 * (255 - ((i * 256) / height));
|
||||
guchar *dest = b;
|
||||
|
||||
for (j = 0; j < width; j++, dest += 3)
|
||||
{
|
||||
dest[0] = src[0];
|
||||
dest[1] = src[1];
|
||||
dest[2] = src[2];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
gdk_draw_rgb_image (widget->window, widget->style->black_gc,
|
||||
widget->allocation.x + x, widget->allocation.y + y,
|
||||
width, height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf, 3 * width);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_bar_new:
|
||||
*
|
||||
* Creates a new #GimpColorBar widget.
|
||||
*
|
||||
* Return value: The new #GimpColorBar widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_bar_new (GtkOrientation orientation)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_COLOR_BAR,
|
||||
"orientation", orientation,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_bar_set_color:
|
||||
* @bar: a #GimpColorBar widget
|
||||
* @color: a #GimpRGB color
|
||||
*
|
||||
* Makes the @bar display a gradient from black (on the left or the
|
||||
* bottom), to the given @color (on the right or at the top).
|
||||
**/
|
||||
void
|
||||
gimp_color_bar_set_color (GimpColorBar *bar,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
guchar *buf;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BAR (bar));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
for (i = 0, buf = bar->buf; i < 256; i++, buf += 3)
|
||||
{
|
||||
buf[0] = ROUND (color->r * (gdouble) i);
|
||||
buf[1] = ROUND (color->g * (gdouble) i);
|
||||
buf[2] = ROUND (color->b * (gdouble) i);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (bar));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_bar_set_color:
|
||||
* @bar: a #GimpColorBar widget
|
||||
* @channel: a #GimpHistogramChannel
|
||||
*
|
||||
* Convenience function that calls gimp_color_bar_set_color() with the
|
||||
* color that matches the @channel.
|
||||
**/
|
||||
void
|
||||
gimp_color_bar_set_channel (GimpColorBar *bar,
|
||||
GimpHistogramChannel channel)
|
||||
{
|
||||
GimpRGB color = { 1.0, 1.0, 1.0, 1.0 };
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BAR (bar));
|
||||
|
||||
switch (channel)
|
||||
{
|
||||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA:
|
||||
gimp_rgb_set (&color, 1.0, 1.0, 1.0);
|
||||
break;
|
||||
case GIMP_HISTOGRAM_RED:
|
||||
gimp_rgb_set (&color, 1.0, 0.0, 0.0);
|
||||
break;
|
||||
case GIMP_HISTOGRAM_GREEN:
|
||||
gimp_rgb_set (&color, 0.0, 1.0, 0.0);
|
||||
break;
|
||||
case GIMP_HISTOGRAM_BLUE:
|
||||
gimp_rgb_set (&color, 0.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_color_bar_set_color (bar, &color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_bar_set_buffers:
|
||||
* @bar: a #GimpColorBar widget
|
||||
* @red: an array of 256 values
|
||||
* @green: an array of 256 values
|
||||
* @blue: an array of 256 values
|
||||
*
|
||||
* This function gives full control over the colors displayed by the
|
||||
* @bar widget. The 3 arrays can for example be taken from a #Levels
|
||||
* or a #Curves struct.
|
||||
**/
|
||||
void
|
||||
gimp_color_bar_set_buffers (GimpColorBar *bar,
|
||||
const guchar *red,
|
||||
const guchar *green,
|
||||
const guchar *blue)
|
||||
{
|
||||
guchar *buf;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BAR (bar));
|
||||
g_return_if_fail (red != NULL);
|
||||
g_return_if_fail (green != NULL);
|
||||
g_return_if_fail (blue != NULL);
|
||||
|
||||
for (i = 0, buf = bar->buf; i < 256; i++, buf += 3)
|
||||
{
|
||||
buf[0] = red[i];
|
||||
buf[1] = green[i];
|
||||
buf[2] = blue[i];
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (bar));
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_BAR_H__
|
||||
#define __GIMP_COLOR_BAR_H__
|
||||
|
||||
|
||||
#include <gtk/gtkmisc.h>
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_BAR (gimp_color_bar_get_type ())
|
||||
#define GIMP_COLOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_BAR, GimpColorBar))
|
||||
#define GIMP_COLOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_BAR, GimpColorBarClass))
|
||||
#define GIMP_IS_COLOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_BAR))
|
||||
#define GIMP_IS_COLOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BAR))
|
||||
#define GIMP_COLOR_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_BAR, GimpColorBarClass))
|
||||
|
||||
|
||||
typedef struct _GimpColorBarClass GimpColorBarClass;
|
||||
|
||||
struct _GimpColorBar
|
||||
{
|
||||
GtkMisc parent_class;
|
||||
|
||||
GtkOrientation orientation;
|
||||
gboolean input;
|
||||
GdkWindow *input_window;
|
||||
|
||||
guchar buf[3 * 256];
|
||||
};
|
||||
|
||||
struct _GimpColorBarClass
|
||||
{
|
||||
GtkMiscClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_color_bar_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_color_bar_new (GtkOrientation orientation);
|
||||
|
||||
void gimp_color_bar_set_color (GimpColorBar *bar,
|
||||
const GimpRGB *color);
|
||||
void gimp_color_bar_set_channel (GimpColorBar *bar,
|
||||
GimpHistogramChannel channel);
|
||||
void gimp_color_bar_set_buffers (GimpColorBar *bar,
|
||||
const guchar *red,
|
||||
const guchar *green,
|
||||
const guchar *blue);
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_BAR_H__ */
|
|
@ -134,11 +134,7 @@ gimp_color_frame_init (GimpColorFrame *frame)
|
|||
GtkWidget *
|
||||
gimp_color_frame_new (void)
|
||||
{
|
||||
GimpColorFrame *frame;
|
||||
|
||||
frame = g_object_new (GIMP_TYPE_COLOR_FRAME, NULL);
|
||||
|
||||
return GTK_WIDGET (frame);
|
||||
return g_object_new (GIMP_TYPE_COLOR_FRAME, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct _GimpColorFrameClass GimpColorFrameClass;
|
|||
|
||||
struct _GimpColorFrame
|
||||
{
|
||||
GtkFrame parent_class;
|
||||
GtkFrame parent_instance;
|
||||
|
||||
gboolean sample_valid;
|
||||
GimpImageType sample_type;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "base/gimphistogram.h"
|
||||
|
||||
#include "gimpcolorbar.h"
|
||||
#include "gimphistogrambox.h"
|
||||
#include "gimphistogramview.h"
|
||||
#include "gimppropwidgets.h"
|
||||
|
@ -35,16 +36,14 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* #define DEBUG_VIEW */
|
||||
/* #define DEBUG_VIEW */
|
||||
|
||||
#define GRADIENT_HEIGHT 10
|
||||
#define GRADIENT_HEIGHT 8
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_histogram_box_class_init (GimpHistogramBoxClass *klass);
|
||||
static void gimp_histogram_box_init (GimpHistogramBox *histogram_box);
|
||||
static void gimp_histogram_box_finalize (GObject *object);
|
||||
static void gimp_histogram_box_init (GimpHistogramBox *box);
|
||||
|
||||
static void gimp_histogram_box_low_adj_update (GtkAdjustment *adj,
|
||||
GimpHistogramBox *box);
|
||||
|
@ -54,16 +53,12 @@ static void gimp_histogram_box_histogram_range (GimpHistogramView *view,
|
|||
gint start,
|
||||
gint end,
|
||||
GimpHistogramBox *box);
|
||||
|
||||
static void gimp_histogram_box_gradient_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
gpointer data);
|
||||
static gboolean gimp_histogram_box_gradient_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static GtkVBoxClass *parent_class = NULL;
|
||||
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);
|
||||
|
||||
|
||||
GType
|
||||
|
@ -78,8 +73,8 @@ gimp_histogram_box_get_type (void)
|
|||
sizeof (GimpHistogramBoxClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_histogram_box_class_init,
|
||||
NULL, /* class_finalize */
|
||||
(GClassInitFunc) NULL,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpHistogramBox),
|
||||
0, /* n_preallocs */
|
||||
|
@ -94,18 +89,6 @@ gimp_histogram_box_get_type (void)
|
|||
return box_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_box_class_init (GimpHistogramBoxClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_histogram_box_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_box_init (GimpHistogramBox *box)
|
||||
{
|
||||
|
@ -114,6 +97,7 @@ gimp_histogram_box_init (GimpHistogramBox *box)
|
|||
GtkObject *adjustment;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *view;
|
||||
GtkWidget *bar;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (box), 2);
|
||||
|
||||
|
@ -139,25 +123,24 @@ gimp_histogram_box_init (GimpHistogramBox *box)
|
|||
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
box->gradient = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (box->gradient, -1,
|
||||
bar = g_object_new (GIMP_TYPE_COLOR_BAR,
|
||||
"channel", box->view->channel,
|
||||
"xpad", box->view->border_width,
|
||||
"ypad", box->view->border_width,
|
||||
NULL);
|
||||
|
||||
gtk_widget_set_size_request (bar,
|
||||
-1,
|
||||
GRADIENT_HEIGHT + 2 * box->view->border_width);
|
||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (box->gradient));
|
||||
gtk_widget_show (box->gradient);
|
||||
gtk_container_add (GTK_CONTAINER (frame), bar);
|
||||
gtk_widget_show (bar);
|
||||
|
||||
g_signal_connect (box->gradient, "size_allocate",
|
||||
G_CALLBACK (gimp_histogram_box_gradient_size_allocate),
|
||||
box);
|
||||
g_signal_connect (box->gradient, "expose_event",
|
||||
G_CALLBACK (gimp_histogram_box_gradient_expose),
|
||||
box);
|
||||
|
||||
g_signal_connect_swapped (view, "notify::histogram-channel",
|
||||
G_CALLBACK (gtk_widget_queue_draw),
|
||||
box->gradient);
|
||||
g_signal_connect_swapped (view, "notify::border-width",
|
||||
G_CALLBACK (gtk_widget_queue_resize),
|
||||
box->gradient);
|
||||
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);
|
||||
|
||||
/* The range selection */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
|
@ -205,20 +188,6 @@ gimp_histogram_box_init (GimpHistogramBox *box)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_box_finalize (GObject *object)
|
||||
{
|
||||
GimpHistogramBox *box = GIMP_HISTOGRAM_BOX (object);
|
||||
|
||||
if (box->gradient_buf)
|
||||
{
|
||||
g_free (box->gradient_buf);
|
||||
box->gradient_buf = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_box_low_adj_update (GtkAdjustment *adjustment,
|
||||
GimpHistogramBox *box)
|
||||
|
@ -248,7 +217,7 @@ gimp_histogram_box_high_adj_update (GtkAdjustment *adjustment,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_box_histogram_range (GimpHistogramView *widget,
|
||||
gimp_histogram_box_histogram_range (GimpHistogramView *view,
|
||||
gint start,
|
||||
gint end,
|
||||
GimpHistogramBox *box)
|
||||
|
@ -263,81 +232,25 @@ gimp_histogram_box_histogram_range (GimpHistogramView *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_box_gradient_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation,
|
||||
gpointer data)
|
||||
gimp_histogram_box_channel_notify (GimpHistogramView *view,
|
||||
GParamSpec *pspec,
|
||||
GimpColorBar *bar)
|
||||
{
|
||||
GimpHistogramBox *box = GIMP_HISTOGRAM_BOX (data);
|
||||
gint border;
|
||||
gint width, height;
|
||||
|
||||
border = box->view->border_width;
|
||||
width = allocation->width - 2 * border;
|
||||
height = allocation->height - 2 * border;
|
||||
|
||||
box->gradient_buf = g_realloc (box->gradient_buf, MAX (0, 3 * width * height));
|
||||
gimp_color_bar_set_channel (bar, view->channel);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_histogram_box_gradient_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event,
|
||||
gpointer data)
|
||||
static void
|
||||
gimp_histogram_box_border_notify (GimpHistogramView *view,
|
||||
GParamSpec *pspec,
|
||||
GimpColorBar *bar)
|
||||
{
|
||||
GimpHistogramBox *box = GIMP_HISTOGRAM_BOX (data);
|
||||
GimpHistogramChannel channel;
|
||||
g_object_set (bar,
|
||||
"xpad", view->border_width,
|
||||
"ypad", view->border_width,
|
||||
NULL);
|
||||
|
||||
gint i;
|
||||
gint border;
|
||||
gint width, height;
|
||||
guchar r, g, b;
|
||||
|
||||
border = box->view->border_width;
|
||||
width = widget->allocation.width - 2 * border;
|
||||
height = widget->allocation.height - 2 * border;
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return TRUE;
|
||||
|
||||
if (box->view)
|
||||
channel = box->view->channel;
|
||||
else
|
||||
channel = GIMP_HISTOGRAM_VALUE;
|
||||
|
||||
switch (channel)
|
||||
{
|
||||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA: r = g = b = 1;
|
||||
break;
|
||||
case GIMP_HISTOGRAM_RED: r = 1; g = b = 0;
|
||||
break;
|
||||
case GIMP_HISTOGRAM_GREEN: g = 1; r = b = 0;
|
||||
break;
|
||||
case GIMP_HISTOGRAM_BLUE: b = 1; r = g = 0;
|
||||
break;
|
||||
default:
|
||||
r = g = b = 0;
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
guchar *buffer = box->gradient_buf + 3 * i;
|
||||
gint x = (i * 256) / width;
|
||||
|
||||
buffer[0] = x * r;
|
||||
buffer[1] = x * g;
|
||||
buffer[2] = x * b;
|
||||
}
|
||||
|
||||
for (i = 1; i < height; i++)
|
||||
memcpy (box->gradient_buf + 3 * i * width, box->gradient_buf, 3 * width);
|
||||
|
||||
gdk_draw_rgb_image (widget->window, widget->style->black_gc,
|
||||
border, border, width, height, GDK_RGB_DITHER_NORMAL,
|
||||
box->gradient_buf, 3 * width);
|
||||
|
||||
return TRUE;
|
||||
gtk_widget_set_size_request (GTK_WIDGET (bar),
|
||||
-1, GRADIENT_HEIGHT + 2 * view->border_width);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
|
|
@ -36,8 +36,6 @@ struct _GimpHistogramBox
|
|||
|
||||
GtkWidget *label;
|
||||
GimpHistogramView *view;
|
||||
GtkWidget *gradient;
|
||||
guchar *gradient_buf;
|
||||
|
||||
GtkAdjustment *low_adj;
|
||||
GtkAdjustment *high_adj;
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct _GimpEditor GimpEditor;
|
|||
typedef struct _GimpDeviceStatus GimpDeviceStatus;
|
||||
typedef struct _GimpErrorConsole GimpErrorConsole;
|
||||
typedef struct _GimpImageEditor GimpImageEditor;
|
||||
typedef struct _GimpColorBar GimpColorBar;
|
||||
typedef struct _GimpColorEditor GimpColorEditor;
|
||||
typedef struct _GimpColormapEditor GimpColormapEditor;
|
||||
typedef struct _GimpComponentEditor GimpComponentEditor;
|
||||
|
|
Loading…
Reference in New Issue