summaryrefslogtreecommitdiffstats
path: root/ash/launcher
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-20 22:35:49 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-20 22:35:49 +0000
commit8e25b31522e0fba31d87dabd47407f3d70e4cce5 (patch)
treef7bb750a24b280e7a16e611392ddaf71afbcbbcb /ash/launcher
parentf5e556f2403b64c2c853b30eb0945a7bcc905c8f (diff)
downloadchromium_src-8e25b31522e0fba31d87dabd47407f3d70e4cce5.zip
chromium_src-8e25b31522e0fba31d87dabd47407f3d70e4cce5.tar.gz
chromium_src-8e25b31522e0fba31d87dabd47407f3d70e4cce5.tar.bz2
Correcting the anchor offset calculation
This is a revert of CL 12498004 since it produced a tiny - not really noticable offset shift of the first icon. With the possibility to move icons around it became apparent since the first icon can now be a rectangular item. To address this, the old spacing trick had to be applied again and the anchor point for menus and tooltips had to be adjusted accordingly. That said - as soon as Simon's change lands, the first item needs proper handling again since the first item can change. BUG=218373 TES=visual Review URL: https://chromiumcodereview.appspot.com/12660015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc17
-rw-r--r--ash/launcher/launcher_view.cc33
-rw-r--r--ash/launcher/launcher_view.h5
3 files changed, 47 insertions, 8 deletions
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index 46f2165..12bdf33 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -40,8 +40,7 @@ const int kTooltipMaxWidth = 250;
// The offset for the tooltip bubble - making sure that the bubble is flush
// with the shelf. The offset includes the arrow size in pixels as well as
// the activation bar and other spacing elements.
-const int kArrowOffsetLeft = 3;
-const int kArrowOffsetRight = 11;
+const int kArrowOffsetLeftRight = 11;
const int kArrowOffsetTopBottom = 7;
} // namespace
@@ -76,10 +75,16 @@ LauncherTooltipManager::LauncherTooltipBubble::LauncherTooltipBubble(
LauncherTooltipManager* host)
: views::BubbleDelegateView(anchor, arrow_location),
host_(host) {
- set_anchor_insets(gfx::Insets(kArrowOffsetTopBottom,
- kArrowOffsetLeft,
- kArrowOffsetTopBottom,
- kArrowOffsetRight));
+ gfx::Insets insets = gfx::Insets(kArrowOffsetTopBottom,
+ kArrowOffsetLeftRight,
+ kArrowOffsetTopBottom,
+ kArrowOffsetLeftRight);
+ // Launcher items can have an asymmetrical border for spacing reasons.
+ // Adjust anchor location for this.
+ if (anchor->border())
+ insets += anchor->border()->GetInsets();
+
+ set_anchor_insets(insets);
set_close_on_esc(false);
set_close_on_deactivate(false);
set_use_focusless(true);
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index ae51c1d..ce5f089 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -406,11 +406,13 @@ void LauncherView::Init() {
overflow_button_->set_context_menu_controller(this);
ConfigureChildView(overflow_button_);
AddChildView(overflow_button_);
+ UpdateFirstButtonPadding();
// We'll layout when our bounds change.
}
void LauncherView::OnShelfAlignmentChanged() {
+ UpdateFirstButtonPadding();
overflow_button_->OnShelfAlignmentChanged();
LayoutToIdealBounds();
for (int i=0; i < view_model_->view_size(); ++i) {
@@ -711,8 +713,14 @@ void LauncherView::AnimateToIdealBounds() {
IdealBounds ideal_bounds;
CalculateIdealBounds(&ideal_bounds);
for (int i = 0; i < view_model_->view_size(); ++i) {
- bounds_animator_->AnimateViewTo(view_model_->view_at(i),
- view_model_->ideal_bounds(i));
+ View* view = view_model_->view_at(i);
+ bounds_animator_->AnimateViewTo(view, view_model_->ideal_bounds(i));
+ // Now that the item animation starts, we have to make sure that the
+ // padding of the first gets properly transferred to the new first item.
+ if (i && view->border())
+ view->set_border(NULL);
+ else if (!i && !view->border())
+ UpdateFirstButtonPadding();
}
overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds);
}
@@ -936,6 +944,21 @@ void LauncherView::ToggleOverflowBubble() {
Shell::GetInstance()->UpdateShelfVisibility();
}
+void LauncherView::UpdateFirstButtonPadding() {
+ ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
+
+ // Creates an empty border for first launcher button to make included leading
+ // inset act as the button's padding. This is only needed on button creation
+ // and when shelf alignment changes.
+ if (view_model_->view_size() > 0) {
+ view_model_->view_at(0)->set_border(views::Border::CreateEmptyBorder(
+ shelf->PrimaryAxisValue(0, leading_inset()),
+ shelf->PrimaryAxisValue(leading_inset(), 0),
+ 0,
+ 0));
+ }
+}
+
void LauncherView::OnFadeOutAnimationEnded() {
AnimateToIdealBounds();
@@ -1419,6 +1442,12 @@ void LauncherView::ShowMenu(
ash::ShelfAlignment align = RootWindowController::ForLauncher(
GetWidget()->GetNativeView())->shelf()->GetAlignment();
anchor_point = source->GetBoundsInScreen();
+
+ // Launcher items can have an asymmetrical border for spacing reasons.
+ // Adjust anchor location for this.
+ if (source->border())
+ anchor_point.Inset(source->border()->GetInsets());
+
switch (align) {
case ash::SHELF_ALIGNMENT_BOTTOM:
menu_alignment = views::MenuItemView::BUBBLE_ABOVE;
diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h
index 2207a3e..244ff40 100644
--- a/ash/launcher/launcher_view.h
+++ b/ash/launcher/launcher_view.h
@@ -163,6 +163,11 @@ class ASH_EXPORT LauncherView : public views::View,
// Toggles the overflow menu.
void ToggleOverflowBubble();
+ // Update first launcher button's padding. This method adds padding to the
+ // first button to include the leading inset. It needs to be called once on
+ // button creation and every time when shelf alignment is changed.
+ void UpdateFirstButtonPadding();
+
// Invoked after the fading out animation for item deletion is ended.
void OnFadeOutAnimationEnded();