[gtk-theme-engine-clearlooks/gtk-style-context: 19/21] Translate GtkJunctionSides to CairoCorners
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-theme-engine-clearlooks/gtk-style-context: 19/21] Translate GtkJunctionSides to CairoCorners
- Date: Tue, 16 Nov 2010 12:27:28 +0000 (UTC)
commit 373d4a2461ab9ec02a7d755cb99adee271fac25b
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 16 00:59:38 2010 +0100
Translate GtkJunctionSides to CairoCorners
src/clearlooks_draw.c | 125 ++++++++++++++++++++++++++++++-----------------
src/clearlooks_draw.h | 1 +
src/clearlooks_engine.c | 3 +-
3 files changed, 83 insertions(+), 46 deletions(-)
---
diff --git a/src/clearlooks_draw.c b/src/clearlooks_draw.c
index abc51cc..575fe2a 100644
--- a/src/clearlooks_draw.c
+++ b/src/clearlooks_draw.c
@@ -139,7 +139,7 @@ clearlooks_draw_top_left_highlight (cairo_t *cr,
double line_width = cairo_get_line_width (cr);
double offset = line_width / 2.0;
double light_top, light_bottom, light_left, light_right;
- double radius;
+ gint radius;
clearlooks_engine = CLEARLOOKS_ENGINE (engine);
@@ -293,7 +293,7 @@ clearlooks_draw_button (cairo_t *cr,
{
ClearlooksStyleFunctions *style_functions;
double xoffset = 0, yoffset = 0;
- double radius;
+ gint radius;
GtkStateFlags state;
const CairoColor *fill;
CairoColor border_normal;
@@ -342,7 +342,7 @@ clearlooks_draw_button (cairo_t *cr,
ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
width-(xoffset*2)-2,
height-(yoffset*2)-2,
- radius, 0); //params->corners);
+ radius, clearlooks_get_corners (engine));
if (state & GTK_STATE_FLAG_ACTIVE)
{
@@ -416,7 +416,7 @@ clearlooks_draw_button (cairo_t *cr,
ge_shade_color (&border_normal, 0.74, &border_normal);
}
- ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, clearlooks_get_corners (engine));
if (state & GTK_STATE_FLAG_INSENSITIVE)
{
@@ -452,7 +452,7 @@ clearlooks_draw_entry (cairo_t *cr,
{
CairoColor *base;
CairoColor border;
- double radius;
+ gint radius;
int xoffset, yoffset;
GtkStateFlags state;
@@ -494,8 +494,8 @@ clearlooks_draw_entry (cairo_t *cr,
/* Now fill the area we want to be base[NORMAL]. */
ge_cairo_rounded_rectangle (cr, xoffset + 1, yoffset + 1, width - (xoffset + 1)*2,
- height - (yoffset + 1) * 2, MAX(0, radius-1), 0);
-// params->corners);
+ height - (yoffset + 1) * 2, MAX(0, radius-1),
+ clearlooks_get_corners (engine));
ge_cairo_set_color (cr, base);
cairo_fill (cr);
@@ -508,7 +508,7 @@ clearlooks_draw_entry (cairo_t *cr,
clearlooks_set_mixed_color (cr, base, &focus_shadow, 0.5);
ge_cairo_inner_rounded_rectangle (cr, xoffset + 1, yoffset + 1,
width - (xoffset + 1)*2, height - (yoffset + 1)*2,
- MAX(0, radius-1), 0); //params->corners);
+ MAX(0, radius-1), clearlooks_get_corners (engine));
cairo_stroke (cr);
}
else
@@ -529,7 +529,7 @@ clearlooks_draw_entry (cairo_t *cr,
ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset,
width-2*xoffset, height-2*yoffset,
- radius, 0); //params->corners);
+ radius, clearlooks_get_corners (engine));
if (state & GTK_STATE_FLAG_FOCUSED ||
state & GTK_STATE_FLAG_INSENSITIVE)
ge_cairo_set_color (cr, &border);
@@ -553,7 +553,7 @@ clearlooks_draw_entry_progress (cairo_t *cr,
gint entry_width, entry_height;
GtkStateFlags state;
double entry_radius;
- double radius;
+ gint radius;
cairo_save (cr);
@@ -675,7 +675,7 @@ clearlooks_draw_spinbutton_down (cairo_t *cr,
int x, int y, int width, int height)
{
cairo_pattern_t *pattern;
- double radius;
+ gint radius;
CairoColor *bg_color, shadow;
gtk_theming_engine_get (engine, 0,
@@ -695,7 +695,8 @@ clearlooks_draw_spinbutton_down (cairo_t *cr,
cairo_translate (cr, x+1, y+1);
- ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius,
+ clearlooks_get_corners (engine));
ge_cairo_set_color (cr, bg_color);
@@ -817,7 +818,7 @@ clearlooks_draw_slider (cairo_t *cr,
CairoColor spot, fill, border;
cairo_pattern_t *pattern;
GtkStateFlags state;
- double radius;
+ gint radius;
state = gtk_theming_engine_get_state (engine);
gtk_theming_engine_get (engine, state,
@@ -841,7 +842,8 @@ clearlooks_draw_slider (cairo_t *cr,
clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
/* fill the widget */
- ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius,
+ clearlooks_get_corners (engine));
/* Fake light */
if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
@@ -873,7 +875,8 @@ clearlooks_draw_slider (cairo_t *cr,
cairo_new_path (cr);
/* Draw the handles */
- ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius,
+ clearlooks_get_corners (engine));
pattern = cairo_pattern_create_linear (1.0, 1.0, 1.0, 1.0+height);
if (state & GTK_STATE_FLAG_PRELIGHT)
@@ -897,7 +900,8 @@ clearlooks_draw_slider (cairo_t *cr,
cairo_restore (cr);
/* Draw the border */
- ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius,
+ clearlooks_get_corners (engine));
if (state & GTK_STATE_FLAG_PRELIGHT ||
state & GTK_STATE_FLAG_INSENSITIVE)
@@ -929,7 +933,7 @@ clearlooks_draw_slider_button (cairo_t *cr,
int x, int y, int width, int height)
{
ClearlooksStyleFunctions *style_functions;
- double radius;
+ gint radius;
gtk_theming_engine_get (engine,
gtk_theming_engine_get_state (engine),
@@ -964,7 +968,7 @@ clearlooks_draw_progressbar_trough (cairo_t *cr,
{
CairoColor fill, border, shadow;
cairo_pattern_t *pattern;
- double radius;
+ gint radius;
GtkStateFlags state;
state = gtk_theming_engine_get_state (engine);
@@ -982,17 +986,20 @@ clearlooks_draw_progressbar_trough (cairo_t *cr,
cairo_set_line_width (cr, 1.0);
/* Create trough box */
- ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius,
+ clearlooks_get_corners (engine));
ge_cairo_set_color (cr, &fill);
cairo_fill (cr);
/* Draw border */
- ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius,
+ clearlooks_get_corners (engine));
ge_cairo_set_color (cr, &border);
cairo_stroke (cr);
/* clip the corners of the shadows */
- ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius,
+ clearlooks_get_corners (engine));
cairo_clip (cr);
ge_shade_color (&border, 0.925, &shadow);
@@ -1029,7 +1036,7 @@ clearlooks_draw_progressbar_fill (cairo_t *cr,
boolean is_horizontal = progressbar->orientation < 2;
double tile_pos = 0;
double stroke_width;
- double radius;
+ gint radius;
int x_step;
cairo_pattern_t *pattern;
@@ -1359,7 +1366,7 @@ clearlooks_draw_frame (cairo_t *cr,
const CairoColor *border = &frame->border;
ClearlooksRectangle bevel_clip = {0, 0, 0, 0};
ClearlooksRectangle frame_clip = {0, 0, 0, 0};
- double radius;
+ gint radius;
CairoColor hilight;
gtk_theming_engine_get (engine, 0,
@@ -1397,16 +1404,18 @@ clearlooks_draw_frame (cairo_t *cr,
{
ge_cairo_set_color (cr, &hilight);
if (frame->shadow == CL_SHADOW_ETCHED_IN)
- ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius,
+ clearlooks_get_corners (engine));
else
- ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius,
+ clearlooks_get_corners (engine));
cairo_stroke (cr);
}
#if 0
else if (frame->shadow != CL_SHADOW_NONE)
{
ShadowParameters shadow;
- shadow.corners = 0; //params->corners;
+ shadow.corners = clearlooks_get_corners (engine);
shadow.shadow = frame->shadow;
clearlooks_draw_highlight_and_shade (cr, engine, &shadow, width, height, radius);
}
@@ -1429,14 +1438,17 @@ clearlooks_draw_frame (cairo_t *cr,
{
ge_cairo_set_color (cr, &dark);
if (frame->shadow == CL_SHADOW_ETCHED_IN)
- ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius,
+ clearlooks_get_corners (engine));
else
- ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius,
+ clearlooks_get_corners (engine));
}
else
{
ge_cairo_set_color (cr, border);
- ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius,
+ clearlooks_get_corners (engine));
}
cairo_stroke (cr);
@@ -1456,7 +1468,7 @@ clearlooks_draw_tab (cairo_t *cr,
cairo_pattern_t *pattern;
- double radius;
+ gint radius;
double stripe_size = 2.0;
double stripe_fill_size;
double length;
@@ -1509,7 +1521,7 @@ clearlooks_draw_tab (cairo_t *cr,
/* Set tab shape */
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
- radius, 0); //params->corners);
+ radius, clearlooks_get_corners (engine));
/* Draw fill */
ge_cairo_set_color (cr, fill);
@@ -1525,7 +1537,7 @@ clearlooks_draw_tab (cairo_t *cr,
ShadowParameters shadow;
shadow.shadow = CL_SHADOW_OUT;
- shadow.corners = 0; //params->corners;
+ shadow.corners = clearlooks_get_corners (engine);
clearlooks_draw_highlight_and_shade (cr, colors, &shadow,
width,
@@ -1554,7 +1566,7 @@ clearlooks_draw_tab (cairo_t *cr,
pattern = NULL;
}
- ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, clearlooks_get_corners (engine));
ge_shade_color (fill, 0.92, &shadow);
@@ -1587,7 +1599,7 @@ clearlooks_draw_tab (cairo_t *cr,
pattern = NULL;
}
- ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, 0); //params->corners);
+ ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, clearlooks_get_corners (engine));
cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_fill.r, stripe_fill.g, stripe_fill.b);
cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_fill.r, stripe_fill.g, stripe_fill.b);
@@ -1598,7 +1610,7 @@ clearlooks_draw_tab (cairo_t *cr,
cairo_pattern_destroy (pattern);
}
- ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, 0); //params->corners);
+ ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, clearlooks_get_corners (engine));
if (state & GTK_STATE_FLAG_ACTIVE)
{
@@ -1808,7 +1820,7 @@ clearlooks_draw_menuitem (cairo_t *cr,
{
CairoColor fill, fill_shade, border;
cairo_pattern_t *pattern;
- gdouble radius;
+ gint radius;
clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &fill);
clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
@@ -1821,7 +1833,7 @@ clearlooks_draw_menuitem (cairo_t *cr,
ge_shade_color (&fill, 0.85, &fill_shade);
cairo_set_line_width (cr, 1.0);
- ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, radius, 0); //widget->corners);
+ ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, radius, clearlooks_get_corners (engine));
pattern = cairo_pattern_create_linear (x, y, x, y + height);
cairo_pattern_add_color_stop_rgb (pattern, 0, fill.r, fill.g, fill.b);
@@ -1842,7 +1854,7 @@ clearlooks_draw_menubaritem (cairo_t *cr,
{
CairoColor fill, fill_shade, border;
cairo_pattern_t *pattern;
- gdouble radius;
+ gint radius;
clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &fill);
clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
@@ -1855,7 +1867,7 @@ clearlooks_draw_menubaritem (cairo_t *cr,
ge_shade_color (&fill, 0.85, &fill_shade);
cairo_set_line_width (cr, 1.0);
- ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, radius, 0); //widget->corners);
+ ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, radius, clearlooks_get_corners (engine));
pattern = cairo_pattern_create_linear (x, y, x, y + height);
cairo_pattern_add_color_stop_rgb (pattern, 0, fill.r, fill.g, fill.b);
@@ -1920,7 +1932,7 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
CairoColor bg, bg_shade, border;
cairo_pattern_t *pattern;
GtkStateFlags state;
- double radius;
+ gint radius;
state = gtk_theming_engine_get_state (engine);
gtk_theming_engine_get (engine, state,
@@ -1945,7 +1957,7 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
/* Draw fill */
if (radius > 3.0)
ge_cairo_rounded_rectangle (cr, 1, 0, width-2, height,
- radius, 0); //widget->corners);
+ radius, clearlooks_get_corners (engine));
else
cairo_rectangle (cr, 1, 0, width-2, height);
ge_cairo_set_color (cr, &bg);
@@ -1963,7 +1975,7 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
/* Draw border */
if (radius > 3.0)
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
- radius, 0); //widget->corners);
+ radius, clearlooks_get_corners (engine));
else
cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
ge_cairo_set_color (cr, &border);
@@ -1983,7 +1995,7 @@ clearlooks_draw_scrollbar_stepper (cairo_t *cr,
CairoColor s1, s2, s3, s4;
cairo_pattern_t *pattern;
GtkStateFlags state;
- double radius;
+ gint radius;
state = gtk_theming_engine_get_state (engine);
gtk_theming_engine_get (engine, state,
@@ -2294,7 +2306,7 @@ clearlooks_draw_icon_view_item (cairo_t *cr,
CairoColor lower_color;
cairo_pattern_t *pattern;
GtkStateFlags state;
- gdouble radius;
+ gint radius;
cairo_save (cr);
@@ -2575,7 +2587,7 @@ clearlooks_draw_checkbox (cairo_t *cr,
gboolean inconsistent = FALSE;
gboolean draw_bullet;
GtkStateFlags state;
- gdouble radius;
+ gint radius;
state = gtk_theming_engine_get_state (engine);
inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
@@ -2886,6 +2898,29 @@ clearlooks_lookup_spot (GtkThemingEngine *engine,
gdk_rgba_free ((GdkRGBA *) bg_color);
}
+CairoCorners
+clearlooks_get_corners (GtkThemingEngine *engine)
+{
+ GtkJunctionSides sides;
+ CairoCorners corners = CR_CORNER_ALL;
+
+ sides = gtk_theming_engine_get_junction_sides (engine);
+
+ if (sides == 0)
+ return CR_CORNER_ALL;
+
+ if (sides & GTK_JUNCTION_LEFT)
+ corners &= ~(CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
+ if (sides & GTK_JUNCTION_RIGHT)
+ corners &= ~(CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
+ if (sides & GTK_JUNCTION_BOTTOM)
+ corners &= ~(CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT);
+ if (sides & GTK_JUNCTION_TOP)
+ corners &= ~(CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT);
+
+ return corners;
+}
+
void
clearlooks_lookup_functions (ClearlooksEngine *engine,
ClearlooksStyleFunctions **functions,
diff --git a/src/clearlooks_draw.h b/src/clearlooks_draw.h
index 38cca47..850346d 100644
--- a/src/clearlooks_draw.h
+++ b/src/clearlooks_draw.h
@@ -48,6 +48,7 @@ void clearlooks_lookup_shade (GtkThemingEngine *engine,
void clearlooks_lookup_spot (GtkThemingEngine *engine,
guint spot_number,
GdkRGBA *color);
+CairoCorners clearlooks_get_corners (GtkThemingEngine *engine);
/* Fallback focus function */
GE_INTERNAL void clearlooks_draw_focus (cairo_t *cr,
diff --git a/src/clearlooks_engine.c b/src/clearlooks_engine.c
index 051233f..267fefb 100644
--- a/src/clearlooks_engine.c
+++ b/src/clearlooks_engine.c
@@ -299,7 +299,8 @@ clearlooks_engine_render_frame_gap (GtkThemingEngine *engine,
#endif
/* Fill the background with bg[NORMAL] */
- ge_cairo_rounded_rectangle (cr, x, y, width, height, radius, 0); //params.corners);
+ ge_cairo_rounded_rectangle (cr, x, y, width, height, radius,
+ clearlooks_get_corners (engine));
ge_cairo_set_color (cr, bg_color);
cairo_fill (cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]