aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--src/sato-draw-cairo.c15
-rw-r--r--src/sato-draw.c205
3 files changed, 91 insertions, 141 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f24c0c..7ad28c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-02-07 Thomas Wood <thomas@openedhand.com>
+
+ * src/sato-draw-cairo.c: (sato_draw_box), (sato_draw_shadow),
+ (sato_draw_focus), (sato_draw_box_gap), (sato_draw_vline),
+ (sato_draw_hline):
+ * src/sato-draw.c: (sato_draw_box), (sato_draw_shadow),
+ (sato_draw_focus), (sato_draw_check), (sato_draw_option),
+ (sato_draw_extension), (sato_draw_vline), (sato_draw_hline),
+ (sato_draw_style_class_init):
+
+ Consolidate some of the differences between cairo and GDK versions
+
2008-02-05 Thomas Wood <thomas@openedhand.com>
* Makefile.am:
diff --git a/src/sato-draw-cairo.c b/src/sato-draw-cairo.c
index e9a51f7..d66c31f 100644
--- a/src/sato-draw-cairo.c
+++ b/src/sato-draw-cairo.c
@@ -72,7 +72,6 @@ sato_draw_box (DRAW_ARGS)
if (DETAIL ("paned") || DETAIL ("vscrollbar") || DETAIL ("hscrollbar"))
return;
-
/* hack to remove PRELIGHT state */
if (!DETAIL ("menuitem") && state_type == GTK_STATE_PRELIGHT)
{
@@ -206,6 +205,7 @@ static void
sato_draw_shadow (DRAW_ARGS)
{
cairo_t *cr;
+
DEBUG ("draw_shadow");
if (shadow_type == GTK_SHADOW_NONE)
@@ -213,7 +213,6 @@ sato_draw_shadow (DRAW_ARGS)
SANITIZE_SIZE;
-
/* FIXME: for RTL */
if (widget && (GTK_IS_SPIN_BUTTON (widget) || GTK_IS_COMBO_BOX_ENTRY (widget->parent)))
width += 10;
@@ -256,7 +255,7 @@ sato_draw_focus (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
gint x, gint y, gint width, gint height)
{
DEBUG ("draw_focus");
-
+ /* TODO */
}
static void
@@ -350,8 +349,8 @@ sato_draw_box_gap (GtkStyle * style, GdkWindow * window,
gint x, gint y, gint width, gint height,
GtkPositionType gap_side, gint gap_x, gint gap_width)
{
- GdkRectangle rect;
cairo_t *cr;
+ GdkRectangle rect;
if (shadow_type == GTK_SHADOW_NONE)
return;
@@ -473,6 +472,10 @@ sato_draw_vline (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
gint y1, gint y2, gint x)
{
cairo_t *cr;
+
+ if (DETAIL ("vscale") || DETAIL ("hscale"))
+ return;
+
cr = gdk_cairo_create (window);
cairo_set_line_width (cr, LINE_WIDTH);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
@@ -491,6 +494,10 @@ sato_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
gint x1, gint x2, gint y)
{
cairo_t *cr;
+
+ if (DETAIL ("vscale") || DETAIL ("hscale"))
+ return;
+
cr = gdk_cairo_create (window);
cairo_set_line_width (cr, LINE_WIDTH);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
diff --git a/src/sato-draw.c b/src/sato-draw.c
index b9f6db1..1ce090c 100644
--- a/src/sato-draw.c
+++ b/src/sato-draw.c
@@ -1,4 +1,4 @@
-/*
+/* vi: set expandtab sw=2 sts=2:
* sato-draw.c
* This file is part of sato-engine
*
@@ -161,71 +161,49 @@ sato_rounded_rectangle (GdkWindow * window, GdkGC * gc, gint x, gint y,
}
-
static void
-sato_gradient (GtkStyle * style, GdkWindow * window, GtkStateType state_type,
- gint x, gint y, gint width, gint height)
+sato_draw_box (DRAW_ARGS)
{
- gint i, rd, gd, bd; /* rd, gd, bd - change in r g and b for gradient */
- GdkColor start_color, end_color;
+ gboolean has_focus;
GdkGC *gc;
- gc = gdk_gc_new (window);
-
- /* get the start and end colours */
- if (state_type == GTK_STATE_ACTIVE)
- {
- start_color = style->bg[state_type];
- sato_shade_colour (&style->bg[state_type], &end_color, 1.15);
- }
- else
- {
- sato_shade_colour (&style->bg[state_type], &start_color, 1.15);
- end_color = style->bg[state_type];
- }
-
- /* set line for 1px */
- gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID, GDK_CAP_BUTT,
- GDK_JOIN_MITER);
+ GdkGC *border_color = style->fg_gc[state_type];
+ DEBUG ("draw_box");
- /* calculate the delta values */
-
- rd = (start_color.red - end_color.red) / MAX (height, 1);
- gd = (start_color.green - end_color.green) / MAX (height, 1);
- bd = (start_color.blue - end_color.blue) / MAX (height, 1);
+ if (DETAIL ("paned") || DETAIL ("vscrollbar") || DETAIL ("hscrollbar"))
+ return;
- i = -1;
- while (++i < height)
+ /* hack to remove PRELIGHT state */
+ if (!DETAIL ("menuitem") && state_type == GTK_STATE_PRELIGHT)
{
- gdk_gc_set_rgb_fg_color (gc, &start_color);
- gdk_draw_line (window, gc, x, y + i, x + width, y + i);
- start_color.red -= rd;
- start_color.blue -= bd;
- start_color.green -= gd;
+ if (GTK_IS_BUTTON (widget) && (gtk_button_get_relief (GTK_BUTTON (widget)) == GTK_RELIEF_NONE))
+ {
+ if (GTK_IS_TOGGLE_BUTTON (widget)
+ && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ {
+ state_type = GTK_STATE_ACTIVE;
+ }
+ else
+ {
+ /* none relief buttons shouldn't draw anything for "normal" state */
+ return;
+ }
+ }
+ else
+ {
+ state_type = GTK_STATE_NORMAL;
+ }
}
- /* round off the gradient corners */
- gdk_draw_point (window, style->bg_gc[state_type], x, y);
- gdk_draw_point (window, style->bg_gc[state_type], x, y + height - 1);
- gdk_draw_point (window, style->bg_gc[state_type], x + width - 1,
- y + height - 1);
- gdk_draw_point (window, style->bg_gc[state_type], x + width - 1, y);
-
-}
-
-static void
-sato_draw_box (DRAW_ARGS)
-{
- GdkGC *gc;
- gboolean has_focus;
-
- DEBUG ("draw_box");
SANITIZE_SIZE;
- if (DETAIL ("paned") || DETAIL ("menubar") || DETAIL ("toolbar"))
- return;
+ /*** treeview headers ***/
+ if (widget && GTK_IS_TREE_VIEW (widget->parent))
+ {
+ return;
+ }
has_focus = (widget && GTK_WIDGET_HAS_FOCUS (widget));
@@ -248,66 +226,36 @@ sato_draw_box (DRAW_ARGS)
entry = g_object_get_data (G_OBJECT (widget->parent), "sato-combo-entry");
if (GTK_IS_ENTRY (entry))
{
- gtk_widget_queue_draw_area (entry, entry->allocation.x, entry->allocation.y, entry->allocation.width,entry->allocation.height);
+ gtk_widget_queue_draw_area (entry, entry->allocation.x, entry->allocation.y,
+ entry->allocation.width,entry->allocation.height);
- if (!has_focus)
- has_focus = GTK_WIDGET_HAS_FOCUS (entry);
+ has_focus = GTK_WIDGET_HAS_FOCUS (entry);
}
g_object_set_data (G_OBJECT (widget->parent), "sato-combo-button", widget);
+ if (has_focus)
+ border_color = style->base_gc[GTK_STATE_SELECTED];
/* FIXME: RTL */
width += 10;
x -= 10;
-
}
- if (has_focus)
- gc = sato_gc_new (style->bg_gc [GTK_STATE_SELECTED], window);
- else
- gc = sato_gc_new (style->text_gc[state_type], window);
-
-
- /*** draw the gradient ***/
-
- if (!DETAIL ("menu") && !DETAIL ("trough"))
- sato_gradient (style, window, state_type, x+1, y+1, width-2, height-2);
-
+ gc = sato_gc_new (border_color, window);
-
- /*** treeview headers ***/
- if (widget && GTK_IS_TREE_VIEW (widget->parent))
+ /* menu and toolbars get just a single line at the bottom of the widget */
+ if (DETAIL ("menubar") || DETAIL ("toolbar"))
{
- goto exit;
+ gdk_draw_line (window, gc, x, y + height - 1, x + width, y + height - 1);
}
-
-
- if (DETAIL ("trough"))
- {
- if (widget && GTK_IS_HSCALE (widget))
- {
- gdk_draw_line (window, gc, x, y + height / 2, x + width, y + height / 2);
- goto exit;
- }
- else if (widget && GTK_IS_VSCALE (widget))
- {
- gdk_draw_line (window, gc, x + width / 2, y, x + width / 2, y + height);
- goto exit;
- }
- else
- gdk_draw_rectangle (window, style->base_gc[state_type], TRUE, x, y, width, height);
-
- }
-
- /*** draw the border ***/
- if (!DETAIL ("bar"))
+ else
{
+ gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x + 1, y + 1, width - 2, height - 2);
sato_rounded_rectangle (window, gc, x, y, width, height);
}
-exit:
g_object_unref (gc);
}
@@ -335,14 +283,17 @@ sato_draw_shadow (DRAW_ARGS)
button = g_object_get_data (G_OBJECT (widget->parent), "sato-combo-button");
if (GTK_IS_BUTTON (button))
- gtk_widget_queue_draw_area (button, button->allocation.x, button->allocation.y, button->allocation.width,button->allocation.height);
+ gtk_widget_queue_draw_area (button, button->allocation.x, button->allocation.y,
+ button->allocation.width,button->allocation.height);
}
+ /*** draw the border ***/
+
/* draw a hilight shadow on focused widgets (i.e. entry widgets) */
if (widget && GTK_WIDGET_HAS_FOCUS (widget))
gc = sato_gc_new (style->base_gc[GTK_STATE_SELECTED], window);
else
- gc = sato_gc_new (style->text_gc[state_type], window);
+ gc = sato_gc_new (style->fg_gc[state_type], window);
sato_rounded_rectangle (window, gc, x, y, width, height);
@@ -354,12 +305,8 @@ sato_draw_focus (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
GdkRectangle *area, GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height)
{
- GdkGC *gc;
DEBUG ("draw_focus");
-
- gc = sato_gc_new (style->fg_gc[state_type], window);
- sato_rounded_rectangle (window, gc, x, y, width, height);
- g_object_unref (gc);
+ /* TODO */
}
static void
@@ -374,19 +321,16 @@ sato_draw_check (GtkStyle * style, GdkWindow * window,
DEBUG ("draw_check");
gc = sato_gc_new (style->text_gc[state_type], window);
- /* clear the background */
- gdk_draw_rectangle (window, style->base_gc[GTK_STATE_NORMAL], TRUE, x+1, y+1, width-2, height-2);
+ /* draw the border */
+ gdk_draw_rectangle (window, style->base_gc[GTK_STATE_NORMAL], TRUE, x, y, width, height);
+ gdk_draw_rectangle (window, style->fg_gc[GTK_STATE_NORMAL], FALSE, x, y, width-1, height-1);
+ /*** draw check mark ***/
if (shadow_type == GTK_SHADOW_IN)
{
- GdkGC *mark_gc;
- mark_gc = sato_gc_new (style->base_gc[GTK_STATE_SELECTED], window);
- gdk_draw_rectangle (window, mark_gc, TRUE, x + 5, y + 5, width - 10, height - 10);
- g_object_unref (mark_gc);
+ gdk_draw_rectangle (window, gc, TRUE, x + 5, y + 5, width - 10, height - 10);
}
- sato_rounded_rectangle (window, gc, x, y, width, height);
-
g_object_unref (gc);
}
@@ -404,18 +348,15 @@ sato_draw_option (GtkStyle * style, GdkWindow * window,
gc = sato_gc_new (style->text_gc[state_type], window);
- /* clear the background */
+ /* draw the border */
gdk_draw_arc (window, style->base_gc[GTK_STATE_NORMAL], TRUE, x+1, y+1, width-2, height-2, 0, 360 * 64);
+ gdk_draw_arc (window, gc, FALSE, x, y, width, height, 0, 360 * 64);
+ /*** draw check mark ***/
if (shadow_type == GTK_SHADOW_IN)
{
- GdkGC *mark_gc;
- mark_gc = sato_gc_new (style->base_gc[GTK_STATE_SELECTED], window);
- gdk_draw_arc (window, mark_gc, TRUE, x + 5, y + 5, width - 10, height - 10, 0, 360 * 64);
- g_object_unref (mark_gc);
+ gdk_draw_arc (window, gc, TRUE, x + 5, y + 5, width - 10, height - 10, 0, 360 * 64);
}
- gdk_draw_arc (window, gc, FALSE, x, y, width, height, 0, 360 * 64);
-
g_object_unref (gc);
}
@@ -517,6 +458,9 @@ sato_draw_extension (GtkStyle * style, GdkWindow * window,
gc = sato_gc_new (style->text_gc[state_type], window);
+ sato_gradient (style, window, state_type, x + 2, y + 2, width - 4,
+ height - 4);
+
switch (gap_side)
{
@@ -541,10 +485,6 @@ sato_draw_extension (GtkStyle * style, GdkWindow * window,
width += 5;
break;
}
-
- if (state_type == GTK_STATE_NORMAL)
- sato_gradient (style, window, state_type, x + 4, y + 4, width - 8,
- height - 8);
@@ -578,10 +518,13 @@ sato_draw_vline (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
gint y1, gint y2, gint x)
{
GdkGC *line_gc;
- line_gc = sato_gc_new (style->text_gc[state_type], window);
if (DETAIL ("vscale") || DETAIL ("hscale"))
return;
+
+ line_gc = sato_gc_new (style->text_gc[state_type], window);
+
+
gdk_draw_line (window, line_gc, x, y1, x, y2);
g_object_unref (line_gc);
@@ -594,10 +537,11 @@ sato_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
{
GdkGC *line_gc;
- line_gc = sato_gc_new (style->text_gc[state_type], window);
-
if (DETAIL ("vscale") || DETAIL ("hscale"))
return;
+
+ line_gc = sato_gc_new (style->dark_gc[state_type], window);
+
gdk_draw_line (window, line_gc, x1, y, x2, y);
g_object_unref (line_gc);
@@ -620,20 +564,7 @@ sato_draw_style_class_init (GtkStyleClass * style_class)
style_class->draw_hline = sato_draw_hline;
style_class->draw_vline = sato_draw_vline;
style_class->draw_focus = sato_draw_focus;
-/*
-
- style_class->draw_arrow = draw_arrow;
- style_class->draw_check = draw_check;
- style_class->draw_option = draw_option;
- style_class->draw_tab = draw_tab;
- style_class->draw_shadow_gap = draw_shadow_gap;
- style_class->draw_box_gap = draw_box_gap;
- style_class->draw_extension = draw_extension;
- style_class->draw_focus = draw_focus;
- style_class->draw_slider = draw_slider;
- style_class->draw_handle = draw_handle;
- style_class->draw_layout = draw_layout;
-*/
+
}