summaryrefslogtreecommitdiff
path: root/dash
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2015-12-11 12:45:21 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2015-12-11 12:45:21 +0000
commitb950f35d38f5a1411b1c08b44c37865a20a4a9e8 (patch)
tree7a4902e5f253a73abe7cf7c12d81bdc7dff9f130 /dash
parent5980b00247e16f9747979b6e49f84cee10aa4b37 (diff)
parent00a1741ca507716a3a0cf93e9567285158c99028 (diff)
Places(Overlay)VScrollBar: impelement gtk-like overlay scrollbars Fixes: #1481706
Approved by: PS Jenkins bot, Andrea Azzarone Original authors: - Marco Trevisan (Treviño) <mail@3v1n0.net> - Andrea Azzarone <andrea.azzarone@canonical.com> (bzr r4045)
Diffstat (limited to 'dash')
-rwxr-xr-xdash/PlacesGroup.cpp35
-rwxr-xr-xdash/ScopeView.cpp25
-rw-r--r--dash/ScopeView.h2
-rw-r--r--dash/StandaloneDash.cpp19
-rw-r--r--dash/pch/dash_pch.hh7
5 files changed, 44 insertions, 44 deletions
diff --git a/dash/PlacesGroup.cpp b/dash/PlacesGroup.cpp
index f0ba9087f..3aafc78f9 100755
--- a/dash/PlacesGroup.cpp
+++ b/dash/PlacesGroup.cpp
@@ -49,14 +49,13 @@ namespace dash
{
namespace
{
-
-const nux::Color kExpandDefaultTextColor(1.0f, 1.0f, 1.0f, 0.5f);
-const float kExpandDefaultIconOpacity = 0.5f;
+const nux::Color EXPAND_DEFAULT_TEXT_COLOR(1.0f, 1.0f, 1.0f, 0.5f);
+const float EXPAND_DEFAULT_ICON_OPACITY = 0.5f;
// Category highlight
-const RawPixel kHighlightRightPadding = 7_em; // FIXME 10 - 3 because the scrollbar is not a real overlay scrollbar!
-const RawPixel kHighlightHeight = 24_em;
-const RawPixel kHighlightLeftPadding = 10_em;
+const RawPixel HIGHLIGHT_RIGHT_PADDING = 10_em;
+const RawPixel HIGHLIGHT_HEIGHT = 24_em;
+const RawPixel HIGHLIGHT_LEFT_PADDING = 10_em;
const RawPixel SPACE_BETWEEN_CHILDREN = 10_em;
const RawPixel TEXT_INTERNAL_MARGIN = 15_em;
const RawPixel EXPAND_INTERNAL_MARGIN = 8_em;
@@ -65,7 +64,6 @@ const double DEFAULT_SCALE = 1.0;
// Font
const char* const NAME_LABEL_FONT = "Ubuntu 13"; // 17px = 13
const char* const EXPANDER_LABEL_FONT = "Ubuntu 10"; // 13px = 10
-
}
class HeaderView : public nux::View
@@ -184,12 +182,12 @@ PlacesGroup::PlacesGroup(dash::StyleInterface& style)
_expand_label->SetLines(-1);
_expand_label->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);
_expand_label->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
- _expand_label->SetTextColor(kExpandDefaultTextColor);
+ _expand_label->SetTextColor(EXPAND_DEFAULT_TEXT_COLOR);
_expand_label_layout->AddView(_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
_expand_icon = new IconTexture(_style.GetGroupExpandIcon());
_expand_icon->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
- _expand_icon->SetOpacity(kExpandDefaultIconOpacity);
+ _expand_icon->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY);
_expand_icon->SetVisible(false);
_expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
@@ -466,9 +464,9 @@ long PlacesGroup::ComputeContentSize()
if (_cached_geometry.GetWidth() != geo.GetWidth())
{
_focus_layer.reset(_style.FocusOverlay(geo.width -
- kHighlightLeftPadding.CP(scale()) -
- kHighlightRightPadding.CP(scale()),
- kHighlightHeight.CP(scale())));
+ HIGHLIGHT_LEFT_PADDING.CP(scale()) -
+ HIGHLIGHT_RIGHT_PADDING.CP(scale()),
+ HIGHLIGHT_HEIGHT.CP(scale())));
_cached_geometry = geo;
}
return ret;
@@ -487,10 +485,10 @@ void PlacesGroup::Draw(nux::GraphicsEngine& graphics_engine,
{
nux::Geometry geo(_header_layout->GetGeometry());
geo.width = base.width -
- kHighlightRightPadding.CP(scale()) -
- kHighlightLeftPadding.CP(scale());
+ HIGHLIGHT_RIGHT_PADDING.CP(scale()) -
+ HIGHLIGHT_LEFT_PADDING.CP(scale());
- geo.x += kHighlightLeftPadding.CP(scale());
+ geo.x += HIGHLIGHT_LEFT_PADDING.CP(scale());
_focus_layer->SetGeometry(geo);
_focus_layer->Renderlayer(graphics_engine);
@@ -500,9 +498,10 @@ void PlacesGroup::Draw(nux::GraphicsEngine& graphics_engine,
{
nux::Geometry bg_geo = base;
int bg_width = _background_layer->GetDeviceTexture()->GetWidth();
- bg_geo.x = std::max(bg_geo.width - bg_width,0);
-
- bg_geo.width = std::min(bg_width, bg_geo.GetWidth()) + 1; // to render into a space left over by the scrollview
+ bg_geo.x = std::max(bg_geo.width - bg_width, 0);
+
+ // to render into a space left over by the scrollview (1 has NOT to be scaled)
+ bg_geo.width = std::min(bg_width, bg_geo.GetWidth()) + 1;
bg_geo.height = _background->GetHeight();
_background_layer->SetGeometry(bg_geo);
diff --git a/dash/ScopeView.cpp b/dash/ScopeView.cpp
index 5a0610b87..1f4fb2c00 100755
--- a/dash/ScopeView.cpp
+++ b/dash/ScopeView.cpp
@@ -105,22 +105,14 @@ public:
up_area_ = area;
}
- void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
+ void EnableScrolling(bool enable_scrolling)
{
- if (RedirectedAncestor())
- {
- if (m_horizontal_scrollbar_enable && _hscrollbar->IsRedrawNeeded())
- graphics::ClearGeometry(_hscrollbar->GetGeometry());
- if (m_vertical_scrollbar_enable && _vscrollbar->IsRedrawNeeded())
- graphics::ClearGeometry(_vscrollbar->GetGeometry());
- }
-
- ScrollView::DrawContent(graphics_engine, force_draw);
+ _vscrollbar->SetInputEventSensitivity(enable_scrolling);
}
- void EnableScrolling(bool enable_scrolling)
+ nux::VScrollBar* GetScrollbar() const
{
- _vscrollbar->SetInputEventSensitivity(enable_scrolling);
+ return _vscrollbar;
}
protected:
@@ -161,7 +153,7 @@ ScopeView::ScopeView(Scope::Ptr const& scope, nux::Area* show_filters)
{
SetupViews(show_filters);
- search_string.SetGetterFunction(sigc::mem_fun(this, &ScopeView::get_search_string));
+ search_string.SetGetterFunction([this] { return search_string_; });
filters_expanded.changed.connect(sigc::mem_fun(this, &ScopeView::OnScopeFilterExpanded));
view_type.changed.connect(sigc::mem_fun(this, &ScopeView::OnViewTypeChanged));
scale.changed.connect(sigc::mem_fun(this, &ScopeView::UpdateScale));
@@ -243,6 +235,7 @@ void ScopeView::SetupViews(nux::Area* show_filters)
scroll_layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
scroll_view_->SetLayout(scroll_layout_);
scroll_view_->SetRightArea(show_filters);
+ scroll_view_->GetScrollbar()->queue_draw.connect(sigc::hide(sigc::mem_fun(scroll_layout_, &nux::VLayout::QueueDraw)));
no_results_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
no_results_->SetTextColor(nux::color::White);
@@ -260,6 +253,7 @@ void ScopeView::SetupViews(nux::Area* show_filters)
fscroll_layout_ = new nux::VLayout();
fscroll_view_->SetLayout(fscroll_layout_);
+ fscroll_view_->GetScrollbar()->queue_draw.connect(sigc::hide(sigc::mem_fun(fscroll_layout_, &nux::VLayout::QueueDraw)));
filter_bar_ = new FilterBar();
@@ -876,11 +870,6 @@ bool ScopeView::PerformSearch(std::string const& search_query, SearchCallback co
return false;
}
-std::string ScopeView::get_search_string() const
-{
- return search_string_;
-}
-
void ScopeView::OnGroupExpanded(PlacesGroup* group)
{
ResultViewGrid* grid = static_cast<ResultViewGrid*>(group->GetChildView());
diff --git a/dash/ScopeView.h b/dash/ScopeView.h
index 9ccccf8c2..4588e5b15 100644
--- a/dash/ScopeView.h
+++ b/dash/ScopeView.h
@@ -143,8 +143,6 @@ private:
void OnCompositorKeyNavFocusChanged(nux::Area*, bool, nux::KeyNavDirection);
- std::string get_search_string() const;
-
CategoryGroups category_views_;
Scope::Ptr scope_;
diff --git a/dash/StandaloneDash.cpp b/dash/StandaloneDash.cpp
index 68c9a7e02..81b0a6aa1 100644
--- a/dash/StandaloneDash.cpp
+++ b/dash/StandaloneDash.cpp
@@ -37,7 +37,7 @@
#include "unity-shared/PanelStyle.h"
#include "unity-shared/ThumbnailGenerator.h"
#include "unity-shared/UBusMessages.h"
-#include "unity-shared/UBusServer.h"
+#include "unity-shared/UBusWrapper.h"
#include <UnityCore/GSettingsScopes.h>
#include <UnityCore/ScopeProxyInterface.h>
@@ -50,12 +50,13 @@ class TestRunner
{
public:
TestRunner(std::string const& scope, double scale)
- : scope_(scope)
+ : scope_(scope.empty() ? "home.scope" : scope)
, scale_(scale)
{}
- static void InitWindowThread (nux::NThread* thread, void* InitData);
- void Init ();
+ static void InitWindowThread(nux::NThread* thread, void* InitData);
+ void Init();
+
std::string scope_;
double scale_;
nux::Layout *layout;
@@ -78,14 +79,14 @@ void TestRunner::Init ()
nux::GetWindowThread()->SetLayout (layout);
nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());
- unity::UBusServer().SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
+ unity::UBusManager::SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
g_variant_new("(sus)", scope_.c_str(), GOTO_DASH_URI, ""));
}
void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
{
TestRunner *self = (TestRunner *) InitData;
- self->Init ();
+ self->Init();
}
int main(int argc, char **argv)
@@ -124,6 +125,12 @@ int main(int argc, char **argv)
WIDTH.CP(scale), HEIGHT.CP(scale),
0, &TestRunner::InitWindowThread, test_runner));
+ nux::ObjectPtr<nux::BaseTexture> background_tex;
+ background_tex.Adopt(nux::CreateTextureFromFile("/usr/share/backgrounds/warty-final-ubuntu.png"));
+ nux::TexCoordXForm texxform;
+ auto tex_layer = std::make_shared<nux::TextureLayer>(background_tex->GetDeviceTexture(), texxform, nux::color::White);
+ wt->SetWindowBackgroundPaintLayer(tex_layer.get());
+
nux::NuxTimerTickSource tick_source;
nux::animation::AnimationController animation_controller(tick_source);
wt->Run(nullptr);
diff --git a/dash/pch/dash_pch.hh b/dash/pch/dash_pch.hh
index 8e582fc74..1e148971b 100644
--- a/dash/pch/dash_pch.hh
+++ b/dash/pch/dash_pch.hh
@@ -27,3 +27,10 @@
#include <memory>
#include <Nux/Nux.h>
+
+#include <UnityCore/ModelRowAdaptor.h>
+#include <UnityCore/Model.h>
+#include <UnityCore/Category.h>
+#include <UnityCore/Categories.h>
+#include <UnityCore/Result.h>
+#include <UnityCore/Results.h>