GtkThemingEngine: Add cairo-ified rendering primitives.

Functions to add paths for lines, rectangle sides, and the gap side in notebooks
have been added.
This commit is contained in:
Carlos Garnacho 2010-07-19 11:51:17 +02:00
parent 5cdb3f0e90
commit 75b059a3f2

View File

@ -709,131 +709,66 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
} }
static void static void
add_path_rounded_rectangle (cairo_t *cr, add_path_line (cairo_t *cr,
gdouble radius, gdouble x1,
guint sides, gdouble y1,
gdouble x, gdouble x2,
gdouble y, gdouble y2)
gdouble width,
gdouble height)
{ {
gdouble r = 0; /* Adjust endpoints */
if (y1 == y2)
if (sides & SIDE_BOTTOM)
{ {
/* Bottom left corner */ y1 += 0.5;
if (r == 0) y2 += 0.5;
cairo_move_to (cr, x + 0.5, y + height - 0.5); x2 += 1;
else }
cairo_arc_negative (cr, else if (x1 == x2)
x + r + 0.5, {
y + height - r - 0.5, x1 += 0.5;
r, x2 += 0.5;
135 * (G_PI / 180), y2 += 1;
90 * (G_PI / 180)); }
/* Bottom side */ cairo_move_to (cr, x1, y1);
cairo_line_to (cr, x + width - r - 0.5, y + height - 0.5); cairo_line_to (cr, x2, y2);
}
/* Bottom right corner */ static void
if (r > 0) add_path_rectangle_sides (cairo_t *cr,
cairo_arc_negative (cr, gdouble x,
x + width - r - 0.5, gdouble y,
y + height - r - 0.5, gdouble width,
r, gdouble height,
90 * (G_PI / 180), guint sides)
45 * (G_PI / 180)); {
if (sides & SIDE_TOP)
{
cairo_move_to (cr, x, y + 0.5);
cairo_line_to (cr, x + width, y + 0.5);
} }
if (sides & SIDE_RIGHT) if (sides & SIDE_RIGHT)
{ {
/* Bottom right corner */ cairo_move_to (cr, x + width - 0.5, y);
if (r == 0) cairo_line_to (cr, x + width - 0.5, y + height);
{
if ((sides & SIDE_BOTTOM) == 0)
cairo_move_to (cr, x + width - 0.5, y + height - 0.5);
}
else
cairo_arc_negative (cr,
x + width - r - 0.5,
y + height - r - 0.5,
r,
45 * (G_PI / 180), 0);
/* Right side */
cairo_line_to (cr, x + width - 0.5, y + r);
/* Top right corner */
if (r > 0)
cairo_arc_negative (cr,
x + width - r - 0.5,
y + r + 0.5,
r,
0, 315 * (G_PI / 180));
} }
if (sides & SIDE_TOP) if (sides & SIDE_BOTTOM)
{ {
/* Top right corner */ cairo_move_to (cr, x, y + height - 0.5);
if (r == 0) cairo_line_to (cr, x + width, y + height - 0.5);
{
if ((sides & SIDE_RIGHT) == 0)
cairo_move_to (cr, x + width - 1, y + 0.5);
}
else
cairo_arc_negative (cr,
x + width - r - 0.5,
y + r + 0.5,
r,
315 * (G_PI / 180),
270 * (G_PI / 180));
/* Top side */
cairo_line_to (cr, x + 0.5 + r, y + 0.5);
/* Top left corner */
if (r > 0)
cairo_arc_negative (cr,
x + r + 0.5,
y + r + 0.5,
r,
270 * (G_PI / 180),
225 * (G_PI / 180));
} }
if (sides & SIDE_LEFT) if (sides & SIDE_LEFT)
{ {
/* Top left corner */ cairo_move_to (cr, x + 0.5, y + height);
if (r == 0) cairo_line_to (cr, x + 0.5, y);
{
if ((sides & SIDE_TOP) == 0)
cairo_move_to (cr, x + 0.5, y + 0.5);
}
else
cairo_arc_negative (cr,
x + + r + 0.5,
y + r + 0.5,
r,
225 * (G_PI / 180),
180 * (G_PI / 180));
/* Left side */
cairo_line_to (cr, x + 0.5, y + height - r);
if (r > 0)
cairo_arc_negative (cr,
x + r + 0.5,
y + height - r + 0.5,
r,
180 * (G_PI / 180),
135 * (G_PI / 180));
} }
} }
static void static void
add_path_gap_side (cairo_t *cr, add_path_gap_side (cairo_t *cr,
GtkPositionType gap_side, GtkPositionType gap_side,
gdouble radius,
gdouble x, gdouble x,
gdouble y, gdouble y,
gdouble width, gdouble width,
@ -841,37 +776,24 @@ add_path_gap_side (cairo_t *cr,
gdouble xy0_gap, gdouble xy0_gap,
gdouble xy1_gap) gdouble xy1_gap)
{ {
if (gap_side == GTK_POS_TOP) switch (gap_side)
{ {
cairo_move_to (cr, x, y); case GTK_POS_TOP:
cairo_line_to (cr, x + xy0_gap, y); add_path_line (cr, x, y, x + xy0_gap, y);
add_path_line (cr, x + xy1_gap, y, x + width, y);
cairo_move_to (cr, x + xy1_gap, y); break;
cairo_line_to (cr, x + width, y); case GTK_POS_BOTTOM:
} add_path_line (cr, x, y + height, x + xy0_gap, y + height);
else if (gap_side == GTK_POS_BOTTOM) add_path_line (cr, x + xy1_gap, y + height, x + width, y + height);
{ break;
cairo_move_to (cr, x, y + height); case GTK_POS_LEFT:
cairo_line_to (cr, x + xy0_gap, y + height); add_path_line (cr, x, y, x, y + xy0_gap);
add_path_line (cr, x, y + xy1_gap, x, y + height);
cairo_move_to (cr, x + xy1_gap, y + height); break;
cairo_line_to (cr, x + width, y + height); case GTK_POS_RIGHT:
} add_path_line (cr, x + width, y, x + width, y + xy0_gap);
else if (gap_side == GTK_POS_LEFT) add_path_line (cr, x + width, y + xy1_gap, x + width, y + height);
{ break;
cairo_move_to (cr, x, y);
cairo_line_to (cr, x, y + xy0_gap);
cairo_move_to (cr, x, y + xy1_gap);
cairo_line_to (cr, x, y + height);
}
else
{
cairo_move_to (cr, x + width, y);
cairo_line_to (cr, x + width, y + xy0_gap);
cairo_move_to (cr, x + width, y + xy1_gap);
cairo_line_to (cr, x + width, y + height);
} }
} }