Commit a1c3265e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added a hack that allows to render the histogram in a brighter color.

2003-12-12  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimphistogramview.[ch]: added a hack that allows to
	render the histogram in a brighter color. Fixed initial range for
	views that are not selectable.

	* app/tools/gimpcurvestool.[ch]: replaced the GtkDrawingArea by a
	bright GimpHistogramView and render the curves tool controls on
	top of the histogram. Fixes bug #71633.
parent 7f7440f0
2003-12-12 Michael Natterer <mitch@gimp.org>
* app/widgets/gimphistogramview.[ch]: added a hack that allows to
render the histogram in a brighter color. Fixed initial range for
views that are not selectable.
* app/tools/gimpcurvestool.[ch]: replaced the GtkDrawingArea by a
bright GimpHistogramView and render the curves tool controls on
top of the histogram. Fixes bug #71633.
2003-12-11 Sven Neumann <sven@gimp.org> 2003-12-11 Sven Neumann <sven@gimp.org>
* app/widgets/gimpdockable.c (gimp_dockable_init): suppress * app/widgets/gimpdockable.c (gimp_dockable_init): suppress
...@@ -37,11 +37,15 @@ ...@@ -37,11 +37,15 @@
#include "tools-types.h" #include "tools-types.h"
#include "config/gimpbaseconfig.h"
#include "base/curves.h" #include "base/curves.h"
#include "base/gimphistogram.h" #include "base/gimphistogram.h"
#include "base/gimplut.h" #include "base/gimplut.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdrawable-histogram.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimagemap.h" #include "core/gimpimagemap.h"
#include "core/gimptoolinfo.h" #include "core/gimptoolinfo.h"
...@@ -49,6 +53,7 @@ ...@@ -49,6 +53,7 @@
#include "widgets/gimpcursor.h" #include "widgets/gimpcursor.h"
#include "widgets/gimpenummenu.h" #include "widgets/gimpenummenu.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimphistogramview.h"
#include "display/gimpdisplay.h" #include "display/gimpdisplay.h"
...@@ -127,11 +132,11 @@ static void curves_load_callback (GtkWidget *widget, ...@@ -127,11 +132,11 @@ static void curves_load_callback (GtkWidget *widget,
GimpCurvesTool *c_tool); GimpCurvesTool *c_tool);
static void curves_save_callback (GtkWidget *widget, static void curves_save_callback (GtkWidget *widget,
GimpCurvesTool *c_tool); GimpCurvesTool *c_tool);
static gint curves_graph_events (GtkWidget *widget, static gboolean curves_graph_events (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
GimpCurvesTool *c_tool); GimpCurvesTool *c_tool);
static void curves_graph_expose (GtkWidget *widget, static gboolean curves_graph_expose (GtkWidget *widget,
GdkRectangle *area, GdkEventExpose *eevent,
GimpCurvesTool *c_tool); GimpCurvesTool *c_tool);
static void file_dialog_create (GimpCurvesTool *c_tool); static void file_dialog_create (GimpCurvesTool *c_tool);
...@@ -261,6 +266,11 @@ gimp_curves_tool_finalize (GObject *object) ...@@ -261,6 +266,11 @@ gimp_curves_tool_finalize (GObject *object)
gimp_lut_free (c_tool->lut); gimp_lut_free (c_tool->lut);
c_tool->lut = NULL; c_tool->lut = NULL;
} }
if (c_tool->hist)
{
gimp_histogram_free (c_tool->hist);
c_tool->hist = NULL;
}
if (c_tool->cursor_layout) if (c_tool->cursor_layout)
{ {
g_object_unref (c_tool->cursor_layout); g_object_unref (c_tool->cursor_layout);
...@@ -293,6 +303,13 @@ gimp_curves_tool_initialize (GimpTool *tool, ...@@ -293,6 +303,13 @@ gimp_curves_tool_initialize (GimpTool *tool,
return; return;
} }
if (! c_tool->hist)
{
Gimp *gimp = GIMP_TOOL (c_tool)->tool_info->gimp;
c_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
}
curves_init (c_tool->curves); curves_init (c_tool->curves);
c_tool->color = gimp_drawable_is_rgb (drawable); c_tool->color = gimp_drawable_is_rgb (drawable);
...@@ -317,6 +334,10 @@ gimp_curves_tool_initialize (GimpTool *tool, ...@@ -317,6 +334,10 @@ gimp_curves_tool_initialize (GimpTool *tool,
c_tool->channel); c_tool->channel);
curves_update (c_tool, ALL); curves_update (c_tool, ALL);
gimp_drawable_calculate_histogram (drawable, c_tool->hist);
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->hist);
} }
static void static void
...@@ -524,17 +545,25 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool) ...@@ -524,17 +545,25 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
GTK_SHRINK | GTK_FILL, 0, 0); GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (frame); gtk_widget_show (frame);
c_tool->graph = gtk_drawing_area_new (); c_tool->graph = gimp_histogram_view_new (FALSE);
gtk_widget_set_size_request (c_tool->graph, gtk_widget_set_size_request (c_tool->graph,
GRAPH_WIDTH + RADIUS * 2, GRAPH_WIDTH + RADIUS * 2,
GRAPH_HEIGHT + RADIUS * 2); GRAPH_HEIGHT + RADIUS * 2);
gtk_widget_set_events (c_tool->graph, GRAPH_MASK); gtk_widget_set_events (c_tool->graph, GRAPH_MASK);
g_object_set (c_tool->graph,
"border-width", RADIUS,
"subdivisions", 1,
NULL);
GIMP_HISTOGRAM_VIEW (c_tool->graph)->light_histogram = TRUE;
gtk_container_add (GTK_CONTAINER (frame), c_tool->graph); gtk_container_add (GTK_CONTAINER (frame), c_tool->graph);
gtk_widget_show (c_tool->graph); gtk_widget_show (c_tool->graph);
g_signal_connect (c_tool->graph, "event", g_signal_connect (c_tool->graph, "event",
G_CALLBACK (curves_graph_events), G_CALLBACK (curves_graph_events),
c_tool); c_tool);
g_signal_connect_after (c_tool->graph, "expose_event",
G_CALLBACK (curves_graph_expose),
c_tool);
/* The range drawing area */ /* The range drawing area */
frame = gtk_frame_new (NULL); frame = gtk_frame_new (NULL);
...@@ -756,19 +785,22 @@ curves_channel_callback (GtkWidget *widget, ...@@ -756,19 +785,22 @@ curves_channel_callback (GtkWidget *widget,
{ {
gimp_menu_item_update (widget, &c_tool->channel); gimp_menu_item_update (widget, &c_tool->channel);
if (! c_tool->color) if (c_tool->color)
{ {
if (c_tool->channel > 1) gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->channel = 2; c_tool->channel);
else }
c_tool->channel = 1; else
{
c_tool->channel = (c_tool->channel > 1) ? 2 : 1;
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->channel - 1);
} }
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type), gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type),
c_tool->curves->curve_type[c_tool->channel]); c_tool->curves->curve_type[c_tool->channel]);
curves_update (c_tool, XRANGE_TOP | YRANGE); curves_update (c_tool, XRANGE_TOP | YRANGE);
gtk_widget_queue_draw (c_tool->graph);
} }
static void static void
...@@ -858,12 +890,6 @@ curves_graph_events (GtkWidget *widget, ...@@ -858,12 +890,6 @@ curves_graph_events (GtkWidget *widget,
gint distance; gint distance;
gint x1, x2, y1, y2; gint x1, x2, y1, y2;
if (event->type == GDK_EXPOSE)
{
curves_graph_expose (widget, &((GdkEventExpose *) event)->area, c_tool);
return TRUE;
}
/* get the pointer position */ /* get the pointer position */
gdk_window_get_pointer (c_tool->graph->window, &tx, &ty, NULL); gdk_window_get_pointer (c_tool->graph->window, &tx, &ty, NULL);
x = CLAMP ((tx - RADIUS), 0, 255); x = CLAMP ((tx - RADIUS), 0, 255);
...@@ -1083,18 +1109,18 @@ curve_print_loc (GimpCurvesTool *c_tool) ...@@ -1083,18 +1109,18 @@ curve_print_loc (GimpCurvesTool *c_tool)
c_tool->cursor_layout); c_tool->cursor_layout);
} }
static void static gboolean
curves_graph_expose (GtkWidget *widget, curves_graph_expose (GtkWidget *widget,
GdkRectangle *area, GdkEventExpose *eevent,
GimpCurvesTool *c_tool) GimpCurvesTool *c_tool)
{ {
GimpHistogramChannel sel_channel; GimpHistogramChannel sel_channel;
gchar buf[32];
gchar buf[32]; gint offset;
gint offset; gint height;
gint height; gint i;
gint i; GdkPoint points[256];
GdkPoint points[256]; GdkGC *graph_gc;
if (c_tool->color) if (c_tool->color)
{ {
...@@ -1108,27 +1134,26 @@ curves_graph_expose (GtkWidget *widget, ...@@ -1108,27 +1134,26 @@ curves_graph_expose (GtkWidget *widget,
sel_channel = GIMP_HISTOGRAM_VALUE; sel_channel = GIMP_HISTOGRAM_VALUE;
} }
/* Draw the background */
gdk_draw_rectangle (widget->window,
widget->style->base_gc[GTK_STATE_NORMAL], TRUE,
0, 0,
widget->allocation.width,
widget->allocation.height);
/* Draw the grid lines */ /* Draw the grid lines */
for (i = 0; i < 5; i++) for (i = 1; i < 4; i++)
{ {
gdk_draw_line (widget->window, gdk_draw_line (widget->window,
c_tool->graph->style->text_aa_gc[GTK_STATE_NORMAL], c_tool->graph->style->text_aa_gc[GTK_STATE_NORMAL],
RADIUS, i * (GRAPH_HEIGHT / 4) + RADIUS, RADIUS,
GRAPH_WIDTH + RADIUS, i * (GRAPH_HEIGHT / 4) + RADIUS); RADIUS + i * (GRAPH_HEIGHT / 4),
RADIUS + GRAPH_WIDTH - 1,
RADIUS + i * (GRAPH_HEIGHT / 4));
gdk_draw_line (widget->window, gdk_draw_line (widget->window,
c_tool->graph->style->text_aa_gc[GTK_STATE_NORMAL], c_tool->graph->style->text_aa_gc[GTK_STATE_NORMAL],
i * (GRAPH_WIDTH / 4) + RADIUS, RADIUS, RADIUS + i * (GRAPH_WIDTH / 4),
i * (GRAPH_WIDTH / 4) + RADIUS, GRAPH_HEIGHT + RADIUS); RADIUS,
RADIUS + i * (GRAPH_WIDTH / 4),
RADIUS + GRAPH_HEIGHT - 1);
} }
/* Draw the curve */ /* Draw the curve */
graph_gc = c_tool->graph->style->text_gc[GTK_STATE_NORMAL];
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
points[i].x = i + RADIUS; points[i].x = i + RADIUS;
...@@ -1138,13 +1163,13 @@ curves_graph_expose (GtkWidget *widget, ...@@ -1138,13 +1163,13 @@ curves_graph_expose (GtkWidget *widget,
if (c_tool->curves->curve_type[c_tool->channel] == GIMP_CURVE_FREE) if (c_tool->curves->curve_type[c_tool->channel] == GIMP_CURVE_FREE)
{ {
gdk_draw_points (widget->window, gdk_draw_points (widget->window,
c_tool->graph->style->text_gc[GTK_STATE_NORMAL], graph_gc,
points, 256); points, 256);
} }
else else
{ {
gdk_draw_lines (widget->window, gdk_draw_lines (widget->window,
c_tool->graph->style->text_gc[GTK_STATE_NORMAL], graph_gc,
points, 256); points, 256);
/* Draw the points */ /* Draw the points */
...@@ -1152,7 +1177,7 @@ curves_graph_expose (GtkWidget *widget, ...@@ -1152,7 +1177,7 @@ curves_graph_expose (GtkWidget *widget,
{ {
if (c_tool->curves->points[c_tool->channel][i][0] != -1) if (c_tool->curves->points[c_tool->channel][i][0] != -1)
gdk_draw_arc (widget->window, gdk_draw_arc (widget->window,
c_tool->graph->style->text_gc[GTK_STATE_NORMAL], graph_gc,
TRUE, TRUE,
c_tool->curves->points[c_tool->channel][i][0], c_tool->curves->points[c_tool->channel][i][0],
255 - c_tool->curves->points[c_tool->channel][i][1], 255 - c_tool->curves->points[c_tool->channel][i][1],
...@@ -1164,11 +1189,11 @@ curves_graph_expose (GtkWidget *widget, ...@@ -1164,11 +1189,11 @@ curves_graph_expose (GtkWidget *widget,
{ {
/* draw the color line */ /* draw the color line */
gdk_draw_line (widget->window, gdk_draw_line (widget->window,
c_tool->graph->style->text_gc[GTK_STATE_NORMAL], graph_gc,
c_tool->col_value[sel_channel] + RADIUS, c_tool->col_value[sel_channel] + RADIUS,
RADIUS, RADIUS,
c_tool->col_value[sel_channel] + RADIUS, c_tool->col_value[sel_channel] + RADIUS,
GRAPH_HEIGHT + RADIUS); GRAPH_HEIGHT + RADIUS - 1);
/* and xpos indicator */ /* and xpos indicator */
g_snprintf (buf, sizeof (buf), "x:%d", g_snprintf (buf, sizeof (buf), "x:%d",
...@@ -1188,15 +1213,16 @@ curves_graph_expose (GtkWidget *widget, ...@@ -1188,15 +1213,16 @@ curves_graph_expose (GtkWidget *widget,
offset = - (offset + 2); offset = - (offset + 2);
gdk_draw_layout (widget->window, gdk_draw_layout (widget->window,
c_tool->graph->style->text_gc[GTK_STATE_NORMAL], graph_gc,
c_tool->col_value[sel_channel] + offset, c_tool->col_value[sel_channel] + offset,
GRAPH_HEIGHT - height - 2, GRAPH_HEIGHT - height - 2,
c_tool->xpos_layout); c_tool->xpos_layout);
} }
curve_print_loc (c_tool); curve_print_loc (c_tool);
}
return FALSE;
}
static void static void
curves_load_callback (GtkWidget *widget, curves_load_callback (GtkWidget *widget,
......
...@@ -50,14 +50,16 @@ struct _GimpCurvesTool ...@@ -50,14 +50,16 @@ struct _GimpCurvesTool
gint rightmost; gint rightmost;
gint col_value[5]; gint col_value[5];
GimpHistogram *hist;
GtkWidget *channel_menu; GtkWidget *channel_menu;
GtkWidget *xrange; GtkWidget *xrange;
GtkWidget *yrange; GtkWidget *yrange;
GtkWidget *graph; GtkWidget *graph;
GtkWidget *curve_type; GtkWidget *curve_type;
gint cursor_x; gint cursor_x;
gint cursor_y; gint cursor_y;
PangoLayout *xpos_layout; PangoLayout *xpos_layout;
PangoLayout *cursor_layout; PangoLayout *cursor_layout;
PangoRectangle cursor_rect; PangoRectangle cursor_rect;
......
...@@ -358,6 +358,8 @@ gimp_histogram_view_expose (GtkWidget *widget, ...@@ -358,6 +358,8 @@ gimp_histogram_view_expose (GtkWidget *widget,
} }
gdk_draw_line (widget->window, gdk_draw_line (widget->window,
view->light_histogram ?
widget->style->mid_gc[GTK_STATE_NORMAL] :
widget->style->text_gc[GTK_STATE_NORMAL], widget->style->text_gc[GTK_STATE_NORMAL],
x + border, height + border - 1, x + border, height + border - 1,
x + border, height + border - y - 1); x + border, height + border - y - 1);
...@@ -463,17 +465,10 @@ gimp_histogram_view_new (gboolean range) ...@@ -463,17 +465,10 @@ gimp_histogram_view_new (gboolean range)
GtkWidget *view = g_object_new (GIMP_TYPE_HISTOGRAM_VIEW, NULL); GtkWidget *view = g_object_new (GIMP_TYPE_HISTOGRAM_VIEW, NULL);
if (range) if (range)
{ gtk_widget_add_events (view,
gtk_widget_add_events (view, GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK);
GDK_BUTTON1_MOTION_MASK);
}
else
{
GIMP_HISTOGRAM_VIEW (view)->start = -1;
GIMP_HISTOGRAM_VIEW (view)->end = -1;
}
return view; return view;
} }
......
...@@ -46,6 +46,9 @@ struct _GimpHistogramView ...@@ -46,6 +46,9 @@ struct _GimpHistogramView
gint border_width; gint border_width;
gint subdivisions; gint subdivisions;
GdkGC *range_gc; GdkGC *range_gc;
/* hack */
gboolean light_histogram;
}; };
struct _GimpHistogramViewClass struct _GimpHistogramViewClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment