1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright (C) 2011 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Gordon Allott <gord.allott@canonical.com>
*/
#ifndef UNITYSHELL_PLACES_GROUP_H
#define UNITYSHELL_PLACES_GROUP_H
#include <Nux/Nux.h>
#include <Nux/View.h>
#include <Nux/VLayout.h>
#include <Nux/HLayout.h>
#include <Nux/TextureArea.h>
#include <sigc++/sigc++.h>
#include "unity-shared/DashStyleInterface.h"
#include "unity-shared/IconTexture.h"
#include "unity-shared/Introspectable.h"
#include "unity-shared/StaticCairoText.h"
#include "unity-shared/UBusWrapper.h"
#include <UnityCore/GLibSource.h>
#include "ResultView.h"
namespace nux
{
class AbstractPaintLayer;
class TextureLayer;
}
namespace unity
{
namespace dash
{
class HSeparator;
class PlacesGroup : public nux::View, public debug::Introspectable
{
NUX_DECLARE_OBJECT_TYPE(PlacesGroup, nux::View);
public:
typedef nux::ObjectPtr<PlacesGroup> Ptr;
PlacesGroup(dash::StyleInterface& style);
nux::Property<double> scale;
void SetIcon(std::string const& icon);
void SetName(std::string const& name);
void SetHeaderCountVisible(bool disable);
StaticCairoText* GetLabel();
StaticCairoText* GetExpandLabel();
void SetChildView(dash::ResultView* view);
dash::ResultView* GetChildView();
void SetChildLayout(nux::Layout* layout);
void Relayout();
void SetCounts(unsigned n_total_items);
virtual void SetExpanded(bool is_expanded);
virtual bool GetExpanded() const;
void PushExpanded();
void PopExpanded();
void SetResultsPreviewAnimationValue(float preview_animation);
int GetHeaderHeight() const;
bool HeaderIsFocusable() const;
nux::View* GetHeaderFocusableView() const;
void SetFiltersExpanded(bool filters_expanded);
sigc::signal<void, PlacesGroup*> expanded;
glib::Variant GetCurrentFocus() const;
void SetCurrentFocus(glib::Variant const& variant);
protected:
long ComputeContentSize();
void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw);
void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw);
// Key navigation
virtual bool AcceptKeyNavFocus();
// Introspection
virtual std::string GetName() const;
virtual void AddProperties(debug::IntrospectionData&);
private:
void Refresh();
bool HeaderHasKeyFocus() const;
bool ShouldBeHighlighted() const;
void DrawSeparatorChanged(bool draw);
void RecvMouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
void OnLabelActivated(nux::Area* label);
void OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction);
bool OnIdleRelayout();
void RefreshLabel();
void UpdatePlacesGroupSize();
void UpdateResultViewPadding();
void UpdateScale(double scale);
private:
std::string _category_id;
dash::StyleInterface& _style;
nux::VLayout* _group_layout;
nux::View* _header_view;
nux::HLayout* _header_layout;
nux::HLayout* _text_layout;
nux::HLayout* _expand_label_layout;
nux::HLayout* _expand_layout;
nux::VLayout* _child_layout;
nux::SpaceLayout* _space_layout;
dash::ResultView* _child_view;
std::unique_ptr<nux::AbstractPaintLayer> _focus_layer;
IconTexture* _icon;
StaticCairoText* _name;
StaticCairoText* _expand_label;
IconTexture* _expand_icon;
nux::BaseTexture* _background;
nux::BaseTexture* _background_nofilters;
bool _using_filters_background;
std::unique_ptr<nux::TextureLayer> _background_layer;
bool _is_expanded;
bool _is_expanded_pushed;
unsigned _n_visible_items_in_unexpand_mode;
unsigned _n_total_items;
std::string _cached_name;
nux::Geometry _cached_geometry;
bool _coverflow_enabled;
bool _disabled_header_count;
glib::Source::UniquePtr _relayout_idle;
UBusManager _ubus;
friend class TestScopeView;
};
} // namespace dash
} // namespace unity
#endif
|