Commit 8c5fe3b5 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

indicate the viewport by shading the outside region using Cairo.

2008-08-22  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpnavigationview.c: indicate the viewport by
	shading the outside region using Cairo.


svn path=/trunk/; revision=26716
parent 9a52100e
2008-08-22 Sven Neumann <sven@gimp.org>
* app/widgets/gimpnavigationview.c: indicate the viewport by
shading the outside region using Cairo.
2008-08-22 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpnavigationeditor.c: Align static function
......
......@@ -70,17 +70,13 @@ struct _GimpNavigationView
gint motion_offset_x;
gint motion_offset_y;
gboolean has_grab;
GdkGC *gc;
};
static void gimp_navigation_view_realize (GtkWidget *widget);
static void gimp_navigation_view_unrealize (GtkWidget *widget);
static void gimp_navigation_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gimp_navigation_view_expose (GtkWidget *widget,
GdkEventExpose *eevent);
GdkEventExpose *event);
static gboolean gimp_navigation_view_button_press (GtkWidget *widget,
GdkEventButton *bevent);
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
......@@ -94,7 +90,7 @@ static gboolean gimp_navigation_view_key_press (GtkWidget *widget,
static void gimp_navigation_view_transform (GimpNavigationView *nav_view);
static void gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
GdkRectangle *area);
cairo_t *cr);
G_DEFINE_TYPE (GimpNavigationView, gimp_navigation_view, GIMP_TYPE_VIEW)
......@@ -142,8 +138,6 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
G_TYPE_NONE, 1,
GDK_TYPE_SCROLL_DIRECTION);
widget_class->realize = gimp_navigation_view_realize;
widget_class->unrealize = gimp_navigation_view_unrealize;
widget_class->size_allocate = gimp_navigation_view_size_allocate;
widget_class->expose_event = gimp_navigation_view_expose;
widget_class->button_press_event = gimp_navigation_view_button_press;
......@@ -173,34 +167,6 @@ gimp_navigation_view_init (GimpNavigationView *view)
view->motion_offset_x = 0;
view->motion_offset_y = 0;
view->has_grab = FALSE;
view->gc = NULL;
}
static void
gimp_navigation_view_realize (GtkWidget *widget)
{
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
GTK_WIDGET_CLASS (parent_class)->realize (widget);
nav_view->gc = gdk_gc_new (widget->window);
gdk_gc_set_function (nav_view->gc, GDK_INVERT);
}
static void
gimp_navigation_view_unrealize (GtkWidget *widget)
{
GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
if (nav_view->gc)
{
g_object_unref (nav_view->gc);
nav_view->gc = NULL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
......@@ -215,14 +181,22 @@ gimp_navigation_view_size_allocate (GtkWidget *widget,
static gboolean
gimp_navigation_view_expose (GtkWidget *widget,
GdkEventExpose *eevent)
GdkEventExpose *event)
{
if (GTK_WIDGET_DRAWABLE (widget))
{
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, eevent);
cairo_t *cr;
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
cr = gdk_cairo_create (widget->window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
gimp_navigation_view_draw_marker (GIMP_NAVIGATION_VIEW (widget), cr);
gimp_navigation_view_draw_marker (GIMP_NAVIGATION_VIEW (widget),
&eevent->area);
cairo_destroy (cr);
}
return TRUE;
......@@ -511,56 +485,36 @@ gimp_navigation_view_transform (GimpNavigationView *nav_view)
static void
gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
GdkRectangle *area)
cairo_t *cr)
{
GimpView *view = GIMP_VIEW (nav_view);
if (view->renderer->viewable &&
nav_view->width &&
nav_view->height)
if (view->renderer->viewable && nav_view->width && nav_view->height)
{
GtkWidget *widget = GTK_WIDGET (view);
gint start_x;
gint start_y;
if (area)
gdk_gc_set_clip_rectangle (nav_view->gc, area);
start_x = widget->allocation.x + nav_view->p_x;
start_y = widget->allocation.y + nav_view->p_y;
/* Draw outer frame */
gdk_gc_set_line_attributes (nav_view->gc,
OUTER_BORDER_PEN_WIDTH,
GDK_LINE_SOLID,
GDK_CAP_BUTT,
GDK_JOIN_MITER);
gdk_draw_rectangle (widget->window,
nav_view->gc,
FALSE,
start_x + OUTER_BORDER_PEN_WIDTH / 2,
start_y + OUTER_BORDER_PEN_WIDTH / 2,
nav_view->p_width - OUTER_BORDER_PEN_WIDTH,
nav_view->p_height - OUTER_BORDER_PEN_WIDTH);
/* Draw inner frame */
gdk_gc_set_line_attributes (nav_view->gc,
INNER_BORDER_PEN_WIDTH,
GDK_LINE_ON_OFF_DASH,
GDK_CAP_BUTT,
GDK_JOIN_MITER);
gdk_draw_rectangle (widget->window,
nav_view->gc,
FALSE,
start_x + OUTER_BORDER_PEN_WIDTH + INNER_BORDER_PEN_WIDTH / 2,
start_y + OUTER_BORDER_PEN_WIDTH + INNER_BORDER_PEN_WIDTH / 2,
nav_view->p_width - OUTER_BORDER_PEN_WIDTH * 2 - INNER_BORDER_PEN_WIDTH,
nav_view->p_height - OUTER_BORDER_PEN_WIDTH * 2 - INNER_BORDER_PEN_WIDTH);
if (area)
gdk_gc_set_clip_rectangle (nav_view->gc, NULL);
GdkColor *color = &widget->style->fg[widget->state];
cairo_translate (cr, widget->allocation.x, widget->allocation.y);
cairo_rectangle (cr,
0, 0, widget->allocation.width, widget->allocation.height);
cairo_rectangle (cr,
nav_view->p_x, nav_view->p_y, nav_view->p_width, nav_view->p_height);
cairo_set_source_rgba (cr,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535., 0.5);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill (cr);
cairo_rectangle (cr,
nav_view->p_x, nav_view->p_y, nav_view->p_width, nav_view->p_height);
gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
cairo_set_line_width (cr, 2);
cairo_stroke (cr);
}
}
......@@ -571,20 +525,14 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view,
gdouble width,
gdouble height)
{
GtkWidget *navview;
GimpView *view;
GimpView *view;
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (nav_view));
navview = GTK_WIDGET (nav_view);
view = GIMP_VIEW (nav_view);
view = GIMP_VIEW (nav_view);
g_return_if_fail (view->renderer->viewable);
/* remove old marker */
if (GTK_WIDGET_DRAWABLE (view))
gimp_navigation_view_draw_marker (nav_view, &navview->allocation);
nav_view->x = x;
nav_view->y = y;
nav_view->width = MAX (1.0, width);
......@@ -593,8 +541,7 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view,
gimp_navigation_view_transform (nav_view);
/* draw new marker */
if (GTK_WIDGET_DRAWABLE (view))
gimp_navigation_view_draw_marker (nav_view, &navview->allocation);
gtk_widget_queue_draw (GTK_WIDGET (view));
}
void
......
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