r4305 - in trunk/src/target/OM-2007.2/libraries/moko-gtk-engine: . data/gtk-2.0 src
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Thu Apr 3 15:46:34 CEST 2008
Author: thomas
Date: 2008-04-03 15:46:31 +0200 (Thu, 03 Apr 2008)
New Revision: 4305
Modified:
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/ChangeLog
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/gtkrc
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/openmoko-dialer
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/src/moko-draw.c
Log:
2008-04-03 Thomas Wood <thomas at openedhand.com>
* src/moko-draw.c:
* data/gtk-2.0/gtkrc:
* data/gtk-2.0/openmoko-dialer:
Completely redesign the visual style, with emphasis on simplicity and
speed.
Modified: trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/ChangeLog 2008-04-03 10:30:02 UTC (rev 4304)
+++ trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/ChangeLog 2008-04-03 13:46:31 UTC (rev 4305)
@@ -1,3 +1,12 @@
+2008-04-03 Thomas Wood <thomas at openedhand.com>
+
+ * src/moko-draw.c:
+ * data/gtk-2.0/gtkrc:
+ * data/gtk-2.0/openmoko-dialer:
+
+ Completely redesign the visual style, with emphasis on simplicity and
+ speed.
+
2007-12-07 Thomas Wood <thomas at openedhand.com>
* src/moko-draw.c: (moko_draw_vline), (moko_draw_hline),
Modified: trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/gtkrc
===================================================================
--- trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/gtkrc 2008-04-03 10:30:02 UTC (rev 4304)
+++ trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/gtkrc 2008-04-03 13:46:31 UTC (rev 4305)
@@ -1,7 +1,7 @@
# Moko GTK+ theme
#
# Copyright 2007 OpenedHand Ltd <info at openedhand.com>
-# Based on OpenedHand's Sato GTK+ Theme
+# Originally based on OpenedHand's Sato GTK+ Theme
#
# This theme uses several style properties introduced in GTK+ 2.10
#
@@ -14,7 +14,7 @@
gtk-icon-sizes = "gtk-button=32,32:gtk-small-toolbar=48,48:gtk-large-toolbar=48,48"
# Set the default gtk-color-scheme property
-gtk_color_scheme = "fg_color:#000;bg_color:#f4f0f4;base_color:#fff;text_color:#000;selected_bg_color:#ff7d00;selected_fg_color:#000"
+gtk_color_scheme = "fg_color:#fff;bg_color:#333;base_color:#fff;text_color:#000;selected_bg_color:#ff7d00;selected_fg_color:#000"
style "default"
{
@@ -24,6 +24,7 @@
GtkButton::default_border = {0, 0, 0, 0}
GtkButton::focus-line-width = 0
+ GtkButton::inner_border = {10, 10, 10, 10}
GtkCheckButton::indicator-size = 35
GtkCheckButton::indicator-spacing = 5
GtkCheckMenuItem::indicator_size = 18
@@ -78,69 +79,38 @@
base [ACTIVE] = @base_color
engine "moko-engine" {
- border = TRUE
}
}
-
class "GtkWidget" style "default"
-style "reversed"
-{
- bg[NORMAL] = @fg_color
- fg[NORMAL] = @bg_color
-
- bg[PRELIGHT] = @fg_color
- fg[PRELIGHT] = @bg_color
-}
-widget_class "*GtkButton*" style "reversed"
-
style "button"
{
- GtkButton::inner_border = {15, 15, 10, 10}
- engine "moko-engine" {
- border = TRUE
- gradient = TRUE
- }
+ bg[NORMAL] = lighter (@bg_color)
+ bg[PRELIGHT] = lighter (@bg_color)
}
class "GtkButton" style "button"
-style "button-colors" {
- bg[NORMAL] = "#333"
- fg[NORMAL] = "#fff"
+style "button-with-indicator"
+{
+ bg[NORMAL] = @bg_color
+ fg[NORMAL] = @fg_color
- bg[PRELIGHT] = "#333"
- fg[PRELIGHT] = "#fff"
-}
-widget_class "GtkButton*" style "button-colors"
+ bg[ACTIVE] = @bg_color
+ fg[ACTIVE] = @fg_color
-style "treeview-header" {
-
- # inner-border was added in GTK+ 2.10
- GtkButton::inner_border = {0, 0, 0, 0}
-
- bg[NORMAL] = "#eee"
- fg[NORMAL] = "#000"
-
- bg[PRELIGHT] = "#eee"
- fg[PRELIGHT] = "#000"
-
- engine "moko-engine" {
- border = FALSE
- gradient = TRUE
- }
+ bg[PRELIGHT] = @bg_color
+ fg[PRELIGHT] = @fg_color
}
-widget_class "*GtkTreeView.GtkButton*" style "treeview-header"
+widget_class "*.GtkCheckButton.*" style "button-with-indicator"
+widget_class "*.GtkRadioButton.*" style "button-with-indicator"
style "combo" {
bg[NORMAL] = @selected_bg_color
+ fg[NORMAL] = @selected_fg_color
text[NORMAL] = @selected_fg_color
bg[PRELIGHT] = @selected_bg_color
text[PRELIGHT] = @selected_fg_color
-
- engine "moko-engine" {
- gradient = TRUE
- }
}
widget_class "*Combo*" style "combo"
@@ -149,35 +119,8 @@
GtkToolbar::internal_padding = 0
xthickness = 0
ythickness = 0
-
- engine "moko-engine" {
- gradient = TRUE
- border = FALSE
- }
}
class "GtkToolbar" style "toolbar"
-class "GtkToolbar" style "reversed"
-
-style "toolitem"
-{
- xthickness = 12
- ythickness = 12
-
- bg[NORMAL] = @selected_bg_color
- fg[NORMAL] = @selected_fg_color
-
- # toolbar colours are reversed
- bg[PRELIGHT] = @fg_color
- fg[PRELIGHT] = @bg_color
-
- engine "moko-engine" {
- gradient = TRUE
- border = FALSE
- }
-}
-widget_class "*Tool*GtkToggleButton" style "toolitem"
-widget_class "*Tool*GtkButton" style "toolitem"
-
style "notebook"
{
xthickness = 0
@@ -185,59 +128,38 @@
# For notebookes, NORMAL is used for the active tab and ACTIVE is used for
# ther other tabs
- bg[NORMAL] = @selected_bg_color
- fg[NORMAL] = @selected_fg_color
-
- # inactive tabs are in "reversed" colours
- fg[ACTIVE] = @bg_color
- bg[ACTIVE] = @fg_color
+ fg[ACTIVE] = @fg_color
+ bg[ACTIVE] = shade (0.3, @bg_color)
}
-class "GtkNotebook" style "notebook"
+widget_class "*GtkNotebook" style "notebook"
-style "menu"
-{
- engine "moko-engine" {
- gradient = FALSE
- border = TRUE
- }
-}
-class "GtkMenu" style "menu"
-
-style "menubar"
-{
- engine "moko-engine" {
- gradient = TRUE
- }
-}
-class "GtkMenuBar" style "menubar"
-widget_class "*GtkMenuBar*" style "reversed"
-
style "menuitem"
{
xthickness = 8
ythickness = 8
+ text[NORMAL] = @fg_color
+ text[PRELIGHT] = @selected_fg_color
+
bg[PRELIGHT] = @selected_bg_color
fg[PRELIGHT] = @selected_fg_color
-
- engine "moko-engine" {
- gradient = TRUE
- border = FALSE
- }
}
widget_class "*MenuItem*" style "menuitem"
+widget "GtkWindow.gtk-combobox-popup-menu" style "menuitem"
style "scrollbar"
{
bg[NORMAL] = @selected_bg_color
bg[PRELIGHT] = @selected_bg_color
-
- engine "moko-engine" {
- border = TRUE
- }
}
class "GtkScrollbar" style "scrollbar"
+style "mokosearchbutton"
+{
+ bg[NORMAL] = "#C0C0C0"
+}
+widget "*.mokosearchbutton" style "mokosearchbutton"
+
include "matchboxpanel"
include "openmoko-calculator"
include "openmoko-contacts"
Modified: trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/openmoko-dialer
===================================================================
--- trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/openmoko-dialer 2008-04-03 10:30:02 UTC (rev 4304)
+++ trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/openmoko-dialer 2008-04-03 13:46:31 UTC (rev 4305)
@@ -12,5 +12,3 @@
widget "*.MokoDialerTextview" style "mokodialertextview"
widget "*.MokoTips*" style "mokodialertextview"
-widget_class "*MokoDigitButton*" style "reversed" # defined in the main gtkrc
-
Modified: trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/src/moko-draw.c
===================================================================
--- trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/src/moko-draw.c 2008-04-03 10:30:02 UTC (rev 4304)
+++ trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/src/moko-draw.c 2008-04-03 13:46:31 UTC (rev 4305)
@@ -35,141 +35,7 @@
GtkStyleClass *parent_style_class;
-/**
- * Prepare a new GC with the additional Moko style values
- */
-static GdkGC*
-moko_gc_new (GdkGC* old_gc, GdkDrawable *d)
-{
- GdkGC *new_gc;
- new_gc = gdk_gc_new (d);
- gdk_gc_copy (new_gc, old_gc);
- gdk_gc_set_line_attributes (new_gc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
- return new_gc;
-}
-
-/*
- * moko_dither16:
- * @dither: An 18x1, 1-bit pixmap
- * @gc: The gc that needs to be dithered
- * @gcd: A gc for @dither
- * @c1: The intended colour
- * @i: Any random number
- *
- * Calculates and sets the dither colour and pattern for a 16-bit drawable,
- * given a 32-bit colour.
- */
static void
-moko_dither16 (GdkPixmap *dither, GdkGC *gc, GdkGC *gcd, GdkColor *c1, gint i)
-{
- gint sum, x;
- GdkColor c1d;
- /* Assuming 565, so see how much of the colour is ignored and use that
- * to decide on the dithering colour/pattern.
- */
- c1d.red = c1->red & 0x700;
- c1d.green = c1->green & 0x300;
- c1d.blue = c1->blue & 0x700;
-
- sum = (c1d.red + c1d.green + c1d.blue) >> 8;
- gdk_gc_set_function (gcd, GDK_SET);
- gdk_draw_line (dither, gcd, 0, 0, 17, 0);
- gdk_gc_set_function (gcd, GDK_CLEAR);
- for (x = 0; x < sum; x ++) {
- gdk_draw_point (dither, gcd, ((x+(i<<3)) * 11) % 18, 0);
- }
-
- c1d.red = c1->red + 0x800;
- c1d.green = c1->green + 0x400;
- c1d.blue = c1->blue + 0x800;
- if (c1d.red < c1->red) c1d.red = 0xFF00;
- if (c1d.green < c1->green) c1d.green = 0xFF00;
- if (c1d.blue < c1->blue) c1d.blue = 0xFF00;
- gdk_gc_set_rgb_bg_color (gc, &c1d);
-
- gdk_gc_set_fill (gc, GDK_OPAQUE_STIPPLED);
- gdk_gc_set_stipple (gc, dither);
-}
-
-static void
-moko_gradient (GtkStyle * style, GdkWindow * window, GtkStateType state_type,
- gint x, gint y, gint width, gint height)
-{
- gint i, rd, gd, bd, depth; /* rd, gd, bd - change in r g and b for gradient */
- GdkColor c1, c2, c3, c4, c1d, c3d;
- GdkPixmap *dither;
- GdkGC *gc, *gcd;
- gc = gdk_gc_new (window);
-
- /* get the start and end colours */
- moko_shade_colour (&style->bg[state_type], &c1, 0.8);
- moko_shade_colour (&style->bg[state_type], &c2, 0.4);
- moko_shade_colour (&style->bg[state_type], &c3, 0.3);
- moko_shade_colour (&style->bg[state_type], &c4, 0.0);
-
- /* set line for 1px */
- gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID, GDK_CAP_BUTT,
- GDK_JOIN_MITER);
-
- /* Get the drawable pixel depth, for dithering */
- depth = gdk_drawable_get_depth (window);
- if (depth == 16) {
- dither = gdk_pixmap_new (NULL, 18, 1, 1);
- gcd = gdk_gc_new (dither);
- }
-
- /*** First Gradient ***/
- /* calculate the delta values */
-
- rd = (c1.red - c2.red) / MAX (height / 2, 1);
- gd = (c1.green - c2.green) / MAX (height / 2, 1);
- bd = (c1.blue - c2.blue) / MAX (height / 2, 1);
-
- i = 0;
- while (i < height / 2)
- {
- gdk_gc_set_rgb_fg_color (gc, &c1);
- /* TODO: Handle 15-bit colour */
- if (depth == 16) {
- moko_dither16 (dither, gc, gcd, &c1, i);
- }
- gdk_draw_line (window, gc, x, y + i, x + width, y + i);
- c1.red -= rd;
- c1.blue -= bd;
- c1.green -= gd;
- i++;
- }
-
- /*** Second Gradient ***/
-
- rd = (c3.red - c4.red) / MAX (height / 2, 1);
- gd = (c3.green - c4.green) / MAX (height / 2, 1);
- bd = (c3.blue - c4.blue) / MAX (height / 2, 1);
-
- i = height / 2;
- while (i < height)
- {
- if (depth == 16) {
- moko_dither16 (dither, gc, gcd, &c3, i);
- }
- gdk_gc_set_rgb_fg_color (gc, &c3);
- gdk_draw_line (window, gc, x, y + i, x + width, y + i);
- c3.red -= rd;
- c3.blue -= bd;
- c3.green -= gd;
- i++;
- }
-
- g_object_unref (gc);
-
- if (depth == 16) {
- g_object_unref (gcd);
- g_object_unref (dither);
- }
-
-}
-
-static void
moko_draw_box (DRAW_ARGS)
{
GdkGC *gc;
@@ -188,77 +54,28 @@
x -= 10;
}
- /*** combo boxes ***/
- if (DETAIL ("button") && widget && GTK_IS_COMBO_BOX_ENTRY (widget->parent))
- {
- GtkWidget *entry;
-
- entry = g_object_get_data (G_OBJECT (widget->parent), "moko-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);
-
- }
-
- g_object_set_data (G_OBJECT (widget->parent), "moko-combo-button", widget);
-
- /* FIXME: RTL */
- width += 10;
- x -= 10;
- }
-
- gc = moko_gc_new (style->text_gc[state_type], window);
-
-
/* "fix" for prelight active toggle buttons */
if (DETAIL ("button") && state_type == GTK_STATE_PRELIGHT && shadow_type == GTK_SHADOW_IN)
{
state_type = GTK_STATE_ACTIVE;
}
- /*** draw the gradient ***/
- if (MOKO_RC_STYLE (style->rc_style)->has_gradient)
- {
- moko_gradient (style, window, state_type, x, y, width, height);
- }
- else
- {
- gtk_paint_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
- }
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);
+ gc = style->base_gc[state_type];
+ else if (DETAIL ("bar"))
+ gc = style->base_gc[GTK_STATE_SELECTED];
+ else
+ gc = style->bg_gc[state_type];
- }
+ gdk_draw_rectangle (window, gc, TRUE, x, y, width, height);
- /*** draw the border ***/
- if (MOKO_RC_STYLE (style->rc_style)->has_border)
- {
- gdk_draw_rectangle (window, gc, FALSE, x + 1, y + 1, width - 2, height - 2);
- }
-
-exit:
- g_object_unref (gc);
-
}
static void
moko_draw_shadow (DRAW_ARGS)
{
- GdkGC *gc;
-
+ GdkGC* gc;
DEBUG ("draw_shadow");
if (shadow_type == GTK_SHADOW_NONE)
@@ -266,26 +83,16 @@
SANITIZE_SIZE;
- /* FIXME: for RTL */
- if (widget && (GTK_IS_SPIN_BUTTON (widget) || GTK_IS_COMBO_BOX_ENTRY (widget->parent)))
- width += 10;
+ gc = gdk_gc_new (window);
- if (widget && GTK_IS_COMBO_BOX_ENTRY (widget->parent))
- {
- GtkWidget *button;
- g_object_set_data (G_OBJECT (widget->parent), "moko-combo-entry", widget);
-
- button = g_object_get_data (G_OBJECT (widget->parent), "moko-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);
- }
-
/* draw a hilight shadow on focused widgets (i.e. entry widgets) */
if (widget && GTK_WIDGET_HAS_FOCUS (widget))
- gc = moko_gc_new (style->base_gc[GTK_STATE_SELECTED], window);
+ gdk_gc_copy (gc, style->base_gc[GTK_STATE_SELECTED]);
else
- gc = moko_gc_new (style->text_gc[state_type], window);
+ gdk_gc_copy (gc, style->base_gc[state_type]);
+ gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
+
gdk_draw_rectangle (window, gc, FALSE, x + 1, y + 1, width - 2, height - 2);
g_object_unref (gc);
@@ -296,16 +103,9 @@
GdkRectangle *area, GtkWidget *widget, const gchar *detail,
gint x, gint y, gint width, gint height)
{
- GdkGC *gc;
DEBUG ("draw_focus");
/* no focus indicator for the moment ... */
- return;
-/*
- gc = moko_gc_new (style->fg_gc[GTK_STATE_SELECTED], window);
- gdk_draw_rectangle (window, gc, FALSE, x, y, width, height);
- g_object_unref (gc);
-*/
}
static void
@@ -315,25 +115,22 @@
const gchar * detail, gint x, gint y, gint width,
gint height)
{
- GdkGC *gc;
+ GdkGC *gc, *border;
- DEBUG ("draw_check");
- gc = moko_gc_new (style->text_gc[state_type], window);
+ if (state_type == GTK_STATE_PRELIGHT)
+ state_type = GTK_STATE_NORMAL;
- /* clear the background */
- gdk_draw_rectangle (window, style->base_gc[GTK_STATE_NORMAL], TRUE, x+1, y+1, width-2, height-2);
-
if (shadow_type == GTK_SHADOW_IN)
- {
- GdkGC *mark_gc;
- mark_gc = moko_gc_new (style->base_gc[GTK_STATE_SELECTED], window);
- gdk_draw_rectangle (window, mark_gc, TRUE, x + 3, y + 3, width - 6, height - 6);
- g_object_unref (mark_gc);
- }
+ gc = style->base_gc[GTK_STATE_SELECTED];
+ else
+ gc = style->base_gc[state_type];
- gdk_draw_rectangle (window, gc, FALSE, x, y, width, height);
+ gdk_draw_rectangle (window, style->black_gc, TRUE,
+ x, y, width, height);
- g_object_unref (gc);
+ gdk_draw_rectangle (window, gc, TRUE,
+ x + 2, y + 2, width - 4, height - 4);
+
}
static void
@@ -343,26 +140,23 @@
const gchar * detail, gint x, gint y, gint width,
gint height)
{
- GdkGC *gc;
-
DEBUG ("draw_option");
- gc = moko_gc_new (style->text_gc[state_type], window);
+ GdkGC *gc;
+ if (state_type == GTK_STATE_PRELIGHT)
+ state_type = GTK_STATE_NORMAL;
+ if (shadow_type == GTK_SHADOW_IN)
+ gc = style->base_gc[GTK_STATE_SELECTED];
+ else
+ gc = style->base_gc[state_type];
- /* clear the background */
- 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, style->black_gc, TRUE,
+ x, y, width, height, 0, 360 * 64);
- if (shadow_type == GTK_SHADOW_IN)
- {
- GdkGC *mark_gc;
- mark_gc = moko_gc_new (style->base_gc[GTK_STATE_SELECTED], window);
- gdk_draw_arc (window, mark_gc, TRUE, x + 3, y + 3, width - 6, height - 6, 0, 360 * 64);
- g_object_unref (mark_gc);
- }
- gdk_draw_arc (window, gc, FALSE, x, y, width, height, 0, 360 * 64);
+ gdk_draw_arc (window, gc, TRUE,
+ x + 2, y + 2, width - 4, height - 4, 0, 360 * 64);
- g_object_unref (gc);
}
static void
@@ -372,57 +166,7 @@
gint x, gint y, gint width, gint height,
GtkPositionType gap_side, gint gap_x, gint gap_width)
{
- GdkGC *gc;
- GdkRectangle rect;
-
- /* lets try without a border */
- return;
-
- if (shadow_type == GTK_SHADOW_NONE)
- return;
-
- gc = moko_gc_new (style->fg_gc [state_type], window);
-
- /* start off with a rectangle... */
- gdk_draw_rectangle (window, gc, FALSE, x, y, width, height);
-
-
- switch (gap_side)
- {
- case GTK_POS_TOP:
-
- rect.x = x + gap_x;
- rect.y = y;
- rect.width = gap_width;
- rect.height = 2;
- break;
- case GTK_POS_BOTTOM:
- rect.x = x + gap_x;
- rect.y = y + height - 1;
- rect.width = gap_width;
- rect.height = 2;
- break;
- case GTK_POS_LEFT:
- rect.x = x;
- rect.y = y + gap_x;
- rect.width = 2;
- rect.height = gap_width;
- break;
- case GTK_POS_RIGHT:
- rect.x = x + width - 2;
- rect.y = y + gap_x;
- rect.width = 2;
- rect.height = gap_width;
- break;
- }
-
- /* and finally blank out the gap */
- gtk_style_apply_default_background (style, window, TRUE, state_type, area,
- rect.x, rect.y, rect.width,
- rect.height);
-
-
- g_object_unref (gc);
+ gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x, y, width, height);
}
@@ -433,19 +177,7 @@
gint x, gint y, gint width, gint height,
GtkPositionType gap_side)
{
-
- GdkGC *gc;
- gc = moko_gc_new (style->bg_gc[state_type], window);
-
- /* NORMAL is used for "active" tabs */
- if (state_type == GTK_STATE_NORMAL)
- moko_gradient (style, window, state_type, x, y, width, height);
- else
- gdk_draw_rectangle (window, gc, TRUE, x, y, width, height);
-
-
- g_object_unref (gc);
-
+ gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x, y, width, height);
}
void
More information about the commitlog
mailing list