summaryrefslogtreecommitdiff
path: root/dash
diff options
Diffstat (limited to 'dash')
-rw-r--r--dash/DashController.cpp79
-rw-r--r--dash/DashController.h10
-rw-r--r--dash/DashView.cpp18
-rwxr-xr-xdash/LensView.cpp133
-rw-r--r--dash/LensView.h5
-rw-r--r--dash/previews/ActionButton.cpp2
-rw-r--r--dash/previews/ApplicationPreview.cpp23
-rw-r--r--dash/previews/CMakeLists.txt6
-rw-r--r--dash/previews/GenericPreview.cpp13
-rw-r--r--dash/previews/MoviePreview.cpp13
-rw-r--r--dash/previews/MusicPreview.cpp10
-rw-r--r--dash/previews/PreviewContainer.cpp44
-rw-r--r--dash/previews/PreviewContainer.h2
-rw-r--r--dash/previews/PreviewInfoHintWidget.cpp5
-rw-r--r--dash/previews/PreviewRatingsWidget.cpp2
-rw-r--r--dash/previews/Track.cpp42
-rw-r--r--dash/previews/Track.h1
17 files changed, 227 insertions, 181 deletions
diff --git a/dash/DashController.cpp b/dash/DashController.cpp
index 008e76ba4..a419bb7f6 100644
--- a/dash/DashController.cpp
+++ b/dash/DashController.cpp
@@ -20,6 +20,7 @@
#include <NuxCore/Logger.h>
#include <Nux/HLayout.h>
+#include <UnityCore/GLibWrapper.h>
#include "unity-shared/UnitySettings.h"
#include "unity-shared/PanelStyle.h"
@@ -38,8 +39,22 @@ namespace
{
nux::logging::Logger logger("unity.dash.controller");
const unsigned int PRELOAD_TIMEOUT_LENGTH = 40;
+
+const std::string DBUS_PATH = "/com/canonical/Unity/Dash";
+const std::string DBUS_INTROSPECTION =\
+ "<node>"
+ " <interface name='com.canonical.Unity.Dash'>"
+ ""
+ " <method name='HideDash'>"
+ " </method>"
+ ""
+ " </interface>"
+ "</node>";
}
+GDBusInterfaceVTable Controller::interface_vtable =
+ { Controller::OnDBusMethodCall, NULL, NULL};
+
Controller::Controller()
: launcher_width(64)
, use_primary(false)
@@ -49,6 +64,7 @@ Controller::Controller()
, view_(nullptr)
, ensure_timeout_(PRELOAD_TIMEOUT_LENGTH)
, timeline_animator_(90)
+ , dbus_connect_cancellable_(g_cancellable_new())
{
SetupRelayoutCallbacks();
RegisterUBusInterests();
@@ -70,6 +86,13 @@ Controller::Controller()
auto spread_cb = sigc::bind(sigc::mem_fun(this, &Controller::HideDash), true);
PluginAdapter::Default()->initiate_spread.connect(spread_cb);
+
+ g_bus_get (G_BUS_TYPE_SESSION, dbus_connect_cancellable_, OnBusAcquired, this);
+}
+
+Controller::~Controller()
+{
+ g_cancellable_cancel(dbus_connect_cancellable_);
}
void Controller::SetupWindow()
@@ -171,7 +194,9 @@ int Controller::GetIdealMonitor()
{
UScreen *uscreen = UScreen::GetDefault();
int primary_monitor;
- if (use_primary)
+ if (window_->IsVisible())
+ primary_monitor = monitor_;
+ else if (use_primary)
primary_monitor = uscreen->GetPrimaryMonitor();
else
primary_monitor = uscreen->GetMonitorWithMouse();
@@ -259,10 +284,12 @@ void Controller::ShowDash()
return;
}
+ /* GetIdealMonitor must get called before visible_ is set */
+ monitor_ = GetIdealMonitor();
+
// The launcher must receive UBUS_OVERLAY_SHOW before window_->EnableInputWindow().
// Other wise the Launcher gets focus for X, which causes XIM to fail.
sources_.AddIdle([this] {
- monitor_ = GetIdealMonitor();
GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_);
ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info);
return false;
@@ -369,9 +396,57 @@ std::string Controller::GetName() const
void Controller::AddProperties(GVariantBuilder* builder)
{
variant::BuilderWrapper(builder).add("visible", visible_)
+ .add("ideal_monitor", GetIdealMonitor())
.add("monitor", monitor_);
}
+void Controller::OnBusAcquired(GObject *obj, GAsyncResult *result, gpointer user_data)
+{
+ glib::Error error;
+ glib::Object<GDBusConnection> connection(g_bus_get_finish (result, &error));
+
+ if (!connection || error)
+ {
+ LOG_WARNING(logger) << "Failed to connect to DBus:" << error;
+ }
+ else
+ {
+ GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTROSPECTION.c_str(), nullptr);
+ unsigned int reg_id;
+
+ if (!introspection_data)
+ {
+ LOG_WARNING(logger) << "No introspection data loaded.";
+ return;
+ }
+
+ reg_id = g_dbus_connection_register_object(connection, DBUS_PATH.c_str(),
+ introspection_data->interfaces[0],
+ &interface_vtable, user_data,
+ nullptr, nullptr);
+ if (!reg_id)
+ {
+ LOG_WARNING(logger) << "Object registration failed. Dash DBus interface not available.";
+ }
+
+ g_dbus_node_info_unref(introspection_data);
+ }
+}
+
+void Controller::OnDBusMethodCall(GDBusConnection* connection, const gchar* sender,
+ const gchar* object_path, const gchar* interface_name,
+ const gchar* method_name, GVariant* parameters,
+ GDBusMethodInvocation* invocation, gpointer user_data)
+{
+ if (g_strcmp0(method_name, "HideDash") == 0)
+ {
+ auto self = static_cast<Controller*>(user_data);
+ self->HideDash();
+ g_dbus_method_invocation_return_value(invocation, nullptr);
+ }
+}
+
+
}
}
diff --git a/dash/DashController.h b/dash/DashController.h
index a03745782..e3e210c1a 100644
--- a/dash/DashController.h
+++ b/dash/DashController.h
@@ -45,6 +45,7 @@ public:
typedef std::shared_ptr<Controller> Ptr;
Controller();
+ ~Controller();
nux::BaseWindow* window() const;
@@ -84,6 +85,12 @@ private:
void StartShowHideTimeline();
void OnViewShowHideFrame(double progress);
+ static void OnBusAcquired(GObject *obj, GAsyncResult *result, gpointer user_data);
+ static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender,
+ const gchar* object_path, const gchar* interface_name,
+ const gchar* method_name, GVariant* parameters,
+ GDBusMethodInvocation* invocation, gpointer user_data);
+
static void OnWindowConfigure(int width, int height, nux::Geometry& geo, void* data);
private:
@@ -100,6 +107,9 @@ private:
glib::SourceManager sources_;
Animator timeline_animator_;
UBusManager ubus_manager_;
+ unsigned int dbus_owner_;
+ glib::Object<GCancellable> dbus_connect_cancellable_;
+ static GDBusInterfaceVTable interface_vtable;
};
diff --git a/dash/DashView.cpp b/dash/DashView.cpp
index fb6bde6dd..171d61368 100644
--- a/dash/DashView.cpp
+++ b/dash/DashView.cpp
@@ -247,6 +247,12 @@ void DashView::AboutToHide()
home_lens_->view_type = ViewType::HIDDEN;
LOG_DEBUG(logger) << "Setting ViewType " << ViewType::HIDDEN
<< " on '" << home_lens_->id() << "'";
+
+ // if a preview is open, close it
+ if (preview_displaying_)
+ {
+ ClosePreview();
+ }
}
void DashView::SetupViews()
@@ -401,22 +407,22 @@ void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw)
if (IsFullRedraw())
nux::GetPainter().PushBackgroundStack();
-
+
if (preview_displaying_)
preview_container_->ProcessDraw(gfx_context, (!force_draw) ? IsFullRedraw() : force_draw);
else
layout_->ProcessDraw(gfx_context, force_draw);
-
+
if (IsFullRedraw())
nux::GetPainter().PopBackgroundStack();
renderer_.DrawInnerCleanup(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry());
}
- void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
- {
- dash::Style& style = dash::Style::Instance();
- nux::Geometry geo(content_geo_);
+void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
+{
+ dash::Style& style = dash::Style::Instance();
+ nux::Geometry geo(content_geo_);
if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP)
{
diff --git a/dash/LensView.cpp b/dash/LensView.cpp
index 38dbedf63..2e8ab0903 100755
--- a/dash/LensView.cpp
+++ b/dash/LensView.cpp
@@ -45,8 +45,6 @@ nux::logging::Logger logger("unity.dash.lensview");
const int CARD_VIEW_GAP_VERT = 24; // pixels
const int CARD_VIEW_GAP_HORIZ = 25; // pixels
-
-const unsigned CATEGORY_COLUMN = 2;
}
// This is so we can access some protected members in scrollview.
@@ -136,6 +134,7 @@ LensView::LensView(Lens::Ptr lens, nux::Area* show_filters)
, lens_(lens)
, initial_activation_(true)
, no_results_active_(false)
+ , last_expanded_group_(nullptr)
, last_good_filter_model_(-1)
{
SetupViews(show_filters);
@@ -247,11 +246,8 @@ void LensView::SetupResults()
{
for (unsigned int i = 0; i < categories_.size(); ++i)
{
- PlacesGroup* group = categories_[i];
- ResultViewGrid* grid = static_cast<ResultViewGrid*>(group->GetChildView());
- DeeFilter filter;
- GetFilterForCategoryIndex(i, &filter);
- glib::Object<DeeModel> filter_model(dee_filter_model_new(model, &filter));
+ ResultViewGrid* grid = GetGridForCategory(i);
+ glib::Object<DeeModel> filter_model(lens_->GetFilterModelForCategory(i));
Results::Ptr results_model = lens_->results;
grid->SetModel(filter_model, results_model->GetTag());
}
@@ -309,7 +305,7 @@ void LensView::OnCategoryAdded(Category const& category)
counts_[group] = 0;
ResultView* grid;
-
+
if (renderer_name == "tile-horizontal")
{
grid = new ResultViewGrid(NUX_TRACKER_LOCATION);
@@ -317,12 +313,12 @@ void LensView::OnCategoryAdded(Category const& category)
static_cast<ResultViewGrid*> (grid)->horizontal_spacing = CARD_VIEW_GAP_HORIZ;
static_cast<ResultViewGrid*> (grid)->vertical_spacing = CARD_VIEW_GAP_VERT;
}
- else if (renderer_name == "flow")
+ else if (renderer_name == "flow" && nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath())
{
grid = new CoverflowResultView(NUX_TRACKER_LOCATION);
grid->SetModelRenderer(new ResultRendererTile(NUX_TRACKER_LOCATION));
group->SetHeaderCountVisible(false);
- }
+ }
else
{
grid = new ResultViewGrid(NUX_TRACKER_LOCATION);
@@ -359,9 +355,7 @@ void LensView::OnCategoryAdded(Category const& category)
Results::Ptr results_model = lens_->results;
if (results_model->model())
{
- DeeFilter filter;
- GetFilterForCategoryIndex(index, &filter);
- glib::Object<DeeModel> filter_model(dee_filter_model_new(results_model->model(), &filter));
+ glib::Object<DeeModel> filter_model(lens_->GetFilterModelForCategory(index));
grid->SetModel(filter_model, results_model->GetTag());
}
@@ -421,62 +415,13 @@ void LensView::OnCategoryOrderChanged()
}
}
-static void category_filter_map_func (DeeModel* orig_model,
- DeeFilterModel* filter_model,
- gpointer user_data)
-{
- DeeModelIter* iter;
- DeeModelIter* end;
- unsigned index = GPOINTER_TO_UINT(user_data);
-
- iter = dee_model_get_first_iter(orig_model);
- end = dee_model_get_last_iter(orig_model);
- while (iter != end)
- {
- unsigned category_index = dee_model_get_uint32(orig_model, iter,
- CATEGORY_COLUMN);
- if (index == category_index)
- {
- dee_filter_model_append_iter(filter_model, iter);
- }
- iter = dee_model_next(orig_model, iter);
- }
-}
-
-static gboolean category_filter_notify_func (DeeModel* orig_model,
- DeeModelIter* orig_iter,
- DeeFilterModel* filter_model,
- gpointer user_data)
-{
- unsigned index = GPOINTER_TO_UINT(user_data);
- unsigned category_index = dee_model_get_uint32(orig_model, orig_iter,
- CATEGORY_COLUMN);
-
- if (index != category_index)
- return FALSE;
-
- dee_filter_model_insert_iter_with_original_order(filter_model, orig_iter);
- return TRUE;
-}
-
-void LensView::GetFilterForCategoryIndex(unsigned index, DeeFilter* filter)
-{
- filter->map_func = category_filter_map_func;
- filter->map_notify = category_filter_notify_func;
- filter->destroy = nullptr;
- filter->userdata = GUINT_TO_POINTER(index);
-}
-
bool LensView::ReinitializeFilterModels()
{
Results::Ptr results_model = lens_->results;
for (unsigned i = last_good_filter_model_ + 1; i < categories_.size(); ++i)
{
- PlacesGroup* group = categories_[i];
- ResultViewGrid* grid = static_cast<ResultViewGrid*>(group->GetChildView());
- DeeFilter filter;
- GetFilterForCategoryIndex(i, &filter);
- glib::Object<DeeModel> filter_model(dee_filter_model_new(results_model->model(), &filter));
+ ResultViewGrid* grid = GetGridForCategory(i);
+ glib::Object<DeeModel> filter_model(lens_->GetFilterModelForCategory(i));
grid->SetModel(filter_model, results_model->GetTag());
}
@@ -485,6 +430,13 @@ bool LensView::ReinitializeFilterModels()
return false;
}
+ResultViewGrid* LensView::GetGridForCategory(unsigned category_index)
+{
+ if (category_index >= categories_.size()) return nullptr;
+ PlacesGroup* group = categories_.at(category_index);
+ return static_cast<ResultViewGrid*>(group->GetChildView());
+}
+
void LensView::OnResultAdded(Result const& result)
{
try {
@@ -500,6 +452,10 @@ void LensView::OnResultAdded(Result const& result)
{
CheckNoResults(Lens::Hints());
}
+
+ // Check if all results so far are from one category
+ // If so, then expand that category.
+ CheckCategoryExpansion();
} catch (std::out_of_range& oor) {
LOG_WARN(logger) << "Result does not have a valid category index: "
<< boost::lexical_cast<unsigned int>(result.category_index)
@@ -602,6 +558,33 @@ void LensView::CheckNoResults(Lens::Hints const& hints)
}
}
+void LensView::CheckCategoryExpansion()
+{
+ int number_of_displayed_categories = 0;
+
+ // Check if we had expanded a group in last run
+ // If so, collapse it for now
+ if (last_expanded_group_ != nullptr)
+ {
+ last_expanded_group_->SetExpanded(false);
+ last_expanded_group_ = nullptr;
+ }
+
+ // Cycle through all categories
+ for (auto category : categories_)
+ {
+ if (counts_[category] > 0) {
+ number_of_displayed_categories++;
+ last_expanded_group_ = category;
+ }
+ }
+
+ if (number_of_displayed_categories == 1 && last_expanded_group_ != nullptr)
+ last_expanded_group_->SetExpanded(true);
+ else
+ last_expanded_group_ = nullptr;
+}
+
void LensView::HideResultsMessage()
{
if (no_results_active_)
@@ -723,18 +706,20 @@ void LensView::ActivateFirst()
Results::Ptr results = lens_->results;
if (results->count())
{
- // FIXME: Linear search in the result model, use category grid's model!
- for (unsigned int c = 0; c < scroll_layout_->GetChildren().size(); ++c)
+ // the first displayed category might not be categories_[0]
+ auto category_order = lens_->GetCategoriesOrder();
+ for (unsigned int i = 0; i < category_order.size(); i++)
{
- for (unsigned int i = 0; i < results->count(); ++i)
+ unsigned cat_index = category_order.at(i);
+ ResultViewGrid* grid = GetGridForCategory(cat_index);
+ if (grid == nullptr) continue;
+ auto it = grid->GetIteratorAtRow(0);
+ if (!it.IsLast())
{
- Result result = results->RowAtIndex(i);
- if (result.category_index == c && result.uri != "")
- {
- uri_activated(result.uri);
- lens_->Activate(result.uri);
- return;
- }
+ Result result(*it);
+ uri_activated(result.uri);
+ lens_->Activate(result.uri);
+ return;
}
}
// Fallback
diff --git a/dash/LensView.h b/dash/LensView.h
index 87f051138..7dbe940d4 100644
--- a/dash/LensView.h
+++ b/dash/LensView.h
@@ -73,6 +73,7 @@ public:
void PerformSearch(std::string const& search_query);
void CheckNoResults(Lens::Hints const& hints);
+ void CheckCategoryExpansion();
void HideResultsMessage();
private:
@@ -94,8 +95,7 @@ private:
void QueueFixRenderering();
bool FixRenderering();
bool ReinitializeFilterModels();
-
- static void GetFilterForCategoryIndex(unsigned index, DeeFilter* filter);
+ ResultViewGrid* GetGridForCategory(unsigned category_index);
void BuildPreview(std::string const& uri, Preview::Ptr model);
@@ -114,6 +114,7 @@ private:
bool initial_activation_;
bool no_results_active_;
std::string search_string_;
+ PlacesGroup* last_expanded_group_;
nux::HLayout* layout_;
LensScrollView* scroll_view_;
diff --git a/dash/previews/ActionButton.cpp b/dash/previews/ActionButton.cpp
index 41f95b45b..72f6d793e 100644
--- a/dash/previews/ActionButton.cpp
+++ b/dash/previews/ActionButton.cpp
@@ -139,7 +139,7 @@ void ActionButton::BuildLayout(std::string const& label, std::string const& icon
if (!label_.empty())
{
- static_text_ = new nux::StaticCairoText(label_, NUX_TRACKER_LOCATION);
+ static_text_ = new nux::StaticCairoText(label_, true, NUX_TRACKER_LOCATION);
if (!font_hint_.empty())
static_text_->SetFont(font_hint_);
static_text_->SetInputEventSensitivity(false);
diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp
index fb6aff2d4..79841fe15 100644
--- a/dash/previews/ApplicationPreview.cpp
+++ b/dash/previews/ApplicationPreview.cpp
@@ -135,11 +135,7 @@ void ApplicationPreview::AddProperties(GVariantBuilder* builder)
void ApplicationPreview::SetupBackground()
{
- nux::ROPConfig rop;
- rop.Blend = true;
- rop.SrcBlend = GL_ONE;
- rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
- details_bg_layer_.reset(new nux::ColorLayer(nux::Color(0.03f, 0.03f, 0.03f, 0.0f), true, rop));
+ details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer());
}
void ApplicationPreview::SetupViews()
@@ -202,14 +198,14 @@ void ApplicationPreview::SetupViews()
title_subtitle_layout_ = new nux::VLayout();
title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
- title_ = new nux::StaticCairoText(app_preview_model->title);
+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
title_->SetLines(-1);
title_->SetFont(style.title_font().c_str());
title_subtitle_layout_->AddView(title_.GetPointer(), 1);
- if (!app_preview_model->subtitle.Get().empty())
+ if (!preview_model_->subtitle.Get().empty())
{
- subtitle_ = new nux::StaticCairoText(app_preview_model->subtitle);
+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
subtitle_->SetFont(style.subtitle_size_font().c_str());
subtitle_->SetLines(-1);
title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);
@@ -220,7 +216,7 @@ void ApplicationPreview::SetupViews()
if (!app_preview_model->license.Get().empty())
{
- license_ = new nux::StaticCairoText(app_preview_model->license);
+ license_ = new nux::StaticCairoText(app_preview_model->license, true, NUX_TRACKER_LOCATION);
license_->SetFont(style.app_license_font().c_str());
license_->SetLines(-1);
app_updated_copywrite_layout->AddView(license_.GetPointer(), 1);
@@ -231,14 +227,14 @@ void ApplicationPreview::SetupViews()
std::stringstream last_update;
last_update << _("Last Updated") << " " << app_preview_model->last_update.Get();
- last_update_ = new nux::StaticCairoText(last_update.str());
+ last_update_ = new nux::StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION);
last_update_->SetFont(style.app_last_update_font().c_str());
app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1);
}
if (!app_preview_model->copyright.Get().empty())
{
- copywrite_ = new nux::StaticCairoText(app_preview_model->copyright);
+ copywrite_ = new nux::StaticCairoText(app_preview_model->copyright, true, NUX_TRACKER_LOCATION);
copywrite_->SetFont(style.app_copywrite_font().c_str());
copywrite_->SetLines(-1);
app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1);
@@ -265,12 +261,11 @@ void ApplicationPreview::SetupViews()
if (!preview_model_->description.Get().empty())
{
- description_ = new nux::StaticCairoText("");
+ description_ = new nux::StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
description_->SetFont(style.description_font().c_str());
description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
description_->SetLines(-style.GetDescriptionLineCount());
description_->SetLineSpacing(style.GetDescriptionLineSpacing());
- description_->SetText(app_preview_model->description);
app_info_layout->AddView(description_.GetPointer());
}
@@ -314,7 +309,7 @@ void ApplicationPreview::PreLayoutManagement()
image_->SetMinMaxSize(geo_art.width, geo_art.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();
+ int top_app_info_max_width = MAX(0, details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails());
if (title_) { title_->SetMaximumWidth(top_app_info_max_width); }
if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); }
diff --git a/dash/previews/CMakeLists.txt b/dash/previews/CMakeLists.txt
index 2ccb845dd..15d47bfe8 100644
--- a/dash/previews/CMakeLists.txt
+++ b/dash/previews/CMakeLists.txt
@@ -10,13 +10,13 @@ set (CFLAGS
"-I${CMAKE_CURRENT_BINARY_DIR}"
)
-if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
set (CFLAGS ${CFLAGS} "-fPIC")
-endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
add_definitions (${CFLAGS})
-set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} "-lunity-core-${UNITY_API_VERSION} -lm -lGL -lGLU")
+set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} ${UNITY_STANDALONE_LADD})
link_libraries (${LIBS})
set (LIB_PATHS ${CACHED_UNITY_DEPS_LIBRARY_DIRS})
diff --git a/dash/previews/GenericPreview.cpp b/dash/previews/GenericPreview.cpp
index d7d7c892c..b48ba6c13 100644
--- a/dash/previews/GenericPreview.cpp
+++ b/dash/previews/GenericPreview.cpp
@@ -130,11 +130,7 @@ void GenericPreview::AddProperties(GVariantBuilder* builder)
void GenericPreview::SetupBackground()
{
- nux::ROPConfig rop;
- rop.Blend = true;
- rop.SrcBlend = GL_ONE;
- rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
- details_bg_layer_.reset(new nux::ColorLayer(nux::Color(0.03f, 0.03f, 0.03f, 0.0f), true, rop));
+ details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer());
}
void GenericPreview::SetupViews()
@@ -168,14 +164,14 @@ void GenericPreview::SetupViews()
nux::VLayout* preview_data_layout = new nux::VLayout();
preview_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
- title_ = new nux::StaticCairoText(preview_model_->title);
+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
title_->SetLines(-1);
title_->SetFont(style.title_font().c_str());
preview_data_layout->AddView(title_.GetPointer(), 1);
if (!preview_model_->subtitle.Get().empty())
{
- subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
subtitle_->SetLines(-1);
subtitle_->SetFont(style.subtitle_size_font().c_str());
preview_data_layout->AddView(subtitle_.GetPointer(), 1);
@@ -193,12 +189,11 @@ void GenericPreview::SetupViews()
if (!preview_model_->description.Get().empty())
{
- description_ = new nux::StaticCairoText("");
+ description_ = new nux::StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
description_->SetFont(style.description_font().c_str());
description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
description_->SetLines(-style.GetDescriptionLineCount());
description_->SetLineSpacing(style.GetDescriptionLineSpacing());
- description_->SetText(preview_model_->description);
preview_info_layout->AddView(description_.GetPointer());
}
diff --git a/dash/previews/MoviePreview.cpp b/dash/previews/MoviePreview.cpp
index fff0cac8f..261bdc4a9 100644
--- a/dash/previews/MoviePreview.cpp
+++ b/dash/previews/MoviePreview.cpp
@@ -139,11 +139,7 @@ void MoviePreview::OnNavigateOut()
void MoviePreview::SetupBackground()
{
- nux::ROPConfig rop;
- rop.Blend = true;
- rop.SrcBlend = GL_ONE;
- rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
- details_bg_layer_.reset(new nux::ColorLayer(nux::Color(0.03f, 0.03f, 0.03f, 0.0f), true, rop));
+ details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer());
}
void MoviePreview::SetupView()
@@ -178,14 +174,14 @@ void MoviePreview::SetupView()
nux::VLayout* app_data_layout = new nux::VLayout();
app_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
- title_ = new nux::StaticCairoText(preview_model_->title);
+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
title_->SetLines(-1);
title_->SetFont(style.title_font().c_str());
app_data_layout->AddView(title_.GetPointer(), 1);
if (!preview_model_->subtitle.Get().empty())
{
- subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
subtitle_->SetLines(-1);
subtitle_->SetFont(style.subtitle_size_font().c_str());
app_data_layout->AddView(subtitle_.GetPointer(), 1);
@@ -217,12 +213,11 @@ void MoviePreview::SetupView()
if (!preview_model_->description.Get().empty())
{
- description_ = new nux::StaticCairoText("");
+ description_ = new nux::StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
description_->SetFont(style.description_font().c_str());
description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
description_->SetLines(-style.GetDescriptionLineCount());
description_->SetLineSpacing(style.GetDescriptionLineSpacing());
- description_->SetText(preview_model_->description);
preview_info_layout->AddView(description_.GetPointer());
}
/////////////////////
diff --git a/dash/previews/MusicPreview.cpp b/dash/previews/MusicPreview.cpp
index b86858f66..039b74152 100644
--- a/dash/previews/MusicPreview.cpp
+++ b/dash/previews/MusicPreview.cpp
@@ -122,11 +122,7 @@ void MusicPreview::AddProperties(GVariantBuilder* builder)
void MusicPreview::SetupBackground()
{
- nux::ROPConfig rop;
- rop.Blend = true;
- rop.SrcBlend = GL_ONE;
- rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
- details_bg_layer_.reset(new nux::ColorLayer(nux::Color(0.03f, 0.03f, 0.03f, 0.0f), true, rop));
+ details_bg_layer_.reset(dash::previews::Style::Instance().GetBackgroundLayer());
}
void MusicPreview::SetupViews()
@@ -160,14 +156,14 @@ void MusicPreview::SetupViews()
nux::VLayout* album_data_layout = new nux::VLayout();
album_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
- title_ = new nux::StaticCairoText(preview_model_->title);
+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
title_->SetFont(style.title_font().c_str());
title_->SetLines(-1);
album_data_layout->AddView(title_.GetPointer(), 1);
if (!preview_model_->subtitle.Get().empty())
{
- subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
subtitle_->SetFont(style.subtitle_size_font().c_str());
subtitle_->SetLines(-1);
album_data_layout->AddView(subtitle_.GetPointer(), 1);
diff --git a/dash/previews/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp
index 8a1ed6789..eabed9d20 100644
--- a/dash/previews/PreviewContainer.cpp
+++ b/dash/previews/PreviewContainer.cpp
@@ -159,9 +159,9 @@ public:
nux::Geometry swipeOut = geometry;
if (swipe_.direction == Navigation::RIGHT)
- swipeOut.OffsetPosition(-(curve_progress * (geometry.GetWidth() + parent_->nav_left_->GetGeometry().GetWidth())), 0);
+ swipeOut.OffsetPosition(-(curve_progress * (parent_->GetGeometry().width - geometry.x)), 0);
else if (swipe_.direction == Navigation::LEFT)
- swipeOut.OffsetPosition(curve_progress* (geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth()), 0);
+ swipeOut.OffsetPosition(curve_progress* (parent_->GetGeometry().width - geometry.x), 0);
current_preview_->SetGeometry(swipeOut);
}
@@ -172,9 +172,9 @@ public:
nux::Geometry swipeIn = geometry;
if (swipe_.direction == Navigation::RIGHT)
- swipeIn.OffsetPosition(float(geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth()) - (curve_progress * (geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth())), 0);
+ swipeIn.OffsetPosition(float(parent_->GetGeometry().width - geometry.x) - (curve_progress * (parent_->GetGeometry().width - geometry.x)), 0);
else if (swipe_.direction == Navigation::LEFT)
- swipeIn.OffsetPosition(-((1.0-curve_progress)*(geometry.GetWidth() + parent_->nav_left_->GetGeometry().GetWidth())), 0);
+ swipeIn.OffsetPosition(-((1.0-curve_progress)*(parent_->GetGeometry().width - geometry.x)), 0);
swipe_.preview->SetGeometry(swipeIn);
}
}
@@ -370,7 +370,6 @@ PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL)
: View(NUX_FILE_LINE_PARAM)
, content_layout_(nullptr)
, nav_disabled_(Navigation::NONE)
- , last_calc_height_(0)
, navigation_progress_speed_(0.0)
, navigation_count_(0)
{
@@ -426,7 +425,7 @@ void PreviewContainer::SetupViews()
layout_ = new nux::HLayout();
SetLayout(layout_);
- layout_->AddSpace(0, 0);
+ layout_->AddSpace(0, 1);
nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
AddChild(nav_left_);
@@ -436,8 +435,9 @@ void PreviewContainer::SetupViews()
layout_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
content_layout_ = new PreviewContent(this);
+ content_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight());
AddChild(content_layout_);
- layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
AddChild(nav_right_);
@@ -446,7 +446,7 @@ void PreviewContainer::SetupViews()
nav_right_->activated.connect([&]() { navigate_right.emit(); });
layout_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
- layout_->AddSpace(0, 0);
+ layout_->AddSpace(0, 1);
content_layout_->start_navigation.connect([&]()
{
@@ -512,32 +512,6 @@ void PreviewContainer::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_d
gfx_engine.PopClippingRectangle();
}
-void PreviewContainer::PreLayoutManagement()
-{
- previews::Style& style = previews::Style::Instance();
- nux::Geometry const& geo = GetGeometry();
-
- int available_preview_width = MAX(1, geo.width - nav_left_->GetGeometry().width - nav_right_->GetGeometry().width);
- int aspect_altered_height = available_preview_width / style.GetPreviewAspectRatio();
-
- aspect_altered_height = CLAMP(aspect_altered_height, 1, geo.height);
- if (last_calc_height_ != aspect_altered_height)
- {
- last_calc_height_ = aspect_altered_height;
-
- content_layout_->SetMinimumHeight(aspect_altered_height);
- content_layout_->SetMaximumHeight(aspect_altered_height);
-
- nav_left_->SetMinimumHeight(aspect_altered_height);
- nav_left_->SetMaximumHeight(aspect_altered_height);
-
- nav_right_->SetMinimumHeight(aspect_altered_height);
- nav_right_->SetMaximumHeight(aspect_altered_height);
- }
-
- View::PreLayoutManagement();
-}
-
bool PreviewContainer::AnimationInProgress()
{
// short circuit to avoid unneeded calculations
@@ -584,7 +558,7 @@ bool PreviewContainer::QueueAnimation()
last_progress_time_ = current;
QueueDraw();
- return true;
+ return false;
}
bool PreviewContainer::AcceptKeyNavFocus()
diff --git a/dash/previews/PreviewContainer.h b/dash/previews/PreviewContainer.h
index 6e790295f..78b19750e 100644
--- a/dash/previews/PreviewContainer.h
+++ b/dash/previews/PreviewContainer.h
@@ -81,7 +81,6 @@ public:
protected:
void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
- void PreLayoutManagement();
bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
@@ -101,7 +100,6 @@ private:
PreviewNavigator* nav_right_;
PreviewContent* content_layout_;
Navigation nav_disabled_;
- int last_calc_height_;
// Animation
struct timespec last_progress_time_;
diff --git a/dash/previews/PreviewInfoHintWidget.cpp b/dash/previews/PreviewInfoHintWidget.cpp
index e6ad0f937..793b55e26 100644
--- a/dash/previews/PreviewInfoHintWidget.cpp
+++ b/dash/previews/PreviewInfoHintWidget.cpp
@@ -160,14 +160,14 @@ void PreviewInfoHintWidget::SetupViews()
std::string tmp_display_name = info_hint->display_name;
tmp_display_name += ":";
- info_name = new nux::StaticCairoText(tmp_display_name, NUX_TRACKER_LOCATION);
+ info_name = new nux::StaticCairoText(tmp_display_name, true, NUX_TRACKER_LOCATION);
info_name->SetFont(style.info_hint_bold_font());
info_name->SetLines(-1);
info_name->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_RIGHT);
hint_layout->AddView(info_name.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
}
- StaticCairoTextPtr info_value(new nux::StaticCairoText(StringFromVariant(info_hint->value), NUX_TRACKER_LOCATION));
+ StaticCairoTextPtr info_value(new nux::StaticCairoText(StringFromVariant(info_hint->value), true, NUX_TRACKER_LOCATION));
info_value->SetFont(style.info_hint_font());
info_value->SetLines(-1);
hint_layout->AddView(info_value.GetPointer(), 1, nux::MINOR_POSITION_CENTER);
@@ -210,6 +210,7 @@ void PreviewInfoHintWidget::PreLayoutManagement()
int info_value_width = geo.width;
info_value_width -= layout_spacing;
info_value_width -= info_hint_width;
+ info_value_width = MAX(0, info_value_width);
for (InfoHint const& info_hint : info_hints_)
{
diff --git a/dash/previews/PreviewRatingsWidget.cpp b/dash/previews/PreviewRatingsWidget.cpp
index 10d370d0b..42d5e78f5 100644
--- a/dash/previews/PreviewRatingsWidget.cpp
+++ b/dash/previews/PreviewRatingsWidget.cpp
@@ -52,7 +52,7 @@ PreviewRatingsWidget::PreviewRatingsWidget(NUX_FILE_LINE_DECL)
ratings_->SetEditable(false);
layout->AddView(ratings_);
- reviews_ = new nux::StaticCairoText("");
+ reviews_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
reviews_->SetFont(style.user_rating_font());
layout->AddView(reviews_);
diff --git a/dash/previews/Track.cpp b/dash/previews/Track.cpp
index c73cff9ab..3f8efffdd 100644
--- a/dash/previews/Track.cpp
+++ b/dash/previews/Track.cpp
@@ -159,7 +159,7 @@ void Track::Update(dash::Track const& track)
uri_ = track.uri;
progress_ = track.progress;
- title_->SetText(track.title);
+ title_->SetText(track.title, true);
std::stringstream ss_track_number;
ss_track_number << track.track_number;
@@ -194,19 +194,16 @@ void Track::SetupViews()
nux::BaseTexture* tex_play = style.GetPlayIcon();
IconTexture* status_play = new IconTexture(tex_play, style.GetStatusIconSize(), style.GetStatusIconSize());
status_play->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
- status_play->SetInputEventSensitivity(false);
nux::BaseTexture* tex_pause = style.GetPauseIcon();
IconTexture* status_pause = new IconTexture(tex_pause, style.GetStatusIconSize(), style.GetStatusIconSize());
status_pause->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
- status_pause->SetInputEventSensitivity(false);
track_number_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
track_number_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
track_number_->SetTextVerticalAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
track_number_->SetLines(-1);
track_number_->SetFont(style.track_font());
- track_number_->SetInputEventSensitivity(false);
title_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
title_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT);
@@ -229,26 +226,18 @@ void Track::SetupViews()
status_play_layout_->GetLayout()->AddSpace(0, 1);
status_play_layout_->GetLayout()->AddView(status_play, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
status_play_layout_->GetLayout()->AddSpace(0, 1);
- status_play_layout_->mouse_click.connect([&](int, int, unsigned long, unsigned long) { play.emit(uri_); });
- status_play_layout_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
- status_play_layout_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));
status_pause_layout_ = new TmpView();
status_pause_layout_->SetLayout(new nux::HLayout());
status_pause_layout_->GetLayout()->AddSpace(0, 1);
status_pause_layout_->GetLayout()->AddView(status_pause, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
status_pause_layout_->GetLayout()->AddSpace(0, 1);
- status_pause_layout_->mouse_click.connect([&](int, int, unsigned long, unsigned long) { pause.emit(uri_); });
- status_pause_layout_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
- status_pause_layout_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));
track_number_layout_ = new TmpView();
track_number_layout_->SetLayout(new nux::HLayout());
track_number_layout_->GetLayout()->AddSpace(0, 1);
track_number_layout_->GetLayout()->AddView(track_number_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
track_number_layout_->GetLayout()->AddSpace(0, 1);
- track_number_layout_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
- track_number_layout_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));
track_status_layout_ = new nux::LayeredLayout();
track_status_layout_->AddLayer(status_play_layout_, true);
@@ -265,11 +254,27 @@ 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);
SetLayout(layout);
+
+ mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
+ mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));
+ mouse_click.connect([&](int, int, unsigned long, unsigned long)
+ {
+ switch (play_state_)
+ {
+ case dash::PLAYING:
+ pause.emit(uri_);
+ break;
+ case dash::PAUSED:
+ case dash::STOPPED:
+ default:
+ play.emit(uri_);
+ break;
+ }
+ });
}
void Track::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
@@ -342,9 +347,18 @@ void Track::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
gfx_engine.PopClippingRectangle();
}
+nux::Area* Track::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
+{
+ bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
+ if (mouse_inside == false)
+ return NULL;
+
+ return this;
+}
+
bool Track::HasStatusFocus() const
{
- return play_state_ == dash::PLAYING || play_state_ == dash::PAUSED;
+ return mouse_over_ || play_state_ == dash::PLAYING || play_state_ == dash::PAUSED;
}
void Track::OnTrackControlMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
diff --git a/dash/previews/Track.h b/dash/previews/Track.h
index 0c177f0fe..b7873ce66 100644
--- a/dash/previews/Track.h
+++ b/dash/previews/Track.h
@@ -61,6 +61,7 @@ protected:
virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void PreLayoutManagement();
+ virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type);
// From debug::Introspectable
std::string GetName() const;