[gtk+] Add a function to get affected area for background
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a function to get affected area for background
- Date: Wed, 20 Jan 2016 14:42:37 +0000 (UTC)
commit 5fd7b85d2b37e59e07fba09bedfb9ffea00bef43
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jan 20 09:41:01 2016 -0500
Add a function to get affected area for background
The new function, gtk_render_background_get_clip answers the
question: what pixels are affected if I call gtk_render_background ?
The long-term goal is to have APIs that answer this question for
all rendering primitives.
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtkrender.c | 33 +++++++++++++++++++++++++++++++++
gtk/gtkrender.h | 9 +++++++++
3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index fe439c9..fd7c85a 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -6258,6 +6258,7 @@ gtk_border_free
<SUBSECTION>
gtk_render_arrow
gtk_render_background
+gtk_render_background_get_clip
gtk_render_check
gtk_render_expander
gtk_render_extension
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c
index 6be35a0..42cd58f 100644
--- a/gtk/gtkrender.c
+++ b/gtk/gtkrender.c
@@ -283,6 +283,39 @@ gtk_render_background (GtkStyleContext *context,
}
/**
+ * gtk_render_background_get_clip:
+ * @context: a #GtkStyleContext
+ * @x: X origin of the rectangle
+ * @y: Y origin of the rectangle
+ * @width: rectangle width
+ * @height: rectangle height
+ * @out_clip: (out): return location for the clip
+ *
+ * Returns the area that will be affected (i.e. drawn to) when
+ * calling gtk_render_background() for the given @context and
+ * rectangle.
+ *
+ * Since: 3.20
+ */
+void
+gtk_render_background_get_clip (GtkStyleContext *context,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GdkRectangle *out_clip)
+{
+ GtkBorder shadow;
+
+ _gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_BOX_SHADOW), &shadow);
+
+ out_clip->x = floor (x) - shadow.left;
+ out_clip->y = floor (y) - shadow.top;
+ out_clip->width = ceil (width) + shadow.left + shadow.right;
+ out_clip->height = ceil (height) + shadow.top + shadow.bottom;
+}
+
+/**
* gtk_render_frame:
* @context: a #GtkStyleContext
* @cr: a #cairo_t
diff --git a/gtk/gtkrender.h b/gtk/gtkrender.h
index ea4b84a..81566c5 100644
--- a/gtk/gtkrender.h
+++ b/gtk/gtkrender.h
@@ -59,6 +59,15 @@ void gtk_render_background (GtkStyleContext *context,
gdouble y,
gdouble width,
gdouble height);
+
+GDK_AVAILABLE_IN_3_20
+void gtk_render_background_get_clip (GtkStyleContext *context,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GdkRectangle *out_clip);
+
GDK_AVAILABLE_IN_ALL
void gtk_render_frame (GtkStyleContext *context,
cairo_t *cr,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]