23
#include "DashStyle.h"
27
24
#include "FilterBasicButton.h"
28
25
#include "FilterExpanderLabel.h"
29
#include "DashStyle.h"
33
32
NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);
35
FilterExpanderLabel::FilterExpanderLabel (std::string label, NUX_FILE_LINE_DECL)
36
: nux::View (NUX_FILE_LINE_PARAM)
38
, top_bar_layout_ (NULL)
40
, right_hand_contents_ (NULL)
41
, expander_graphic_ (NULL)
42
, label_("<span size='larger' weight='bold'>" + label + "</span>")
44
expanded.changed.connect (sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
48
FilterExpanderLabel::~FilterExpanderLabel() {
52
void FilterExpanderLabel::SetLabel (std::string label)
54
label_ = "<span size='larger' weight='bold'>" + label + "</span>";
55
cairo_label_->SetText(label_.c_str());
58
void FilterExpanderLabel::SetRightHandView (nux::View *view)
60
view->SetMaximumHeight(30);
62
right_hand_contents_ = view;
63
top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
66
void FilterExpanderLabel::SetContents (nux::Layout *contents)
69
contents_->SetVisible(expanded);
70
layout_->AddLayout (contents_, 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
75
void FilterExpanderLabel::BuildLayout ()
77
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
78
top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
80
cairo_label_ = new nux::StaticText(label_.c_str(), NUX_TRACKER_LOCATION);
81
cairo_label_->SetFontName("Ubuntu 10");
82
cairo_label_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
83
cairo_label_->mouse_down.connect(
84
[&](int x, int y, unsigned long button_flags, unsigned long key_flag)
88
contents_->SetVisible(expanded);
92
top_bar_layout_->AddView (cairo_label_, 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
93
top_bar_layout_->AddSpace(1, 1);
95
top_bar_layout_->SetMaximumWidth((dash::Style::Instance().GetTileWidth() -12)*2+10);
97
layout_->AddLayout (top_bar_layout_, 0, nux::MINOR_POSITION_LEFT);
98
layout_->SetVerticalInternalMargin(0);
106
void FilterExpanderLabel::DoExpandChange (bool change)
109
contents_->SetVisible(change);
114
void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {
115
nux::Geometry geo = GetGeometry();
117
GfxContext.PushClippingRectangle(geo);
118
nux::GetPainter().PaintBackground(GfxContext, geo);
119
GfxContext.PopClippingRectangle();
122
void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {
123
GfxContext.PushClippingRectangle(GetGeometry());
125
GetLayout()->ProcessDraw(GfxContext, force_draw);
127
GfxContext.PopClippingRectangle();
130
void FilterExpanderLabel::PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw) {
131
nux::View::PostDraw(GfxContext, force_draw);
34
FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL)
35
: FilterWidget(NUX_FILE_LINE_PARAM)
38
, top_bar_layout_(nullptr)
39
, right_hand_contents_(nullptr)
40
, expander_graphic_(nullptr)
41
, cairo_label_(nullptr)
43
, label_("<span size='larger' weight='bold'>" + label + "</span>" + " ▾")
45
expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
49
FilterExpanderLabel::~FilterExpanderLabel()
53
void FilterExpanderLabel::SetLabel(std::string const& label)
57
label_ = "<span size='larger' weight='bold'>";
60
label_ += expanded ? " ▾" : " ▸";
61
cairo_label_->SetText(label_.c_str());
64
void FilterExpanderLabel::SetRightHandView(nux::View* view)
66
view->SetMaximumHeight(30);
68
right_hand_contents_ = view;
69
top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
72
void FilterExpanderLabel::SetContents(nux::Layout* contents)
74
contents_.Adopt(contents);
76
layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
77
top_bar_layout_->SetTopAndBottomPadding(0);
82
void FilterExpanderLabel::BuildLayout()
84
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
85
top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
87
cairo_label_ = new nux::StaticText(label_.c_str(), NUX_TRACKER_LOCATION);
88
cairo_label_->SetFontName("Ubuntu 10");
89
cairo_label_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
90
cairo_label_->mouse_down.connect(
91
[&](int x, int y, unsigned long button_flags, unsigned long key_flag)
96
top_bar_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
97
top_bar_layout_->AddSpace(1, 1);
99
top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 10);
101
layout_->AddLayout(top_bar_layout_, 0, nux::MINOR_POSITION_LEFT);
102
layout_->SetVerticalInternalMargin(0);
110
void FilterExpanderLabel::DoExpandChange(bool change)
112
label_ = "<span size='larger' weight='bold'>";
113
label_ += raw_label_;
115
label_ += expanded ? " ▾" : " ▸";
118
cairo_label_->SetText(label_);
120
if (change and contents_ and !contents_->IsChildOf(layout_))
122
layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
123
top_bar_layout_->SetTopAndBottomPadding(0);
125
else if (!change and contents_ and contents_->IsChildOf(layout_))
127
layout_->RemoveChildObject(contents_.GetPointer());
128
top_bar_layout_->SetTopAndBottomPadding(0, 10);
131
layout_->ComputeContentSize();
135
void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
137
nux::Geometry const& geo = GetGeometry();
139
GfxContext.PushClippingRectangle(geo);
140
nux::GetPainter().PaintBackground(GfxContext, geo);
141
GfxContext.PopClippingRectangle();
144
void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
146
GfxContext.PushClippingRectangle(GetGeometry());
147
GetLayout()->ProcessDraw(GfxContext, force_draw);
148
GfxContext.PopClippingRectangle();