Add a frame-gap illustration

This commit is contained in:
Matthias Clasen 2010-11-23 22:55:52 -05:00 committed by Carlos Garnacho
parent 1391a61bc5
commit d1f1af202b
4 changed files with 44 additions and 4 deletions

View File

@ -348,6 +348,7 @@ HTML_IMAGES = \
$(srcdir)/images/expanders.png \
$(srcdir)/images/background.png \
$(srcdir)/images/frames.png \
$(srcdir)/images/frame-gap.png \
$(srcdir)/images/sliders.png \
$(srcdir)/images/focus.png \
$(srcdir)/images/extensions.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

View File

@ -3037,7 +3037,7 @@ gtk_render_arrow (GtkStyleContext *context,
* <example>
* <title>Typical background rendering, showing the effect of
* <parameter>background-image</parameter>,
* <parameter>border-width</parameter and
* <parameter>border-width</parameter> and
* <parameter>border-radius</parameter></title>
* <inlinegraphic fileref="background.png" format="PNG"/>
* </example>
@ -3320,9 +3320,14 @@ gtk_render_slider (GtkStyleContext *context,
* @xy1_gap: end coordinate (X or Y depending on @gap_side) for the gap
*
* Renders a frame around the rectangle defined by (@x, @y, @width, @height),
* leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates for
* %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for %GTK_POS_LEFT
* and %GTK_POS_RIGHT.
* leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates
* for %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for
* %GTK_POS_LEFT and %GTK_POS_RIGHT.
*
* <example>
* <title>Typical rendering of a frame with a gap</title>
* <inlinegraphic fileref="frame-gap.png" format="PNG"/>
* </example>
*
* Since: 3.0
**/

View File

@ -265,6 +265,38 @@ draw_cb_extension (GtkWidget *widget, cairo_t *cr)
return TRUE;
}
static gboolean
draw_cb_frame_gap (GtkWidget *widget, cairo_t *cr)
{
GtkStyleContext *context;
GtkStyleProvider *provider;
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
provider = (GtkStyleProvider *)gtk_css_provider_new ();
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
".frame {\n"
" border-style: solid;\n"
" border-width: 1;\n"
" border-radius: 0;\n"
"}\n",
-1, NULL);
gtk_style_context_add_provider (context, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_class (context, "frame");
gtk_style_context_set_junction_sides (context, 0);
gtk_render_frame_gap (context, cr, 12, 12, 50, 50, GTK_POS_TOP, 15, 35);
gtk_style_context_remove_class (context, "frame");
gtk_style_context_remove_provider (context, provider);
gtk_style_context_restore (context);
return TRUE;
}
static char *what;
static gboolean
@ -290,6 +322,8 @@ draw_cb (GtkWidget *widget, cairo_t *cr)
return draw_cb_focus (widget, cr);
else if (strcmp (what, "extension") == 0)
return draw_cb_extension (widget, cr);
else if (strcmp (what, "frame-gap") == 0)
return draw_cb_frame_gap (widget, cr);
return FALSE;
}