60
58
void FilterBar::Init()
60
dash::Style& style = dash::Style::Instance();
62
62
nux::LinearLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
63
layout->SetSpaceBetweenChildren(10);
63
layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding());
64
layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding());
81
82
AddChild(filter_view);
82
83
filter_map_[filter] = filter_view;
83
84
GetLayout()->AddView(filter_view, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
86
UpdateDrawSeparators();
86
89
void FilterBar::RemoveFilter(Filter::Ptr const& filter)
112
117
GfxContext.PushClippingRectangle(GetGeometry());
113
118
GetLayout()->ProcessDraw(GfxContext, force_draw);
115
nux::Color col(0.13f, 0.13f, 0.13f, 0.13f);
117
std::list<Area *>& layout_list = GetLayout()->GetChildren();
119
int num_separators = layout_list.size() - 1;
121
for (auto iter : layout_list)
120
GfxContext.PopClippingRectangle();
123
void FilterBar::UpdateDrawSeparators()
125
std::list<Area*> children = GetLayout()->GetChildren();
126
std::list<Area*>::reverse_iterator rit;
127
bool found_one = false;
129
for (rit = children.rbegin(); rit != children.rend(); ++rit)
123
if (i != num_separators)
125
nux::Area* filter_view = iter;
126
nux::Geometry const& geom = filter_view->GetGeometry();
128
unsigned int alpha = 0, src = 0, dest = 0;
129
GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
131
GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
132
GfxContext.GetRenderStates().SetColorMask(true, true, true, false);
133
nux::GetPainter().Draw2DLine(GfxContext,
134
geom.x + SEPARATOR_LEFT_PADDING, geom.y + geom.height - 1,
135
geom.x + geom.width - SEPARATOR_WIDTH_SOTTRACTOR, geom.y + geom.height - 1,
137
GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
131
FilterExpanderLabel* widget = dynamic_cast<FilterExpanderLabel*>(*rit);
136
widget->draw_separator = found_one;
142
GfxContext.PopClippingRectangle();
145
145
bool FilterBar::AcceptKeyNavFocus()
158
158
void FilterBar::AddProperties(GVariantBuilder* builder)
160
variant::BuilderWrapper(builder)
161
.add("x", GetAbsoluteX())
162
.add("y", GetAbsoluteY())
163
.add("width", GetAbsoluteWidth())
164
.add("height", GetAbsoluteHeight());
162
167
} // namespace dash