summaryrefslogtreecommitdiff
path: root/dash/previews
diff options
authorNick Dedekind <nicholas.dedekind@gmail.com>2012-07-05 11:51:38 +0100
committerNick Dedekind <nicholas.dedekind@gmail.com>2012-07-05 11:51:38 +0100
commita4ce3fe462b96085cab99590c1ea9f9b21acace4 (patch)
treee349b8270e373b90802844f1ffdc8608f4864874 /dash/previews
parente94df55552e025ac55392abf0c099bfdf846af82 (diff)
PreviewContainer now hosts Previews
(bzr r2419.4.10)
Diffstat (limited to 'dash/previews')
-rw-r--r--dash/previews/ApplicationPreview.cpp4
-rw-r--r--dash/previews/ApplicationPreview.h3
-rw-r--r--dash/previews/CMakeLists.txt1
-rw-r--r--dash/previews/GenericPreview.cpp4
-rw-r--r--dash/previews/MoviePreview.cpp4
-rw-r--r--dash/previews/MusicPreview.cpp4
-rw-r--r--dash/previews/Preview.cpp54
-rw-r--r--dash/previews/Preview.h22
-rw-r--r--dash/previews/PreviewContainer.cpp173
-rw-r--r--dash/previews/PreviewContainer.h103
-rw-r--r--dash/previews/PreviewFactory.cpp41
-rw-r--r--dash/previews/PreviewFactory.h9
-rw-r--r--dash/previews/PreviewFactoryItem.h2
-rw-r--r--dash/previews/PreviewNavigator.cpp2
-rw-r--r--dash/previews/Standalone.cpp29
15 files changed, 349 insertions, 106 deletions
diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp
index 64d68a2ba..17e9d4761 100644
--- a/dash/previews/ApplicationPreview.cpp
+++ b/dash/previews/ApplicationPreview.cpp
@@ -35,9 +35,7 @@ namespace previews
namespace
{
-nux::logging::Logger logger("unity.dash.applicationpreview");
-
-bool registered(PreviewFactory::Instance().RegisterItem("preview-application", new PreviewFactoryItem<dash::ApplicationPreview, previews::ApplicationPreview>()));
+nux::logging::Logger logger("unity.dash.previews.applicationpreview");
}
diff --git a/dash/previews/ApplicationPreview.h b/dash/previews/ApplicationPreview.h
index 9b6fa642d..79d01361e 100644
--- a/dash/previews/ApplicationPreview.h
+++ b/dash/previews/ApplicationPreview.h
@@ -50,6 +50,9 @@ public:
protected:
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+
+protected:
+
};
}
diff --git a/dash/previews/CMakeLists.txt b/dash/previews/CMakeLists.txt
index 732c14e5d..78d7dd930 100644
--- a/dash/previews/CMakeLists.txt
+++ b/dash/previews/CMakeLists.txt
@@ -33,6 +33,7 @@ set (PREVIEWS_SOURCES
MusicPreview.cpp
MoviePreview.cpp
Preview.cpp
+ PreviewContainer.cpp
PreviewFactory.cpp
PreviewNavigator.cpp
)
diff --git a/dash/previews/GenericPreview.cpp b/dash/previews/GenericPreview.cpp
index 5261e1c8c..dd15dc011 100644
--- a/dash/previews/GenericPreview.cpp
+++ b/dash/previews/GenericPreview.cpp
@@ -35,9 +35,7 @@ namespace previews
namespace
{
-nux::logging::Logger logger("unity.dash.genericpreview");
-
-bool registered(PreviewFactory::Instance().RegisterItem("preview-generic", new PreviewFactoryItem<dash::GenericPreview, previews::GenericPreview>()));
+nux::logging::Logger logger("unity.dash.previews.genericpreview");
}
diff --git a/dash/previews/MoviePreview.cpp b/dash/previews/MoviePreview.cpp
index 150bf7c83..3dce0ee00 100644
--- a/dash/previews/MoviePreview.cpp
+++ b/dash/previews/MoviePreview.cpp
@@ -35,9 +35,7 @@ namespace previews
namespace
{
-nux::logging::Logger logger("unity.dash.moviepreview");
-
-bool registered(PreviewFactory::Instance().RegisterItem("preview-movie", new PreviewFactoryItem<dash::MoviePreview, previews::MoviePreview>()));
+nux::logging::Logger logger("unity.dash.previews.moviepreview");
}
diff --git a/dash/previews/MusicPreview.cpp b/dash/previews/MusicPreview.cpp
index b69f6ed80..972455608 100644
--- a/dash/previews/MusicPreview.cpp
+++ b/dash/previews/MusicPreview.cpp
@@ -35,9 +35,7 @@ namespace previews
namespace
{
-nux::logging::Logger logger("unity.dash.moviepreview");
-
-bool registered(PreviewFactory::Instance().RegisterItem("preview-movie", new PreviewFactoryItem<dash::MusicPreview, previews::MusicPreview>()));
+nux::logging::Logger logger("unity.dash.previews.moviepreview");
}
diff --git a/dash/previews/Preview.cpp b/dash/previews/Preview.cpp
index 076bd6d77..c5ef9f31c 100644
--- a/dash/previews/Preview.cpp
+++ b/dash/previews/Preview.cpp
@@ -24,9 +24,6 @@
#include "unity-shared/IntrospectableWrappers.h"
#include <NuxCore/Logger.h>
#include <Nux/HLayout.h>
-#include <Nux/ProgramFramework/TestView.h>
-
-#include "PreviewNavigator.h"
namespace unity
{
@@ -37,29 +34,14 @@ namespace previews
namespace
{
-nux::logging::Logger logger("unity.dash.preview");
+nux::logging::Logger logger("unity.dash.previews.preview");
}
-class TestView2 : public nux::View
-{
-public:
- TestView2():View(NUX_TRACKER_LOCATION) {}
-
-
- void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
- {
- // just for debugging, draw a vertical gradient
- gPainter.Paint2DQuadVGradient(gfx_engine, GetGeometry(),
- nux::Color(0x96, 0x11, 0xDA), nux::Color(0x54, 0xD9, 0x11));
- }
-
- void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
- {
- }
-};
-
NUX_IMPLEMENT_OBJECT_TYPE(Preview);
+int Y = 0;
+int DY = 7;
+
Preview::Preview(dash::Preview::Ptr preview_model)
: View(NUX_TRACKER_LOCATION)
, preview_model_(preview_model)
@@ -71,15 +53,10 @@ Preview::~Preview()
{
}
-void Preview::DisableNavButton(NavButton button)
-{
-}
-
void Preview::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
{
- // just for debugging, draw a vertical gradient
- // gPainter.Paint2DQuadColor(gfx_engine, GetGeometry(),
- // nux::Color(0, 0, 0));
+ gPainter.Paint2DQuadVGradient(gfx_engine, GetGeometry(),
+ nux::Color(0x96, 0x11, 0xDA), nux::Color(0x54, 0xD9, 0x11));
}
void Preview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
@@ -104,25 +81,6 @@ void Preview::AddProperties(GVariantBuilder* builder)
void Preview::SetupViews()
{
- previews::Style& stlye = previews::Style::Instance();
-
- layout_ = new nux::HLayout();
- SetLayout(layout_);
-
- nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
- nav_left_->SetMinimumWidth(stlye.NavigatorMinimumWidth());
- nav_left_->SetMaximumWidth(stlye.NavigatorMaximumWidth());
- nav_left_->activated.connect([&]() { navigate_left.emit(); });
- layout_->AddView(nav_left_, 0);
-
- content_ = new TestView2();
- layout_->AddView(content_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
-
- nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
- nav_right_->SetMinimumWidth(stlye.NavigatorMinimumWidth());
- nav_right_->SetMaximumWidth(stlye.NavigatorMaximumWidth());
- nav_right_->activated.connect([&]() { navigate_right.emit(); });
- layout_->AddView(nav_right_, 0);
}
}
diff --git a/dash/previews/Preview.h b/dash/previews/Preview.h
index 5755be5d2..9e2908663 100644
--- a/dash/previews/Preview.h
+++ b/dash/previews/Preview.h
@@ -35,15 +35,6 @@ namespace dash
namespace previews
{
-class PreviewNavigator;
-
-typedef enum
-{
- LEFT,
- RIGHT,
- BOTH
-} NavButton;
-
class Preview : public nux::View, public debug::Introspectable
{
public:
@@ -52,14 +43,7 @@ public:
Preview(dash::Preview::Ptr preview_model);
virtual ~Preview();
-
- // calling this should disable the nav buttons to the left or the right of the preview
- virtual void DisableNavButton(NavButton button);
- // For the nav buttons to the left/right of the previews, call when they are activated
- sigc::signal<void> navigate_left;
- sigc::signal<void> navigate_right;
-
// From debug::Introspectable
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
@@ -72,12 +56,6 @@ protected:
protected:
dash::Preview::Ptr preview_model_;
-
- // View related
- nux::HLayout* layout_;
- PreviewNavigator* nav_left_;
- PreviewNavigator* nav_right_;
- View* content_;
};
}
diff --git a/dash/previews/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp
new file mode 100644
index 000000000..7d626ab19
--- /dev/null
+++ b/dash/previews/PreviewContainer.cpp
@@ -0,0 +1,173 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright 2011 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser 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 applicable version of the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of both the GNU Lesser 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 "PreviewContainer.h"
+#include <NuxCore/Logger.h>
+#include <Nux/HLayout.h>
+
+#include "unity-shared/IntrospectableWrappers.h"
+#include "unity-shared/TimeUtil.h"
+#include "PreviewNavigator.h"
+#include "PreviewFactory.h"
+
+namespace unity
+{
+namespace dash
+{
+namespace previews
+{
+
+namespace
+{
+nux::logging::Logger logger("unity.dash.previews.previewcontainer");
+
+const int ANIM_DURATION_SHORT_SHORT = 100;
+const int ANIM_DURATION = 200;
+const int ANIM_DURATION_LONG = 10000;
+
+const std::string ANIMATION_IDLE = "animation-idle";
+}
+
+class PreviewContent : private nux::HLayout
+{
+public:
+ PreviewContent() {}
+
+ void SetLeftPreview();
+ void SetRightPreview();
+
+private:
+};
+
+NUX_IMPLEMENT_OBJECT_TYPE(PreviewContainer);
+
+PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL)
+ : View(NUX_FILE_LINE_PARAM)
+{
+ SetupViews();
+}
+
+PreviewContainer::~PreviewContainer()
+{
+}
+
+void PreviewContainer::preview(glib::Variant const& preview)
+{
+ PreviewFactoryOperator previewOperator(PreviewFactory::Instance().Item(preview));
+
+ dash::Preview::Ptr model = previewOperator.CreateModel();
+
+ content_layout_->RemoveChildObject(current_preview_.GetPointer());
+ current_preview_ = previewOperator.CreateView(model);
+ if (current_preview_)
+ {
+ content_layout_->AddView(current_preview_.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ }
+}
+
+void PreviewContainer::DisableNavButton(NavButton button)
+{
+}
+
+void PreviewContainer::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
+{
+}
+
+void PreviewContainer::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
+{
+ // rely on the compiz event loop to come back to us in a nice throttling
+ if (AnimationInProgress())
+ {
+ auto idle = std::make_shared<glib::Idle>(glib::Source::Priority::DEFAULT);
+ sources_.Add(idle, ANIMATION_IDLE);
+ idle->Run([&]() {
+ EnsureAnimation();
+ return false;
+ });
+ }
+
+
+ nux::Geometry base = GetGeometry();
+ gfx_engine.PushClippingRectangle(base);
+
+ if (GetCompositionLayout())
+ GetCompositionLayout()->ProcessDraw(gfx_engine, force_draw);
+
+ gfx_engine.PopClippingRectangle();
+}
+
+void PreviewContainer::EnsureAnimation()
+{
+ LOG_WARN(logger) << "draw!";
+ QueueDraw();
+}
+
+std::string PreviewContainer::GetName() const
+{
+ return "PreviewContainer";
+}
+
+void PreviewContainer::AddProperties(GVariantBuilder* builder)
+{
+}
+
+void PreviewContainer::SetupViews()
+{
+ previews::Style& stlye = previews::Style::Instance();
+
+ layout_ = new nux::HLayout();
+ SetLayout(layout_);
+
+ nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
+ nav_left_->SetMinimumWidth(stlye.NavigatorMinimumWidth());
+ nav_left_->SetMaximumWidth(stlye.NavigatorMaximumWidth());
+ nav_left_->activated.connect([&]() { navigate_left.emit(); });
+ layout_->AddView(nav_left_, 0);
+
+ content_layout_ = new nux::HLayout();
+ layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+
+ nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
+ nav_right_->SetMinimumWidth(stlye.NavigatorMinimumWidth());
+ nav_right_->SetMaximumWidth(stlye.NavigatorMaximumWidth());
+ nav_right_->activated.connect([&]() { navigate_right.emit(); });
+ layout_->AddView(nav_right_, 0);
+}
+
+bool PreviewContainer::AnimationInProgress()
+{
+ // short circuit to avoid unneeded calculations
+ struct timespec current;
+ clock_gettime(CLOCK_MONOTONIC, &current);
+
+ // hover in animation
+ if (unity::TimeUtil::TimeDelta(&current, &_times[TIME_PREVIEW_NAVIGATE]) < ANIM_DURATION_LONG)
+ return true;
+
+ return false;
+}
+
+
+
+}
+}
+}
diff --git a/dash/previews/PreviewContainer.h b/dash/previews/PreviewContainer.h
new file mode 100644
index 000000000..472faf77e
--- /dev/null
+++ b/dash/previews/PreviewContainer.h
@@ -0,0 +1,103 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright 2011 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser 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 applicable version of the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of both the GNU Lesser General Public
+ * License version 3 along with this program. If not, see
+ * <http://www.gnu.org/licenses/>
+ *
+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
+ *
+ */
+
+#ifndef PREVIEWCONTAINER_H
+#define PREVIEWCONTAINER_H
+
+#include <Nux/Nux.h>
+#include <Nux/View.h>
+#include <UnityCore/Preview.h>
+#include "Preview.h"
+#include "unity-shared/Introspectable.h"
+#include <UnityCore/GLibSource.h>
+
+namespace unity
+{
+namespace dash
+{
+namespace previews
+{
+
+class PreviewNavigator;
+
+typedef enum
+{
+ LEFT = (1<<0),
+ RIGHT = (1<<1),
+ BOTH = LEFT|RIGHT
+} NavButton;
+
+class PreviewContainer : public nux::View, public debug::Introspectable
+{
+public:
+ typedef nux::ObjectPtr<PreviewContainer> Ptr;
+ NUX_DECLARE_OBJECT_TYPE(PreviewContainer, nux::View);
+
+ PreviewContainer(NUX_FILE_LINE_PROTO);
+ virtual ~PreviewContainer();
+
+ void preview(glib::Variant const& preview);
+
+ // calling this should disable the nav buttons to the left or the right of the preview
+ virtual void DisableNavButton(NavButton button);
+
+ // From debug::Introspectable
+ std::string GetName() const;
+ void AddProperties(GVariantBuilder* builder);
+
+ // For the nav buttons to the left/right of the previews, call when they are activated
+ sigc::signal<void> navigate_left;
+ sigc::signal<void> navigate_right;
+
+protected:
+ virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
+ virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
+
+private:
+ void SetupViews();
+
+ bool AnimationInProgress();
+ void EnsureAnimation();
+
+private:
+ // View related
+ nux::HLayout* layout_;
+ PreviewNavigator* nav_left_;
+ PreviewNavigator* nav_right_;
+ nux::HLayout* content_layout_;
+ previews::Preview::Ptr current_preview_;
+
+ // Animation
+ typedef enum {
+ TIME_PREVIEW_NAVIGATE,
+ TIME_LAST
+ } PreviewActionTimes;
+ struct timespec _times[TIME_LAST];
+
+ glib::SourceManager sources_;
+};
+
+} // napespace prviews
+} // namespace dash
+} // namespace unity
+
+#endif //PREVIEWCONTAINER_H
diff --git a/dash/previews/PreviewFactory.cpp b/dash/previews/PreviewFactory.cpp
index 3fa9027a0..d97114981 100644
--- a/dash/previews/PreviewFactory.cpp
+++ b/dash/previews/PreviewFactory.cpp
@@ -16,7 +16,7 @@
* License version 3 along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
- * Authored by: Gordon Allott <gord.allott@canonical.com>
+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
*
*/
@@ -25,7 +25,17 @@
#include <NuxCore/Logger.h>
#include <unity-protocol.h>
+// PreviewClasses
+#include <UnityCore/GenericPreview.h>
#include "GenericPreview.h"
+#include <UnityCore/ApplicationPreview.h>
+#include "ApplicationPreview.h"
+#include <UnityCore/GenericPreview.h>
+#include "GenericPreview.h"
+#include <UnityCore/MoviePreview.h>
+#include "MoviePreview.h"
+#include <UnityCore/MusicPreview.h>
+#include "MusicPreview.h"
namespace unity
{
@@ -33,13 +43,27 @@ namespace dash
{
namespace
{
-nux::logging::Logger logger("unity.dash.previewfactory");
+nux::logging::Logger logger("unity.dash.previews.previewfactory");
+
+PreviewFactory* factory_instance = nullptr;
}
PreviewFactory::PreviewFactory()
{
+ if (factory_instance)
+ {
+ LOG_ERROR(logger) << "More than one dash::PreviewFactory created.";
+ }
+ else
+ {
+ factory_instance = this;
+ }
+
+ RegisterItem("preview-application", new PreviewFactoryItem<dash::ApplicationPreview, previews::ApplicationPreview>());
RegisterItem("preview-generic", new PreviewFactoryItem<dash::GenericPreview, previews::GenericPreview>());
+ RegisterItem("preview-movie", new PreviewFactoryItem<dash::MoviePreview, previews::MoviePreview>());
+ RegisterItem("preview-movie", new PreviewFactoryItem<dash::MusicPreview, previews::MusicPreview>());
}
PreviewFactory::~PreviewFactory()
@@ -49,12 +73,19 @@ PreviewFactory::~PreviewFactory()
delete factory_item.second;
}
factory_items_.clear();
+
+ if (factory_instance == this)
+ factory_instance = nullptr;
}
PreviewFactory& PreviewFactory::Instance()
{
- static PreviewFactory factory;
- return factory;
+ if (!factory_instance)
+ {
+ LOG_ERROR(logger) << "No previews::Style created yet.";
+ }
+
+ return *factory_instance;
}
bool PreviewFactory::RegisterItem(std::string const& renderer_name, IPreviewFactoryItem*const item)
@@ -71,7 +102,7 @@ bool PreviewFactory::RegisterItem(std::string const& renderer_name, IPreviewFact
return true;
}
-PreviewFactoryOperator PreviewFactory::Item(glib::Variant& properties)
+PreviewFactoryOperator PreviewFactory::Item(glib::Variant const& properties)
{
static PreviewFactoryOperator nullOperator;
glib::Object<UnityProtocolPreview> preview(unity_protocol_preview_parse(properties));
diff --git a/dash/previews/PreviewFactory.h b/dash/previews/PreviewFactory.h
index 0ac84eee3..e36c5c7fe 100644
--- a/dash/previews/PreviewFactory.h
+++ b/dash/previews/PreviewFactory.h
@@ -16,7 +16,7 @@
* License version 3 along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
- * Authored by: Gordon Allott <gord.allott@canonical.com>
+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
*
*/
@@ -34,16 +34,17 @@ class PreviewFactory
{
typedef std::map<std::string, IPreviewFactoryItem*> FactoryItems;
public:
+ PreviewFactory();
+ ~PreviewFactory();
+
static PreviewFactory& Instance();
bool RegisterItem(std::string const& renderer_name, IPreviewFactoryItem*const item);
- PreviewFactoryOperator Item(glib::Variant& properties);
+ PreviewFactoryOperator Item(glib::Variant const& properties);
PreviewFactoryOperator Item(glib::Object<GObject> const& proto_obj);
private:
- PreviewFactory();
- ~PreviewFactory();
FactoryItems factory_items_;
};
diff --git a/dash/previews/PreviewFactoryItem.h b/dash/previews/PreviewFactoryItem.h
index 932caece3..2b187987c 100644
--- a/dash/previews/PreviewFactoryItem.h
+++ b/dash/previews/PreviewFactoryItem.h
@@ -16,7 +16,7 @@
* License version 3 along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
- * Authored by: Gordon Allott <gord.allott@canonical.com>
+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
*
*/
diff --git a/dash/previews/PreviewNavigator.cpp b/dash/previews/PreviewNavigator.cpp
index 56c04e51a..20fc4fb67 100644
--- a/dash/previews/PreviewNavigator.cpp
+++ b/dash/previews/PreviewNavigator.cpp
@@ -35,7 +35,7 @@ namespace previews
namespace
{
-nux::logging::Logger logger("unity.dash.previewnavigator");
+nux::logging::Logger logger("unity.dash.previews.previewnavigator");
}
NUX_IMPLEMENT_OBJECT_TYPE(PreviewNavigator);
diff --git a/dash/previews/Standalone.cpp b/dash/previews/Standalone.cpp
index 6b7a54992..b3f307b6b 100644
--- a/dash/previews/Standalone.cpp
+++ b/dash/previews/Standalone.cpp
@@ -35,8 +35,11 @@
#include "unity-shared/FontSettings.h"
#include "unity-shared/UnitySettings.h"
+#include "unity-shared/PreviewStyle.h"
#include "Preview.h"
+#include "PreviewContainer.h"
+
#define WIDTH 1024
#define HEIGHT 768
@@ -52,9 +55,9 @@ public:
static void InitWindowThread (nux::NThread* thread, void* InitData);
void Init ();
- nux::Layout *layout;
- previews::Preview::Ptr view;
- unity::dash::Preview::Ptr model;
+
+ previews::PreviewContainer::Ptr container_;
+ nux::Layout *layout_;
};
TestRunner::TestRunner ()
@@ -67,7 +70,12 @@ TestRunner::~TestRunner ()
void TestRunner::Init ()
{
- layout = new nux::VLayout(NUX_TRACKER_LOCATION);
+ container_ = new previews::PreviewContainer(NUX_TRACKER_LOCATION);
+ container_->SetMinMaxSize(WIDTH, HEIGHT);
+
+ layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
+ layout_->AddView(container_.GetPointer(), 1, nux::MINOR_POSITION_CENTER);
+ layout_->SetMinMaxSize(WIDTH, HEIGHT);
// creates a generic preview object
glib::Object<GIcon> icon(g_icon_new_for_string("accessories", NULL));
@@ -84,16 +92,9 @@ void TestRunner::Init ()
glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())),
glib::StealRef());
- PreviewFactoryOperator previewOperator(PreviewFactory::Instance().Item(v));
-
- model = previewOperator.CreateModel();
- view = previewOperator.CreateView(model);
-
- view->SetMinMaxSize(WIDTH, HEIGHT);
- layout->AddView (view.GetPointer(), 1, nux::MINOR_POSITION_CENTER);
- layout->SetMinMaxSize(WIDTH, HEIGHT);
+ container_->preview(v);
- nux::GetWindowThread()->SetLayout (layout);
+ nux::GetWindowThread()->SetLayout (layout_);
}
void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
@@ -111,6 +112,8 @@ int main(int argc, char **argv)
nux::NuxInitialize(0);
nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
// The instances for the pseudo-singletons.
+ unity::dash::previews::Style panel_style;
+ unity::dash::PreviewFactory preview_factory;
unity::Settings settings;
TestRunner *test_runner = new TestRunner ();