summaryrefslogtreecommitdiff
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2012-02-10 01:28:11 +0100
committerAndrea Azzarone <azzaronea@gmail.com>2012-02-10 01:28:11 +0100
commit16a829a95d092b7cb4a758671d3d1d85a6c065dc (patch)
tree35ed18f2970f39a7d1ff80ca52fa082537074595
parente4a4f67f646523449e33f87f972f9675d9f5fb7a (diff)
Removes magic numbers.
(bzr r1935.1.3)
-rw-r--r--plugins/unityshell/src/DashStyle.h4
-rw-r--r--plugins/unityshell/src/DashView.cpp3
-rw-r--r--plugins/unityshell/src/FilterExpanderLabel.cpp43
-rw-r--r--plugins/unityshell/src/FilterMultiRangeWidget.cpp13
-rw-r--r--plugins/unityshell/src/LensView.cpp6
5 files changed, 48 insertions, 21 deletions
diff --git a/plugins/unityshell/src/DashStyle.h b/plugins/unityshell/src/DashStyle.h
index 5c29a7680..98f604f2f 100644
--- a/plugins/unityshell/src/DashStyle.h
+++ b/plugins/unityshell/src/DashStyle.h
@@ -192,10 +192,6 @@ public:
nux::BaseTexture* GetGroupUnexpandIcon();
nux::BaseTexture* GetGroupExpandIcon();
- // Paddings
- static const int FILTERS_LEFT_PADDING = 0;
- static const int FILTERS_RIGHT_PADDING = 0;
-
sigc::signal<void> changed;
private:
diff --git a/plugins/unityshell/src/DashView.cpp b/plugins/unityshell/src/DashView.cpp
index 12a3e8b6c..0f101e38e 100644
--- a/plugins/unityshell/src/DashView.cpp
+++ b/plugins/unityshell/src/DashView.cpp
@@ -41,6 +41,7 @@ namespace dash
namespace
{
nux::logging::Logger logger("unity.dash.view");
+
}
NUX_IMPLEMENT_OBJECT_TYPE(DashView);
@@ -220,7 +221,7 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo)
width = MAX(width, tile_width * 6);
- width += 19 + 32 + 8 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING; // add the left padding and the group plugin padding
+ width += 19 + 40; // add the left padding and the group plugin padding
height = search_bar_->GetGeometry().height;
height += tile_height * 3;
diff --git a/plugins/unityshell/src/FilterExpanderLabel.cpp b/plugins/unityshell/src/FilterExpanderLabel.cpp
index ecffa2112..54e8295b1 100644
--- a/plugins/unityshell/src/FilterExpanderLabel.cpp
+++ b/plugins/unityshell/src/FilterExpanderLabel.cpp
@@ -26,7 +26,28 @@
namespace
{
-const float kExpandDefaultIconOpacity = 1.0f;
+
+const float EXPAND_DEFAULT_ICON_OPACITY = 1.0f;
+
+// right_hand_contents_
+const int RIGHT_HAND_CONTENTS_HEIGHT = 33;
+
+// layout_
+const int LAYOUT_LEFT_PADDING = 3;
+const int LAYOUT_RIGHT_PADDING = 1;
+
+// top_bar_layout_
+const int TOP_BAR_LAYOUT_LEFT_PADDING = 2;
+const int TOP_BAR_LAYOUT_RIGHT_PADDING = 0;
+const int TOP_BAR_LAYOUT_WIDTH_ADDER = 19;
+
+// expander_layout_
+const int EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8;
+
+// highlight
+const int HIGHLIGHT_HEIGHT = 34;
+const int HIGHLIGHT_WIDTH_SUBTRACTOR = 5;
+
}
namespace unity
@@ -94,7 +115,8 @@ void FilterExpanderLabel::SetLabel(std::string const& label)
void FilterExpanderLabel::SetRightHandView(nux::View* view)
{
- view->SetMinimumHeight(33);
+ view->SetMinimumHeight(RIGHT_HAND_CONTENTS_HEIGHT);
+ view->SetMaximumHeight(RIGHT_HAND_CONTENTS_HEIGHT);
right_hand_contents_ = view;
top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
@@ -114,14 +136,13 @@ void FilterExpanderLabel::SetContents(nux::Layout* contents)
void FilterExpanderLabel::BuildLayout()
{
layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
- layout_->SetLeftAndRightPadding(3, 1);
+ layout_->SetLeftAndRightPadding(LAYOUT_LEFT_PADDING, LAYOUT_RIGHT_PADDING);
top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- top_bar_layout_->SetLeftAndRightPadding(2, 0);
+ top_bar_layout_->SetLeftAndRightPadding(TOP_BAR_LAYOUT_LEFT_PADDING, TOP_BAR_LAYOUT_RIGHT_PADDING);
expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- expander_layout_->SetSpaceBetweenChildren(8);
-
+ expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN);
expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
expander_view_->SetLayout(expander_layout_);
@@ -129,7 +150,7 @@ void FilterExpanderLabel::BuildLayout()
cairo_label_ = new nux::StaticText(label_.c_str(), NUX_TRACKER_LOCATION);
cairo_label_->SetFontName("Ubuntu 10");
- cairo_label_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
+ cairo_label_->SetTextColor(nux::color::White);
cairo_label_->SetAcceptKeyNavFocusOnMouseDown(false);
nux::BaseTexture* arrow;
@@ -137,7 +158,7 @@ void FilterExpanderLabel::BuildLayout()
expand_icon_ = new IconTexture(arrow,
arrow->GetWidth(),
arrow->GetHeight());
- expand_icon_->SetOpacity(kExpandDefaultIconOpacity);
+ expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY);
expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());
expand_icon_->SetVisible(true);
arrow_layout_ = new nux::VLayout();
@@ -151,7 +172,7 @@ void FilterExpanderLabel::BuildLayout()
expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);
top_bar_layout_->AddSpace(1, 1);
- top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + 19);
+ top_bar_layout_->SetMaximumWidth((Style::Instance().GetTileWidth() - 12) * 2 + TOP_BAR_LAYOUT_WIDTH_ADDER);
layout_->AddLayout(top_bar_layout_, 0, nux::MINOR_POSITION_LEFT);
layout_->SetVerticalInternalMargin(0);
@@ -225,8 +246,8 @@ void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
{
nux::Geometry geo(top_bar_layout_->GetGeometry());
geo.x = base.x;
- geo.height = 34;
- geo.width = base.width - 5;
+ geo.height = HIGHLIGHT_HEIGHT;
+ geo.width = base.width - HIGHLIGHT_WIDTH_SUBTRACTOR;;
if (!highlight_layer_)
highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height));
diff --git a/plugins/unityshell/src/FilterMultiRangeWidget.cpp b/plugins/unityshell/src/FilterMultiRangeWidget.cpp
index fe5448f6b..18fc9452a 100644
--- a/plugins/unityshell/src/FilterMultiRangeWidget.cpp
+++ b/plugins/unityshell/src/FilterMultiRangeWidget.cpp
@@ -33,6 +33,15 @@ namespace unity
{
namespace dash
{
+namespace
+{
+
+const int TOP_PADDING = 9;
+const int RIGHT_PADDING = 8;
+const int BOTTOM_PADDING = 12;
+const int LEFT_PADDING = 0;
+
+}
NUX_IMPLEMENT_OBJECT_TYPE(FilterMultiRange);
@@ -44,8 +53,8 @@ FilterMultiRange::FilterMultiRange(NUX_FILE_LINE_DECL)
all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION);
layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
- layout_->SetLeftAndRightPadding(0, 8);
- layout_->SetTopAndBottomPadding(9, 12);
+ layout_->SetLeftAndRightPadding(LEFT_PADDING, RIGHT_PADDING);
+ layout_->SetTopAndBottomPadding(TOP_PADDING, BOTTOM_PADDING);
SetRightHandView(all_button_);
SetContents(layout_);
diff --git a/plugins/unityshell/src/LensView.cpp b/plugins/unityshell/src/LensView.cpp
index 6fb2657ff..486e33939 100644
--- a/plugins/unityshell/src/LensView.cpp
+++ b/plugins/unityshell/src/LensView.cpp
@@ -39,6 +39,7 @@ namespace
{
nux::logging::Logger logger("unity.dash.lensview");
+const int FSCROLL_VIEW_WIDTH_ADDER = 11;
}
// This is so we can access some protected members in scrollview.
@@ -163,7 +164,6 @@ void LensView::SetupViews()
layout_->AddView(fscroll_view_, 1);
fscroll_layout_ = new nux::VLayout();
- fscroll_layout_->SetLeftAndRightPadding(dash::Style::FILTERS_LEFT_PADDING, dash::Style::FILTERS_RIGHT_PADDING);
fscroll_view_->SetLayout(fscroll_layout_);
filter_bar_ = new FilterBar();
@@ -346,8 +346,8 @@ void LensView::OnFilterAdded(Filter::Ptr filter)
filter_bar_->AddFilter(filter);
int width = dash::Style::Instance().GetTileWidth();
- fscroll_view_->SetMinimumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8);
- fscroll_view_->SetMaximumWidth(width * 2 + dash::Style::FILTERS_LEFT_PADDING + dash::Style::FILTERS_RIGHT_PADDING + 3 + 8);
+ fscroll_view_->SetMinimumWidth(width * 2 + FSCROLL_VIEW_WIDTH_ADDER);
+ fscroll_view_->SetMaximumWidth(width * 2 + FSCROLL_VIEW_WIDTH_ADDER);
can_refine_search = true;
}