Compare commits
9 Commits
quick-keyb
...
wip/render
Author | SHA1 | Date | |
---|---|---|---|
|
34a2a57895 | ||
|
fe26e863ea | ||
|
2f90e1a7d9 | ||
|
84144393bc | ||
|
b8accdcd0a | ||
|
5da78ac0c5 | ||
|
3fc2dc9a5c | ||
|
8105d45fe1 | ||
|
fc9b67a739 |
@@ -482,6 +482,7 @@ gtk_private_h_sources = \
|
||||
gtkpixelcacheprivate.h \
|
||||
gtkquery.h \
|
||||
gtkrangeprivate.h \
|
||||
gtkrenderopsprivate.h \
|
||||
gtkrbtree.h \
|
||||
gtkrecentchooserdefault.h \
|
||||
gtkrecentchooserprivate.h \
|
||||
@@ -782,6 +783,7 @@ gtk_base_c_sources = \
|
||||
gtkrenderbackground.c \
|
||||
gtkrenderborder.c \
|
||||
gtkrendericon.c \
|
||||
gtkrenderops.c \
|
||||
gtkresources.c \
|
||||
gtkrevealer.c \
|
||||
gtkroundedbox.c \
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
@@ -1540,12 +1541,12 @@ gtk_image_size_allocate (GtkWidget *widget,
|
||||
/* XXX: This is not strictly correct, we could compute the area
|
||||
* actually occupied by the image, but I'm lazy...
|
||||
*/
|
||||
_gtk_style_context_get_icon_extents (gtk_widget_get_style_context (widget),
|
||||
&clip,
|
||||
allocation->x,
|
||||
allocation->y,
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
gtk_css_style_get_icon_extents (gtk_style_context_lookup_style (gtk_widget_get_style_context (widget)),
|
||||
&clip,
|
||||
allocation->x,
|
||||
allocation->y,
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
|
||||
_gtk_widget_set_simple_clip (widget, &clip);
|
||||
}
|
||||
|
@@ -31,9 +31,7 @@
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkcsstransformvalueprivate.h"
|
||||
#include "gtkhslaprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtkrenderopsprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
#include "fallback-c89.c"
|
||||
@@ -57,7 +55,7 @@ gtk_do_render_check (GtkStyleContext *context,
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_CHECK;
|
||||
|
||||
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, image_type);
|
||||
gtk_render_ops_draw_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, image_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +120,7 @@ gtk_do_render_option (GtkStyleContext *context,
|
||||
else
|
||||
image_type = GTK_CSS_IMAGE_BUILTIN_OPTION;
|
||||
|
||||
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, image_type);
|
||||
gtk_render_ops_draw_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, image_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +197,7 @@ gtk_do_render_arrow (GtkStyleContext *context,
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, size, size, image_type);
|
||||
gtk_render_ops_draw_icon (gtk_style_context_lookup_style (context), cr, x, y, size, size, image_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,9 +278,9 @@ gtk_render_background (GtkStyleContext *context,
|
||||
cairo_save (cr);
|
||||
cairo_new_path (cr);
|
||||
|
||||
gtk_css_style_render_background (gtk_style_context_lookup_style (context),
|
||||
cr, x, y, width, height,
|
||||
gtk_style_context_get_junction_sides (context));
|
||||
gtk_render_ops_draw_background (gtk_style_context_lookup_style (context),
|
||||
cr, x, y, width, height,
|
||||
gtk_style_context_get_junction_sides (context));
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
@@ -322,11 +320,11 @@ gtk_render_frame (GtkStyleContext *context,
|
||||
cairo_save (cr);
|
||||
cairo_new_path (cr);
|
||||
|
||||
gtk_css_style_render_border (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
x, y, width, height,
|
||||
0,
|
||||
gtk_style_context_get_junction_sides (context));
|
||||
gtk_render_ops_draw_border (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
x, y, width, height,
|
||||
0,
|
||||
gtk_style_context_get_junction_sides (context));
|
||||
|
||||
|
||||
cairo_restore (cr);
|
||||
@@ -367,7 +365,7 @@ gtk_do_render_expander (GtkStyleContext *context,
|
||||
: GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT;
|
||||
}
|
||||
|
||||
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, image_type);
|
||||
gtk_render_ops_draw_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, image_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,9 +443,9 @@ gtk_render_focus (GtkStyleContext *context,
|
||||
cairo_save (cr);
|
||||
cairo_new_path (cr);
|
||||
|
||||
gtk_css_style_render_outline (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
x, y, width, height);
|
||||
gtk_render_ops_draw_outline (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
x, y, width, height);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
@@ -604,15 +602,15 @@ gtk_do_render_slider (GtkStyleContext *context,
|
||||
style = gtk_style_context_lookup_style (context);
|
||||
junction = gtk_style_context_get_junction_sides (context);
|
||||
|
||||
gtk_css_style_render_background (style,
|
||||
cr,
|
||||
x, y, width, height,
|
||||
junction);
|
||||
gtk_css_style_render_border (style,
|
||||
cr,
|
||||
x, y, width, height,
|
||||
0,
|
||||
junction);
|
||||
gtk_render_ops_draw_background (style,
|
||||
cr,
|
||||
x, y, width, height,
|
||||
junction);
|
||||
gtk_render_ops_draw_border (style,
|
||||
cr,
|
||||
x, y, width, height,
|
||||
0,
|
||||
junction);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -751,9 +749,9 @@ gtk_css_style_render_frame_gap (GtkCssStyle *style,
|
||||
cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc));
|
||||
cairo_clip (cr);
|
||||
|
||||
gtk_css_style_render_border (style, cr,
|
||||
x, y, width, height,
|
||||
0, junction);
|
||||
gtk_render_ops_draw_border (style, cr,
|
||||
x, y, width, height,
|
||||
0, junction);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
@@ -851,15 +849,15 @@ gtk_css_style_render_extension (GtkCssStyle *style,
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_css_style_render_background (style,
|
||||
cr,
|
||||
x, y,
|
||||
width, height,
|
||||
junction);
|
||||
gtk_render_ops_draw_background (style,
|
||||
cr,
|
||||
x, y,
|
||||
width, height,
|
||||
junction);
|
||||
|
||||
gtk_css_style_render_border (style, cr,
|
||||
x, y, width, height,
|
||||
hidden_side, junction);
|
||||
gtk_render_ops_draw_border (style, cr,
|
||||
x, y, width, height,
|
||||
hidden_side, junction);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -954,7 +952,7 @@ gtk_do_render_handle (GtkStyleContext *context,
|
||||
type = GTK_CSS_IMAGE_BUILTIN_HANDLE;
|
||||
}
|
||||
|
||||
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, type);
|
||||
gtk_render_ops_draw_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1030,7 +1028,7 @@ gtk_render_activity (GtkStyleContext *context,
|
||||
cairo_save (cr);
|
||||
cairo_new_path (cr);
|
||||
|
||||
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, GTK_CSS_IMAGE_BUILTIN_SPINNER);
|
||||
gtk_render_ops_draw_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, GTK_CSS_IMAGE_BUILTIN_SPINNER);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
@@ -1224,10 +1222,10 @@ gtk_render_icon (GtkStyleContext *context,
|
||||
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
|
||||
|
||||
gtk_css_style_render_icon_surface (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
surface,
|
||||
x, y);
|
||||
gtk_render_ops_draw_icon_surface (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
surface,
|
||||
x, y);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
@@ -1259,10 +1257,10 @@ gtk_render_icon_surface (GtkStyleContext *context,
|
||||
cairo_save (cr);
|
||||
cairo_new_path (cr);
|
||||
|
||||
gtk_css_style_render_icon_surface (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
surface,
|
||||
x, y);
|
||||
gtk_render_ops_draw_icon_surface (gtk_style_context_lookup_style (context),
|
||||
cr,
|
||||
surface,
|
||||
x, y);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
@@ -26,6 +26,92 @@
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkcsstransformvalueprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
static void
|
||||
gtk_cairo_rectangle_transform (cairo_rectangle_int_t *dest,
|
||||
const cairo_rectangle_int_t *src,
|
||||
const cairo_matrix_t *matrix)
|
||||
{
|
||||
double x1, x2, x3, x4;
|
||||
double y1, y2, y3, y4;
|
||||
|
||||
g_return_if_fail (dest != NULL);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (matrix != NULL);
|
||||
|
||||
x1 = src->x;
|
||||
y1 = src->y;
|
||||
x2 = src->x + src->width;
|
||||
y2 = src->y;
|
||||
x3 = src->x + src->width;
|
||||
y3 = src->y + src->height;
|
||||
x4 = src->x;
|
||||
y4 = src->y + src->height;
|
||||
|
||||
cairo_matrix_transform_point (matrix, &x1, &y1);
|
||||
cairo_matrix_transform_point (matrix, &x2, &y2);
|
||||
cairo_matrix_transform_point (matrix, &x3, &y3);
|
||||
cairo_matrix_transform_point (matrix, &x4, &y4);
|
||||
|
||||
dest->x = floor (MIN (MIN (x1, x2), MIN (x3, x4)));
|
||||
dest->y = floor (MIN (MIN (y1, y2), MIN (y3, y4)));
|
||||
dest->width = ceil (MAX (MAX (x1, x2), MAX (x3, x4))) - dest->x;
|
||||
dest->height = ceil (MAX (MAX (y1, y2), MAX (y3, y4))) - dest->y;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_style_get_icon_extents (GtkCssStyle *style,
|
||||
GdkRectangle *extents,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
cairo_matrix_t transform_matrix, matrix;
|
||||
GtkBorder border;
|
||||
GdkRectangle rect;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), FALSE);
|
||||
g_return_val_if_fail (extents != NULL, FALSE);
|
||||
|
||||
if (_gtk_css_image_value_get_image (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SOURCE)) == NULL)
|
||||
{
|
||||
extents->x = extents->y = extents->width = extents->height = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extents->x = x;
|
||||
extents->y = y;
|
||||
extents->width = width;
|
||||
extents->height = height;
|
||||
|
||||
/* builtin images can't be transformed */
|
||||
if (GTK_IS_CSS_IMAGE_BUILTIN (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SOURCE)))
|
||||
return TRUE;
|
||||
|
||||
if (!_gtk_css_transform_value_get_matrix (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_TRANSFORM), &transform_matrix))
|
||||
return TRUE;
|
||||
|
||||
cairo_matrix_init_translate (&matrix, x + width / 2.0, y + height / 2.0);
|
||||
cairo_matrix_multiply (&matrix, &transform_matrix, &matrix);
|
||||
/* need to round to full pixels */
|
||||
rect.x = - (width + 1) / 2;
|
||||
rect.y = - (height + 1) / 2;
|
||||
rect.width = (width + 1) & ~1;
|
||||
rect.height = (height + 1) & ~1;
|
||||
gtk_cairo_rectangle_transform (extents, &rect, &matrix);
|
||||
|
||||
_gtk_css_shadows_value_get_extents (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SHADOW), &border);
|
||||
|
||||
extents->x -= border.left;
|
||||
extents->y -= border.top;
|
||||
extents->width += border.left + border.right;
|
||||
extents->height += border.top + border.bottom;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_style_render_icon (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
|
@@ -29,19 +29,26 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gtk_css_style_render_icon (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type);
|
||||
gboolean gtk_css_style_get_icon_extents (GtkCssStyle *style,
|
||||
GdkRectangle *extents,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
void gtk_css_style_render_icon_surface (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
double x,
|
||||
double y);
|
||||
void gtk_css_style_render_icon (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type);
|
||||
|
||||
void gtk_css_style_render_icon_surface (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
283
gtk/gtkrenderops.c
Normal file
283
gtk/gtkrenderops.c
Normal file
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderopsprivate.h"
|
||||
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOps, gtk_render_ops, G_TYPE_OBJECT)
|
||||
|
||||
static cairo_t *
|
||||
gtk_render_ops_real_begin_draw_widget (GtkRenderOps *ops,
|
||||
GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
return cairo_reference (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_ops_real_end_draw_widget (GtkRenderOps *ops,
|
||||
GtkWidget *widget,
|
||||
cairo_t *draw_cr,
|
||||
cairo_t *original_cr)
|
||||
{
|
||||
cairo_destroy (draw_cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_ops_real_draw_background (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
gtk_css_style_render_background (style, cr, x, y, width, height, junction);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_real_draw_border (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
gtk_css_style_render_border (style, cr, x, y, width, height, hidden_side, junction);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_real_draw_outline (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
gtk_css_style_render_outline (style, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_real_draw_icon (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type)
|
||||
{
|
||||
gtk_css_style_render_icon (style, cr, x, y, width, height, builtin_type);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_real_draw_icon_surface (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
gtk_css_style_render_icon_surface (style, cr, surface, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_ops_class_init (GtkRenderOpsClass *klass)
|
||||
{
|
||||
klass->begin_draw_widget = gtk_render_ops_real_begin_draw_widget;
|
||||
klass->end_draw_widget = gtk_render_ops_real_end_draw_widget;
|
||||
klass->draw_background = gtk_render_ops_real_draw_background;
|
||||
klass->draw_border = gtk_render_ops_real_draw_border;
|
||||
klass->draw_outline = gtk_render_ops_real_draw_outline;
|
||||
klass->draw_icon = gtk_render_ops_real_draw_icon;
|
||||
klass->draw_icon_surface = gtk_render_ops_real_draw_icon_surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_ops_init (GtkRenderOps *image)
|
||||
{
|
||||
}
|
||||
|
||||
static const cairo_user_data_key_t render_ops_key;
|
||||
|
||||
static GtkRenderOps *
|
||||
gtk_cairo_get_render_ops (cairo_t *cr)
|
||||
{
|
||||
return cairo_get_user_data (cr, &render_ops_key);
|
||||
}
|
||||
|
||||
/* public API */
|
||||
void
|
||||
gtk_cairo_set_render_ops (cairo_t *cr,
|
||||
GtkRenderOps *ops)
|
||||
{
|
||||
if (ops)
|
||||
{
|
||||
g_object_ref (ops);
|
||||
cairo_set_user_data (cr, &render_ops_key, ops, g_object_unref);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_user_data (cr, &render_ops_key, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
cairo_t *
|
||||
gtk_render_ops_begin_draw_widget (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (cr);
|
||||
if (ops == NULL)
|
||||
return gtk_render_ops_real_begin_draw_widget (NULL, widget, cr);
|
||||
|
||||
return GTK_RENDER_OPS_GET_CLASS (ops)->begin_draw_widget (ops, widget, cr);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_end_draw_widget (GtkWidget *widget,
|
||||
cairo_t *draw_cr,
|
||||
cairo_t *original_cr)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (original_cr);
|
||||
if (ops == NULL)
|
||||
{
|
||||
gtk_render_ops_real_end_draw_widget (NULL, widget, draw_cr, original_cr);
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_RENDER_OPS_GET_CLASS (ops)->end_draw_widget (ops, widget, draw_cr, original_cr);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_draw_background (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (cr);
|
||||
if (ops == NULL)
|
||||
{
|
||||
gtk_render_ops_real_draw_background (NULL, style, cr, x, y, width, height, junction);
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_RENDER_OPS_GET_CLASS (ops)->draw_background (ops, style, cr, x, y, width, height, junction);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_draw_border (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (cr);
|
||||
if (ops == NULL)
|
||||
{
|
||||
gtk_render_ops_real_draw_border (NULL, style, cr, x, y, width, height, hidden_side, junction);
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_RENDER_OPS_GET_CLASS (ops)->draw_border (ops, style, cr, x, y, width, height, hidden_side, junction);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_draw_outline (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (cr);
|
||||
if (ops == NULL)
|
||||
{
|
||||
gtk_render_ops_real_draw_outline (NULL, style, cr, x, y, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_RENDER_OPS_GET_CLASS (ops)->draw_outline (ops, style, cr, x, y, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_draw_icon (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (cr);
|
||||
if (ops == NULL)
|
||||
{
|
||||
gtk_render_ops_real_draw_icon (NULL, style, cr, x, y, width, height, builtin_type);
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_RENDER_OPS_GET_CLASS (ops)->draw_icon (ops, style, cr, x, y, width, height, builtin_type);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_ops_draw_icon_surface (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkRenderOps *ops;
|
||||
|
||||
ops = gtk_cairo_get_render_ops (cr);
|
||||
if (ops == NULL)
|
||||
{
|
||||
gtk_render_ops_real_draw_icon_surface (NULL, style, cr, surface, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_RENDER_OPS_GET_CLASS (ops)->draw_icon_surface (ops, style, cr, surface, x, y);
|
||||
}
|
||||
|
145
gtk/gtkrenderopsprivate.h
Normal file
145
gtk/gtkrenderopsprivate.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPS_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPS_PRIVATE_H__
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include <gtk/gtktypes.h>
|
||||
#include "gtkcssimagebuiltinprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPS (gtk_render_ops_get_type ())
|
||||
#define GTK_RENDER_OPS(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPS, GtkRenderOps))
|
||||
#define GTK_RENDER_OPS_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPS, GtkRenderOpsClass))
|
||||
#define GTK_IS_RENDER_OPS(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPS))
|
||||
#define GTK_IS_RENDER_OPS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPS))
|
||||
#define GTK_RENDER_OPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPS, GtkRenderOpsClass))
|
||||
|
||||
typedef struct _GtkRenderOps GtkRenderOps;
|
||||
typedef struct _GtkRenderOpsClass GtkRenderOpsClass;
|
||||
|
||||
struct _GtkRenderOps
|
||||
{
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct _GtkRenderOpsClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
cairo_t * (* begin_draw_widget) (GtkRenderOps *ops,
|
||||
GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
void (* end_draw_widget) (GtkRenderOps *ops,
|
||||
GtkWidget *widget,
|
||||
cairo_t *draw_cr,
|
||||
cairo_t *original_cr);
|
||||
void (* draw_background) (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction);
|
||||
void (* draw_border) (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction);
|
||||
void (* draw_outline) (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height);
|
||||
void (* draw_icon) (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type);
|
||||
void (* draw_icon_surface) (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
double x,
|
||||
double y);
|
||||
};
|
||||
|
||||
GType gtk_render_ops_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* public API */
|
||||
void gtk_cairo_set_render_ops (cairo_t *cr,
|
||||
GtkRenderOps *ops);
|
||||
|
||||
/* calls from inside GTK */
|
||||
cairo_t * gtk_render_ops_begin_draw_widget (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
void gtk_render_ops_end_draw_widget (GtkWidget *widget,
|
||||
cairo_t *draw_cr,
|
||||
cairo_t *original_cr);
|
||||
|
||||
void gtk_render_ops_draw_background (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction);
|
||||
void gtk_render_ops_draw_border (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction);
|
||||
void gtk_render_ops_draw_outline (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height);
|
||||
void gtk_render_ops_draw_icon (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type);
|
||||
void gtk_render_ops_draw_icon_surface (GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPS_PRIVATE_H__ */
|
@@ -34,6 +34,7 @@
|
||||
#include "gtkimage.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@@ -202,11 +203,11 @@ gtk_spinner_size_allocate (GtkWidget *widget,
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
size = MIN (allocation->width, allocation->height);
|
||||
|
||||
_gtk_style_context_get_icon_extents (context,
|
||||
&clip,
|
||||
allocation->x + (allocation->width - size) / 2,
|
||||
allocation->y + (allocation->height - size) / 2,
|
||||
size, size);
|
||||
gtk_css_style_get_icon_extents (gtk_style_context_lookup_style (context),
|
||||
&clip,
|
||||
allocation->x + (allocation->width - size) / 2,
|
||||
allocation->y + (allocation->height - size) / 2,
|
||||
size, size);
|
||||
|
||||
gdk_rectangle_union (&clip, allocation, &clip);
|
||||
|
||||
|
@@ -3063,87 +3063,6 @@ _gtk_style_context_get_changes (GtkStyleContext *context)
|
||||
return context->priv->invalidating_context;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cairo_rectangle_transform (cairo_rectangle_int_t *dest,
|
||||
const cairo_rectangle_int_t *src,
|
||||
const cairo_matrix_t *matrix)
|
||||
{
|
||||
double x1, x2, x3, x4;
|
||||
double y1, y2, y3, y4;
|
||||
|
||||
g_return_if_fail (dest != NULL);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (matrix != NULL);
|
||||
|
||||
x1 = src->x;
|
||||
y1 = src->y;
|
||||
x2 = src->x + src->width;
|
||||
y2 = src->y;
|
||||
x3 = src->x + src->width;
|
||||
y3 = src->y + src->height;
|
||||
x4 = src->x;
|
||||
y4 = src->y + src->height;
|
||||
|
||||
cairo_matrix_transform_point (matrix, &x1, &y1);
|
||||
cairo_matrix_transform_point (matrix, &x2, &y2);
|
||||
cairo_matrix_transform_point (matrix, &x3, &y3);
|
||||
cairo_matrix_transform_point (matrix, &x4, &y4);
|
||||
|
||||
dest->x = floor (MIN (MIN (x1, x2), MIN (x3, x4)));
|
||||
dest->y = floor (MIN (MIN (y1, y2), MIN (y3, y4)));
|
||||
dest->width = ceil (MAX (MAX (x1, x2), MAX (x3, x4))) - dest->x;
|
||||
dest->height = ceil (MAX (MAX (y1, y2), MAX (y3, y4))) - dest->y;
|
||||
}
|
||||
void
|
||||
_gtk_style_context_get_icon_extents (GtkStyleContext *context,
|
||||
GdkRectangle *extents,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
cairo_matrix_t transform_matrix, matrix;
|
||||
GtkBorder border;
|
||||
GdkRectangle rect;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (extents != NULL);
|
||||
|
||||
if (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)) == NULL)
|
||||
{
|
||||
extents->x = extents->y = extents->width = extents->height = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
extents->x = x;
|
||||
extents->y = y;
|
||||
extents->width = width;
|
||||
extents->height = height;
|
||||
|
||||
/* builtin images can't be transformed */
|
||||
if (GTK_IS_CSS_IMAGE_BUILTIN (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)))
|
||||
return;
|
||||
|
||||
if (!_gtk_css_transform_value_get_matrix (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_TRANSFORM), &transform_matrix))
|
||||
return;
|
||||
|
||||
cairo_matrix_init_translate (&matrix, x + width / 2.0, y + height / 2.0);
|
||||
cairo_matrix_multiply (&matrix, &transform_matrix, &matrix);
|
||||
/* need to round to full pixels */
|
||||
rect.x = - (width + 1) / 2;
|
||||
rect.y = - (height + 1) / 2;
|
||||
rect.width = (width + 1) & ~1;
|
||||
rect.height = (height + 1) & ~1;
|
||||
gtk_cairo_rectangle_transform (extents, &rect, &matrix);
|
||||
|
||||
_gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SHADOW), &border);
|
||||
|
||||
extents->x -= border.left;
|
||||
extents->y -= border.top;
|
||||
extents->width += border.left + border.right;
|
||||
extents->height += border.top + border.bottom;
|
||||
}
|
||||
|
||||
static AtkAttributeSet *
|
||||
add_attribute (AtkAttributeSet *attributes,
|
||||
AtkTextAttribute attr,
|
||||
|
@@ -57,13 +57,6 @@ void _gtk_style_context_get_cursor_color (GtkStyleContext
|
||||
GdkRGBA *primary_color,
|
||||
GdkRGBA *secondary_color);
|
||||
|
||||
void _gtk_style_context_get_icon_extents (GtkStyleContext *context,
|
||||
GdkRectangle *extents,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
/* Accessibility support */
|
||||
AtkAttributeSet *_gtk_style_context_get_attributes (AtkAttributeSet *attributes,
|
||||
GtkStyleContext *context,
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkAdjustment GtkAdjustment;
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkrenderopsprivate.h"
|
||||
#include "gtkselectionprivate.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtksizegroup-private.h"
|
||||
@@ -6984,13 +6985,18 @@ _gtk_widget_draw_internal (GtkWidget *widget,
|
||||
if (gdk_cairo_get_clip_rectangle (cr, NULL))
|
||||
{
|
||||
gboolean result;
|
||||
cairo_t *draw_cr;
|
||||
|
||||
gdk_window_mark_paint_from_clip (window, cr);
|
||||
|
||||
draw_cr = gtk_render_ops_begin_draw_widget (widget, cr);
|
||||
|
||||
g_signal_emit (widget, widget_signals[DRAW],
|
||||
0, cr,
|
||||
0, draw_cr,
|
||||
&result);
|
||||
|
||||
gtk_render_ops_end_draw_widget (widget, draw_cr, cr);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_BASELINES))
|
||||
{
|
||||
|
@@ -9,6 +9,13 @@ inspector_c_sources = \
|
||||
inspector/general.c \
|
||||
inspector/gestures.c \
|
||||
inspector/graphdata.c \
|
||||
inspector/gtkrenderoperation.c \
|
||||
inspector/gtkrenderoperationbackground.c \
|
||||
inspector/gtkrenderoperationborder.c \
|
||||
inspector/gtkrenderoperationcairo.c \
|
||||
inspector/gtkrenderoperationicon.c \
|
||||
inspector/gtkrenderoperationoutline.c \
|
||||
inspector/gtkrenderoperationwidget.c \
|
||||
inspector/gtktreemodelcssnode.c \
|
||||
inspector/init.c \
|
||||
inspector/inspect-button.c \
|
||||
@@ -19,10 +26,12 @@ inspector_c_sources = \
|
||||
inspector/object-tree.c \
|
||||
inspector/prop-editor.c \
|
||||
inspector/prop-list.c \
|
||||
inspector/recordingrenderops.c \
|
||||
inspector/resource-list.c \
|
||||
inspector/selector.c \
|
||||
inspector/signals-list.c \
|
||||
inspector/size-groups.c \
|
||||
inspector/snapshot.c \
|
||||
inspector/statistics.c \
|
||||
inspector/style-prop-list.c \
|
||||
inspector/treewalk.c \
|
||||
@@ -40,6 +49,13 @@ inspector_h_sources = \
|
||||
inspector/general.h \
|
||||
inspector/gestures.h \
|
||||
inspector/graphdata.h \
|
||||
inspector/gtkrenderoperation.h \
|
||||
inspector/gtkrenderoperationbackground.h \
|
||||
inspector/gtkrenderoperationborder.h \
|
||||
inspector/gtkrenderoperationcairo.h \
|
||||
inspector/gtkrenderoperationicon.h \
|
||||
inspector/gtkrenderoperationoutline.h \
|
||||
inspector/gtkrenderoperationwidget.h \
|
||||
inspector/gtktreemodelcssnode.h \
|
||||
inspector/init.h \
|
||||
inspector/magnifier.h \
|
||||
@@ -49,10 +65,12 @@ inspector_h_sources = \
|
||||
inspector/object-tree.h \
|
||||
inspector/prop-editor.h \
|
||||
inspector/prop-list.h \
|
||||
inspector/recordingrenderops.h \
|
||||
inspector/resource-list.h \
|
||||
inspector/selector.h \
|
||||
inspector/signals-list.h \
|
||||
inspector/size-groups.h \
|
||||
inspector/snapshot.h \
|
||||
inspector/statistics.h \
|
||||
inspector/style-prop-list.h \
|
||||
inspector/treewalk.h \
|
||||
@@ -75,6 +93,7 @@ inspector_templates = \
|
||||
inspector/resource-list.ui \
|
||||
inspector/selector.ui \
|
||||
inspector/signals-list.ui \
|
||||
inspector/snapshot.ui \
|
||||
inspector/statistics.ui \
|
||||
inspector/style-prop-list.ui \
|
||||
inspector/visual.ui \
|
||||
|
103
gtk/inspector/gtkrenderoperation.c
Normal file
103
gtk/inspector/gtkrenderoperation.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperation, gtk_render_operation, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_render_operation_real_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
clip->x = clip->y = clip->width = clip->height = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_real_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
cairo_matrix_init_identity (matrix);
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_real_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup (G_OBJECT_TYPE_NAME (operation));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_real_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_class_init (GtkRenderOperationClass *klass)
|
||||
{
|
||||
klass->get_clip = gtk_render_operation_real_get_clip;
|
||||
klass->get_matrix = gtk_render_operation_real_get_matrix;
|
||||
klass->describe = gtk_render_operation_real_describe;
|
||||
klass->draw = gtk_render_operation_real_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_init (GtkRenderOperation *image)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_operation_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_RENDER_OPERATION (operation));
|
||||
g_return_if_fail (clip != NULL);
|
||||
|
||||
GTK_RENDER_OPERATION_GET_CLASS (operation)->get_clip (operation, clip);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_operation_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_RENDER_OPERATION (operation));
|
||||
g_return_if_fail (matrix != NULL);
|
||||
|
||||
GTK_RENDER_OPERATION_GET_CLASS (operation)->get_matrix (operation, matrix);
|
||||
}
|
||||
|
||||
char *
|
||||
gtk_render_operation_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_RENDER_OPERATION (operation), NULL);
|
||||
|
||||
return GTK_RENDER_OPERATION_GET_CLASS (operation)->describe (operation);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_operation_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_RENDER_OPERATION (operation));
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
GTK_RENDER_OPERATION_GET_CLASS (operation)->draw (operation, cr);
|
||||
}
|
||||
|
71
gtk/inspector/gtkrenderoperation.h
Normal file
71
gtk/inspector/gtkrenderoperation.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_PRIVATE_H__
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION (gtk_render_operation_get_type ())
|
||||
#define GTK_RENDER_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION, GtkRenderOperation))
|
||||
#define GTK_RENDER_OPERATION_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION, GtkRenderOperationClass))
|
||||
#define GTK_IS_RENDER_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION))
|
||||
#define GTK_IS_RENDER_OPERATION_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION))
|
||||
#define GTK_RENDER_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION, GtkRenderOperationClass))
|
||||
|
||||
typedef struct _GtkRenderOperation GtkRenderOperation;
|
||||
typedef struct _GtkRenderOperationClass GtkRenderOperationClass;
|
||||
|
||||
struct _GtkRenderOperation
|
||||
{
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* get_clip) (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip);
|
||||
void (* get_matrix) (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix);
|
||||
|
||||
char * (* describe) (GtkRenderOperation *operation);
|
||||
void (* draw) (GtkRenderOperation *operation,
|
||||
cairo_t *cr);
|
||||
};
|
||||
|
||||
GType gtk_render_operation_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gtk_render_operation_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip);
|
||||
void gtk_render_operation_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix);
|
||||
|
||||
char * gtk_render_operation_describe (GtkRenderOperation *operation);
|
||||
void gtk_render_operation_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_PRIVATE_H__ */
|
130
gtk/inspector/gtkrenderoperationbackground.c
Normal file
130
gtk/inspector/gtkrenderoperationbackground.c
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright © 2015 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperationbackground.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkcssshadowsvalueprivate.h"
|
||||
#include "gtkrenderbackgroundprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperationBackground, gtk_render_operation_background, GTK_TYPE_RENDER_OPERATION)
|
||||
|
||||
static void
|
||||
gtk_render_operation_background_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
GtkRenderOperationBackground *oper = GTK_RENDER_OPERATION_BACKGROUND (operation);
|
||||
GtkBorder extents;
|
||||
|
||||
_gtk_css_shadows_value_get_extents (gtk_css_style_get_value (oper->style,
|
||||
GTK_CSS_PROPERTY_BOX_SHADOW),
|
||||
&extents);
|
||||
|
||||
clip->x = -extents.left;
|
||||
clip->y = -extents.right;
|
||||
clip->width = ceil (oper->width) + extents.left + extents.right;
|
||||
clip->height = ceil (oper->height) + extents.top + extents.bottom;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_background_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
GtkRenderOperationBackground *oper = GTK_RENDER_OPERATION_BACKGROUND (operation);
|
||||
|
||||
cairo_matrix_init_translate (matrix, oper->x, oper->y);
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_background_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup ("CSS background");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_background_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperationBackground *oper = GTK_RENDER_OPERATION_BACKGROUND (operation);
|
||||
|
||||
gtk_css_style_render_background (oper->style,
|
||||
cr,
|
||||
0, 0,
|
||||
oper->width,
|
||||
oper->height,
|
||||
oper->junction);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_background_finalize (GObject *object)
|
||||
{
|
||||
GtkRenderOperationBackground *oper = GTK_RENDER_OPERATION_BACKGROUND (object);
|
||||
|
||||
g_object_unref (oper->style);
|
||||
|
||||
G_OBJECT_CLASS (gtk_render_operation_background_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_background_class_init (GtkRenderOperationBackgroundClass *klass)
|
||||
{
|
||||
GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_render_operation_background_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_background_get_clip;
|
||||
operation_class->get_matrix = gtk_render_operation_background_get_matrix;
|
||||
operation_class->describe = gtk_render_operation_background_describe;
|
||||
operation_class->draw = gtk_render_operation_background_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_background_init (GtkRenderOperationBackground *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_render_operation_background_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
GtkRenderOperationBackground *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_BACKGROUND, NULL);
|
||||
|
||||
result->style = g_object_ref (style);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
result->width = width;
|
||||
result->height = height;
|
||||
result->junction = junction;
|
||||
|
||||
return GTK_RENDER_OPERATION (result);
|
||||
}
|
||||
|
67
gtk/inspector/gtkrenderoperationbackground.h
Normal file
67
gtk/inspector/gtkrenderoperationbackground.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_BACKGROUND_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_BACKGROUND_PRIVATE_H__
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
#include "gtkcsstypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION_BACKGROUND (gtk_render_operation_background_get_type ())
|
||||
#define GTK_RENDER_OPERATION_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_BACKGROUND, GtkRenderOperationBackground))
|
||||
#define GTK_RENDER_OPERATION_BACKGROUND_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_BACKGROUND, GtkRenderOperationBackgroundClass))
|
||||
#define GTK_IS_RENDER_OPERATION_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_BACKGROUND))
|
||||
#define GTK_IS_RENDER_OPERATION_BACKGROUND_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_BACKGROUND))
|
||||
#define GTK_RENDER_OPERATION_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_BACKGROUND, GtkRenderOperationBackgroundClass))
|
||||
|
||||
typedef struct _GtkRenderOperationBackground GtkRenderOperationBackground;
|
||||
typedef struct _GtkRenderOperationBackgroundClass GtkRenderOperationBackgroundClass;
|
||||
|
||||
struct _GtkRenderOperationBackground
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
GtkCssStyle *style;
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
GtkJunctionSides junction;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationBackgroundClass
|
||||
{
|
||||
GtkRenderOperationClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_render_operation_background_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOperation * gtk_render_operation_background_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkJunctionSides junction);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_BACKGROUND_PRIVATE_H__ */
|
127
gtk/inspector/gtkrenderoperationborder.c
Normal file
127
gtk/inspector/gtkrenderoperationborder.c
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright © 2015 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperationborder.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperationBorder, gtk_render_operation_border, GTK_TYPE_RENDER_OPERATION)
|
||||
|
||||
static void
|
||||
gtk_render_operation_border_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (operation);
|
||||
|
||||
clip->x = 0;
|
||||
clip->y = 0;
|
||||
clip->width = ceil (oper->width);
|
||||
clip->height = ceil (oper->height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_border_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (operation);
|
||||
|
||||
cairo_matrix_init_translate (matrix, oper->x, oper->y);
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_border_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup ("CSS border");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_border_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (operation);
|
||||
|
||||
gtk_css_style_render_border (oper->style,
|
||||
cr,
|
||||
0, 0,
|
||||
oper->width,
|
||||
oper->height,
|
||||
oper->hidden_side,
|
||||
oper->junction);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_border_finalize (GObject *object)
|
||||
{
|
||||
GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (object);
|
||||
|
||||
g_object_unref (oper->style);
|
||||
|
||||
G_OBJECT_CLASS (gtk_render_operation_border_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_border_class_init (GtkRenderOperationBorderClass *klass)
|
||||
{
|
||||
GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_render_operation_border_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_border_get_clip;
|
||||
operation_class->get_matrix = gtk_render_operation_border_get_matrix;
|
||||
operation_class->describe = gtk_render_operation_border_describe;
|
||||
operation_class->draw = gtk_render_operation_border_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_border_init (GtkRenderOperationBorder *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_render_operation_border_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
GtkRenderOperationBorder *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_BORDER, NULL);
|
||||
|
||||
result->style = g_object_ref (style);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
result->width = width;
|
||||
result->height = height;
|
||||
result->hidden_side = hidden_side;
|
||||
result->junction = junction;
|
||||
|
||||
return GTK_RENDER_OPERATION (result);
|
||||
}
|
||||
|
69
gtk/inspector/gtkrenderoperationborder.h
Normal file
69
gtk/inspector/gtkrenderoperationborder.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_BORDER_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_BORDER_PRIVATE_H__
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
#include "gtkcsstypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION_BORDER (gtk_render_operation_border_get_type ())
|
||||
#define GTK_RENDER_OPERATION_BORDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_BORDER, GtkRenderOperationBorder))
|
||||
#define GTK_RENDER_OPERATION_BORDER_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_BORDER, GtkRenderOperationBorderClass))
|
||||
#define GTK_IS_RENDER_OPERATION_BORDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_BORDER))
|
||||
#define GTK_IS_RENDER_OPERATION_BORDER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_BORDER))
|
||||
#define GTK_RENDER_OPERATION_BORDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_BORDER, GtkRenderOperationBorderClass))
|
||||
|
||||
typedef struct _GtkRenderOperationBorder GtkRenderOperationBorder;
|
||||
typedef struct _GtkRenderOperationBorderClass GtkRenderOperationBorderClass;
|
||||
|
||||
struct _GtkRenderOperationBorder
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
GtkCssStyle *style;
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
guint hidden_side;
|
||||
GtkJunctionSides junction;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationBorderClass
|
||||
{
|
||||
GtkRenderOperationClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_render_operation_border_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOperation * gtk_render_operation_border_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_BORDER_PRIVATE_H__ */
|
105
gtk/inspector/gtkrenderoperationcairo.c
Normal file
105
gtk/inspector/gtkrenderoperationcairo.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperationcairo.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperationCairo, gtk_render_operation_cairo, GTK_TYPE_RENDER_OPERATION)
|
||||
|
||||
static void
|
||||
gtk_render_operation_cairo_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
GtkRenderOperationCairo *oper = GTK_RENDER_OPERATION_CAIRO (operation);
|
||||
cairo_rectangle_t extents;
|
||||
double off_x, off_y;
|
||||
|
||||
g_assert (cairo_surface_get_type (oper->surface) == CAIRO_SURFACE_TYPE_RECORDING);
|
||||
cairo_recording_surface_ink_extents (oper->surface, &extents.x, &extents.y, &extents.width, &extents.height);
|
||||
cairo_surface_get_device_offset (oper->surface, &off_x, &off_y);
|
||||
extents.x -= off_x;
|
||||
extents.y -= off_y;
|
||||
|
||||
clip->x = floor (extents.x);
|
||||
clip->y = floor (extents.y);
|
||||
clip->width = ceil (extents.x + extents.width) - clip->x;
|
||||
clip->height = ceil (extents.y + extents.height) - clip->y;
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_cairo_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup ("custom rendering");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_cairo_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperationCairo *oper = GTK_RENDER_OPERATION_CAIRO (operation);
|
||||
|
||||
cairo_set_source_surface (cr, oper->surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_cairo_finalize (GObject *object)
|
||||
{
|
||||
GtkRenderOperationCairo *oper = GTK_RENDER_OPERATION_CAIRO (object);
|
||||
|
||||
cairo_surface_destroy (oper->surface);
|
||||
|
||||
G_OBJECT_CLASS (gtk_render_operation_cairo_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_cairo_class_init (GtkRenderOperationCairoClass *klass)
|
||||
{
|
||||
GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_render_operation_cairo_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_cairo_get_clip;
|
||||
operation_class->describe = gtk_render_operation_cairo_describe;
|
||||
operation_class->draw = gtk_render_operation_cairo_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_cairo_init (GtkRenderOperationCairo *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_render_operation_cairo_new (cairo_surface_t *surface)
|
||||
{
|
||||
GtkRenderOperationCairo *result;
|
||||
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_CAIRO, NULL);
|
||||
|
||||
result->surface = cairo_surface_reference (surface);
|
||||
|
||||
return GTK_RENDER_OPERATION (result);
|
||||
}
|
||||
|
57
gtk/inspector/gtkrenderoperationcairo.h
Normal file
57
gtk/inspector/gtkrenderoperationcairo.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_CAIRO_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_CAIRO_PRIVATE_H__
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION_CAIRO (gtk_render_operation_cairo_get_type ())
|
||||
#define GTK_RENDER_OPERATION_CAIRO(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_CAIRO, GtkRenderOperationCairo))
|
||||
#define GTK_RENDER_OPERATION_CAIRO_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_CAIRO, GtkRenderOperationCairoClass))
|
||||
#define GTK_IS_RENDER_OPERATION_CAIRO(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_CAIRO))
|
||||
#define GTK_IS_RENDER_OPERATION_CAIRO_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_CAIRO))
|
||||
#define GTK_RENDER_OPERATION_CAIRO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_CAIRO, GtkRenderOperationCairoClass))
|
||||
|
||||
typedef struct _GtkRenderOperationCairo GtkRenderOperationCairo;
|
||||
typedef struct _GtkRenderOperationCairoClass GtkRenderOperationCairoClass;
|
||||
|
||||
struct _GtkRenderOperationCairo
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
cairo_surface_t *surface;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationCairoClass
|
||||
{
|
||||
GtkRenderOperationClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_render_operation_cairo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOperation * gtk_render_operation_cairo_new (cairo_surface_t *surface);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_CAIRO_PRIVATE_H__ */
|
191
gtk/inspector/gtkrenderoperationicon.c
Normal file
191
gtk/inspector/gtkrenderoperationicon.c
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright © 2015 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperationicon.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkrendericonprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperationIcon, gtk_render_operation_icon, GTK_TYPE_RENDER_OPERATION)
|
||||
|
||||
static void
|
||||
gtk_render_operation_icon_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
GtkRenderOperationIcon *oper = GTK_RENDER_OPERATION_ICON (operation);
|
||||
|
||||
clip->x = 0;
|
||||
clip->y = 0;
|
||||
clip->width = ceil (oper->width);
|
||||
clip->height = ceil (oper->height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_icon_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
GtkRenderOperationIcon *oper = GTK_RENDER_OPERATION_ICON (operation);
|
||||
|
||||
cairo_matrix_init_translate (matrix, oper->x, oper->y);
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_icon_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
GtkRenderOperationIcon *oper = GTK_RENDER_OPERATION_ICON (operation);
|
||||
|
||||
switch (oper->builtin_type)
|
||||
{
|
||||
default:
|
||||
g_warning ("missing builtin type %u", (guint) oper->builtin_type);
|
||||
/* fall through */
|
||||
case GTK_CSS_IMAGE_BUILTIN_NONE:
|
||||
return g_strdup ("CSS icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_CHECK:
|
||||
return g_strdup ("CSS check icon (unchecked)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_CHECK_CHECKED:
|
||||
return g_strdup ("CSS check icon (checked)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT:
|
||||
return g_strdup ("CSS check icon (inconsistent)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_OPTION:
|
||||
return g_strdup ("CSS option icon (unchecked)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_OPTION_CHECKED:
|
||||
return g_strdup ("CSS option icon (checked)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT:
|
||||
return g_strdup ("CSS option icon (inconsistent)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_UP:
|
||||
return g_strdup ("CSS up arrow icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN:
|
||||
return g_strdup ("CSS down arrow icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_LEFT:
|
||||
return g_strdup ("CSS left arrow icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT:
|
||||
return g_strdup ("CSS right arrow icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT:
|
||||
return g_strdup ("CSS horizontal left expander icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT:
|
||||
return g_strdup ("CSS vertical left expander icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT:
|
||||
return g_strdup ("CSS horizontal right expander icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT:
|
||||
return g_strdup ("CSS vertical right expander icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT_EXPANDED:
|
||||
return g_strdup ("CSS horizontal left expander icon (expanded)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED:
|
||||
return g_strdup ("CSS vertical left expander icon (expanded)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT_EXPANDED:
|
||||
return g_strdup ("CSS horizontal right expander icon (expanded)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED:
|
||||
return g_strdup ("CSS vertical right expander icon (expanded)");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_TOPLEFT:
|
||||
return g_strdup ("CSS top left grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_TOP:
|
||||
return g_strdup ("CSS top grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_TOPRIGHT:
|
||||
return g_strdup ("CSS top right grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_RIGHT:
|
||||
return g_strdup ("CSS right grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMRIGHT:
|
||||
return g_strdup ("CSS bottom right grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOM:
|
||||
return g_strdup ("CSS bottom grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_BOTTOMLEFT:
|
||||
return g_strdup ("CSS bottom left grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT:
|
||||
return g_strdup ("CSS left grip icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR:
|
||||
return g_strdup ("CSS pane separator icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_HANDLE:
|
||||
return g_strdup ("CSS handle icon");
|
||||
case GTK_CSS_IMAGE_BUILTIN_SPINNER:
|
||||
return g_strdup ("CSS spinner icon");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_icon_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperationIcon *oper = GTK_RENDER_OPERATION_ICON (operation);
|
||||
|
||||
gtk_css_style_render_icon (oper->style,
|
||||
cr,
|
||||
0, 0,
|
||||
oper->width,
|
||||
oper->height,
|
||||
oper->builtin_type);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_icon_finalize (GObject *object)
|
||||
{
|
||||
GtkRenderOperationIcon *oper = GTK_RENDER_OPERATION_ICON (object);
|
||||
|
||||
g_object_unref (oper->style);
|
||||
|
||||
G_OBJECT_CLASS (gtk_render_operation_icon_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_icon_class_init (GtkRenderOperationIconClass *klass)
|
||||
{
|
||||
GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_render_operation_icon_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_icon_get_clip;
|
||||
operation_class->get_matrix = gtk_render_operation_icon_get_matrix;
|
||||
operation_class->describe = gtk_render_operation_icon_describe;
|
||||
operation_class->draw = gtk_render_operation_icon_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_icon_init (GtkRenderOperationIcon *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_render_operation_icon_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type)
|
||||
{
|
||||
GtkRenderOperationIcon *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_ICON, NULL);
|
||||
|
||||
result->style = g_object_ref (style);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
result->width = width;
|
||||
result->height = height;
|
||||
result->builtin_type = builtin_type;
|
||||
|
||||
return GTK_RENDER_OPERATION (result);
|
||||
}
|
||||
|
67
gtk/inspector/gtkrenderoperationicon.h
Normal file
67
gtk/inspector/gtkrenderoperationicon.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_ICON_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_ICON_PRIVATE_H__
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
#include "gtkcssimagebuiltinprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION_ICON (gtk_render_operation_icon_get_type ())
|
||||
#define GTK_RENDER_OPERATION_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_ICON, GtkRenderOperationIcon))
|
||||
#define GTK_RENDER_OPERATION_ICON_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_ICON, GtkRenderOperationIconClass))
|
||||
#define GTK_IS_RENDER_OPERATION_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_ICON))
|
||||
#define GTK_IS_RENDER_OPERATION_ICON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_ICON))
|
||||
#define GTK_RENDER_OPERATION_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_ICON, GtkRenderOperationIconClass))
|
||||
|
||||
typedef struct _GtkRenderOperationIcon GtkRenderOperationIcon;
|
||||
typedef struct _GtkRenderOperationIconClass GtkRenderOperationIconClass;
|
||||
|
||||
struct _GtkRenderOperationIcon
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
GtkCssStyle *style;
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
GtkCssImageBuiltinType builtin_type;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationIconClass
|
||||
{
|
||||
GtkRenderOperationClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_render_operation_icon_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOperation * gtk_render_operation_icon_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height,
|
||||
GtkCssImageBuiltinType builtin_type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_ICON_PRIVATE_H__ */
|
126
gtk/inspector/gtkrenderoperationoutline.c
Normal file
126
gtk/inspector/gtkrenderoperationoutline.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright © 2015 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperationoutline.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkrenderborderprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperationOutline, gtk_render_operation_outline, GTK_TYPE_RENDER_OPERATION)
|
||||
|
||||
static void
|
||||
gtk_render_operation_outline_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
GtkRenderOperationOutline *oper = GTK_RENDER_OPERATION_OUTLINE (operation);
|
||||
double offset, border_width;
|
||||
|
||||
border_width = _gtk_css_number_value_get (gtk_css_style_get_value (oper->style, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
|
||||
offset = _gtk_css_number_value_get (gtk_css_style_get_value (oper->style, GTK_CSS_PROPERTY_OUTLINE_OFFSET), 100);
|
||||
|
||||
clip->x = floor (- border_width - offset);
|
||||
clip->y = floor (- border_width - offset);
|
||||
clip->width = ceil (oper->width + border_width + offset) - clip->x;
|
||||
clip->height = ceil (oper->height + border_width + offset) - clip->y;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_outline_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
GtkRenderOperationOutline *oper = GTK_RENDER_OPERATION_OUTLINE (operation);
|
||||
|
||||
cairo_matrix_init_translate (matrix, oper->x, oper->y);
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_outline_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
return g_strdup ("CSS outline");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_outline_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperationOutline *oper = GTK_RENDER_OPERATION_OUTLINE (operation);
|
||||
|
||||
gtk_css_style_render_outline (oper->style,
|
||||
cr,
|
||||
0, 0,
|
||||
oper->width,
|
||||
oper->height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_outline_finalize (GObject *object)
|
||||
{
|
||||
GtkRenderOperationOutline *oper = GTK_RENDER_OPERATION_OUTLINE (object);
|
||||
|
||||
g_object_unref (oper->style);
|
||||
|
||||
G_OBJECT_CLASS (gtk_render_operation_outline_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_outline_class_init (GtkRenderOperationOutlineClass *klass)
|
||||
{
|
||||
GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_render_operation_outline_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_outline_get_clip;
|
||||
operation_class->get_matrix = gtk_render_operation_outline_get_matrix;
|
||||
operation_class->describe = gtk_render_operation_outline_describe;
|
||||
operation_class->draw = gtk_render_operation_outline_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_outline_init (GtkRenderOperationOutline *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_render_operation_outline_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkRenderOperationOutline *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_OUTLINE, NULL);
|
||||
|
||||
result->style = g_object_ref (style);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
result->width = width;
|
||||
result->height = height;
|
||||
|
||||
return GTK_RENDER_OPERATION (result);
|
||||
}
|
||||
|
65
gtk/inspector/gtkrenderoperationoutline.h
Normal file
65
gtk/inspector/gtkrenderoperationoutline.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright © 2015 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_OUTLINE_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_OUTLINE_PRIVATE_H__
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
#include "gtkcsstypesprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION_OUTLINE (gtk_render_operation_outline_get_type ())
|
||||
#define GTK_RENDER_OPERATION_OUTLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_OUTLINE, GtkRenderOperationOutline))
|
||||
#define GTK_RENDER_OPERATION_OUTLINE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_OUTLINE, GtkRenderOperationOutlineClass))
|
||||
#define GTK_IS_RENDER_OPERATION_OUTLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_OUTLINE))
|
||||
#define GTK_IS_RENDER_OPERATION_OUTLINE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_OUTLINE))
|
||||
#define GTK_RENDER_OPERATION_OUTLINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_OUTLINE, GtkRenderOperationOutlineClass))
|
||||
|
||||
typedef struct _GtkRenderOperationOutline GtkRenderOperationOutline;
|
||||
typedef struct _GtkRenderOperationOutlineClass GtkRenderOperationOutlineClass;
|
||||
|
||||
struct _GtkRenderOperationOutline
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
GtkCssStyle *style;
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationOutlineClass
|
||||
{
|
||||
GtkRenderOperationClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_render_operation_outline_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOperation * gtk_render_operation_outline_new (GtkCssStyle *style,
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_OUTLINE_PRIVATE_H__ */
|
133
gtk/inspector/gtkrenderoperationwidget.c
Normal file
133
gtk/inspector/gtkrenderoperationwidget.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkrenderoperationwidget.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRenderOperationWidget, gtk_render_operation_widget, GTK_TYPE_RENDER_OPERATION)
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_get_clip (GtkRenderOperation *operation,
|
||||
cairo_rectangle_int_t *clip)
|
||||
{
|
||||
GtkRenderOperationWidget *oper = GTK_RENDER_OPERATION_WIDGET (operation);
|
||||
|
||||
*clip = oper->widget_clip;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_get_matrix (GtkRenderOperation *operation,
|
||||
cairo_matrix_t *matrix)
|
||||
{
|
||||
GtkRenderOperationWidget *oper = GTK_RENDER_OPERATION_WIDGET (operation);
|
||||
|
||||
*matrix = oper->matrix;
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_render_operation_widget_describe (GtkRenderOperation *operation)
|
||||
{
|
||||
GtkRenderOperationWidget *oper = GTK_RENDER_OPERATION_WIDGET (operation);
|
||||
|
||||
return g_strdup (g_type_name (oper->widget_type));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_draw (GtkRenderOperation *operation,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperationWidget *oper = GTK_RENDER_OPERATION_WIDGET (operation);
|
||||
cairo_matrix_t matrix;
|
||||
GList *l;
|
||||
|
||||
for (l = oper->operations; l; l = l->next)
|
||||
{
|
||||
cairo_save (cr);
|
||||
|
||||
gtk_render_operation_get_matrix (l->data, &matrix);
|
||||
cairo_transform (cr, &matrix);
|
||||
gtk_render_operation_draw (l->data, cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_finalize (GObject *object)
|
||||
{
|
||||
GtkRenderOperationWidget *oper = GTK_RENDER_OPERATION_WIDGET (object);
|
||||
|
||||
g_list_free_full (oper->operations, g_object_unref);
|
||||
|
||||
G_OBJECT_CLASS (gtk_render_operation_widget_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_class_init (GtkRenderOperationWidgetClass *klass)
|
||||
{
|
||||
GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_render_operation_widget_finalize;
|
||||
|
||||
operation_class->get_clip = gtk_render_operation_widget_get_clip;
|
||||
operation_class->get_matrix = gtk_render_operation_widget_get_matrix;
|
||||
operation_class->describe = gtk_render_operation_widget_describe;
|
||||
operation_class->draw = gtk_render_operation_widget_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_render_operation_widget_init (GtkRenderOperationWidget *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_render_operation_widget_new (GtkWidget *widget,
|
||||
cairo_matrix_t *matrix)
|
||||
|
||||
{
|
||||
GtkRenderOperationWidget *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_RENDER_OPERATION_WIDGET, NULL);
|
||||
|
||||
result->widget_type = G_OBJECT_TYPE (widget);
|
||||
gtk_widget_get_allocation (widget, &result->widget_allocation);
|
||||
gtk_widget_get_clip (widget, &result->widget_clip);
|
||||
result->widget_clip.x -= result->widget_allocation.x;
|
||||
result->widget_clip.y -= result->widget_allocation.y;
|
||||
result->matrix = *matrix;
|
||||
|
||||
return GTK_RENDER_OPERATION (result);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_render_operation_widget_add_operation (GtkRenderOperationWidget *widget,
|
||||
GtkRenderOperation *oper)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_RENDER_OPERATION_WIDGET (widget));
|
||||
g_return_if_fail (GTK_IS_RENDER_OPERATION (oper));
|
||||
|
||||
g_object_ref (oper);
|
||||
|
||||
widget->operations = g_list_append (widget->operations, oper);
|
||||
}
|
||||
|
65
gtk/inspector/gtkrenderoperationwidget.h
Normal file
65
gtk/inspector/gtkrenderoperationwidget.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RENDER_OPERATION_WIDGET_PRIVATE_H__
|
||||
#define __GTK_RENDER_OPERATION_WIDGET_PRIVATE_H__
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RENDER_OPERATION_WIDGET (gtk_render_operation_widget_get_type ())
|
||||
#define GTK_RENDER_OPERATION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_WIDGET, GtkRenderOperationWidget))
|
||||
#define GTK_RENDER_OPERATION_WIDGET_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_WIDGET, GtkRenderOperationWidgetClass))
|
||||
#define GTK_IS_RENDER_OPERATION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_WIDGET))
|
||||
#define GTK_IS_RENDER_OPERATION_WIDGET_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_WIDGET))
|
||||
#define GTK_RENDER_OPERATION_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_WIDGET, GtkRenderOperationWidgetClass))
|
||||
|
||||
typedef struct _GtkRenderOperationWidget GtkRenderOperationWidget;
|
||||
typedef struct _GtkRenderOperationWidgetClass GtkRenderOperationWidgetClass;
|
||||
|
||||
struct _GtkRenderOperationWidget
|
||||
{
|
||||
GtkRenderOperation parent;
|
||||
|
||||
GType widget_type;
|
||||
GtkAllocation widget_allocation;
|
||||
GtkAllocation widget_clip;
|
||||
cairo_matrix_t matrix;
|
||||
GList *operations;
|
||||
};
|
||||
|
||||
struct _GtkRenderOperationWidgetClass
|
||||
{
|
||||
GtkRenderOperationClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_render_operation_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOperation * gtk_render_operation_widget_new (GtkWidget *widget,
|
||||
cairo_matrix_t *matrix);
|
||||
|
||||
void gtk_render_operation_widget_add_operation(GtkRenderOperationWidget *widget,
|
||||
GtkRenderOperation *oper);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_OPERATION_WIDGET_PRIVATE_H__ */
|
@@ -21,7 +21,10 @@
|
||||
#include "magnifier.h"
|
||||
|
||||
#include "gtkmagnifierprivate.h"
|
||||
#include "recordingrenderops.h"
|
||||
#include "snapshot.h"
|
||||
|
||||
#include "gtkbutton.h"
|
||||
#include "gtklabel.h"
|
||||
|
||||
|
||||
@@ -67,6 +70,25 @@ gtk_inspector_magnifier_set_object (GtkInspectorMagnifier *sl,
|
||||
_gtk_magnifier_set_coords (GTK_MAGNIFIER (sl->priv->magnifier), 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
on_snapshot_clicked (GtkButton *button,
|
||||
GtkInspectorMagnifier *sl)
|
||||
{
|
||||
GtkRenderOperation *oper;
|
||||
GtkRenderOps *ops;
|
||||
GtkWidget *snapshot;
|
||||
|
||||
ops = gtk_recording_render_ops_new ();
|
||||
oper = gtk_recording_render_ops_run_for_widget (GTK_RECORDING_RENDER_OPS (ops),
|
||||
GTK_WIDGET (sl->priv->object));
|
||||
g_object_unref (ops);
|
||||
|
||||
snapshot = gtk_inspector_snapshot_new (oper);
|
||||
gtk_window_present (GTK_WINDOW (snapshot));
|
||||
|
||||
g_object_unref (oper);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_magnifier_class_init (GtkInspectorMagnifierClass *klass)
|
||||
{
|
||||
@@ -75,6 +97,8 @@ gtk_inspector_magnifier_class_init (GtkInspectorMagnifierClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/magnifier.ui");
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMagnifier, magnifier);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMagnifier, object_title);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_snapshot_clicked);
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
@@ -8,6 +8,17 @@
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="margin">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="snapshot">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Snapshot</property>
|
||||
<property name="tooltip-text" translatable="yes">Take a snapshot for closer inspection</property>
|
||||
<signal name="clicked" handler="on_snapshot_clicked"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="magnification">
|
||||
<property name="visible">True</property>
|
||||
|
276
gtk/inspector/recordingrenderops.c
Normal file
276
gtk/inspector/recordingrenderops.c
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright © 2011 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "recordingrenderops.h"
|
||||
|
||||
#include "gtkrenderoperationbackground.h"
|
||||
#include "gtkrenderoperationborder.h"
|
||||
#include "gtkrenderoperationcairo.h"
|
||||
#include "gtkrenderoperationicon.h"
|
||||
#include "gtkrenderoperationoutline.h"
|
||||
#include "gtkrenderoperationwidget.h"
|
||||
#include "gtkwidget.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkRecordingRenderOps, gtk_recording_render_ops, GTK_TYPE_RENDER_OPS)
|
||||
|
||||
static cairo_t *
|
||||
gtk_recording_render_ops_cairo_create (GtkRecordingRenderOps *ops,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
cairo_t *cr;
|
||||
cairo_surface_t *surface;
|
||||
cairo_rectangle_t extents;
|
||||
GtkAllocation clip, allocation;
|
||||
|
||||
gtk_widget_get_clip (widget, &clip);
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
extents.x = allocation.x - clip.x;
|
||||
extents.y = allocation.y - clip.y;
|
||||
extents.width = clip.width;
|
||||
extents.height = clip.height;
|
||||
|
||||
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, &extents);
|
||||
cairo_surface_set_device_offset (surface, -extents.x, -extents.y);
|
||||
cr = cairo_create (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
gtk_cairo_set_render_ops (cr, GTK_RENDER_OPS (ops));
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_save_snapshot (GtkRecordingRenderOps *record,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRenderOperation *oper;
|
||||
cairo_surface_t *target, *snapshot;
|
||||
cairo_rectangle_t extents, real_extents;
|
||||
cairo_t *copy;
|
||||
|
||||
target = cairo_get_target (cr);
|
||||
g_assert (cairo_surface_get_type (target) == CAIRO_SURFACE_TYPE_RECORDING);
|
||||
cairo_recording_surface_ink_extents (target, &extents.x, &extents.y, &extents.width, &extents.height);
|
||||
|
||||
/* no snapshot necessary */
|
||||
if (extents.width <= 0 || extents.height <= 0)
|
||||
return;
|
||||
|
||||
/* create snapshot */
|
||||
g_print ("saving snapshot of %g %g %g %g\n", extents.x, extents.y, extents.width, extents.height);
|
||||
real_extents = extents;
|
||||
real_extents.x = real_extents.y = 0;
|
||||
snapshot = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, &real_extents);
|
||||
cairo_surface_set_device_offset (snapshot, -extents.x, -extents.y);
|
||||
copy = cairo_create (snapshot);
|
||||
cairo_set_source_surface (copy, target, 0, 0);
|
||||
cairo_paint (copy);
|
||||
cairo_destroy (copy);
|
||||
|
||||
if (extents.x > 10)
|
||||
cairo_surface_write_to_png (snapshot, "foo.png");
|
||||
|
||||
/* enqueue snapshot */
|
||||
oper = gtk_render_operation_cairo_new (snapshot);
|
||||
cairo_surface_destroy (snapshot);
|
||||
gtk_render_operation_widget_add_operation (record->widgets->data, oper);
|
||||
g_object_unref (oper);
|
||||
|
||||
/* clear original_surface */
|
||||
cairo_save (cr);
|
||||
cairo_reset_clip (cr);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_draw_background (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
|
||||
GtkRenderOperation *oper;
|
||||
|
||||
gtk_recording_render_ops_save_snapshot (record, cr);
|
||||
|
||||
oper = gtk_render_operation_background_new (style, x, y, width, height, junction);
|
||||
gtk_render_operation_widget_add_operation (record->widgets->data, oper);
|
||||
g_object_unref (oper);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_draw_border (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
guint hidden_side,
|
||||
GtkJunctionSides junction)
|
||||
{
|
||||
GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
|
||||
GtkRenderOperation *oper;
|
||||
|
||||
gtk_recording_render_ops_save_snapshot (record, cr);
|
||||
|
||||
oper = gtk_render_operation_border_new (style, x, y, width, height, hidden_side, junction);
|
||||
gtk_render_operation_widget_add_operation (record->widgets->data, oper);
|
||||
g_object_unref (oper);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_draw_outline (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
|
||||
GtkRenderOperation *oper;
|
||||
|
||||
gtk_recording_render_ops_save_snapshot (record, cr);
|
||||
|
||||
oper = gtk_render_operation_outline_new (style, x, y, width, height);
|
||||
gtk_render_operation_widget_add_operation (record->widgets->data, oper);
|
||||
g_object_unref (oper);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_draw_icon (GtkRenderOps *ops,
|
||||
GtkCssStyle *style,
|
||||
cairo_t *cr,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
GtkCssImageBuiltinType builtin_type)
|
||||
{
|
||||
GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
|
||||
GtkRenderOperation *oper;
|
||||
|
||||
gtk_recording_render_ops_save_snapshot (record, cr);
|
||||
|
||||
oper = gtk_render_operation_icon_new (style, x, y, width, height, builtin_type);
|
||||
gtk_render_operation_widget_add_operation (record->widgets->data, oper);
|
||||
g_object_unref (oper);
|
||||
}
|
||||
|
||||
static cairo_t *
|
||||
gtk_recording_render_ops_begin_draw_widget (GtkRenderOps *ops,
|
||||
GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
|
||||
GtkRenderOperation *oper;
|
||||
cairo_matrix_t matrix;
|
||||
|
||||
if (record->widgets)
|
||||
gtk_recording_render_ops_save_snapshot (record, cr);
|
||||
|
||||
g_print ("begin drawing widget %s\n", gtk_widget_get_name (widget));
|
||||
|
||||
cairo_get_matrix (cr, &matrix);
|
||||
|
||||
oper = gtk_render_operation_widget_new (widget, &matrix);
|
||||
|
||||
if (record->widgets)
|
||||
gtk_render_operation_widget_add_operation (record->widgets->data, oper);
|
||||
record->widgets = g_list_prepend (record->widgets, oper);
|
||||
|
||||
return gtk_recording_render_ops_cairo_create (record, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_end_draw_widget (GtkRenderOps *ops,
|
||||
GtkWidget *widget,
|
||||
cairo_t *draw_cr,
|
||||
cairo_t *original_cr)
|
||||
{
|
||||
GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
|
||||
|
||||
gtk_recording_render_ops_save_snapshot (record, draw_cr);
|
||||
|
||||
g_print ("ended drawing widget %s\n", gtk_widget_get_name (widget));
|
||||
|
||||
if (record->widgets->next)
|
||||
{
|
||||
g_object_unref (record->widgets->data);
|
||||
record->widgets = g_list_remove (record->widgets, record->widgets->data);
|
||||
}
|
||||
|
||||
cairo_destroy (draw_cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_class_init (GtkRecordingRenderOpsClass *klass)
|
||||
{
|
||||
GtkRenderOpsClass *ops_class = GTK_RENDER_OPS_CLASS (klass);
|
||||
|
||||
ops_class->begin_draw_widget = gtk_recording_render_ops_begin_draw_widget;
|
||||
ops_class->end_draw_widget = gtk_recording_render_ops_end_draw_widget;
|
||||
ops_class->draw_background = gtk_recording_render_ops_draw_background;
|
||||
ops_class->draw_border = gtk_recording_render_ops_draw_border;
|
||||
ops_class->draw_outline = gtk_recording_render_ops_draw_outline;
|
||||
ops_class->draw_icon = gtk_recording_render_ops_draw_icon;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_recording_render_ops_init (GtkRecordingRenderOps *image)
|
||||
{
|
||||
}
|
||||
|
||||
GtkRenderOps *
|
||||
gtk_recording_render_ops_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_RECORDING_RENDER_OPS, NULL);
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_recording_render_ops_run_for_widget (GtkRecordingRenderOps *ops,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkRenderOperation *result;
|
||||
cairo_t *cr;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_RECORDING_RENDER_OPS (ops), NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
cr = gtk_recording_render_ops_cairo_create (ops, widget);
|
||||
gtk_widget_draw (widget, cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
result = ops->widgets->data;
|
||||
g_list_free (ops->widgets);
|
||||
ops->widgets = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
62
gtk/inspector/recordingrenderops.h
Normal file
62
gtk/inspector/recordingrenderops.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_RECORDING_RENDER_OPS_PRIVATE_H__
|
||||
#define __GTK_RECORDING_RENDER_OPS_PRIVATE_H__
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gtk/gtkrenderopsprivate.h"
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_RECORDING_RENDER_OPS (gtk_recording_render_ops_get_type ())
|
||||
#define GTK_RECORDING_RENDER_OPS(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RECORDING_RENDER_OPS, GtkRecordingRenderOps))
|
||||
#define GTK_RECORDING_RENDER_OPS_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RECORDING_RENDER_OPS, GtkRecordingRenderOpsClass))
|
||||
#define GTK_IS_RECORDING_RENDER_OPS(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RECORDING_RENDER_OPS))
|
||||
#define GTK_IS_RECORDING_RENDER_OPS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RECORDING_RENDER_OPS))
|
||||
#define GTK_RECORDING_RENDER_OPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECORDING_RENDER_OPS, GtkRecordingRenderOpsClass))
|
||||
|
||||
typedef struct _GtkRecordingRenderOps GtkRecordingRenderOps;
|
||||
typedef struct _GtkRecordingRenderOpsClass GtkRecordingRenderOpsClass;
|
||||
|
||||
struct _GtkRecordingRenderOps
|
||||
{
|
||||
GtkRenderOps parent;
|
||||
|
||||
GList *widgets;
|
||||
};
|
||||
|
||||
struct _GtkRecordingRenderOpsClass
|
||||
{
|
||||
GtkRenderOpsClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_recording_render_ops_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkRenderOps * gtk_recording_render_ops_new (void);
|
||||
|
||||
GtkRenderOperation * gtk_recording_render_ops_run_for_widget (GtkRecordingRenderOps *ops,
|
||||
GtkWidget *widget);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RECORDING_RENDER_OPS_PRIVATE_H__ */
|
220
gtk/inspector/snapshot.c
Normal file
220
gtk/inspector/snapshot.c
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "snapshot.h"
|
||||
|
||||
#include <gtk/gtkimage.h>
|
||||
#include <gtk/gtklabel.h>
|
||||
#include <gtk/gtklistbox.h>
|
||||
|
||||
#include "gtkrenderoperationwidget.h"
|
||||
#include "window.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_OPERATION
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkInspectorSnapshot, gtk_inspector_snapshot, GTK_TYPE_WINDOW)
|
||||
|
||||
static void
|
||||
gtk_inspector_snapshot_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkInspectorSnapshot *snapshot = GTK_INSPECTOR_SNAPSHOT (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_OPERATION:
|
||||
gtk_inspector_snapshot_set_operation (snapshot,
|
||||
g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_snapshot_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkInspectorSnapshot *snapshot = GTK_INSPECTOR_SNAPSHOT (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_OPERATION:
|
||||
g_value_set_object (value, snapshot->operation);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
create_surface_for_operation (GtkRenderOperation *oper)
|
||||
{
|
||||
GtkAllocation clip;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
||||
gtk_render_operation_get_clip (oper, &clip);
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, clip.width, clip.height);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
cairo_translate (cr, -clip.x, -clip.y);
|
||||
gtk_render_operation_draw (oper, cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static void
|
||||
on_operation_selected (GtkListBox *listbox,
|
||||
GtkListBoxRow *row,
|
||||
GtkInspectorSnapshot *snapshot)
|
||||
{
|
||||
GtkRenderOperation *oper;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (row == NULL)
|
||||
{
|
||||
gtk_image_clear (GTK_IMAGE (snapshot->image));
|
||||
return;
|
||||
}
|
||||
|
||||
oper = g_object_get_data (G_OBJECT (row), "operation");
|
||||
|
||||
surface = create_surface_for_operation (oper);
|
||||
gtk_image_set_from_surface (GTK_IMAGE (snapshot->image), surface);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_snapshot_class_init (GtkInspectorSnapshotClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->set_property = gtk_inspector_snapshot_set_property;
|
||||
object_class->get_property = gtk_inspector_snapshot_get_property;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_OPERATION,
|
||||
g_param_spec_object ("operation",
|
||||
"Operation",
|
||||
"Operation to show",
|
||||
GTK_TYPE_RENDER_OPERATION,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/snapshot.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorSnapshot, operations_listbox);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorSnapshot, image);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_operation_selected);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_snapshot_init (GtkInspectorSnapshot *iw)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (iw));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_inspector_snapshot_new (GtkRenderOperation *oper)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_SNAPSHOT,
|
||||
"screen", gtk_inspector_get_screen (),
|
||||
"operation", oper,
|
||||
NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_snapshot_fill_listbox (GtkInspectorSnapshot *snapshot,
|
||||
GtkRenderOperation *oper,
|
||||
guint depth)
|
||||
{
|
||||
GtkWidget *label, *row;
|
||||
char *text, *description;
|
||||
|
||||
description = gtk_render_operation_describe (oper);
|
||||
text = g_strdup_printf ("%*s %s", 2 * depth, "", description);
|
||||
label = gtk_label_new (text);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_show (label);
|
||||
g_free (text);
|
||||
g_free (description);
|
||||
|
||||
row = gtk_list_box_row_new ();
|
||||
gtk_container_add (GTK_CONTAINER (row), label);
|
||||
g_object_set_data (G_OBJECT (row), "operation", oper);
|
||||
gtk_widget_show (row);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (snapshot->operations_listbox), row);
|
||||
|
||||
if (GTK_IS_RENDER_OPERATION_WIDGET (oper))
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = GTK_RENDER_OPERATION_WIDGET (oper)->operations; l; l = l->next)
|
||||
{
|
||||
gtk_inspector_snapshot_fill_listbox (snapshot, l->data, depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_inspector_snapshot_set_operation (GtkInspectorSnapshot *snapshot,
|
||||
GtkRenderOperation *oper)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_INSPECTOR_SNAPSHOT (snapshot));
|
||||
g_return_if_fail (oper == NULL || GTK_IS_RENDER_OPERATION (oper));
|
||||
|
||||
if (snapshot->operation)
|
||||
{
|
||||
/* implicit version of gtk_list_box_clear(): */
|
||||
gtk_list_box_bind_model (GTK_LIST_BOX (snapshot->operations_listbox), NULL, NULL, NULL, NULL);
|
||||
g_object_unref (snapshot->operation);
|
||||
}
|
||||
|
||||
if (oper)
|
||||
{
|
||||
g_object_ref (oper);
|
||||
snapshot->operation = oper;
|
||||
gtk_inspector_snapshot_fill_listbox (snapshot, oper, 0);
|
||||
}
|
||||
}
|
||||
|
||||
GtkRenderOperation *
|
||||
gtk_inspector_snapshot_get_operation (GtkInspectorSnapshot *snapshot)
|
||||
{
|
||||
return snapshot->operation;
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
66
gtk/inspector/snapshot.h
Normal file
66
gtk/inspector/snapshot.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef _GTK_INSPECTOR_SNAPSHOT_H_
|
||||
#define _GTK_INSPECTOR_SNAPSHOT_H_
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
#include "gtkrenderoperation.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_INSPECTOR_SNAPSHOT (gtk_inspector_snapshot_get_type())
|
||||
#define GTK_INSPECTOR_SNAPSHOT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_SNAPSHOT, GtkInspectorSnapshot))
|
||||
#define GTK_INSPECTOR_SNAPSHOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_SNAPSHOT, GtkInspectorSnapshotClass))
|
||||
#define GTK_IS_INSPECTOR_SNAPSHOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_SNAPSHOT))
|
||||
#define GTK_IS_INSPECTOR_SNAPSHOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_SNAPSHOT))
|
||||
#define GTK_INSPECTOR_SNAPSHOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_SNAPSHOT, GtkInspectorSnapshotClass))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWindow parent;
|
||||
|
||||
GtkRenderOperation *operation;
|
||||
|
||||
GtkWidget *operations_listbox;
|
||||
GtkWidget *image;
|
||||
} GtkInspectorSnapshot;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWindowClass parent;
|
||||
} GtkInspectorSnapshotClass;
|
||||
|
||||
GType gtk_inspector_snapshot_get_type (void);
|
||||
|
||||
GtkWidget * gtk_inspector_snapshot_new (GtkRenderOperation *oper);
|
||||
|
||||
void gtk_inspector_snapshot_set_operation (GtkInspectorSnapshot *snapshot,
|
||||
GtkRenderOperation *oper);
|
||||
GtkRenderOperation * gtk_inspector_snapshot_get_operation (GtkInspectorSnapshot *snapshot);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif // _GTK_INSPECTOR_SNAPSHOT_H_
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
53
gtk/inspector/snapshot.ui
Normal file
53
gtk/inspector/snapshot.ui
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk30">
|
||||
<template class="GtkInspectorSnapshot" parent="GtkWindow">
|
||||
<property name="default-height">500</property>
|
||||
<property name="default-width">800</property>
|
||||
<property name="icon">resource:///org/gtk/libgtk/inspector/logo.png</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="show-close-button">True</property>
|
||||
<property name="title">Snapshot</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned" id="paned">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="vscrollbar-policy">automatic</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="operations_listbox">
|
||||
<property name="visible">True</property>
|
||||
<signal name="row-selected" handler="on_operation_selected"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport" id="viewport1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
@@ -248,8 +248,8 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
gtk_widget_class_bind_template_callback (widget_class, close_object_details);
|
||||
}
|
||||
|
||||
static GdkScreen *
|
||||
get_inspector_screen (void)
|
||||
GdkScreen *
|
||||
gtk_inspector_get_screen (void)
|
||||
{
|
||||
static GdkDisplay *display = NULL;
|
||||
|
||||
@@ -285,7 +285,7 @@ GtkWidget *
|
||||
gtk_inspector_window_new (void)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_WINDOW,
|
||||
"screen", get_inspector_screen (),
|
||||
"screen", gtk_inspector_get_screen (),
|
||||
NULL));
|
||||
}
|
||||
|
||||
|
@@ -91,6 +91,8 @@ G_BEGIN_DECLS
|
||||
GType gtk_inspector_window_get_type (void);
|
||||
GtkWidget *gtk_inspector_window_new (void);
|
||||
|
||||
GdkScreen *gtk_inspector_get_screen (void);
|
||||
|
||||
void gtk_inspector_flash_widget (GtkInspectorWindow *iw,
|
||||
GtkWidget *widget);
|
||||
void gtk_inspector_start_highlight (GtkWidget *widget);
|
||||
|
Reference in New Issue
Block a user