Merge lp:~canonical-dx-team/unity/unity.fix-684048 into lp:unity

Proposed by Mirco Müller
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 688
Proposed branch: lp:~canonical-dx-team/unity/unity.fix-684048
Merge into: lp:unity
Diff against target: 173 lines (+52/-31)
2 files modified
src/QuicklistMenuItemRadio.cpp (+50/-20)
src/QuicklistMenuItemRadio.h (+2/-11)
To merge this branch: bzr merge lp:~canonical-dx-team/unity/unity.fix-684048
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+42968@code.launchpad.net

Description of the change

Fixed drawing of broken ql-radio-item rendering by removing obsolete local member-variables shadowing member-variables of parent-class. Also see http://launchpadlibrarian.net/60276932/fixed-ql-radio-item.png

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

Fixes the issue for me, code looks good, approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/QuicklistMenuItemRadio.cpp'
2--- src/QuicklistMenuItemRadio.cpp 2010-12-02 15:14:22 +0000
3+++ src/QuicklistMenuItemRadio.cpp 2010-12-07 16:25:07 +0000
4@@ -59,14 +59,9 @@
5 _item_type = MENUITEM_TYPE_LABEL;
6
7 if (item)
8- _text = dbusmenu_menuitem_property_get (item, DBUSMENU_MENUITEM_PROP_LABEL);
9+ _text = g_strdup (dbusmenu_menuitem_property_get (item, DBUSMENU_MENUITEM_PROP_LABEL));
10 else
11- _text = "QuicklistItem";
12-
13- _normalTexture[0] = NULL;
14- _normalTexture[1] = NULL;
15- _prelightTexture[0] = NULL;
16- _prelightTexture[1] = NULL;
17+ _text = g_strdup ("Radio Button");
18
19 int textWidth = 1;
20 int textHeight = 1;
21@@ -94,6 +89,15 @@
22 void
23 QuicklistMenuItemRadio::PreLayoutManagement ()
24 {
25+ _pre_layout_width = GetBaseWidth ();
26+ _pre_layout_height = GetBaseHeight ();
27+
28+ if (_normalTexture[0] == 0)
29+ {
30+ UpdateTexture ();
31+ }
32+
33+ QuicklistMenuItem::PreLayoutManagement ();
34 }
35
36 long
37@@ -137,7 +141,7 @@
38 bool forceDraw)
39 {
40 // Check if the texture have been computed. If they haven't, exit the function.
41- if (_normalTexture[0] == NULL)
42+ if (!_normalTexture[0])
43 return;
44
45 nux::IntrusiveSP<nux::IOpenGLBaseTexture> texture;
46@@ -154,16 +158,41 @@
47 GL_ONE,
48 GL_ONE_MINUS_SRC_ALPHA);
49
50- if (GetActive ())
51- if (GetEnabled ())
52+ if (GetEnabled ())
53+ {
54+ if (GetActive () && _prelight)
55+ {
56+ texture = _prelightTexture[0]->GetDeviceTexture ();
57+ }
58+ else if (GetActive ())
59+ {
60+ texture = _normalTexture[0]->GetDeviceTexture ();
61+ }
62+
63+ if ((!GetActive ()) && _prelight)
64+ {
65 texture = _prelightTexture[1]->GetDeviceTexture ();
66- else
67- texture = _prelightTexture[0]->GetDeviceTexture ();
68- else
69- if (GetEnabled ())
70+ }
71+ else if (!GetActive ())
72+ {
73 texture = _normalTexture[1]->GetDeviceTexture ();
74+ }
75+
76+ _color = nux::Color::White;
77+ }
78+ else
79+ {
80+ if (GetActive ())
81+ {
82+ texture = _prelightTexture[0]->GetDeviceTexture ();
83+ }
84 else
85+ {
86 texture = _normalTexture[0]->GetDeviceTexture ();
87+ }
88+
89+ _color = nux::Color::DarkGray;
90+ }
91
92 gfxContext.QRP_GLSL_1Tex (base.x,
93 base.y,
94@@ -193,8 +222,9 @@
95 void
96 QuicklistMenuItemRadio::UpdateTexture ()
97 {
98- int width = GetBaseWidth ();
99- int height = GetBaseHeight ();
100+ nux::Color transparent = nux::Color (0.0f, 0.0f, 0.0f, 0.0f);
101+ int width = GetBaseWidth ();
102+ int height = GetBaseHeight ();
103
104 _cairoGraphics = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, width, height);
105 cairo_t *cr = _cairoGraphics->GetContext ();
106@@ -208,7 +238,7 @@
107 cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
108 cairo_set_line_width (cr, 1.0f);
109
110- DrawText (cr, width, height, _textColor);
111+ DrawText (cr, width, height, nux::Color::White);
112
113 nux::NBitmapData* bitmap = _cairoGraphics->GetBitmap ();
114
115@@ -236,7 +266,7 @@
116 cairo_fill (cr);
117
118 cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
119- DrawText (cr, width, height, _textColor);
120+ DrawText (cr, width, height, nux::Color::White);
121
122 bitmap = _cairoGraphics->GetBitmap ();
123
124@@ -266,7 +296,7 @@
125
126 cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f);
127
128- DrawText (cr, width, height, _textColor);
129+ DrawText (cr, width, height, transparent);
130
131 bitmap = _cairoGraphics->GetBitmap ();
132
133@@ -299,7 +329,7 @@
134 cairo_arc (cr, x, y, radius, 0.0f * (G_PI / 180.0f), 360.0f * (G_PI / 180.0f));
135 cairo_fill (cr);
136
137- DrawText (cr, width, height, _textColor);
138+ DrawText (cr, width, height, transparent);
139
140 bitmap = _cairoGraphics->GetBitmap ();
141
142
143=== modified file 'src/QuicklistMenuItemRadio.h'
144--- src/QuicklistMenuItemRadio.h 2010-12-01 22:22:43 +0000
145+++ src/QuicklistMenuItemRadio.h 2010-12-07 16:25:07 +0000
146@@ -39,6 +39,7 @@
147
148 ~QuicklistMenuItemRadio ();
149
150+ protected:
151 void PreLayoutManagement ();
152
153 long PostLayoutManagement (long layoutResult);
154@@ -56,19 +57,9 @@
155 void PostDraw (nux::GraphicsEngine& gfxContext,
156 bool forceDraw);
157
158- private:
159- nux::NString _text;
160- nux::Color _textColor;
161- int _pre_layout_width;
162- int _pre_layout_height;
163- nux::CairoGraphics* _cairoGraphics;
164-
165- nux::BaseTexture* _normalTexture[2];
166- nux::BaseTexture* _prelightTexture[2];
167-
168 void Initialize (DbusmenuMenuitem* item);
169
170- void UpdateTexture ();
171+ virtual void UpdateTexture ();
172 virtual int CairoSurfaceWidth ();
173 };
174