summaryrefslogtreecommitdiff
path: root/dash/previews
diff options
Diffstat (limited to 'dash/previews')
-rw-r--r--dash/previews/ActionButton.cpp1
-rw-r--r--dash/previews/ApplicationPreview.cpp72
-rw-r--r--dash/previews/ApplicationPreview.h7
-rw-r--r--dash/previews/GenericPreview.cpp50
-rw-r--r--dash/previews/GenericPreview.h3
-rw-r--r--dash/previews/MoviePreview.cpp44
-rw-r--r--dash/previews/MoviePreview.h3
-rw-r--r--dash/previews/MusicPreview.cpp59
-rw-r--r--dash/previews/MusicPreview.h2
-rw-r--r--dash/previews/Preview.cpp54
-rw-r--r--dash/previews/Preview.h5
-rw-r--r--dash/previews/PreviewContainer.cpp11
-rw-r--r--dash/previews/PreviewContainer.h1
-rw-r--r--dash/previews/PreviewNavigator.cpp31
-rw-r--r--dash/previews/StandaloneApplicationPreview.cpp5
-rw-r--r--dash/previews/StandaloneMusicPreview.cpp1
-rw-r--r--dash/previews/Track.cpp30
-rw-r--r--dash/previews/Track.h1
18 files changed, 272 insertions, 108 deletions
diff --git a/dash/previews/ActionButton.cpp b/dash/previews/ActionButton.cpp
index 2a948c8ee..92c6b833c 100644
--- a/dash/previews/ActionButton.cpp
+++ b/dash/previews/ActionButton.cpp
@@ -44,7 +44,6 @@ ActionButton::ActionButton(std::string const& label, std::string const& icon_hin
, image_(nullptr)
, static_text_(nullptr)
{
-
SetAcceptKeyNavFocusOnMouseDown(false);
SetAcceptKeyNavFocusOnMouseEnter(false);
Init();
diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp
index cf2ab7ca7..3ce6f2ffa 100644
--- a/dash/previews/ApplicationPreview.cpp
+++ b/dash/previews/ApplicationPreview.cpp
@@ -150,15 +150,13 @@ void ApplicationPreview::SetupViews()
previews::Style& style = dash::previews::Style::Instance();
- int details_width = style.GetPreviewWidth() - style.GetPreviewHeight() - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin();
nux::HLayout* image_data_layout = new nux::HLayout();
image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
- CoverArt* app_image = new CoverArt();
- app_image->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
- app_image->SetFont(style.no_preview_image_font());
- app_image->SetMinMaxSize(style.GetPreviewHeight(), style.GetPreviewHeight());
+ image_ = new CoverArt();
+ image_->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
+ image_->SetFont(style.no_preview_image_font());
/////////////////////
// App Data Panel
@@ -190,7 +188,6 @@ void ApplicationPreview::SetupViews()
/////////////////////
// Data
- int top_app_info_max_width = details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails();;
nux::VLayout* app_data_layout = new nux::VLayout();
app_data_layout->SetSpaceBetweenChildren(16);
@@ -201,12 +198,10 @@ void ApplicationPreview::SetupViews()
title_ = new nux::StaticCairoText(app_preview_model->title);
title_->SetLines(-1);
title_->SetFont(style.title_font().c_str());
- title_->SetMaximumWidth(top_app_info_max_width);
subtitle_ = new nux::StaticCairoText(app_preview_model->subtitle);
subtitle_->SetFont(style.subtitle_size_font().c_str());
subtitle_->SetLines(-1);
- subtitle_->SetMaximumWidth(top_app_info_max_width);
nux::VLayout* app_updated_copywrite_layout = new nux::VLayout();
app_updated_copywrite_layout->SetSpaceBetweenChildren(8);
@@ -214,16 +209,13 @@ void ApplicationPreview::SetupViews()
license_ = new nux::StaticCairoText(app_preview_model->license);
license_->SetFont(style.app_license_font().c_str());
license_->SetLines(-1);
- license_->SetMaximumWidth(top_app_info_max_width);
last_update_ = new nux::StaticCairoText(_("Last Updated ") + app_preview_model->last_update.Get());
last_update_->SetFont(style.app_last_update_font().c_str());
- last_update_->SetMaximumWidth(top_app_info_max_width);
copywrite_ = new nux::StaticCairoText(app_preview_model->copyright);
copywrite_->SetFont(style.app_copywrite_font().c_str());
copywrite_->SetLines(-1);
- copywrite_->SetMaximumWidth(top_app_info_max_width);
title_subtitle_layout_->AddView(title_, 1);
title_subtitle_layout_->AddView(subtitle_, 1);
@@ -251,15 +243,13 @@ void ApplicationPreview::SetupViews()
app_info_layout->SetSpaceBetweenChildren(12);
app_info->SetLayout(app_info_layout);
- app_description_ = new nux::StaticCairoText("");
- app_description_->SetFont(style.description_font().c_str());
- app_description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
- app_description_->SetLines(-20);
- app_description_->SetLineSpacing(2);
- app_description_->SetText(app_preview_model->description);
- app_description_->SetMaximumWidth(details_width);
-
- app_info_layout->AddView(app_description_);
+ description_ = new nux::StaticCairoText("");
+ description_->SetFont(style.description_font().c_str());
+ description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
+ description_->SetLines(-20);
+ description_->SetLineSpacing(2);
+ description_->SetText(app_preview_model->description);
+ app_info_layout->AddView(description_);
if (preview_model_->GetInfoHints().size() > 0)
{
PreviewInfoHintWidget* preview_info_hints = new PreviewInfoHintWidget(preview_model_, 24);
@@ -269,7 +259,8 @@ void ApplicationPreview::SetupViews()
/////////////////////
// Actions
- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), (details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonHeight());
+ action_buttons_.clear();
+ nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
///////////////////
@@ -278,13 +269,50 @@ void ApplicationPreview::SetupViews()
full_data_layout_->AddLayout(actions_layout, 0);
/////////////////////
- image_data_layout->AddView(app_image, 0);
+ image_data_layout->AddView(image_, 0);
image_data_layout->AddLayout(full_data_layout_, 1);
SetLayout(image_data_layout);
}
+long ApplicationPreview::ComputeContentSize()
+{
+ nux::Geometry geo = GetGeometry();
+ GetLayout()->SetGeometry(geo);
+
+ previews::Style& style = dash::previews::Style::Instance();
+
+ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
+
+ if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
+ geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
+ image_->SetGeometry(geo_art);
+
+ full_data_layout_->SetGeometry(nux::Geometry(geo_art.x + geo_art.width + style.GetPanelSplitWidth(), geo.y,
+ geo.width - geo_art.width - style.GetPanelSplitWidth(), geo.height));
+
+ int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
+ int top_app_info_max_width = details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails();
+
+ title_->SetMaximumWidth(top_app_info_max_width);
+ subtitle_->SetMaximumWidth(top_app_info_max_width);
+ license_->SetMaximumWidth(top_app_info_max_width);
+ last_update_->SetMaximumWidth(top_app_info_max_width);
+ copywrite_->SetMaximumWidth(top_app_info_max_width);
+ description_->SetMaximumWidth(details_width);
+
+ for (nux::AbstractButton* button : action_buttons_)
+ {
+ button->SetMinMaxSize(MIN((details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
+ }
+
+ image_->ComputeContentSize();
+ full_data_layout_->ComputeContentSize();
+
+ return nux::eCompliantHeight | nux::eCompliantWidth;
+}
+
} // namespace previews
} // namespace dash
diff --git a/dash/previews/ApplicationPreview.h b/dash/previews/ApplicationPreview.h
index 2335cf0c3..825d87e7c 100644
--- a/dash/previews/ApplicationPreview.h
+++ b/dash/previews/ApplicationPreview.h
@@ -41,6 +41,7 @@ namespace dash
{
namespace previews
{
+class CoverArt;
class PreviewRatingsWidget;
@@ -60,16 +61,16 @@ public:
protected:
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual long ComputeContentSize();
void SetupBackground();
void SetupViews();
-
-
protected:
nux::VLayout* full_data_layout_;
nux::VLayout* title_subtitle_layout_;
+ CoverArt* image_;
IconTexture* app_icon_;
PreviewRatingsWidget* app_rating_;
nux::StaticCairoText* title_;
@@ -77,7 +78,7 @@ protected:
nux::StaticCairoText* license_;
nux::StaticCairoText* last_update_;
nux::StaticCairoText* copywrite_;
- nux::StaticCairoText* app_description_;
+ nux::StaticCairoText* description_;
typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr;
LayerPtr details_bg_layer_;
diff --git a/dash/previews/GenericPreview.cpp b/dash/previews/GenericPreview.cpp
index 744f553af..9152a1de2 100644
--- a/dash/previews/GenericPreview.cpp
+++ b/dash/previews/GenericPreview.cpp
@@ -30,6 +30,7 @@
#include <Nux/VLayout.h>
#include <Nux/GridHLayout.h>
#include <UnityCore/GenericPreview.h>
+#include <Nux/AbstractButton.h>
#include "GenericPreview.h"
#include "PreviewInfoHintWidget.h"
@@ -139,15 +140,12 @@ void GenericPreview::SetupViews()
{
previews::Style& style = dash::previews::Style::Instance();
- int details_width = style.GetPreviewWidth() - style.GetPreviewHeight() - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin();
-
nux::HLayout* image_data_layout = new nux::HLayout();
image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
- CoverArt* image = new CoverArt();
- image->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
- image->SetFont(style.no_preview_image_font());
- image->SetMinMaxSize(style.GetPreviewHeight(), style.GetPreviewHeight());
+ image_ = new CoverArt();
+ image_->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
+ image_->SetFont(style.no_preview_image_font());
/////////////////////
// Data Panel
@@ -164,12 +162,10 @@ void GenericPreview::SetupViews()
title_ = new nux::StaticCairoText(preview_model_->title);
title_->SetLines(-1);
title_->SetFont(style.title_font().c_str());
- title_->SetMaximumWidth(details_width);
subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
subtitle_->SetLines(-1);
subtitle_->SetFont(style.subtitle_size_font().c_str());
- subtitle_->SetMaximumWidth(details_width);
preview_data_layout->AddView(title_, 1);
preview_data_layout->AddView(subtitle_, 1);
@@ -190,7 +186,6 @@ void GenericPreview::SetupViews()
description_->SetLines(-20);
description_->SetLineSpacing(1.5);
description_->SetText(preview_model_->description);
- description_->SetMaximumWidth(details_width);
preview_info_layout->AddView(description_);
if (preview_model_->GetInfoHints().size() > 0)
@@ -202,7 +197,8 @@ void GenericPreview::SetupViews()
/////////////////////
// Actions
- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), (details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonHeight());
+ action_buttons_.clear();
+ nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
///////////////////
@@ -211,12 +207,44 @@ void GenericPreview::SetupViews()
full_data_layout_->AddView(actions_layout, 0);
/////////////////////
- image_data_layout->AddView(image, 0);
+ image_data_layout->AddView(image_, 0);
image_data_layout->AddLayout(full_data_layout_, 1);
SetLayout(image_data_layout);
}
+long GenericPreview::ComputeContentSize()
+{
+ nux::Geometry geo = GetGeometry();
+ GetLayout()->SetGeometry(geo);
+
+ previews::Style& style = dash::previews::Style::Instance();
+
+ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
+
+ if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
+ geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
+ image_->SetGeometry(geo_art);
+
+ full_data_layout_->SetGeometry(nux::Geometry(geo_art.x + geo_art.width + style.GetPanelSplitWidth(), geo.y,
+ geo.width - geo_art.width - style.GetPanelSplitWidth(), geo.height));
+
+ int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
+
+ title_->SetMaximumWidth(details_width);
+ subtitle_->SetMaximumWidth(details_width);
+ description_->SetMaximumWidth(details_width);
+
+ for (nux::AbstractButton* button : action_buttons_)
+ {
+ button->SetMinMaxSize(MIN((details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
+ }
+
+ image_->ComputeContentSize();
+ full_data_layout_->ComputeContentSize();
+
+ return nux::eCompliantHeight | nux::eCompliantWidth;
+}
}
diff --git a/dash/previews/GenericPreview.h b/dash/previews/GenericPreview.h
index 31b6bdfc9..67f12df89 100644
--- a/dash/previews/GenericPreview.h
+++ b/dash/previews/GenericPreview.h
@@ -40,6 +40,7 @@ namespace dash
{
namespace previews
{
+class CoverArt;
class GenericPreview : public Preview
{
@@ -57,6 +58,7 @@ public:
protected:
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual long ComputeContentSize();
void SetupBackground();
void SetupViews();
@@ -64,6 +66,7 @@ protected:
protected:
nux::VLayout* full_data_layout_;
+ CoverArt* image_;
nux::StaticCairoText* title_;
nux::StaticCairoText* subtitle_;
nux::StaticCairoText* description_;
diff --git a/dash/previews/MoviePreview.cpp b/dash/previews/MoviePreview.cpp
index 0c3310509..45a8f4a96 100644
--- a/dash/previews/MoviePreview.cpp
+++ b/dash/previews/MoviePreview.cpp
@@ -30,6 +30,7 @@
#include <Nux/HLayout.h>
#include <Nux/VLayout.h>
#include <Nux/GridHLayout.h>
+#include <Nux/AbstractButton.h>
#include "MoviePreview.h"
#include "PreviewInfoHintWidget.h"
@@ -151,15 +152,12 @@ void MoviePreview::SetupView()
previews::Style& style = dash::previews::Style::Instance();
- int details_width = style.GetPreviewWidth() - style.GetPreviewHeight() - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin();
-
nux::HLayout* image_data_layout = new nux::HLayout();
image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
CoverArt* image = new CoverArt();
image->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
image->SetFont(style.no_preview_image_font());
- image->SetMinMaxSize(style.GetPreviewHeight(), style.GetPreviewHeight());
/////////////////////
// Data Panel
@@ -176,12 +174,10 @@ void MoviePreview::SetupView()
title_ = new nux::StaticCairoText(preview_model_->title);
title_->SetLines(-1);
title_->SetFont(style.title_font().c_str());
- title_->SetMaximumWidth(details_width);
subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
subtitle_->SetLines(-1);
subtitle_->SetFont(style.subtitle_size_font().c_str());
- subtitle_->SetMaximumWidth(details_width);
app_data_layout->AddView(title_, 1);
app_data_layout->AddView(subtitle_, 1);
@@ -202,7 +198,6 @@ void MoviePreview::SetupView()
description_->SetLines(-20);
description_->SetLineSpacing(1.5);
description_->SetText(preview_model_->description);
- description_->SetMaximumWidth(details_width);
preview_info_layout->AddView(description_);
if (preview_model_->GetInfoHints().size() > 0)
@@ -214,7 +209,8 @@ void MoviePreview::SetupView()
/////////////////////
// Actions
- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), (details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonHeight());
+ action_buttons_.clear();
+ nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
///////////////////
@@ -229,6 +225,40 @@ void MoviePreview::SetupView()
SetLayout(image_data_layout);
}
+
+long MoviePreview::ComputeContentSize()
+{
+ nux::Geometry geo = GetGeometry();
+ GetLayout()->SetGeometry(geo);
+
+ previews::Style& style = dash::previews::Style::Instance();
+
+ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
+
+ if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
+ geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
+ image_->SetGeometry(geo_art);
+
+ full_data_layout_->SetGeometry(nux::Geometry(geo_art.x + geo_art.width + style.GetPanelSplitWidth(), geo.y,
+ geo.width - geo_art.width - style.GetPanelSplitWidth(), geo.height));
+
+ int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
+
+ title_->SetMaximumWidth(details_width);
+ subtitle_->SetMaximumWidth(details_width);
+ description_->SetMaximumWidth(details_width);
+
+ for (nux::AbstractButton* button : action_buttons_)
+ {
+ button->SetMinMaxSize(MIN((details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
+ }
+
+ image_->ComputeContentSize();
+ full_data_layout_->ComputeContentSize();
+
+ return nux::eCompliantHeight | nux::eCompliantWidth;
+}
+
} // namespace previews
} // namespace dash
} // namespace unity
diff --git a/dash/previews/MoviePreview.h b/dash/previews/MoviePreview.h
index 3812b67cb..2fd6a1797 100644
--- a/dash/previews/MoviePreview.h
+++ b/dash/previews/MoviePreview.h
@@ -39,6 +39,7 @@ namespace dash
{
namespace previews
{
+class CoverArt;
class MoviePreview : public Preview
{
@@ -56,6 +57,7 @@ public:
protected:
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual long ComputeContentSize();
virtual void OnNavigateOut();
virtual void OnNavigateInComplete();
@@ -66,6 +68,7 @@ protected:
protected:
nux::VLayout* full_data_layout_;
+ CoverArt* image_;
nux::StaticCairoText* title_;
nux::StaticCairoText* subtitle_;
nux::StaticCairoText* description_;
diff --git a/dash/previews/MusicPreview.cpp b/dash/previews/MusicPreview.cpp
index 9894d83ac..e414bd584 100644
--- a/dash/previews/MusicPreview.cpp
+++ b/dash/previews/MusicPreview.cpp
@@ -29,7 +29,7 @@
#include <NuxCore/Logger.h>
#include <Nux/HLayout.h>
#include <Nux/VLayout.h>
-#include <Nux/Button.h>
+#include <Nux/AbstractButton.h>
#include "MusicPreview.h"
#include "ActionButton.h"
@@ -134,15 +134,12 @@ void MusicPreview::SetupViews()
previews::Style& style = dash::previews::Style::Instance();
- int details_width = style.GetPreviewWidth() - style.GetPreviewHeight() - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin();
-
nux::HLayout* image_data_layout = new nux::HLayout();
image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
- CoverArt* album_cover = new CoverArt();
- album_cover->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
- album_cover->SetFont(style.no_preview_image_font());
- album_cover->SetMinMaxSize(style.GetPreviewHeight(), style.GetPreviewHeight());
+ image_ = new CoverArt();
+ image_->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : "");
+ image_->SetFont(style.no_preview_image_font());
/////////////////////
// App Data Panel
@@ -157,11 +154,11 @@ void MusicPreview::SetupViews()
title_ = new nux::StaticCairoText(preview_model_->title);
title_->SetFont(style.title_font().c_str());
- title_->SetMaximumWidth(details_width);
+ title_->SetLines(-1);
subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
subtitle_->SetFont(style.subtitle_size_font().c_str());
- subtitle_->SetMaximumWidth(details_width);
+ subtitle_->SetLines(-1);
album_data_layout->AddView(title_, 1);
album_data_layout->AddView(subtitle_, 1);
@@ -196,13 +193,15 @@ void MusicPreview::SetupViews()
hints_layout->AddView(preview_info_hints, 0);
// If there are actions, we use a vertical layout
- actions_layout = BuildVerticalActionsLayout(preview_model_->GetActions(), (details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonHeight());
+ action_buttons_.clear();
+ actions_layout = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);
actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
}
else // otherwise we add a grid layout.
{
hint_actions_layout->AddSpace(0,1);
- actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), (details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonHeight());
+ action_buttons_.clear();
+ actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
}
/////////////////////
@@ -211,11 +210,14 @@ void MusicPreview::SetupViews()
hint_actions_layout->AddView(actions_layout, 0);
full_data_layout_->AddLayout(album_data_layout, 0);
- if (tracks_) { full_data_layout_->AddView(tracks_, 1); }
+ if (tracks_)
+ {
+ full_data_layout_->AddView(tracks_, 1);
+ }
full_data_layout_->AddLayout(hint_actions_layout, 0);
/////////////////////
- image_data_layout->AddView(album_cover, 0);
+ image_data_layout->AddView(image_, 0);
image_data_layout->AddLayout(full_data_layout_, 1);
SetLayout(image_data_layout);
@@ -245,6 +247,37 @@ void MusicPreview::OnPauseTrack(std::string const& uri)
music_preview_model->PauseUri(uri);
}
+long MusicPreview::ComputeContentSize()
+{
+ nux::Geometry geo = GetGeometry();
+ GetLayout()->SetGeometry(geo);
+
+ previews::Style& style = dash::previews::Style::Instance();
+
+ nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
+
+ if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
+ geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
+ image_->SetGeometry(geo_art);
+
+ full_data_layout_->SetGeometry(nux::Geometry(geo_art.x + geo_art.width + style.GetPanelSplitWidth(), geo.y,
+ geo.width - geo_art.width - style.GetPanelSplitWidth(), geo.height));
+
+ int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
+
+ title_->SetMaximumWidth(details_width);
+ subtitle_->SetMaximumWidth(details_width);
+
+ for (nux::AbstractButton* button : action_buttons_)
+ {
+ button->SetMinMaxSize(MIN((details_width - style.GetSpaceBetweenActions()) / 2, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
+ }
+
+ image_->ComputeContentSize();
+ full_data_layout_->ComputeContentSize();
+
+ return nux::eCompliantHeight | nux::eCompliantWidth;
+}
}
}
diff --git a/dash/previews/MusicPreview.h b/dash/previews/MusicPreview.h
index f25016a59..5f1fb3e14 100644
--- a/dash/previews/MusicPreview.h
+++ b/dash/previews/MusicPreview.h
@@ -59,6 +59,7 @@ public:
protected:
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual long ComputeContentSize();
void SetupBackground();
void SetupViews();
@@ -67,6 +68,7 @@ protected:
void OnPauseTrack(std::string const& uri);
private:
+ CoverArt* image_;
nux::StaticCairoText* title_;
nux::StaticCairoText* subtitle_;
nux::VLayout* full_data_layout_;
diff --git a/dash/previews/Preview.cpp b/dash/previews/Preview.cpp
index bbad87994..423ff6c8c 100644
--- a/dash/previews/Preview.cpp
+++ b/dash/previews/Preview.cpp
@@ -53,32 +53,32 @@ previews::Preview::Ptr Preview::PreviewForModel(dash::Preview::Ptr model)
return previews::Preview::Ptr();
}
- if (model->renderer_name == "preview-generic")
- {
- return Preview::Ptr(new GenericPreview(model));
- }
- else if (model->renderer_name == "preview-application")
- {
- return Preview::Ptr(new ApplicationPreview(model));
- }
- else if (model->renderer_name == "preview-music")
- {
- return Preview::Ptr(new MusicPreview(model));
- }
- else if (model->renderer_name == "preview-movie")
- {
- return Preview::Ptr(new MoviePreview(model));
- }
- // else if (renderer_name == "preview-series")
+ // if (model->renderer_name == "preview-generic")
// {
- // return Preview::Ptr(new SeriesPreview(model));
+ // return Preview::Ptr(new GenericPreview(model));
+ // }
+ // else if (model->renderer_name == "preview-application")
+ // {
+ // return Preview::Ptr(new ApplicationPreview(model));
+ // }
+ // else if (model->renderer_name == "preview-music")
+ // {
+ // return Preview::Ptr(new MusicPreview(model));
+ // }
+ // else if (model->renderer_name == "preview-movie")
+ // {
+ // return Preview::Ptr(new MoviePreview(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";
// }
- else
- {
- LOG_WARN(logger) << "Unable to create Preview for renderer: " << model->renderer_name.Get();
- }
- return previews::Preview::Ptr();
+ return Preview::Ptr(new GenericPreview(model));
}
NUX_IMPLEMENT_OBJECT_TYPE(Preview);
@@ -108,7 +108,7 @@ void Preview::OnActionActivated(nux::AbstractButton* button, std::string const&
preview_model_->PerformAction(id);
}
-nux::Layout* Preview::BuildGridActionsLayout(dash::Preview::ActionPtrList actions, int action_width, int action_height)
+nux::Layout* Preview::BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons)
{
previews::Style& style = dash::previews::Style::Instance();
@@ -131,8 +131,8 @@ nux::Layout* Preview::BuildGridActionsLayout(dash::Preview::ActionPtrList action
dash::Preview::ActionPtr action = actions[action_iter];
ActionButton* button = new ActionButton(action->display_name, action->icon_hint, NUX_TRACKER_LOCATION);
- button->SetMinMaxSize(action_width, action_height);
button->click.connect(sigc::bind(sigc::mem_fun(this, &Preview::OnActionActivated), action->id));
+ buttons.push_back(button);
actions_layout_h->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
}
@@ -144,7 +144,7 @@ nux::Layout* Preview::BuildGridActionsLayout(dash::Preview::ActionPtrList action
return actions_buffer_v;
}
-nux::Layout* Preview::BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, int action_width, int action_height)
+nux::Layout* Preview::BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons)
{
previews::Style& style = dash::previews::Style::Instance();
@@ -162,8 +162,8 @@ nux::Layout* Preview::BuildVerticalActionsLayout(dash::Preview::ActionPtrList ac
dash::Preview::ActionPtr action = actions[action_iter];
ActionButton* button = new ActionButton(action->display_name, action->icon_hint, NUX_TRACKER_LOCATION);
- button->SetMinMaxSize(action_width, action_height);
button->click.connect(sigc::bind(sigc::mem_fun(this, &Preview::OnActionActivated), action->id));
+ buttons.push_back(button);
actions_layout_v->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
}
diff --git a/dash/previews/Preview.h b/dash/previews/Preview.h
index 9c1d175b8..a8170d484 100644
--- a/dash/previews/Preview.h
+++ b/dash/previews/Preview.h
@@ -67,11 +67,12 @@ protected:
virtual void OnNavigateInComplete() {}
virtual void OnNavigateOut() {}
- nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, int action_width, int action_height);
- nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, int action_width, int action_height);
+ nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
+ nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
protected:
dash::Preview::Ptr preview_model_;
+ std::list<nux::AbstractButton*> action_buttons_;
friend class PreviewContent;
};
diff --git a/dash/previews/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp
index 3e80e5688..95229ad5c 100644
--- a/dash/previews/PreviewContainer.cpp
+++ b/dash/previews/PreviewContainer.cpp
@@ -270,8 +270,7 @@ void PreviewContainer::SetupViews()
layout_->AddView(nav_left_, 0);
content_layout_ = new PreviewContent(this);
- content_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight());
- layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ 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(style.GetNavigatorWidth());
@@ -434,6 +433,8 @@ bool PreviewContainer::InspectKeyEvent(unsigned int eventType, unsigned int keys
case NUX_KP_ENTER:
direction = nux::KeyNavDirection::KEY_NAV_ENTER;
break;
+ case NUX_VK_ESCAPE:
+ return true;
default:
direction = nux::KeyNavDirection::KEY_NAV_NONE;
break;
@@ -468,9 +469,15 @@ void PreviewContainer::OnKeyDown(unsigned long event_type, unsigned long event_k
case NUX_VK_LEFT:
navigate_left.emit();
break;
+
case NUX_VK_RIGHT:
navigate_right.emit();
break;
+
+ case NUX_VK_ESCAPE:
+ request_close.emit();
+ break;
+
default:
return;
}
diff --git a/dash/previews/PreviewContainer.h b/dash/previews/PreviewContainer.h
index bff5571cd..af0bd98ea 100644
--- a/dash/previews/PreviewContainer.h
+++ b/dash/previews/PreviewContainer.h
@@ -72,6 +72,7 @@ public:
// 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;
+ sigc::signal<void> request_close;
bool AcceptKeyNavFocus();
diff --git a/dash/previews/PreviewNavigator.cpp b/dash/previews/PreviewNavigator.cpp
index ff0d44cba..10994131e 100644
--- a/dash/previews/PreviewNavigator.cpp
+++ b/dash/previews/PreviewNavigator.cpp
@@ -75,10 +75,10 @@ void PreviewNavigator::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_d
nux::Geometry base = GetGeometry();
gfx_engine.PushClippingRectangle(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);
-
+ 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);
@@ -92,21 +92,34 @@ void PreviewNavigator::SetupViews()
if (orientation_ == Orientation::LEFT || orientation_ == Orientation::RIGHT)
{
nux::VLayout* vlayout = new nux::VLayout();
+ nux::HLayout* hlayout = new nux::HLayout();
vlayout->SetSpaceBetweenChildren(0);
- layout_ = vlayout;
+ hlayout->SetSpaceBetweenChildren(0);
+ layout_ = hlayout;
if (orientation_ == Orientation::LEFT)
- texture_ = new IconTexture(Style::Instance().GetNavLeftIcon(), 32, 32);
+ texture_ = new IconTexture(Style::Instance().GetNavLeftIcon(), 24, 24);
else
- texture_ = new IconTexture(Style::Instance().GetNavRightIcon(), 32, 32);
+ texture_ = new IconTexture(Style::Instance().GetNavRightIcon(), 24, 24);
+
+ vlayout->AddSpace(0,1);
+ vlayout->AddLayout(hlayout);
+ vlayout->AddSpace(0,1);
+ SetLayout(vlayout);
}
else if (orientation_ == Orientation::UP || orientation_ == Orientation::DOWN)
{
nux::HLayout* hlayout = new nux::HLayout();
+ nux::VLayout* vlayout = new nux::VLayout();
hlayout->SetSpaceBetweenChildren(0);
- layout_ = hlayout;
+ vlayout->SetSpaceBetweenChildren(0);
+ layout_ = vlayout;
+
+ hlayout->AddSpace(0,1);
+ hlayout->AddLayout(vlayout);
+ hlayout->AddSpace(0,1);
+ SetLayout(hlayout);
}
- SetLayout(layout_);
layout_->AddSpace(0, 1);
diff --git a/dash/previews/StandaloneApplicationPreview.cpp b/dash/previews/StandaloneApplicationPreview.cpp
index 831804d45..6330115e5 100644
--- a/dash/previews/StandaloneApplicationPreview.cpp
+++ b/dash/previews/StandaloneApplicationPreview.cpp
@@ -142,6 +142,7 @@ 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));
+ container_->request_close.connect([&]() { exit(0); });
DummyView* dummyView = new DummyView(container_.GetPointer());
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
@@ -150,9 +151,9 @@ void TestRunner::Init ()
std::stringstream app_name;
- app_name << "Yellow Submarine Eleanoewee ew";
+ app_name << "Skype";
- const char* subtitle = "The Beatles, 1986";
+ const char* subtitle = "Version 3.2, Size 32 MB";
const char* description = "Skype is a proprietary voice-over-Internet Protocol service and software application originally created by Niklas Zennström and Janus Friis in 2003, and owned by Microsoft since 2011. \
The service allows users to communicate with peers by voice, video, and instant messaging over the Internet. Phone calls may be placed to recipients on the traditional telephone networks. Calls to other users within the Skype service are free of charge, while calls to landline telephones and mobile phones are charged via a debit-based user account system.";
diff --git a/dash/previews/StandaloneMusicPreview.cpp b/dash/previews/StandaloneMusicPreview.cpp
index 3b593a845..7981bbaa8 100644
--- a/dash/previews/StandaloneMusicPreview.cpp
+++ b/dash/previews/StandaloneMusicPreview.cpp
@@ -179,6 +179,7 @@ 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));
+ container_->request_close.connect([&]() { exit(0); });
DummyView* dummyView = new DummyView(container_.GetPointer());
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
diff --git a/dash/previews/Track.cpp b/dash/previews/Track.cpp
index 19ad97ce4..54d7274d1 100644
--- a/dash/previews/Track.cpp
+++ b/dash/previews/Track.cpp
@@ -161,8 +161,8 @@ void Track::SetupBackground()
void Track::SetupViews()
{
previews::Style& style = previews::Style::Instance();
- nux::Layout* layout = new nux::HLayout();
- layout->SetLeftAndRightPadding(0,5);
+ nux::HLayout* layout = new nux::HLayout();
+ layout->SetLeftAndRightPadding(0,0);
nux::BaseTexture* tex_play = style.GetPlayIcon();
IconTexture* status_play = new IconTexture(tex_play, tex_play ? tex_play->GetWidth() : 25, tex_play ? tex_play->GetHeight() : 25);
@@ -183,23 +183,18 @@ void Track::SetupViews()
track_number_->SetFont(style.track_font());
track_number_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
track_number_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));
- track_number_->SetMaximumWidth(30);
-
- int track_width = style.GetPreviewWidth() - style.GetPreviewHeight() - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin();
title_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
title_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT);
title_->SetTextVerticalAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
title_->SetLines(-1);
title_->SetFont(style.track_font());
- title_->SetMaximumWidth(track_width - 30 - 60 - 10);
duration_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
duration_->SetTextEllipsize(nux::StaticCairoText::NUX_ELLIPSIZE_NONE);
duration_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_RIGHT);
duration_->SetTextVerticalAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
duration_->SetLines(-1);
- duration_->SetMaximumWidth(30);
duration_->SetFont(style.track_font());
// Layouts
// stick text fields in a layout so they don't alter thier geometry.
@@ -223,8 +218,6 @@ void Track::SetupViews()
track_status_layout_->AddLayer(status_pause_layout_, true);
track_status_layout_->AddLayer(track_number_layout_, true);
track_status_layout_->SetActiveLayer(track_number_layout_);
- track_status_layout_->SetMinimumWidth(30);
- track_status_layout_->SetMaximumWidth(30);
title_layout_ = new nux::HLayout();
title_layout_->SetLeftAndRightPadding(3);
@@ -235,6 +228,7 @@ void Track::SetupViews()
duration_layout_->AddSpace(0, 1);
duration_layout_->AddView(duration_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ layout->SetSpaceBetweenChildren(6);
layout->AddLayout(track_status_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
layout->AddLayout(title_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
layout->AddLayout(duration_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
@@ -355,6 +349,24 @@ void Track::UpdateTrackState()
}
+long Track::ComputeContentSize()
+{
+ track_status_layout_->SetMinimumWidth(30);
+ track_status_layout_->SetMaximumWidth(30);
+
+ track_number_->SetMinimumWidth(30);
+ track_number_->SetMaximumWidth(30);
+
+ duration_->SetMaximumWidth(40);
+ duration_->SetMaximumWidth(40);
+
+ title_->SetMaximumWidth(GetGeometry().width - 30 - 30 - 12);
+
+ return View::ComputeContentSize();
+}
+
+
+
}
}
}
diff --git a/dash/previews/Track.h b/dash/previews/Track.h
index e58aae0c6..b14df2057 100644
--- a/dash/previews/Track.h
+++ b/dash/previews/Track.h
@@ -64,6 +64,7 @@ public:
protected:
virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
+ virtual long ComputeContentSize();
void SetupBackground();
void SetupViews();