summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorharrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 17:16:07 +0000
committerharrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 17:16:07 +0000
commit8572c4870436356bbb3541383f3af797890a4aee (patch)
treea096b3185e3d2275c762894cd5b8ce8ca70c9759 /ash
parent34219e93c43e8b7063848700ffcb60624ccdcdba (diff)
downloadchromium_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')
-rw-r--r--ash/ash_strings.grd3
-rw-r--r--ash/launcher/launcher.cc19
-rw-r--r--ash/launcher/launcher_alignment_menu.cc10
-rw-r--r--ash/launcher/launcher_alignment_menu.h1
-rw-r--r--ash/launcher/launcher_button.cc43
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc3
-rw-r--r--ash/launcher/launcher_view.cc18
-rw-r--r--ash/launcher/overflow_bubble.cc3
-rw-r--r--ash/launcher/overflow_button.cc8
-rw-r--r--ash/shelf_types.h1
-rw-r--r--ash/system/date/tray_date.cc8
-rw-r--r--ash/system/session_length_limit/tray_session_length_limit.cc6
-rw-r--r--ash/system/status_area_widget_delegate.cc3
-rw-r--r--ash/system/tray/system_tray.cc6
-rw-r--r--ash/system/tray/tray_background_view.cc11
-rw-r--r--ash/system/tray/tray_item_view.cc3
-rw-r--r--ash/system/tray/tray_views.cc6
-rw-r--r--ash/system/user/tray_user.cc6
-rw-r--r--ash/wm/app_list_controller.cc7
-rw-r--r--ash/wm/shelf_layout_manager.cc91
-rw-r--r--ash/wm/shelf_layout_manager.h4
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc31
22 files changed, 185 insertions, 106 deletions
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd
index 2f1b8ef..e46f84b 100644
--- a/ash/ash_strings.grd
+++ b/ash/ash_strings.grd
@@ -191,6 +191,9 @@ This file contains the strings for ash.
<message name="IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_RIGHT" desc="Title of the menu item in the context menu for aligning the launcher to the right of the screen">
Right
</message>
+ <message name="IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_TOP" desc="Title of the menu item in the context menu for aligning the launcher to the top of the screen">
+ Top
+ </message>
<message name="IDS_AURA_SET_DESKTOP_WALLPAPER" desc="The label used for change wallpaper in context menu">
Set wallpaper...
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());
diff --git a/ash/shelf_types.h b/ash/shelf_types.h
index 4286f07..d1d6cb5 100644
--- a/ash/shelf_types.h
+++ b/ash/shelf_types.h
@@ -11,6 +11,7 @@ enum ShelfAlignment {
SHELF_ALIGNMENT_BOTTOM,
SHELF_ALIGNMENT_LEFT,
SHELF_ALIGNMENT_RIGHT,
+ SHELF_ALIGNMENT_TOP,
};
enum ShelfAutoHideBehavior {
diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc
index 6dce15bc..4d7ef6f 100644
--- a/ash/system/date/tray_date.cc
+++ b/ash/system/date/tray_date.cc
@@ -145,7 +145,8 @@ TrayDate::~TrayDate() {
views::View* TrayDate::CreateTrayView(user::LoginStatus status) {
CHECK(time_tray_ == NULL);
ClockLayout clock_layout =
- system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ?
+ (system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ||
+ system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) ?
HORIZONTAL_CLOCK : VERTICAL_CLOCK;
time_tray_ = new tray::TimeView(clock_layout);
views::View* view = new TrayItemView(this);
@@ -176,8 +177,9 @@ void TrayDate::UpdateAfterLoginStatusChange(user::LoginStatus status) {
void TrayDate::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
if (time_tray_) {
- ClockLayout clock_layout = alignment == SHELF_ALIGNMENT_BOTTOM ?
- HORIZONTAL_CLOCK : VERTICAL_CLOCK;
+ ClockLayout clock_layout = (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_TOP) ?
+ HORIZONTAL_CLOCK : VERTICAL_CLOCK;
time_tray_->UpdateClockLayout(clock_layout);
}
}
diff --git a/ash/system/session_length_limit/tray_session_length_limit.cc b/ash/system/session_length_limit/tray_session_length_limit.cc
index ca38519..d9c3588 100644
--- a/ash/system/session_length_limit/tray_session_length_limit.cc
+++ b/ash/system/session_length_limit/tray_session_length_limit.cc
@@ -133,7 +133,8 @@ void RemainingSessionTimeTrayView::SetSessionLengthLimit(
void RemainingSessionTimeTrayView::UpdateClockLayout(
ShelfAlignment shelf_alignment) {
SetBorder(shelf_alignment);
- const bool horizontal_layout = shelf_alignment == SHELF_ALIGNMENT_BOTTOM;
+ const bool horizontal_layout = (shelf_alignment == SHELF_ALIGNMENT_BOTTOM ||
+ shelf_alignment == SHELF_ALIGNMENT_TOP);
if (horizontal_layout && !horizontal_layout_label_) {
// Remove labels used for vertical layout.
RemoveAllChildViews(true);
@@ -190,7 +191,8 @@ void RemainingSessionTimeTrayView::UpdateClockLayout(
}
void RemainingSessionTimeTrayView::SetBorder(ShelfAlignment shelf_alignment) {
- if (shelf_alignment == SHELF_ALIGNMENT_BOTTOM) {
+ if (shelf_alignment == SHELF_ALIGNMENT_BOTTOM ||
+ shelf_alignment == SHELF_ALIGNMENT_TOP) {
set_border(views::Border::CreateEmptyBorder(
0, kTrayLabelItemHorizontalPaddingBottomAlignment,
0, kTrayLabelItemHorizontalPaddingBottomAlignment));
diff --git a/ash/system/status_area_widget_delegate.cc b/ash/system/status_area_widget_delegate.cc
index f82ec13..3e599a9 100644
--- a/ash/system/status_area_widget_delegate.cc
+++ b/ash/system/status_area_widget_delegate.cc
@@ -93,7 +93,8 @@ void StatusAreaWidgetDelegate::UpdateLayout() {
SetLayoutManager(layout);
views::ColumnSet* columns = layout->AddColumnSet(0);
- if (alignment_ == SHELF_ALIGNMENT_BOTTOM) {
+ if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
+ alignment_ == SHELF_ALIGNMENT_TOP) {
for (int c = 0; c < child_count(); ++c) {
if (c != 0)
columns->AddPaddingColumn(0, kTraySpacing);
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index d166d9a..fff363b 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -315,7 +315,8 @@ void SystemTray::DestroyNotificationBubble() {
int SystemTray::GetTrayXOffset(SystemTrayItem* item) const {
// Don't attempt to align the arrow if the shelf is on the left or right.
- if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM)
+ if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM &&
+ shelf_alignment() != SHELF_ALIGNMENT_TOP)
return TrayBubbleView::InitParams::kArrowDefaultOffset;
std::map<SystemTrayItem*, views::View*>::const_iterator it =
@@ -541,7 +542,8 @@ bool SystemTray::PerformAction(const ui::Event& event) {
if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) {
const ui::LocatedEvent& located_event =
static_cast<const ui::LocatedEvent&>(event);
- if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ||
+ shelf_alignment() == SHELF_ALIGNMENT_TOP) {
gfx::Point point(located_event.x(), 0);
ConvertPointToWidget(this, &point);
arrow_offset = point.x();
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 208f435..ea77496 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -131,7 +131,8 @@ void TrayBackgroundView::TrayContainer::ViewHierarchyChanged(bool is_add,
void TrayBackgroundView::TrayContainer::UpdateLayout() {
// Adjust the size of status tray dark background by adding additional
// empty border.
- if (alignment_ == SHELF_ALIGNMENT_BOTTOM) {
+ if (alignment_ == SHELF_ALIGNMENT_BOTTOM ||
+ alignment_ == SHELF_ALIGNMENT_TOP) {
set_border(views::Border::CreateEmptyBorder(
kTrayContainerVerticalPaddingBottomAlignment,
kTrayContainerHorizontalPaddingBottomAlignment,
@@ -275,6 +276,12 @@ void TrayBackgroundView::SetBorder() {
on_edge ? kPaddingFromBottomOfScreenBottomAlignment :
kPaddingFromBottomOfScreenBottomAlignment - 1,
on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0));
+ } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) {
+ set_border(views::Border::CreateEmptyBorder(
+ on_edge ? kPaddingFromBottomOfScreenBottomAlignment :
+ kPaddingFromBottomOfScreenBottomAlignment - 1,
+ 0, 0,
+ on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0));
} else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
set_border(views::Border::CreateEmptyBorder(
0, kPaddingFromOuterEdgeOfLauncherVerticalAlignment,
@@ -361,6 +368,8 @@ TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const {
return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT;
case SHELF_ALIGNMENT_RIGHT:
return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT;
+ case SHELF_ALIGNMENT_TOP:
+ return TrayBubbleView::ANCHOR_ALIGNMENT_TOP;
}
NOTREACHED();
return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM;
diff --git a/ash/system/tray/tray_item_view.cc b/ash/system/tray/tray_item_view.cc
index 4fd7e43..ae778ae 100644
--- a/ash/system/tray/tray_item_view.cc
+++ b/ash/system/tray/tray_item_view.cc
@@ -78,7 +78,8 @@ int TrayItemView::GetAnimationDurationMS() {
gfx::Size TrayItemView::GetPreferredSize() {
gfx::Size size = DesiredSize();
- if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM)
+ if (owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM ||
+ owner()->system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP)
size.set_height(kTrayIconHeight);
else
size.set_width(kTrayIconWidth);
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc
index 57b39e3..061c8c4 100644
--- a/ash/system/tray/tray_views.cc
+++ b/ash/system/tray/tray_views.cc
@@ -704,7 +704,8 @@ void SetupLabelForTray(views::Label* label) {
void SetTrayImageItemBorder(views::View* tray_view,
ShelfAlignment alignment) {
- if (alignment == SHELF_ALIGNMENT_BOTTOM) {
+ if (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_TOP) {
tray_view->set_border(views::Border::CreateEmptyBorder(
0, kTrayImageItemHorizontalPaddingBottomAlignment,
0, kTrayImageItemHorizontalPaddingBottomAlignment));
@@ -719,7 +720,8 @@ void SetTrayImageItemBorder(views::View* tray_view,
void SetTrayLabelItemBorder(TrayItemView* tray_view,
ShelfAlignment alignment) {
- if (alignment == SHELF_ALIGNMENT_BOTTOM) {
+ if (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_TOP) {
tray_view->set_border(views::Border::CreateEmptyBorder(
0, kTrayLabelItemHorizontalPaddingBottomAlignment,
0, kTrayLabelItemHorizontalPaddingBottomAlignment));
diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc
index 287e584..fad3e09 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -611,7 +611,8 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
if (avatar_) {
- if (alignment == SHELF_ALIGNMENT_BOTTOM) {
+ if (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_TOP) {
avatar_->set_border(views::Border::CreateEmptyBorder(
0, kTrayImageItemHorizontalPaddingBottomAlignment + 2,
0, kTrayImageItemHorizontalPaddingBottomAlignment));
@@ -619,7 +620,8 @@ void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
SetTrayImageItemBorder(avatar_, alignment);
}
} else {
- if (alignment == SHELF_ALIGNMENT_BOTTOM) {
+ if (alignment == SHELF_ALIGNMENT_BOTTOM ||
+ alignment == SHELF_ALIGNMENT_TOP) {
label_->set_border(views::Border::CreateEmptyBorder(
0, kTrayLabelItemHorizontalPaddingBottomAlignment,
0, kTrayLabelItemHorizontalPaddingBottomAlignment));
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index 0063d37..c95e1a4 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -49,7 +49,8 @@ views::BubbleBorder::ArrowLocation GetBubbleArrowLocation(
SelectValueForShelfAlignment(
views::BubbleBorder::BOTTOM_CENTER,
views::BubbleBorder::LEFT_CENTER,
- views::BubbleBorder::RIGHT_CENTER);
+ views::BubbleBorder::RIGHT_CENTER,
+ views::BubbleBorder::TOP_CENTER);
}
// Offset given |rect| towards shelf.
@@ -68,8 +69,8 @@ gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) {
case SHELF_ALIGNMENT_RIGHT:
offseted.Offset(kAnimationOffset, 0);
break;
- default:
- NOTREACHED() << "Unknown shelf alignment " << shelf_alignment;
+ case SHELF_ALIGNMENT_TOP:
+ offseted.Offset(0, -kAnimationOffset);
break;
}
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 85130c2..87c6370 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -215,18 +215,11 @@ gfx::Rect ShelfLayoutManager::GetIdealBounds() {
status_area_widget_->GetNativeView()));
int width = 0, height = 0;
GetShelfSize(&width, &height);
- switch (alignment_) {
- case SHELF_ALIGNMENT_BOTTOM:
- return gfx::Rect(bounds.x(), bounds.bottom() - height,
- bounds.width(), height);
- case SHELF_ALIGNMENT_LEFT:
- return gfx::Rect(bounds.x(), bounds.y(), width, bounds.height());
- case SHELF_ALIGNMENT_RIGHT:
- return gfx::Rect(bounds.right() - width, bounds.y(), width,
- bounds.height());
- }
- NOTREACHED();
- return gfx::Rect();
+ return SelectValueForShelfAlignment(
+ gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height),
+ gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()),
+ gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()),
+ gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height));
}
void ShelfLayoutManager::LayoutShelf() {
@@ -334,7 +327,7 @@ void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
const ui::GestureEvent& gesture) {
- bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM;
+ bool horizontal = IsHorizontalAlignment();
gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() :
gesture.details().scroll_x();
LayoutShelf();
@@ -360,7 +353,7 @@ ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
}
void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
- bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM;
+ bool horizontal = IsHorizontalAlignment();
bool should_change = false;
if (gesture.type() == ui::ET_GESTURE_SCROLL_END) {
// The visibility of the shelf changes only if the shelf was dragged X%
@@ -380,6 +373,7 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
correct_direction = gesture_drag_amount_ < 0;
break;
case SHELF_ALIGNMENT_LEFT:
+ case SHELF_ALIGNMENT_TOP:
correct_direction = gesture_drag_amount_ > 0;
break;
}
@@ -390,12 +384,11 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 :
fabs(gesture.details().velocity_x()) > 0;
} else {
- if (horizontal)
- should_change = gesture.details().velocity_y() < 0;
- else if (alignment_ == SHELF_ALIGNMENT_LEFT)
- should_change = gesture.details().velocity_x() > 0;
- else
- should_change = gesture.details().velocity_x() < 0;
+ should_change = SelectValueForShelfAlignment(
+ gesture.details().velocity_y() < 0,
+ gesture.details().velocity_x() > 0,
+ gesture.details().velocity_x() < 0,
+ gesture.details().velocity_y() > 0);
}
} else {
NOTREACHED();
@@ -479,7 +472,8 @@ void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active,
}
bool ShelfLayoutManager::IsHorizontalAlignment() const {
- return alignment_ == SHELF_ALIGNMENT_BOTTOM;
+ return alignment_ == SHELF_ALIGNMENT_BOTTOM ||
+ alignment_ == SHELF_ALIGNMENT_TOP;
}
// static
@@ -598,7 +592,7 @@ void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
gfx::Size status_size(status_area_widget_->GetWindowBoundsInScreen().size());
gfx::Size launcher_size = launcher_ ?
launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size();
- if (alignment_ == SHELF_ALIGNMENT_BOTTOM)
+ if (IsHorizontalAlignment())
*height = std::max(launcher_size.height(), status_size.height());
else
*width = std::max(launcher_size.width(), status_size.width());
@@ -606,17 +600,11 @@ void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset,
gfx::Rect* bounds) const {
- switch (alignment_) {
- case SHELF_ALIGNMENT_BOTTOM:
- bounds->Inset(gfx::Insets(0, 0, inset, 0));
- break;
- case SHELF_ALIGNMENT_LEFT:
- bounds->Inset(gfx::Insets(0, inset, 0, 0));
- break;
- case SHELF_ALIGNMENT_RIGHT:
- bounds->Inset(gfx::Insets(0, 0, 0, inset));
- break;
- }
+ bounds->Inset(SelectValueForShelfAlignment(
+ gfx::Insets(0, 0, inset, 0),
+ gfx::Insets(0, inset, 0, 0),
+ gfx::Insets(0, 0, 0, inset),
+ gfx::Insets(inset, 0, 0, 0)));
}
void ShelfLayoutManager::CalculateTargetBounds(
@@ -640,7 +628,7 @@ void ShelfLayoutManager::CalculateTargetBounds(
shelf_size = kAutoHideSize;
// Keep the launcher to its full height when dragging is in progress.
if (gesture_drag_status_ == GESTURE_DRAG_NONE) {
- if (SHELF_ALIGNMENT_BOTTOM == alignment_)
+ if (IsHorizontalAlignment())
launcher_size.set_height(kAutoHideSize);
else
launcher_size.set_width(kAutoHideSize);
@@ -690,6 +678,21 @@ void ShelfLayoutManager::CalculateTargetBounds(
target_bounds->work_area_insets.Set(
0, 0, 0, GetWorkAreaSize(state, launcher_size.width()));
break;
+ case SHELF_ALIGNMENT_TOP:
+ target_bounds->status_bounds_in_root = gfx::Rect(
+ base::i18n::IsRTL() ? available_bounds.x() :
+ available_bounds.right() - status_size.width(),
+ available_bounds.y() + launcher_size.height() - status_size.height(),
+ status_size.width(), status_size.height());
+ if (launcher_widget())
+ target_bounds->launcher_bounds_in_root = gfx::Rect(
+ available_bounds.x(),
+ available_bounds.y(),
+ available_bounds.width(),
+ launcher_size.height());
+ target_bounds->work_area_insets.Set(
+ GetWorkAreaSize(state, shelf_height), 0, 0, 0);
+ break;
}
target_bounds->opacity =
(gesture_drag_status_ != GESTURE_DRAG_NONE ||
@@ -702,7 +705,7 @@ void ShelfLayoutManager::CalculateTargetBounds(
void ShelfLayoutManager::UpdateTargetBoundsForGesture(
TargetBounds* target_bounds) const {
CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_);
- bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM;
+ bool horizontal = IsHorizontalAlignment();
int resistance_free_region = 0;
if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
@@ -718,13 +721,11 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
resistance_free_region -= kAutoHideSize;
}
- bool resist = false;
- if (horizontal)
- resist = gesture_drag_amount_ < -resistance_free_region;
- else if (alignment_ == SHELF_ALIGNMENT_LEFT)
- resist = gesture_drag_amount_ > resistance_free_region;
- else
- resist = gesture_drag_amount_ < -resistance_free_region;
+ bool resist = SelectValueForShelfAlignment(
+ gesture_drag_amount_ < -resistance_free_region,
+ gesture_drag_amount_ > resistance_free_region,
+ gesture_drag_amount_ < -resistance_free_region,
+ gesture_drag_amount_ > resistance_free_region);
float translate = 0.f;
if (resist) {
@@ -854,7 +855,8 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
-kNotificationBubbleGapHeight : 0,
alignment_ == SHELF_ALIGNMENT_LEFT ?
-kNotificationBubbleGapHeight : 0,
- 0);
+ alignment_ == SHELF_ALIGNMENT_TOP ?
+ -kNotificationBubbleGapHeight : 0);
}
return shelf_region.Contains(Shell::GetScreen()->GetCursorScreenPoint()) ?
SHELF_AUTO_HIDE_SHOWN : SHELF_AUTO_HIDE_HIDDEN;
@@ -877,6 +879,9 @@ void ShelfLayoutManager::UpdateHitTestBounds() {
case SHELF_ALIGNMENT_RIGHT:
insets.Set(0, kWorkspaceAreaBottomInset, 0, 0);
break;
+ case SHELF_ALIGNMENT_TOP:
+ insets.Set(0, 0, kWorkspaceAreaBottomInset, 0);
+ break;
}
}
if (launcher_widget() && launcher_widget()->GetNativeWindow()) {
diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h
index f58a4dc..de4425a 100644
--- a/ash/wm/shelf_layout_manager.h
+++ b/ash/wm/shelf_layout_manager.h
@@ -162,7 +162,7 @@ class ASH_EXPORT ShelfLayoutManager :
// A helper function that provides a shortcut for choosing
// values specific to a shelf alignment.
template<typename T>
- T SelectValueForShelfAlignment(T bottom, T left, T right) const {
+ T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const {
switch (alignment_) {
case SHELF_ALIGNMENT_BOTTOM:
return bottom;
@@ -170,6 +170,8 @@ class ASH_EXPORT ShelfLayoutManager :
return left;
case SHELF_ALIGNMENT_RIGHT:
return right;
+ case SHELF_ALIGNMENT_TOP:
+ return top;
}
NOTREACHED();
return right;
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index 7b07145..cabdb0e 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -602,7 +602,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
}
-// Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT.
+// Tests SHELF_ALIGNMENT_(LEFT, RIGHT, TOP).
TEST_F(ShelfLayoutManagerTest, SetAlignment) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
// Force an initial layout.
@@ -670,6 +670,35 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
display.GetWorkAreaInsets().right());
EXPECT_EQ(ShelfLayoutManager::kAutoHideSize,
display.bounds().right() - display.work_area().right());
+
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ shelf->SetAlignment(SHELF_ALIGNMENT_TOP);
+ display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
+ launcher_bounds = shelf->launcher_widget()->GetWindowBoundsInScreen();
+ display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
+ ASSERT_NE(-1, display.id());
+ EXPECT_EQ(shelf->GetIdealBounds().height(),
+ display.GetWorkAreaInsets().top());
+ EXPECT_GE(launcher_bounds.height(),
+ shelf->launcher_widget()->GetContentsView()->GetPreferredSize().height());
+ EXPECT_EQ(SHELF_ALIGNMENT_TOP, GetSystemTray()->shelf_alignment());
+ status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen());
+ EXPECT_GE(status_bounds.height(),
+ status_area_widget->GetContentsView()->GetPreferredSize().height());
+ EXPECT_EQ(shelf->GetIdealBounds().height(),
+ display.GetWorkAreaInsets().top());
+ EXPECT_EQ(0, display.GetWorkAreaInsets().right());
+ EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
+ EXPECT_EQ(0, display.GetWorkAreaInsets().left());
+ EXPECT_EQ(display.work_area().y(), launcher_bounds.bottom());
+ EXPECT_EQ(display.bounds().x(), launcher_bounds.x());
+ EXPECT_EQ(display.bounds().width(), launcher_bounds.width());
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
+ EXPECT_EQ(ShelfLayoutManager::kAutoHideSize,
+ display.GetWorkAreaInsets().top());
+ EXPECT_EQ(ShelfLayoutManager::kAutoHideSize,
+ display.work_area().y() - display.bounds().y());
}
TEST_F(ShelfLayoutManagerTest, GestureDrag) {