diff options
| -rw-r--r-- | data/2indicate_54x54.png | bin | 0 -> 316 bytes | |||
| -rw-r--r-- | data/3indicate_54x54.png | bin | 0 -> 297 bytes | |||
| -rw-r--r-- | data/4indicate_54x54.png | bin | 0 -> 311 bytes | |||
| -rw-r--r-- | src/BamfLauncherIcon.cpp | 34 | ||||
| -rw-r--r-- | src/BamfLauncherIcon.h | 3 | ||||
| -rw-r--r-- | src/Launcher.cpp | 102 | ||||
| -rw-r--r-- | src/Launcher.h | 6 | ||||
| -rw-r--r-- | src/LauncherIcon.cpp | 17 | ||||
| -rw-r--r-- | src/LauncherIcon.h | 4 |
9 files changed, 118 insertions, 48 deletions
diff --git a/data/2indicate_54x54.png b/data/2indicate_54x54.png Binary files differnew file mode 100644 index 000000000..5b89cbc3c --- /dev/null +++ b/data/2indicate_54x54.png diff --git a/data/3indicate_54x54.png b/data/3indicate_54x54.png Binary files differnew file mode 100644 index 000000000..1bfb72bc8 --- /dev/null +++ b/data/3indicate_54x54.png diff --git a/data/4indicate_54x54.png b/data/4indicate_54x54.png Binary files differnew file mode 100644 index 000000000..065677772 --- /dev/null +++ b/data/4indicate_54x54.png diff --git a/src/BamfLauncherIcon.cpp b/src/BamfLauncherIcon.cpp index 463151dd8..452308faf 100644 --- a/src/BamfLauncherIcon.cpp +++ b/src/BamfLauncherIcon.cpp @@ -27,6 +27,8 @@ BamfLauncherIcon::BamfLauncherIcon (Launcher* IconManager, BamfApplication *app, g_free (icon_name); + g_signal_connect (app, "child-removed", (GCallback) &BamfLauncherIcon::OnChildRemoved, this); + g_signal_connect (app, "child-added", (GCallback) &BamfLauncherIcon::OnChildAdded, this); g_signal_connect (app, "urgent-changed", (GCallback) &BamfLauncherIcon::OnUrgentChanged, this); g_signal_connect (app, "running-changed", (GCallback) &BamfLauncherIcon::OnRunningChanged, this); g_signal_connect (app, "active-changed", (GCallback) &BamfLauncherIcon::OnActiveChanged, this); @@ -34,6 +36,8 @@ BamfLauncherIcon::BamfLauncherIcon (Launcher* IconManager, BamfApplication *app, g_signal_connect (app, "closed", (GCallback) &BamfLauncherIcon::OnClosed, this); g_object_ref (m_App); + + EnsureWindowState (); } BamfLauncherIcon::~BamfLauncherIcon() @@ -140,3 +144,33 @@ BamfLauncherIcon::OnUrgentChanged (BamfView *view, gboolean urgent, gpointer dat BamfLauncherIcon *self = (BamfLauncherIcon *) data; self->SetUrgent (urgent); } + +void +BamfLauncherIcon::EnsureWindowState () +{ + GList *children, *l; + int count = 0; + + children = bamf_view_get_children (BAMF_VIEW (m_App)); + for (l = children; l; l = l->next) + { + if (BAMF_IS_WINDOW (l->data)) + count++; + } + + SetRelatedWindows (count); +} + +void +BamfLauncherIcon::OnChildAdded (BamfView *view, BamfView *child, gpointer data) +{ + BamfLauncherIcon *self = (BamfLauncherIcon*) data; + self->EnsureWindowState (); +} + +void +BamfLauncherIcon::OnChildRemoved (BamfView *view, BamfView *child, gpointer data) +{ + BamfLauncherIcon *self = (BamfLauncherIcon*) data; + self->EnsureWindowState (); +} diff --git a/src/BamfLauncherIcon.h b/src/BamfLauncherIcon.h index 56c1fba1a..8bf98d8d4 100644 --- a/src/BamfLauncherIcon.h +++ b/src/BamfLauncherIcon.h @@ -25,12 +25,15 @@ private: CompScreen *m_Screen; void OnMouseClick (); + void EnsureWindowState (); static void OnClosed (BamfView *view, gpointer data); static void OnUserVisibleChanged (BamfView *view, gboolean visible, gpointer data); static void OnActiveChanged (BamfView *view, gboolean active, gpointer data); static void OnRunningChanged (BamfView *view, gboolean running, gpointer data); static void OnUrgentChanged (BamfView *view, gboolean urgent, gpointer data); + static void OnChildAdded (BamfView *view, BamfView *child, gpointer data); + static void OnChildRemoved (BamfView *view, BamfView *child, gpointer data); }; #endif // BAMFLAUNCHERICON_H diff --git a/src/Launcher.cpp b/src/Launcher.cpp index af41ea6dc..2e161d069 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -205,9 +205,14 @@ Launcher::Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_DECL) _icon_image_size = 48; _icon_image_size_delta = 6; _icon_size = _icon_image_size + _icon_image_size_delta; + _icon_bkg_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_corner_54x54.png"); _icon_outline_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_outline_54x54.png"); _icon_shine_texture = nux::CreateTextureFromFile (PKGDATADIR"/round_shine_54x54.png"); + _icon_2indicator = nux::CreateTextureFromFile (PKGDATADIR"/2indicate_54x54.png"); + _icon_3indicator = nux::CreateTextureFromFile (PKGDATADIR"/3indicate_54x54.png"); + _icon_4indicator = nux::CreateTextureFromFile (PKGDATADIR"/4indicate_54x54.png"); + _dnd_security = 15; _dnd_delta = 0; _anim_handle = 0; @@ -483,6 +488,12 @@ std::list<Launcher::RenderArg> Launcher::RenderArgs (nux::Geometry &box_geo) arg.folding_rads = 0.0f; arg.skip = false; + arg.window_indicators = MIN (4, icon->RelatedWindows ()); + + // we dont need to show strays + if (arg.window_indicators == 1 || !icon->Running ()) + arg.window_indicators = 0; + // animate this shit struct timeval running_time = icon->RunningTime (); int running_ms = TimeDelta (¤t, &running_time); @@ -1056,6 +1067,47 @@ void Launcher::RenderIconImage(nux::GraphicsEngine& GfxContext, RenderArg arg) } } +void Launcher::DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg arg) +{ + GfxContext.GetRenderStates ().SetSeparateBlend (true, + GL_SRC_ALPHA, + GL_ONE_MINUS_SRC_ALPHA, + GL_ONE_MINUS_DST_ALPHA, + GL_ONE); + + GfxContext.GetRenderStates ().SetColorMask (true, true, true, true); + + if (arg.backlight_intensity < 1.0f) + RenderIcon(GfxContext, arg, _icon_outline_texture, nux::Color(0xFF6D6D6D), 1.0f - arg.backlight_intensity); + if (arg.backlight_intensity > 0.0f) + RenderIcon(GfxContext, arg, _icon_bkg_texture, arg.icon->BackgroundColor (), arg.backlight_intensity); + + GfxContext.GetRenderStates ().SetSeparateBlend (true, + GL_SRC_ALPHA, + GL_ONE_MINUS_SRC_ALPHA, + GL_ONE_MINUS_DST_ALPHA, + GL_ONE); + GfxContext.GetRenderStates ().SetColorMask (true, true, true, true); + + RenderIconImage (GfxContext, arg); + + if (arg.backlight_intensity > 0.0f) + RenderIcon(GfxContext, arg, _icon_shine_texture, nux::Color::White, arg.backlight_intensity); + + switch (arg.window_indicators) + { + case 2: + RenderIcon(GfxContext, arg, _icon_2indicator, nux::Color::White, 1.0f); + break; + case 3: + RenderIcon(GfxContext, arg, _icon_3indicator, nux::Color::White, 1.0f); + break; + case 4: + RenderIcon(GfxContext, arg, _icon_4indicator, nux::Color::White, 1.0f); + break; + } +} + void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { nux::Geometry base = GetGeometry(); @@ -1083,32 +1135,8 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { if ((*rev_it).folding_rads >= 0.0f || (*rev_it).skip) continue; - - RenderArg arg = *rev_it; - - GfxContext.GetRenderStates ().SetSeparateBlend (true, - GL_SRC_ALPHA, - GL_ONE_MINUS_SRC_ALPHA, - GL_ONE_MINUS_DST_ALPHA, - GL_ONE); - - GfxContext.GetRenderStates ().SetColorMask (true, true, true, true); - - if (arg.backlight_intensity < 1.0f) - RenderIcon(GfxContext, arg, _icon_outline_texture, nux::Color(0xFF6D6D6D), 1.0f - arg.backlight_intensity); - if (arg.backlight_intensity > 0.0f) - RenderIcon(GfxContext, arg, _icon_bkg_texture, arg.icon->BackgroundColor (), arg.backlight_intensity); - - GfxContext.GetRenderStates ().SetSeparateBlend (true, - GL_SRC_ALPHA, - GL_ONE_MINUS_SRC_ALPHA, - GL_ONE_MINUS_DST_ALPHA, - GL_ONE); - GfxContext.GetRenderStates ().SetColorMask (true, true, true, true); - RenderIconImage (GfxContext, arg); - if (arg.backlight_intensity > 0.0f) - RenderIcon(GfxContext, arg, _icon_shine_texture, nux::Color::White, arg.backlight_intensity); + DrawRenderArg (GfxContext, *rev_it); } std::list<Launcher::RenderArg>::iterator it; @@ -1117,30 +1145,8 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) if ((*it).folding_rads < 0.0f || (*it).skip) continue; + DrawRenderArg (GfxContext, *it); RenderArg arg = *it; - - GfxContext.GetRenderStates ().SetSeparateBlend (true, - GL_SRC_ALPHA, - GL_ONE_MINUS_SRC_ALPHA, - GL_ONE_MINUS_DST_ALPHA, - GL_ONE); - - GfxContext.GetRenderStates ().SetColorMask (true, true, true, true); - if (arg.backlight_intensity < 1.0f) - RenderIcon(GfxContext, arg, _icon_outline_texture, nux::Color(0xFF6D6D6D), 1.0f - arg.backlight_intensity); - if (arg.backlight_intensity > 0.0f) - RenderIcon(GfxContext, arg, _icon_bkg_texture, arg.icon->BackgroundColor (), arg.backlight_intensity); - - GfxContext.GetRenderStates ().SetSeparateBlend (true, - GL_SRC_ALPHA, - GL_ONE_MINUS_SRC_ALPHA, - GL_ONE_MINUS_DST_ALPHA, - GL_ONE); - GfxContext.GetRenderStates ().SetColorMask (true, true, true, true); - RenderIconImage (GfxContext, arg); - - if (arg.backlight_intensity > 0.0f) - RenderIcon(GfxContext, arg, _icon_shine_texture, nux::Color::White, arg.backlight_intensity); } GfxContext.GetRenderStates().SetColorMask (true, true, true, true); diff --git a/src/Launcher.h b/src/Launcher.h index 9706466ff..a17fda726 100644 --- a/src/Launcher.h +++ b/src/Launcher.h @@ -71,6 +71,7 @@ private: bool running_arrow; bool active_arrow; bool skip; + int window_indicators; } RenderArg; static gboolean AnimationTimeout (gpointer data); @@ -96,6 +97,8 @@ private: std::list<RenderArg> RenderArgs (nux::Geometry &box_geo); + void DrawRenderArg (nux::GraphicsEngine& GfxContext, RenderArg arg); + void OnIconAdded (void *icon_pointer); void OnIconRemoved (void *icon_pointer); void OnOrderChanged (); @@ -140,6 +143,9 @@ private: nux::BaseTexture* _icon_bkg_texture; nux::BaseTexture* _icon_shine_texture; nux::BaseTexture* _icon_outline_texture; + nux::BaseTexture* _icon_2indicator; + nux::BaseTexture* _icon_3indicator; + nux::BaseTexture* _icon_4indicator; int _dnd_delta; int _dnd_security; guint _anim_handle; diff --git a/src/LauncherIcon.cpp b/src/LauncherIcon.cpp index a6834c102..d19ebc4e9 100644 --- a/src/LauncherIcon.cpp +++ b/src/LauncherIcon.cpp @@ -35,6 +35,8 @@ LauncherIcon::LauncherIcon(Launcher* IconManager) _running = false; _visible = false; _urgent = false; + + _related_windows = 0; _background_color = nux::Color::White; _mouse_inside = false; @@ -264,6 +266,15 @@ void LauncherIcon::SetUrgent (bool urgent) needs_redraw.emit (this); } +void LauncherIcon::SetRelatedWindows (int windows) +{ + if (_related_windows == windows) + return; + + _related_windows = windows; + needs_redraw.emit (this); +} + void LauncherIcon::Remove () { SetVisible (false); @@ -317,3 +328,9 @@ LauncherIcon::Urgent () { return _urgent; } + +int +LauncherIcon::RelatedWindows () +{ + return _related_windows; +} diff --git a/src/LauncherIcon.h b/src/LauncherIcon.h index 83e44287e..ba4df197f 100644 --- a/src/LauncherIcon.h +++ b/src/LauncherIcon.h @@ -51,6 +51,8 @@ public: int SortPriority (); + int RelatedWindows (); + struct timeval ShowTime (); struct timeval HideTime (); struct timeval RunningTime (); @@ -78,6 +80,7 @@ protected: void SetActive (bool active); void SetRunning (bool running); void SetUrgent (bool urgent); + void SetRelatedWindows (int windows); void Remove (); void SetIconType (LauncherIconType type); @@ -112,6 +115,7 @@ private: bool _running; bool _urgent; int _sort_priority; + int _related_windows; LauncherIconType _icon_type; struct timeval _show_time; struct timeval _hide_time; |
