Ticket #648: color.patch2

File color.patch2, 3.7 KB (added by chr, 11 years ago)

change color selection of the odometer and the stopwatch

Line 
1Index: navit/attr_def.h
2===================================================================
3--- navit/attr_def.h    (revision 3562)
4+++ navit/attr_def.h    (working copy)
5@@ -341,6 +341,7 @@
6 ATTR(color2)
7 ATTR(background_color)
8 ATTR(text_color)
9+ATTR(idle_color)
10 ATTR(background_color2)
11 ATTR2(0x0007ffff,type_color_end)
12 ATTR2(0x00080000,type_object_begin)
13Index: navit/osd/core/osd_core.c
14===================================================================
15--- navit/osd/core/osd_core.c   (revision 3562)
16+++ navit/osd/core/osd_core.c   (working copy)
17@@ -171,6 +171,7 @@
18        struct graphics_gc *white;
19        struct callback *click_cb;
20        char *text;                 //text of label attribute for this osd
21+       struct color idle_color;    //text color when counter is idle
22 
23        int bActive;                //counting or not
24        double sum_dist;            //sum of distance ofprevious intervals in meters
25@@ -301,24 +302,14 @@
26 static void
27 osd_odometer_init(struct odometer *this, struct navit *nav)
28 {
29-       struct color c;
30-
31        osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
32 
33        this->orange = graphics_gc_new(this->osd_item.gr);
34-       c.r = 0xFFFF;
35-       c.g = 0xA5A5;
36-       c.b = 0x0000;
37-       c.a = 65535;
38-       graphics_gc_set_foreground(this->orange, &c);
39+       graphics_gc_set_foreground(this->orange, &this->idle_color);
40        graphics_gc_set_linewidth(this->orange, this->width);
41 
42        this->white = graphics_gc_new(this->osd_item.gr);
43-       c.r = 65535;
44-       c.g = 65535;
45-       c.b = 65535;
46-       c.a = 65535;
47-       graphics_gc_set_foreground(this->white, &c);
48+       graphics_gc_set_foreground(this->white, &this->osd_item.text_color);
49        graphics_gc_set_linewidth(this->white, this->width);
50 
51        graphics_gc_set_linewidth(this->osd_item.graphic_fg_white, this->width);
52@@ -364,10 +355,11 @@
53                this->text = NULL;
54 
55 
56-
57        osd_set_std_attr(attrs, &this->osd_item, 2);
58        attr = attr_search(attrs, NULL, attr_width);
59        this->width=attr ? attr->u.num : 2;
60+       attr = attr_search(attrs, NULL, attr_idle_color);
61+       this->idle_color=attr ? *attr->u.color : ((struct color) {0xffff,0xa5a5,0x0000,0xffff}); // text idle_color defaults to orange
62        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_init), attr_graphics_ready, this));
63        return (struct osd_priv *) this;
64 }
65@@ -380,6 +372,7 @@
66        int width;
67        struct graphics_gc *orange,*white;
68        struct callback *click_cb;
69+       struct color idle_color;    //text color when counter is idle
70 
71        int bActive;                //counting or not
72        time_t current_base_time;   //base time of currently measured time interval
73@@ -459,25 +452,14 @@
74 static void
75 osd_stopwatch_init(struct stopwatch *this, struct navit *nav)
76 {
77-
78-       struct color c;
79-
80        osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
81 
82        this->orange = graphics_gc_new(this->osd_item.gr);
83-       c.r = 0xFFFF;
84-       c.g = 0xA5A5;
85-       c.b = 0x0000;
86-       c.a = 65535;
87-       graphics_gc_set_foreground(this->orange, &c);
88+       graphics_gc_set_foreground(this->orange, &this->idle_color);
89        graphics_gc_set_linewidth(this->orange, this->width);
90 
91        this->white = graphics_gc_new(this->osd_item.gr);
92-       c.r = 65535;
93-       c.g = 65535;
94-       c.b = 65535;
95-       c.a = 65535;
96-       graphics_gc_set_foreground(this->white, &c);
97+       graphics_gc_set_foreground(this->white, &this->osd_item.text_color);
98        graphics_gc_set_linewidth(this->white, this->width);
99 
100 
101@@ -512,6 +494,8 @@
102        osd_set_std_attr(attrs, &this->osd_item, 2);
103        attr = attr_search(attrs, NULL, attr_width);
104        this->width=attr ? attr->u.num : 2;
105+       attr = attr_search(attrs, NULL, attr_idle_color);
106+       this->idle_color=attr ? *attr->u.color : ((struct color) {0xffff,0xa5a5,0x0000,0xffff}); // text idle_color defaults to orange
107        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_stopwatch_init), attr_graphics_ready, this));
108        return (struct osd_priv *) this;
109 }