summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2014-06-06 13:55:20 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-06-06 13:55:20 +0000
commit476768d6f13522a230abdc5612e783fb3fa81f7a (patch)
treee9ecfb9429f3093adaf0daf102caaaabddeff304
parent3b43db9c2710cb397fcce39bd7aa294c9a355ce0 (diff)
parent40ad1f050267a083f2be8c99f9fc322143475073 (diff)
SwitcherView: use RawPixel's for the size values and convert them to match current scaling Fixes: 1317348
(bzr r3813)
-rw-r--r--launcher/SwitcherView.cpp54
-rw-r--r--launcher/SwitcherView.h1
-rw-r--r--tests/test_switcher_view.cpp1
3 files changed, 35 insertions, 21 deletions
diff --git a/launcher/SwitcherView.cpp b/launcher/SwitcherView.cpp
index c4b612c28..edfe560c6 100644
--- a/launcher/SwitcherView.cpp
+++ b/launcher/SwitcherView.cpp
@@ -38,24 +38,32 @@ namespace switcher
namespace
{
RawPixel const VERTICAL_PADDING = 45_em;
- unsigned int const SPREAD_OFFSET = 100;
- unsigned int const EXTRA_ICON_SPACE = 10;
+ RawPixel const BORDER_SIZE = 50_em;
+ RawPixel const FLAT_SPACING = 20_em;
+ RawPixel const ICON_SIZE = 128_em;
+ RawPixel const MINIMUM_SPACING = 10_em;
+ RawPixel const TILE_SIZE = 150_em;
+ RawPixel const SPREAD_OFFSET = 100_em;
+ RawPixel const EXTRA_ICON_SPACE = 10_em;
+ RawPixel const TEXT_SIZE = 15_em;
+
+ unsigned int const ANIMATION_LENGTH = 250;
unsigned int const MAX_DIRECTIONS_CHANGED = 3;
+ double const TEXT_TILE_MULTIPLIER = 3.5;
}
NUX_IMPLEMENT_OBJECT_TYPE(SwitcherView);
SwitcherView::SwitcherView(ui::AbstractIconRenderer::Ptr const& renderer)
: render_boxes(false)
- , border_size(50)
- , flat_spacing(20)
- , icon_size(128)
- , minimum_spacing(10)
- , tile_size(150)
- , vertical_size(tile_size + VERTICAL_PADDING.CP(scale()) * 2)
- , text_size(15)
- , animation_length(250)
- , spread_size(3.5f)
+ , border_size(BORDER_SIZE.CP(scale))
+ , flat_spacing(FLAT_SPACING.CP(scale))
+ , icon_size(ICON_SIZE.CP(scale))
+ , minimum_spacing(MINIMUM_SPACING.CP(scale))
+ , tile_size(TILE_SIZE.CP(scale))
+ , vertical_size(tile_size + VERTICAL_PADDING.CP(scale) * 2)
+ , text_size(TEXT_SIZE.CP(scale))
+ , animation_length(ANIMATION_LENGTH)
, icon_renderer_(renderer)
, text_view_(new StaticCairoText(""))
, animation_(animation_length)
@@ -67,10 +75,11 @@ SwitcherView::SwitcherView(ui::AbstractIconRenderer::Ptr const& renderer)
icon_renderer_->monitor = monitors::MAX;
icon_renderer_->SetTargetSize(tile_size, icon_size, minimum_spacing);
- text_view_->SetMaximumWidth(tile_size * spread_size);
+ text_view_->SetMaximumWidth(tile_size * TEXT_TILE_MULTIPLIER);
text_view_->SetLines(1);
text_view_->SetTextColor(nux::color::White);
text_view_->SetFont("Ubuntu Bold 10");
+ text_view_->SetScale(scale);
icon_size.changed.connect(sigc::mem_fun(this, &SwitcherView::OnIconSizeChanged));
tile_size.changed.connect(sigc::mem_fun(this, &SwitcherView::OnTileSizeChanged));
@@ -112,10 +121,10 @@ void SwitcherView::AddProperties(debug::IntrospectionData& introspection)
.add("vertical-size", vertical_size)
.add("text-size", text_size)
.add("animation-length", animation_length)
- .add("spread-size", spread_size)
+ .add("spread-size", TEXT_TILE_MULTIPLIER)
.add("label", text_view_->GetText())
.add("last_icon_selected", last_icon_selected_)
- .add("spread_offset", SPREAD_OFFSET)
+ .add("spread_offset", SPREAD_OFFSET.CP(scale))
.add("label_visible", text_view_->IsVisible());
}
@@ -172,11 +181,18 @@ void SwitcherView::OnIconSizeChanged(int size)
void SwitcherView::OnTileSizeChanged(int size)
{
icon_renderer_->SetTargetSize(tile_size, icon_size, minimum_spacing);
- vertical_size = tile_size + VERTICAL_PADDING.CP(scale()) * 2;
+ vertical_size = tile_size + VERTICAL_PADDING.CP(scale) * 2;
}
void SwitcherView::OnScaleChanged(double scale)
{
+ text_view_->SetScale(scale);
+ border_size = BORDER_SIZE.CP(scale);
+ flat_spacing = FLAT_SPACING.CP(scale);
+ icon_size = ICON_SIZE.CP(scale);
+ minimum_spacing = MINIMUM_SPACING.CP(scale);
+ tile_size = TILE_SIZE.CP(scale);
+ text_size = TEXT_SIZE.CP(scale);
vertical_size = tile_size + VERTICAL_PADDING.CP(scale) * 2;
}
@@ -706,7 +722,7 @@ bool SwitcherView::RenderArgsFlat(nux::Geometry& background_geo, int selection,
if (text_view_->IsVisible())
{
background_geo.height += text_size;
- text_view_->SetBaseY(background_geo.y + background_geo.height - VERTICAL_PADDING.CP(scale()));
+ text_view_->SetBaseY(background_geo.y + background_geo.height - VERTICAL_PADDING.CP(scale));
}
if (model_)
@@ -722,7 +738,7 @@ bool SwitcherView::RenderArgsFlat(nux::Geometry& background_geo, int selection,
nux::Geometry const& spread_bounds = UpdateRenderTargets(progress);
ResizeRenderTargets(spread_bounds, progress);
// remove extra space consumed by spread
- spread_padded_width = spread_bounds.width + SPREAD_OFFSET;
+ spread_padded_width = spread_bounds.width + SPREAD_OFFSET.CP(scale);
max_width -= spread_padded_width - tile_size;
int expansion = std::max(0, spread_bounds.height - icon_size);
@@ -968,7 +984,7 @@ void SwitcherView::DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw,
int SwitcherView::IconIndexAt(int x, int y) const
{
- int half_size = icon_size.Get() / 2 + EXTRA_ICON_SPACE;
+ int half_size = icon_size.Get() / 2 + EXTRA_ICON_SPACE.CP(scale);
int icon_index = -1;
// Taking icon rotation into consideration will make selection more
@@ -1005,7 +1021,7 @@ int SwitcherView::DetailIconIdexAt(int x, int y) const
for (unsigned int i = 0; i < render_targets_.size(); ++i)
{
- if (render_targets_[i]->result.IsPointInside(x + SPREAD_OFFSET, y + SPREAD_OFFSET))
+ if (render_targets_[i]->result.IsPointInside(x + SPREAD_OFFSET.CP(scale), y + SPREAD_OFFSET.CP(scale)))
return i;
}
diff --git a/launcher/SwitcherView.h b/launcher/SwitcherView.h
index c86ae3179..392aac293 100644
--- a/launcher/SwitcherView.h
+++ b/launcher/SwitcherView.h
@@ -65,7 +65,6 @@ public:
nux::Property<int> vertical_size;
nux::Property<int> text_size;
nux::Property<int> animation_length;
- nux::Property<double> spread_size;
void SkipAnimation();
diff --git a/tests/test_switcher_view.cpp b/tests/test_switcher_view.cpp
index 896eca506..0bce83b97 100644
--- a/tests/test_switcher_view.cpp
+++ b/tests/test_switcher_view.cpp
@@ -118,7 +118,6 @@ TEST_F(TestSwitcherView, Initiate)
EXPECT_EQ(switcher.text_size, 15);
EXPECT_EQ(switcher.animation_length, 250);
EXPECT_EQ(switcher.monitor, 0);
- EXPECT_EQ(switcher.spread_size, 3.5f);
ASSERT_NE(switcher.text_view_, nullptr);
ASSERT_NE(switcher.icon_renderer_, nullptr);
EXPECT_EQ(switcher.icon_renderer_->pip_style, ui::OVER_TILE);