summaryrefslogtreecommitdiff
path: root/dash/previews
diff options
authorManuel de la Pena <manuel@canonical.com>2013-05-06 13:57:14 +0200
committerManuel de la Pena <manuel@canonical.com>2013-05-06 13:57:14 +0200
commitae6ff369d9a9bbc475c3e755c58869ee75937748 (patch)
tree98d5263885b0590ace837979bd95a9385207cfad /dash/previews
parent25c90fdef54fa888275bbe3d604dbf72bcceb7e2 (diff)
parentb0477dbe8dfe65756eec88b8e68824923d0d213f (diff)
Merged with libunity breackage.
(bzr r3263.2.24)
Diffstat (limited to 'dash/previews')
-rw-r--r--dash/previews/ApplicationPreview.cpp18
-rw-r--r--dash/previews/DBusTestRunner.h1
-rw-r--r--dash/previews/LensDBusTestRunner.h19
-rw-r--r--dash/previews/MusicPaymentPreview.cpp4
-rw-r--r--dash/previews/MusicPaymentPreview.h1
-rw-r--r--dash/previews/MusicPreview.cpp37
-rw-r--r--dash/previews/MusicPreview.h4
-rw-r--r--dash/previews/PaymentPreview.cpp.moved368
-rw-r--r--dash/previews/PaymentPreview.h1
-rw-r--r--dash/previews/Preview.cpp9
-rw-r--r--dash/previews/StandaloneMusicPreview.cpp4
-rw-r--r--dash/previews/Track.cpp65
-rw-r--r--dash/previews/Track.h9
-rw-r--r--dash/previews/Tracks.cpp11
-rw-r--r--dash/previews/Tracks.h10
15 files changed, 459 insertions, 102 deletions
diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp
index f2e898f70..7ab91a2d2 100644
--- a/dash/previews/ApplicationPreview.cpp
+++ b/dash/previews/ApplicationPreview.cpp
@@ -153,14 +153,16 @@ void ApplicationPreview::SetupViews()
app_icon_->mouse_click.connect(on_mouse_down);
icon_layout->AddView(app_icon_.GetPointer(), 0);
- app_rating_ = new PreviewRatingsWidget();
- AddChild(app_rating_.GetPointer());
- app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
- app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
- app_rating_->SetRating(app_preview_model->rating);
- app_rating_->SetReviews(app_preview_model->num_ratings);
- app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
- icon_layout->AddView(app_rating_.GetPointer(), 0);
+ if (app_preview_model->rating >= 0) {
+ app_rating_ = new PreviewRatingsWidget();
+ AddChild(app_rating_.GetPointer());
+ app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
+ app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
+ app_rating_->SetRating(app_preview_model->rating);
+ app_rating_->SetReviews(app_preview_model->num_ratings);
+ app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
+ icon_layout->AddView(app_rating_.GetPointer(), 0);
+ }
/////////////////////
diff --git a/dash/previews/DBusTestRunner.h b/dash/previews/DBusTestRunner.h
index b271bea34..54b856151 100644
--- a/dash/previews/DBusTestRunner.h
+++ b/dash/previews/DBusTestRunner.h
@@ -24,7 +24,6 @@
#include <UnityCore/GLibDBusProxy.h>
#include <UnityCore/Preview.h>
-#include <UnityCore/Lens.h>
#include <UnityCore/Results.h>
#include <NuxCore/Logger.h>
diff --git a/dash/previews/LensDBusTestRunner.h b/dash/previews/LensDBusTestRunner.h
index 0eb594068..745981745 100644
--- a/dash/previews/LensDBusTestRunner.h
+++ b/dash/previews/LensDBusTestRunner.h
@@ -23,6 +23,7 @@
#include "DBusTestRunner.h"
+#include "UnityCore/ScopeProxyInterface.h"
namespace unity
{
@@ -31,18 +32,18 @@ namespace dash
namespace previews
{
-class LensDBusTestRunner : public DBusTestRunner
+class ScopeDBusTestRunner : public DBusTestRunner
{
public:
typedef std::map<std::string, unity::glib::Variant> Hints;
- LensDBusTestRunner(std::string const& dbus_name, std::string const& dbus_path, std::string const& interface_name)
+ ScopeDBusTestRunner(std::string const& dbus_name, std::string const& dbus_path, std::string const& interface_name)
: DBusTestRunner(dbus_name, dbus_path, interface_name)
, results_(new Results(ModelType::REMOTE))
, results_variant_(NULL)
{
- proxy_->Connect("Changed", sigc::mem_fun(this, &LensDBusTestRunner::OnChanged));
- results_->end_transaction.connect(sigc::mem_fun(this, &LensDBusTestRunner::ResultsModelUpdated));
+ proxy_->Connect("Changed", sigc::mem_fun(this, &ScopeDBusTestRunner::OnChanged));
+ results_->end_transaction.connect(sigc::mem_fun(this, &ScopeDBusTestRunner::ResultsModelUpdated));
}
void OnProxyConnectionChanged()
@@ -52,7 +53,7 @@ public:
if (proxy_->IsConnected())
{
proxy_->Call("InfoRequest");
- proxy_->Call("SetViewType", g_variant_new("(u)", LENS_VIEW));
+ proxy_->Call("SetViewType", g_variant_new("(u)", ScopeViewType::SCOPE_VIEW));
}
}
@@ -81,7 +82,7 @@ public:
&filters_model_name,
&hints_iter);
- LOG_DEBUG(logger) << "Lens info changed for " << dbus_name_ << "\n"
+ LOG_DEBUG(logger) << "Scope info changed for " << dbus_name_ << "\n"
<< " Path: " << dbus_path << "\n"
<< " SearchInGlobal: " << search_in_global << "\n"
<< " Visible: " << visible << "\n"
@@ -125,7 +126,7 @@ public:
g_variant_new("(sa{sv})",
search_string.c_str(),
&b),
- sigc::mem_fun(this, &LensDBusTestRunner::OnSearchFinished),
+ sigc::mem_fun(this, &ScopeDBusTestRunner::OnSearchFinished),
search_cancellable_);
g_variant_builder_clear(&b);
@@ -183,7 +184,7 @@ public:
proxy_->Call("Activate",
g_variant_new("(su)", uri.c_str(),
UNITY_PROTOCOL_ACTION_TYPE_PREVIEW_RESULT),
- sigc::mem_fun(this, &LensDBusTestRunner::ActivationReply),
+ sigc::mem_fun(this, &ScopeDBusTestRunner::ActivationReply),
preview_cancellable_);
}
@@ -208,7 +209,7 @@ public:
{
dash::Preview::Ptr preview(dash::Preview::PreviewForVariant(iter->second));
- // would be nice to make parent_lens a shared_ptr,
+ // would be nice to make parent_scope a shared_ptr,
// but that's not really doable from here
preview_ready.emit(uri.Str(), preview);
return;
diff --git a/dash/previews/MusicPaymentPreview.cpp b/dash/previews/MusicPaymentPreview.cpp
index f85b7578c..69d5e4b17 100644
--- a/dash/previews/MusicPaymentPreview.cpp
+++ b/dash/previews/MusicPaymentPreview.cpp
@@ -1,4 +1,4 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright 2012-2013 Canonical Ltd.
*
@@ -94,7 +94,7 @@ void MusicPaymentPreview::OnActionActivated(ActionButton* button, std::string co
// HACK: We need to think a better way to do this
auto const& password = password_entry_->text_entry()->GetText();
glib::Variant variant_pw(g_variant_new_string(password.c_str()));
- Lens::Hints hints {
+ glib::HintsMap hints {
std::make_pair(MusicPaymentPreview::DATA_PASSWORD_KEY, variant_pw)
};
preview_model_->PerformAction(id, hints);
diff --git a/dash/previews/MusicPaymentPreview.h b/dash/previews/MusicPaymentPreview.h
index 423ac6547..40062f562 100644
--- a/dash/previews/MusicPaymentPreview.h
+++ b/dash/previews/MusicPaymentPreview.h
@@ -25,7 +25,6 @@
#include <Nux/Nux.h>
#include <Nux/AbstractButton.h>
-#include <UnityCore/Lens.h>
#include <UnityCore/PaymentPreview.h>
#include "ActionButton.h"
#include "ActionLink.h"
diff --git a/dash/previews/MusicPreview.cpp b/dash/previews/MusicPreview.cpp
index 21e4f2868..9e1fb98f0 100644
--- a/dash/previews/MusicPreview.cpp
+++ b/dash/previews/MusicPreview.cpp
@@ -34,6 +34,7 @@
#include "ActionButton.h"
#include "Tracks.h"
#include "PreviewInfoHintWidget.h"
+#include "PreviewPlayer.h"
namespace unity
{
@@ -177,8 +178,6 @@ void MusicPreview::SetupViews()
{
tracks_ = new previews::Tracks(tracks_model, NUX_TRACKER_LOCATION);
AddChild(tracks_.GetPointer());
- tracks_->play.connect(sigc::mem_fun(this, &MusicPreview::OnPlayTrack));
- tracks_->pause.connect(sigc::mem_fun(this, &MusicPreview::OnPauseTrack));
tracks_->mouse_click.connect(on_mouse_down);
}
/////////////////////
@@ -264,30 +263,6 @@ void MusicPreview::SetupViews()
SetLayout(image_data_layout);
}
-void MusicPreview::OnPlayTrack(std::string const& uri)
-{
- dash::MusicPreview* music_preview_model = dynamic_cast<dash::MusicPreview*>(preview_model_.get());
- if (!music_preview_model)
- {
- LOG_ERROR(logger) << "Play failed. No preview found";
- return;
- }
-
- music_preview_model->PlayUri(uri);
-}
-
-void MusicPreview::OnPauseTrack(std::string const& uri)
-{
- dash::MusicPreview* music_preview_model = dynamic_cast<dash::MusicPreview*>(preview_model_.get());
- if (!music_preview_model)
- {
- LOG_ERROR(logger) << "Pause failed. No preview found";
- return;
- }
-
- music_preview_model->PauseUri(uri);
-}
-
void MusicPreview::PreLayoutManagement()
{
nux::Geometry geo = GetGeometry();
@@ -314,6 +289,12 @@ void MusicPreview::PreLayoutManagement()
Preview::PreLayoutManagement();
}
+void MusicPreview::OnNavigateOut()
+{
+ PreviewPlayer player;
+ player.Stop();
}
-}
-}
+
+} // namespace previews
+} // namespace dash
+} // namespace unity
diff --git a/dash/previews/MusicPreview.h b/dash/previews/MusicPreview.h
index cf56b1e0e..f215dadd5 100644
--- a/dash/previews/MusicPreview.h
+++ b/dash/previews/MusicPreview.h
@@ -54,9 +54,7 @@ protected:
virtual void SetupViews();
- void OnPlayTrack(std::string const& uri);
- void OnPauseTrack(std::string const& uri);
- bool HasUbuntuOneCredentials();
+ virtual void OnNavigateOut();
protected:
nux::ObjectPtr<Tracks> tracks_;
diff --git a/dash/previews/PaymentPreview.cpp.moved b/dash/previews/PaymentPreview.cpp.moved
new file mode 100644
index 000000000..388734b34
--- /dev/null
+++ b/dash/previews/PaymentPreview.cpp.moved
@@ -0,0 +1,368 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright 2012-2013 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: Diego Sarmentero <diego.sarmentero@canonical.com>
+ * Manuel de la Pena <manuel.delapena@canonical.com>
+ *
+ */
+#include <NuxCore/Logger.h>
+#include "PaymentPreview.h"
+#include "unity-shared/CoverArt.h"
+#include "unity-shared/PreviewStyle.h"
+
+namespace unity
+{
+
+namespace dash
+{
+
+namespace previews
+{
+
+namespace
+{
+
+nux::logging::Logger logger("unity.dash.previews.payment.preview");
+
+}
+
+class OverlaySpinner : public unity::debug::Introspectable, public nux::View
+{
+ NUX_DECLARE_OBJECT_TYPE(OverlaySpinner, nux::View);
+public:
+ OverlaySpinner();
+
+ void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
+ void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+
+protected:
+ // Introspectable methods
+ std::string GetName() const;
+ void AddProperties(GVariantBuilder* builder);
+
+ // Key navigation
+ virtual bool AcceptKeyNavFocus();
+
+private:
+ bool OnFrameTimeout();
+
+ nux::BaseTexture* spin_;
+
+ glib::Source::UniquePtr frame_timeout_;
+
+ nux::Matrix4 rotate_;
+ float rotation_;
+};
+
+NUX_IMPLEMENT_OBJECT_TYPE(OverlaySpinner);
+
+OverlaySpinner::OverlaySpinner()
+ : nux::View(NUX_TRACKER_LOCATION),
+ rotation_(0.0f)
+{
+ previews::Style& style = dash::previews::Style::Instance();
+
+ spin_ = style.GetSearchSpinIcon();
+
+ rotate_.Identity();
+ rotate_.Rotate_z(0.0);
+}
+
+void OverlaySpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
+{
+ nux::Geometry const& geo = GetGeometry();
+ nux::TexCoordXForm texxform;
+
+ GfxContext.PushClippingRectangle(geo);
+
+ nux::GetPainter().PaintBackground(GfxContext, geo);
+
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
+ texxform.min_filter = nux::TEXFILTER_LINEAR;
+ texxform.mag_filter = nux::TEXFILTER_LINEAR;
+
+ unsigned int current_alpha_blend;
+ unsigned int current_src_blend_factor;
+ unsigned int current_dest_blend_factor;
+ GfxContext.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor);
+ GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+ nux::Geometry spin_geo(geo.x + ((geo.width - spin_->GetWidth()) / 2),
+ geo.y + ((geo.height - spin_->GetHeight()) / 2),
+ spin_->GetWidth(),
+ spin_->GetHeight());
+ // Geometry (== Rect) uses integers which were rounded above,
+ // hence an extra 0.5 offset for odd sizes is needed
+ // because pure floating point is not being used.
+ int spin_offset_w = !(geo.width % 2) ? 0 : 1;
+ int spin_offset_h = !(geo.height % 2) ? 0 : 1;
+
+ nux::Matrix4 matrix_texture;
+ matrix_texture = nux::Matrix4::TRANSLATE(-spin_geo.x - (spin_geo.width + spin_offset_w) / 2.0f,
+ -spin_geo.y - (spin_geo.height + spin_offset_h) / 2.0f, 0) * matrix_texture;
+ matrix_texture = rotate_ * matrix_texture;
+ matrix_texture = nux::Matrix4::TRANSLATE(spin_geo.x + (spin_geo.width + spin_offset_w) / 2.0f,
+ spin_geo.y + (spin_geo.height + spin_offset_h) / 2.0f, 0) * matrix_texture;
+
+ GfxContext.SetModelViewMatrix(GfxContext.GetModelViewMatrix() * matrix_texture);
+
+ GfxContext.QRP_1Tex(spin_geo.x,
+ spin_geo.y,
+ spin_geo.width,
+ spin_geo.height,
+ spin_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+
+ // revert to model view matrix stack
+ GfxContext.ApplyModelViewMatrix();
+
+ GfxContext.PopClippingRectangle();
+
+ GfxContext.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor);
+
+ if (!frame_timeout_)
+ {
+ frame_timeout_.reset(new glib::Timeout(22, sigc::mem_fun(this, &OverlaySpinner::OnFrameTimeout)));
+ }
+}
+
+
+void OverlaySpinner::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
+{
+}
+
+
+bool OverlaySpinner::OnFrameTimeout()
+{
+ rotation_ += 0.1f;
+
+ if (rotation_ >= 360.0f)
+ rotation_ = 0.0f;
+
+ rotate_.Rotate_z(rotation_);
+ QueueDraw();
+
+ frame_timeout_.reset();
+ return false;
+}
+
+std::string OverlaySpinner::GetName() const
+{
+ return "OverlaySpinner";
+}
+
+void OverlaySpinner::AddProperties(GVariantBuilder* builder)
+{
+ nux::Geometry geo = GetGeometry();
+
+ variant::BuilderWrapper(builder)
+ .add("x", geo.x)
+ .add("y", geo.y)
+ .add("width", geo.width)
+ .add("height", geo.height);
+}
+
+
+bool OverlaySpinner::AcceptKeyNavFocus()
+{
+ return false;
+}
+
+PaymentPreview::PaymentPreview(dash::Preview::Ptr preview_model)
+: Preview(preview_model)
+, data_(nullptr)
+, full_data_layout_(nullptr)
+{
+}
+
+std::string PaymentPreview::GetName() const
+{
+ return "";
+}
+
+
+nux::Layout* PaymentPreview::GetHeader()
+{
+ nux::HLayout* header_data_layout = new nux::HLayout();
+ header_data_layout->SetSpaceBetweenChildren(10);
+ header_data_layout->SetMaximumHeight(76);
+ header_data_layout->SetMinimumHeight(76);
+
+ image_ = new CoverArt();
+ image_->SetMinMaxSize(64, 64);
+ AddChild(image_.GetPointer());
+ UpdateCoverArtImage(image_.GetPointer());
+
+ header_data_layout->AddView(image_.GetPointer(), 0);
+ header_data_layout->AddLayout(GetTitle(), 0);
+ header_data_layout->AddSpace(10, 1);
+ header_data_layout->AddLayout(GetPrice(), 0);
+ return header_data_layout;
+}
+
+nux::ObjectPtr<ActionLink> PaymentPreview::CreateLink(dash::Preview::ActionPtr action)
+{
+ previews::Style& style = dash::previews::Style::Instance();
+
+ nux::ObjectPtr<ActionLink> link;
+ link = new ActionLink(action->id,
+ action->display_name, NUX_TRACKER_LOCATION);
+ link->font_hint.Set(style.payment_form_labels_font().c_str());
+ link->SetMinimumWidth(178);
+ link->SetMaximumHeight(34);
+ return link;
+}
+
+
+nux::ObjectPtr<ActionButton> PaymentPreview::CreateButton(dash::Preview::ActionPtr action)
+{
+ previews::Style& style = dash::previews::Style::Instance();
+
+ nux::ObjectPtr<ActionButton> button;
+ button = new ActionButton(action->id,
+ action->display_name, action->icon_hint,
+ NUX_TRACKER_LOCATION);
+ button->SetFont(style.action_font());
+ button->SetExtraHint(action->extra_text, style.action_extra_font());
+ button->SetMinimumWidth(178);
+ button->SetMaximumHeight(34);
+ return button;
+}
+
+
+void PaymentPreview::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
+{
+ nux::Geometry const& base = GetGeometry();
+
+ gfx_engine.PushClippingRectangle(base);
+ nux::GetPainter().PaintBackground(gfx_engine, base);
+
+ if (full_data_layout_)
+ {
+ 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);
+
+ details_bg_layer_->SetGeometry(full_data_layout_->GetGeometry());
+ nux::GetPainter().RenderSinglePaintLayer(gfx_engine, full_data_layout_->GetGeometry(), details_bg_layer_.get());
+
+ gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
+ }
+
+ gfx_engine.PopClippingRectangle();
+}
+
+void PaymentPreview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
+{
+ nux::Geometry const& base = GetGeometry();
+ gfx_engine.PushClippingRectangle(base);
+
+ if (!IsFullRedraw())
+ nux::GetPainter().PushLayer(gfx_engine, details_bg_layer_->GetGeometry(), details_bg_layer_.get());
+
+ 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);
+
+ if (GetCompositionLayout())
+ GetCompositionLayout()->ProcessDraw(gfx_engine, force_draw);
+
+ gfx_engine.GetRenderStates().SetBlend(alpha, src, dest);
+
+ if (!IsFullRedraw())
+ nux::GetPainter().PopBackground();
+
+ gfx_engine.PopClippingRectangle();
+}
+
+void PaymentPreview::ShowOverlay(bool isShown)
+{
+ if (!full_data_layout_)
+ return;
+
+ if (isShown)
+ {
+ full_data_layout_->SetActiveLayerN(1);
+ }
+ else
+ {
+ full_data_layout_->SetActiveLayerN(0);
+ }
+ QueueDraw();
+}
+
+void PaymentPreview::ShowOverlay()
+{
+ ShowOverlay(true);
+}
+
+void PaymentPreview::HideOverlay()
+{
+ ShowOverlay(false);
+}
+
+void PaymentPreview::SetupBackground()
+{
+ details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer());
+}
+
+void PaymentPreview::SetupViews()
+{
+ full_data_layout_ = new nux::LayeredLayout();
+
+ // layout to be used to show the info
+ content_data_layout_ = new nux::VLayout();
+ content_data_layout_->SetSpaceBetweenChildren(5);
+ content_data_layout_->SetPadding(10, 10, 0, 10);
+
+ header_layout_ = GetHeader();
+
+ content_data_layout_->AddLayout(header_layout_.GetPointer(), 1);
+
+ body_layout_ = GetBody();
+ content_data_layout_->AddLayout(body_layout_.GetPointer(), 1);
+
+ footer_layout_ = GetFooter();
+ content_data_layout_->AddLayout(footer_layout_.GetPointer(), 1);
+
+ full_data_layout_->AddLayout(content_data_layout_.GetPointer());
+
+ // layout to draw an overlay
+ overlay_layout_ = new nux::VLayout();
+ StaticCairoText* calculating = new StaticCairoText(
+ "Performing purchase", true,
+ NUX_TRACKER_LOCATION);
+
+ OverlaySpinner* spinner_ = new OverlaySpinner();
+ overlay_layout_->AddSpace(20, 1);
+ overlay_layout_->AddView(calculating, 0, nux::MINOR_POSITION_CENTER);
+ overlay_layout_->AddView(spinner_, 1, nux::MINOR_POSITION_CENTER);
+ overlay_layout_->AddSpace(20, 1);
+
+ full_data_layout_->AddLayout(overlay_layout_.GetPointer());
+
+ SetLayout(full_data_layout_.GetPointer());
+}
+
+}
+
+}
+
+}
diff --git a/dash/previews/PaymentPreview.h b/dash/previews/PaymentPreview.h
index 3359d8952..3a09e895b 100644
--- a/dash/previews/PaymentPreview.h
+++ b/dash/previews/PaymentPreview.h
@@ -28,7 +28,6 @@
#include <Nux/HLayout.h>
#include <Nux/LayeredLayout.h>
#include <Nux/AbstractButton.h>
-#include <UnityCore/Lens.h>
#include <UnityCore/PaymentPreview.h>
#include "ActionButton.h"
#include "ActionLink.h"
diff --git a/dash/previews/Preview.cpp b/dash/previews/Preview.cpp
index 44eaca080..c32038444 100644
--- a/dash/previews/Preview.cpp
+++ b/dash/previews/Preview.cpp
@@ -88,10 +88,6 @@ previews::Preview::Ptr Preview::PreviewForModel(dash::Preview::Ptr model)
{
return Preview::Ptr(new SocialPreview(model));
}
- // else if (renderer_name == "preview-series")
- // {
- // return Preview::Ptr(new SeriesPreview(model));
- // }
else
{
LOG_WARN(logger) << "Unable to create Preview for renderer: " << model->renderer_name.Get() << "; using generic";
@@ -116,9 +112,6 @@ Preview::Preview(dash::Preview::Ptr preview_model)
Preview::~Preview()
{
- if (preview_model_)
- preview_model_->EmitClosed();
-
delete tab_iterator_;
}
@@ -131,7 +124,7 @@ void Preview::AddProperties(GVariantBuilder* builder)
{
variant::BuilderWrapper(builder)
.add(GetAbsoluteGeometry())
- .add("uri", preview_model_->preview_uri.Get());
+ .add("uri", preview_model_->preview_result.uri);
}
void Preview::OnActionActivated(ActionButton* button, std::string const& id)
diff --git a/dash/previews/StandaloneMusicPreview.cpp b/dash/previews/StandaloneMusicPreview.cpp
index 830fdd330..c4680e587 100644
--- a/dash/previews/StandaloneMusicPreview.cpp
+++ b/dash/previews/StandaloneMusicPreview.cpp
@@ -116,7 +116,7 @@ protected:
LayerPtr bg_layer_;
};
-class TestRunner : public previews::LensDBusTestRunner
+class TestRunner : public previews::ScopeDBusTestRunner
{
public:
TestRunner(std::string const& search_string);
@@ -136,7 +136,7 @@ public:
};
TestRunner::TestRunner (std::string const& search_string)
-: LensDBusTestRunner("com.canonical.Unity.Lens.Music","/com/canonical/unity/lens/music", "com.canonical.Unity.Lens")
+: ScopeDBusTestRunner("com.canonical.Unity.Scope.Music","/com/canonical/unity/scope/music", "com.canonical.Unity.Scope")
, search_string_(search_string)
, first_(true)
{
diff --git a/dash/previews/Track.cpp b/dash/previews/Track.cpp
index 92e38ece2..0e43f3bc1 100644
--- a/dash/previews/Track.cpp
+++ b/dash/previews/Track.cpp
@@ -125,7 +125,8 @@ private:
Track::Track(NUX_FILE_LINE_DECL)
: View(NUX_FILE_LINE_PARAM)
- , play_state_(dash::STOPPED)
+ , play_state_(PlayerState::STOPPED)
+ , progress_(0.0)
, mouse_over_(false)
{
SetupBackground();
@@ -134,6 +135,7 @@ Track::Track(NUX_FILE_LINE_DECL)
Track::~Track()
{
+ player_connection_.disconnect();
}
std::string Track::GetName() const
@@ -145,7 +147,7 @@ void Track::AddProperties(GVariantBuilder* builder)
{
variant::BuilderWrapper(builder)
.add("uri", uri_)
- .add("play-state", play_state_)
+ .add("play-state", (int)play_state_)
.add("progress", progress_)
.add("playpause-x", track_status_layout_->GetAbsoluteX())
.add("playpause-y", track_status_layout_->GetAbsoluteX())
@@ -156,8 +158,6 @@ void Track::AddProperties(GVariantBuilder* builder)
void Track::Update(dash::Track const& track)
{
uri_ = track.uri;
- progress_ = track.progress;
-
title_->SetText(track.title, true);
std::stringstream ss_track_number;
@@ -168,9 +168,25 @@ void Track::Update(dash::Track const& track)
duration_->SetText(duration);
g_free(duration);
- play_state_ = track.play_state;
- UpdateTrackState();
+ player_connection_.disconnect();
+ player_connection_ = player_.updated.connect([this](std::string const& uri, PlayerState player_state, double progress)
+ {
+ if (uri != uri_)
+ {
+ // If we're received an update for another track, we're obviously not playing this track anymore.
+ if (progress_ != 0.0 || play_state_ != PlayerState::STOPPED)
+ {
+ progress_ = 0.0;
+ play_state_ = PlayerState::STOPPED;
+ UpdateTrackState();
+ }
+ return;
+ }
+ progress_ = progress;
+ play_state_ = player_state;
+ UpdateTrackState();
+ });
QueueDraw();
}
@@ -264,13 +280,17 @@ void Track::SetupViews()
{
switch (play_state_)
{
- case dash::PLAYING:
- pause.emit(uri_);
+ case PlayerState::PLAYING:
+ player_.Pause();
+ break;
+
+ case PlayerState::PAUSED:
+ player_.Resume();
break;
- case dash::PAUSED:
- case dash::STOPPED:
+
+ case PlayerState::STOPPED:
default:
- play.emit(uri_);
+ player_.Play(uri_);
break;
}
});
@@ -357,7 +377,7 @@ nux::Area* Track::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxE
bool Track::HasStatusFocus() const
{
- return mouse_over_ || play_state_ == dash::PLAYING || play_state_ == dash::PAUSED;
+ return mouse_over_ || play_state_ == PlayerState::PLAYING || play_state_ == PlayerState::PAUSED;
}
void Track::OnTrackControlMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
@@ -382,11 +402,11 @@ void Track::UpdateTrackState()
{
switch (play_state_)
{
- case dash::PLAYING:
+ case PlayerState::PLAYING:
track_status_layout_->SetActiveLayer(status_pause_layout_);
break;
- case dash::PAUSED:
- case dash::STOPPED:
+ case PlayerState::PAUSED:
+ case PlayerState::STOPPED:
default:
track_status_layout_->SetActiveLayer(status_play_layout_);
break;
@@ -396,18 +416,19 @@ void Track::UpdateTrackState()
{
switch (play_state_)
{
- case dash::PLAYING:
+ case PlayerState::PLAYING:
track_status_layout_->SetActiveLayer(status_play_layout_);
break;
- case dash::PAUSED:
+ case PlayerState::PAUSED:
track_status_layout_->SetActiveLayer(status_pause_layout_);
break;
- case dash::STOPPED:
+ case PlayerState::STOPPED:
default:
track_status_layout_->SetActiveLayer(track_number_layout_);
break;
}
}
+ QueueDraw();
}
@@ -425,8 +446,6 @@ void Track::PreLayoutManagement()
View::PreLayoutManagement();
}
-
-
-}
-}
-}
+} // namespace previews
+} // namespace dash
+} // namesapce unity
diff --git a/dash/previews/Track.h b/dash/previews/Track.h
index b1815dae1..329e17f9e 100644
--- a/dash/previews/Track.h
+++ b/dash/previews/Track.h
@@ -27,6 +27,7 @@
#include <Nux/View.h>
#include <UnityCore/Tracks.h>
#include "unity-shared/Introspectable.h"
+#include "PreviewPlayer.h"
namespace nux
{
@@ -54,9 +55,6 @@ public:
void Update(dash::Track const& track_row);
- sigc::signal<void, std::string const&> play;
- sigc::signal<void, std::string const&> pause;
-
protected:
virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
@@ -81,7 +79,11 @@ protected:
protected:
std::string uri_;
+ PlayerState play_state_;
float progress_;
+ PreviewPlayer player_;
+ sigc::connection player_connection_;
+
unity::StaticCairoText* track_number_;
unity::StaticCairoText* title_;
unity::StaticCairoText* duration_;
@@ -97,7 +99,6 @@ protected:
nux::View* track_number_layout_;
nux::LayeredLayout* track_status_layout_;
- dash::PlayState play_state_;
bool mouse_over_;
};
diff --git a/dash/previews/Tracks.cpp b/dash/previews/Tracks.cpp
index 1c5a3872c..7f53519cc 100644
--- a/dash/previews/Tracks.cpp
+++ b/dash/previews/Tracks.cpp
@@ -47,9 +47,9 @@ Tracks::Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_DECL)
if (tracks_)
{
- tracks_->track_added.connect(sigc::mem_fun(this, &Tracks::OnTrackAdded));
- tracks_->track_changed.connect(sigc::mem_fun(this, &Tracks::OnTrackUpdated));
- tracks_->track_removed.connect(sigc::mem_fun(this, &Tracks::OnTrackRemoved));
+ add_track_ = tracks_->track_added.connect(sigc::mem_fun(this, &Tracks::OnTrackAdded));
+ change_track_ = tracks_->track_changed.connect(sigc::mem_fun(this, &Tracks::OnTrackUpdated));
+ remove_track_ = tracks_->track_removed.connect(sigc::mem_fun(this, &Tracks::OnTrackRemoved));
// Add what we've got.
for (std::size_t i = 0; i < tracks_->count.Get(); i++)
@@ -61,6 +61,9 @@ Tracks::Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_DECL)
Tracks::~Tracks()
{
+ add_track_.disconnect();
+ change_track_.disconnect();
+ remove_track_.disconnect();
}
std::string Tracks::GetName() const
@@ -105,8 +108,6 @@ void Tracks::OnTrackAdded(dash::Track const& track_row)
previews::Track::Ptr track_view(new previews::Track(NUX_TRACKER_LOCATION));
AddChild(track_view.GetPointer());
- track_view->play.connect([&](std::string const& uri) { play.emit(uri); });
- track_view->pause.connect([&](std::string const& uri) { pause.emit(uri); });
track_view->Update(track_row);
track_view->SetMinimumHeight(style.GetTrackHeight());
diff --git a/dash/previews/Tracks.h b/dash/previews/Tracks.h
index ca4a0a25c..1854ddc01 100644
--- a/dash/previews/Tracks.h
+++ b/dash/previews/Tracks.h
@@ -56,9 +56,6 @@ public:
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
- sigc::signal<void, std::string const&> play;
- sigc::signal<void, std::string const&> pause;
-
protected:
virtual bool AcceptKeyNavFocus() { return false; }
@@ -68,15 +65,14 @@ protected:
void OnTrackAdded(dash::Track const& track);
void OnTrackRemoved(dash::Track const&track);
- void onPlayTrack(std::string const& uri);
- void onPauseTrack(std::string const& uri);
-
protected:
dash::Tracks::Ptr tracks_;
nux::VLayout* layout_;
std::map<std::string, previews::Track::Ptr> m_tracks;
- int track_count_;
+ sigc::connection add_track_;
+ sigc::connection change_track_;
+ sigc::connection remove_track_;
};
}