Merge lp:~canonical-dx-team/unity/unity.jason-fixes into lp:unity

Proposed by Jason Smith
Status: Merged
Merged at revision: 653
Proposed branch: lp:~canonical-dx-team/unity/unity.jason-fixes
Merge into: lp:unity
Diff against target: 2858 lines (+2469/-289) (has conflicts)
5 files modified
src/BamfLauncherIcon.cpp (+80/-42)
src/BamfLauncherIcon.h (+6/-0)
src/Launcher.cpp (+1884/-0)
src/Launcher.h (+494/-245)
src/LauncherController.cpp (+5/-2)
Text conflict in src/Launcher.cpp
Text conflict in src/Launcher.h
To merge this branch: bzr merge lp:~canonical-dx-team/unity/unity.jason-fixes
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+42393@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good, but please send a GError into g_app_info_launch and g_warning the contents if it's set (and don't forget to free it too), We should be always settings GErrors and reporting them so we get the best info if Unity is breaking for someone.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/BamfLauncherIcon.cpp'
2--- src/BamfLauncherIcon.cpp 2010-11-30 04:56:10 +0000
3+++ src/BamfLauncherIcon.cpp 2010-12-02 15:23:26 +0000
4@@ -102,6 +102,18 @@
5 }
6
7 void
8+BamfLauncherIcon::OpenInstance ()
9+{
10+ GDesktopAppInfo *appInfo;
11+
12+ appInfo = g_desktop_app_info_new_from_filename (bamf_application_get_desktop_file (BAMF_APPLICATION (m_App)));
13+ g_app_info_launch (G_APP_INFO (appInfo), NULL, NULL, NULL);
14+ g_object_unref (appInfo);
15+
16+ UpdateQuirkTime (LAUNCHER_ICON_QUIRK_STARTING);
17+}
18+
19+void
20 BamfLauncherIcon::OnMouseClick (int button)
21 {
22 if (button != 1)
23@@ -110,7 +122,6 @@
24 BamfView *view;
25 GList *children, *l;
26 bool active, running;
27- GDesktopAppInfo *appInfo;
28
29 children = bamf_view_get_children (BAMF_VIEW (m_App));
30 active = bamf_view_is_active (BAMF_VIEW (m_App));
31@@ -118,12 +129,7 @@
32
33 if (!running)
34 {
35- appInfo = g_desktop_app_info_new_from_filename (bamf_application_get_desktop_file (BAMF_APPLICATION (m_App)));
36- g_app_info_launch (G_APP_INFO (appInfo), NULL, NULL, NULL);
37- g_object_unref (appInfo);
38-
39- UpdateQuirkTime (LAUNCHER_ICON_QUIRK_STARTING);
40-
41+ OpenInstance ();
42 return;
43 }
44
45@@ -269,6 +275,12 @@
46 }
47
48 void
49+BamfLauncherIcon::OnLaunch (DbusmenuMenuitem *item, int time, BamfLauncherIcon *self)
50+{
51+ self->OpenInstance ();
52+}
53+
54+void
55 BamfLauncherIcon::OnQuit (DbusmenuMenuitem *item, int time, BamfLauncherIcon *self)
56 {
57 GList *children, *l;
58@@ -315,12 +327,67 @@
59 }
60 }
61
62+void
63+BamfLauncherIcon::EnsureMenuItemsReady ()
64+{
65+ DbusmenuMenuitem *menu_item;
66+
67+ /* Launch */
68+ if (_menu_items.find ("Launch") == _menu_items.end ())
69+ {
70+ menu_item = dbusmenu_menuitem_new ();
71+ g_object_ref (menu_item);
72+
73+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, "Open New Window");
74+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
75+
76+ g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, (GCallback) &BamfLauncherIcon::OnLaunch, this);
77+
78+ _menu_items["Launch"] = menu_item;
79+ }
80+
81+ /* Pin */
82+ if (_menu_items.find ("Pin") == _menu_items.end ())
83+ {
84+ menu_item = dbusmenu_menuitem_new ();
85+ g_object_ref (menu_item);
86+
87+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_CHECK);
88+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, "Keep In Launcher");
89+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
90+
91+ g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, (GCallback) &BamfLauncherIcon::OnTogglePin, this);
92+
93+ _menu_items["Pin"] = menu_item;
94+ }
95+ int checked = !bamf_view_is_sticky (BAMF_VIEW (m_App)) ?
96+ DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED;
97+
98+ dbusmenu_menuitem_property_set_int (_menu_items["Pin"],
99+ DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
100+ checked);
101+
102+
103+ /* Quit */
104+ if (_menu_items.find ("Quit") == _menu_items.end ())
105+ {
106+ menu_item = dbusmenu_menuitem_new ();
107+ g_object_ref (menu_item);
108+
109+ dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, "Quit");
110+ dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
111+
112+ g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, (GCallback) &BamfLauncherIcon::OnQuit, this);
113+
114+ _menu_items["Quit"] = menu_item;
115+ }
116+}
117+
118 std::list<DbusmenuMenuitem *>
119 BamfLauncherIcon::GetMenus ()
120 {
121 std::map<std::string, DbusmenuClient *>::iterator it;
122 std::list<DbusmenuMenuitem *> result;
123- DbusmenuMenuitem *menu_item;
124
125 for (it = _menu_clients.begin (); it != _menu_clients.end (); it++)
126 {
127@@ -339,42 +406,13 @@
128 }
129 }
130
131- if (_menu_items.find ("Pin") == _menu_items.end ())
132- {
133- menu_item = dbusmenu_menuitem_new ();
134- g_object_ref (menu_item);
135-
136- dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_CHECK);
137- dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, "Pin To Launcher");
138- dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
139-
140- g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, (GCallback) &BamfLauncherIcon::OnTogglePin, this);
141-
142- _menu_items["Pin"] = menu_item;
143- }
144-
145- int checked = !bamf_view_is_sticky (BAMF_VIEW (m_App)) ?
146- DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED;
147-
148- dbusmenu_menuitem_property_set_int (_menu_items["Pin"],
149- DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
150- checked);
151+ EnsureMenuItemsReady ();
152+
153+ result.push_back (_menu_items["Launch"]);
154 result.push_back (_menu_items["Pin"]);
155
156- if (_menu_items.find ("Quit") == _menu_items.end ())
157- {
158- menu_item = dbusmenu_menuitem_new ();
159- g_object_ref (menu_item);
160-
161- dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, "Quit");
162- dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
163-
164- g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, (GCallback) &BamfLauncherIcon::OnQuit, this);
165-
166- _menu_items["Quit"] = menu_item;
167- }
168-
169- result.push_back (_menu_items["Quit"]);
170+ if (bamf_view_is_running (BAMF_VIEW (m_App)))
171+ result.push_back (_menu_items["Quit"]);
172
173 return result;
174 }
175
176=== modified file 'src/BamfLauncherIcon.h'
177--- src/BamfLauncherIcon.h 2010-11-30 03:19:56 +0000
178+++ src/BamfLauncherIcon.h 2010-12-02 15:23:26 +0000
179@@ -55,8 +55,13 @@
180 std::map<std::string, DbusmenuMenuitem *> _menu_items;
181
182 void EnsureWindowState ();
183+
184 void UpdateMenus ();
185
186+ void OpenInstance ();
187+
188+ void EnsureMenuItemsReady ();
189+
190 static void OnClosed (BamfView *view, gpointer data);
191 static void OnUserVisibleChanged (BamfView *view, gboolean visible, gpointer data);
192 static void OnActiveChanged (BamfView *view, gboolean active, gpointer data);
193@@ -65,6 +70,7 @@
194 static void OnChildAdded (BamfView *view, BamfView *child, gpointer data);
195 static void OnChildRemoved (BamfView *view, BamfView *child, gpointer data);
196
197+ static void OnLaunch (DbusmenuMenuitem *item, int time, BamfLauncherIcon *self);
198 static void OnQuit (DbusmenuMenuitem *item, int time, BamfLauncherIcon *self);
199 static void OnTogglePin (DbusmenuMenuitem *item, int time, BamfLauncherIcon *self);
200 };
201
202=== modified file 'src/Launcher.cpp'
203--- src/Launcher.cpp 2010-12-01 22:28:50 +0000
204+++ src/Launcher.cpp 2010-12-02 15:23:26 +0000
205@@ -1,3 +1,4 @@
206+<<<<<<< TREE
207 /*
208 * Copyright (C) 2010 Canonical Ltd
209 *
210@@ -1865,3 +1866,1886 @@
211 _active_quicklist = 0;
212 }
213
214+=======
215+/*
216+ * Copyright (C) 2010 Canonical Ltd
217+ *
218+ * This program is free software: you can redistribute it and/or modify
219+ * it under the terms of the GNU General Public License version 3 as
220+ * published by the Free Software Foundation.
221+ *
222+ * This program is distributed in the hope that it will be useful,
223+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
224+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225+ * GNU General Public License for more details.
226+ *
227+ * You should have received a copy of the GNU General Public License
228+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
229+ *
230+ * Authored by: Jason Smith <jason.smith@canonical.com>
231+ * Authored by: Jay Taoko <jay.taoko@canonical.com>
232+ */
233+
234+#include <math.h>
235+
236+#include "Nux/Nux.h"
237+#include "Nux/VScrollBar.h"
238+#include "Nux/HLayout.h"
239+#include "Nux/VLayout.h"
240+#include "Nux/MenuPage.h"
241+
242+#include "NuxGraphics/NuxGraphics.h"
243+#include "NuxGraphics/GpuDevice.h"
244+#include "NuxGraphics/GLTextureResourceManager.h"
245+
246+#include "Nux/BaseWindow.h"
247+#include "Nux/WindowCompositor.h"
248+
249+#include "Launcher.h"
250+#include "LauncherIcon.h"
251+#include "LauncherModel.h"
252+#include "QuicklistView.h"
253+
254+#define ANIM_DURATION_SHORT 125
255+#define ANIM_DURATION 200
256+#define ANIM_DURATION_LONG 350
257+
258+#define URGENT_BLINKS 3
259+
260+#define MAX_STARTING_BLINKS 5
261+#define STARTING_BLINK_LAMBDA 3
262+
263+#define BACKLIGHT_STRENGTH 0.9f
264+
265+int
266+TimeDelta (struct timespec *x, struct timespec *y)
267+{
268+ return ((x->tv_sec - y->tv_sec) * 1000) + ((x->tv_nsec - y->tv_nsec) / 1000000);
269+}
270+
271+static bool USE_ARB_SHADERS = true;
272+/*
273+ Use this shader to pass vertices in screen coordinates in the C++ code and compute use
274+ the fragment shader to perform the texture perspective correct division.
275+ This shader assume the following:
276+ - the projection matrix is orthogonal: glOrtho(0, ScreenWidth, ScreenWidth, 0, Near, Far)
277+ - vertices x and y are in screen coordinates: Vertex(x_screen, y_screen, 0, 1.0)
278+ - the vertices w coordinates has been computed 'manually'
279+ - vertices uv textture coordinates are passed to the shader as: (u/w, v/w, 0, 1/w)
280+
281+ The texture coordinates s=u/w, t=v/w and q=1w are interpolated linearly in screen coordinates.
282+ In the fragment shader we get the texture coordinates used for the sampling by dividing
283+ s and t resulting from the interpolation by q.
284+
285+ */
286+
287+nux::NString gPerspectiveCorrectShader = TEXT (
288+"[Vertex Shader] \n\
289+#version 120 \n\
290+uniform mat4 ViewProjectionMatrix; \n\
291+ \n\
292+attribute vec4 iColor; \n\
293+attribute vec4 iTexCoord0; \n\
294+attribute vec4 iVertex; \n\
295+ \n\
296+varying vec4 varyTexCoord0; \n\
297+varying vec4 varyVertexColor; \n\
298+ \n\
299+void main() \n\
300+{ \n\
301+ varyTexCoord0 = iTexCoord0; \n\
302+ varyVertexColor = iColor; \n\
303+ gl_Position = ViewProjectionMatrix * iVertex; \n\
304+} \n\
305+ \n\
306+[Fragment Shader] \n\
307+#version 120 \n\
308+#extension GL_ARB_texture_rectangle : enable \n\
309+ \n\
310+varying vec4 varyTexCoord0; \n\
311+varying vec4 varyVertexColor; \n\
312+ \n\
313+uniform sampler2D TextureObject0; \n\
314+uniform vec4 color0; \n\
315+vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\
316+{ \n\
317+ return texture2D(TexObject, TexCoord.st); \n\
318+} \n\
319+ \n\
320+void main() \n\
321+{ \n\
322+ vec4 tex = varyTexCoord0; \n\
323+ tex.s = tex.s/varyTexCoord0.w; \n\
324+ tex.t = tex.t/varyTexCoord0.w; \n\
325+ \n\
326+ vec4 texel = SampleTexture(TextureObject0, tex); \n\
327+ gl_FragColor = texel*varyVertexColor; \n\
328+} \n\
329+");
330+
331+nux::NString PerspectiveCorrectVtx = TEXT (
332+ "!!ARBvp1.0 \n\
333+ ATTRIB iPos = vertex.position; \n\
334+ ATTRIB iColor = vertex.attrib[3]; \n\
335+ PARAM mvp[4] = {state.matrix.mvp}; \n\
336+ OUTPUT oPos = result.position; \n\
337+ OUTPUT oColor = result.color; \n\
338+ OUTPUT oTexCoord0 = result.texcoord[0]; \n\
339+ # Transform the vertex to clip coordinates. \n\
340+ DP4 oPos.x, mvp[0], iPos; \n\
341+ DP4 oPos.y, mvp[1], iPos; \n\
342+ DP4 oPos.z, mvp[2], iPos; \n\
343+ DP4 oPos.w, mvp[3], iPos; \n\
344+ MOV oColor, iColor; \n\
345+ MOV oTexCoord0, vertex.attrib[8]; \n\
346+ END");
347+
348+
349+
350+nux::NString PerspectiveCorrectTexFrg = TEXT (
351+ "!!ARBfp1.0 \n\
352+ PARAM color0 = program.local[0]; \n\
353+ TEMP temp; \n\
354+ TEMP pcoord; \n\
355+ TEMP tex0; \n\
356+ TEMP temp1; \n\
357+ TEMP recip; \n\
358+ MOV pcoord, fragment.texcoord[0].w; \n\
359+ RCP temp, fragment.texcoord[0].w; \n\
360+ MUL pcoord.xy, fragment.texcoord[0], temp; \n\
361+ TEX tex0, pcoord, texture[0], 2D; \n\
362+ MUL result.color, color0, tex0; \n\
363+ END");
364+
365+nux::NString PerspectiveCorrectTexRectFrg = TEXT (
366+ "!!ARBfp1.0 \n\
367+ PARAM color0 = program.local[0]; \n\
368+ TEMP temp; \n\
369+ TEMP pcoord; \n\
370+ TEMP tex0; \n\
371+ MOV pcoord, fragment.texcoord[0].w; \n\
372+ RCP temp, fragment.texcoord[0].w; \n\
373+ MUL pcoord.xy, fragment.texcoord[0], temp; \n\
374+ TEX tex0, pcoord, texture[0], RECT; \n\
375+ MUL result.color, color0, tex0; \n\
376+ END");
377+
378+static void GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
379+ int ViewportWidth,
380+ int ViewportHeight,
381+ float NearClipPlane,
382+ float FarClipPlane,
383+ float Fovy);
384+
385+Launcher::Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_DECL)
386+: View(NUX_FILE_LINE_PARAM)
387+, m_ContentOffsetY(0)
388+, m_RunningIndicator(0)
389+, m_ActiveIndicator(0)
390+, m_BackgroundLayer(0)
391+, _model (0)
392+{
393+ _parent = parent;
394+ _active_quicklist = 0;
395+
396+ m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION);
397+
398+ OnMouseDown.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown));
399+ OnMouseUp.connect(sigc::mem_fun(this, &Launcher::RecvMouseUp));
400+ OnMouseDrag.connect(sigc::mem_fun(this, &Launcher::RecvMouseDrag));
401+ OnMouseEnter.connect(sigc::mem_fun(this, &Launcher::RecvMouseEnter));
402+ OnMouseLeave.connect(sigc::mem_fun(this, &Launcher::RecvMouseLeave));
403+ OnMouseMove.connect(sigc::mem_fun(this, &Launcher::RecvMouseMove));
404+ OnMouseWheel.connect(sigc::mem_fun(this, &Launcher::RecvMouseWheel));
405+
406+ m_ActiveTooltipIcon = NULL;
407+ m_ActiveMenuIcon = NULL;
408+
409+ SetCompositionLayout(m_Layout);
410+
411+ if(!USE_ARB_SHADERS)
412+ {
413+ _shader_program_uv_persp_correction = nux::GetThreadGLDeviceFactory()->CreateShaderProgram();
414+ _shader_program_uv_persp_correction->LoadIShader(gPerspectiveCorrectShader.GetTCharPtr());
415+ _shader_program_uv_persp_correction->Link();
416+ }
417+ else
418+ {
419+ _AsmShaderProg = nux::GetThreadGLDeviceFactory()->CreateAsmShaderProgram();
420+ _AsmShaderProg->LoadVertexShader (TCHAR_TO_ANSI (*PerspectiveCorrectVtx) );
421+
422+ if ((nux::GetThreadGLDeviceFactory()->SUPPORT_GL_ARB_TEXTURE_NON_POWER_OF_TWO() == false) &&
423+ (nux::GetThreadGLDeviceFactory()->SUPPORT_GL_EXT_TEXTURE_RECTANGLE () || nux::GetThreadGLDeviceFactory()->SUPPORT_GL_ARB_TEXTURE_RECTANGLE ()))
424+ {
425+ // No support for non power of two textures but support for rectangle textures
426+ _AsmShaderProg->LoadPixelShader (TCHAR_TO_ANSI (*PerspectiveCorrectTexRectFrg) );
427+ }
428+ else
429+ {
430+ _AsmShaderProg->LoadPixelShader (TCHAR_TO_ANSI (*PerspectiveCorrectTexFrg) );
431+ }
432+
433+ _AsmShaderProg->Link();
434+ }
435+
436+ _folded_angle = 1.0f;
437+ _neg_folded_angle = -1.0f;
438+ _space_between_icons = 5;
439+ _launcher_top_y = 0;
440+ _launcher_bottom_y = 0;
441+ _folded_z_distance = 10.0f;
442+ _launcher_state = LAUNCHER_FOLDED;
443+ _launcher_action_state = ACTION_NONE;
444+ _icon_under_mouse = NULL;
445+ _icon_mouse_down = NULL;
446+ _icon_image_size = 48;
447+ _icon_glow_size = 62;
448+ _icon_image_size_delta = 6;
449+ _icon_size = _icon_image_size + _icon_image_size_delta;
450+
451+ _icon_bkg_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_corner_54x54.png");
452+ _icon_outline_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_outline_54x54.png");
453+ _icon_shine_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_shine_54x54.png");
454+ _icon_glow_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_glow_62x62.png");
455+ _icon_2indicator = nux::CreateTextureFromFile (PKGDATADIR"/2indicate_54x54.png");
456+ _icon_3indicator = nux::CreateTextureFromFile (PKGDATADIR"/3indicate_54x54.png");
457+ _icon_4indicator = nux::CreateTextureFromFile (PKGDATADIR"/4indicate_54x54.png");
458+
459+ _enter_y = 0;
460+ _dnd_security = 15;
461+ _dnd_delta = 0;
462+ _anim_handle = 0;
463+ _autohide_handle = 0;
464+ _floating = false;
465+ _hovered = false;
466+ _autohide = false;
467+ _hidden = false;
468+ _mouse_inside_launcher = false;
469+
470+ // 0 out timers to avoid wonky startups
471+ _enter_time.tv_sec = 0;
472+ _enter_time.tv_nsec = 0;
473+ _exit_time.tv_sec = 0;
474+ _exit_time.tv_nsec = 0;
475+ _drag_end_time.tv_sec = 0;
476+ _drag_end_time.tv_nsec = 0;
477+ _autohide_time.tv_sec = 0;
478+ _autohide_time.tv_nsec = 0;
479+}
480+
481+Launcher::~Launcher()
482+{
483+
484+}
485+
486+/* Render Layout Logic */
487+
488+float Launcher::GetHoverProgress ()
489+{
490+ struct timespec current;
491+ clock_gettime (CLOCK_MONOTONIC, &current);
492+
493+ if (_hovered)
494+ return CLAMP ((float) (TimeDelta (&current, &_enter_time)) / (float) ANIM_DURATION, 0.0f, 1.0f);
495+ else
496+ return 1.0f - CLAMP ((float) (TimeDelta (&current, &_exit_time)) / (float) ANIM_DURATION, 0.0f, 1.0f);
497+}
498+
499+float Launcher::DnDExitProgress ()
500+{
501+ struct timespec current;
502+ clock_gettime (CLOCK_MONOTONIC, &current);
503+
504+ return 1.0f - CLAMP ((float) (TimeDelta (&current, &_drag_end_time)) / (float) ANIM_DURATION_LONG, 0.0f, 1.0f);
505+}
506+
507+float Launcher::AutohideProgress ()
508+{
509+ if (!_autohide)
510+ return 0.0f;
511+
512+ struct timespec current;
513+ clock_gettime (CLOCK_MONOTONIC, &current);
514+
515+ if (_hidden)
516+ return CLAMP ((float) (TimeDelta (&current, &_autohide_time)) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
517+ else
518+ return 1.0f - CLAMP ((float) (TimeDelta (&current, &_autohide_time)) / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
519+}
520+
521+gboolean Launcher::AnimationTimeout (gpointer data)
522+{
523+ Launcher *self = (Launcher*) data;
524+
525+ self->NeedRedraw ();
526+
527+ if (self->AnimationInProgress ())
528+ return true;
529+
530+ // zero out handle so we know we are done
531+ self->_anim_handle = 0;
532+ return false;
533+}
534+
535+void Launcher::EnsureAnimation ()
536+{
537+ if (_anim_handle)
538+ return;
539+
540+ NeedRedraw ();
541+
542+ if (AnimationInProgress ())
543+ _anim_handle = g_timeout_add (1000 / 60 - 1, &Launcher::AnimationTimeout, this);
544+}
545+
546+bool Launcher::IconNeedsAnimation (LauncherIcon *icon, struct timespec current)
547+{
548+ struct timespec time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_VISIBLE);
549+ if (TimeDelta (&current, &time) < ANIM_DURATION_SHORT)
550+ return true;
551+
552+ time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_RUNNING);
553+ if (TimeDelta (&current, &time) < ANIM_DURATION_SHORT)
554+ return true;
555+
556+ time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_STARTING);
557+ if (TimeDelta (&current, &time) < (ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2))
558+ return true;
559+
560+ time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_URGENT);
561+ if (TimeDelta (&current, &time) < (ANIM_DURATION_LONG * URGENT_BLINKS * 2))
562+ return true;
563+
564+ time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_PRESENTED);
565+ if (TimeDelta (&current, &time) < ANIM_DURATION)
566+ return true;
567+
568+ time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_SHIMMER);
569+ if (TimeDelta (&current, &time) < ANIM_DURATION_LONG)
570+ return true;
571+
572+ return false;
573+}
574+
575+bool Launcher::AnimationInProgress ()
576+{
577+ // performance here can be improved by caching the longer remaining animation found and short circuiting to that each time
578+ // this way extra checks may be avoided
579+
580+ // short circuit to avoid unneeded calculations
581+ struct timespec current;
582+ clock_gettime (CLOCK_MONOTONIC, &current);
583+
584+ // hover in animation
585+ if (TimeDelta (&current, &_enter_time) < ANIM_DURATION)
586+ return true;
587+
588+ // hover out animation
589+ if (TimeDelta (&current, &_exit_time) < ANIM_DURATION)
590+ return true;
591+
592+ // drag end animation
593+ if (TimeDelta (&current, &_drag_end_time) < ANIM_DURATION_LONG)
594+ return true;
595+
596+ if (TimeDelta (&current, &_autohide_time) < ANIM_DURATION_SHORT)
597+ return true;
598+
599+ // animations happening on specific icons
600+ LauncherModel::iterator it;
601+ for (it = _model->begin (); it != _model->end (); it++)
602+ if (IconNeedsAnimation (*it, current))
603+ return true;
604+
605+ return false;
606+}
607+
608+void Launcher::SetTimeStruct (struct timespec *timer, struct timespec *sister, int sister_relation)
609+{
610+ struct timespec current;
611+ clock_gettime (CLOCK_MONOTONIC, &current);
612+
613+ if (sister)
614+ {
615+ int diff = TimeDelta (&current, sister);
616+
617+ if (diff < sister_relation)
618+ {
619+ int remove = sister_relation - diff;
620+ current.tv_sec -= remove / 1000;
621+ remove = remove % 1000;
622+
623+ if (remove > current.tv_nsec / 1000000)
624+ {
625+ current.tv_sec--;
626+ current.tv_nsec += 1000000000;
627+ }
628+ current.tv_nsec -= remove * 1000000;
629+ }
630+ }
631+
632+ timer->tv_sec = current.tv_sec;
633+ timer->tv_nsec = current.tv_nsec;
634+}
635+
636+float IconVisibleProgress (LauncherIcon *icon, struct timespec current)
637+{
638+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE))
639+ {
640+ struct timespec icon_visible_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_VISIBLE);
641+ int enter_ms = TimeDelta (&current, &icon_visible_time);
642+ return CLAMP ((float) enter_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
643+ }
644+ else
645+ {
646+ struct timespec icon_hide_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_VISIBLE);
647+ int hide_ms = TimeDelta (&current, &icon_hide_time);
648+ return 1.0f - CLAMP ((float) hide_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
649+ }
650+}
651+
652+void Launcher::SetDndDelta (float x, float y, nux::Geometry geo, struct timespec current)
653+{
654+ LauncherIcon *anchor = 0;
655+ LauncherModel::iterator it;
656+ anchor = MouseIconIntersection (x, _enter_y);
657+
658+ if (anchor)
659+ {
660+ float position = y;
661+ for (it = _model->begin (); it != _model->end (); it++)
662+ {
663+ if (*it == anchor)
664+ {
665+ position += _icon_size / 2;
666+ _dnd_delta = _enter_y - position;
667+
668+ if (position + _icon_size / 2 + _dnd_delta > geo.height)
669+ _dnd_delta -= (position + _icon_size / 2 + _dnd_delta) - geo.height;
670+
671+ break;
672+ }
673+ position += (_icon_size + _space_between_icons) * IconVisibleProgress (*it, current);
674+ }
675+ }
676+}
677+
678+float Launcher::IconPresentProgress (LauncherIcon *icon, struct timespec current)
679+{
680+ struct timespec icon_present_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_PRESENTED);
681+ int ms = TimeDelta (&current, &icon_present_time);
682+ float result = CLAMP ((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
683+
684+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_PRESENTED))
685+ return result;
686+ else
687+ return 1.0f - result;
688+}
689+
690+float Launcher::IconUrgentProgress (LauncherIcon *icon, struct timespec current)
691+{
692+ struct timespec urgent_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_URGENT);
693+ int urgent_ms = TimeDelta (&current, &urgent_time);
694+ float result = CLAMP ((float) urgent_ms / (float) (ANIM_DURATION_LONG * URGENT_BLINKS * 2), 0.0f, 1.0f);
695+
696+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_URGENT))
697+ return result;
698+ else
699+ return 1.0f - result;
700+}
701+
702+float Launcher::IconShimmerProgress (LauncherIcon *icon, struct timespec current)
703+{
704+ struct timespec shimmer_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_SHIMMER);
705+ int shimmer_ms = TimeDelta (&current, &shimmer_time);
706+ return CLAMP ((float) shimmer_ms / (float) ANIM_DURATION_LONG, 0.0f, 1.0f);
707+}
708+
709+float Launcher::IconUrgentPulseValue (LauncherIcon *icon, struct timespec current)
710+{
711+ if (!icon->GetQuirk (LAUNCHER_ICON_QUIRK_URGENT))
712+ return 1.0f; // we are full on in a normal condition
713+
714+ double urgent_progress = (double) IconUrgentProgress (icon, current);
715+ return 0.5f + (float) (std::cos (M_PI * (float) (URGENT_BLINKS * 2) * urgent_progress)) * 0.5f;
716+}
717+
718+float Launcher::IconStartingPulseValue (LauncherIcon *icon, struct timespec current)
719+{
720+ struct timespec starting_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_STARTING);
721+ int starting_ms = TimeDelta (&current, &starting_time);
722+ double starting_progress = (double) CLAMP ((float) starting_ms / (float) (ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2), 0.0f, 1.0f);
723+
724+ return 1.0f - (0.5f + (float) (std::cos (M_PI * (float) (MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f);
725+}
726+
727+float Launcher::IconBackgroundIntensity (LauncherIcon *icon, struct timespec current)
728+{
729+ float result = 0.0f;
730+ struct timespec running_time = icon->GetQuirkTime (LAUNCHER_ICON_QUIRK_RUNNING);
731+ int running_ms = TimeDelta (&current, &running_time);
732+ float running_progress = CLAMP ((float) running_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
733+
734+ // After we finish a fade in from running, we can reset the quirk
735+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_RUNNING) && running_progress == 1.0f)
736+ icon->ResetQuirkTime (LAUNCHER_ICON_QUIRK_STARTING);
737+
738+ result = IconStartingPulseValue (icon, current) * BACKLIGHT_STRENGTH;
739+
740+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_RUNNING))
741+ {
742+ // running progress fades in whatever the pulsing did not fill in already
743+ result += running_progress * (BACKLIGHT_STRENGTH - result);
744+
745+ // urgent serves to bring the total down only
746+ if (icon->GetQuirk (LAUNCHER_ICON_QUIRK_URGENT))
747+ result *= 0.2f + 0.8f * IconUrgentPulseValue (icon, current);
748+ }
749+ else
750+ {
751+ // modestly evil
752+ result += BACKLIGHT_STRENGTH - running_progress * BACKLIGHT_STRENGTH;
753+ }
754+
755+ return result;
756+}
757+
758+void Launcher::SetupRenderArg (LauncherIcon *icon, struct timespec current, RenderArg &arg)
759+{
760+ arg.icon = icon;
761+ arg.alpha = 1.0f;
762+ arg.running_arrow = false;
763+ arg.active_arrow = icon->GetQuirk (LAUNCHER_ICON_QUIRK_ACTIVE);
764+ arg.folding_rads = 0.0f;
765+ arg.skip = false;
766+
767+ arg.window_indicators = MIN (4, icon->RelatedWindows ());
768+
769+ // we dont need to show strays
770+ if (arg.window_indicators == 1 || !icon->GetQuirk (LAUNCHER_ICON_QUIRK_RUNNING))
771+ arg.window_indicators = 0;
772+
773+ arg.backlight_intensity = IconBackgroundIntensity (icon, current);
774+ arg.shimmer_progress = IconShimmerProgress (icon, current);
775+
776+ float urgent_progress = IconUrgentProgress (icon, current);
777+ urgent_progress = CLAMP (urgent_progress * 3, 0.0f, 1.0f); // we want to go 3x faster than the urgent normal cycle
778+ arg.glow_intensity = urgent_progress;
779+}
780+
781+int Launcher::DragLimiter (int x)
782+{
783+ int result = (int) ((1 - std::pow (159.0 / 160, std::abs (x))) * 160);
784+
785+ if (x >= 0)
786+ return result;
787+ return -result;
788+}
789+
790+void Launcher::RenderArgs (std::list<Launcher::RenderArg> &launcher_args,
791+ std::list<Launcher::RenderArg> &shelf_args,
792+ nux::Geometry &box_geo, nux::Geometry &shelf_geo)
793+{
794+ nux::Geometry geo = GetGeometry ();
795+ LauncherModel::iterator it;
796+ nux::Point3 center;
797+ float hover_progress = GetHoverProgress ();
798+ float folded_z_distance = _folded_z_distance * (1.0f - hover_progress);
799+ float animation_neg_rads = _neg_folded_angle * (1.0f - hover_progress);
800+ int vertical_offset = _parent->GetGeometry ().y;
801+ struct timespec current;
802+ clock_gettime (CLOCK_MONOTONIC, &current);
803+
804+ float folding_constant = 0.25f;
805+ float folding_not_constant = folding_constant + ((1.0f - folding_constant) * hover_progress);
806+
807+ int folded_size = (int) (_icon_size * folding_not_constant);
808+ int folded_spacing = (int) (_space_between_icons * folding_not_constant);
809+
810+ center.x = geo.width / 2;
811+ center.y = _space_between_icons;
812+ center.z = 0;
813+
814+ // compute required height of shelf
815+ float shelf_sum = 0.0f;
816+ for (it = _model->shelf_begin (); it != _model->shelf_end (); it++)
817+ {
818+ float height = (_icon_size + _space_between_icons) * IconVisibleProgress (*it, current);
819+ shelf_sum += height;
820+ }
821+
822+ // add bottom padding
823+ if (shelf_sum > 0.0f)
824+ shelf_sum += _space_between_icons;
825+
826+ int launcher_height = geo.height - shelf_sum;
827+
828+ // compute required height of launcher AND folding threshold
829+ float sum = 0.0f + center.y;
830+ int folding_threshold = launcher_height - _icon_size / 2.5f;
831+ for (it = _model->begin (); it != _model->end (); it++)
832+ {
833+ float height = (_icon_size + _space_between_icons) * IconVisibleProgress (*it, current);
834+ sum += height;
835+
836+ // magic constant must some day be explained, for now suffice to say this constant prevents the bottom from "marching";
837+ float magic_constant = 1.2f;
838+
839+ float present_progress = IconPresentProgress (*it, current);
840+ folding_threshold -= CLAMP (sum - launcher_height, 0.0f, height * magic_constant) * (folding_constant + (1.0f - folding_constant) * present_progress);
841+ }
842+
843+ // this happens on hover, basically its a flag and a value in one, we translate this into a dnd offset
844+ if (_enter_y != 0 && _enter_y + _icon_size / 2 > folding_threshold)
845+ SetDndDelta (center.x, center.y, nux::Geometry (geo.x, geo.y, geo.width, geo.height - shelf_sum), current);
846+
847+ _enter_y = 0;
848+
849+ if (hover_progress > 0.0f && _dnd_delta != 0)
850+ {
851+ int delta_y = _dnd_delta;
852+
853+ // logically dnd exit only restores to the clamped ranges
854+ // hover_progress restores to 0
855+ float max = 0.0f;
856+ float min = MIN (0.0f, launcher_height - sum);
857+
858+ if (_dnd_delta > max)
859+ delta_y = max + DragLimiter (delta_y - max);
860+ else if (_dnd_delta < min)
861+ delta_y = min + DragLimiter (delta_y - min);
862+
863+ if (_launcher_action_state != ACTION_DRAG_LAUNCHER)
864+ {
865+ float dnd_progress = DnDExitProgress ();
866+
867+ if (_dnd_delta > max)
868+ delta_y = max + (delta_y - max) * dnd_progress;
869+ else if (_dnd_delta < min)
870+ delta_y = min + (delta_y - min) * dnd_progress;
871+
872+ if (dnd_progress == 0.0f)
873+ _dnd_delta = (int) delta_y;
874+ }
875+
876+ delta_y *= hover_progress;
877+ center.y += delta_y;
878+ }
879+ else
880+ {
881+ _dnd_delta = 0;
882+ }
883+
884+ float autohide_progress = AutohideProgress ();
885+ float autohide_offset = 0.0f;
886+ if (_autohide && autohide_progress > 0.0f)
887+ {
888+ autohide_offset -= geo.width * autohide_progress;
889+ }
890+
891+ // Inform the painter where to paint the box
892+ box_geo = geo;
893+
894+ if (_floating)
895+ box_geo.height = sum + shelf_sum + _space_between_icons;
896+
897+ if (_autohide)
898+ box_geo.x += autohide_offset;
899+
900+ shelf_geo = nux::Geometry (box_geo.x, box_geo.height - shelf_sum, box_geo.width, shelf_sum);
901+
902+ // The functional position we wish to represent for these icons is not smooth. Rather than introducing
903+ // special casing to represent this, we use MIN/MAX functions. This helps ensure that even though our
904+ // function is not smooth it is continuous, which is more important for our visual representation (icons
905+ // wont start jumping around). As a general rule ANY if () statements that modify center.y should be seen
906+ // as bugs.
907+ for (it = _model->begin (); it != _model->end (); it++)
908+ {
909+ RenderArg arg;
910+ LauncherIcon *icon = *it;
911+
912+ SetupRenderArg (icon, current, arg);
913+
914+ // reset z
915+ center.z = 0;
916+
917+ float size_modifier = IconVisibleProgress (icon, current);
918+ if (size_modifier < 1.0f)
919+ {
920+ arg.alpha = size_modifier;
921+ center.z = 300.0f * (1.0f - size_modifier);
922+ }
923+
924+ if (size_modifier <= 0.0f)
925+ {
926+ arg.skip = true;
927+ continue;
928+ }
929+
930+ // goes for 0.0f when fully unfolded, to 1.0f folded
931+ float folding_progress = CLAMP ((center.y + _icon_size - folding_threshold) / (float) _icon_size, 0.0f, 1.0f);
932+ float present_progress = IconPresentProgress (icon, current);
933+
934+ folding_progress *= 1.0f - present_progress;
935+
936+ float half_size = (folded_size / 2.0f) + (_icon_size / 2.0f - folded_size / 2.0f) * (1.0f - folding_progress);
937+
938+ float icon_hide_offset = autohide_offset;
939+
940+ if (icon->PresentUrgency () == 1)
941+ icon_hide_offset *= 0.5f + 0.5f * (1.0f - present_progress);
942+ else if (icon->PresentUrgency () >= 2)
943+ icon_hide_offset *= 1.0f - present_progress;
944+
945+ // icon is crossing threshold, start folding
946+ center.z += folded_z_distance * folding_progress;
947+ arg.folding_rads = animation_neg_rads * folding_progress;
948+
949+ center.y += half_size * size_modifier; // move to center
950+ arg.center = nux::Point3 (center.x + icon_hide_offset, center.y, center.z); // copy center
951+ icon->SetCenter (nux::Point3 (center.x, center.y + vertical_offset, center.z));
952+ center.y += half_size * size_modifier; // move to end
953+
954+ float spacing_overlap = CLAMP ((float) (center.y + (_space_between_icons * size_modifier) - folding_threshold) / (float) _icon_size, 0.0f, 1.0f);
955+ //add spacing
956+ center.y += (_space_between_icons * (1.0f - spacing_overlap) + folded_spacing * spacing_overlap) * size_modifier;
957+
958+ launcher_args.push_back (arg);
959+ }
960+
961+ center.y = (box_geo.y + box_geo.height) - shelf_sum + _space_between_icons;
962+
963+ // Place shelf icons
964+ for (it = _model->shelf_begin (); it != _model->shelf_end (); it++)
965+ {
966+ RenderArg arg;
967+ LauncherIcon *icon = *it;
968+
969+ SetupRenderArg (icon, current, arg);
970+
971+ // reset z
972+ center.z = 0;
973+
974+ float size_modifier = IconVisibleProgress (icon, current);
975+ if (size_modifier < 1.0f)
976+ {
977+ arg.alpha = size_modifier;
978+ center.z = 300.0f * (1.0f - size_modifier);
979+ }
980+
981+ if (size_modifier <= 0.0f)
982+ {
983+ arg.skip = true;
984+ continue;
985+ }
986+
987+ float half_size = _icon_size / 2.0f;
988+
989+ center.y += half_size * size_modifier; // move to center
990+ arg.center = nux::Point3 (center.x + autohide_offset, center.y, center.z); // copy center
991+ icon->SetCenter (nux::Point3 (center.x, center.y + vertical_offset, center.z));
992+ center.y += half_size * size_modifier; // move to end
993+ center.y += _space_between_icons * size_modifier;
994+
995+ shelf_args.push_back (arg);
996+ }
997+}
998+
999+/* End Render Layout Logic */
1000+
1001+void Launcher::SetHidden (bool hidden)
1002+{
1003+ if (hidden == _hidden)
1004+ return;
1005+
1006+ _hidden = hidden;
1007+ SetTimeStruct (&_autohide_time, &_autohide_time, ANIM_DURATION);
1008+
1009+ _parent->EnableInputWindow(!hidden);
1010+
1011+ EnsureAnimation ();
1012+}
1013+
1014+gboolean Launcher::OnAutohideTimeout (gpointer data)
1015+{
1016+ Launcher *self = (Launcher*) data;
1017+
1018+ if (self->_hovered || self->_hidden)
1019+ return false;
1020+
1021+ self->SetHidden (true);
1022+
1023+ self->_autohide_handle = 0;
1024+ return false;
1025+}
1026+
1027+void Launcher::OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
1028+{
1029+ if (!_autohide || !_hidden)
1030+ return;
1031+
1032+ SetHidden (false);
1033+}
1034+
1035+void Launcher::SetupAutohideTimer ()
1036+{
1037+ if (_autohide)
1038+ {
1039+ if (_autohide_handle > 0)
1040+ g_source_remove (_autohide_handle);
1041+ _autohide_handle = g_timeout_add (1000, &Launcher::OnAutohideTimeout, this);
1042+ }
1043+}
1044+
1045+void Launcher::OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
1046+{
1047+ SetupAutohideTimer ();
1048+}
1049+
1050+bool Launcher::AutohideEnabled ()
1051+{
1052+ return _autohide;
1053+}
1054+
1055+gboolean Launcher::StrutHack (gpointer data)
1056+{
1057+ Launcher *self = (Launcher *) data;
1058+ self->_parent->InputWindowEnableStruts(false);
1059+ self->_parent->InputWindowEnableStruts(true);
1060+
1061+ return false;
1062+}
1063+
1064+void Launcher::SetAutohide (bool autohide, nux::View *trigger)
1065+{
1066+ if (_autohide == autohide)
1067+ return;
1068+
1069+ if (autohide)
1070+ {
1071+ _parent->InputWindowEnableStruts(false);
1072+ _autohide_trigger = trigger;
1073+ _autohide_trigger->OnMouseEnter.connect (sigc::mem_fun(this, &Launcher::OnTriggerMouseEnter));
1074+ _autohide_trigger->OnMouseLeave.connect (sigc::mem_fun(this, &Launcher::OnTriggerMouseLeave));
1075+ }
1076+ else
1077+ {
1078+ _parent->EnableInputWindow(true);
1079+ g_timeout_add (1000, &Launcher::StrutHack, this);
1080+ _parent->InputWindowEnableStruts(true);
1081+ }
1082+
1083+ _autohide = autohide;
1084+ EnsureAnimation ();
1085+}
1086+
1087+void Launcher::SetFloating (bool floating)
1088+{
1089+ if (_floating == floating)
1090+ return;
1091+
1092+ _floating = floating;
1093+ EnsureAnimation ();
1094+}
1095+
1096+void Launcher::SetHover ()
1097+{
1098+ if (_hovered)
1099+ return;
1100+
1101+ _enter_y = (int) _mouse_position.y;
1102+
1103+ if (_last_shelf_area.y - _enter_y < 5 && _last_shelf_area.y - _enter_y >= 0)
1104+ _enter_y = _last_shelf_area.y - 5;
1105+
1106+ _hovered = true;
1107+ SetTimeStruct (&_enter_time, &_exit_time, ANIM_DURATION);
1108+}
1109+
1110+void Launcher::UnsetHover ()
1111+{
1112+ if (!_hovered)
1113+ return;
1114+
1115+ _hovered = false;
1116+ SetTimeStruct (&_exit_time, &_enter_time, ANIM_DURATION);
1117+ SetupAutohideTimer ();
1118+}
1119+
1120+void Launcher::SetIconSize(int tile_size, int icon_size)
1121+{
1122+ nux::Geometry geo = _parent->GetGeometry ();
1123+
1124+ _icon_size = tile_size;
1125+ _icon_image_size = icon_size;
1126+ _icon_image_size_delta = tile_size - icon_size;
1127+
1128+ // recreate tile textures
1129+
1130+ _parent->SetGeometry (nux::Geometry (geo.x, geo.y, tile_size + 12, geo.height));
1131+}
1132+
1133+void Launcher::OnIconAdded (void *icon_pointer)
1134+{
1135+ LauncherIcon *icon = (LauncherIcon *) icon_pointer;
1136+ icon->Reference ();
1137+ EnsureAnimation();
1138+
1139+ // How to free these properly?
1140+ icon->_xform_coords["HitArea"] = new nux::Vector4[4];
1141+ icon->_xform_coords["Image"] = new nux::Vector4[4];
1142+ icon->_xform_coords["Tile"] = new nux::Vector4[4];
1143+ icon->_xform_coords["Glow"] = new nux::Vector4[4];
1144+
1145+ // needs to be disconnected
1146+ icon->needs_redraw.connect (sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw));
1147+}
1148+
1149+void Launcher::OnIconRemoved (void *icon_pointer)
1150+{
1151+ LauncherIcon *icon = (LauncherIcon *) icon_pointer;
1152+ icon->UnReference ();
1153+
1154+ EnsureAnimation();
1155+}
1156+
1157+void Launcher::OnOrderChanged ()
1158+{
1159+
1160+}
1161+
1162+void Launcher::SetModel (LauncherModel *model)
1163+{
1164+ _model = model;
1165+ _model->icon_added.connect (sigc::mem_fun (this, &Launcher::OnIconAdded));
1166+ _model->icon_removed.connect (sigc::mem_fun (this, &Launcher::OnIconRemoved));
1167+ _model->order_changed.connect (sigc::mem_fun (this, &Launcher::OnOrderChanged));
1168+}
1169+
1170+void Launcher::OnIconNeedsRedraw (void *icon)
1171+{
1172+ EnsureAnimation();
1173+}
1174+
1175+long Launcher::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
1176+{
1177+ long ret = TraverseInfo;
1178+ ret = PostProcessEvent2(ievent, ret, ProcessEventInfo);
1179+ return ret;
1180+}
1181+
1182+void Launcher::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
1183+{
1184+
1185+}
1186+
1187+void Launcher::RenderIcon(nux::GraphicsEngine& GfxContext,
1188+ RenderArg arg,
1189+ nux::BaseTexture *icon,
1190+ nux::Color bkg_color,
1191+ float alpha,
1192+ nux::Vector4 xform_coords[],
1193+ nux::Geometry geo,
1194+ bool render_indicators)
1195+{
1196+ nux::Matrix4 ObjectMatrix;
1197+ nux::Matrix4 ViewMatrix;
1198+ nux::Matrix4 ProjectionMatrix;
1199+ nux::Matrix4 ViewProjectionMatrix;
1200+
1201+ if(nux::Abs (arg.folding_rads) < 0.01f)
1202+ icon->GetDeviceTexture()->SetFiltering(GL_NEAREST, GL_NEAREST);
1203+ else
1204+ icon->GetDeviceTexture()->SetFiltering(GL_LINEAR, GL_LINEAR);
1205+
1206+ nux::Vector4 v0;
1207+ nux::Vector4 v1;
1208+ nux::Vector4 v2;
1209+ nux::Vector4 v3;
1210+
1211+ v0.x = xform_coords[0].x ;
1212+ v0.y = xform_coords[0].y ;
1213+ v0.z = xform_coords[0].z ;
1214+ v0.w = xform_coords[0].w ;
1215+ v1.x = xform_coords[1].x ;
1216+ v1.y = xform_coords[1].y ;
1217+ v1.z = xform_coords[1].z ;
1218+ v1.w = xform_coords[1].w ;
1219+ v2.x = xform_coords[2].x ;
1220+ v2.y = xform_coords[2].y ;
1221+ v2.z = xform_coords[2].z ;
1222+ v2.w = xform_coords[2].w ;
1223+ v3.x = xform_coords[3].x ;
1224+ v3.y = xform_coords[3].y ;
1225+ v3.z = xform_coords[3].z ;
1226+ v3.w = xform_coords[3].w ;
1227+
1228+ float s0, t0, s1, t1, s2, t2, s3, t3;
1229+ nux::Color color = nux::Color::White;
1230+
1231+ if (icon->Type ().IsDerivedFromType(nux::TextureRectangle::StaticObjectType))
1232+ {
1233+ s0 = 0.0f; t0 = 0.0f;
1234+ s1 = 0.0f; t1 = icon->GetHeight();
1235+ s2 = icon->GetWidth(); t2 = icon->GetHeight();
1236+ s3 = icon->GetWidth(); t3 = 0.0f;
1237+ }
1238+ else
1239+ {
1240+ s0 = 0.0f; t0 = 0.0f;
1241+ s1 = 0.0f; t1 = 1.0f;
1242+ s2 = 1.0f; t2 = 1.0f;
1243+ s3 = 1.0f; t3 = 0.0f;
1244+ }
1245+
1246+ float VtxBuffer[] =
1247+ {// Perspective correct
1248+ v0.x, v0.y, 0.0f, 1.0f, s0/v0.w, t0/v0.w, 0.0f, 1.0f/v0.w, color.R(), color.G(), color.B(), color.A(),
1249+ v1.x, v1.y, 0.0f, 1.0f, s1/v1.w, t1/v1.w, 0.0f, 1.0f/v1.w, color.R(), color.G(), color.B(), color.A(),
1250+ v2.x, v2.y, 0.0f, 1.0f, s2/v2.w, t2/v2.w, 0.0f, 1.0f/v2.w, color.R(), color.G(), color.B(), color.A(),
1251+ v3.x, v3.y, 0.0f, 1.0f, s3/v3.w, t3/v3.w, 0.0f, 1.0f/v3.w, color.R(), color.G(), color.B(), color.A(),
1252+ };
1253+
1254+ CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
1255+ CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
1256+
1257+ int TextureObjectLocation;
1258+ int VertexLocation;
1259+ int TextureCoord0Location;
1260+ int VertexColorLocation;
1261+ int FragmentColor;
1262+
1263+ if(!USE_ARB_SHADERS)
1264+ {
1265+ _shader_program_uv_persp_correction->Begin();
1266+
1267+ TextureObjectLocation = _shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0");
1268+ VertexLocation = _shader_program_uv_persp_correction->GetAttributeLocation("iVertex");
1269+ TextureCoord0Location = _shader_program_uv_persp_correction->GetAttributeLocation("iTexCoord0");
1270+ VertexColorLocation = _shader_program_uv_persp_correction->GetAttributeLocation("iColor");
1271+ FragmentColor = _shader_program_uv_persp_correction->GetUniformLocationARB ("color");
1272+
1273+ nux::GetGraphicsEngine ().SetTexture(GL_TEXTURE0, icon);
1274+
1275+ if(TextureObjectLocation != -1)
1276+ CHECKGL( glUniform1iARB (TextureObjectLocation, 0) );
1277+
1278+ int VPMatrixLocation = _shader_program_uv_persp_correction->GetUniformLocationARB("ViewProjectionMatrix");
1279+ if(VPMatrixLocation != -1)
1280+ {
1281+ nux::Matrix4 mat = nux::GetGraphicsEngine ().GetModelViewProjectionMatrix ();
1282+ _shader_program_uv_persp_correction->SetUniformLocMatrix4fv ((GLint)VPMatrixLocation, 1, false, (GLfloat*)&(mat.m));
1283+ }
1284+ }
1285+ else
1286+ {
1287+ _AsmShaderProg->Begin();
1288+
1289+ VertexLocation = nux::VTXATTRIB_POSITION;
1290+ TextureCoord0Location = nux::VTXATTRIB_TEXCOORD0;
1291+ VertexColorLocation = nux::VTXATTRIB_COLOR;
1292+
1293+ nux::GetGraphicsEngine().SetTexture(GL_TEXTURE0, icon);
1294+ }
1295+
1296+ CHECKGL( glEnableVertexAttribArrayARB(VertexLocation) );
1297+ CHECKGL( glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer) );
1298+
1299+ if(TextureCoord0Location != -1)
1300+ {
1301+ CHECKGL( glEnableVertexAttribArrayARB(TextureCoord0Location) );
1302+ CHECKGL( glVertexAttribPointerARB((GLuint)TextureCoord0Location, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 4) );
1303+ }
1304+
1305+ if(VertexColorLocation != -1)
1306+ {
1307+ CHECKGL( glEnableVertexAttribArrayARB(VertexColorLocation) );
1308+ CHECKGL( glVertexAttribPointerARB((GLuint)VertexColorLocation, 4, GL_FLOAT, GL_FALSE, 48, VtxBuffer + 8) );
1309+ }
1310+
1311+ bkg_color.SetAlpha (bkg_color.A () * alpha);
1312+
1313+ if(!USE_ARB_SHADERS)
1314+ {
1315+ CHECKGL ( glUniform4fARB (FragmentColor, bkg_color.R(), bkg_color.G(), bkg_color.B(), bkg_color.A() ) );
1316+ nux::GetGraphicsEngine ().SetTexture(GL_TEXTURE0, icon);
1317+ CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
1318+ }
1319+ else
1320+ {
1321+ CHECKGL ( glProgramLocalParameter4fARB (GL_FRAGMENT_PROGRAM_ARB, 0, bkg_color.R(), bkg_color.G(), bkg_color.B(), bkg_color.A() ) );
1322+ nux::GetGraphicsEngine ().SetTexture(GL_TEXTURE0, icon);
1323+ CHECKGL( glDrawArrays(GL_QUADS, 0, 4) );
1324+ }
1325+
1326+ if(VertexLocation != -1)
1327+ CHECKGL( glDisableVertexAttribArrayARB(VertexLocation) );
1328+ if(TextureCoord0Location != -1)
1329+ CHECKGL( glDisableVertexAttribArrayARB(TextureCoord0Location) );
1330+ if(VertexColorLocation != -1)
1331+ CHECKGL( glDisableVertexAttribArrayARB(VertexColorLocation) );
1332+
1333+ if(!USE_ARB_SHADERS)
1334+ {
1335+ _shader_program_uv_persp_correction->End();
1336+ }
1337+ else
1338+ {
1339+ _AsmShaderProg->End();
1340+ }
1341+
1342+ int markerCenter = (v1.y + v0.y) / 2;
1343+
1344+ if (arg.running_arrow && render_indicators)
1345+ {
1346+ if (!m_RunningIndicator)
1347+ {
1348+ GdkPixbuf *pbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/running_indicator.png", NULL);
1349+ m_RunningIndicator = nux::CreateTextureFromPixbuf (pbuf);
1350+ g_object_unref (pbuf);
1351+ }
1352+ gPainter.Draw2DTexture (GfxContext, m_RunningIndicator, geo.x, markerCenter - (m_ActiveIndicator->GetHeight () / 2));
1353+ }
1354+
1355+ if (arg.active_arrow && render_indicators)
1356+ {
1357+ if (!m_ActiveIndicator)
1358+ {
1359+ GdkPixbuf *pbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/focused_indicator.png", NULL);
1360+ m_ActiveIndicator = nux::CreateTextureFromPixbuf (pbuf);
1361+ g_object_unref (pbuf);
1362+ }
1363+ gPainter.Draw2DTexture (GfxContext, m_ActiveIndicator, (geo.x + geo.width) - m_ActiveIndicator->GetWidth (), markerCenter - (m_ActiveIndicator->GetHeight () / 2));
1364+ }
1365+}
1366+
1367+void Launcher::DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg arg, nux::Geometry geo)
1368+{
1369+ GfxContext.GetRenderStates ().SetSeparateBlend (true,
1370+ GL_SRC_ALPHA,
1371+ GL_ONE_MINUS_SRC_ALPHA,
1372+ GL_ONE_MINUS_DST_ALPHA,
1373+ GL_ONE);
1374+
1375+ GfxContext.GetRenderStates ().SetColorMask (true, true, true, true);
1376+
1377+ if (arg.backlight_intensity < 1.0f)
1378+ {
1379+ RenderIcon(GfxContext,
1380+ arg,
1381+ _icon_outline_texture,
1382+ nux::Color(0xFF6D6D6D),
1383+ 1.0f - arg.backlight_intensity,
1384+ arg.icon->_xform_coords["Tile"],
1385+ geo,
1386+ false);
1387+ }
1388+
1389+ if (arg.backlight_intensity > 0.0f)
1390+ {
1391+ RenderIcon(GfxContext,
1392+ arg,
1393+ _icon_bkg_texture,
1394+ arg.icon->BackgroundColor (),
1395+ arg.backlight_intensity,
1396+ arg.icon->_xform_coords["Tile"],
1397+ geo,
1398+ false);
1399+ }
1400+
1401+ GfxContext.GetRenderStates ().SetSeparateBlend (true,
1402+ GL_SRC_ALPHA,
1403+ GL_ONE_MINUS_SRC_ALPHA,
1404+ GL_ONE_MINUS_DST_ALPHA,
1405+ GL_ONE);
1406+ GfxContext.GetRenderStates ().SetColorMask (true, true, true, true);
1407+
1408+ RenderIcon (GfxContext,
1409+ arg,
1410+ arg.icon->TextureForSize (_icon_image_size),
1411+ nux::Color::White,
1412+ arg.alpha,
1413+ arg.icon->_xform_coords["Image"],
1414+ geo,
1415+ true);
1416+
1417+ if (arg.backlight_intensity > 0.0f)
1418+ {
1419+ RenderIcon(GfxContext,
1420+ arg,
1421+ _icon_shine_texture,
1422+ nux::Color::White,
1423+ arg.backlight_intensity,
1424+ arg.icon->_xform_coords["Tile"],
1425+ geo,
1426+ false);
1427+ }
1428+
1429+ switch (arg.window_indicators)
1430+ {
1431+ case 2:
1432+ RenderIcon(GfxContext,
1433+ arg,
1434+ _icon_2indicator,
1435+ nux::Color::White,
1436+ 1.0f,
1437+ arg.icon->_xform_coords["Tile"],
1438+ geo,
1439+ false);
1440+ break;
1441+ case 3:
1442+ RenderIcon(GfxContext,
1443+ arg,
1444+ _icon_3indicator,
1445+ nux::Color::White,
1446+ 1.0f,
1447+ arg.icon->_xform_coords["Tile"],
1448+ geo,
1449+ false);
1450+ break;
1451+ case 4:
1452+ RenderIcon(GfxContext,
1453+ arg,
1454+ _icon_4indicator,
1455+ nux::Color::White,
1456+ 1.0f,
1457+ arg.icon->_xform_coords["Tile"],
1458+ geo,
1459+ false);
1460+ break;
1461+ }
1462+
1463+ if (arg.glow_intensity > 0.0f)
1464+ {
1465+ RenderIcon(GfxContext,
1466+ arg,
1467+ _icon_glow_texture,
1468+ arg.icon->GlowColor (),
1469+ arg.glow_intensity,
1470+ arg.icon->_xform_coords["Glow"],
1471+ geo,
1472+ false);
1473+ }
1474+
1475+ if (arg.shimmer_progress > 0.0f && arg.shimmer_progress < 1.0f)
1476+ {
1477+ nux::Geometry base = GetGeometry ();
1478+ int x1 = base.x + base.width;
1479+ int x2 = base.x + base.width;
1480+ float shimmer_constant = 1.9f;
1481+
1482+ x1 -= geo.width * arg.shimmer_progress * shimmer_constant;
1483+ GfxContext.PushClippingRectangle(nux::Geometry (x1, geo.y, x2 - x1, geo.height));
1484+
1485+ float fade_out = 1.0f - CLAMP (((x2 - x1) - geo.width) / (geo.width * (shimmer_constant - 1.0f)), 0.0f, 1.0f);
1486+
1487+ RenderIcon(GfxContext,
1488+ arg,
1489+ _icon_glow_texture,
1490+ arg.icon->GlowColor (),
1491+ fade_out,
1492+ arg.icon->_xform_coords["Glow"],
1493+ geo,
1494+ false);
1495+
1496+ GfxContext.PopClippingRectangle();
1497+ }
1498+}
1499+
1500+void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
1501+{
1502+ nux::Geometry base = GetGeometry();
1503+ GfxContext.PushClippingRectangle(base);
1504+ nux::Geometry bkg_box;
1505+ nux::Geometry shelf_box;
1506+ std::list<Launcher::RenderArg> args;
1507+ std::list<Launcher::RenderArg> shelf_args;
1508+
1509+ nux::ROPConfig ROP;
1510+ ROP.Blend = false;
1511+ ROP.SrcBlend = GL_SRC_ALPHA;
1512+ ROP.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
1513+
1514+ RenderArgs (args, shelf_args, bkg_box, shelf_box);
1515+ _last_shelf_area = shelf_box;
1516+
1517+ // clear region
1518+ gPainter.PushDrawColorLayer(GfxContext, base, nux::Color(0x00000000), true, ROP);
1519+
1520+ // clip vertically but not horizontally
1521+ GfxContext.PushClippingRectangle(nux::Geometry (base.x, bkg_box.y, base.width, bkg_box.height));
1522+ GfxContext.GetRenderStates ().SetSeparateBlend (true,
1523+ GL_SRC_ALPHA,
1524+ GL_ONE_MINUS_SRC_ALPHA,
1525+ GL_ONE_MINUS_DST_ALPHA,
1526+ GL_ONE);
1527+
1528+ gPainter.Paint2DQuadColor (GfxContext, bkg_box, nux::Color(0xAA000000));
1529+
1530+ UpdateIconXForm (args);
1531+ UpdateIconXForm (shelf_args);
1532+ EventLogic ();
1533+
1534+ /* drag launcher */
1535+ std::list<Launcher::RenderArg>::reverse_iterator rev_it;
1536+ for (rev_it = args.rbegin (); rev_it != args.rend (); rev_it++)
1537+ {
1538+ if ((*rev_it).folding_rads >= 0.0f || (*rev_it).skip)
1539+ continue;
1540+
1541+ DrawRenderArg (GfxContext, *rev_it, bkg_box);
1542+ }
1543+
1544+ std::list<Launcher::RenderArg>::iterator it;
1545+ for (it = args.begin(); it != args.end(); it++)
1546+ {
1547+ if ((*it).folding_rads < 0.0f || (*it).skip)
1548+ continue;
1549+
1550+ DrawRenderArg (GfxContext, *it, bkg_box);
1551+ }
1552+
1553+ /* draw shelf */
1554+
1555+ nux::Color shelf_color = nux::Color (0xCC000000);
1556+ nux::Color shelf_zero = nux::Color (0x00000000);
1557+ int shelf_shadow_height = 35;
1558+
1559+ nux::Geometry shelf_shadow = nux::Geometry (shelf_box.x, shelf_box.y - shelf_shadow_height, shelf_box.width, shelf_shadow_height);
1560+ gPainter.Paint2DQuadColor (GfxContext, shelf_shadow, shelf_zero, shelf_color, shelf_color, shelf_zero);
1561+ gPainter.Paint2DQuadColor (GfxContext, shelf_box, shelf_color);
1562+
1563+ for (it = shelf_args.begin(); it != shelf_args.end(); it++)
1564+ {
1565+ if ((*it).skip)
1566+ continue;
1567+
1568+ DrawRenderArg (GfxContext, *it, bkg_box);
1569+ }
1570+
1571+ gPainter.Paint2DQuadColor (GfxContext, nux::Geometry (bkg_box.x + bkg_box.width - 1, bkg_box.y, 1, bkg_box.height), nux::Color(0x60FFFFFF));
1572+
1573+ GfxContext.GetRenderStates().SetColorMask (true, true, true, true);
1574+ GfxContext.GetRenderStates ().SetSeparateBlend (false,
1575+ GL_SRC_ALPHA,
1576+ GL_ONE_MINUS_SRC_ALPHA,
1577+ GL_SRC_ALPHA,
1578+ GL_ONE_MINUS_SRC_ALPHA);
1579+
1580+ gPainter.PopBackground();
1581+ GfxContext.PopClippingRectangle();
1582+ GfxContext.PopClippingRectangle();
1583+}
1584+
1585+void Launcher::PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw)
1586+{
1587+}
1588+
1589+void Launcher::PreLayoutManagement()
1590+{
1591+ View::PreLayoutManagement();
1592+ if(m_CompositionLayout)
1593+ {
1594+ m_CompositionLayout->SetGeometry(GetGeometry());
1595+ }
1596+}
1597+
1598+long Launcher::PostLayoutManagement(long LayoutResult)
1599+{
1600+ View::PostLayoutManagement(LayoutResult);
1601+
1602+ _mouse_position = nux::Point2 (0, 0);
1603+
1604+ return nux::eCompliantHeight | nux::eCompliantWidth;
1605+}
1606+
1607+void Launcher::PositionChildLayout(float offsetX, float offsetY)
1608+{
1609+}
1610+
1611+bool Launcher::TooltipNotify(LauncherIcon* Icon)
1612+{
1613+ if(GetActiveMenuIcon())
1614+ return false;
1615+ return true;
1616+}
1617+
1618+bool Launcher::MenuNotify(LauncherIcon* Icon)
1619+{
1620+
1621+
1622+ return true;
1623+}
1624+
1625+void Launcher::NotifyMenuTermination(LauncherIcon* Icon)
1626+{
1627+}
1628+
1629+void Launcher::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
1630+{
1631+ _mouse_position = nux::Point2 (x, y);
1632+
1633+ MouseDownLogic (x, y, button_flags, key_flags);
1634+ EnsureAnimation ();
1635+}
1636+
1637+void Launcher::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
1638+{
1639+ _mouse_position = nux::Point2 (x, y);
1640+ nux::Geometry geo = GetGeometry ();
1641+
1642+ if (_launcher_action_state == ACTION_DRAG_LAUNCHER && !geo.IsInside(nux::Point(x, y)))
1643+ {
1644+ // we are no longer hovered
1645+ UnsetHover ();
1646+ }
1647+
1648+ MouseUpLogic (x, y, button_flags, key_flags);
1649+ _launcher_action_state = ACTION_NONE;
1650+ EnsureAnimation ();
1651+}
1652+
1653+void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
1654+{
1655+ _mouse_position = nux::Point2 (x, y);
1656+
1657+ _dnd_delta += dy;
1658+
1659+ if (nux::Abs (_dnd_delta) < 15 && _launcher_action_state != ACTION_DRAG_LAUNCHER)
1660+ return;
1661+
1662+ if (_icon_under_mouse)
1663+ {
1664+ _icon_under_mouse->MouseLeave.emit ();
1665+ _icon_under_mouse->_mouse_inside = false;
1666+ _icon_under_mouse = 0;
1667+ }
1668+
1669+ _launcher_action_state = ACTION_DRAG_LAUNCHER;
1670+ EnsureAnimation ();
1671+}
1672+
1673+void Launcher::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
1674+{
1675+ _mouse_position = nux::Point2 (x, y);
1676+ _mouse_inside_launcher = true;
1677+
1678+ if (!_last_shelf_area.IsInside (nux::Point (x, y)))
1679+ SetHover ();
1680+
1681+ EventLogic ();
1682+ EnsureAnimation ();
1683+}
1684+
1685+void Launcher::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
1686+{
1687+ _mouse_position = nux::Point2 (x, y);
1688+ _mouse_inside_launcher = false;
1689+
1690+ if (_launcher_action_state != ACTION_DRAG_LAUNCHER)
1691+ UnsetHover ();
1692+
1693+ EventLogic ();
1694+ EnsureAnimation ();
1695+}
1696+
1697+void Launcher::RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
1698+{
1699+ _mouse_position = nux::Point2 (x, y);
1700+
1701+ if (!_last_shelf_area.IsInside (nux::Point (x, y)))
1702+ {
1703+ SetHover ();
1704+ EnsureAnimation ();
1705+ }
1706+ // Every time the mouse moves, we check if it is inside an icon...
1707+
1708+ EventLogic ();
1709+}
1710+
1711+void Launcher::RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags)
1712+{
1713+}
1714+
1715+const gchar* Launcher::GetName ()
1716+{
1717+ return "Launcher";
1718+}
1719+
1720+void Launcher::AddProperties (GVariantBuilder *builder)
1721+{
1722+}
1723+
1724+void Launcher::EventLogic ()
1725+{
1726+ if (_launcher_action_state == ACTION_DRAG_LAUNCHER)
1727+ return;
1728+
1729+ LauncherIcon* launcher_icon = 0;
1730+
1731+ if (_mouse_inside_launcher)
1732+ launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);
1733+
1734+ if (_icon_under_mouse && (_icon_under_mouse != launcher_icon))
1735+ {
1736+ _icon_under_mouse->MouseLeave.emit ();
1737+ _icon_under_mouse->_mouse_inside = false;
1738+ _icon_under_mouse = 0;
1739+ }
1740+
1741+ if (launcher_icon && (_icon_under_mouse != launcher_icon))
1742+ {
1743+ launcher_icon->MouseEnter.emit ();
1744+ launcher_icon->_mouse_inside = true;
1745+ _icon_under_mouse = launcher_icon;
1746+ }
1747+}
1748+
1749+void Launcher::MouseDownLogic (int x, int y, unsigned long button_flags, unsigned long key_flags)
1750+{
1751+ LauncherIcon* launcher_icon = 0;
1752+ launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);
1753+
1754+ if (launcher_icon)
1755+ {
1756+ _icon_mouse_down = launcher_icon;
1757+ launcher_icon->MouseDown.emit (nux::GetEventButton (button_flags));
1758+ }
1759+}
1760+
1761+void Launcher::MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags)
1762+{
1763+ LauncherIcon* launcher_icon = 0;
1764+ launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);
1765+
1766+ if (_icon_mouse_down && (_icon_mouse_down == launcher_icon))
1767+ {
1768+ _icon_mouse_down->MouseUp.emit (nux::GetEventButton (button_flags));
1769+
1770+ if (_launcher_action_state != ACTION_DRAG_LAUNCHER)
1771+ _icon_mouse_down->MouseClick.emit (nux::GetEventButton (button_flags));
1772+ }
1773+
1774+ if (launcher_icon && (_icon_mouse_down != launcher_icon))
1775+ {
1776+ launcher_icon->MouseUp.emit (nux::GetEventButton (button_flags));
1777+ }
1778+
1779+ if (_launcher_action_state == ACTION_DRAG_LAUNCHER)
1780+ {
1781+ SetTimeStruct (&_drag_end_time);
1782+ }
1783+
1784+ _icon_mouse_down = 0;
1785+}
1786+
1787+LauncherIcon* Launcher::MouseIconIntersection (int x, int y)
1788+{
1789+ LauncherModel::iterator it;
1790+ LauncherModel::reverse_iterator rev_it;
1791+ // We are looking for the icon at screen coordinates x, y;
1792+ nux::Point2 mouse_position(x, y);
1793+ int inside = 0;
1794+
1795+ for (it = _model->shelf_begin(); it != _model->shelf_end (); it++)
1796+ {
1797+ if (!(*it)->GetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE))
1798+ continue;
1799+
1800+ nux::Point2 screen_coord [4];
1801+ for (int i = 0; i < 4; i++)
1802+ {
1803+ screen_coord [i].x = (*it)->_xform_coords["HitArea"] [i].x;
1804+ screen_coord [i].y = (*it)->_xform_coords["HitArea"] [i].y;
1805+ }
1806+ inside = PointInside2DPolygon (screen_coord, 4, mouse_position, 1);
1807+ if (inside)
1808+ return (*it);
1809+ }
1810+
1811+ // Because of the way icons fold and stack on one another, we must proceed in 2 steps.
1812+ for (rev_it = _model->rbegin (); rev_it != _model->rend (); rev_it++)
1813+ {
1814+ if ((*rev_it)->_folding_angle < 0.0f || !(*rev_it)->GetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE))
1815+ continue;
1816+
1817+ nux::Point2 screen_coord [4];
1818+ for (int i = 0; i < 4; i++)
1819+ {
1820+ screen_coord [i].x = (*rev_it)->_xform_coords["HitArea"] [i].x;
1821+ screen_coord [i].y = (*rev_it)->_xform_coords["HitArea"] [i].y;
1822+ }
1823+ inside = PointInside2DPolygon (screen_coord, 4, mouse_position, 1);
1824+ if (inside)
1825+ return (*rev_it);
1826+ }
1827+
1828+ for (it = _model->begin(); it != _model->end (); it++)
1829+ {
1830+ if ((*it)->_folding_angle >= 0.0f || !(*it)->GetQuirk (LAUNCHER_ICON_QUIRK_VISIBLE))
1831+ continue;
1832+
1833+ nux::Point2 screen_coord [4];
1834+ for (int i = 0; i < 4; i++)
1835+ {
1836+ screen_coord [i].x = (*it)->_xform_coords["HitArea"] [i].x;
1837+ screen_coord [i].y = (*it)->_xform_coords["HitArea"] [i].y;
1838+ }
1839+ inside = PointInside2DPolygon (screen_coord, 4, mouse_position, 1);
1840+ if (inside)
1841+ return (*it);
1842+ }
1843+
1844+ return 0;
1845+}
1846+
1847+void Launcher::SetIconXForm (LauncherIcon *icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry geo,
1848+ float x, float y, float w, float h, float z, std::string name)
1849+{
1850+ nux::Vector4 v0 = nux::Vector4(x, y, z, 1.0f);
1851+ nux::Vector4 v1 = nux::Vector4(x, y+h, z, 1.0f);
1852+ nux::Vector4 v2 = nux::Vector4(x+w, y+h, z, 1.0f);
1853+ nux::Vector4 v3 = nux::Vector4(x+w, y, z, 1.0f);
1854+
1855+ v0 = ViewProjectionMatrix * v0;
1856+ v1 = ViewProjectionMatrix * v1;
1857+ v2 = ViewProjectionMatrix * v2;
1858+ v3 = ViewProjectionMatrix * v3;
1859+
1860+ v0.divide_xyz_by_w();
1861+ v1.divide_xyz_by_w();
1862+ v2.divide_xyz_by_w();
1863+ v3.divide_xyz_by_w();
1864+
1865+ // normalize to the viewport coordinates and translate to the correct location
1866+ v0.x = geo.width *(v0.x + 1.0f)/2.0f - geo.width/2.0f + x + w/2.0f;
1867+ v0.y = -geo.height*(v0.y - 1.0f)/2.0f - geo.height/2.0f + y + h/2.0f;
1868+ v1.x = geo.width *(v1.x + 1.0f)/2.0f - geo.width/2.0f + x + w/2.0f;;
1869+ v1.y = -geo.height*(v1.y - 1.0f)/2.0f - geo.height/2.0f + y + h/2.0f;
1870+ v2.x = geo.width *(v2.x + 1.0f)/2.0f - geo.width/2.0f + x + w/2.0f;
1871+ v2.y = -geo.height*(v2.y - 1.0f)/2.0f - geo.height/2.0f + y + h/2.0f;
1872+ v3.x = geo.width *(v3.x + 1.0f)/2.0f - geo.width/2.0f + x + w/2.0f;
1873+ v3.y = -geo.height*(v3.y - 1.0f)/2.0f - geo.height/2.0f + y + h/2.0f;
1874+
1875+
1876+ nux::Vector4* vectors = icon->_xform_coords[name];
1877+
1878+ vectors[0].x = v0.x;
1879+ vectors[0].y = v0.y;
1880+ vectors[0].z = v0.z;
1881+ vectors[0].w = v0.w;
1882+ vectors[1].x = v1.x;
1883+ vectors[1].y = v1.y;
1884+ vectors[1].z = v1.z;
1885+ vectors[1].w = v1.w;
1886+ vectors[2].x = v2.x;
1887+ vectors[2].y = v2.y;
1888+ vectors[2].z = v2.z;
1889+ vectors[2].w = v2.w;
1890+ vectors[3].x = v3.x;
1891+ vectors[3].y = v3.y;
1892+ vectors[3].z = v3.z;
1893+ vectors[3].w = v3.w;
1894+}
1895+
1896+void Launcher::UpdateIconXForm (std::list<Launcher::RenderArg> args)
1897+{
1898+ nux::Geometry geo = GetGeometry ();
1899+ nux::Matrix4 ObjectMatrix;
1900+ nux::Matrix4 ViewMatrix;
1901+ nux::Matrix4 ProjectionMatrix;
1902+ nux::Matrix4 ViewProjectionMatrix;
1903+
1904+ GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90));
1905+
1906+ //LauncherModel::iterator it;
1907+ std::list<Launcher::RenderArg>::iterator it;
1908+ for(it = args.begin(); it != args.end(); it++)
1909+ {
1910+ if ((*it).skip)
1911+ continue;
1912+
1913+ LauncherIcon* launcher_icon = (*it).icon;
1914+
1915+ // We to store the icon angle in the icons itself. Makes one thing easier afterward.
1916+ launcher_icon->_folding_angle = (*it).folding_rads;
1917+
1918+ float w = _icon_size;
1919+ float h = _icon_size;
1920+ float x = (*it).center.x - w/2.0f; // x: top left corner
1921+ float y = (*it).center.y - h/2.0f; // y: top left corner
1922+ float z = (*it).center.z;
1923+
1924+ ObjectMatrix = nux::Matrix4::TRANSLATE(geo.width/2.0f, geo.height/2.0f, z) * // Translate the icon to the center of the viewport
1925+ nux::Matrix4::ROTATEX((*it).folding_rads) * // rotate the icon
1926+ nux::Matrix4::TRANSLATE(-x - w/2.0f, -y - h/2.0f, -z); // Put the center the icon to (0, 0)
1927+
1928+ ViewProjectionMatrix = ProjectionMatrix*ViewMatrix*ObjectMatrix;
1929+
1930+ SetIconXForm (launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, "Tile");
1931+
1932+ w = _icon_image_size;
1933+ h = _icon_image_size;
1934+ x = (*it).center.x - _icon_size/2.0f + _icon_image_size_delta/2.0f;
1935+ y = (*it).center.y - _icon_size/2.0f + _icon_image_size_delta/2.0f;
1936+ z = (*it).center.z;
1937+
1938+ SetIconXForm (launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, "Image");
1939+
1940+ w = _icon_glow_size;
1941+ h = _icon_glow_size;
1942+ x = (*it).center.x - _icon_glow_size/2.0f;
1943+ y = (*it).center.y - _icon_glow_size/2.0f;
1944+ z = (*it).center.z;
1945+
1946+ SetIconXForm (launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, "Glow");
1947+
1948+ w = geo.width + 2;
1949+ h = _icon_size + _space_between_icons;
1950+ x = (*it).center.x - w/2.0f;
1951+ y = (*it).center.y - h/2.0f;
1952+ z = (*it).center.z;
1953+
1954+ SetIconXForm (launcher_icon, ViewProjectionMatrix, geo, x, y, w, h, z, "HitArea");
1955+ }
1956+}
1957+
1958+void GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
1959+ int ViewportWidth,
1960+ int ViewportHeight,
1961+ float NearClipPlane,
1962+ float FarClipPlane,
1963+ float Fovy)
1964+{
1965+/*
1966+ Objective:
1967+ Given a perspective matrix defined by (Fovy, AspectRatio, NearPlane, FarPlane), we want to compute
1968+ the ModelView matrix that transform a quad defined by its top-left coord (0, 0) and its
1969+ bottom-right coord (WindowWidth, WindowHeight) into a full screen quad that covers the entire viewport (one to one).
1970+ Any quad that is facing the camera and whose 4 points are on the 4 guiding line of the view frustum (pyramid)
1971+ will always cover the entire viewport one to one (when projected on the screen).
1972+ So all we have to do is to define a quad with x:[-x_cs, x_cs] and y:[-y_cs, y_cs] and find the z distance in eye space (z_cs) so that
1973+ the quad touches the 4 guiding lines of the view frustum.
1974+ We consider a well centered projection view (no skewing, no oblique clipping plane, ...) and derive the following equations:
1975+ x_cs = AspectRatio*y_cs
1976+ y_cs/z_cs = tanf(Fovy/2) ==> z_cs = y_cs*1/tanf(Fovy/2) (this is the absolute value the quad depth value will be -z_cs since we are using OpenGL right hand coord system).
1977+
1978+ The quad (in camera space) facing the camera and centered around the camera view axis is defined by the points (-x_cs, y_cs) (top-left)
1979+ and the point (x_cs, -y_cs) (bottom-right). If we move that quad along the camera view axis and place it at a distance z_cs of the camera,
1980+ then its 4 corners are each on the 4 lines of the view frustum.
1981+
1982+ (-x_cs, y_cs) Camera Space
1983+ ^
1984+ __________|__________
1985+ | | |
1986+ | | |
1987+ | |(0, 0) |
1988+ |----------|----------|->
1989+ | | |
1990+ | | |
1991+ |__________|__________|
1992+ (x_cs, -y_cs)
1993+
1994+ The full-screen quad (in screen space) is defined by the point (0, 0) (top-left) and (WindowWidth, WindowHeight) (bottom-right).
1995+ We can choose and arbitrary value y_cs and compute the z_cs position in camera space that will produce a quad in camera space that projects into
1996+ the full-screen space.
1997+
1998+ (0, 0) Screen Space
1999+ _____________________->
2000+ | | |
2001+ | | |
2002+ | | |
2003+ |----------|----------|
2004+ | | |
2005+ | | |
2006+ |__________|__________|
2007+ v (WindowWidth, WindowHeight)
2008+
2009+ The model view matrix is the succession of transformation that convert the quad (0, 0, WindowWidth, WindowHeight) into
2010+ the quad (-x_cs, y_cs, x_cs, -y_cs)
2011+
2012+ Screen Space Camera Space
2013+ x ----> x_ = x*2*x_cs/WindowWidth - x_cs
2014+ y ----> y_ = -y*2*y_cs/WindowHeight + y_cs
2015+ z ----> z_ = A*z -y_cs*1/tanf(Fovy/2)
2016+ where A is a coefficient that can attenuate the rate of change in depth when the quad moves along the camera axis
2017+
2018+ If the following is the projection matrix:
2019+
2020+ (a, 0, 0, 0) a = 1/(AspectRatio*tan(Fovy/2))
2021+ (0, b, 0, 0) b = 1/tan(Fovy/2)
2022+ (0, 0, c, d)
2023+ (0, 0, -1, 0)
2024+
2025+ and the camera space vertex is (x_cs, y_cs, z_cs, w_cs) projects to the top left corner of the view port on the screen ((-1, 1) in clip space), then
2026+ x_cs*a/(-z_cs) = -1; | z_cs = x_cs*a x_cs*a = -y_cs*b ==> x_cs = y_cs*AspectRatio
2027+ | ==> ==>
2028+ y_cs*b/(-z_cs) = +1; | z_cs = -y_cs*b z_cs = -y_cs*1/tanf(Fovy/2)
2029+*/
2030+
2031+
2032+ float AspectRatio = (float)ViewportWidth/(float)ViewportHeight;
2033+ float CameraToScreenDistance = -1.0f;
2034+ float y_cs = -CameraToScreenDistance*tanf(0.5f*Fovy/* *3.1415926/180.0f*/);
2035+ float x_cs = y_cs*AspectRatio;
2036+ //float CameraToScreenDistance = -y_cs*1.0f/(tanf(0.5f*Fovy/* *3.1415926/180.0f*/));
2037+
2038+ ViewMatrix = nux::Matrix4::TRANSLATE(-x_cs, y_cs, CameraToScreenDistance) *
2039+ nux::Matrix4::SCALE(2.0f*x_cs/ViewportWidth, -2.0f*y_cs/ViewportHeight, -2.0f * 3 * y_cs/ViewportHeight /* or -2.0f * x_cs/ViewportWidth*/ );
2040+
2041+ PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane);
2042+
2043+// // Example usage with the matrices above:
2044+// float W = 300;
2045+// float H = 300;
2046+// // centered quad
2047+// float X = (ViewportWidth - W)/2.0;
2048+// float Y = (ViewportHeight - H)/2.0;
2049+// float Z = 0.0f;
2050+//
2051+// {
2052+// glPushMatrix();
2053+// // Local Transformation of the object
2054+// glTranslatef(0.0f, 0.0f, ObjectDistanceToCamera);
2055+// glTranslatef(X + W/2.0f, Y + H/2.0f, 0.0f);
2056+// glRotatef(cameraAngleY, 1, 0, 0);
2057+// glRotatef(cameraAngleX, 0, 1, 0);
2058+// glTranslatef(-X - W/2.0f, -Y - H/2.0f, 0.0f);
2059+//
2060+// glBegin(GL_QUADS);
2061+// {
2062+// glNormal3f(0.0f, 0.0f, 1.0f);
2063+//
2064+// glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
2065+// glVertex4f(X, Y, Z, 1.0f);
2066+//
2067+// glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
2068+// glVertex4f(X, Y+H, Z, 1.0f);
2069+//
2070+// glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
2071+// glVertex4f(X+W, Y+H, Z, 1.0f);
2072+//
2073+// glColor4f(0.0f, 1.0f, 1.0f, 1.0f);
2074+// glVertex4f(X+W, Y, Z, 1.0f);
2075+// }
2076+// glEnd();
2077+}
2078+
2079+void Launcher::SetActiveQuicklist (QuicklistView *quicklist)
2080+{
2081+ // Assert: _active_quicklist should be 0
2082+ _active_quicklist = quicklist;
2083+}
2084+
2085+QuicklistView *Launcher::GetActiveQuicklist ()
2086+{
2087+ return _active_quicklist;
2088+}
2089+
2090+void Launcher::CancelActiveQuicklist (QuicklistView *quicklist)
2091+{
2092+ if (_active_quicklist == quicklist)
2093+ _active_quicklist = 0;
2094+}
2095+
2096+>>>>>>> MERGE-SOURCE
2097
2098=== modified file 'src/Launcher.h'
2099--- src/Launcher.h 2010-12-01 22:28:50 +0000
2100+++ src/Launcher.h 2010-12-02 15:23:26 +0000
2101@@ -1,245 +1,494 @@
2102-/*
2103- * Copyright (C) 2010 Canonical Ltd
2104- *
2105- * This program is free software: you can redistribute it and/or modify
2106- * it under the terms of the GNU General Public License version 3 as
2107- * published by the Free Software Foundation.
2108- *
2109- * This program is distributed in the hope that it will be useful,
2110- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2111- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2112- * GNU General Public License for more details.
2113- *
2114- * You should have received a copy of the GNU General Public License
2115- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2116- *
2117- * Authored by: Jason Smith <jason.smith@canonical.com>
2118- * Authored by: Jay Taoko <jay.taoko@canonical.com>
2119- */
2120-
2121-#ifndef LAUNCHER_H
2122-#define LAUNCHER_H
2123-
2124-#include <sys/time.h>
2125-
2126-#include <Nux/View.h>
2127-#include <Nux/BaseWindow.h>
2128-#include "Introspectable.h"
2129-#include "LauncherIcon.h"
2130-#include "NuxGraphics/IOpenGLAsmShader.h"
2131-#include "Nux/TimerProc.h"
2132-
2133-class LauncherModel;
2134-class QuicklistView;
2135-
2136-class Launcher : public Introspectable, public nux::View
2137-{
2138-public:
2139- Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);
2140- ~Launcher();
2141-
2142- virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
2143- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
2144- virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
2145- virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
2146-
2147- LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
2148- LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
2149-
2150- bool TooltipNotify(LauncherIcon* Icon);
2151- bool MenuNotify(LauncherIcon* Icon);
2152-
2153- void SetIconSize(int tile_size, int icon_size);
2154- void NotifyMenuTermination(LauncherIcon* Icon);
2155-
2156- void SetModel (LauncherModel *model);
2157-
2158- void SetFloating (bool floating);
2159-
2160- void SetAutohide (bool autohide, nux::View *show_trigger);
2161- bool AutohideEnabled ();
2162-
2163- virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
2164- virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
2165- virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2166- virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
2167- virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
2168- virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2169- virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
2170-
2171- //! Called by LauncherIcon to signal that a Quicklist is becoming active.
2172- void SetActiveQuicklist (QuicklistView *quicklist);
2173- //! Get the active qicklist
2174- QuicklistView *GetActiveQuicklist ();
2175- //! Called by LauncherIcon to signal that a Quicklist is becoming unactive.
2176- void CancelActiveQuicklist (QuicklistView *quicklist);
2177-
2178-protected:
2179- // Introspectable methods
2180- const gchar* GetName ();
2181- void AddProperties (GVariantBuilder *builder);
2182-
2183-private:
2184- typedef enum
2185- {
2186- LAUNCHER_FOLDED,
2187- LAUNCHER_UNFOLDED
2188- } LauncherState;
2189-
2190- typedef enum
2191- {
2192- ACTION_NONE,
2193- ACTION_DRAG_LAUNCHER,
2194- ACTION_DRAG_ICON,
2195- } LauncherActionState;
2196-
2197- typedef struct
2198- {
2199- LauncherIcon *icon;
2200- nux::Point3 center;
2201- float folding_rads;
2202- float alpha;
2203- float backlight_intensity;
2204- float glow_intensity;
2205- float shimmer_progress;
2206- bool running_arrow;
2207- bool active_arrow;
2208- bool skip;
2209- int window_indicators;
2210- } RenderArg;
2211-
2212- static gboolean AnimationTimeout (gpointer data);
2213- static gboolean OnAutohideTimeout (gpointer data);
2214- static gboolean StrutHack (gpointer data);
2215-
2216- void OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
2217- void OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
2218-
2219- bool IconNeedsAnimation (LauncherIcon *icon, struct timespec current);
2220- bool AnimationInProgress ();
2221- void SetTimeStruct (struct timespec *timer, struct timespec *sister = 0, int sister_relation = 0);
2222-
2223- void EnsureAnimation ();
2224- void SetupAutohideTimer ();
2225-
2226- float DnDExitProgress ();
2227- float GetHoverProgress ();
2228- float AutohideProgress ();
2229- float IconPresentProgress (LauncherIcon *icon, struct timespec current);
2230- float IconUrgentProgress (LauncherIcon *icon, struct timespec current);
2231- float IconShimmerProgress (LauncherIcon *icon, struct timespec current);
2232- float IconUrgentPulseValue (LauncherIcon *icon, struct timespec current);
2233- float IconStartingPulseValue (LauncherIcon *icon, struct timespec current);
2234- float IconBackgroundIntensity (LauncherIcon *icon, struct timespec current);
2235-
2236- void SetHover ();
2237- void UnsetHover ();
2238- void SetHidden (bool hidden);
2239-
2240- void SetDndDelta (float x, float y, nux::Geometry geo, struct timespec current);
2241-
2242- void SetupRenderArg (LauncherIcon *icon, struct timespec current, RenderArg &arg);
2243- void RenderArgs (std::list<Launcher::RenderArg> &launcher_args,
2244- std::list<Launcher::RenderArg> &shelf_args,
2245- nux::Geometry &box_geo, nux::Geometry &shelf_geo);
2246-
2247- void DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg arg, nux::Geometry geo);
2248-
2249- void OnIconAdded (void *icon_pointer);
2250- void OnIconRemoved (void *icon_pointer);
2251- void OnOrderChanged ();
2252-
2253- void OnIconNeedsRedraw (void *icon);
2254-
2255- void RenderIcon (nux::GraphicsEngine& GfxContext,
2256- RenderArg arg,
2257- nux::BaseTexture *icon,
2258- nux::Color bkg_color,
2259- float alpha,
2260- nux::Vector4 xform_coords[],
2261- nux::Geometry geo,
2262- bool render_indicators);
2263-
2264- void SetIconXForm (LauncherIcon *icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry geo,
2265- float x, float y, float w, float h, float z, std::string name);
2266- void UpdateIconXForm (std::list<Launcher::RenderArg> args);
2267-
2268- LauncherIcon* MouseIconIntersection (int x, int y);
2269- void EventLogic ();
2270- void MouseDownLogic (int x, int y, unsigned long button_flags, unsigned long key_flags);
2271- void MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags);
2272-
2273- virtual void PreLayoutManagement();
2274- virtual long PostLayoutManagement(long LayoutResult);
2275- virtual void PositionChildLayout(float offsetX, float offsetY);
2276-
2277-
2278- nux::HLayout* m_Layout;
2279- int m_ContentOffsetY;
2280-
2281- LauncherIcon* m_ActiveTooltipIcon;
2282- LauncherIcon* m_ActiveMenuIcon;
2283-
2284-
2285- QuicklistView* _active_quicklist;
2286-
2287- bool _hovered;
2288- bool _floating;
2289- bool _autohide;
2290- bool _hidden;
2291- bool _mouse_inside_launcher;
2292-
2293- float _folded_angle;
2294- float _neg_folded_angle;
2295- float _folded_z_distance;
2296- float _launcher_top_y;
2297- float _launcher_bottom_y;
2298-
2299- LauncherState _launcher_state;
2300- LauncherActionState _launcher_action_state;
2301- LauncherIcon* _icon_under_mouse;
2302- LauncherIcon* _icon_mouse_down;
2303-
2304- int _space_between_icons;
2305- int _icon_size;
2306- int _icon_image_size;
2307- int _icon_image_size_delta;
2308- int _icon_glow_size;
2309- int _dnd_delta;
2310- int _dnd_security;
2311- int _enter_y;
2312-
2313- nux::BaseTexture* _icon_bkg_texture;
2314- nux::BaseTexture* _icon_shine_texture;
2315- nux::BaseTexture* _icon_outline_texture;
2316- nux::BaseTexture* _icon_glow_texture;
2317- nux::BaseTexture* _icon_2indicator;
2318- nux::BaseTexture* _icon_3indicator;
2319- nux::BaseTexture* _icon_4indicator;
2320-
2321- guint _anim_handle;
2322- guint _autohide_handle;
2323-
2324- nux::Matrix4 _view_matrix;
2325- nux::Matrix4 _projection_matrix;
2326- nux::Point2 _mouse_position;
2327- nux::IntrusiveSP<nux::IOpenGLShaderProgram> _shader_program_uv_persp_correction;
2328- nux::IntrusiveSP<nux::IOpenGLAsmShaderProgram> _AsmShaderProg;
2329- nux::BaseTexture* m_RunningIndicator;
2330- nux::BaseTexture* m_ActiveIndicator;
2331- nux::AbstractPaintLayer* m_BackgroundLayer;
2332- nux::BaseWindow* _parent;
2333- nux::View* _autohide_trigger;
2334- nux::Geometry _last_shelf_area;
2335- LauncherModel* _model;
2336-
2337- /* event times */
2338- struct timespec _enter_time;
2339- struct timespec _exit_time;
2340- struct timespec _drag_end_time;
2341- struct timespec _autohide_time;
2342-};
2343-
2344-#endif // LAUNCHER_H
2345-
2346-
2347+<<<<<<< TREE
2348+/*
2349+ * Copyright (C) 2010 Canonical Ltd
2350+ *
2351+ * This program is free software: you can redistribute it and/or modify
2352+ * it under the terms of the GNU General Public License version 3 as
2353+ * published by the Free Software Foundation.
2354+ *
2355+ * This program is distributed in the hope that it will be useful,
2356+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2357+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2358+ * GNU General Public License for more details.
2359+ *
2360+ * You should have received a copy of the GNU General Public License
2361+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2362+ *
2363+ * Authored by: Jason Smith <jason.smith@canonical.com>
2364+ * Authored by: Jay Taoko <jay.taoko@canonical.com>
2365+ */
2366+
2367+#ifndef LAUNCHER_H
2368+#define LAUNCHER_H
2369+
2370+#include <sys/time.h>
2371+
2372+#include <Nux/View.h>
2373+#include <Nux/BaseWindow.h>
2374+#include "Introspectable.h"
2375+#include "LauncherIcon.h"
2376+#include "NuxGraphics/IOpenGLAsmShader.h"
2377+#include "Nux/TimerProc.h"
2378+
2379+class LauncherModel;
2380+class QuicklistView;
2381+
2382+class Launcher : public Introspectable, public nux::View
2383+{
2384+public:
2385+ Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);
2386+ ~Launcher();
2387+
2388+ virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
2389+ virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
2390+ virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
2391+ virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
2392+
2393+ LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
2394+ LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
2395+
2396+ bool TooltipNotify(LauncherIcon* Icon);
2397+ bool MenuNotify(LauncherIcon* Icon);
2398+
2399+ void SetIconSize(int tile_size, int icon_size);
2400+ void NotifyMenuTermination(LauncherIcon* Icon);
2401+
2402+ void SetModel (LauncherModel *model);
2403+
2404+ void SetFloating (bool floating);
2405+
2406+ void SetAutohide (bool autohide, nux::View *show_trigger);
2407+ bool AutohideEnabled ();
2408+
2409+ virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
2410+ virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
2411+ virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2412+ virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
2413+ virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
2414+ virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2415+ virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
2416+
2417+ //! Called by LauncherIcon to signal that a Quicklist is becoming active.
2418+ void SetActiveQuicklist (QuicklistView *quicklist);
2419+ //! Get the active qicklist
2420+ QuicklistView *GetActiveQuicklist ();
2421+ //! Called by LauncherIcon to signal that a Quicklist is becoming unactive.
2422+ void CancelActiveQuicklist (QuicklistView *quicklist);
2423+
2424+protected:
2425+ // Introspectable methods
2426+ const gchar* GetName ();
2427+ void AddProperties (GVariantBuilder *builder);
2428+
2429+private:
2430+ typedef enum
2431+ {
2432+ LAUNCHER_FOLDED,
2433+ LAUNCHER_UNFOLDED
2434+ } LauncherState;
2435+
2436+ typedef enum
2437+ {
2438+ ACTION_NONE,
2439+ ACTION_DRAG_LAUNCHER,
2440+ ACTION_DRAG_ICON,
2441+ } LauncherActionState;
2442+
2443+ typedef struct
2444+ {
2445+ LauncherIcon *icon;
2446+ nux::Point3 center;
2447+ float folding_rads;
2448+ float alpha;
2449+ float backlight_intensity;
2450+ float glow_intensity;
2451+ float shimmer_progress;
2452+ bool running_arrow;
2453+ bool active_arrow;
2454+ bool skip;
2455+ int window_indicators;
2456+ } RenderArg;
2457+
2458+ static gboolean AnimationTimeout (gpointer data);
2459+ static gboolean OnAutohideTimeout (gpointer data);
2460+ static gboolean StrutHack (gpointer data);
2461+
2462+ void OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
2463+ void OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
2464+
2465+ bool IconNeedsAnimation (LauncherIcon *icon, struct timespec current);
2466+ bool AnimationInProgress ();
2467+ void SetTimeStruct (struct timespec *timer, struct timespec *sister = 0, int sister_relation = 0);
2468+
2469+ void EnsureAnimation ();
2470+ void SetupAutohideTimer ();
2471+
2472+ float DnDExitProgress ();
2473+ float GetHoverProgress ();
2474+ float AutohideProgress ();
2475+ float IconPresentProgress (LauncherIcon *icon, struct timespec current);
2476+ float IconUrgentProgress (LauncherIcon *icon, struct timespec current);
2477+ float IconShimmerProgress (LauncherIcon *icon, struct timespec current);
2478+ float IconUrgentPulseValue (LauncherIcon *icon, struct timespec current);
2479+ float IconStartingPulseValue (LauncherIcon *icon, struct timespec current);
2480+ float IconBackgroundIntensity (LauncherIcon *icon, struct timespec current);
2481+
2482+ void SetHover ();
2483+ void UnsetHover ();
2484+ void SetHidden (bool hidden);
2485+
2486+ void SetDndDelta (float x, float y, nux::Geometry geo, struct timespec current);
2487+
2488+ void SetupRenderArg (LauncherIcon *icon, struct timespec current, RenderArg &arg);
2489+ void RenderArgs (std::list<Launcher::RenderArg> &launcher_args,
2490+ std::list<Launcher::RenderArg> &shelf_args,
2491+ nux::Geometry &box_geo, nux::Geometry &shelf_geo);
2492+
2493+ void DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg arg, nux::Geometry geo);
2494+
2495+ void OnIconAdded (void *icon_pointer);
2496+ void OnIconRemoved (void *icon_pointer);
2497+ void OnOrderChanged ();
2498+
2499+ void OnIconNeedsRedraw (void *icon);
2500+
2501+ void RenderIcon (nux::GraphicsEngine& GfxContext,
2502+ RenderArg arg,
2503+ nux::BaseTexture *icon,
2504+ nux::Color bkg_color,
2505+ float alpha,
2506+ nux::Vector4 xform_coords[],
2507+ nux::Geometry geo,
2508+ bool render_indicators);
2509+
2510+ void SetIconXForm (LauncherIcon *icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry geo,
2511+ float x, float y, float w, float h, float z, std::string name);
2512+ void UpdateIconXForm (std::list<Launcher::RenderArg> args);
2513+
2514+ LauncherIcon* MouseIconIntersection (int x, int y);
2515+ void EventLogic ();
2516+ void MouseDownLogic (int x, int y, unsigned long button_flags, unsigned long key_flags);
2517+ void MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags);
2518+
2519+ virtual void PreLayoutManagement();
2520+ virtual long PostLayoutManagement(long LayoutResult);
2521+ virtual void PositionChildLayout(float offsetX, float offsetY);
2522+
2523+
2524+ nux::HLayout* m_Layout;
2525+ int m_ContentOffsetY;
2526+
2527+ LauncherIcon* m_ActiveTooltipIcon;
2528+ LauncherIcon* m_ActiveMenuIcon;
2529+
2530+
2531+ QuicklistView* _active_quicklist;
2532+
2533+ bool _hovered;
2534+ bool _floating;
2535+ bool _autohide;
2536+ bool _hidden;
2537+ bool _mouse_inside_launcher;
2538+
2539+ float _folded_angle;
2540+ float _neg_folded_angle;
2541+ float _folded_z_distance;
2542+ float _launcher_top_y;
2543+ float _launcher_bottom_y;
2544+
2545+ LauncherState _launcher_state;
2546+ LauncherActionState _launcher_action_state;
2547+ LauncherIcon* _icon_under_mouse;
2548+ LauncherIcon* _icon_mouse_down;
2549+
2550+ int _space_between_icons;
2551+ int _icon_size;
2552+ int _icon_image_size;
2553+ int _icon_image_size_delta;
2554+ int _icon_glow_size;
2555+ int _dnd_delta;
2556+ int _dnd_security;
2557+ int _enter_y;
2558+
2559+ nux::BaseTexture* _icon_bkg_texture;
2560+ nux::BaseTexture* _icon_shine_texture;
2561+ nux::BaseTexture* _icon_outline_texture;
2562+ nux::BaseTexture* _icon_glow_texture;
2563+ nux::BaseTexture* _icon_2indicator;
2564+ nux::BaseTexture* _icon_3indicator;
2565+ nux::BaseTexture* _icon_4indicator;
2566+
2567+ guint _anim_handle;
2568+ guint _autohide_handle;
2569+
2570+ nux::Matrix4 _view_matrix;
2571+ nux::Matrix4 _projection_matrix;
2572+ nux::Point2 _mouse_position;
2573+ nux::IntrusiveSP<nux::IOpenGLShaderProgram> _shader_program_uv_persp_correction;
2574+ nux::IntrusiveSP<nux::IOpenGLAsmShaderProgram> _AsmShaderProg;
2575+ nux::BaseTexture* m_RunningIndicator;
2576+ nux::BaseTexture* m_ActiveIndicator;
2577+ nux::AbstractPaintLayer* m_BackgroundLayer;
2578+ nux::BaseWindow* _parent;
2579+ nux::View* _autohide_trigger;
2580+ nux::Geometry _last_shelf_area;
2581+ LauncherModel* _model;
2582+
2583+ /* event times */
2584+ struct timespec _enter_time;
2585+ struct timespec _exit_time;
2586+ struct timespec _drag_end_time;
2587+ struct timespec _autohide_time;
2588+};
2589+
2590+#endif // LAUNCHER_H
2591+
2592+
2593+=======
2594+/*
2595+ * Copyright (C) 2010 Canonical Ltd
2596+ *
2597+ * This program is free software: you can redistribute it and/or modify
2598+ * it under the terms of the GNU General Public License version 3 as
2599+ * published by the Free Software Foundation.
2600+ *
2601+ * This program is distributed in the hope that it will be useful,
2602+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2603+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2604+ * GNU General Public License for more details.
2605+ *
2606+ * You should have received a copy of the GNU General Public License
2607+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2608+ *
2609+ * Authored by: Jason Smith <jason.smith@canonical.com>
2610+ * Authored by: Jay Taoko <jay.taoko@canonical.com>
2611+ */
2612+
2613+#ifndef LAUNCHER_H
2614+#define LAUNCHER_H
2615+
2616+#include <sys/time.h>
2617+
2618+#include <Nux/View.h>
2619+#include <Nux/BaseWindow.h>
2620+#include "Introspectable.h"
2621+#include "LauncherIcon.h"
2622+#include "NuxGraphics/IOpenGLAsmShader.h"
2623+#include "Nux/TimerProc.h"
2624+
2625+class LauncherModel;
2626+class QuicklistView;
2627+
2628+class Launcher : public Introspectable, public nux::View
2629+{
2630+public:
2631+ Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);
2632+ ~Launcher();
2633+
2634+ virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
2635+ virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
2636+ virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
2637+ virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
2638+
2639+ LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
2640+ LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
2641+
2642+ bool TooltipNotify(LauncherIcon* Icon);
2643+ bool MenuNotify(LauncherIcon* Icon);
2644+
2645+ void SetIconSize(int tile_size, int icon_size);
2646+ void NotifyMenuTermination(LauncherIcon* Icon);
2647+
2648+ void SetModel (LauncherModel *model);
2649+
2650+ void SetFloating (bool floating);
2651+
2652+ void SetAutohide (bool autohide, nux::View *show_trigger);
2653+ bool AutohideEnabled ();
2654+
2655+ virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
2656+ virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
2657+ virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2658+ virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
2659+ virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
2660+ virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
2661+ virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
2662+
2663+ //! Called by LauncherIcon to signal that a Quicklist is becoming active.
2664+ void SetActiveQuicklist (QuicklistView *quicklist);
2665+ //! Get the active qicklist
2666+ QuicklistView *GetActiveQuicklist ();
2667+ //! Called by LauncherIcon to signal that a Quicklist is becoming unactive.
2668+ void CancelActiveQuicklist (QuicklistView *quicklist);
2669+
2670+protected:
2671+ // Introspectable methods
2672+ const gchar* GetName ();
2673+ void AddProperties (GVariantBuilder *builder);
2674+
2675+private:
2676+ typedef enum
2677+ {
2678+ LAUNCHER_FOLDED,
2679+ LAUNCHER_UNFOLDED
2680+ } LauncherState;
2681+
2682+ typedef enum
2683+ {
2684+ ACTION_NONE,
2685+ ACTION_DRAG_LAUNCHER,
2686+ ACTION_DRAG_ICON,
2687+ } LauncherActionState;
2688+
2689+ typedef struct
2690+ {
2691+ LauncherIcon *icon;
2692+ nux::Point3 center;
2693+ float folding_rads;
2694+ float alpha;
2695+ float backlight_intensity;
2696+ float glow_intensity;
2697+ float shimmer_progress;
2698+ bool running_arrow;
2699+ bool active_arrow;
2700+ bool skip;
2701+ int window_indicators;
2702+ } RenderArg;
2703+
2704+ static gboolean AnimationTimeout (gpointer data);
2705+ static gboolean OnAutohideTimeout (gpointer data);
2706+ static gboolean StrutHack (gpointer data);
2707+
2708+ void OnTriggerMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
2709+ void OnTriggerMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
2710+
2711+ bool IconNeedsAnimation (LauncherIcon *icon, struct timespec current);
2712+ bool AnimationInProgress ();
2713+ void SetTimeStruct (struct timespec *timer, struct timespec *sister = 0, int sister_relation = 0);
2714+
2715+ void EnsureAnimation ();
2716+ void SetupAutohideTimer ();
2717+
2718+ float DnDExitProgress ();
2719+ float GetHoverProgress ();
2720+ float AutohideProgress ();
2721+ float IconPresentProgress (LauncherIcon *icon, struct timespec current);
2722+ float IconUrgentProgress (LauncherIcon *icon, struct timespec current);
2723+ float IconShimmerProgress (LauncherIcon *icon, struct timespec current);
2724+ float IconUrgentPulseValue (LauncherIcon *icon, struct timespec current);
2725+ float IconStartingPulseValue (LauncherIcon *icon, struct timespec current);
2726+ float IconBackgroundIntensity (LauncherIcon *icon, struct timespec current);
2727+
2728+ void SetHover ();
2729+ void UnsetHover ();
2730+ void SetHidden (bool hidden);
2731+
2732+ void SetDndDelta (float x, float y, nux::Geometry geo, struct timespec current);
2733+ int DragLimiter (int x);
2734+
2735+ void SetupRenderArg (LauncherIcon *icon, struct timespec current, RenderArg &arg);
2736+ void RenderArgs (std::list<Launcher::RenderArg> &launcher_args,
2737+ std::list<Launcher::RenderArg> &shelf_args,
2738+ nux::Geometry &box_geo, nux::Geometry &shelf_geo);
2739+
2740+ void DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg arg, nux::Geometry geo);
2741+
2742+ void OnIconAdded (void *icon_pointer);
2743+ void OnIconRemoved (void *icon_pointer);
2744+ void OnOrderChanged ();
2745+
2746+ void OnIconNeedsRedraw (void *icon);
2747+
2748+ void RenderIcon (nux::GraphicsEngine& GfxContext,
2749+ RenderArg arg,
2750+ nux::BaseTexture *icon,
2751+ nux::Color bkg_color,
2752+ float alpha,
2753+ nux::Vector4 xform_coords[],
2754+ nux::Geometry geo,
2755+ bool render_indicators);
2756+
2757+ void SetIconXForm (LauncherIcon *icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry geo,
2758+ float x, float y, float w, float h, float z, std::string name);
2759+ void UpdateIconXForm (std::list<Launcher::RenderArg> args);
2760+
2761+ LauncherIcon* MouseIconIntersection (int x, int y);
2762+ void EventLogic ();
2763+ void MouseDownLogic (int x, int y, unsigned long button_flags, unsigned long key_flags);
2764+ void MouseUpLogic (int x, int y, unsigned long button_flags, unsigned long key_flags);
2765+
2766+ virtual void PreLayoutManagement();
2767+ virtual long PostLayoutManagement(long LayoutResult);
2768+ virtual void PositionChildLayout(float offsetX, float offsetY);
2769+
2770+
2771+ nux::HLayout* m_Layout;
2772+ int m_ContentOffsetY;
2773+
2774+ LauncherIcon* m_ActiveTooltipIcon;
2775+ LauncherIcon* m_ActiveMenuIcon;
2776+
2777+
2778+ QuicklistView* _active_quicklist;
2779+
2780+ bool _hovered;
2781+ bool _floating;
2782+ bool _autohide;
2783+ bool _hidden;
2784+ bool _mouse_inside_launcher;
2785+
2786+ float _folded_angle;
2787+ float _neg_folded_angle;
2788+ float _folded_z_distance;
2789+ float _launcher_top_y;
2790+ float _launcher_bottom_y;
2791+
2792+ LauncherState _launcher_state;
2793+ LauncherActionState _launcher_action_state;
2794+ LauncherIcon* _icon_under_mouse;
2795+ LauncherIcon* _icon_mouse_down;
2796+
2797+ int _space_between_icons;
2798+ int _icon_size;
2799+ int _icon_image_size;
2800+ int _icon_image_size_delta;
2801+ int _icon_glow_size;
2802+ int _dnd_delta;
2803+ int _dnd_security;
2804+ int _enter_y;
2805+
2806+ nux::BaseTexture* _icon_bkg_texture;
2807+ nux::BaseTexture* _icon_shine_texture;
2808+ nux::BaseTexture* _icon_outline_texture;
2809+ nux::BaseTexture* _icon_glow_texture;
2810+ nux::BaseTexture* _icon_2indicator;
2811+ nux::BaseTexture* _icon_3indicator;
2812+ nux::BaseTexture* _icon_4indicator;
2813+
2814+ guint _anim_handle;
2815+ guint _autohide_handle;
2816+
2817+ nux::Matrix4 _view_matrix;
2818+ nux::Matrix4 _projection_matrix;
2819+ nux::Point2 _mouse_position;
2820+ nux::IntrusiveSP<nux::IOpenGLShaderProgram> _shader_program_uv_persp_correction;
2821+ nux::IntrusiveSP<nux::IOpenGLAsmShaderProgram> _AsmShaderProg;
2822+ nux::BaseTexture* m_RunningIndicator;
2823+ nux::BaseTexture* m_ActiveIndicator;
2824+ nux::AbstractPaintLayer* m_BackgroundLayer;
2825+ nux::BaseWindow* _parent;
2826+ nux::View* _autohide_trigger;
2827+ nux::Geometry _last_shelf_area;
2828+ LauncherModel* _model;
2829+
2830+ /* event times */
2831+ struct timespec _enter_time;
2832+ struct timespec _exit_time;
2833+ struct timespec _drag_end_time;
2834+ struct timespec _autohide_time;
2835+};
2836+
2837+#endif // LAUNCHER_H
2838+
2839+
2840+>>>>>>> MERGE-SOURCE
2841
2842=== modified file 'src/LauncherController.cpp'
2843--- src/LauncherController.cpp 2010-11-30 04:42:47 +0000
2844+++ src/LauncherController.cpp 2010-12-02 15:23:26 +0000
2845@@ -72,8 +72,11 @@
2846 }
2847 }
2848
2849- owner->Present (2, 600);
2850- owner->UpdateQuirkTimeDelayed (300, LAUNCHER_ICON_QUIRK_SHIMMER);
2851+ if (owner)
2852+ {
2853+ owner->Present (2, 600);
2854+ owner->UpdateQuirkTimeDelayed (300, LAUNCHER_ICON_QUIRK_SHIMMER);
2855+ }
2856 }
2857
2858 void