Merge lp:~canonical-dx-team/unity/unity.quicklist-support into lp:unity
- unity.quicklist-support
- Merge into trunk
Proposed by
Jay Taoko
Status: | Merged |
---|---|
Merged at revision: | 610 |
Proposed branch: | lp:~canonical-dx-team/unity/unity.quicklist-support |
Merge into: | lp:unity |
Diff against target: |
2843 lines (+1510/-1015) 13 files modified
po/unity.pot (+1/-1) src/BamfLauncherIcon.cpp (+3/-0) src/Launcher.cpp (+21/-0) src/Launcher.h (+45/-32) src/LauncherIcon.cpp (+157/-10) src/LauncherIcon.h (+21/-3) src/QuicklistView.cpp (+1126/-883) src/QuicklistView.h (+89/-74) src/StaticCairoText.cpp (+2/-3) src/StaticCairoText.h (+1/-0) src/Tooltip.cpp (+39/-8) src/Tooltip.h (+2/-0) src/unity.cpp (+3/-1) |
To merge this branch: | bzr merge lp:~canonical-dx-team/unity/unity.quicklist-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil J. Patel (community) | Approve | ||
Review via email: mp+41125@code.launchpad.net |
Commit message
Description of the change
* Support for Quicklist
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'po/unity.pot' | |||
2 | --- po/unity.pot 2010-11-12 09:42:09 +0000 | |||
3 | +++ po/unity.pot 2010-11-18 14:03:47 +0000 | |||
4 | @@ -8,7 +8,7 @@ | |||
5 | 8 | msgstr "" | 8 | msgstr "" |
6 | 9 | "Project-Id-Version: PACKAGE VERSION\n" | 9 | "Project-Id-Version: PACKAGE VERSION\n" |
7 | 10 | "Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n" | 10 | "Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n" |
9 | 11 | "POT-Creation-Date: 2010-11-11 19:06+0000\n" | 11 | "POT-Creation-Date: 2010-11-15 11:43-0500\n" |
10 | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
11 | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
12 | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
13 | 15 | 15 | ||
14 | === modified file 'src/BamfLauncherIcon.cpp' | |||
15 | --- src/BamfLauncherIcon.cpp 2010-11-17 14:40:39 +0000 | |||
16 | +++ src/BamfLauncherIcon.cpp 2010-11-18 14:03:47 +0000 | |||
17 | @@ -67,6 +67,9 @@ | |||
18 | 67 | void | 67 | void |
19 | 68 | BamfLauncherIcon::OnMouseClick (int button) | 68 | BamfLauncherIcon::OnMouseClick (int button) |
20 | 69 | { | 69 | { |
21 | 70 | if (button != 1) | ||
22 | 71 | return; | ||
23 | 72 | |||
24 | 70 | BamfView *view; | 73 | BamfView *view; |
25 | 71 | GList *children, *l; | 74 | GList *children, *l; |
26 | 72 | bool active, running; | 75 | bool active, running; |
27 | 73 | 76 | ||
28 | === modified file 'src/Launcher.cpp' | |||
29 | --- src/Launcher.cpp 2010-11-17 18:02:14 +0000 | |||
30 | +++ src/Launcher.cpp 2010-11-18 14:03:47 +0000 | |||
31 | @@ -35,6 +35,7 @@ | |||
32 | 35 | #include "Launcher.h" | 35 | #include "Launcher.h" |
33 | 36 | #include "LauncherIcon.h" | 36 | #include "LauncherIcon.h" |
34 | 37 | #include "LauncherModel.h" | 37 | #include "LauncherModel.h" |
35 | 38 | #include "QuicklistView.h" | ||
36 | 38 | 39 | ||
37 | 39 | #define ANIM_DURATION_SHORT 125 | 40 | #define ANIM_DURATION_SHORT 125 |
38 | 40 | #define ANIM_DURATION 200 | 41 | #define ANIM_DURATION 200 |
39 | @@ -170,6 +171,8 @@ | |||
40 | 170 | , _model (0) | 171 | , _model (0) |
41 | 171 | { | 172 | { |
42 | 172 | _parent = parent; | 173 | _parent = parent; |
43 | 174 | _active_quicklist = 0; | ||
44 | 175 | |||
45 | 173 | m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION); | 176 | m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION); |
46 | 174 | 177 | ||
47 | 175 | OnMouseDown.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown)); | 178 | OnMouseDown.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown)); |
48 | @@ -1891,3 +1894,21 @@ | |||
49 | 1891 | // } | 1894 | // } |
50 | 1892 | // glEnd(); | 1895 | // glEnd(); |
51 | 1893 | } | 1896 | } |
52 | 1897 | |||
53 | 1898 | void Launcher::SetActiveQuicklist (QuicklistView *quicklist) | ||
54 | 1899 | { | ||
55 | 1900 | // Assert: _active_quicklist should be 0 | ||
56 | 1901 | _active_quicklist = quicklist; | ||
57 | 1902 | } | ||
58 | 1903 | |||
59 | 1904 | QuicklistView *Launcher::GetActiveQuicklist () | ||
60 | 1905 | { | ||
61 | 1906 | return _active_quicklist; | ||
62 | 1907 | } | ||
63 | 1908 | |||
64 | 1909 | void Launcher::CancelActiveQuicklist (QuicklistView *quicklist) | ||
65 | 1910 | { | ||
66 | 1911 | if (_active_quicklist == quicklist) | ||
67 | 1912 | _active_quicklist = 0; | ||
68 | 1913 | } | ||
69 | 1914 | |||
70 | 1894 | 1915 | ||
71 | === modified file 'src/Launcher.h' | |||
72 | --- src/Launcher.h 2010-11-16 00:56:20 +0000 | |||
73 | +++ src/Launcher.h 2010-11-18 14:03:47 +0000 | |||
74 | @@ -29,42 +29,51 @@ | |||
75 | 29 | #include "Nux/TimerProc.h" | 29 | #include "Nux/TimerProc.h" |
76 | 30 | 30 | ||
77 | 31 | class LauncherModel; | 31 | class LauncherModel; |
78 | 32 | class QuicklistView; | ||
79 | 32 | 33 | ||
80 | 33 | class Launcher : public nux::View | 34 | class Launcher : public nux::View |
81 | 34 | { | 35 | { |
82 | 35 | public: | 36 | public: |
115 | 36 | Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO); | 37 | Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO); |
116 | 37 | ~Launcher(); | 38 | ~Launcher(); |
117 | 38 | 39 | ||
118 | 39 | virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo); | 40 | virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo); |
119 | 40 | virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | 41 | virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); |
120 | 41 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 42 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
121 | 42 | virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw); | 43 | virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw); |
122 | 43 | 44 | ||
123 | 44 | LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;} | 45 | LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;} |
124 | 45 | LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;} | 46 | LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;} |
125 | 46 | 47 | ||
126 | 47 | bool TooltipNotify(LauncherIcon* Icon); | 48 | bool TooltipNotify(LauncherIcon* Icon); |
127 | 48 | bool MenuNotify(LauncherIcon* Icon); | 49 | bool MenuNotify(LauncherIcon* Icon); |
128 | 49 | 50 | ||
129 | 50 | void SetIconSize(int tile_size, int icon_size); | 51 | void SetIconSize(int tile_size, int icon_size); |
130 | 51 | void NotifyMenuTermination(LauncherIcon* Icon); | 52 | void NotifyMenuTermination(LauncherIcon* Icon); |
131 | 52 | 53 | ||
132 | 53 | void SetModel (LauncherModel *model); | 54 | void SetModel (LauncherModel *model); |
133 | 54 | 55 | ||
134 | 55 | void SetFloating (bool floating); | 56 | void SetFloating (bool floating); |
135 | 56 | 57 | ||
136 | 57 | void SetAutohide (bool autohide, nux::View *show_trigger); | 58 | void SetAutohide (bool autohide, nux::View *show_trigger); |
137 | 58 | bool AutohideEnabled (); | 59 | bool AutohideEnabled (); |
138 | 59 | 60 | ||
139 | 60 | virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); | 61 | virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); |
140 | 61 | virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); | 62 | virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); |
141 | 62 | virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); | 63 | virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
142 | 63 | virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags); | 64 | virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags); |
143 | 64 | virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags); | 65 | virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags); |
144 | 65 | virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); | 66 | virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
145 | 66 | virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); | 67 | virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags); |
146 | 67 | 68 | ||
147 | 69 | |||
148 | 70 | //! Called by LauncherIcon to signal that a Quicklist is becoming active. | ||
149 | 71 | void SetActiveQuicklist (QuicklistView *quicklist); | ||
150 | 72 | //! Get the active qicklist | ||
151 | 73 | QuicklistView *GetActiveQuicklist (); | ||
152 | 74 | //! Called by LauncherIcon to signal that a Quicklist is becoming unactive. | ||
153 | 75 | void CancelActiveQuicklist (QuicklistView *quicklist); | ||
154 | 76 | |||
155 | 68 | private: | 77 | private: |
156 | 69 | typedef enum | 78 | typedef enum |
157 | 70 | { | 79 | { |
158 | @@ -140,6 +149,7 @@ | |||
159 | 140 | virtual void PreLayoutManagement(); | 149 | virtual void PreLayoutManagement(); |
160 | 141 | virtual long PostLayoutManagement(long LayoutResult); | 150 | virtual long PostLayoutManagement(long LayoutResult); |
161 | 142 | virtual void PositionChildLayout(float offsetX, float offsetY); | 151 | virtual void PositionChildLayout(float offsetX, float offsetY); |
162 | 152 | |||
163 | 143 | 153 | ||
164 | 144 | nux::HLayout* m_Layout; | 154 | nux::HLayout* m_Layout; |
165 | 145 | int m_ContentOffsetY; | 155 | int m_ContentOffsetY; |
166 | @@ -147,6 +157,9 @@ | |||
167 | 147 | LauncherIcon* m_ActiveTooltipIcon; | 157 | LauncherIcon* m_ActiveTooltipIcon; |
168 | 148 | LauncherIcon* m_ActiveMenuIcon; | 158 | LauncherIcon* m_ActiveMenuIcon; |
169 | 149 | 159 | ||
170 | 160 | |||
171 | 161 | QuicklistView* _active_quicklist; | ||
172 | 162 | |||
173 | 150 | bool _hovered; | 163 | bool _hovered; |
174 | 151 | bool _floating; | 164 | bool _floating; |
175 | 152 | bool _autohide; | 165 | bool _autohide; |
176 | 153 | 166 | ||
177 | === modified file 'src/LauncherIcon.cpp' | |||
178 | --- src/LauncherIcon.cpp 2010-11-14 03:08:14 +0000 | |||
179 | +++ src/LauncherIcon.cpp 2010-11-18 14:03:47 +0000 | |||
180 | @@ -33,10 +33,13 @@ | |||
181 | 33 | 33 | ||
182 | 34 | #define DEFAULT_ICON "application-default-icon" | 34 | #define DEFAULT_ICON "application-default-icon" |
183 | 35 | 35 | ||
185 | 36 | LauncherIcon::LauncherIcon(Launcher* IconManager) | 36 | nux::Tooltip *LauncherIcon::_current_tooltip = 0; |
186 | 37 | QuicklistView *LauncherIcon::_current_quicklist = 0; | ||
187 | 38 | |||
188 | 39 | LauncherIcon::LauncherIcon(Launcher* launcher) | ||
189 | 37 | { | 40 | { |
190 | 38 | _folding_angle = 0; | 41 | _folding_angle = 0; |
192 | 39 | m_IconManager = IconManager; | 42 | _launcher = launcher; |
193 | 40 | m_TooltipText = "blank"; | 43 | m_TooltipText = "blank"; |
194 | 41 | 44 | ||
195 | 42 | _show_time.tv_sec = 0; | 45 | _show_time.tv_sec = 0; |
196 | @@ -67,8 +70,16 @@ | |||
197 | 67 | _icon_type = LAUNCHER_ICON_TYPE_NONE; | 70 | _icon_type = LAUNCHER_ICON_TYPE_NONE; |
198 | 68 | _sort_priority = 0; | 71 | _sort_priority = 0; |
199 | 69 | 72 | ||
200 | 73 | _quicklist = new QuicklistView (); | ||
201 | 74 | _quicklist->sigVisible.connect (sigc::mem_fun (this, &LauncherIcon::RecvShowQuicklist)); | ||
202 | 75 | _quicklist->sigHidden.connect (sigc::mem_fun (this, &LauncherIcon::RecvHideQuicklist)); | ||
203 | 76 | _quicklist_is_initialized = false; | ||
204 | 77 | |||
205 | 70 | MouseEnter.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter)); | 78 | MouseEnter.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter)); |
206 | 71 | MouseLeave.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave)); | 79 | MouseLeave.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave)); |
207 | 80 | MouseDown.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseDown)); | ||
208 | 81 | MouseUp.connect (sigc::mem_fun(this, &LauncherIcon::RecvMouseUp)); | ||
209 | 82 | |||
210 | 72 | } | 83 | } |
211 | 73 | 84 | ||
212 | 74 | LauncherIcon::~LauncherIcon() | 85 | LauncherIcon::~LauncherIcon() |
213 | @@ -206,17 +217,47 @@ | |||
214 | 206 | void | 217 | void |
215 | 207 | LauncherIcon::RecvMouseEnter () | 218 | LauncherIcon::RecvMouseEnter () |
216 | 208 | { | 219 | { |
218 | 209 | int icon_x = _xform_screen_coord[0].x; | 220 | if (_quicklist_is_initialized == false) |
219 | 221 | { | ||
220 | 222 | std::list<DbusmenuClient *> menus_list = Menus (); | ||
221 | 223 | std::list<DbusmenuClient *>::iterator it; | ||
222 | 224 | for (it = menus_list.begin (); it != menus_list.end (); it++) | ||
223 | 225 | { | ||
224 | 226 | g_signal_connect(G_OBJECT(*it), DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(&LauncherIcon::root_changed), _quicklist); | ||
225 | 227 | dbusmenu_client_add_type_handler (*it, DBUSMENU_CLIENT_TYPES_DEFAULT, (&LauncherIcon::label_handler)); | ||
226 | 228 | dbusmenu_client_add_type_handler (*it, DBUSMENU_CLIENT_TYPES_SEPARATOR, (&LauncherIcon::separator_handler)); | ||
227 | 229 | } | ||
228 | 230 | |||
229 | 231 | _quicklist_is_initialized = true; | ||
230 | 232 | } | ||
231 | 233 | |||
232 | 234 | if (_launcher->GetActiveQuicklist ()) | ||
233 | 235 | { | ||
234 | 236 | // A quicklist is active | ||
235 | 237 | return; | ||
236 | 238 | } | ||
237 | 239 | |||
238 | 240 | // int icon_x = _xform_screen_coord[0].x; | ||
239 | 241 | // int icon_y = _xform_screen_coord[0].y; | ||
240 | 242 | // int icon_w = _xform_screen_coord[2].x - _xform_screen_coord[0].x; | ||
241 | 243 | // int icon_h = _xform_screen_coord[2].y - _xform_screen_coord[0].y; | ||
242 | 244 | |||
243 | 245 | //int icon_x = _xform_screen_coord[0].x; | ||
244 | 210 | int icon_y = _xform_screen_coord[0].y; | 246 | int icon_y = _xform_screen_coord[0].y; |
246 | 211 | int icon_w = _xform_screen_coord[2].x - _xform_screen_coord[0].x; | 247 | //int icon_w = _xform_screen_coord[2].x - _xform_screen_coord[0].x; |
247 | 212 | int icon_h = _xform_screen_coord[2].y - _xform_screen_coord[0].y; | 248 | int icon_h = _xform_screen_coord[2].y - _xform_screen_coord[0].y; |
248 | 213 | 249 | ||
255 | 214 | _tooltip->SetBaseX (icon_x + icon_w - 10); | 250 | int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w; |
256 | 215 | _tooltip->SetBaseY (icon_y + | 251 | int tip_y = 24 + // The BaseWindow where the launcher resides is 24 pixels away from the top of the screen: find a better way to get that number. |
257 | 216 | 23 + // TODO: HARCODED, replace m_IconManager->GetBaseY () | 252 | icon_y + |
258 | 217 | (icon_h / 2) - | 253 | (icon_h / 2); |
259 | 218 | (_tooltip->GetBaseHeight () / 2)); | 254 | |
260 | 219 | _tooltip->ShowWindow (true); | 255 | _tooltip->ShowTooltipWithTipAt (tip_x, tip_y); |
261 | 256 | |||
262 | 257 | if (!_quicklist->IsVisible ()) | ||
263 | 258 | { | ||
264 | 259 | _tooltip->ShowWindow (true); | ||
265 | 260 | } | ||
266 | 220 | } | 261 | } |
267 | 221 | 262 | ||
268 | 222 | void LauncherIcon::RecvMouseLeave () | 263 | void LauncherIcon::RecvMouseLeave () |
269 | @@ -224,6 +265,112 @@ | |||
270 | 224 | _tooltip->ShowWindow (false); | 265 | _tooltip->ShowWindow (false); |
271 | 225 | } | 266 | } |
272 | 226 | 267 | ||
273 | 268 | |||
274 | 269 | gboolean LauncherIcon::label_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) | ||
275 | 270 | { | ||
276 | 271 | //const gchar* s = dbusmenu_menuitem_property_get (newitem, DBUSMENU_MENUITEM_PROP_LABEL); | ||
277 | 272 | //printf ("label: %s\n", s); | ||
278 | 273 | |||
279 | 274 | return true; | ||
280 | 275 | } | ||
281 | 276 | |||
282 | 277 | gboolean LauncherIcon::separator_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) | ||
283 | 278 | { | ||
284 | 279 | //const gchar* s = dbusmenu_menuitem_property_get (newitem, DBUSMENU_MENUITEM_PROP_LABEL); | ||
285 | 280 | //printf ("separator: %s\n", s); | ||
286 | 281 | |||
287 | 282 | return true; | ||
288 | 283 | } | ||
289 | 284 | |||
290 | 285 | void LauncherIcon::child_realized (DbusmenuMenuitem *newitem, QuicklistView *quicklist) | ||
291 | 286 | { | ||
292 | 287 | const gchar* label = dbusmenu_menuitem_property_get (newitem, DBUSMENU_MENUITEM_PROP_LABEL); | ||
293 | 288 | const gchar* type = dbusmenu_menuitem_property_get (newitem, DBUSMENU_MENUITEM_PROP_TYPE); | ||
294 | 289 | |||
295 | 290 | if (g_strcmp0 (type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0) | ||
296 | 291 | { | ||
297 | 292 | quicklist->AddMenuItem ("-----------------"); | ||
298 | 293 | } | ||
299 | 294 | else | ||
300 | 295 | { | ||
301 | 296 | quicklist->AddMenuItem (label); | ||
302 | 297 | } | ||
303 | 298 | |||
304 | 299 | } | ||
305 | 300 | |||
306 | 301 | void LauncherIcon::root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, QuicklistView *quicklist) | ||
307 | 302 | { | ||
308 | 303 | GList * child = NULL; | ||
309 | 304 | for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child)) | ||
310 | 305 | { | ||
311 | 306 | g_signal_connect(G_OBJECT(child->data), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(child_realized), quicklist); | ||
312 | 307 | } | ||
313 | 308 | } | ||
314 | 309 | |||
315 | 310 | void LauncherIcon::RecvMouseDown (int button) | ||
316 | 311 | { | ||
317 | 312 | if (button == 3) | ||
318 | 313 | { | ||
319 | 314 | if (_launcher->GetActiveQuicklist () == _quicklist) | ||
320 | 315 | { | ||
321 | 316 | // this quicklist is already active | ||
322 | 317 | return; | ||
323 | 318 | } | ||
324 | 319 | |||
325 | 320 | if (_launcher->GetActiveQuicklist ()) | ||
326 | 321 | { | ||
327 | 322 | // Hide the active quicklist. This will prevent it from Ungrabing the pointer in | ||
328 | 323 | // QuicklistView::RecvMouseDownOutsideOfQuicklist or void QuicklistView::RecvMouseClick. | ||
329 | 324 | // So the new quicklist that is about to be set as active will keep the grab of the pointer. | ||
330 | 325 | // Also disable theinput window. | ||
331 | 326 | _launcher->GetActiveQuicklist ()->EnableInputWindow (false); | ||
332 | 327 | _launcher->GetActiveQuicklist ()->CaptureMouseDownAnyWhereElse (false); | ||
333 | 328 | // This call must be last, because after, _launcher->GetActiveQuicklist () will return Null. | ||
334 | 329 | // the launcher listen to the sigHidden signal emitted by the BaseWindow when it becomes invisible | ||
335 | 330 | // and it set the active window to Null. | ||
336 | 331 | _launcher->GetActiveQuicklist ()->ShowWindow (false); | ||
337 | 332 | } | ||
338 | 333 | |||
339 | 334 | _tooltip->ShowWindow (false); | ||
340 | 335 | |||
341 | 336 | |||
342 | 337 | //int icon_x = _xform_screen_coord[0].x; | ||
343 | 338 | int icon_y = _xform_screen_coord[0].y; | ||
344 | 339 | //int icon_w = _xform_screen_coord[2].x - _xform_screen_coord[0].x; | ||
345 | 340 | int icon_h = _xform_screen_coord[2].y - _xform_screen_coord[0].y; | ||
346 | 341 | |||
347 | 342 | int tip_x = _launcher->GetBaseWidth () + 1; //icon_x + icon_w; | ||
348 | 343 | int tip_y = 24 + // The BaseWindow where the launcher resides is 24 pixels away from the top of the screen: find a better way to get that number. | ||
349 | 344 | icon_y + | ||
350 | 345 | (icon_h / 2); | ||
351 | 346 | |||
352 | 347 | _quicklist->ShowQuicklistWithTipAt (tip_x, tip_y); | ||
353 | 348 | _quicklist->EnableInputWindow (true); | ||
354 | 349 | _quicklist->GrabPointer (); | ||
355 | 350 | nux::GetWindowCompositor ().SetAlwaysOnFrontWindow (_quicklist); | ||
356 | 351 | _quicklist->NeedRedraw (); | ||
357 | 352 | } | ||
358 | 353 | } | ||
359 | 354 | |||
360 | 355 | void LauncherIcon::RecvMouseUp (int button) | ||
361 | 356 | { | ||
362 | 357 | if (button == 3) | ||
363 | 358 | { | ||
364 | 359 | if (_quicklist->IsVisible ()) | ||
365 | 360 | _quicklist->CaptureMouseDownAnyWhereElse (true); | ||
366 | 361 | } | ||
367 | 362 | } | ||
368 | 363 | |||
369 | 364 | void LauncherIcon::RecvShowQuicklist (nux::BaseWindow *quicklist) | ||
370 | 365 | { | ||
371 | 366 | _launcher->SetActiveQuicklist (_quicklist); | ||
372 | 367 | } | ||
373 | 368 | |||
374 | 369 | void LauncherIcon::RecvHideQuicklist (nux::BaseWindow *quicklist) | ||
375 | 370 | { | ||
376 | 371 | _launcher->CancelActiveQuicklist (_quicklist); | ||
377 | 372 | } | ||
378 | 373 | |||
379 | 227 | void LauncherIcon::HideTooltip () | 374 | void LauncherIcon::HideTooltip () |
380 | 228 | { | 375 | { |
381 | 229 | _tooltip->ShowWindow (false); | 376 | _tooltip->ShowWindow (false); |
382 | 230 | 377 | ||
383 | === modified file 'src/LauncherIcon.h' | |||
384 | --- src/LauncherIcon.h 2010-11-14 06:23:18 +0000 | |||
385 | +++ src/LauncherIcon.h 2010-11-18 14:03:47 +0000 | |||
386 | @@ -33,8 +33,10 @@ | |||
387 | 33 | #include <libdbusmenu-glib/client.h> | 33 | #include <libdbusmenu-glib/client.h> |
388 | 34 | 34 | ||
389 | 35 | #include "Tooltip.h" | 35 | #include "Tooltip.h" |
390 | 36 | #include "QuicklistView.h" | ||
391 | 36 | 37 | ||
392 | 37 | class Launcher; | 38 | class Launcher; |
393 | 39 | class QuicklistView; | ||
394 | 38 | 40 | ||
395 | 39 | typedef enum | 41 | typedef enum |
396 | 40 | { | 42 | { |
397 | @@ -51,7 +53,7 @@ | |||
398 | 51 | class LauncherIcon : public nux::InitiallyUnownedObject, public sigc::trackable | 53 | class LauncherIcon : public nux::InitiallyUnownedObject, public sigc::trackable |
399 | 52 | { | 54 | { |
400 | 53 | public: | 55 | public: |
402 | 54 | LauncherIcon(Launcher* IconManager); | 56 | LauncherIcon(Launcher* launcher); |
403 | 55 | ~LauncherIcon(); | 57 | ~LauncherIcon(); |
404 | 56 | 58 | ||
405 | 57 | void SetTooltipText (const TCHAR* text); | 59 | void SetTooltipText (const TCHAR* text); |
406 | @@ -66,6 +68,11 @@ | |||
407 | 66 | 68 | ||
408 | 67 | void RecvMouseEnter (); | 69 | void RecvMouseEnter (); |
409 | 68 | void RecvMouseLeave (); | 70 | void RecvMouseLeave (); |
410 | 71 | void RecvMouseDown (int button); | ||
411 | 72 | void RecvMouseUp (int button); | ||
412 | 73 | |||
413 | 74 | void RecvShowQuicklist (nux::BaseWindow *quicklist); | ||
414 | 75 | void RecvHideQuicklist (nux::BaseWindow *quicklist); | ||
415 | 69 | 76 | ||
416 | 70 | void HideTooltip (); | 77 | void HideTooltip (); |
417 | 71 | 78 | ||
418 | @@ -121,20 +128,30 @@ | |||
419 | 121 | nux::NString m_TooltipText; | 128 | nux::NString m_TooltipText; |
420 | 122 | //! the window this icon belong too. | 129 | //! the window this icon belong too. |
421 | 123 | nux::BaseWindow* m_Window; | 130 | nux::BaseWindow* m_Window; |
423 | 124 | Launcher* m_IconManager; | 131 | Launcher* _launcher; |
424 | 125 | 132 | ||
425 | 126 | nux::Vector4 _xform_screen_coord [4]; | 133 | nux::Vector4 _xform_screen_coord [4]; |
426 | 127 | nux::Vector4 _xform_icon_screen_coord [4]; | 134 | nux::Vector4 _xform_icon_screen_coord [4]; |
427 | 128 | bool _mouse_inside; | 135 | bool _mouse_inside; |
428 | 129 | float _folding_angle; | 136 | float _folding_angle; |
429 | 130 | 137 | ||
431 | 131 | nux::Tooltip* _tooltip; | 138 | nux::Tooltip *_tooltip; |
432 | 139 | QuicklistView *_quicklist; | ||
433 | 140 | |||
434 | 141 | static nux::Tooltip *_current_tooltip; | ||
435 | 142 | static QuicklistView *_current_quicklist; | ||
436 | 132 | 143 | ||
437 | 133 | 144 | ||
438 | 134 | friend class Launcher; | 145 | friend class Launcher; |
439 | 135 | friend class LauncherController; | 146 | friend class LauncherController; |
440 | 136 | 147 | ||
441 | 137 | private: | 148 | private: |
442 | 149 | |||
443 | 150 | static gboolean label_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); | ||
444 | 151 | static gboolean separator_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); | ||
445 | 152 | |||
446 | 153 | static void child_realized (DbusmenuMenuitem *newitem, QuicklistView *quicklist); | ||
447 | 154 | static void root_changed (DbusmenuClient * client, DbusmenuMenuitem *newroot, QuicklistView *quicklist); | ||
448 | 138 | static gboolean OnPresentTimeout (gpointer data); | 155 | static gboolean OnPresentTimeout (gpointer data); |
449 | 139 | 156 | ||
450 | 140 | nux::Color ColorForIcon (GdkPixbuf *pixbuf); | 157 | nux::Color ColorForIcon (GdkPixbuf *pixbuf); |
451 | @@ -148,6 +165,7 @@ | |||
452 | 148 | int _sort_priority; | 165 | int _sort_priority; |
453 | 149 | int _related_windows; | 166 | int _related_windows; |
454 | 150 | guint _present_time_handle; | 167 | guint _present_time_handle; |
455 | 168 | bool _quicklist_is_initialized; | ||
456 | 151 | 169 | ||
457 | 152 | LauncherIconType _icon_type; | 170 | LauncherIconType _icon_type; |
458 | 153 | 171 | ||
459 | 154 | 172 | ||
460 | === modified file 'src/QuicklistView.cpp' | |||
461 | --- src/QuicklistView.cpp 2010-11-11 10:46:30 +0000 | |||
462 | +++ src/QuicklistView.cpp 2010-11-18 14:03:47 +0000 | |||
463 | @@ -1,21 +1,21 @@ | |||
464 | 1 | /* | 1 | /* |
482 | 2 | * Copyright (C) 2010 Canonical Ltd | 2 | * Copyright (C) 2010 Canonical Ltd |
483 | 3 | * | 3 | * |
484 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
485 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
486 | 6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
487 | 7 | * | 7 | * |
488 | 8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
489 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
490 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
491 | 11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
492 | 12 | * | 12 | * |
493 | 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
494 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
495 | 15 | * | 15 | * |
496 | 16 | * Authored by: Jay Taoko <jay.taoko@canonical.com> | 16 | * Authored by: Jay Taoko <jay.taoko@canonical.com> |
497 | 17 | * Authored by: Mirco Müller <mirco.mueller@canonical.com | 17 | * Authored by: Mirco Müller <mirco.mueller@canonical.com |
498 | 18 | */ | 18 | */ |
499 | 19 | 19 | ||
500 | 20 | #include "Nux/Nux.h" | 20 | #include "Nux/Nux.h" |
501 | 21 | #include "Nux/VLayout.h" | 21 | #include "Nux/VLayout.h" |
502 | @@ -30,480 +30,701 @@ | |||
503 | 30 | 30 | ||
504 | 31 | #include "QuicklistView.h" | 31 | #include "QuicklistView.h" |
505 | 32 | 32 | ||
838 | 33 | namespace nux | 33 | |
839 | 34 | { | 34 | NUX_IMPLEMENT_OBJECT_TYPE (QuicklistView); |
840 | 35 | NUX_IMPLEMENT_OBJECT_TYPE (QuicklistView); | 35 | |
841 | 36 | 36 | QuicklistView::QuicklistView () | |
842 | 37 | QuicklistView::QuicklistView () | 37 | { |
843 | 38 | { | 38 | _texture_bg = 0; |
844 | 39 | _texture_bg = 0; | 39 | _texture_mask = 0; |
845 | 40 | _texture_mask = 0; | 40 | _texture_outline = 0; |
846 | 41 | _texture_outline = 0; | 41 | _cairo_text_has_changed = true; |
847 | 42 | _cairo_text_has_changed = true; | 42 | |
848 | 43 | 43 | _anchorX = 0; | |
849 | 44 | _anchorX = 0; | 44 | _anchorY = 0; |
850 | 45 | _anchorY = 0; | 45 | _labelText = TEXT ("QuicklistView 1234567890"); |
851 | 46 | _labelText = TEXT ("QuicklistView 1234567890"); | 46 | |
852 | 47 | 47 | _anchor_width = 10; | |
853 | 48 | _anchor_width = 10; | 48 | _anchor_height = 18; |
854 | 49 | _anchor_height = 18; | 49 | _corner_radius = 4; |
855 | 50 | _corner_radius = 4; | 50 | _padding = 13; |
856 | 51 | _padding = 10; | 51 | _top_size = 4; |
857 | 52 | 52 | ||
858 | 53 | _hlayout = new nux::HLayout (TEXT(""), NUX_TRACKER_LOCATION); | 53 | _hlayout = new nux::HLayout (TEXT(""), NUX_TRACKER_LOCATION); |
859 | 54 | _vlayout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION); | 54 | _vlayout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION); |
860 | 55 | 55 | _item_layout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION); | |
861 | 56 | _left_space = new nux::SpaceLayout (_padding + _anchor_width + _corner_radius, _padding + _anchor_width + _corner_radius, 1, 1000); | 56 | _default_item_layout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION); |
862 | 57 | _right_space = new nux::SpaceLayout (_padding + _corner_radius, _padding + _corner_radius, 1, 1000); | 57 | |
863 | 58 | 58 | _left_space = new nux::SpaceLayout (_padding + _anchor_width + _corner_radius, _padding + _anchor_width + _corner_radius, 1, 1000); | |
864 | 59 | _top_space = new nux::SpaceLayout (1, 1000, _padding + _corner_radius, _padding + _corner_radius); | 59 | _right_space = new nux::SpaceLayout (_padding + _corner_radius, _padding + _corner_radius, 1, 1000); |
865 | 60 | _bottom_space = new nux::SpaceLayout (1, 1000, _padding + _corner_radius, _padding + _corner_radius); | 60 | |
866 | 61 | 61 | _top_space = new nux::SpaceLayout (1, 1000, _padding + _corner_radius, _padding + _corner_radius); | |
867 | 62 | _vlayout->AddLayout(_top_space, 0); | 62 | _bottom_space = new nux::SpaceLayout (1, 1000, _padding + _corner_radius, _padding + _corner_radius); |
868 | 63 | 63 | ||
869 | 64 | for (int i = 0; i < 5; i++) | 64 | _vlayout->AddLayout (_top_space, 0); |
870 | 65 | { | 65 | |
871 | 66 | nux::StaticCairoText* tooltip_text; | 66 | _vlayout->AddLayout (_item_layout, 0); |
872 | 67 | if (i == 0) | 67 | |
873 | 68 | tooltip_text = new nux::StaticCairoText (TEXT ("1234567890"), NUX_TRACKER_LOCATION); | 68 | _vlayout->AddLayout (_default_item_layout, 0); |
874 | 69 | else | 69 | |
875 | 70 | tooltip_text = new nux::StaticCairoText (TEXT ("QuicklistView 1234567890"), NUX_TRACKER_LOCATION); | 70 | for (int i = 0; i < 2; i++) |
876 | 71 | 71 | { | |
877 | 72 | tooltip_text->sigTextChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextChanged)); | 72 | nux::StaticCairoText* item_text; |
878 | 73 | _vlayout->AddView(tooltip_text, 1, eCenter, eFull); | 73 | item_text = new nux::StaticCairoText (TEXT ("Default Item"), NUX_TRACKER_LOCATION); |
879 | 74 | _item_list.push_back (tooltip_text); | 74 | |
880 | 75 | tooltip_text->Reference(); | 75 | item_text->sigTextChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextChanged)); |
881 | 76 | } | 76 | item_text->sigTextColorChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextColorChanged)); |
882 | 77 | 77 | _default_item_layout->AddView(item_text, 1, nux::eCenter, nux::eFull); | |
883 | 78 | _vlayout->AddLayout(_bottom_space, 0); | 78 | _default_item_list.push_back (item_text); |
884 | 79 | 79 | item_text->Reference(); | |
885 | 80 | _hlayout->AddLayout(_left_space, 0); | 80 | } |
886 | 81 | _hlayout->AddLayout(_vlayout, 1, eCenter, eFull); | 81 | |
887 | 82 | _hlayout->AddLayout(_right_space, 0); | 82 | _vlayout->AddLayout (_bottom_space, 0); |
888 | 83 | 83 | ||
889 | 84 | SetWindowSizeMatchLayout (true); | 84 | _hlayout->AddLayout (_left_space, 0); |
890 | 85 | SetLayout (_hlayout); | 85 | _hlayout->AddLayout (_vlayout, 1, nux::eCenter, nux::eFull); |
891 | 86 | 86 | _hlayout->AddLayout (_right_space, 0); | |
892 | 87 | } | 87 | |
893 | 88 | 88 | SetWindowSizeMatchLayout (true); | |
894 | 89 | QuicklistView::~QuicklistView () | 89 | SetLayout (_hlayout); |
895 | 90 | { | 90 | |
896 | 91 | if (_texture_bg) | 91 | OnMouseDownOutsideArea.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseDownOutsideOfQuicklist)); |
897 | 92 | _texture_bg->UnReference (); | 92 | OnMouseDown.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseDown)); |
898 | 93 | 93 | OnMouseUp.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseUp)); | |
899 | 94 | std::list<nux::StaticCairoText*>::iterator it; | 94 | OnMouseClick.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseClick)); |
900 | 95 | for (it = _item_list.begin(); it != _item_list.end(); it++) | 95 | OnMouseMove.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseMove)); |
901 | 96 | { | 96 | OnMouseDrag.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseDrag)); |
902 | 97 | (*it)->UnReference(); | 97 | |
903 | 98 | } | 98 | } |
904 | 99 | _item_list.clear (); | 99 | |
905 | 100 | } | 100 | QuicklistView::~QuicklistView () |
906 | 101 | 101 | { | |
907 | 102 | long QuicklistView::ProcessEvent (IEvent& ievent, long TraverseInfo, long ProcessEventInfo) | 102 | if (_texture_bg) |
908 | 103 | { | 103 | _texture_bg->UnReference (); |
909 | 104 | long ret = TraverseInfo; | 104 | |
910 | 105 | std::list<nux::StaticCairoText*>::iterator it; | 105 | std::list<nux::StaticCairoText*>::iterator it; |
911 | 106 | for (it = _item_list.begin(); it != _item_list.end(); it++) | 106 | for (it = _item_list.begin(); it != _item_list.end(); it++) |
912 | 107 | { | 107 | { |
913 | 108 | ret = (*it)->ProcessEvent(ievent, ret, ProcessEventInfo); | 108 | (*it)->UnReference(); |
914 | 109 | } | 109 | } |
915 | 110 | return ret; | 110 | _item_list.clear (); |
916 | 111 | } | 111 | } |
917 | 112 | 112 | ||
918 | 113 | void QuicklistView::Draw (GraphicsEngine& gfxContext, bool forceDraw) | 113 | void QuicklistView::ShowQuicklistWithTipAt (int anchor_tip_x, int anchor_tip_y) |
919 | 114 | { | 114 | { |
920 | 115 | Geometry base = GetGeometry(); | 115 | int window_width; |
921 | 116 | 116 | int window_height; | |
922 | 117 | // the elements position inside the window are referenced to top-left window | 117 | |
923 | 118 | // corner. So bring base to (0, 0). | 118 | window_width = nux::GetWindow ().GetWindowWidth (); |
924 | 119 | base.SetX (0); | 119 | window_height = nux::GetWindow ().GetWindowHeight (); |
925 | 120 | base.SetY (0); | 120 | |
926 | 121 | gfxContext.PushClippingRectangle (base); | 121 | _anchorX = anchor_tip_x; |
927 | 122 | 122 | _anchorY = anchor_tip_y; | |
928 | 123 | GetGraphicsEngine().GetRenderStates().SetBlend (false, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 123 | |
929 | 124 | 124 | int x = _anchorX - _padding; | |
930 | 125 | TexCoordXForm texxform_bg; | 125 | int y = anchor_tip_y - _anchor_height/2 - _top_size - _corner_radius - _padding; |
931 | 126 | texxform_bg.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP); | 126 | |
932 | 127 | texxform_bg.SetTexCoordType (TexCoordXForm::OFFSET_COORD); | 127 | SetBaseX (x); |
933 | 128 | 128 | SetBaseY (y); | |
934 | 129 | TexCoordXForm texxform_mask; | 129 | |
935 | 130 | texxform_mask.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP); | 130 | ShowWindow (true); |
936 | 131 | texxform_mask.SetTexCoordType (TexCoordXForm::OFFSET_COORD); | 131 | } |
937 | 132 | 132 | ||
938 | 133 | 133 | void QuicklistView::ShowWindow (bool b, bool start_modal) | |
939 | 134 | gfxContext.QRP_GLSL_2TexMod (base.x, | 134 | { |
940 | 135 | base.y, | 135 | BaseWindow::ShowWindow (b, start_modal); |
941 | 136 | base.width, | 136 | |
942 | 137 | base.height, | 137 | // Reset all colors to white |
943 | 138 | _texture_bg->GetDeviceTexture(), | 138 | std::list<nux::StaticCairoText*>::iterator it; |
944 | 139 | texxform_bg, | 139 | for (it = _item_list.begin(); it != _item_list.end(); it++) |
945 | 140 | Color(1.0f, 1.0f, 1.0f, 1.0f), | 140 | { |
946 | 141 | _texture_mask->GetDeviceTexture(), | 141 | (*it)->SetTextColor (nux::Color::White); |
947 | 142 | texxform_mask, | 142 | } |
948 | 143 | Color(1.0f, 1.0f, 1.0f, 1.0f)); | 143 | } |
949 | 144 | 144 | ||
950 | 145 | 145 | long QuicklistView::ProcessEvent (nux::IEvent& ievent, long TraverseInfo, long ProcessEventInfo) | |
951 | 146 | TexCoordXForm texxform; | 146 | { |
952 | 147 | texxform.SetWrap(TEXWRAP_CLAMP, TEXWRAP_CLAMP); | 147 | long ret = TraverseInfo; |
953 | 148 | texxform.SetTexCoordType (TexCoordXForm::OFFSET_COORD); | 148 | long ProcEvInfo = 0; |
954 | 149 | 149 | ||
955 | 150 | GetGraphicsEngine().GetRenderStates().SetBlend (true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | 150 | nux::IEvent window_event = ievent; |
956 | 151 | gfxContext.QRP_GLSL_1Tex (base.x, | 151 | nux::Geometry base = GetGeometry(); |
957 | 152 | base.y, | 152 | window_event.e_x_root = base.x; |
958 | 153 | base.width, | 153 | window_event.e_y_root = base.y; |
959 | 154 | base.height, | 154 | |
960 | 155 | _texture_outline->GetDeviceTexture(), | 155 | // The child layout get the Mouse down button only if the MouseDown happened inside the client view Area |
961 | 156 | texxform, | 156 | nux::Geometry viewGeometry = GetGeometry(); |
962 | 157 | Color(1.0f, 1.0f, 1.0f, 1.0f)); | 157 | |
963 | 158 | 158 | if (ievent.e_event == nux::NUX_MOUSE_PRESSED) | |
964 | 159 | GetGraphicsEngine().GetRenderStates().SetBlend (false); | 159 | { |
965 | 160 | 160 | if (!viewGeometry.IsPointInside (ievent.e_x - ievent.e_x_root, ievent.e_y - ievent.e_y_root) ) | |
966 | 161 | std::list<nux::StaticCairoText*>::iterator it; | 161 | { |
967 | 162 | for (it = _item_list.begin(); it != _item_list.end(); it++) | 162 | ProcEvInfo = nux::eDoNotProcess; |
968 | 163 | { | 163 | } |
969 | 164 | (*it)->ProcessDraw(gfxContext, forceDraw); | 164 | } |
970 | 165 | } | 165 | |
971 | 166 | 166 | // We choose to test the quicklist items ourselves instead of processing them as it is usual in nux. | |
972 | 167 | gfxContext.PopClippingRectangle (); | 167 | // This is meantto be easier since the quicklist has a atypical way of working. |
973 | 168 | } | 168 | // if (m_layout) |
974 | 169 | 169 | // ret = m_layout->ProcessEvent (window_event, ret, ProcEvInfo); | |
975 | 170 | void QuicklistView::DrawContent (GraphicsEngine& GfxContext, bool force_draw) | 170 | |
976 | 171 | { | 171 | // PostProcessEvent2 must always have its last parameter set to 0 |
977 | 172 | 172 | // because the m_BackgroundArea is the real physical limit of the window. | |
978 | 173 | } | 173 | // So the previous test about IsPointInside do not prevail over m_BackgroundArea |
979 | 174 | 174 | // testing the event by itself. | |
980 | 175 | void QuicklistView::PreLayoutManagement () | 175 | ret = PostProcessEvent2 (ievent, ret, 0); |
981 | 176 | { | 176 | return ret; |
982 | 177 | int MaxItemWidth = 0; | 177 | } |
983 | 178 | int TotalItemHeight = 0; | 178 | |
984 | 179 | 179 | void QuicklistView::Draw (nux::GraphicsEngine& gfxContext, bool forceDraw) | |
985 | 180 | std::list<nux::StaticCairoText*>::iterator it; | 180 | { |
986 | 181 | for (it = _item_list.begin(); it != _item_list.end(); it++) | 181 | nux::Geometry base = GetGeometry(); |
987 | 182 | { | 182 | |
988 | 183 | int textWidth = 0; | 183 | // the elements position inside the window are referenced to top-left window |
989 | 184 | int textHeight = 0; | 184 | // corner. So bring base to (0, 0). |
990 | 185 | (*it)->GetTextExtents(textWidth, textHeight); | 185 | base.SetX (0); |
991 | 186 | if (textWidth > MaxItemWidth) | 186 | base.SetY (0); |
992 | 187 | MaxItemWidth = textWidth; | 187 | gfxContext.PushClippingRectangle (base); |
993 | 188 | TotalItemHeight += textHeight; | 188 | |
994 | 189 | } | 189 | nux::GetGraphicsEngine().GetRenderStates().SetBlend (false, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
995 | 190 | 190 | ||
996 | 191 | if(TotalItemHeight < _anchor_height) | 191 | nux::TexCoordXForm texxform_bg; |
997 | 192 | { | 192 | texxform_bg.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP); |
998 | 193 | _top_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight)/2 +1 + _padding + _corner_radius); | 193 | texxform_bg.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD); |
999 | 194 | _bottom_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight)/2 +1 + _padding + _corner_radius); | 194 | |
1000 | 195 | } | 195 | nux::TexCoordXForm texxform_mask; |
1001 | 196 | 196 | texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP); | |
1002 | 197 | BaseWindow::PreLayoutManagement (); | 197 | texxform_mask.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD); |
1003 | 198 | } | 198 | |
1004 | 199 | 199 | ||
1005 | 200 | long QuicklistView::PostLayoutManagement (long LayoutResult) | 200 | gfxContext.QRP_GLSL_2TexMod (base.x, |
1006 | 201 | { | 201 | base.y, |
1007 | 202 | long result = BaseWindow::PostLayoutManagement (LayoutResult); | 202 | base.width, |
1008 | 203 | UpdateTexture (); | 203 | base.height, |
1009 | 204 | 204 | _texture_bg->GetDeviceTexture(), | |
1010 | 205 | int x = _padding + _anchor_width + _corner_radius; | 205 | texxform_bg, |
1011 | 206 | int y = _padding + _corner_radius; | 206 | nux::Color(1.0f, 1.0f, 1.0f, 1.0f), |
1012 | 207 | 207 | _texture_mask->GetDeviceTexture(), | |
1013 | 208 | std::list<nux::StaticCairoText*>::iterator it; | 208 | texxform_mask, |
1014 | 209 | for (it = _item_list.begin(); it != _item_list.end(); it++) | 209 | nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); |
1015 | 210 | { | 210 | |
1016 | 211 | (*it)->SetBaseX (x); | 211 | |
1017 | 212 | (*it)->SetBaseY (y); | 212 | nux::TexCoordXForm texxform; |
1018 | 213 | 213 | texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP); | |
1019 | 214 | y += (*it)->GetBaseHeight (); | 214 | texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD); |
1020 | 215 | } | 215 | |
1021 | 216 | 216 | nux::GetGraphicsEngine().GetRenderStates().SetBlend (true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | |
1022 | 217 | return result; | 217 | gfxContext.QRP_GLSL_1Tex (base.x, |
1023 | 218 | } | 218 | base.y, |
1024 | 219 | 219 | base.width, | |
1025 | 220 | void QuicklistView::RecvCairoTextChanged (StaticCairoText& cairo_text) | 220 | base.height, |
1026 | 221 | { | 221 | _texture_outline->GetDeviceTexture(), |
1027 | 222 | _cairo_text_has_changed = true; | 222 | texxform, |
1028 | 223 | } | 223 | nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); |
1029 | 224 | 224 | ||
1030 | 225 | ///////////////////////////////////////////////////////////////////////////////////////////////// | 225 | nux::GetGraphicsEngine().GetRenderStates().SetBlend (false); |
1031 | 226 | ///////////////////////////////////////////////////////////////////////////////////////////////// | 226 | |
1032 | 227 | ///////////////////////////////////////////////////////////////////////////////////////////////// | 227 | std::list<nux::StaticCairoText*>::iterator it; |
1033 | 228 | 228 | for (it = _item_list.begin(); it != _item_list.end(); it++) | |
1034 | 229 | static inline void ql_blurinner (guchar* pixel, | 229 | { |
1035 | 230 | gint *zR, | 230 | (*it)->ProcessDraw(gfxContext, forceDraw); |
1036 | 231 | gint *zG, | 231 | } |
1037 | 232 | gint *zB, | 232 | |
1038 | 233 | gint *zA, | 233 | for (it = _default_item_list.begin(); it != _default_item_list.end(); it++) |
1039 | 234 | gint alpha, | 234 | { |
1040 | 235 | gint aprec, | 235 | (*it)->ProcessDraw(gfxContext, forceDraw); |
1041 | 236 | gint zprec) | 236 | } |
1042 | 237 | { | 237 | |
1043 | 238 | gint R; | 238 | |
1044 | 239 | gint G; | 239 | gfxContext.PopClippingRectangle (); |
1045 | 240 | gint B; | 240 | } |
1046 | 241 | guchar A; | 241 | |
1047 | 242 | 242 | void QuicklistView::DrawContent (nux::GraphicsEngine& GfxContext, bool force_draw) | |
1048 | 243 | R = *pixel; | 243 | { |
1049 | 244 | G = *(pixel + 1); | 244 | |
1050 | 245 | B = *(pixel + 2); | 245 | } |
1051 | 246 | A = *(pixel + 3); | 246 | |
1052 | 247 | 247 | void QuicklistView::PreLayoutManagement () | |
1053 | 248 | *zR += (alpha * ((R << zprec) - *zR)) >> aprec; | 248 | { |
1054 | 249 | *zG += (alpha * ((G << zprec) - *zG)) >> aprec; | 249 | int MaxItemWidth = 0; |
1055 | 250 | *zB += (alpha * ((B << zprec) - *zB)) >> aprec; | 250 | int TotalItemHeight = 0; |
1056 | 251 | *zA += (alpha * ((A << zprec) - *zA)) >> aprec; | 251 | |
1057 | 252 | 252 | std::list<nux::StaticCairoText*>::iterator it; | |
1058 | 253 | *pixel = *zR >> zprec; | 253 | for (it = _item_list.begin(); it != _item_list.end(); it++) |
1059 | 254 | *(pixel + 1) = *zG >> zprec; | 254 | { |
1060 | 255 | *(pixel + 2) = *zB >> zprec; | 255 | int textWidth = 0; |
1061 | 256 | *(pixel + 3) = *zA >> zprec; | 256 | int textHeight = 0; |
1062 | 257 | } | 257 | (*it)->GetTextExtents(textWidth, textHeight); |
1063 | 258 | 258 | if (textWidth > MaxItemWidth) | |
1064 | 259 | static inline void ql_blurrow (guchar* pixels, | 259 | MaxItemWidth = textWidth; |
1065 | 260 | gint width, | 260 | TotalItemHeight += textHeight; |
1066 | 261 | gint height, | 261 | } |
1067 | 262 | gint channels, | 262 | |
1068 | 263 | gint line, | 263 | for (it = _default_item_list.begin(); it != _default_item_list.end(); it++) |
1069 | 264 | gint alpha, | 264 | { |
1070 | 265 | gint aprec, | 265 | int textWidth = 0; |
1071 | 266 | gint zprec) | 266 | int textHeight = 0; |
1072 | 267 | { | 267 | (*it)->GetTextExtents(textWidth, textHeight); |
1073 | 268 | gint zR; | 268 | if (textWidth > MaxItemWidth) |
1074 | 269 | gint zG; | 269 | MaxItemWidth = textWidth; |
1075 | 270 | gint zB; | 270 | TotalItemHeight += textHeight; |
1076 | 271 | gint zA; | 271 | } |
1077 | 272 | gint index; | 272 | |
1078 | 273 | guchar* scanline; | 273 | if(TotalItemHeight < _anchor_height) |
1079 | 274 | 274 | { | |
1080 | 275 | scanline = &(pixels[line * width * channels]); | 275 | _top_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight)/2 +1 + _padding + _corner_radius); |
1081 | 276 | 276 | _bottom_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight)/2 +1 + _padding + _corner_radius); | |
1082 | 277 | zR = *scanline << zprec; | 277 | } |
1083 | 278 | zG = *(scanline + 1) << zprec; | 278 | |
1084 | 279 | zB = *(scanline + 2) << zprec; | 279 | BaseWindow::PreLayoutManagement (); |
1085 | 280 | zA = *(scanline + 3) << zprec; | 280 | } |
1086 | 281 | 281 | ||
1087 | 282 | for (index = 0; index < width; index ++) | 282 | long QuicklistView::PostLayoutManagement (long LayoutResult) |
1088 | 283 | ql_blurinner (&scanline[index * channels], &zR, &zG, &zB, &zA, alpha, aprec, | 283 | { |
1089 | 284 | zprec); | 284 | long result = BaseWindow::PostLayoutManagement (LayoutResult); |
1090 | 285 | 285 | UpdateTexture (); | |
1091 | 286 | for (index = width - 2; index >= 0; index--) | 286 | |
1092 | 287 | ql_blurinner (&scanline[index * channels], &zR, &zG, &zB, &zA, alpha, aprec, | 287 | int x = _padding + _anchor_width + _corner_radius; |
1093 | 288 | zprec); | 288 | int y = _padding + _corner_radius; |
1094 | 289 | } | 289 | |
1095 | 290 | 290 | std::list<nux::StaticCairoText*>::iterator it; | |
1096 | 291 | static inline void ql_blurcol (guchar* pixels, | 291 | for (it = _item_list.begin(); it != _item_list.end(); it++) |
1097 | 292 | gint width, | 292 | { |
1098 | 293 | gint height, | 293 | (*it)->SetBaseX (x); |
1099 | 294 | gint channels, | 294 | (*it)->SetBaseY (y); |
1100 | 295 | gint x, | 295 | |
1101 | 296 | gint alpha, | 296 | y += (*it)->GetBaseHeight (); |
1102 | 297 | gint aprec, | 297 | } |
1103 | 298 | gint zprec) | 298 | |
1104 | 299 | { | 299 | for (it = _default_item_list.begin(); it != _default_item_list.end(); it++) |
1105 | 300 | gint zR; | 300 | { |
1106 | 301 | gint zG; | 301 | (*it)->SetBaseX (x); |
1107 | 302 | gint zB; | 302 | (*it)->SetBaseY (y); |
1108 | 303 | gint zA; | 303 | |
1109 | 304 | gint index; | 304 | y += (*it)->GetBaseHeight (); |
1110 | 305 | guchar* ptr; | 305 | } |
1111 | 306 | 306 | ||
1112 | 307 | ptr = pixels; | 307 | return result; |
1113 | 308 | 308 | } | |
1114 | 309 | ptr += x * channels; | 309 | |
1115 | 310 | 310 | void QuicklistView::RecvCairoTextChanged (nux::StaticCairoText& cairo_text) | |
1116 | 311 | zR = *((guchar*) ptr ) << zprec; | 311 | { |
1117 | 312 | zG = *((guchar*) ptr + 1) << zprec; | 312 | _cairo_text_has_changed = true; |
1118 | 313 | zB = *((guchar*) ptr + 2) << zprec; | 313 | } |
1119 | 314 | zA = *((guchar*) ptr + 3) << zprec; | 314 | |
1120 | 315 | 315 | void QuicklistView::RecvCairoTextColorChanged (nux::StaticCairoText& cairo_text) | |
1121 | 316 | for (index = width; index < (height - 1) * width; index += width) | 316 | { |
1122 | 317 | ql_blurinner ((guchar*) &ptr[index * channels], &zR, &zG, &zB, &zA, alpha, | 317 | NeedRedraw (); |
1123 | 318 | aprec, zprec); | 318 | } |
1124 | 319 | 319 | ||
1125 | 320 | for (index = (height - 2) * width; index >= 0; index -= width) | 320 | void QuicklistView::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags) |
1126 | 321 | ql_blurinner ((guchar*) &ptr[index * channels], &zR, &zG, &zB, &zA, alpha, | 321 | { |
1127 | 322 | aprec, zprec); | 322 | // if (IsVisible ()) |
1128 | 323 | } | 323 | // { |
1129 | 324 | 324 | // CaptureMouseDownAnyWhereElse (false); | |
1130 | 325 | // | 325 | // ForceStopFocus (1, 1); |
1131 | 326 | // pixels image-data | 326 | // UnGrabPointer (); |
1132 | 327 | // width image-width | 327 | // EnableInputWindow (false); |
1133 | 328 | // height image-height | 328 | // ShowWindow (false); |
1134 | 329 | // channels image-channels | 329 | // } |
1135 | 330 | // | 330 | } |
1136 | 331 | // in-place blur of image 'img' with kernel of approximate radius 'radius' | 331 | |
1137 | 332 | // | 332 | void QuicklistView::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags) |
1138 | 333 | // blurs with two sided exponential impulse response | 333 | { |
1139 | 334 | // | 334 | |
1140 | 335 | // aprec = precision of alpha parameter in fixed-point format 0.aprec | 335 | } |
1141 | 336 | // | 336 | |
1142 | 337 | // zprec = precision of state parameters zR,zG,zB and zA in fp format 8.zprec | 337 | void QuicklistView::RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags) |
1143 | 338 | // | 338 | { |
1144 | 339 | void ql_expblur (guchar* pixels, | 339 | if (IsVisible ()) |
1145 | 340 | gint width, | 340 | { |
1146 | 341 | gint height, | 341 | CaptureMouseDownAnyWhereElse (false); |
1147 | 342 | gint channels, | 342 | ForceStopFocus (1, 1); |
1148 | 343 | gint radius, | 343 | UnGrabPointer (); |
1149 | 344 | gint aprec, | 344 | EnableInputWindow (false); |
1150 | 345 | gint zprec) | 345 | ShowWindow (false); |
1151 | 346 | { | 346 | } |
1152 | 347 | gint alpha; | 347 | } |
1153 | 348 | gint row = 0; | 348 | |
1154 | 349 | gint col = 0; | 349 | void QuicklistView::RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags) |
1155 | 350 | 350 | { | |
1156 | 351 | if (radius < 1) | 351 | std::list<nux::StaticCairoText*>::iterator it; |
1157 | 352 | return; | 352 | for (it = _item_list.begin(); it != _item_list.end(); it++) |
1158 | 353 | 353 | { | |
1159 | 354 | // calculate the alpha such that 90% of | 354 | if ((*it)->GetGeometry ().IsPointInside (x, y)) |
1160 | 355 | // the kernel is within the radius. | 355 | { |
1161 | 356 | // (Kernel extends to infinity) | 356 | (*it)->SetTextColor (nux::Color::DarkGray); |
1162 | 357 | alpha = (gint) ((1 << aprec) * (1.0f - expf (-2.3f / (radius + 1.f)))); | 357 | } |
1163 | 358 | 358 | else | |
1164 | 359 | for (; row < height; row++) | 359 | { |
1165 | 360 | ql_blurrow (pixels, width, height, channels, row, alpha, aprec, zprec); | 360 | (*it)->SetTextColor (nux::Color::White); |
1166 | 361 | 361 | } | |
1167 | 362 | for(; col < width; col++) | 362 | } |
1168 | 363 | ql_blurcol (pixels, width, height, channels, col, alpha, aprec, zprec); | 363 | |
1169 | 364 | 364 | for (it = _default_item_list.begin(); it != _default_item_list.end(); it++) | |
1170 | 365 | { | ||
1171 | 366 | if ((*it)->GetGeometry ().IsPointInside (x, y)) | ||
1172 | 367 | { | ||
1173 | 368 | (*it)->SetTextColor (nux::Color::DarkGray); | ||
1174 | 369 | } | ||
1175 | 370 | else | ||
1176 | 371 | { | ||
1177 | 372 | (*it)->SetTextColor (nux::Color::White); | ||
1178 | 373 | } | ||
1179 | 374 | } | ||
1180 | 375 | } | ||
1181 | 376 | |||
1182 | 377 | void QuicklistView::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags) | ||
1183 | 378 | { | ||
1184 | 379 | std::list<nux::StaticCairoText*>::iterator it; | ||
1185 | 380 | for (it = _item_list.begin(); it != _item_list.end(); it++) | ||
1186 | 381 | { | ||
1187 | 382 | if ((*it)->GetGeometry ().IsPointInside (x, y)) | ||
1188 | 383 | { | ||
1189 | 384 | (*it)->SetTextColor (nux::Color::DarkGray); | ||
1190 | 385 | } | ||
1191 | 386 | else | ||
1192 | 387 | { | ||
1193 | 388 | (*it)->SetTextColor (nux::Color::White); | ||
1194 | 389 | } | ||
1195 | 390 | } | ||
1196 | 391 | |||
1197 | 392 | for (it = _default_item_list.begin(); it != _default_item_list.end(); it++) | ||
1198 | 393 | { | ||
1199 | 394 | if ((*it)->GetGeometry ().IsPointInside (x, y)) | ||
1200 | 395 | { | ||
1201 | 396 | (*it)->SetTextColor (nux::Color::DarkGray); | ||
1202 | 397 | } | ||
1203 | 398 | else | ||
1204 | 399 | { | ||
1205 | 400 | (*it)->SetTextColor (nux::Color::White); | ||
1206 | 401 | } | ||
1207 | 402 | } | ||
1208 | 403 | } | ||
1209 | 404 | |||
1210 | 405 | void QuicklistView::RecvMouseDownOutsideOfQuicklist (int x, int y, unsigned long button_flags, unsigned long key_flags) | ||
1211 | 406 | { | ||
1212 | 407 | if (IsVisible ()) | ||
1213 | 408 | { | ||
1214 | 409 | CaptureMouseDownAnyWhereElse (false); | ||
1215 | 410 | ForceStopFocus (1, 1); | ||
1216 | 411 | UnGrabPointer (); | ||
1217 | 412 | EnableInputWindow (false); | ||
1218 | 413 | ShowWindow (false); | ||
1219 | 414 | } | ||
1220 | 415 | } | ||
1221 | 416 | |||
1222 | 417 | void QuicklistView::RemoveAllMenuItem () | ||
1223 | 418 | { | ||
1224 | 419 | _item_list.clear (); | ||
1225 | 420 | _item_layout->Clear (); | ||
1226 | 421 | _cairo_text_has_changed = true; | ||
1227 | 422 | nux::GetGraphicsThread ()->AddObjectToRefreshList (this); | ||
1228 | 423 | } | ||
1229 | 424 | |||
1230 | 425 | void QuicklistView::AddMenuItem (nux::NString str) | ||
1231 | 426 | { | ||
1232 | 427 | nux::StaticCairoText* item_text; | ||
1233 | 428 | item_text = new nux::StaticCairoText (str.GetTCharPtr (), NUX_TRACKER_LOCATION); | ||
1234 | 429 | |||
1235 | 430 | item_text->sigTextChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextChanged)); | ||
1236 | 431 | item_text->sigTextColorChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextColorChanged)); | ||
1237 | 432 | _item_layout->AddView(item_text, 1, nux::eCenter, nux::eFull); | ||
1238 | 433 | _item_list.push_back (item_text); | ||
1239 | 434 | item_text->Reference(); | ||
1240 | 435 | |||
1241 | 436 | _cairo_text_has_changed = true; | ||
1242 | 437 | nux::GetGraphicsThread ()->AddObjectToRefreshList (this); | ||
1243 | 438 | NeedRedraw (); | ||
1244 | 439 | } | ||
1245 | 440 | |||
1246 | 441 | void QuicklistView::RenderQuicklistView () | ||
1247 | 442 | { | ||
1248 | 443 | |||
1249 | 444 | } | ||
1250 | 445 | |||
1251 | 446 | ///////////////////////////////////////////////////////////////////////////////////////////////// | ||
1252 | 447 | ///////////////////////////////////////////////////////////////////////////////////////////////// | ||
1253 | 448 | ///////////////////////////////////////////////////////////////////////////////////////////////// | ||
1254 | 449 | |||
1255 | 450 | static inline void ql_blurinner (guchar* pixel, | ||
1256 | 451 | gint *zR, | ||
1257 | 452 | gint *zG, | ||
1258 | 453 | gint *zB, | ||
1259 | 454 | gint *zA, | ||
1260 | 455 | gint alpha, | ||
1261 | 456 | gint aprec, | ||
1262 | 457 | gint zprec) | ||
1263 | 458 | { | ||
1264 | 459 | gint R; | ||
1265 | 460 | gint G; | ||
1266 | 461 | gint B; | ||
1267 | 462 | guchar A; | ||
1268 | 463 | |||
1269 | 464 | R = *pixel; | ||
1270 | 465 | G = *(pixel + 1); | ||
1271 | 466 | B = *(pixel + 2); | ||
1272 | 467 | A = *(pixel + 3); | ||
1273 | 468 | |||
1274 | 469 | *zR += (alpha * ((R << zprec) - *zR)) >> aprec; | ||
1275 | 470 | *zG += (alpha * ((G << zprec) - *zG)) >> aprec; | ||
1276 | 471 | *zB += (alpha * ((B << zprec) - *zB)) >> aprec; | ||
1277 | 472 | *zA += (alpha * ((A << zprec) - *zA)) >> aprec; | ||
1278 | 473 | |||
1279 | 474 | *pixel = *zR >> zprec; | ||
1280 | 475 | *(pixel + 1) = *zG >> zprec; | ||
1281 | 476 | *(pixel + 2) = *zB >> zprec; | ||
1282 | 477 | *(pixel + 3) = *zA >> zprec; | ||
1283 | 478 | } | ||
1284 | 479 | |||
1285 | 480 | static inline void ql_blurrow (guchar* pixels, | ||
1286 | 481 | gint width, | ||
1287 | 482 | gint height, | ||
1288 | 483 | gint channels, | ||
1289 | 484 | gint line, | ||
1290 | 485 | gint alpha, | ||
1291 | 486 | gint aprec, | ||
1292 | 487 | gint zprec) | ||
1293 | 488 | { | ||
1294 | 489 | gint zR; | ||
1295 | 490 | gint zG; | ||
1296 | 491 | gint zB; | ||
1297 | 492 | gint zA; | ||
1298 | 493 | gint index; | ||
1299 | 494 | guchar* scanline; | ||
1300 | 495 | |||
1301 | 496 | scanline = &(pixels[line * width * channels]); | ||
1302 | 497 | |||
1303 | 498 | zR = *scanline << zprec; | ||
1304 | 499 | zG = *(scanline + 1) << zprec; | ||
1305 | 500 | zB = *(scanline + 2) << zprec; | ||
1306 | 501 | zA = *(scanline + 3) << zprec; | ||
1307 | 502 | |||
1308 | 503 | for (index = 0; index < width; index ++) | ||
1309 | 504 | ql_blurinner (&scanline[index * channels], &zR, &zG, &zB, &zA, alpha, aprec, | ||
1310 | 505 | zprec); | ||
1311 | 506 | |||
1312 | 507 | for (index = width - 2; index >= 0; index--) | ||
1313 | 508 | ql_blurinner (&scanline[index * channels], &zR, &zG, &zB, &zA, alpha, aprec, | ||
1314 | 509 | zprec); | ||
1315 | 510 | } | ||
1316 | 511 | |||
1317 | 512 | static inline void ql_blurcol (guchar* pixels, | ||
1318 | 513 | gint width, | ||
1319 | 514 | gint height, | ||
1320 | 515 | gint channels, | ||
1321 | 516 | gint x, | ||
1322 | 517 | gint alpha, | ||
1323 | 518 | gint aprec, | ||
1324 | 519 | gint zprec) | ||
1325 | 520 | { | ||
1326 | 521 | gint zR; | ||
1327 | 522 | gint zG; | ||
1328 | 523 | gint zB; | ||
1329 | 524 | gint zA; | ||
1330 | 525 | gint index; | ||
1331 | 526 | guchar* ptr; | ||
1332 | 527 | |||
1333 | 528 | ptr = pixels; | ||
1334 | 529 | |||
1335 | 530 | ptr += x * channels; | ||
1336 | 531 | |||
1337 | 532 | zR = *((guchar*) ptr ) << zprec; | ||
1338 | 533 | zG = *((guchar*) ptr + 1) << zprec; | ||
1339 | 534 | zB = *((guchar*) ptr + 2) << zprec; | ||
1340 | 535 | zA = *((guchar*) ptr + 3) << zprec; | ||
1341 | 536 | |||
1342 | 537 | for (index = width; index < (height - 1) * width; index += width) | ||
1343 | 538 | ql_blurinner ((guchar*) &ptr[index * channels], &zR, &zG, &zB, &zA, alpha, | ||
1344 | 539 | aprec, zprec); | ||
1345 | 540 | |||
1346 | 541 | for (index = (height - 2) * width; index >= 0; index -= width) | ||
1347 | 542 | ql_blurinner ((guchar*) &ptr[index * channels], &zR, &zG, &zB, &zA, alpha, | ||
1348 | 543 | aprec, zprec); | ||
1349 | 544 | } | ||
1350 | 545 | |||
1351 | 546 | // | ||
1352 | 547 | // pixels image-data | ||
1353 | 548 | // width image-width | ||
1354 | 549 | // height image-height | ||
1355 | 550 | // channels image-channels | ||
1356 | 551 | // | ||
1357 | 552 | // in-place blur of image 'img' with kernel of approximate radius 'radius' | ||
1358 | 553 | // | ||
1359 | 554 | // blurs with two sided exponential impulse response | ||
1360 | 555 | // | ||
1361 | 556 | // aprec = precision of alpha parameter in fixed-point format 0.aprec | ||
1362 | 557 | // | ||
1363 | 558 | // zprec = precision of state parameters zR,zG,zB and zA in fp format 8.zprec | ||
1364 | 559 | // | ||
1365 | 560 | void ql_expblur (guchar* pixels, | ||
1366 | 561 | gint width, | ||
1367 | 562 | gint height, | ||
1368 | 563 | gint channels, | ||
1369 | 564 | gint radius, | ||
1370 | 565 | gint aprec, | ||
1371 | 566 | gint zprec) | ||
1372 | 567 | { | ||
1373 | 568 | gint alpha; | ||
1374 | 569 | gint row = 0; | ||
1375 | 570 | gint col = 0; | ||
1376 | 571 | |||
1377 | 572 | if (radius < 1) | ||
1378 | 365 | return; | 573 | return; |
1380 | 366 | } | 574 | |
1381 | 575 | // calculate the alpha such that 90% of | ||
1382 | 576 | // the kernel is within the radius. | ||
1383 | 577 | // (Kernel extends to infinity) | ||
1384 | 578 | alpha = (gint) ((1 << aprec) * (1.0f - expf (-2.3f / (radius + 1.f)))); | ||
1385 | 579 | |||
1386 | 580 | for (; row < height; row++) | ||
1387 | 581 | ql_blurrow (pixels, width, height, channels, row, alpha, aprec, zprec); | ||
1388 | 582 | |||
1389 | 583 | for(; col < width; col++) | ||
1390 | 584 | ql_blurcol (pixels, width, height, channels, col, alpha, aprec, zprec); | ||
1391 | 585 | |||
1392 | 586 | return; | ||
1393 | 587 | } | ||
1394 | 367 | 588 | ||
1395 | 368 | /** | 589 | /** |
1403 | 369 | * ctk_surface_blur: | 590 | * ctk_surface_blur: |
1404 | 370 | * @surface: pointer to a cairo image-surface | 591 | * @surface: pointer to a cairo image-surface |
1405 | 371 | * @radius: unsigned integer acting as the blur-radius to apply | 592 | * @radius: unsigned integer acting as the blur-radius to apply |
1406 | 372 | * | 593 | * |
1407 | 373 | * Applies an exponential blur on the passed surface executed on the CPU. Not as | 594 | * Applies an exponential blur on the passed surface executed on the CPU. Not as |
1408 | 374 | * nice as a real gaussian blur, but much faster. | 595 | * nice as a real gaussian blur, but much faster. |
1409 | 375 | **/ | 596 | **/ |
1410 | 376 | void ql_surface_blur (cairo_surface_t* surface, | 597 | void ql_surface_blur (cairo_surface_t* surface, |
1541 | 377 | guint radius) | 598 | guint radius) |
1542 | 378 | { | 599 | { |
1543 | 379 | guchar* pixels; | 600 | guchar* pixels; |
1544 | 380 | guint width; | 601 | guint width; |
1545 | 381 | guint height; | 602 | guint height; |
1546 | 382 | cairo_format_t format; | 603 | cairo_format_t format; |
1547 | 383 | 604 | ||
1548 | 384 | // before we mess with the surface execute any pending drawing | 605 | // before we mess with the surface execute any pending drawing |
1549 | 385 | cairo_surface_flush (surface); | 606 | cairo_surface_flush (surface); |
1550 | 386 | 607 | ||
1551 | 387 | pixels = cairo_image_surface_get_data (surface); | 608 | pixels = cairo_image_surface_get_data (surface); |
1552 | 388 | width = cairo_image_surface_get_width (surface); | 609 | width = cairo_image_surface_get_width (surface); |
1553 | 389 | height = cairo_image_surface_get_height (surface); | 610 | height = cairo_image_surface_get_height (surface); |
1554 | 390 | format = cairo_image_surface_get_format (surface); | 611 | format = cairo_image_surface_get_format (surface); |
1555 | 391 | 612 | ||
1556 | 392 | switch (format) | 613 | switch (format) |
1557 | 393 | { | 614 | { |
1558 | 394 | case CAIRO_FORMAT_ARGB32: | 615 | case CAIRO_FORMAT_ARGB32: |
1559 | 395 | ql_expblur (pixels, width, height, 4, radius, 16, 7); | 616 | ql_expblur (pixels, width, height, 4, radius, 16, 7); |
1560 | 396 | break; | 617 | break; |
1561 | 397 | 618 | ||
1562 | 398 | case CAIRO_FORMAT_RGB24: | 619 | case CAIRO_FORMAT_RGB24: |
1563 | 399 | ql_expblur (pixels, width, height, 3, radius, 16, 7); | 620 | ql_expblur (pixels, width, height, 3, radius, 16, 7); |
1564 | 400 | break; | 621 | break; |
1565 | 401 | 622 | ||
1566 | 402 | case CAIRO_FORMAT_A8: | 623 | case CAIRO_FORMAT_A8: |
1567 | 403 | ql_expblur (pixels, width, height, 1, radius, 16, 7); | 624 | ql_expblur (pixels, width, height, 1, radius, 16, 7); |
1568 | 404 | break; | 625 | break; |
1569 | 405 | 626 | ||
1570 | 406 | default : | 627 | default : |
1571 | 407 | // do nothing | 628 | // do nothing |
1572 | 408 | break; | 629 | break; |
1573 | 409 | } | 630 | } |
1574 | 410 | 631 | ||
1575 | 411 | // inform cairo we altered the surfaces contents | 632 | // inform cairo we altered the surfaces contents |
1576 | 412 | cairo_surface_mark_dirty (surface); | 633 | cairo_surface_mark_dirty (surface); |
1577 | 413 | } | 634 | } |
1578 | 414 | 635 | ||
1579 | 415 | 636 | ||
1580 | 416 | void ql_tint_dot_hl (cairo_t* cr, | 637 | void ql_tint_dot_hl (cairo_t* cr, |
1581 | 417 | gint width, | 638 | gint width, |
1582 | 418 | gint height, | 639 | gint height, |
1583 | 419 | gfloat hl_x, | 640 | gfloat hl_x, |
1584 | 420 | gfloat hl_y, | 641 | gfloat hl_y, |
1585 | 421 | gfloat hl_size, | 642 | gfloat hl_size, |
1586 | 422 | gfloat* rgba_tint, | 643 | gfloat* rgba_tint, |
1587 | 423 | gfloat* rgba_hl, | 644 | gfloat* rgba_hl, |
1588 | 424 | gfloat* rgba_dot) | 645 | gfloat* rgba_dot) |
1589 | 425 | { | 646 | { |
1590 | 426 | cairo_surface_t* dots_surf = NULL; | 647 | cairo_surface_t* dots_surf = NULL; |
1591 | 427 | cairo_t* dots_cr = NULL; | 648 | cairo_t* dots_cr = NULL; |
1592 | 428 | cairo_pattern_t* dots_pattern = NULL; | 649 | cairo_pattern_t* dots_pattern = NULL; |
1593 | 429 | cairo_pattern_t* hl_pattern = NULL; | 650 | cairo_pattern_t* hl_pattern = NULL; |
1594 | 430 | 651 | ||
1595 | 431 | // create context for dot-pattern | 652 | // create context for dot-pattern |
1596 | 432 | dots_surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 4, 4); | 653 | dots_surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 4, 4); |
1597 | 433 | dots_cr = cairo_create (dots_surf); | 654 | dots_cr = cairo_create (dots_surf); |
1598 | 434 | 655 | ||
1599 | 435 | // clear normal context | 656 | // clear normal context |
1600 | 436 | cairo_scale (cr, 1.0f, 1.0f); | 657 | cairo_scale (cr, 1.0f, 1.0f); |
1601 | 437 | cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f); | 658 | cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f); |
1602 | 438 | cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); | 659 | cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); |
1603 | 439 | cairo_paint (cr); | 660 | cairo_paint (cr); |
1604 | 440 | 661 | ||
1605 | 441 | // prepare drawing for normal context | 662 | // prepare drawing for normal context |
1606 | 442 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); | 663 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
1607 | 443 | 664 | ||
1608 | 444 | // create path in normal context | 665 | // create path in normal context |
1609 | 445 | cairo_rectangle (cr, 0.0f, 0.0f, (gdouble) width, (gdouble) height); | 666 | cairo_rectangle (cr, 0.0f, 0.0f, (gdouble) width, (gdouble) height); |
1610 | 446 | 667 | ||
1611 | 447 | // fill path of normal context with tint | 668 | // fill path of normal context with tint |
1612 | 448 | cairo_set_source_rgba (cr, | 669 | cairo_set_source_rgba (cr, |
1613 | 449 | rgba_tint[0], | 670 | rgba_tint[0], |
1614 | 450 | rgba_tint[1], | 671 | rgba_tint[1], |
1615 | 451 | rgba_tint[2], | 672 | rgba_tint[2], |
1616 | 452 | rgba_tint[3]); | 673 | rgba_tint[3]); |
1617 | 453 | cairo_fill_preserve (cr); | 674 | cairo_fill_preserve (cr); |
1618 | 454 | 675 | ||
1619 | 455 | // create pattern in dot-context | 676 | // create pattern in dot-context |
1620 | 456 | cairo_set_operator (dots_cr, CAIRO_OPERATOR_CLEAR); | 677 | cairo_set_operator (dots_cr, CAIRO_OPERATOR_CLEAR); |
1621 | 457 | cairo_paint (dots_cr); | 678 | cairo_paint (dots_cr); |
1622 | 458 | cairo_scale (dots_cr, 1.0f, 1.0f); | 679 | cairo_scale (dots_cr, 1.0f, 1.0f); |
1623 | 459 | cairo_set_operator (dots_cr, CAIRO_OPERATOR_OVER); | 680 | cairo_set_operator (dots_cr, CAIRO_OPERATOR_OVER); |
1624 | 460 | cairo_set_source_rgba (dots_cr, | 681 | cairo_set_source_rgba (dots_cr, |
1625 | 461 | rgba_dot[0], | 682 | rgba_dot[0], |
1626 | 462 | rgba_dot[1], | 683 | rgba_dot[1], |
1627 | 463 | rgba_dot[2], | 684 | rgba_dot[2], |
1628 | 464 | rgba_dot[3]); | 685 | rgba_dot[3]); |
1629 | 465 | cairo_rectangle (dots_cr, 0.0f, 0.0f, 1.0f, 1.0f); | 686 | cairo_rectangle (dots_cr, 0.0f, 0.0f, 1.0f, 1.0f); |
1630 | 466 | cairo_fill (dots_cr); | 687 | cairo_fill (dots_cr); |
1631 | 467 | cairo_rectangle (dots_cr, 2.0f, 2.0f, 1.0f, 1.0f); | 688 | cairo_rectangle (dots_cr, 2.0f, 2.0f, 1.0f, 1.0f); |
1632 | 468 | cairo_fill (dots_cr); | 689 | cairo_fill (dots_cr); |
1633 | 469 | dots_pattern = cairo_pattern_create_for_surface (dots_surf); | 690 | dots_pattern = cairo_pattern_create_for_surface (dots_surf); |
1634 | 470 | 691 | ||
1635 | 471 | // fill path of normal context with dot-pattern | 692 | // fill path of normal context with dot-pattern |
1636 | 472 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); | 693 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
1637 | 473 | cairo_set_source (cr, dots_pattern); | 694 | cairo_set_source (cr, dots_pattern); |
1638 | 474 | cairo_pattern_set_extend (dots_pattern, CAIRO_EXTEND_REPEAT); | 695 | cairo_pattern_set_extend (dots_pattern, CAIRO_EXTEND_REPEAT); |
1639 | 475 | cairo_fill_preserve (cr); | 696 | cairo_fill_preserve (cr); |
1640 | 476 | cairo_pattern_destroy (dots_pattern); | 697 | cairo_pattern_destroy (dots_pattern); |
1641 | 477 | cairo_surface_destroy (dots_surf); | 698 | cairo_surface_destroy (dots_surf); |
1642 | 478 | cairo_destroy (dots_cr); | 699 | cairo_destroy (dots_cr); |
1643 | 479 | 700 | ||
1644 | 480 | // draw highlight | 701 | // draw highlight |
1645 | 481 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); | 702 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
1646 | 482 | hl_pattern = cairo_pattern_create_radial (hl_x, | 703 | hl_pattern = cairo_pattern_create_radial (hl_x, |
1647 | 483 | hl_y, | 704 | hl_y, |
1648 | 484 | 0.0f, | 705 | 0.0f, |
1649 | 485 | hl_x, | 706 | hl_x, |
1650 | 486 | hl_y, | 707 | hl_y, |
1651 | 487 | hl_size); | 708 | hl_size); |
1652 | 488 | cairo_pattern_add_color_stop_rgba (hl_pattern, | 709 | cairo_pattern_add_color_stop_rgba (hl_pattern, |
1653 | 489 | 0.0f, | 710 | 0.0f, |
1654 | 490 | 1.0f, | 711 | 1.0f, |
1655 | 491 | 1.0f, | 712 | 1.0f, |
1656 | 492 | 1.0f, | 713 | 1.0f, |
1657 | 493 | 0.65f); | 714 | 0.65f); |
1658 | 494 | cairo_pattern_add_color_stop_rgba (hl_pattern, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f); | 715 | cairo_pattern_add_color_stop_rgba (hl_pattern, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f); |
1659 | 495 | cairo_set_source (cr, hl_pattern); | 716 | cairo_set_source (cr, hl_pattern); |
1660 | 496 | cairo_fill (cr); | 717 | cairo_fill (cr); |
1661 | 497 | cairo_pattern_destroy (hl_pattern); | 718 | cairo_pattern_destroy (hl_pattern); |
1662 | 498 | } | 719 | } |
1663 | 499 | 720 | ||
1664 | 500 | void ql_setup (cairo_surface_t** surf, | 721 | void ql_setup (cairo_surface_t** surf, |
1665 | 501 | cairo_t** cr, | 722 | cairo_t** cr, |
1666 | 502 | gboolean outline, | 723 | gboolean outline, |
1667 | 503 | gint width, | 724 | gint width, |
1668 | 504 | gint height, | 725 | gint height, |
1669 | 505 | gboolean negative) | 726 | gboolean negative) |
1670 | 506 | { | 727 | { |
1671 | 507 | // // create context | 728 | // // create context |
1672 | 508 | // if (outline) | 729 | // if (outline) |
1673 | 509 | // *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); | 730 | // *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); |
1674 | @@ -511,401 +732,423 @@ | |||
1675 | 511 | // *surf = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); | 732 | // *surf = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); |
1676 | 512 | // *cr = cairo_create (*surf); | 733 | // *cr = cairo_create (*surf); |
1677 | 513 | 734 | ||
1682 | 514 | // clear context | 735 | // clear context |
1683 | 515 | cairo_scale (*cr, 1.0f, 1.0f); | 736 | cairo_scale (*cr, 1.0f, 1.0f); |
1684 | 516 | if (outline) | 737 | if (outline) |
1685 | 517 | { | 738 | { |
1686 | 739 | cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f); | ||
1687 | 740 | cairo_set_operator (*cr, CAIRO_OPERATOR_CLEAR); | ||
1688 | 741 | } | ||
1689 | 742 | else | ||
1690 | 743 | { | ||
1691 | 744 | cairo_set_operator (*cr, CAIRO_OPERATOR_OVER); | ||
1692 | 745 | if (negative) | ||
1693 | 518 | cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f); | 746 | cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f); |
1839 | 519 | cairo_set_operator (*cr, CAIRO_OPERATOR_CLEAR); | 747 | else |
1840 | 520 | } | 748 | cairo_set_source_rgba (*cr, 1.0f, 1.0f, 1.0f, 1.0f); |
1841 | 521 | else | 749 | } |
1842 | 522 | { | 750 | cairo_paint (*cr); |
1843 | 523 | cairo_set_operator (*cr, CAIRO_OPERATOR_OVER); | 751 | } |
1844 | 524 | if (negative) | 752 | |
1845 | 525 | cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f); | 753 | void ql_compute_full_mask_path (cairo_t* cr, |
1846 | 526 | else | 754 | gfloat anchor_width, |
1847 | 527 | cairo_set_source_rgba (*cr, 1.0f, 1.0f, 1.0f, 1.0f); | 755 | gfloat anchor_height, |
1848 | 528 | } | 756 | gint width, |
1849 | 529 | cairo_paint (*cr); | 757 | gint height, |
1850 | 530 | } | 758 | gint upper_size, |
1851 | 531 | 759 | gfloat radius, | |
1852 | 532 | void ql_compute_full_mask_path (cairo_t* cr, | 760 | guint pad) |
1853 | 533 | gfloat anchor_width, | 761 | { |
1854 | 534 | gfloat anchor_height, | 762 | // 0 1 2 3 |
1855 | 535 | gint width, | 763 | // +--+--------+--+ |
1856 | 536 | gint height, | 764 | // | | |
1857 | 537 | gint upper_size, | 765 | // + 14 + 4 |
1858 | 538 | gfloat radius, | 766 | // | | |
1859 | 539 | guint pad) | 767 | // | | |
1860 | 540 | { | 768 | // | | |
1861 | 541 | // 0 1 2 3 | 769 | // + 13 | |
1862 | 542 | // +--+--------+--+ | 770 | // / | |
1863 | 543 | // | | | 771 | // / | |
1864 | 544 | // + 14 + 4 | 772 | // + 12 | |
1865 | 545 | // | | | 773 | // \ | |
1866 | 546 | // | | | 774 | // \ | |
1867 | 547 | // | | | 775 | // 11 + | |
1868 | 548 | // + 13 | | 776 | // | | |
1869 | 549 | // / | | 777 | // | | |
1870 | 550 | // / | | 778 | // | | |
1871 | 551 | // + 12 | | 779 | // 10 + + 5 |
1872 | 552 | // \ | | 780 | // | | |
1873 | 553 | // \ | | 781 | // +--+--------+--+ 6 |
1874 | 554 | // 11 + | | 782 | // 9 8 7 |
1875 | 555 | // | | | 783 | |
1876 | 556 | // | | | 784 | |
1877 | 557 | // | | | 785 | gfloat padding = pad; |
1878 | 558 | // 10 + + 5 | 786 | int ZEROPOINT5 = 0.0f; |
1879 | 559 | // | | | 787 | |
1880 | 560 | // +--+--------+--+ 6 | 788 | gfloat HeightToAnchor = 0.0f; |
1881 | 561 | // 9 8 7 | 789 | HeightToAnchor = ((gfloat) height - 2.0f * radius - anchor_height -2*padding) / 2.0f; |
1882 | 562 | 790 | if (HeightToAnchor < 0.0f) | |
1883 | 563 | 791 | { | |
1884 | 564 | gfloat padding = pad; | 792 | g_warning ("Anchor-height and corner-radius a higher than whole texture!"); |
1885 | 565 | int ZEROPOINT5 = 0.0f; | 793 | return; |
1886 | 566 | 794 | } | |
1887 | 567 | gfloat HeightToAnchor = 0.0f; | 795 | |
1888 | 568 | HeightToAnchor = ((gfloat) height - 2.0f * radius - anchor_height -2*padding) / 2.0f; | 796 | //gint dynamic_size = height - 2*radius - 2*padding - anchor_height; |
1889 | 569 | if (HeightToAnchor < 0.0f) | 797 | //gint upper_dynamic_size = upper_size; |
1890 | 570 | { | 798 | //gint lower_dynamic_size = dynamic_size - upper_dynamic_size; |
1891 | 571 | g_warning ("Anchor-height and corner-radius a higher than whole texture!"); | 799 | |
1892 | 572 | return; | 800 | if(upper_size >= 0) |
1893 | 573 | } | 801 | { |
1894 | 574 | 802 | if(upper_size > height - 2.0f * radius - anchor_height -2 * padding) | |
1895 | 575 | //gint dynamic_size = height - 2*radius - 2*padding - anchor_height; | 803 | { |
1896 | 576 | //gint upper_dynamic_size = upper_size; | 804 | //g_warning ("[_compute_full_mask_path] incorrect upper_size value"); |
1897 | 577 | //gint lower_dynamic_size = dynamic_size - upper_dynamic_size; | 805 | HeightToAnchor = 0; |
1898 | 578 | 806 | } | |
1899 | 579 | if(upper_size >= 0) | 807 | else |
1900 | 580 | { | 808 | { |
1901 | 581 | if(upper_size > height - 2.0f * radius - anchor_height -2 * padding) | 809 | HeightToAnchor = height - 2.0f * radius - anchor_height -2 * padding - upper_size; |
1902 | 582 | { | 810 | } |
1903 | 583 | //g_warning ("[_compute_full_mask_path] incorrect upper_size value"); | 811 | } |
1904 | 584 | HeightToAnchor = 0; | 812 | else |
1905 | 585 | } | 813 | { |
1906 | 586 | else | 814 | HeightToAnchor = (height - 2.0f * radius - anchor_height -2*padding) / 2.0f; |
1907 | 587 | { | 815 | } |
1908 | 588 | HeightToAnchor = height - 2.0f * radius - anchor_height -2 * padding - upper_size; | 816 | |
1909 | 589 | } | 817 | cairo_translate (cr, -0.5f, -0.5f); |
1910 | 590 | } | 818 | |
1911 | 591 | else | 819 | // create path |
1912 | 592 | { | 820 | cairo_move_to (cr, padding + anchor_width + radius + ZEROPOINT5, padding + ZEROPOINT5); // Point 1 |
1913 | 593 | HeightToAnchor = (height - 2.0f * radius - anchor_height -2*padding) / 2.0f; | 821 | cairo_line_to (cr, width - padding - radius, padding + ZEROPOINT5); // Point 2 |
1914 | 594 | } | 822 | cairo_arc (cr, |
1915 | 595 | 823 | width - padding - radius + ZEROPOINT5, | |
1916 | 596 | cairo_translate (cr, -0.5f, -0.5f); | 824 | padding + radius + ZEROPOINT5, |
1917 | 597 | 825 | radius, | |
1918 | 598 | // create path | 826 | -90.0f * G_PI / 180.0f, |
1919 | 599 | cairo_move_to (cr, padding + anchor_width + radius + ZEROPOINT5, padding + ZEROPOINT5); // Point 1 | 827 | 0.0f * G_PI / 180.0f); // Point 4 |
1920 | 600 | cairo_line_to (cr, width - padding - radius, padding + ZEROPOINT5); // Point 2 | 828 | cairo_line_to (cr, |
1921 | 601 | cairo_arc (cr, | 829 | (gdouble) width - padding + ZEROPOINT5, |
1922 | 602 | width - padding - radius + ZEROPOINT5, | 830 | (gdouble) height - radius - padding + ZEROPOINT5); // Point 5 |
1923 | 603 | padding + radius + ZEROPOINT5, | 831 | cairo_arc (cr, |
1924 | 604 | radius, | 832 | (gdouble) width - padding - radius + ZEROPOINT5, |
1925 | 605 | -90.0f * G_PI / 180.0f, | 833 | (gdouble) height - padding - radius + ZEROPOINT5, |
1926 | 606 | 0.0f * G_PI / 180.0f); // Point 4 | 834 | radius, |
1927 | 607 | cairo_line_to (cr, | 835 | 0.0f * G_PI / 180.0f, |
1928 | 608 | (gdouble) width - padding + ZEROPOINT5, | 836 | 90.0f * G_PI / 180.0f); // Point 7 |
1929 | 609 | (gdouble) height - radius - padding + ZEROPOINT5); // Point 5 | 837 | cairo_line_to (cr, |
1930 | 610 | cairo_arc (cr, | 838 | anchor_width + padding + radius + ZEROPOINT5, |
1931 | 611 | (gdouble) width - padding - radius + ZEROPOINT5, | 839 | (gdouble) height - padding + ZEROPOINT5); // Point 8 |
1932 | 612 | (gdouble) height - padding - radius + ZEROPOINT5, | 840 | |
1933 | 613 | radius, | 841 | cairo_arc (cr, |
1934 | 614 | 0.0f * G_PI / 180.0f, | 842 | anchor_width + padding + radius + ZEROPOINT5, |
1935 | 615 | 90.0f * G_PI / 180.0f); // Point 7 | 843 | (gdouble) height - padding - radius, |
1936 | 616 | cairo_line_to (cr, | 844 | radius, |
1937 | 617 | anchor_width + padding + radius + ZEROPOINT5, | 845 | 90.0f * G_PI / 180.0f, |
1938 | 618 | (gdouble) height - padding + ZEROPOINT5); // Point 8 | 846 | 180.0f * G_PI / 180.0f); // Point 10 |
1939 | 619 | 847 | ||
1940 | 620 | cairo_arc (cr, | 848 | cairo_line_to (cr, |
1941 | 621 | anchor_width + padding + radius + ZEROPOINT5, | 849 | padding + anchor_width + ZEROPOINT5, |
1942 | 622 | (gdouble) height - padding - radius, | 850 | (gdouble) height - padding - radius - HeightToAnchor + ZEROPOINT5 ); // Point 11 |
1943 | 623 | radius, | 851 | cairo_line_to (cr, |
1944 | 624 | 90.0f * G_PI / 180.0f, | 852 | padding + ZEROPOINT5, |
1945 | 625 | 180.0f * G_PI / 180.0f); // Point 10 | 853 | (gdouble) height - padding - radius - HeightToAnchor - anchor_height / 2.0f + ZEROPOINT5); // Point 12 |
1946 | 626 | 854 | cairo_line_to (cr, | |
1947 | 627 | cairo_line_to (cr, | 855 | padding + anchor_width + ZEROPOINT5, |
1948 | 628 | padding + anchor_width + ZEROPOINT5, | 856 | (gdouble) height - padding - radius - HeightToAnchor - anchor_height + ZEROPOINT5); // Point 13 |
1949 | 629 | (gdouble) height - padding - radius - HeightToAnchor + ZEROPOINT5 ); // Point 11 | 857 | |
1950 | 630 | cairo_line_to (cr, | 858 | cairo_line_to (cr, padding + anchor_width + ZEROPOINT5, padding + radius + ZEROPOINT5); // Point 14 |
1951 | 631 | padding + ZEROPOINT5, | 859 | cairo_arc (cr, |
1952 | 632 | (gdouble) height - padding - radius - HeightToAnchor - anchor_height / 2.0f + ZEROPOINT5); // Point 12 | 860 | padding + anchor_width + radius + ZEROPOINT5, |
1953 | 633 | cairo_line_to (cr, | 861 | padding + radius + ZEROPOINT5, |
1954 | 634 | padding + anchor_width + ZEROPOINT5, | 862 | radius, |
1955 | 635 | (gdouble) height - padding - radius - HeightToAnchor - anchor_height + ZEROPOINT5); // Point 13 | 863 | 180.0f * G_PI / 180.0f, |
1956 | 636 | 864 | 270.0f * G_PI / 180.0f); | |
1957 | 637 | cairo_line_to (cr, padding + anchor_width + ZEROPOINT5, padding + radius + ZEROPOINT5); // Point 14 | 865 | |
1958 | 638 | cairo_arc (cr, | 866 | cairo_close_path (cr); |
1959 | 639 | padding + anchor_width + radius + ZEROPOINT5, | 867 | } |
1960 | 640 | padding + radius + ZEROPOINT5, | 868 | |
1961 | 641 | radius, | 869 | void ql_compute_mask (cairo_t* cr) |
1962 | 642 | 180.0f * G_PI / 180.0f, | 870 | { |
1963 | 643 | 270.0f * G_PI / 180.0f); | 871 | cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); |
1964 | 644 | 872 | cairo_fill_preserve (cr); | |
1965 | 645 | cairo_close_path (cr); | 873 | } |
1966 | 646 | } | 874 | |
1967 | 647 | 875 | void ql_compute_outline (cairo_t* cr, | |
1968 | 648 | void ql_compute_mask (cairo_t* cr) | 876 | gfloat line_width, |
1969 | 649 | { | 877 | gfloat* rgba_line) |
1970 | 650 | cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); | 878 | { |
1971 | 651 | cairo_fill_preserve (cr); | 879 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); |
1972 | 652 | } | 880 | cairo_set_source_rgba (cr, |
1973 | 653 | 881 | rgba_line[0], | |
1974 | 654 | void ql_compute_outline (cairo_t* cr, | 882 | rgba_line[1], |
1975 | 655 | gfloat line_width, | 883 | rgba_line[2], |
1976 | 656 | gfloat* rgba_line) | 884 | rgba_line[3]); |
1977 | 657 | { | 885 | cairo_set_line_width (cr, line_width); |
1978 | 658 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); | 886 | cairo_stroke (cr); |
1979 | 659 | cairo_set_source_rgba (cr, | 887 | } |
1980 | 660 | rgba_line[0], | 888 | |
1981 | 661 | rgba_line[1], | 889 | void ql_draw (cairo_t* cr, |
1982 | 662 | rgba_line[2], | 890 | gboolean outline, |
1983 | 663 | rgba_line[3]); | 891 | gfloat line_width, |
1984 | 892 | gfloat* rgba, | ||
1985 | 893 | gboolean negative, | ||
1986 | 894 | gboolean stroke) | ||
1987 | 895 | { | ||
1988 | 896 | // prepare drawing | ||
1989 | 897 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); | ||
1990 | 898 | |||
1991 | 899 | // actually draw the mask | ||
1992 | 900 | if (outline) | ||
1993 | 901 | { | ||
1994 | 664 | cairo_set_line_width (cr, line_width); | 902 | cairo_set_line_width (cr, line_width); |
2242 | 665 | cairo_stroke (cr); | 903 | cairo_set_source_rgba (cr, rgba[0], rgba[1], rgba[2], rgba[3]); |
2243 | 666 | } | 904 | } |
2244 | 667 | 905 | else | |
2245 | 668 | void ql_draw (cairo_t* cr, | 906 | { |
2246 | 669 | gboolean outline, | 907 | if (negative) |
2247 | 670 | gfloat line_width, | 908 | cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f); |
2248 | 671 | gfloat* rgba, | 909 | else |
2249 | 672 | gboolean negative, | 910 | cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f); |
2250 | 673 | gboolean stroke) | 911 | } |
2251 | 674 | { | 912 | |
2252 | 675 | // prepare drawing | 913 | // stroke or fill? |
2253 | 676 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); | 914 | if (stroke) |
2254 | 677 | 915 | cairo_stroke_preserve (cr); | |
2255 | 678 | // actually draw the mask | 916 | else |
2256 | 679 | if (outline) | 917 | cairo_fill_preserve (cr); |
2257 | 680 | { | 918 | } |
2258 | 681 | cairo_set_line_width (cr, line_width); | 919 | |
2259 | 682 | cairo_set_source_rgba (cr, rgba[0], rgba[1], rgba[2], rgba[3]); | 920 | void ql_finalize (cairo_t** cr, |
2260 | 683 | } | 921 | gboolean outline, |
2261 | 684 | else | 922 | gfloat line_width, |
2262 | 685 | { | 923 | gfloat* rgba, |
2263 | 686 | if (negative) | 924 | gboolean negative, |
2264 | 687 | cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f); | 925 | gboolean stroke) |
2265 | 688 | else | 926 | { |
2266 | 689 | cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f); | 927 | // prepare drawing |
2267 | 690 | } | 928 | cairo_set_operator (*cr, CAIRO_OPERATOR_SOURCE); |
2268 | 691 | 929 | ||
2269 | 692 | // stroke or fill? | 930 | // actually draw the mask |
2270 | 693 | if (stroke) | 931 | if (outline) |
2271 | 694 | cairo_stroke_preserve (cr); | 932 | { |
2272 | 695 | else | 933 | cairo_set_line_width (*cr, line_width); |
2273 | 696 | cairo_fill_preserve (cr); | 934 | cairo_set_source_rgba (*cr, rgba[0], rgba[1], rgba[2], rgba[3]); |
2274 | 697 | } | 935 | } |
2275 | 698 | 936 | else | |
2276 | 699 | void ql_finalize (cairo_t** cr, | 937 | { |
2277 | 700 | gboolean outline, | 938 | if (negative) |
2278 | 701 | gfloat line_width, | 939 | cairo_set_source_rgba (*cr, 1.0f, 1.0f, 1.0f, 1.0f); |
2279 | 702 | gfloat* rgba, | 940 | else |
2280 | 703 | gboolean negative, | 941 | cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f); |
2281 | 704 | gboolean stroke) | 942 | } |
2282 | 705 | { | 943 | |
2283 | 706 | // prepare drawing | 944 | // stroke or fill? |
2284 | 707 | cairo_set_operator (*cr, CAIRO_OPERATOR_SOURCE); | 945 | if (stroke) |
2285 | 708 | 946 | cairo_stroke (*cr); | |
2286 | 709 | // actually draw the mask | 947 | else |
2287 | 710 | if (outline) | 948 | cairo_fill (*cr); |
2288 | 711 | { | 949 | } |
2289 | 712 | cairo_set_line_width (*cr, line_width); | 950 | |
2290 | 713 | cairo_set_source_rgba (*cr, rgba[0], rgba[1], rgba[2], rgba[3]); | 951 | void |
2291 | 714 | } | 952 | ql_compute_full_outline_shadow ( |
2292 | 715 | else | 953 | cairo_t* cr, |
2293 | 716 | { | 954 | cairo_surface_t* surf, |
2294 | 717 | if (negative) | 955 | gint width, |
2295 | 718 | cairo_set_source_rgba (*cr, 1.0f, 1.0f, 1.0f, 1.0f); | 956 | gint height, |
2296 | 719 | else | 957 | gfloat anchor_width, |
2297 | 720 | cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f); | 958 | gfloat anchor_height, |
2298 | 721 | } | 959 | gint upper_size, |
2299 | 722 | 960 | gfloat corner_radius, | |
2300 | 723 | // stroke or fill? | 961 | guint blur_coeff, |
2301 | 724 | if (stroke) | 962 | gfloat* rgba_shadow, |
2302 | 725 | cairo_stroke (*cr); | 963 | gfloat line_width, |
2303 | 726 | else | 964 | gint padding_size, |
2304 | 727 | cairo_fill (*cr); | 965 | gfloat* rgba_line) |
2305 | 728 | } | 966 | { |
2306 | 729 | 967 | ql_setup (&surf, &cr, TRUE, width, height, FALSE); | |
2307 | 730 | void | 968 | ql_compute_full_mask_path (cr, |
2308 | 731 | ql_compute_full_outline_shadow ( | 969 | anchor_width, |
2309 | 732 | cairo_t* cr, | 970 | anchor_height, |
2310 | 733 | cairo_surface_t* surf, | 971 | width, |
2311 | 734 | gint width, | 972 | height, |
2312 | 735 | gint height, | 973 | upper_size, |
2313 | 736 | gfloat anchor_width, | 974 | corner_radius, |
2314 | 737 | gfloat anchor_height, | 975 | padding_size); |
2315 | 738 | gint upper_size, | 976 | |
2316 | 739 | gfloat corner_radius, | 977 | ql_draw (cr, TRUE, line_width, rgba_shadow, FALSE, FALSE); |
2317 | 740 | guint blur_coeff, | 978 | ql_surface_blur (surf, blur_coeff); |
2318 | 741 | gfloat* rgba_shadow, | 979 | ql_compute_mask (cr); |
2319 | 742 | gfloat line_width, | 980 | ql_compute_outline (cr, line_width, rgba_line); |
2320 | 743 | gint padding_size, | 981 | } |
2321 | 744 | gfloat* rgba_line) | 982 | |
2322 | 745 | { | 983 | void ql_compute_full_mask ( |
2323 | 746 | ql_setup (&surf, &cr, TRUE, width, height, FALSE); | 984 | cairo_t* cr, |
2324 | 747 | ql_compute_full_mask_path (cr, | 985 | cairo_surface_t* surf, |
2325 | 748 | anchor_width, | 986 | gint width, |
2326 | 749 | anchor_height, | 987 | gint height, |
2327 | 750 | width, | 988 | gfloat radius, |
2328 | 751 | height, | 989 | guint shadow_radius, |
2329 | 752 | upper_size, | 990 | gfloat anchor_width, |
2330 | 753 | corner_radius, | 991 | gfloat anchor_height, |
2331 | 754 | padding_size); | 992 | gint upper_size, |
2332 | 755 | 993 | gboolean negative, | |
2333 | 756 | ql_draw (cr, TRUE, line_width, rgba_shadow, FALSE, FALSE); | 994 | gboolean outline, |
2334 | 757 | ql_surface_blur (surf, blur_coeff); | 995 | gfloat line_width, |
2335 | 758 | ql_compute_mask (cr); | 996 | gint padding_size, |
2336 | 759 | ql_compute_outline (cr, line_width, rgba_line); | 997 | gfloat* rgba) |
2337 | 760 | } | 998 | { |
2338 | 761 | 999 | ql_setup (&surf, &cr, outline, width, height, negative); | |
2339 | 762 | void ql_compute_full_mask ( | 1000 | ql_compute_full_mask_path (cr, |
2340 | 763 | cairo_t* cr, | 1001 | anchor_width, |
2341 | 764 | cairo_surface_t* surf, | 1002 | anchor_height, |
2342 | 765 | gint width, | 1003 | width, |
2343 | 766 | gint height, | 1004 | height, |
2344 | 767 | gfloat radius, | 1005 | upper_size, |
2345 | 768 | guint shadow_radius, | 1006 | radius, |
2346 | 769 | gfloat anchor_width, | 1007 | padding_size); |
2347 | 770 | gfloat anchor_height, | 1008 | ql_finalize (&cr, outline, line_width, rgba, negative, outline); |
2348 | 771 | gint upper_size, | 1009 | } |
2349 | 772 | gboolean negative, | 1010 | |
2350 | 773 | gboolean outline, | 1011 | void QuicklistView::UpdateTexture () |
2351 | 774 | gfloat line_width, | 1012 | { |
2352 | 775 | gint padding_size, | 1013 | if (_cairo_text_has_changed == false) |
2353 | 776 | gfloat* rgba) | 1014 | return; |
2354 | 777 | { | 1015 | |
2355 | 778 | ql_setup (&surf, &cr, outline, width, height, negative); | 1016 | int size_above_anchor = -1; // equal to sise below |
2356 | 779 | ql_compute_full_mask_path (cr, | 1017 | |
2357 | 780 | anchor_width, | 1018 | if ((_item_list.size () != 0) || (_default_item_list.size () != 0)) |
2358 | 781 | anchor_height, | 1019 | { |
2359 | 782 | width, | 1020 | _top_size = 4; |
2360 | 783 | height, | 1021 | size_above_anchor = _top_size; |
2361 | 784 | upper_size, | 1022 | int x = _anchorX - _padding; |
2362 | 785 | radius, | 1023 | int y = _anchorY - _anchor_height/2 - _top_size - _corner_radius - _padding; |
2363 | 786 | padding_size); | 1024 | |
2364 | 787 | ql_finalize (&cr, outline, line_width, rgba, negative, outline); | 1025 | SetBaseX (x); |
2365 | 788 | } | 1026 | SetBaseY (y); |
2366 | 789 | 1027 | } | |
2367 | 790 | void QuicklistView::UpdateTexture () | 1028 | else |
2368 | 791 | { | 1029 | { |
2369 | 792 | if (_cairo_text_has_changed == false) | 1030 | _top_size = 0; |
2370 | 793 | return; | 1031 | size_above_anchor = -1; |
2371 | 794 | 1032 | int x = _anchorX - _padding; | |
2372 | 795 | float blur_coef = 6.0f; | 1033 | int y = _anchorY - _anchor_height/2 - _top_size - _corner_radius - _padding; |
2373 | 796 | 1034 | ||
2374 | 797 | CairoGraphics* cairo_bg = new CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); | 1035 | SetBaseX (x); |
2375 | 798 | CairoGraphics* cairo_mask = new CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); | 1036 | SetBaseY (y); |
2376 | 799 | CairoGraphics* cairo_outline = new CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); | 1037 | } |
2377 | 800 | 1038 | ||
2378 | 801 | cairo_t *cr_bg = cairo_bg->GetContext (); | 1039 | float blur_coef = 6.0f; |
2379 | 802 | cairo_t *cr_mask = cairo_mask->GetContext (); | 1040 | |
2380 | 803 | cairo_t *cr_outline = cairo_outline->GetContext (); | 1041 | nux::CairoGraphics* cairo_bg = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); |
2381 | 804 | 1042 | nux::CairoGraphics* cairo_mask = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); | |
2382 | 805 | float tint_color[4] = {0.0f, 0.0f, 0.0f, 0.80f}; | 1043 | nux::CairoGraphics* cairo_outline = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); |
2383 | 806 | float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.15f}; | 1044 | |
2384 | 807 | float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.20f}; | 1045 | cairo_t *cr_bg = cairo_bg->GetContext (); |
2385 | 808 | float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f}; | 1046 | cairo_t *cr_mask = cairo_mask->GetContext (); |
2386 | 809 | float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.75f}; | 1047 | cairo_t *cr_outline = cairo_outline->GetContext (); |
2387 | 810 | float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f}; | 1048 | |
2388 | 811 | float anchor_width = 10; | 1049 | float tint_color[4] = {0.0f, 0.0f, 0.0f, 0.80f}; |
2389 | 812 | float anchor_height = 18; | 1050 | float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.15f}; |
2390 | 813 | 1051 | float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.20f}; | |
2391 | 814 | ql_tint_dot_hl (cr_bg, | 1052 | float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f}; |
2392 | 815 | GetBaseWidth (), | 1053 | float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.75f}; |
2393 | 816 | GetBaseHeight (), | 1054 | float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f}; |
2394 | 817 | GetBaseWidth () / 2.0f, | 1055 | // float anchor_width = 10; |
2395 | 818 | 0, | 1056 | // float anchor_height = 18; |
2396 | 819 | Max<float>(GetBaseWidth () / 1.3f, GetBaseHeight () / 1.3f), | 1057 | |
2397 | 820 | tint_color, | 1058 | ql_tint_dot_hl (cr_bg, |
2398 | 821 | hl_color, | 1059 | GetBaseWidth (), |
2399 | 822 | dot_color); | 1060 | GetBaseHeight (), |
2400 | 823 | 1061 | GetBaseWidth () / 2.0f, | |
2401 | 824 | ql_compute_full_outline_shadow | 1062 | 0, |
2402 | 825 | ( | 1063 | nux::Max<float>(GetBaseWidth () / 1.3f, GetBaseHeight () / 1.3f), |
2403 | 826 | cr_outline, | 1064 | tint_color, |
2404 | 827 | cairo_outline->GetSurface(), | 1065 | hl_color, |
2405 | 828 | GetBaseWidth (), | 1066 | dot_color); |
2406 | 829 | GetBaseHeight (), | 1067 | |
2407 | 830 | anchor_width, | 1068 | ql_compute_full_outline_shadow |
2408 | 831 | anchor_height, | 1069 | ( |
2409 | 832 | -1, | 1070 | cr_outline, |
2410 | 833 | _corner_radius, | 1071 | cairo_outline->GetSurface(), |
2411 | 834 | blur_coef, | 1072 | GetBaseWidth (), |
2412 | 835 | shadow_color, | 1073 | GetBaseHeight (), |
2413 | 836 | 1.0f, | 1074 | _anchor_width, |
2414 | 837 | _padding, | 1075 | _anchor_height, |
2415 | 838 | outline_color); | 1076 | size_above_anchor, |
2416 | 839 | 1077 | _corner_radius, | |
2417 | 840 | ql_compute_full_mask ( | 1078 | blur_coef, |
2418 | 841 | cr_mask, | 1079 | shadow_color, |
2419 | 842 | cairo_mask->GetSurface(), | 1080 | 1.0f, |
2420 | 843 | GetBaseWidth (), | 1081 | _padding, |
2421 | 844 | GetBaseHeight(), | 1082 | outline_color); |
2422 | 845 | _corner_radius, // radius, | 1083 | |
2423 | 846 | 16, // shadow_radius, | 1084 | ql_compute_full_mask ( |
2424 | 847 | anchor_width, // anchor_width, | 1085 | cr_mask, |
2425 | 848 | anchor_height, // anchor_height, | 1086 | cairo_mask->GetSurface(), |
2426 | 849 | -1, // upper_size, | 1087 | GetBaseWidth (), |
2427 | 850 | true, // negative, | 1088 | GetBaseHeight(), |
2428 | 851 | false, // outline, | 1089 | _corner_radius, // radius, |
2429 | 852 | 1.0, // line_width, | 1090 | 16, // shadow_radius, |
2430 | 853 | _padding, // padding_size, | 1091 | _anchor_width, // anchor_width, |
2431 | 854 | mask_color); | 1092 | _anchor_height, // anchor_height, |
2432 | 855 | 1093 | size_above_anchor, // upper_size, | |
2433 | 856 | cairo_destroy (cr_bg); | 1094 | true, // negative, |
2434 | 857 | cairo_destroy (cr_outline); | 1095 | false, // outline, |
2435 | 858 | cairo_destroy (cr_mask); | 1096 | 1.0, // line_width, |
2436 | 859 | 1097 | _padding, // padding_size, | |
2437 | 860 | NBitmapData* bitmap = cairo_bg->GetBitmap(); | 1098 | mask_color); |
2438 | 861 | 1099 | ||
2439 | 862 | if (_texture_bg) | 1100 | cairo_destroy (cr_bg); |
2440 | 863 | _texture_bg->UnReference (); | 1101 | cairo_destroy (cr_outline); |
2441 | 864 | _texture_bg = GetThreadGLDeviceFactory()->CreateSystemCapableTexture (); | 1102 | cairo_destroy (cr_mask); |
2442 | 865 | _texture_bg->Update(bitmap); | 1103 | |
2443 | 866 | delete bitmap; | 1104 | nux::NBitmapData* bitmap = cairo_bg->GetBitmap(); |
2444 | 867 | 1105 | ||
2445 | 868 | bitmap = cairo_mask->GetBitmap(); | 1106 | if (_texture_bg) |
2446 | 869 | if (_texture_mask) | 1107 | _texture_bg->UnReference (); |
2447 | 870 | _texture_mask->UnReference (); | 1108 | _texture_bg = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture (); |
2448 | 871 | _texture_mask = GetThreadGLDeviceFactory()->CreateSystemCapableTexture (); | 1109 | _texture_bg->Update(bitmap); |
2449 | 872 | _texture_mask->Update(bitmap); | 1110 | delete bitmap; |
2450 | 873 | delete bitmap; | 1111 | |
2451 | 874 | 1112 | bitmap = cairo_mask->GetBitmap(); | |
2452 | 875 | bitmap = cairo_outline->GetBitmap(); | 1113 | if (_texture_mask) |
2453 | 876 | if (_texture_outline) | 1114 | _texture_mask->UnReference (); |
2454 | 877 | _texture_outline->UnReference (); | 1115 | _texture_mask = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture (); |
2455 | 878 | _texture_outline = GetThreadGLDeviceFactory()->CreateSystemCapableTexture (); | 1116 | _texture_mask->Update(bitmap); |
2456 | 879 | _texture_outline->Update(bitmap); | 1117 | delete bitmap; |
2457 | 880 | delete bitmap; | 1118 | |
2458 | 881 | 1119 | bitmap = cairo_outline->GetBitmap(); | |
2459 | 882 | delete cairo_bg; | 1120 | if (_texture_outline) |
2460 | 883 | delete cairo_mask; | 1121 | _texture_outline->UnReference (); |
2461 | 884 | delete cairo_outline; | 1122 | _texture_outline = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture (); |
2462 | 885 | _cairo_text_has_changed = false; | 1123 | _texture_outline->Update(bitmap); |
2463 | 886 | } | 1124 | delete bitmap; |
2464 | 887 | 1125 | ||
2465 | 888 | void QuicklistView::PositionChildLayout (float offsetX, | 1126 | delete cairo_bg; |
2466 | 889 | float offsetY) | 1127 | delete cairo_mask; |
2467 | 890 | { | 1128 | delete cairo_outline; |
2468 | 891 | } | 1129 | _cairo_text_has_changed = false; |
2469 | 892 | 1130 | ||
2470 | 893 | void QuicklistView::LayoutWindowElements () | 1131 | // Request a redraw, so this area will be added to Compiz list of dirty areas. |
2471 | 894 | { | 1132 | NeedRedraw (); |
2472 | 895 | } | 1133 | } |
2473 | 896 | 1134 | ||
2474 | 897 | void QuicklistView::NotifyConfigurationChange (int width, | 1135 | void QuicklistView::PositionChildLayout (float offsetX, float offsetY) |
2475 | 898 | int height) | 1136 | { |
2476 | 899 | { | 1137 | } |
2477 | 900 | } | 1138 | |
2478 | 901 | 1139 | void QuicklistView::LayoutWindowElements () | |
2479 | 902 | void QuicklistView::SetText (NString text) | 1140 | { |
2480 | 903 | { | 1141 | } |
2481 | 904 | if (_labelText == text) | 1142 | |
2482 | 905 | return; | 1143 | void QuicklistView::NotifyConfigurationChange (int width, int height) |
2483 | 906 | 1144 | { | |
2484 | 907 | _labelText = text; | 1145 | } |
2485 | 908 | UpdateTexture (); | 1146 | |
2486 | 909 | } | 1147 | void QuicklistView::SetText (nux::NString text) |
2487 | 910 | 1148 | { | |
2488 | 911 | } // namespace nux | 1149 | if (_labelText == text) |
2489 | 1150 | return; | ||
2490 | 1151 | |||
2491 | 1152 | _labelText = text; | ||
2492 | 1153 | UpdateTexture (); | ||
2493 | 1154 | } | ||
2494 | 912 | 1155 | ||
2495 | === modified file 'src/QuicklistView.h' | |||
2496 | --- src/QuicklistView.h 2010-11-11 10:46:30 +0000 | |||
2497 | +++ src/QuicklistView.h 2010-11-18 14:03:47 +0000 | |||
2498 | @@ -17,8 +17,8 @@ | |||
2499 | 17 | * Authored by: Mirco Müller <mirco.mueller@canonical.com | 17 | * Authored by: Mirco Müller <mirco.mueller@canonical.com |
2500 | 18 | */ | 18 | */ |
2501 | 19 | 19 | ||
2504 | 20 | #ifndef TOOLTIP_H | 20 | #ifndef QUICKLISTVIEW_H |
2505 | 21 | #define TOOLTIP_H | 21 | #define QUICKLISTVIEW_H |
2506 | 22 | 22 | ||
2507 | 23 | #include "Nux/Nux.h" | 23 | #include "Nux/Nux.h" |
2508 | 24 | #include "Nux/BaseWindow.h" | 24 | #include "Nux/BaseWindow.h" |
2509 | @@ -46,77 +46,92 @@ | |||
2510 | 46 | #define V_MARGIN 4 | 46 | #define V_MARGIN 4 |
2511 | 47 | #define FONT_FACE "Ubuntu 13" | 47 | #define FONT_FACE "Ubuntu 13" |
2512 | 48 | 48 | ||
2514 | 49 | namespace nux | 49 | |
2515 | 50 | class VLayout; | ||
2516 | 51 | class HLayout; | ||
2517 | 52 | class SpaceLayout; | ||
2518 | 53 | |||
2519 | 54 | class QuicklistView : public nux::BaseWindow | ||
2520 | 50 | { | 55 | { |
2592 | 51 | class VLayout; | 56 | NUX_DECLARE_OBJECT_TYPE (QuicklistView, nux::BaseWindow); |
2593 | 52 | class HLayout; | 57 | public: |
2594 | 53 | class SpaceLayout; | 58 | QuicklistView (); |
2595 | 54 | 59 | ||
2596 | 55 | class QuicklistView : public BaseWindow | 60 | ~QuicklistView (); |
2597 | 56 | { | 61 | |
2598 | 57 | NUX_DECLARE_OBJECT_TYPE (QuicklistView, BaseWindow); | 62 | long ProcessEvent (nux::IEvent& iEvent, |
2599 | 58 | public: | 63 | long traverseInfo, |
2600 | 59 | QuicklistView (); | 64 | long processEventInfo); |
2601 | 60 | 65 | ||
2602 | 61 | ~QuicklistView (); | 66 | void Draw (nux::GraphicsEngine& gfxContext, |
2603 | 62 | 67 | bool forceDraw); | |
2604 | 63 | long ProcessEvent (IEvent& iEvent, | 68 | |
2605 | 64 | long traverseInfo, | 69 | void DrawContent (nux::GraphicsEngine& gfxContext, |
2606 | 65 | long processEventInfo); | 70 | bool forceDraw); |
2607 | 66 | 71 | ||
2608 | 67 | void Draw (GraphicsEngine& gfxContext, | 72 | void SetText (nux::NString text); |
2609 | 68 | bool forceDraw); | 73 | |
2610 | 69 | 74 | void RemoveAllMenuItem (); | |
2611 | 70 | void DrawContent (GraphicsEngine& gfxContext, | 75 | void AddMenuItem (nux::NString str); |
2612 | 71 | bool forceDraw); | 76 | void RenderQuicklistView (); |
2613 | 72 | 77 | ||
2614 | 73 | void SetText (NString text); | 78 | void ShowQuicklistWithTipAt (int anchor_tip_x, int anchor_tip_y); |
2615 | 74 | 79 | virtual void ShowWindow (bool b, bool StartModal = false); | |
2616 | 75 | private: | 80 | |
2617 | 76 | void RecvCairoTextChanged (StaticCairoText& cairo_text); | 81 | private: |
2618 | 77 | 82 | void RecvCairoTextChanged (nux::StaticCairoText& cairo_text); | |
2619 | 78 | void PreLayoutManagement (); | 83 | void RecvCairoTextColorChanged (nux::StaticCairoText& cairo_text); |
2620 | 79 | 84 | ||
2621 | 80 | long PostLayoutManagement (long layoutResult); | 85 | void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); |
2622 | 81 | 86 | void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); | |
2623 | 82 | void PositionChildLayout (float offsetX, | 87 | void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags); |
2624 | 83 | float offsetY); | 88 | void RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
2625 | 84 | 89 | void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); | |
2626 | 85 | void LayoutWindowElements (); | 90 | void RecvMouseDownOutsideOfQuicklist (int x, int y, unsigned long button_flags, unsigned long key_flags); |
2627 | 86 | 91 | ||
2628 | 87 | void NotifyConfigurationChange (int width, | 92 | void PreLayoutManagement (); |
2629 | 88 | int height); | 93 | |
2630 | 89 | 94 | long PostLayoutManagement (long layoutResult); | |
2631 | 90 | //nux::CairoGraphics* _cairo_graphics; | 95 | |
2632 | 91 | int _anchorX; | 96 | void PositionChildLayout (float offsetX, float offsetY); |
2633 | 92 | int _anchorY; | 97 | |
2634 | 93 | nux::NString _labelText; | 98 | void LayoutWindowElements (); |
2635 | 94 | int _dpiX; | 99 | |
2636 | 95 | int _dpiY; | 100 | void NotifyConfigurationChange (int width, int height); |
2637 | 96 | 101 | ||
2638 | 97 | cairo_font_options_t* _fontOpts; | 102 | //nux::CairoGraphics* _cairo_graphics; |
2639 | 98 | 103 | int _anchorX; | |
2640 | 99 | nux::StaticCairoText* _tooltip_text; | 104 | int _anchorY; |
2641 | 100 | nux::BaseTexture* _texture_bg; | 105 | nux::NString _labelText; |
2642 | 101 | nux::BaseTexture* _texture_mask; | 106 | int _dpiX; |
2643 | 102 | nux::BaseTexture* _texture_outline; | 107 | int _dpiY; |
2644 | 103 | 108 | int _top_size; // size of the segment from point 13 to 14. See figure in ql_compute_full_mask_path. | |
2645 | 104 | float _anchor_width; | 109 | |
2646 | 105 | float _anchor_height; | 110 | cairo_font_options_t* _fontOpts; |
2647 | 106 | float _corner_radius; | 111 | |
2648 | 107 | float _padding; | 112 | nux::StaticCairoText* _tooltip_text; |
2649 | 108 | nux::HLayout *_hlayout; | 113 | nux::BaseTexture* _texture_bg; |
2650 | 109 | VLayout *_vlayout; | 114 | nux::BaseTexture* _texture_mask; |
2651 | 110 | nux::SpaceLayout *_left_space; //!< Space from the left of the widget to the left of the text. | 115 | nux::BaseTexture* _texture_outline; |
2652 | 111 | nux::SpaceLayout *_right_space; //!< Space from the right of the text to the right of the widget. | 116 | |
2653 | 112 | nux::SpaceLayout *_top_space; //!< Space from the left of the widget to the left of the text. | 117 | float _anchor_width; |
2654 | 113 | nux::SpaceLayout *_bottom_space; //!< Space from the right of the text to the right of the widget. | 118 | float _anchor_height; |
2655 | 114 | 119 | float _corner_radius; | |
2656 | 115 | bool _cairo_text_has_changed; | 120 | float _padding; |
2657 | 116 | void UpdateTexture (); | 121 | nux::HLayout *_hlayout; |
2658 | 117 | std::list<nux::StaticCairoText*> _item_list; | 122 | nux::VLayout *_vlayout; |
2659 | 118 | }; | 123 | nux::VLayout *_item_layout; |
2660 | 119 | } | 124 | nux::VLayout *_default_item_layout; |
2661 | 120 | 125 | nux::SpaceLayout *_left_space; //!< Space from the left of the widget to the left of the text. | |
2662 | 121 | #endif // TOOLTIP_H | 126 | nux::SpaceLayout *_right_space; //!< Space from the right of the text to the right of the widget. |
2663 | 127 | nux::SpaceLayout *_top_space; //!< Space from the left of the widget to the left of the text. | ||
2664 | 128 | nux::SpaceLayout *_bottom_space; //!< Space from the right of the text to the right of the widget. | ||
2665 | 129 | |||
2666 | 130 | bool _cairo_text_has_changed; | ||
2667 | 131 | void UpdateTexture (); | ||
2668 | 132 | std::list<nux::StaticCairoText*> _item_list; | ||
2669 | 133 | std::list<nux::StaticCairoText*> _default_item_list; | ||
2670 | 134 | }; | ||
2671 | 135 | |||
2672 | 136 | #endif // QUICKLISTVIEW_H | ||
2673 | 122 | 137 | ||
2674 | 123 | 138 | ||
2675 | === modified file 'src/StaticCairoText.cpp' | |||
2676 | --- src/StaticCairoText.cpp 2010-11-10 15:45:18 +0000 | |||
2677 | +++ src/StaticCairoText.cpp 2010-11-18 14:03:47 +0000 | |||
2678 | @@ -170,7 +170,7 @@ | |||
2679 | 170 | base.height, | 170 | base.height, |
2680 | 171 | _texture2D->GetDeviceTexture(), | 171 | _texture2D->GetDeviceTexture(), |
2681 | 172 | texxform, | 172 | texxform, |
2683 | 173 | Color(1.0f, 1.0f, 1.0f, 1.0f)); | 173 | _textColor); |
2684 | 174 | 174 | ||
2685 | 175 | gfxContext.GetRenderStates().SetBlend (false); | 175 | gfxContext.GetRenderStates().SetBlend (false); |
2686 | 176 | 176 | ||
2687 | @@ -252,8 +252,7 @@ | |||
2688 | 252 | if (_textColor != textColor) | 252 | if (_textColor != textColor) |
2689 | 253 | { | 253 | { |
2690 | 254 | _textColor = textColor; | 254 | _textColor = textColor; |
2693 | 255 | UpdateTexture (); | 255 | sigTextColorChanged.emit (*this); |
2692 | 256 | sigTextChanged.emit (*this); | ||
2694 | 257 | } | 256 | } |
2695 | 258 | } | 257 | } |
2696 | 259 | 258 | ||
2697 | 260 | 259 | ||
2698 | === modified file 'src/StaticCairoText.h' | |||
2699 | --- src/StaticCairoText.h 2010-11-10 14:42:46 +0000 | |||
2700 | +++ src/StaticCairoText.h 2010-11-18 14:03:47 +0000 | |||
2701 | @@ -99,6 +99,7 @@ | |||
2702 | 99 | void GetTextExtents (int &width, int &height); | 99 | void GetTextExtents (int &width, int &height); |
2703 | 100 | 100 | ||
2704 | 101 | sigc::signal<void, StaticCairoText&> sigTextChanged; | 101 | sigc::signal<void, StaticCairoText&> sigTextChanged; |
2705 | 102 | sigc::signal<void, StaticCairoText&> sigTextColorChanged; | ||
2706 | 102 | 103 | ||
2707 | 103 | protected: | 104 | protected: |
2708 | 104 | 105 | ||
2709 | 105 | 106 | ||
2710 | === modified file 'src/Tooltip.cpp' | |||
2711 | --- src/Tooltip.cpp 2010-11-11 15:08:31 +0000 | |||
2712 | +++ src/Tooltip.cpp 2010-11-18 14:03:47 +0000 | |||
2713 | @@ -49,6 +49,7 @@ | |||
2714 | 49 | _anchor_height = 18; | 49 | _anchor_height = 18; |
2715 | 50 | _corner_radius = 4; | 50 | _corner_radius = 4; |
2716 | 51 | _padding = 15; | 51 | _padding = 15; |
2717 | 52 | _top_size = 4; | ||
2718 | 52 | 53 | ||
2719 | 53 | _hlayout = new nux::HLayout (TEXT(""), NUX_TRACKER_LOCATION); | 54 | _hlayout = new nux::HLayout (TEXT(""), NUX_TRACKER_LOCATION); |
2720 | 54 | _vlayout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION); | 55 | _vlayout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION); |
2721 | @@ -94,6 +95,26 @@ | |||
2722 | 94 | 95 | ||
2723 | 95 | return ret; | 96 | return ret; |
2724 | 96 | } | 97 | } |
2725 | 98 | |||
2726 | 99 | void Tooltip::ShowTooltipWithTipAt (int anchor_tip_x, int anchor_tip_y) | ||
2727 | 100 | { | ||
2728 | 101 | int window_width; | ||
2729 | 102 | int window_height; | ||
2730 | 103 | |||
2731 | 104 | window_width = nux::GetWindow ().GetWindowWidth (); | ||
2732 | 105 | window_height = nux::GetWindow ().GetWindowHeight (); | ||
2733 | 106 | |||
2734 | 107 | _anchorX = anchor_tip_x; | ||
2735 | 108 | _anchorY = anchor_tip_y; | ||
2736 | 109 | |||
2737 | 110 | int x = _anchorX - _padding; | ||
2738 | 111 | int y = anchor_tip_y - _anchor_height/2 - _top_size - _corner_radius - _padding; | ||
2739 | 112 | |||
2740 | 113 | SetBaseX (x); | ||
2741 | 114 | SetBaseY (y); | ||
2742 | 115 | |||
2743 | 116 | ShowWindow (true); | ||
2744 | 117 | } | ||
2745 | 97 | 118 | ||
2746 | 98 | void Tooltip::Draw (GraphicsEngine& gfxContext, bool forceDraw) | 119 | void Tooltip::Draw (GraphicsEngine& gfxContext, bool forceDraw) |
2747 | 99 | { | 120 | { |
2748 | @@ -766,6 +787,18 @@ | |||
2749 | 766 | if (_cairo_text_has_changed == false) | 787 | if (_cairo_text_has_changed == false) |
2750 | 767 | return; | 788 | return; |
2751 | 768 | 789 | ||
2752 | 790 | int width = GetBaseWidth (); | ||
2753 | 791 | int height = GetBaseHeight (); | ||
2754 | 792 | int size_above_anchor = -1; // equal to sise below | ||
2755 | 793 | |||
2756 | 794 | _top_size = 0; | ||
2757 | 795 | size_above_anchor = -1; | ||
2758 | 796 | int x = _anchorX - _padding; | ||
2759 | 797 | int y = _anchorY - height/2; | ||
2760 | 798 | |||
2761 | 799 | SetBaseX (x); | ||
2762 | 800 | SetBaseY (y); | ||
2763 | 801 | |||
2764 | 769 | float blur_coef = 6.0f; | 802 | float blur_coef = 6.0f; |
2765 | 770 | 803 | ||
2766 | 771 | CairoGraphics* cairo_bg = new CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); | 804 | CairoGraphics* cairo_bg = new CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ()); |
2767 | @@ -782,8 +815,6 @@ | |||
2768 | 782 | float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f}; | 815 | float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f}; |
2769 | 783 | float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.75f}; | 816 | float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.75f}; |
2770 | 784 | float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f}; | 817 | float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f}; |
2771 | 785 | float anchor_width = 10; | ||
2772 | 786 | float anchor_height = 18; | ||
2773 | 787 | 818 | ||
2774 | 788 | tint_dot_hl (cr_bg, | 819 | tint_dot_hl (cr_bg, |
2775 | 789 | GetBaseWidth (), | 820 | GetBaseWidth (), |
2776 | @@ -801,8 +832,8 @@ | |||
2777 | 801 | cairo_outline->GetSurface(), | 832 | cairo_outline->GetSurface(), |
2778 | 802 | GetBaseWidth (), | 833 | GetBaseWidth (), |
2779 | 803 | GetBaseHeight (), | 834 | GetBaseHeight (), |
2782 | 804 | anchor_width, | 835 | _anchor_width, |
2783 | 805 | anchor_height, | 836 | _anchor_height, |
2784 | 806 | -1, | 837 | -1, |
2785 | 807 | _corner_radius, | 838 | _corner_radius, |
2786 | 808 | blur_coef, | 839 | blur_coef, |
2787 | @@ -816,15 +847,15 @@ | |||
2788 | 816 | cairo_mask->GetSurface(), | 847 | cairo_mask->GetSurface(), |
2789 | 817 | GetBaseWidth (), | 848 | GetBaseWidth (), |
2790 | 818 | GetBaseHeight(), | 849 | GetBaseHeight(), |
2792 | 819 | _corner_radius, // radius, | 850 | _corner_radius, // radius, |
2793 | 820 | 16, // shadow_radius, | 851 | 16, // shadow_radius, |
2796 | 821 | anchor_width, // anchor_width, | 852 | _anchor_width, // anchor_width, |
2797 | 822 | anchor_height, // anchor_height, | 853 | _anchor_height, // anchor_height, |
2798 | 823 | -1, // upper_size, | 854 | -1, // upper_size, |
2799 | 824 | true, // negative, | 855 | true, // negative, |
2800 | 825 | false, // outline, | 856 | false, // outline, |
2801 | 826 | 1.0, // line_width, | 857 | 1.0, // line_width, |
2803 | 827 | _padding, // padding_size, | 858 | _padding, // padding_size, |
2804 | 828 | mask_color); | 859 | mask_color); |
2805 | 829 | 860 | ||
2806 | 830 | cairo_destroy (cr_bg); | 861 | cairo_destroy (cr_bg); |
2807 | 831 | 862 | ||
2808 | === modified file 'src/Tooltip.h' | |||
2809 | --- src/Tooltip.h 2010-11-11 10:46:30 +0000 | |||
2810 | +++ src/Tooltip.h 2010-11-18 14:03:47 +0000 | |||
2811 | @@ -73,6 +73,7 @@ | |||
2812 | 73 | 73 | ||
2813 | 74 | void SetText (NString text); | 74 | void SetText (NString text); |
2814 | 75 | 75 | ||
2815 | 76 | void ShowTooltipWithTipAt (int anchor_tip_x, int anchor_tip_y); | ||
2816 | 76 | private: | 77 | private: |
2817 | 77 | void RecvCairoTextChanged (StaticCairoText& cairo_text); | 78 | void RecvCairoTextChanged (StaticCairoText& cairo_text); |
2818 | 78 | 79 | ||
2819 | @@ -94,6 +95,7 @@ | |||
2820 | 94 | nux::NString _labelText; | 95 | nux::NString _labelText; |
2821 | 95 | int _dpiX; | 96 | int _dpiX; |
2822 | 96 | int _dpiY; | 97 | int _dpiY; |
2823 | 98 | int _top_size; // size of the segment from point 13 to 14. See figure in _compute_full_mask_path. | ||
2824 | 97 | 99 | ||
2825 | 98 | cairo_font_options_t* _fontOpts; | 100 | cairo_font_options_t* _fontOpts; |
2826 | 99 | 101 | ||
2827 | 100 | 102 | ||
2828 | === modified file 'src/unity.cpp' | |||
2829 | --- src/unity.cpp 2010-11-12 12:03:25 +0000 | |||
2830 | +++ src/unity.cpp 2010-11-18 14:03:47 +0000 | |||
2831 | @@ -188,9 +188,11 @@ | |||
2832 | 188 | UnityScreen::handleEvent (XEvent *event) | 188 | UnityScreen::handleEvent (XEvent *event) |
2833 | 189 | { | 189 | { |
2834 | 190 | screen->handleEvent (event); | 190 | screen->handleEvent (event); |
2836 | 191 | 191 | ||
2837 | 192 | if (screen->otherGrabExist ("deco", "move", NULL)) | 192 | if (screen->otherGrabExist ("deco", "move", NULL)) |
2838 | 193 | { | ||
2839 | 193 | wt->ProcessForeignEvent (event, NULL); | 194 | wt->ProcessForeignEvent (event, NULL); |
2840 | 195 | } | ||
2841 | 194 | } | 196 | } |
2842 | 195 | 197 | ||
2843 | 196 | bool | 198 | bool |
Approved, with understanding that tests are coming today.