summaryrefslogtreecommitdiff
path: root/dash/previews
diff options
Diffstat (limited to 'dash/previews')
-rw-r--r--dash/previews/ActionButton.cpp6
-rw-r--r--dash/previews/ApplicationPreview.cpp15
-rw-r--r--dash/previews/ApplicationPreview.h3
-rw-r--r--dash/previews/CMakeLists.txt16
-rw-r--r--dash/previews/PreviewContainer.cpp5
-rw-r--r--dash/previews/StandaloneApplicationPreview.cpp (renamed from dash/previews/Standalone.cpp)2
-rw-r--r--dash/previews/StandaloneMusicPreview.cpp267
7 files changed, 301 insertions, 13 deletions
diff --git a/dash/previews/ActionButton.cpp b/dash/previews/ActionButton.cpp
index 5170b46e8..6cc98ec48 100644
--- a/dash/previews/ActionButton.cpp
+++ b/dash/previews/ActionButton.cpp
@@ -42,6 +42,10 @@ ActionButton::ActionButton(std::string const& label, NUX_FILE_LINE_DECL)
{
SetLayoutPadding(2, 11, 2, 11);
Button::SetLabel(label);
+
+ SetAcceptKeyNavFocusOnMouseDown(false);
+ SetAcceptKeyNavFocusOnMouseEnter(false);
+
Init();
}
@@ -52,8 +56,6 @@ ActionButton::~ActionButton()
void ActionButton::Init()
{
InitTheme();
- SetAcceptKeyNavFocusOnMouseDown(false);
- SetAcceptKeyNavFocusOnMouseEnter(false);
key_nav_focus_change.connect([&] (nux::Area*, bool, nux::KeyNavDirection)
{
diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp
index 7bca26a0c..f8144bc52 100644
--- a/dash/previews/ApplicationPreview.cpp
+++ b/dash/previews/ApplicationPreview.cpp
@@ -259,7 +259,10 @@ void ApplicationPreview::SetupViews()
for (dash::Preview::ActionPtr action : preview_model_->GetActions())
{
- actions_layout->AddView(new ActionButton(action->display_name, NUX_TRACKER_LOCATION), 0);
+ ActionButton* button = new ActionButton(action->display_name, NUX_TRACKER_LOCATION);
+ button->click.connect(sigc::bind(sigc::mem_fun(this, &ApplicationPreview::OnActionActivated), action->id));
+
+ actions_layout->AddView(button, 0);
}
/////////////////////
@@ -274,6 +277,12 @@ void ApplicationPreview::SetupViews()
SetLayout(image_data_layout);
}
+void ApplicationPreview::OnActionActivated(nux::Button*, std::string const& id)
+{
+ if (preview_model_)
+ preview_model_->PerformAction(id);
}
-}
-}
+
+} // namespace previews
+} // namespace dash
+} // namepsace unity
diff --git a/dash/previews/ApplicationPreview.h b/dash/previews/ApplicationPreview.h
index d3e880922..e2de0eec1 100644
--- a/dash/previews/ApplicationPreview.h
+++ b/dash/previews/ApplicationPreview.h
@@ -32,6 +32,7 @@ namespace nux
{
class AbstractPaintLayer;
class VLayout;
+class Button;
}
namespace unity
@@ -65,6 +66,8 @@ protected:
void SetupBackground();
void SetupViews();
+ void OnActionActivated(nux::Button* button, std::string const& id);
+
protected:
IconTexture* app_icon_;
PreviewRatingsWidget* app_rating_;
diff --git a/dash/previews/CMakeLists.txt b/dash/previews/CMakeLists.txt
index 0640a89f3..97828b34b 100644
--- a/dash/previews/CMakeLists.txt
+++ b/dash/previews/CMakeLists.txt
@@ -44,9 +44,17 @@ set (PREVIEWS_SOURCES
add_library (previews-lib STATIC ${PREVIEWS_SOURCES})
add_dependencies (previews-lib unity-core-${UNITY_API_VERSION} unity-shared)
target_link_libraries (previews-lib unity-shared)
+
+#
+# Application Standalone variant
+#
+add_executable (app_previews StandaloneApplicationPreview.cpp)
+add_dependencies (app_previews previews-lib)
+target_link_libraries (app_previews previews-lib unity-shared)
+
#
-# Standalone variant
+# Music Standalone variant
#
-add_executable (previews Standalone.cpp)
-add_dependencies (previews previews-lib)
-target_link_libraries (previews previews-lib unity-shared)
+#add_executable (music_previews StandaloneMusicPreview.cpp)
+#add_dependencies (music_previews previews-lib)
+#target_link_libraries (music_previews previews-lib unity-shared) \ No newline at end of file
diff --git a/dash/previews/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp
index 31058c2dc..868aa4b71 100644
--- a/dash/previews/PreviewContainer.cpp
+++ b/dash/previews/PreviewContainer.cpp
@@ -59,8 +59,6 @@ public:
void PushPreview(previews::Preview::Ptr preview, NavButton direction)
{
AddView(preview.GetPointer());
- preview->SetReconfigureParentLayoutOnGeometryChange(false);
-
preview->SetVisible(false);
PreviewSwipe swipe;
swipe.direction = direction;
@@ -132,6 +130,7 @@ public:
if (current_preview_)
RemoveChildObject(current_preview_.GetPointer());
current_preview_ = swipe_.preview;
+ swipe_.preview.Release();
}
// another swipe?
@@ -161,7 +160,7 @@ public:
void ProcessDraw2(nux::GraphicsEngine& gfx_engine, bool force_draw)
{
if (swipe_.preview && swipe_.preview->IsVisible()) { swipe_.preview->ProcessDraw(gfx_engine, force_draw); }
- if (current_preview_ && swipe_.preview->IsVisible()) { current_preview_->ProcessDraw(gfx_engine, force_draw); }
+ if (current_preview_ && current_preview_->IsVisible()) { current_preview_->ProcessDraw(gfx_engine, force_draw); }
_queued_draw = false;
}
diff --git a/dash/previews/Standalone.cpp b/dash/previews/StandaloneApplicationPreview.cpp
index e1f218679..3704d49c4 100644
--- a/dash/previews/Standalone.cpp
+++ b/dash/previews/StandaloneApplicationPreview.cpp
@@ -63,7 +63,7 @@ public:
nux::Layout* layout = new nux::VLayout();
layout->SetPadding(16);
- layout->AddView(view, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ layout->AddView(view, 1, nux::MINOR_POSITION_CENTER);
SetLayout(layout);
}
diff --git a/dash/previews/StandaloneMusicPreview.cpp b/dash/previews/StandaloneMusicPreview.cpp
new file mode 100644
index 000000000..4163bf121
--- /dev/null
+++ b/dash/previews/StandaloneMusicPreview.cpp
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2010 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 3 along with this program. If not, see
+ * <http://www.gnu.org/licenses/>
+ *
+ * Authored by: Gordon Allott <gord.allott@canonical.com>
+ *
+ */
+#include <gtk/gtk.h>
+
+#include "Nux/Nux.h"
+#include "Nux/VLayout.h"
+#include "Nux/WindowThread.h"
+#include "NuxGraphics/GraphicsEngine.h"
+#include <Nux/Layout.h>
+#include <NuxCore/Logger.h>
+#include <UnityCore/Variant.h>
+#include <UnityCore/Preview.h>
+#include <UnityCore/ApplicationPreview.h>
+#include <UnityCore/MoviePreview.h>
+#include <UnityCore/MusicPreview.h>
+#include <UnityCore/SeriesPreview.h>
+#include <unity-protocol.h>
+#include "PreviewFactory.h"
+
+#include "unity-shared/FontSettings.h"
+#include "unity-shared/UnitySettings.h"
+#include "unity-shared/PreviewStyle.h"
+#include "unity-shared/DashStyle.h"
+
+#include "Preview.h"
+#include "PreviewContainer.h"
+
+
+#define WIDTH 972
+#define HEIGHT 452
+
+using namespace unity;
+using namespace unity::dash;
+
+class DummyView : public nux::View
+{
+public:
+ DummyView(nux::View* view)
+ : View(NUX_TRACKER_LOCATION)
+ {
+ nux::ROPConfig rop;
+ rop.Blend = true;
+ rop.SrcBlend = GL_ONE;
+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
+ bg_layer_.reset(new nux::ColorLayer(nux::Color(81, 26, 48), true, rop));
+
+ nux::Layout* layout = new nux::VLayout();
+ layout->SetPadding(16);
+ layout->AddView(view, 1, nux::MINOR_POSITION_CENTER);
+ SetLayout(layout);
+ }
+
+protected:
+ virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
+ {
+ nux::Geometry const& base = GetGeometry();
+
+ gfx_engine.PushClippingRectangle(base);
+ nux::GetPainter().PaintBackground(gfx_engine, base);
+
+ unsigned int alpha, src, dest = 0;
+ gfx_engine.GetRenderStates().GetBlend(alpha, src, dest);
+ gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+ bg_layer_->SetGeometry(GetGeometry());
+ nux::GetPainter().RenderSinglePaintLayer(gfx_engine, GetGeometry(), bg_layer_.get());
+
+ gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
+
+ gfx_engine.PopClippingRectangle();
+ }
+
+ virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
+ {
+ nux::Geometry const& base = GetGeometry();
+ gfx_engine.PushClippingRectangle(base);
+
+ if (!IsFullRedraw())
+ nux::GetPainter().PushLayer(gfx_engine, GetGeometry(), bg_layer_.get());
+
+ if (GetCompositionLayout())
+ GetCompositionLayout()->ProcessDraw(gfx_engine, force_draw);
+
+ if (!IsFullRedraw())
+ nux::GetPainter().PopBackground();
+
+ gfx_engine.PopClippingRectangle();
+ }
+
+ typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr;
+ LayerPtr bg_layer_;
+};
+
+class TestRunner
+{
+public:
+ TestRunner ();
+ ~TestRunner ();
+
+ static void InitWindowThread (nux::NThread* thread, void* InitData);
+ void Init ();
+ void NavRight();
+ void NavLeft();
+
+ previews::PreviewContainer::Ptr container_;
+ nux::Layout *layout_;
+ int nav_iter;
+};
+
+TestRunner::TestRunner ()
+{
+ nav_iter = 0;
+}
+
+TestRunner::~TestRunner ()
+{
+}
+
+void TestRunner::Init ()
+{
+ container_ = new previews::PreviewContainer(NUX_TRACKER_LOCATION);
+ container_->navigate_right.connect(sigc::mem_fun(this, &TestRunner::NavRight));
+ container_->navigate_left.connect(sigc::mem_fun(this, &TestRunner::NavLeft));
+
+ DummyView* dummyView = new DummyView(container_.GetPointer());
+ layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
+ layout_->AddView(dummyView, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ nux::GetWindowThread()->SetLayout (layout_);
+
+
+ std::stringstream app_name;
+ app_name << "Title " << nav_iter;
+
+ const char* subtitle = "The Beatles, 1986";
+ const char* description = "";
+
+ // creates a generic preview object
+ glib::Object<GIcon> image(g_icon_new_for_string("./Beatles.png", NULL));
+ glib::Object<GIcon> iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL));
+ glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL));
+
+ glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_music_preview_new()));
+
+ unity_protocol_preview_set_title(proto_obj, app_name.str().c_str());
+ unity_protocol_preview_set_subtitle(proto_obj, subtitle);
+ unity_protocol_preview_set_description(proto_obj, description);
+ unity_protocol_preview_set_thumbnail(proto_obj, image);
+ unity_protocol_preview_add_action(proto_obj, "play-album", "Play Album", NULL, 0);
+ unity_protocol_preview_add_info_hint(proto_obj, "run-time", "", iconHint1, g_variant_new("s", "10 Tracks, 37.50 min"));
+ unity_protocol_preview_add_info_hint(proto_obj, "genre", "Energy", iconHint2, g_variant_new("s", "60s, Rock 'n Roll, britpop"));
+
+ glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())),
+ glib::StealRef());
+
+ container_->preview(v, previews::RIGHT);
+
+}
+
+void TestRunner::NavRight()
+{
+ std::stringstream app_name;
+ app_name << "Title " << ++nav_iter;
+
+ const char* subtitle = "The Beatles, 1986";
+ const char* description = "";
+
+ // creates a generic preview object
+ glib::Object<GIcon> image(g_icon_new_for_string("./Beatles.png", NULL));
+ glib::Object<GIcon> iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL));
+ glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL));
+
+ glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_music_preview_new()));
+
+ unity_protocol_preview_set_title(proto_obj, app_name.str().c_str());
+ unity_protocol_preview_set_subtitle(proto_obj, subtitle);
+ unity_protocol_preview_set_description(proto_obj, description);
+ unity_protocol_preview_set_thumbnail(proto_obj, image);
+ unity_protocol_preview_add_action(proto_obj, "play-album", "Play Album", NULL, 0);
+ unity_protocol_preview_add_info_hint(proto_obj, "run-time", "", iconHint1, g_variant_new("s", "10 Tracks, 37.50 min"));
+ unity_protocol_preview_add_info_hint(proto_obj, "genre", "Energy", iconHint2, g_variant_new("s", "60s, Rock 'n Roll, britpop"));
+
+ glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())),
+ glib::StealRef());
+
+ container_->preview(v, previews::RIGHT);
+}
+
+void TestRunner::NavLeft()
+{
+ std::stringstream app_name;
+ app_name << "Title " << --nav_iter;
+
+ const char* subtitle = "The Beatles, 1986";
+ const char* description = "";
+
+ // creates a generic preview object
+ glib::Object<GIcon> image(g_icon_new_for_string("./Beatles.png", NULL));
+ glib::Object<GIcon> iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL));
+ glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL));
+
+ glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_music_preview_new()));
+
+ unity_protocol_preview_set_title(proto_obj, app_name.str().c_str());
+ unity_protocol_preview_set_subtitle(proto_obj, subtitle);
+ unity_protocol_preview_set_description(proto_obj, description);
+ unity_protocol_preview_set_thumbnail(proto_obj, image);
+ unity_protocol_preview_add_action(proto_obj, "play-album", "Play Album", NULL, 0);
+ unity_protocol_preview_add_info_hint(proto_obj, "run-time", "", iconHint1, g_variant_new("s", "10 Tracks, 37.50 min"));
+ unity_protocol_preview_add_info_hint(proto_obj, "genre", "Energy", iconHint2, g_variant_new("s", "60s, Rock 'n Roll, britpop"));
+
+ glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())),
+ glib::StealRef());
+
+ container_->preview(v, previews::LEFT);
+}
+
+void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
+{
+ TestRunner *self = (TestRunner *) InitData;
+ self->Init ();
+}
+
+int main(int argc, char **argv)
+{
+ nux::WindowThread* wt = NULL;
+
+ gtk_init (&argc, &argv);
+
+ nux::NuxInitialize(0);
+ nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
+ nux::logging::Logger("unity").SetLogLevel(nux::logging::Warning);
+ // The instances for the pseudo-singletons.
+ unity::Settings settings;
+ unity::dash::previews::Style panel_style;
+ unity::dash::Style dash_style;
+ unity::dash::PreviewFactory preview_factory;
+
+ TestRunner *test_runner = new TestRunner ();
+ wt = nux::CreateGUIThread(TEXT("Unity Preview"),
+ WIDTH, HEIGHT,
+ 0,
+ &TestRunner::InitWindowThread,
+ test_runner);
+
+ wt->Run (NULL);
+ delete wt;
+ return 0;
+}
+
+