diff options
author | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 17:16:07 +0000 |
---|---|---|
committer | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 17:16:07 +0000 |
commit | 8572c4870436356bbb3541383f3af797890a4aee (patch) | |
tree | a096b3185e3d2275c762894cd5b8ce8ca70c9759 /ash/launcher | |
parent | 34219e93c43e8b7063848700ffcb60624ccdcdba (diff) | |
download | chromium_src-8572c4870436356bbb3541383f3af797890a4aee.zip chromium_src-8572c4870436356bbb3541383f3af797890a4aee.tar.gz chromium_src-8572c4870436356bbb3541383f3af797890a4aee.tar.bz2 |
Add option to align launcher/shelf to top of screen (similar to left/right align).
BUG=159770
Review URL: https://chromiumcodereview.appspot.com/11885007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r-- | ash/launcher/launcher.cc | 19 | ||||
-rw-r--r-- | ash/launcher/launcher_alignment_menu.cc | 10 | ||||
-rw-r--r-- | ash/launcher/launcher_alignment_menu.h | 1 | ||||
-rw-r--r-- | ash/launcher/launcher_button.cc | 43 | ||||
-rw-r--r-- | ash/launcher/launcher_tooltip_manager.cc | 3 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 18 | ||||
-rw-r--r-- | ash/launcher/overflow_bubble.cc | 3 | ||||
-rw-r--r-- | ash/launcher/overflow_button.cc | 8 |
8 files changed, 61 insertions, 44 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index 3df6095..f07f8fd 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -112,15 +112,19 @@ class Launcher::DimmerView : public views::WidgetDelegateView, private: // views::View overrides: virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE { + ash::internal::ShelfLayoutManager* shelf = ash::GetRootWindowController( + GetWidget()->GetNativeView()->GetRootWindow())->shelf(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); gfx::ImageSkia background_image = *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_DIMMING); if (SHELF_ALIGNMENT_BOTTOM != launcher_->alignment_) background_image = gfx::ImageSkiaOperations::CreateRotatedImage( background_image, - (SHELF_ALIGNMENT_LEFT == launcher_->alignment_ ? - SkBitmapOperations::ROTATION_90_CW : - SkBitmapOperations::ROTATION_270_CW)); + shelf->SelectValueForShelfAlignment( + SkBitmapOperations::ROTATION_90_CW, + SkBitmapOperations::ROTATION_90_CW, + SkBitmapOperations::ROTATION_270_CW, + SkBitmapOperations::ROTATION_180_CW)); SkPaint paint; paint.setAlpha(kDimAlpha); @@ -168,7 +172,8 @@ void Launcher::DelegateView::Layout() { return; View* launcher_view = child_at(0); - if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM) { + if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM || + launcher_->alignment_ == SHELF_ALIGNMENT_TOP) { int w = std::max(0, width() - launcher_->status_size_.width()); launcher_view->SetBounds(0, 0, w, height()); } else { @@ -189,12 +194,14 @@ void Launcher::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { shelf->SelectValueForShelfAlignment( SkBitmapOperations::ROTATION_90_CW, SkBitmapOperations::ROTATION_90_CW, - SkBitmapOperations::ROTATION_270_CW)); + SkBitmapOperations::ROTATION_270_CW, + SkBitmapOperations::ROTATION_180_CW)); gfx::Rect black_rect = shelf->SelectValueForShelfAlignment( gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels), gfx::Rect(0, 0, kNumBlackPixels, height()), - gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height())); + gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height()), + gfx::Rect(0, 0, width(), kNumBlackPixels)); SkPaint paint; paint.setAlpha(alpha_); diff --git a/ash/launcher/launcher_alignment_menu.cc b/ash/launcher/launcher_alignment_menu.cc index 1136baa..c8c90db 100644 --- a/ash/launcher/launcher_alignment_menu.cc +++ b/ash/launcher/launcher_alignment_menu.cc @@ -29,6 +29,9 @@ LauncherAlignmentMenu::LauncherAlignmentMenu( AddRadioItemWithStringId(MENU_ALIGN_RIGHT, IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_RIGHT, align_group_id); + AddRadioItemWithStringId(MENU_ALIGN_TOP, + IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_TOP, + align_group_id); } LauncherAlignmentMenu::~LauncherAlignmentMenu() { @@ -39,7 +42,8 @@ bool LauncherAlignmentMenu::IsCommandIdChecked(int command_id) const { SelectValueForShelfAlignment( MENU_ALIGN_BOTTOM == command_id, MENU_ALIGN_LEFT == command_id, - MENU_ALIGN_RIGHT == command_id); + MENU_ALIGN_RIGHT == command_id, + MENU_ALIGN_TOP == command_id); } bool LauncherAlignmentMenu::IsCommandIdEnabled(int command_id) const { @@ -66,6 +70,10 @@ void LauncherAlignmentMenu::ExecuteCommand(int command_id) { Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, root_window_); break; + case MENU_ALIGN_TOP: + Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_TOP, + root_window_); + break; } } diff --git a/ash/launcher/launcher_alignment_menu.h b/ash/launcher/launcher_alignment_menu.h index 25311d4..7b0754a 100644 --- a/ash/launcher/launcher_alignment_menu.h +++ b/ash/launcher/launcher_alignment_menu.h @@ -36,6 +36,7 @@ class ASH_EXPORT LauncherAlignmentMenu : public ui::SimpleMenuModel, MENU_ALIGN_LEFT = 500, MENU_ALIGN_RIGHT, MENU_ALIGN_BOTTOM, + MENU_ALIGN_TOP, }; aura::RootWindow* root_window_; diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc index dee32e3..c2cf286 100644 --- a/ash/launcher/launcher_button.cc +++ b/ash/launcher/launcher_button.cc @@ -276,22 +276,23 @@ void LauncherButton::Layout() { int x_offset = 0, y_offset = 0; gfx::Rect icon_bounds; - if (shelf_layout_manager_->GetAlignment() == SHELF_ALIGNMENT_BOTTOM) { + if (shelf_layout_manager_->IsHorizontalAlignment()) { icon_bounds.SetRect( button_bounds.x(), button_bounds.y() + kIconPad, button_bounds.width(), kIconSize); - if (ShouldHop(state_)) - y_offset -= kHopSpacing; } else { icon_bounds.SetRect( button_bounds.x() + kIconPad, button_bounds.y(), kIconSize, button_bounds.height()); - if (!ShouldHop(state_)) - x_offset += kHopSpacing; } - if (shelf_layout_manager_->GetAlignment() == SHELF_ALIGNMENT_LEFT) - x_offset = -x_offset; + if (ShouldHop(state_)) { + x_offset += shelf_layout_manager_->SelectValueForShelfAlignment( + 0, kHopSpacing, -kHopSpacing, 0); + y_offset += shelf_layout_manager_->SelectValueForShelfAlignment( + -kHopSpacing, 0, 0, kHopSpacing); + } + icon_bounds.Offset(x_offset, y_offset); icon_view_->SetBoundsRect(icon_bounds); bar_->SetBoundsRect(GetContentsBounds()); @@ -378,7 +379,8 @@ void LauncherButton::UpdateState() { shelf_layout_manager_->SelectValueForShelfAlignment( SkBitmapOperations::ROTATION_270_CW, SkBitmapOperations::ROTATION_270_CW, - SkBitmapOperations::ROTATION_90_CW))); + SkBitmapOperations::ROTATION_90_CW, + SkBitmapOperations::ROTATION_180_CW))); bar_->SetVisible(true); } bool rtl = base::i18n::IsRTL(); @@ -386,31 +388,14 @@ void LauncherButton::UpdateState() { shelf_layout_manager_->SelectValueForShelfAlignment( views::ImageView::CENTER, rtl ? views::ImageView::TRAILING : views::ImageView::LEADING, - rtl ? views::ImageView::LEADING : views::ImageView::TRAILING)); + rtl ? views::ImageView::LEADING : views::ImageView::TRAILING, + views::ImageView::CENTER)); bar_->SetVerticalAlignment( shelf_layout_manager_->SelectValueForShelfAlignment( views::ImageView::TRAILING, views::ImageView::CENTER, - views::ImageView::CENTER)); - - switch (shelf_layout_manager_->GetAlignment()) { - case SHELF_ALIGNMENT_BOTTOM: - bar_->SetHorizontalAlignment(views::ImageView::CENTER); - bar_->SetVerticalAlignment(views::ImageView::TRAILING); - break; - case SHELF_ALIGNMENT_LEFT: - bar_->SetHorizontalAlignment( - base::i18n::IsRTL() ? views::ImageView::TRAILING : - views::ImageView::LEADING); - bar_->SetVerticalAlignment(views::ImageView::CENTER); - break; - case SHELF_ALIGNMENT_RIGHT: - bar_->SetHorizontalAlignment( - base::i18n::IsRTL() ? views::ImageView::LEADING : - views::ImageView::TRAILING); - bar_->SetVerticalAlignment(views::ImageView::CENTER); - break; - } + views::ImageView::CENTER, + views::ImageView::LEADING)); // Force bar to layout as alignment may have changed but not bounds. bar_->Layout(); diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc index 2435d4f..ba5bf48 100644 --- a/ash/launcher/launcher_tooltip_manager.cc +++ b/ash/launcher/launcher_tooltip_manager.cc @@ -352,7 +352,8 @@ void LauncherTooltipManager::CreateBubble(views::View* anchor, shelf_layout_manager_->SelectValueForShelfAlignment( views::BubbleBorder::BOTTOM_CENTER, views::BubbleBorder::LEFT_CENTER, - views::BubbleBorder::RIGHT_CENTER); + views::BubbleBorder::RIGHT_CENTER, + views::BubbleBorder::TOP_CENTER); view_ = new LauncherTooltipBubble(anchor, arrow_location, this); widget_ = view_->GetWidget(); diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index 4b6bac82..6156c84 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -417,8 +417,13 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { leading_inset(), width() - kLauncherPreferredSize, std::max(width() - kLauncherPreferredSize, - ShelfLayoutManager::kAutoHideSize + 1)); - int y = shelf->PrimaryAxisValue(0, leading_inset()); + ShelfLayoutManager::kAutoHideSize + 1), + leading_inset()); + int y = shelf->SelectValueForShelfAlignment( + 0, + leading_inset(), + leading_inset(), + height() - kLauncherPreferredSize); int w = shelf->PrimaryAxisValue(kLauncherPreferredSize, width()); int h = shelf->PrimaryAxisValue(height(), kLauncherPreferredSize); for (int i = 0; i < view_model_->view_size(); ++i) { @@ -492,8 +497,13 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { leading_inset(), width() - kLauncherPreferredSize, std::max(width() - kLauncherPreferredSize, - ShelfLayoutManager::kAutoHideSize + 1)); - y = shelf->PrimaryAxisValue(0, leading_inset()); + ShelfLayoutManager::kAutoHideSize + 1), + leading_inset()); + y = shelf->SelectValueForShelfAlignment( + 0, + leading_inset(), + leading_inset(), + height() - kLauncherPreferredSize); } else if (last_visible_index_ == app_list_index) { x = view_model_->ideal_bounds(last_visible_index_).x(); y = view_model_->ideal_bounds(last_visible_index_).y(); diff --git a/ash/launcher/overflow_bubble.cc b/ash/launcher/overflow_bubble.cc index f0cd6d7..258d562 100644 --- a/ash/launcher/overflow_bubble.cc +++ b/ash/launcher/overflow_bubble.cc @@ -62,7 +62,8 @@ class OverflowBubbleView : public views::BubbleDelegateView { return GetShelfLayoutManagerForLauncher()->SelectValueForShelfAlignment( views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP, - views::BubbleBorder::RIGHT_TOP); + views::BubbleBorder::RIGHT_TOP, + views::BubbleBorder::TOP_LEFT); } void ScrollByXOffset(int x_offset); diff --git a/ash/launcher/overflow_button.cc b/ash/launcher/overflow_button.cc index 6f007bf..7f1e581 100644 --- a/ash/launcher/overflow_button.cc +++ b/ash/launcher/overflow_button.cc @@ -74,7 +74,7 @@ void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) { ShelfLayoutManager::ForLauncher(GetWidget()->GetNativeView()); // Nudge the background a little to line up right. - if (shelf->GetAlignment() == SHELF_ALIGNMENT_BOTTOM) { + if (shelf->IsHorizontalAlignment()) { rect.set_origin(gfx::Point( bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, bounds.y() + kBackgroundOffset - 1)); @@ -128,13 +128,17 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) { transform.Translate(kBackgroundOffset, height()); RotateCounterclockwise(&transform); break; + case SHELF_ALIGNMENT_TOP: + transform.Translate(1, kBackgroundOffset); + break; } canvas->Save(); canvas->Transform(transform); gfx::Rect rect(GetContentsBounds()); - if (alignment == SHELF_ALIGNMENT_BOTTOM) { + if (alignment == SHELF_ALIGNMENT_BOTTOM || + alignment == SHELF_ALIGNMENT_TOP) { canvas->DrawImageInt(*image_, rect.x() + (rect.width() - image_->width()) / 2, kButtonHoverSize - image_->height()); |