Changeset 4305
- Timestamp:
- 04/03/08 15:46:31 (5 years ago)
- Location:
- trunk/src/target/OM-2007.2/libraries/moko-gtk-engine
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
data/gtk-2.0/gtkrc (modified) (8 diffs)
-
data/gtk-2.0/openmoko-dialer (modified) (1 diff)
-
src/moko-draw.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/ChangeLog
r3612 r4305 1 2008-04-03 Thomas Wood <thomas@openedhand.com> 2 3 * src/moko-draw.c: 4 * data/gtk-2.0/gtkrc: 5 * data/gtk-2.0/openmoko-dialer: 6 7 Completely redesign the visual style, with emphasis on simplicity and 8 speed. 9 1 10 2007-12-07 Thomas Wood <thomas@openedhand.com> 2 11 -
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/gtkrc
r3611 r4305 2 2 # 3 3 # Copyright 2007 OpenedHand Ltd <info@openedhand.com> 4 # Based on OpenedHand's Sato GTK+ Theme4 # Originally based on OpenedHand's Sato GTK+ Theme 5 5 # 6 6 # This theme uses several style properties introduced in GTK+ 2.10 … … 15 15 16 16 # Set the default gtk-color-scheme property 17 gtk_color_scheme = "fg_color:# 000;bg_color:#f4f0f4;base_color:#fff;text_color:#000;selected_bg_color:#ff7d00;selected_fg_color:#000"17 gtk_color_scheme = "fg_color:#fff;bg_color:#333;base_color:#fff;text_color:#000;selected_bg_color:#ff7d00;selected_fg_color:#000" 18 18 19 19 style "default" … … 25 25 GtkButton::default_border = {0, 0, 0, 0} 26 26 GtkButton::focus-line-width = 0 27 GtkButton::inner_border = {10, 10, 10, 10} 27 28 GtkCheckButton::indicator-size = 35 28 29 GtkCheckButton::indicator-spacing = 5 … … 79 80 80 81 engine "moko-engine" { 81 border = TRUE82 82 } 83 83 } 84 85 84 class "GtkWidget" style "default" 86 87 style "reversed"88 {89 bg[NORMAL] = @fg_color90 fg[NORMAL] = @bg_color91 92 bg[PRELIGHT] = @fg_color93 fg[PRELIGHT] = @bg_color94 }95 widget_class "*GtkButton*" style "reversed"96 85 97 86 style "button" 98 87 { 99 GtkButton::inner_border = {15, 15, 10, 10} 100 engine "moko-engine" { 101 border = TRUE 102 gradient = TRUE 103 } 88 bg[NORMAL] = lighter (@bg_color) 89 bg[PRELIGHT] = lighter (@bg_color) 104 90 } 105 91 class "GtkButton" style "button" 106 92 107 style "button-colors" { 108 bg[NORMAL] = "#333" 109 fg[NORMAL] = "#fff" 93 style "button-with-indicator" 94 { 95 bg[NORMAL] = @bg_color 96 fg[NORMAL] = @fg_color 110 97 111 bg[PRELIGHT] = "#333" 112 fg[PRELIGHT] = "#fff" 98 bg[ACTIVE] = @bg_color 99 fg[ACTIVE] = @fg_color 100 101 bg[PRELIGHT] = @bg_color 102 fg[PRELIGHT] = @fg_color 113 103 } 114 widget_class "GtkButton*" style "button-colors" 115 116 style "treeview-header" { 117 118 # inner-border was added in GTK+ 2.10 119 GtkButton::inner_border = {0, 0, 0, 0} 120 121 bg[NORMAL] = "#eee" 122 fg[NORMAL] = "#000" 123 124 bg[PRELIGHT] = "#eee" 125 fg[PRELIGHT] = "#000" 126 127 engine "moko-engine" { 128 border = FALSE 129 gradient = TRUE 130 } 131 } 132 widget_class "*GtkTreeView.GtkButton*" style "treeview-header" 104 widget_class "*.GtkCheckButton.*" style "button-with-indicator" 105 widget_class "*.GtkRadioButton.*" style "button-with-indicator" 133 106 134 107 style "combo" { 135 108 bg[NORMAL] = @selected_bg_color 109 fg[NORMAL] = @selected_fg_color 136 110 text[NORMAL] = @selected_fg_color 137 111 138 112 bg[PRELIGHT] = @selected_bg_color 139 113 text[PRELIGHT] = @selected_fg_color 140 141 engine "moko-engine" {142 gradient = TRUE143 }144 114 } 145 115 widget_class "*Combo*" style "combo" … … 150 120 xthickness = 0 151 121 ythickness = 0 152 153 engine "moko-engine" {154 gradient = TRUE155 border = FALSE156 }157 122 } 158 123 class "GtkToolbar" style "toolbar" 159 class "GtkToolbar" style "reversed"160 161 style "toolitem"162 {163 xthickness = 12164 ythickness = 12165 166 bg[NORMAL] = @selected_bg_color167 fg[NORMAL] = @selected_fg_color168 169 # toolbar colours are reversed170 bg[PRELIGHT] = @fg_color171 fg[PRELIGHT] = @bg_color172 173 engine "moko-engine" {174 gradient = TRUE175 border = FALSE176 }177 }178 widget_class "*Tool*GtkToggleButton" style "toolitem"179 widget_class "*Tool*GtkButton" style "toolitem"180 181 124 style "notebook" 182 125 { … … 186 129 # For notebookes, NORMAL is used for the active tab and ACTIVE is used for 187 130 # ther other tabs 188 bg[NORMAL] = @selected_bg_color 189 fg[NORMAL] = @selected_fg_color 190 191 # inactive tabs are in "reversed" colours 192 fg[ACTIVE] = @bg_color 193 bg[ACTIVE] = @fg_color 131 fg[ACTIVE] = @fg_color 132 bg[ACTIVE] = shade (0.3, @bg_color) 194 133 } 195 class "GtkNotebook" style "notebook" 196 197 style "menu" 198 { 199 engine "moko-engine" { 200 gradient = FALSE 201 border = TRUE 202 } 203 } 204 class "GtkMenu" style "menu" 205 206 style "menubar" 207 { 208 engine "moko-engine" { 209 gradient = TRUE 210 } 211 } 212 class "GtkMenuBar" style "menubar" 213 widget_class "*GtkMenuBar*" style "reversed" 134 widget_class "*GtkNotebook" style "notebook" 214 135 215 136 style "menuitem" … … 218 139 ythickness = 8 219 140 141 text[NORMAL] = @fg_color 142 text[PRELIGHT] = @selected_fg_color 143 220 144 bg[PRELIGHT] = @selected_bg_color 221 145 fg[PRELIGHT] = @selected_fg_color 222 223 engine "moko-engine" {224 gradient = TRUE225 border = FALSE226 }227 146 } 228 147 widget_class "*MenuItem*" style "menuitem" 148 widget "GtkWindow.gtk-combobox-popup-menu" style "menuitem" 229 149 230 150 style "scrollbar" … … 232 152 bg[NORMAL] = @selected_bg_color 233 153 bg[PRELIGHT] = @selected_bg_color 234 235 engine "moko-engine" {236 border = TRUE237 }238 154 } 239 155 class "GtkScrollbar" style "scrollbar" 156 157 style "mokosearchbutton" 158 { 159 bg[NORMAL] = "#C0C0C0" 160 } 161 widget "*.mokosearchbutton" style "mokosearchbutton" 240 162 241 163 include "matchboxpanel" -
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/data/gtk-2.0/openmoko-dialer
r3399 r4305 13 13 widget "*.MokoTips*" style "mokodialertextview" 14 14 15 widget_class "*MokoDigitButton*" style "reversed" # defined in the main gtkrc16 -
trunk/src/target/OM-2007.2/libraries/moko-gtk-engine/src/moko-draw.c
r3612 r4305 35 35 36 36 GtkStyleClass *parent_style_class; 37 38 /**39 * Prepare a new GC with the additional Moko style values40 */41 static GdkGC*42 moko_gc_new (GdkGC* old_gc, GdkDrawable *d)43 {44 GdkGC *new_gc;45 new_gc = gdk_gc_new (d);46 gdk_gc_copy (new_gc, old_gc);47 gdk_gc_set_line_attributes (new_gc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);48 return new_gc;49 }50 51 /*52 * moko_dither16:53 * @dither: An 18x1, 1-bit pixmap54 * @gc: The gc that needs to be dithered55 * @gcd: A gc for @dither56 * @c1: The intended colour57 * @i: Any random number58 *59 * Calculates and sets the dither colour and pattern for a 16-bit drawable,60 * given a 32-bit colour.61 */62 static void63 moko_dither16 (GdkPixmap *dither, GdkGC *gc, GdkGC *gcd, GdkColor *c1, gint i)64 {65 gint sum, x;66 GdkColor c1d;67 /* Assuming 565, so see how much of the colour is ignored and use that68 * to decide on the dithering colour/pattern.69 */70 c1d.red = c1->red & 0x700;71 c1d.green = c1->green & 0x300;72 c1d.blue = c1->blue & 0x700;73 74 sum = (c1d.red + c1d.green + c1d.blue) >> 8;75 gdk_gc_set_function (gcd, GDK_SET);76 gdk_draw_line (dither, gcd, 0, 0, 17, 0);77 gdk_gc_set_function (gcd, GDK_CLEAR);78 for (x = 0; x < sum; x ++) {79 gdk_draw_point (dither, gcd, ((x+(i<<3)) * 11) % 18, 0);80 }81 82 c1d.red = c1->red + 0x800;83 c1d.green = c1->green + 0x400;84 c1d.blue = c1->blue + 0x800;85 if (c1d.red < c1->red) c1d.red = 0xFF00;86 if (c1d.green < c1->green) c1d.green = 0xFF00;87 if (c1d.blue < c1->blue) c1d.blue = 0xFF00;88 gdk_gc_set_rgb_bg_color (gc, &c1d);89 90 gdk_gc_set_fill (gc, GDK_OPAQUE_STIPPLED);91 gdk_gc_set_stipple (gc, dither);92 }93 94 static void95 moko_gradient (GtkStyle * style, GdkWindow * window, GtkStateType state_type,96 gint x, gint y, gint width, gint height)97 {98 gint i, rd, gd, bd, depth; /* rd, gd, bd - change in r g and b for gradient */99 GdkColor c1, c2, c3, c4, c1d, c3d;100 GdkPixmap *dither;101 GdkGC *gc, *gcd;102 gc = gdk_gc_new (window);103 104 /* get the start and end colours */105 moko_shade_colour (&style->bg[state_type], &c1, 0.8);106 moko_shade_colour (&style->bg[state_type], &c2, 0.4);107 moko_shade_colour (&style->bg[state_type], &c3, 0.3);108 moko_shade_colour (&style->bg[state_type], &c4, 0.0);109 110 /* set line for 1px */111 gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID, GDK_CAP_BUTT,112 GDK_JOIN_MITER);113 114 /* Get the drawable pixel depth, for dithering */115 depth = gdk_drawable_get_depth (window);116 if (depth == 16) {117 dither = gdk_pixmap_new (NULL, 18, 1, 1);118 gcd = gdk_gc_new (dither);119 }120 121 /*** First Gradient ***/122 /* calculate the delta values */123 124 rd = (c1.red - c2.red) / MAX (height / 2, 1);125 gd = (c1.green - c2.green) / MAX (height / 2, 1);126 bd = (c1.blue - c2.blue) / MAX (height / 2, 1);127 128 i = 0;129 while (i < height / 2)130 {131 gdk_gc_set_rgb_fg_color (gc, &c1);132 /* TODO: Handle 15-bit colour */133 if (depth == 16) {134 moko_dither16 (dither, gc, gcd, &c1, i);135 }136 gdk_draw_line (window, gc, x, y + i, x + width, y + i);137 c1.red -= rd;138 c1.blue -= bd;139 c1.green -= gd;140 i++;141 }142 143 /*** Second Gradient ***/144 145 rd = (c3.red - c4.red) / MAX (height / 2, 1);146 gd = (c3.green - c4.green) / MAX (height / 2, 1);147 bd = (c3.blue - c4.blue) / MAX (height / 2, 1);148 149 i = height / 2;150 while (i < height)151 {152 if (depth == 16) {153 moko_dither16 (dither, gc, gcd, &c3, i);154 }155 gdk_gc_set_rgb_fg_color (gc, &c3);156 gdk_draw_line (window, gc, x, y + i, x + width, y + i);157 c3.red -= rd;158 c3.blue -= bd;159 c3.green -= gd;160 i++;161 }162 163 g_object_unref (gc);164 165 if (depth == 16) {166 g_object_unref (gcd);167 g_object_unref (dither);168 }169 170 }171 37 172 38 static void … … 189 55 } 190 56 191 /*** combo boxes ***/192 if (DETAIL ("button") && widget && GTK_IS_COMBO_BOX_ENTRY (widget->parent))193 {194 GtkWidget *entry;195 196 entry = g_object_get_data (G_OBJECT (widget->parent), "moko-combo-entry");197 if (GTK_IS_ENTRY (entry))198 {199 gtk_widget_queue_draw_area (entry, entry->allocation.x, entry->allocation.y, entry->allocation.width,entry->allocation.height);200 201 }202 203 g_object_set_data (G_OBJECT (widget->parent), "moko-combo-button", widget);204 205 /* FIXME: RTL */206 width += 10;207 x -= 10;208 }209 210 gc = moko_gc_new (style->text_gc[state_type], window);211 212 213 57 /* "fix" for prelight active toggle buttons */ 214 58 if (DETAIL ("button") && state_type == GTK_STATE_PRELIGHT && shadow_type == GTK_SHADOW_IN) … … 217 61 } 218 62 219 /*** draw the gradient ***/220 if (MOKO_RC_STYLE (style->rc_style)->has_gradient)221 {222 moko_gradient (style, window, state_type, x, y, width, height);223 }224 else225 {226 gtk_paint_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);227 }228 63 229 64 if (DETAIL ("trough")) 230 { 231 if (widget && GTK_IS_HSCALE (widget)) 232 { 233 gdk_draw_line (window, gc, x, y + height / 2, x + width, y + height / 2); 234 goto exit; 235 } 236 else if (widget && GTK_IS_VSCALE (widget)) 237 { 238 gdk_draw_line (window, gc, x + width / 2, y, x + width / 2, y + height); 239 goto exit; 240 } 241 else 242 gdk_draw_rectangle (window, style->base_gc[state_type], TRUE, x, y, width, height); 243 244 } 245 246 /*** draw the border ***/ 247 if (MOKO_RC_STYLE (style->rc_style)->has_border) 248 { 249 gdk_draw_rectangle (window, gc, FALSE, x + 1, y + 1, width - 2, height - 2); 250 } 251 252 exit: 253 g_object_unref (gc); 65 gc = style->base_gc[state_type]; 66 else if (DETAIL ("bar")) 67 gc = style->base_gc[GTK_STATE_SELECTED]; 68 else 69 gc = style->bg_gc[state_type]; 70 71 gdk_draw_rectangle (window, gc, TRUE, x, y, width, height); 254 72 255 73 } … … 258 76 moko_draw_shadow (DRAW_ARGS) 259 77 { 260 GdkGC *gc; 261 78 GdkGC* gc; 262 79 DEBUG ("draw_shadow"); 263 80 … … 267 84 SANITIZE_SIZE; 268 85 269 /* FIXME: for RTL */ 270 if (widget && (GTK_IS_SPIN_BUTTON (widget) || GTK_IS_COMBO_BOX_ENTRY (widget->parent))) 271 width += 10; 272 273 if (widget && GTK_IS_COMBO_BOX_ENTRY (widget->parent)) 274 { 275 GtkWidget *button; 276 g_object_set_data (G_OBJECT (widget->parent), "moko-combo-entry", widget); 277 278 button = g_object_get_data (G_OBJECT (widget->parent), "moko-combo-button"); 279 if (GTK_IS_BUTTON (button)) 280 gtk_widget_queue_draw_area (button, button->allocation.x, button->allocation.y, button->allocation.width,button->allocation.height); 281 } 86 gc = gdk_gc_new (window); 282 87 283 88 /* draw a hilight shadow on focused widgets (i.e. entry widgets) */ 284 89 if (widget && GTK_WIDGET_HAS_FOCUS (widget)) 285 gc = moko_gc_new (style->base_gc[GTK_STATE_SELECTED], window); 286 else 287 gc = moko_gc_new (style->text_gc[state_type], window); 90 gdk_gc_copy (gc, style->base_gc[GTK_STATE_SELECTED]); 91 else 92 gdk_gc_copy (gc, style->base_gc[state_type]); 93 94 gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); 288 95 289 96 gdk_draw_rectangle (window, gc, FALSE, x + 1, y + 1, width - 2, height - 2); … … 297 104 gint x, gint y, gint width, gint height) 298 105 { 299 GdkGC *gc;300 106 DEBUG ("draw_focus"); 301 107 302 108 /* no focus indicator for the moment ... */ 303 return;304 /*305 gc = moko_gc_new (style->fg_gc[GTK_STATE_SELECTED], window);306 gdk_draw_rectangle (window, gc, FALSE, x, y, width, height);307 g_object_unref (gc);308 */309 109 } 310 110 … … 316 116 gint height) 317 117 { 318 GdkGC *gc; 319 320 DEBUG ("draw_check"); 321 gc = moko_gc_new (style->text_gc[state_type], window); 322 323 /* clear the background */ 324 gdk_draw_rectangle (window, style->base_gc[GTK_STATE_NORMAL], TRUE, x+1, y+1, width-2, height-2); 118 GdkGC *gc, *border; 119 120 if (state_type == GTK_STATE_PRELIGHT) 121 state_type = GTK_STATE_NORMAL; 325 122 326 123 if (shadow_type == GTK_SHADOW_IN) 327 {328 GdkGC *mark_gc;329 mark_gc = moko_gc_new (style->base_gc[GTK_STATE_SELECTED], window);330 gdk_draw_rectangle (window, mark_gc, TRUE, x + 3, y + 3, width - 6, height - 6); 331 g_object_unref (mark_gc);332 }333 334 gdk_draw_rectangle (window, gc, FALSE, x, y, width, height);335 336 g_object_unref (gc); 124 gc = style->base_gc[GTK_STATE_SELECTED]; 125 else 126 gc = style->base_gc[state_type]; 127 128 gdk_draw_rectangle (window, style->black_gc, TRUE, 129 x, y, width, height); 130 131 gdk_draw_rectangle (window, gc, TRUE, 132 x + 2, y + 2, width - 4, height - 4); 133 337 134 } 338 135 … … 344 141 gint height) 345 142 { 143 DEBUG ("draw_option"); 144 346 145 GdkGC *gc; 347 348 DEBUG ("draw_option"); 349 350 gc = moko_gc_new (style->text_gc[state_type], window); 351 352 353 /* clear the background */ 354 gdk_draw_arc (window, style->base_gc[GTK_STATE_NORMAL], TRUE, x+1, y+1, width-2, height-2, 0, 360 * 64); 355 146 if (state_type == GTK_STATE_PRELIGHT) 147 state_type = GTK_STATE_NORMAL; 356 148 if (shadow_type == GTK_SHADOW_IN) 357 { 358 GdkGC *mark_gc; 359 mark_gc = moko_gc_new (style->base_gc[GTK_STATE_SELECTED], window); 360 gdk_draw_arc (window, mark_gc, TRUE, x + 3, y + 3, width - 6, height - 6, 0, 360 * 64); 361 g_object_unref (mark_gc); 362 } 363 gdk_draw_arc (window, gc, FALSE, x, y, width, height, 0, 360 * 64); 364 365 g_object_unref (gc); 149 gc = style->base_gc[GTK_STATE_SELECTED]; 150 else 151 gc = style->base_gc[state_type]; 152 153 154 gdk_draw_arc (window, style->black_gc, TRUE, 155 x, y, width, height, 0, 360 * 64); 156 157 gdk_draw_arc (window, gc, TRUE, 158 x + 2, y + 2, width - 4, height - 4, 0, 360 * 64); 159 366 160 } 367 161 … … 373 167 GtkPositionType gap_side, gint gap_x, gint gap_width) 374 168 { 375 GdkGC *gc; 376 GdkRectangle rect; 377 378 /* lets try without a border */ 379 return; 380 381 if (shadow_type == GTK_SHADOW_NONE) 382 return; 383 384 gc = moko_gc_new (style->fg_gc [state_type], window); 385 386 /* start off with a rectangle... */ 387 gdk_draw_rectangle (window, gc, FALSE, x, y, width, height); 388 389 390 switch (gap_side) 391 { 392 case GTK_POS_TOP: 393 394 rect.x = x + gap_x; 395 rect.y = y; 396 rect.width = gap_width; 397 rect.height = 2; 398 break; 399 case GTK_POS_BOTTOM: 400 rect.x = x + gap_x; 401 rect.y = y + height - 1; 402 rect.width = gap_width; 403 rect.height = 2; 404 break; 405 case GTK_POS_LEFT: 406 rect.x = x; 407 rect.y = y + gap_x; 408 rect.width = 2; 409 rect.height = gap_width; 410 break; 411 case GTK_POS_RIGHT: 412 rect.x = x + width - 2; 413 rect.y = y + gap_x; 414 rect.width = 2; 415 rect.height = gap_width; 416 break; 417 } 418 419 /* and finally blank out the gap */ 420 gtk_style_apply_default_background (style, window, TRUE, state_type, area, 421 rect.x, rect.y, rect.width, 422 rect.height); 423 424 425 g_object_unref (gc); 169 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x, y, width, height); 426 170 } 427 171 … … 434 178 GtkPositionType gap_side) 435 179 { 436 437 GdkGC *gc; 438 gc = moko_gc_new (style->bg_gc[state_type], window); 439 440 /* NORMAL is used for "active" tabs */ 441 if (state_type == GTK_STATE_NORMAL) 442 moko_gradient (style, window, state_type, x, y, width, height); 443 else 444 gdk_draw_rectangle (window, gc, TRUE, x, y, width, height); 445 446 447 g_object_unref (gc); 448 180 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x, y, width, height); 449 181 } 450 182
Note: See TracChangeset
for help on using the changeset viewer.
