Merge lp:~sil2100/unity/fix-1053047-6.0 into lp:unity/6.0

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2770
Proposed branch: lp:~sil2100/unity/fix-1053047-6.0
Merge into: lp:unity/6.0
Diff against target: 328 lines (+178/-16)
7 files modified
dash/LensView.cpp (+1/-1)
dash/PlacesGroup.cpp (+9/-13)
dash/PlacesGroup.h (+4/-1)
tests/CMakeLists.txt (+5/-0)
tests/test_places_group.cpp (+103/-0)
unity-shared/DashStyle.h (+3/-1)
unity-shared/DashStyleInterface.h (+53/-0)
To merge this branch: bzr merge lp:~sil2100/unity/fix-1053047-6.0
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+128540@code.launchpad.net

Commit message

Cherry-picked from lp:unity rev 2812:
Use expand icon by default.

Description of the change

Cherry-picked andyrock's fix from trunk:

== Problem ==
Dash - Category expander arrow is in expanded mode no metter if category is actually expanded.

== Test ==
Unit test added.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/LensView.cpp'
--- dash/LensView.cpp 2012-10-03 11:59:50 +0000
+++ dash/LensView.cpp 2012-10-08 16:22:39 +0000
@@ -309,7 +309,7 @@
309 if (existing_group->GetCategoryIndex() == index) return;309 if (existing_group->GetCategoryIndex() == index) return;
310 }310 }
311311
312 PlacesGroup* group = new PlacesGroup();312 PlacesGroup* group = new PlacesGroup(dash::Style::Instance());
313 AddChild(group);313 AddChild(group);
314 group->SetName(name);314 group->SetName(name);
315 group->SetIcon(icon_hint);315 group->SetIcon(icon_hint);
316316
=== modified file 'dash/PlacesGroup.cpp'
--- dash/PlacesGroup.cpp 2012-09-18 11:55:33 +0000
+++ dash/PlacesGroup.cpp 2012-10-08 16:22:39 +0000
@@ -31,8 +31,6 @@
31#include <UnityCore/GLibWrapper.h>31#include <UnityCore/GLibWrapper.h>
3232
33#include "unity-shared/StaticCairoText.h"33#include "unity-shared/StaticCairoText.h"
34#include "unity-shared/DashStyle.h"
35#include "unity-shared/LineSeparator.h"
36#include "unity-shared/ubus-server.h"34#include "unity-shared/ubus-server.h"
37#include "unity-shared/UBusMessages.h"35#include "unity-shared/UBusMessages.h"
3836
@@ -112,8 +110,9 @@
112110
113NUX_IMPLEMENT_OBJECT_TYPE(PlacesGroup);111NUX_IMPLEMENT_OBJECT_TYPE(PlacesGroup);
114112
115PlacesGroup::PlacesGroup()113PlacesGroup::PlacesGroup(dash::StyleInterface& style)
116 : AbstractPlacesGroup(),114 : AbstractPlacesGroup(),
115 _style(style),
117 _child_view(nullptr),116 _child_view(nullptr),
118 _is_expanded(false),117 _is_expanded(false),
119 _n_visible_items_in_unexpand_mode(0),118 _n_visible_items_in_unexpand_mode(0),
@@ -122,15 +121,13 @@
122 _coverflow_enabled(false),121 _coverflow_enabled(false),
123 disabled_header_count_(false)122 disabled_header_count_(false)
124{123{
125 dash::Style& style = dash::Style::Instance();
126
127 SetAcceptKeyNavFocusOnMouseDown(false);124 SetAcceptKeyNavFocusOnMouseDown(false);
128 SetAcceptKeyNavFocusOnMouseEnter(false);125 SetAcceptKeyNavFocusOnMouseEnter(false);
129126
130 nux::BaseTexture* arrow = style.GetGroupUnexpandIcon();127 nux::BaseTexture* arrow = _style.GetGroupExpandIcon();
131 128
132 _background = style.GetCategoryBackground();129 _background = _style.GetCategoryBackground();
133 _background_nofilters = style.GetCategoryBackgroundNoFilters();130 _background_nofilters = _style.GetCategoryBackgroundNoFilters();
134131
135 nux::ROPConfig rop;132 nux::ROPConfig rop;
136 rop.Blend = true;133 rop.Blend = true;
@@ -154,7 +151,7 @@
154 _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL);151 _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL);
155152
156 _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);153 _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
157 _header_layout->SetLeftAndRightPadding(style.GetCategoryHeaderLeftPadding(), 0);154 _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding(), 0);
158 _header_layout->SetSpaceBetweenChildren(10);155 _header_layout->SetSpaceBetweenChildren(10);
159 _header_view->SetLayout(_header_layout);156 _header_view->SetLayout(_header_layout);
160157
@@ -449,7 +446,7 @@
449 // only the width matters446 // only the width matters
450 if (_cached_geometry.GetWidth() != geo.GetWidth())447 if (_cached_geometry.GetWidth() != geo.GetWidth())
451 {448 {
452 _focus_layer.reset(dash::Style::Instance().FocusOverlay(geo.width - kHighlightLeftPadding - kHighlightRightPadding, kHighlightHeight));449 _focus_layer.reset(_style.FocusOverlay(geo.width - kHighlightLeftPadding - kHighlightRightPadding, kHighlightHeight));
453 _cached_geometry = geo;450 _cached_geometry = geo;
454 }451 }
455 return ret;452 return ret;
@@ -557,11 +554,10 @@
557554
558 Refresh();555 Refresh();
559556
560 dash::Style& style = dash::Style::Instance();
561 if (_is_expanded)557 if (_is_expanded)
562 _expand_icon->SetTexture(style.GetGroupUnexpandIcon());558 _expand_icon->SetTexture(_style.GetGroupUnexpandIcon());
563 else559 else
564 _expand_icon->SetTexture(style.GetGroupExpandIcon());560 _expand_icon->SetTexture(_style.GetGroupExpandIcon());
565561
566 expanded.emit(this);562 expanded.emit(this);
567}563}
568564
=== modified file 'dash/PlacesGroup.h'
--- dash/PlacesGroup.h 2012-09-13 09:15:15 +0000
+++ dash/PlacesGroup.h 2012-10-08 16:22:39 +0000
@@ -27,6 +27,7 @@
2727
28#include <sigc++/sigc++.h>28#include <sigc++/sigc++.h>
2929
30#include "unity-shared/DashStyleInterface.h"
30#include "unity-shared/IconTexture.h"31#include "unity-shared/IconTexture.h"
31#include "unity-shared/Introspectable.h"32#include "unity-shared/Introspectable.h"
32#include "unity-shared/StaticCairoText.h"33#include "unity-shared/StaticCairoText.h"
@@ -54,7 +55,7 @@
54 NUX_DECLARE_OBJECT_TYPE(PlacesGroup, dash::AbstractPlacesGroup);55 NUX_DECLARE_OBJECT_TYPE(PlacesGroup, dash::AbstractPlacesGroup);
55public:56public:
5657
57 PlacesGroup();58 PlacesGroup(dash::StyleInterface& style);
5859
59 void SetIcon(std::string const& icon);60 void SetIcon(std::string const& icon);
60 void SetName(std::string const& name);61 void SetName(std::string const& name);
@@ -116,6 +117,8 @@
116 void RefreshLabel();117 void RefreshLabel();
117118
118private:119private:
120 dash::StyleInterface& _style;
121
119 nux::VLayout* _group_layout;122 nux::VLayout* _group_layout;
120 nux::View* _header_view;123 nux::View* _header_view;
121 nux::HLayout* _header_layout;124 nux::HLayout* _header_layout;
122125
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2012-10-01 15:12:05 +0000
+++ tests/CMakeLists.txt 2012-10-08 16:22:39 +0000
@@ -220,6 +220,7 @@
220 test_launcher_icon.cpp220 test_launcher_icon.cpp
221 test_keyboard_util.cpp221 test_keyboard_util.cpp
222 test_panel_style.cpp222 test_panel_style.cpp
223 test_places_group.cpp
223 test_previews_application.cpp224 test_previews_application.cpp
224 test_previews_generic.cpp225 test_previews_generic.cpp
225 test_previews_movie.cpp226 test_previews_movie.cpp
@@ -246,6 +247,10 @@
246 ${CMAKE_SOURCE_DIR}/dash/DashViewPrivate.cpp247 ${CMAKE_SOURCE_DIR}/dash/DashViewPrivate.cpp
247 ${CMAKE_SOURCE_DIR}/dash/LensViewPrivate.cpp248 ${CMAKE_SOURCE_DIR}/dash/LensViewPrivate.cpp
248 ${CMAKE_SOURCE_DIR}/dash/ResultRenderer.cpp249 ${CMAKE_SOURCE_DIR}/dash/ResultRenderer.cpp
250 ${CMAKE_SOURCE_DIR}/dash/PlacesGroup.cpp
251 ${CMAKE_SOURCE_DIR}/dash/ResultRenderer.cpp
252 ${CMAKE_SOURCE_DIR}/dash/ResultRendererHorizontalTile.cpp
253 ${CMAKE_SOURCE_DIR}/dash/ResultRendererTile.cpp
249 ${CMAKE_SOURCE_DIR}/dash/ResultView.cpp254 ${CMAKE_SOURCE_DIR}/dash/ResultView.cpp
250 ${CMAKE_SOURCE_DIR}/dash/ResultViewGrid.cpp255 ${CMAKE_SOURCE_DIR}/dash/ResultViewGrid.cpp
251 ${CMAKE_SOURCE_DIR}/dash/previews/ActionButton.cpp256 ${CMAKE_SOURCE_DIR}/dash/previews/ActionButton.cpp
252257
=== added file 'tests/test_places_group.cpp'
--- tests/test_places_group.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_places_group.cpp 2012-10-08 16:22:39 +0000
@@ -0,0 +1,103 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 *
19 */
20
21#include "config.h"
22#include <gmock/gmock.h>
23using namespace testing;
24
25#include <Nux/Nux.h>
26#include <Nux/PaintLayer.h>
27
28#include "PlacesGroup.h"
29using namespace unity;
30
31namespace {
32
33class MockDashStyle : public dash::StyleInterface
34{
35public:
36 MockDashStyle()
37 {
38 std::string full_path = PKGDATADIR "album_missing.png";
39 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_size(full_path.c_str(), 20, 20, nullptr));
40 base_texture_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
41 }
42
43 MOCK_METHOD2(FocusOverlay, nux::AbstractPaintLayer*(int width, int height));
44 MOCK_METHOD0(GetCategoryBackground, nux::BaseTexture*());
45 MOCK_METHOD0(GetCategoryBackgroundNoFilters, nux::BaseTexture*());
46
47 MOCK_METHOD0(GetGroupExpandIcon, nux::BaseTexture*());
48 MOCK_METHOD0(GetGroupUnexpandIcon, nux::BaseTexture*());
49
50 MOCK_CONST_METHOD0(GetCategoryHeaderLeftPadding, int());
51 MOCK_CONST_METHOD0(GetPlacesGroupTopSpace, int());
52
53 nux::ObjectPtr<nux::BaseTexture> base_texture_;
54};
55
56
57class TestPlacesGroup : public Test
58{
59public:
60 void SetUp()
61 {
62 SetupMockDashStyle();
63
64 places_group_ = new PlacesGroup(dash_style_);
65 }
66
67 void SetupMockDashStyle()
68 {
69 ON_CALL(dash_style_, FocusOverlay(_, _))
70 .WillByDefault(Return(new nux::ColorLayer(nux::color::White)));
71
72 ON_CALL(dash_style_, GetCategoryBackground())
73 .WillByDefault(Return(dash_style_.base_texture_.GetPointer()));
74
75 ON_CALL(dash_style_, GetCategoryBackgroundNoFilters())
76 .WillByDefault(Return(dash_style_.base_texture_.GetPointer()));
77
78 ON_CALL(dash_style_, GetGroupExpandIcon())
79 .WillByDefault(Return(dash_style_.base_texture_.GetPointer()));
80
81 ON_CALL(dash_style_, GetGroupUnexpandIcon())
82 .WillByDefault(Return(dash_style_.base_texture_.GetPointer()));
83 }
84
85 NiceMock<MockDashStyle> dash_style_;
86 nux::ObjectPtr<PlacesGroup> places_group_;
87};
88
89
90TEST_F(TestPlacesGroup, Constructor)
91{
92 EXPECT_CALL(dash_style_, GetGroupExpandIcon())
93 .Times(1);
94
95 EXPECT_CALL(dash_style_, GetGroupUnexpandIcon())
96 .Times(0);
97
98 PlacesGroup places_group(dash_style_);
99
100 EXPECT_FALSE(places_group.GetExpanded());
101}
102
103}
0104
=== modified file 'unity-shared/DashStyle.h'
--- unity-shared/DashStyle.h 2012-10-01 15:12:05 +0000
+++ unity-shared/DashStyle.h 2012-10-08 16:22:39 +0000
@@ -20,6 +20,8 @@
20#ifndef DASH_STYLE_H20#ifndef DASH_STYLE_H
21#define DASH_STYLE_H21#define DASH_STYLE_H
2222
23#include "DashStyleInterface.h"
24
23#include <Nux/Nux.h>25#include <Nux/Nux.h>
24#include <Nux/View.h>26#include <Nux/View.h>
25#include <Nux/AbstractButton.h>27#include <Nux/AbstractButton.h>
@@ -83,7 +85,7 @@
83};85};
8486
8587
86class Style88class Style : public StyleInterface
87{89{
88public:90public:
89 Style ();91 Style ();
9092
=== added file 'unity-shared/DashStyleInterface.h'
--- unity-shared/DashStyleInterface.h 1970-01-01 00:00:00 +0000
+++ unity-shared/DashStyleInterface.h 2012-10-08 16:22:39 +0000
@@ -0,0 +1,53 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2012 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 */
19
20#ifndef UNITYSHELL_DASH_STYLE_INTERFACE_H
21#define UNITYSHELL_DASH_STYLE_INTERFACE_H
22
23#include <memory>
24
25namespace nux {
26 class AbstractPaintLayer;
27 class BaseTexture;
28}
29
30namespace unity {
31namespace dash {
32
33class StyleInterface
34{
35public:
36 virtual ~StyleInterface() {};
37
38 virtual nux::AbstractPaintLayer* FocusOverlay(int width, int height) = 0;
39
40 virtual nux::BaseTexture* GetCategoryBackground() = 0;
41 virtual nux::BaseTexture* GetCategoryBackgroundNoFilters() = 0;
42
43 virtual nux::BaseTexture* GetGroupUnexpandIcon() = 0;
44 virtual nux::BaseTexture* GetGroupExpandIcon() = 0;
45
46 virtual int GetCategoryHeaderLeftPadding() const = 0;
47 virtual int GetPlacesGroupTopSpace() const = 0;
48};
49
50}
51}
52
53#endif

Subscribers

People subscribed via source and target branches