diff options
author | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-12 02:57:56 +0000 |
---|---|---|
committer | harrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-12 02:57:56 +0000 |
commit | 0ac231118b5ffa2ca76423c1ecc10ca47327596f (patch) | |
tree | fd7503398048811b348ea3b820e7600ada9946f3 | |
parent | 7177c4325ff6804e53ae62399a48e7af7b04abec (diff) | |
download | chromium_src-0ac231118b5ffa2ca76423c1ecc10ca47327596f.zip chromium_src-0ac231118b5ffa2ca76423c1ecc10ca47327596f.tar.gz chromium_src-0ac231118b5ffa2ca76423c1ecc10ca47327596f.tar.bz2 |
Shelf Cleanup AlternateShelfLayout P1 Attempt 3
R=skuhne@chromium.org
TBR=jamescook@chromium.org, miket@chromium.org, skuhne@chromium.org
BUG=338429
re-landing of https://codereview.chromium.org/176883022/ with fix for the inset of app panel as discussed offline /w jennyz@
Review URL: https://codereview.chromium.org/229453005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263451 0039d316-1c4b-4281-b951-d872f2087c98
40 files changed, 326 insertions, 1501 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index 903e4fd..ac9c945 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -243,8 +243,6 @@ 'session_state_delegate.h', 'session_state_observer.cc', 'session_state_observer.h', - 'shelf/alternate_app_list_button.cc', - 'shelf/alternate_app_list_button.h', 'shelf/app_list_button.cc', 'shelf/app_list_button.h', 'shelf/app_list_shelf_item_delegate.cc', diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc index a0e3975..f6bfeda 100644 --- a/ash/ash_switches.cc +++ b/ash/ash_switches.cc @@ -43,10 +43,6 @@ const char kAshDefaultWallpaperSmall[] = "ash-default-wallpaper-small"; const char kAshDisableAlternateFrameCaptionButtonStyle[] = "ash-disable-alternate-caption-button"; -// Disable the alternate shelf layout. -const char kAshDisableAlternateShelfLayout[] = - "ash-disable-alternate-shelf-layout"; - // Disable ability to dock windows at the desktop edge. const char kAshDisableDockedWindows[] = "ash-disable-docked-windows"; @@ -103,14 +99,6 @@ const char kAshSecondaryDisplayLayout[] = "ash-secondary-display-layout"; // Enables the heads-up display for tracking touch points. const char kAshTouchHud[] = "ash-touch-hud"; -// Use alternate layout of the shelf for testing a new look and feel: -// Slightly smaller profile, only 2 states for the "bar highlight" on -// launcher buttons, app list icon with more visible state indication, -// app list icon repositionable and defaulting as 1st item in shelf, -// more visible state indication for background on status area. -// crbug's [244983, 244990, 244994, 245005, 245012] -const char kAshUseAlternateShelfLayout[] = "ash-use-alternate-shelf"; - // Uses the 1st display in --ash-host-window-bounds as internal display. // This is for debugging on linux desktop. const char kAshUseFirstDisplayAsInternal[] = @@ -134,11 +122,6 @@ bool UseAlternateFrameCaptionButtonStyle() { HasSwitch(kAshDisableAlternateFrameCaptionButtonStyle); } -bool UseAlternateShelfLayout() { - return !CommandLine::ForCurrentProcess()-> - HasSwitch(kAshDisableAlternateShelfLayout); -} - bool UseDockedWindows() { return !CommandLine::ForCurrentProcess()->HasSwitch(kAshDisableDockedWindows); } diff --git a/ash/ash_switches.h b/ash/ash_switches.h index 829ee96..6b1e01f 100644 --- a/ash/ash_switches.h +++ b/ash/ash_switches.h @@ -25,7 +25,6 @@ ASH_EXPORT extern const char kAshDefaultWallpaperIsOem[]; ASH_EXPORT extern const char kAshDefaultWallpaperLarge[]; ASH_EXPORT extern const char kAshDefaultWallpaperSmall[]; ASH_EXPORT extern const char kAshDisableAlternateFrameCaptionButtonStyle[]; -ASH_EXPORT extern const char kAshDisableAlternateShelfLayout[]; ASH_EXPORT extern const char kAshDisableDockedWindows[]; ASH_EXPORT extern const char kAshEnableAlternateFrameCaptionButtonStyle[]; #if defined(OS_CHROMEOS) @@ -42,7 +41,6 @@ ASH_EXPORT extern const char kAshHideNotificationsForFactory[]; ASH_EXPORT extern const char kAshHostWindowBounds[]; ASH_EXPORT extern const char kAshSecondaryDisplayLayout[]; ASH_EXPORT extern const char kAshTouchHud[]; -ASH_EXPORT extern const char kAshUseAlternateShelfLayout[]; ASH_EXPORT extern const char kAshUseFirstDisplayAsInternal[]; ASH_EXPORT extern const char kAuraLegacyPowerButton[]; #if defined(OS_WIN) @@ -53,9 +51,6 @@ ASH_EXPORT extern const char kForceAshToDesktop[]; // maximize, restore, close) should be used. ASH_EXPORT bool UseAlternateFrameCaptionButtonStyle(); -// Returns true if the alternate shelf layout should be used. -ASH_EXPORT bool UseAlternateShelfLayout(); - // Returns true if items can be dragged off the shelf to unpin. ASH_EXPORT bool UseDragOffShelf(); diff --git a/ash/dip_unittest.cc b/ash/dip_unittest.cc index d50fd4c..ccae332 100644 --- a/ash/dip_unittest.cc +++ b/ash/dip_unittest.cc @@ -69,43 +69,4 @@ TEST_F(DIPTest, WorkArea) { shelf->shelf_widget()->GetNativeView()->layer()->bounds().height()); } -TEST_F(DIPTest, WorkAreaForLegacyShelfLayout) { - CommandLine::ForCurrentProcess()->AppendSwitch( - ash::switches::kAshDisableAlternateShelfLayout); - UpdateDisplay("1000x900*1.0f"); - - aura::Window* root = Shell::GetPrimaryRootWindow(); - const gfx::Display display = - Shell::GetScreen()->GetDisplayNearestWindow(root); - - EXPECT_EQ("0,0 1000x900", display.bounds().ToString()); - gfx::Rect work_area = display.work_area(); - EXPECT_EQ("0,0 1000x852", work_area.ToString()); - EXPECT_EQ("0,0,48,0", display.bounds().InsetsFrom(work_area).ToString()); - - UpdateDisplay("2000x1800*2.0f"); - gfx::Screen* screen = Shell::GetScreen(); - - const gfx::Display display_2x = screen->GetDisplayNearestWindow(root); - const DisplayInfo display_info_2x = - Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id()); - - // The |bounds_in_native()| should report bounds in pixel coordinate. - EXPECT_EQ("1,1 2000x1800", - display_info_2x.bounds_in_native().ToString()); - - // Aura and views coordinates are in DIP, so they their bounds do not change. - EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString()); - work_area = display_2x.work_area(); - EXPECT_EQ("0,0 1000x852", work_area.ToString()); - EXPECT_EQ("0,0,48,0", display_2x.bounds().InsetsFrom(work_area).ToString()); - - // Sanity check if the workarea's inset hight is same as - // the shelf's height. - Shelf* shelf = Shelf::ForPrimaryDisplay(); - EXPECT_EQ( - display_2x.bounds().InsetsFrom(work_area).height(), - shelf->shelf_widget()->GetNativeView()->layer()->bounds().height()); -} - } // namespace ash diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc index faaa23c..3da1368 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/display_controller_unittest.cc @@ -790,99 +790,6 @@ TEST_F(DisplayControllerTest, FindNearestDisplay) { gfx::Point(300, 400)).id()); } -TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) { - if (!SupportsMultipleDisplays()) - return; - - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kAshDisableAlternateShelfLayout); - - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); - DisplayManager* display_manager = Shell::GetInstance()->display_manager(); - - UpdateDisplay("200x200,300x300"); - gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); - - DisplayLayout display_layout(DisplayLayout::RIGHT, 50); - display_manager->SetLayoutForCurrentDisplays(display_layout); - - EXPECT_NE(primary_display.id(), secondary_display.id()); - aura::Window* primary_root = - display_controller->GetRootWindowForDisplayId(primary_display.id()); - aura::Window* secondary_root = - display_controller->GetRootWindowForDisplayId(secondary_display.id()); - EXPECT_NE(primary_root, secondary_root); - aura::Window* shelf_window = - Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); - EXPECT_TRUE(primary_root->Contains(shelf_window)); - EXPECT_FALSE(secondary_root->Contains(shelf_window)); - EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint( - gfx::Point(-100, -100)).id()); - EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); - - EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); - EXPECT_EQ("0,0 200x152", primary_display.work_area().ToString()); - EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); - EXPECT_EQ("200,0 300x252", secondary_display.work_area().ToString()); - EXPECT_EQ("right, 50", - display_manager->GetCurrentDisplayLayout().ToString()); - - // Switch primary and secondary - display_controller->SetPrimaryDisplay(secondary_display); - const DisplayLayout& inverted_layout = - display_manager->GetCurrentDisplayLayout(); - EXPECT_EQ("left, -50", inverted_layout.ToString()); - - EXPECT_EQ(secondary_display.id(), - Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); - EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint( - gfx::Point(-100, -100)).id()); - EXPECT_EQ(secondary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); - - EXPECT_EQ( - primary_root, - display_controller->GetRootWindowForDisplayId(secondary_display.id())); - EXPECT_EQ( - secondary_root, - display_controller->GetRootWindowForDisplayId(primary_display.id())); - EXPECT_TRUE(primary_root->Contains(shelf_window)); - EXPECT_FALSE(secondary_root->Contains(shelf_window)); - - // Test if the bounds are correctly swapped. - gfx::Display swapped_primary = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); - EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); - EXPECT_EQ("0,0 300x252", swapped_primary.work_area().ToString()); - EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); - - EXPECT_EQ("-200,-50 200x152", swapped_secondary.work_area().ToString()); - - aura::WindowTracker tracker; - tracker.Add(primary_root); - tracker.Add(secondary_root); - - // Deleting 2nd display should move the primary to original primary display. - UpdateDisplay("200x200"); - RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. - EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); - EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint( - gfx::Point(-100, -100)).id()); - EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); - EXPECT_TRUE(tracker.Contains(primary_root)); - EXPECT_FALSE(tracker.Contains(secondary_root)); - EXPECT_TRUE(primary_root->Contains(shelf_window)); -} - TEST_F(DisplayControllerTest, SwapPrimaryById) { if (!SupportsMultipleDisplays()) return; diff --git a/ash/resources/ash_resources.grd b/ash/resources/ash_resources.grd index 5b00acf..bfbb809 100644 --- a/ash/resources/ash_resources.grd +++ b/ash/resources/ash_resources.grd @@ -20,18 +20,14 @@ <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_BACKGROUND" file="common/launcher/launcher_background.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_CORNER" file="common/launcher/launcher_corner.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_DIMMING" file="common/launcher/launcher_dimming.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_ICON_APPLIST" file="common/launcher/launcher_appmenu.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_ICON_APPLIST_ALTERNATE" file="common/alt_launcher/status_app_menu_icon.png" /> + <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_ICON_APPLIST" file="common/alt_launcher/status_app_menu_icon.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_ICON_APPLIST_HOT" file="common/launcher/launcher_appmenu_hover.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_ICON_APPLIST_PUSHED" file="common/launcher/launcher_appmenu_pressed.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_LIST_BROWSER" file="common/launcher/window_switcher_icon_normal.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_LIST_INCOGNITO_BROWSER" file="common/launcher/window_switcher_icon_incognito.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_OVERFLOW" file="common/launcher/launcher_overflow.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_ACTIVE" file="common/launcher/launcher_underline_bottom_active.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_ACTIVE_ALTERNATE" file="common/alt_launcher/launcher_underline_active.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_HOVER" file="common/launcher/launcher_underline_bottom_hover.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_RUNNING" file="common/launcher/launcher_underline_bottom_running.png" /> - <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_RUNNING_ALTERNATE" file="common/alt_launcher/launcher_underline_running.png" /> + <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_ACTIVE" file="common/alt_launcher/launcher_underline_active.png" /> + <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_UNDERLINE_RUNNING" file="common/alt_launcher/launcher_underline_running.png" /> <structure type="chrome_scaled_image" name="IDR_ASH_SHELF_ICON_TASK_MANAGER" file="common/launcher/task_manager.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_MULTI_WINDOW_RESIZE_H" file="common/multi_window_resize_horizontal.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_MULTI_WINDOW_RESIZE_V" file="common/multi_window_resize_vertical.png" /> diff --git a/ash/shelf/alternate_app_list_button.h b/ash/shelf/alternate_app_list_button.h deleted file mode 100644 index bd95632..0000000 --- a/ash/shelf/alternate_app_list_button.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SHELF_ALTERNATE_APP_LIST_BUTTON_H_ -#define ASH_SHELF_ALTERNATE_APP_LIST_BUTTON_H_ - -#include "ui/views/controls/button/image_button.h" - -namespace ash { -class ShelfButtonHost; -class ShelfWidget; - -// Button used for the AppList icon on the shelf. -// This class is an alternate implementation to ash::AppListButton -// for the purposes of testing an alternate shelf layout -// (see ash_switches: UseAlternateShelfLayout). -class AlternateAppListButton : public views::ImageButton { - public: - // Bounds size (inset) required for the app icon image (in pixels). - static const int kImageBoundsSize; - - AlternateAppListButton(views::ButtonListener* listener, - ShelfButtonHost* host, - ShelfWidget* shelf_widget); - virtual ~AlternateAppListButton(); - - protected: - // views::ImageButton overrides: - virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseCaptureLost() OVERRIDE; - virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; - - // ui::EventHandler overrides: - virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; - - private: - ShelfButtonHost* host_; - // Reference to the shelf widget containing this button, owned by the - // root window controller. - ShelfWidget* shelf_widget_; - - DISALLOW_COPY_AND_ASSIGN(AlternateAppListButton); -}; - -} // namespace ash - -#endif // ASH_SHELF_ALTERNATE_APP_LIST_BUTTON_H_ diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc index 8b1aca5..d1246c8 100644 --- a/ash/shelf/app_list_button.cc +++ b/ash/shelf/app_list_button.cc @@ -1,14 +1,17 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/shelf/app_list_button.h" -#include <vector> - #include "ash/ash_constants.h" +#include "ash/ash_switches.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_button_host.h" -#include "ash/shelf/shelf_constants.h" +#include "ash/shelf/shelf_item_types.h" +#include "ash/shelf/shelf_layout_manager.h" +#include "ash/shelf/shelf_widget.h" +#include "ash/shell.h" #include "grit/ash_resources.h" #include "grit/ash_strings.h" #include "ui/accessibility/ax_view_state.h" @@ -18,27 +21,24 @@ #include "ui/compositor/layer_animation_element.h" #include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/scoped_layer_animation_settings.h" +#include "ui/gfx/canvas.h" +#include "ui/gfx/image/image_skia_operations.h" +#include "ui/views/controls/button/image_button.h" #include "ui/views/painter.h" namespace ash { +// static +const int AppListButton::kImageBoundsSize = 7; -const int kAnimationDurationInMs = 600; -const float kAnimationOpacity[] = { 1.0f, 0.4f, 1.0f }; AppListButton::AppListButton(views::ButtonListener* listener, - ShelfButtonHost* host) + ShelfButtonHost* host, + ShelfWidget* shelf_widget) : views::ImageButton(listener), - host_(host) { - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - SetImage(views::CustomButton::STATE_NORMAL, - rb.GetImageNamed(IDR_ASH_SHELF_ICON_APPLIST).ToImageSkia()); - SetImage(views::CustomButton::STATE_HOVERED, - rb.GetImageNamed(IDR_ASH_SHELF_ICON_APPLIST_HOT).ToImageSkia()); - SetImage(views::CustomButton::STATE_PRESSED, - rb.GetImageNamed(IDR_ASH_SHELF_ICON_APPLIST_PUSHED).ToImageSkia()); + host_(host), + shelf_widget_(shelf_widget) { SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE)); - SetSize(gfx::Size(kShelfPreferredSize, kShelfPreferredSize)); - SetImageAlignment(ImageButton::ALIGN_CENTER, ImageButton::ALIGN_TOP); + SetSize(gfx::Size(kShelfSize, kShelfSize)); SetFocusPainter(views::Painter::CreateSolidFocusPainter( kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); } @@ -46,40 +46,6 @@ AppListButton::AppListButton(views::ButtonListener* listener, AppListButton::~AppListButton() { } -void AppListButton::StartLoadingAnimation() { - layer()->GetAnimator()->StopAnimating(); - - scoped_ptr<ui::LayerAnimationSequence> opacity_sequence( - new ui::LayerAnimationSequence()); - - opacity_sequence->set_is_cyclic(true); - - for (size_t i = 0; i < arraysize(kAnimationOpacity); ++i) { - opacity_sequence->AddElement( - ui::LayerAnimationElement::CreateOpacityElement( - kAnimationOpacity[i], - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); - } - - opacity_sequence->AddElement( - ui::LayerAnimationElement::CreatePauseElement( - ui::LayerAnimationElement::OPACITY, - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs))); - - // LayerAnimator takes ownership of the sequences. - layer()->GetAnimator()->ScheduleAnimation(opacity_sequence.release()); -} - -void AppListButton::StopLoadingAnimation() { - layer()->GetAnimator()->StopAnimating(); - - ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); - settings.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kAnimationDurationInMs)); - layer()->SetOpacity(1.0f); - layer()->SetTransform(gfx::Transform()); -} - bool AppListButton::OnMousePressed(const ui::MouseEvent& event) { ImageButton::OnMousePressed(event); host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event); @@ -117,6 +83,84 @@ void AppListButton::OnMouseExited(const ui::MouseEvent& event) { host_->MouseExitedButton(this); } +void AppListButton::OnGestureEvent(ui::GestureEvent* event) { + switch (event->type()) { + case ui::ET_GESTURE_SCROLL_BEGIN: + host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event); + event->SetHandled(); + return; + case ui::ET_GESTURE_SCROLL_UPDATE: + host_->PointerDraggedOnButton(this, ShelfButtonHost::TOUCH, *event); + event->SetHandled(); + return; + case ui::ET_GESTURE_SCROLL_END: + case ui::ET_SCROLL_FLING_START: + host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false); + event->SetHandled(); + return; + default: + ImageButton::OnGestureEvent(event); + return; + } +} + +void AppListButton::OnPaint(gfx::Canvas* canvas) { + // Call the base class first to paint any background/borders. + View::OnPaint(canvas); + + int background_image_id = 0; + if (Shell::GetInstance()->GetAppListTargetVisibility()) { + background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; + } else { + if (shelf_widget_->GetDimsShelf()) + background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; + else + background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; + } + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + const gfx::ImageSkia* background_image = + rb.GetImageNamed(background_image_id).ToImageSkia(); + const gfx::ImageSkia* forground_image = + rb.GetImageNamed(IDR_ASH_SHELF_ICON_APPLIST).ToImageSkia(); + + gfx::Rect contents_bounds = GetContentsBounds(); + gfx::Rect background_bounds, forground_bounds; + + ShelfAlignment alignment = shelf_widget_->GetAlignment(); + background_bounds.set_size(background_image->size()); + if (alignment == SHELF_ALIGNMENT_LEFT) { + background_bounds.set_x(contents_bounds.width() - + ShelfLayoutManager::kShelfItemInset - background_image->width()); + background_bounds.set_y(contents_bounds.y() + + (contents_bounds.height() - background_image->height()) / 2); + } else if(alignment == SHELF_ALIGNMENT_RIGHT) { + background_bounds.set_x(ShelfLayoutManager::kShelfItemInset); + background_bounds.set_y(contents_bounds.y() + + (contents_bounds.height() - background_image->height()) / 2); + } else { + background_bounds.set_y(ShelfLayoutManager::kShelfItemInset); + background_bounds.set_x(contents_bounds.x() + + (contents_bounds.width() - background_image->width()) / 2); + } + + forground_bounds.set_size(forground_image->size()); + forground_bounds.set_x(background_bounds.x() + + std::max(0, + (background_bounds.width() - forground_bounds.width()) / 2)); + forground_bounds.set_y(background_bounds.y() + + std::max(0, + (background_bounds.height() - forground_bounds.height()) / 2)); + + canvas->DrawImageInt(*background_image, + background_bounds.x(), + background_bounds.y()); + canvas->DrawImageInt(*forground_image, + forground_bounds.x(), + forground_bounds.y()); + + views::Painter::PaintFocusPainter(this, canvas, focus_painter()); +} + void AppListButton::GetAccessibleState(ui::AXViewState* state) { state->role = ui::AX_ROLE_BUTTON; state->name = host_->GetAccessibleName(this); diff --git a/ash/shelf/app_list_button.h b/ash/shelf/app_list_button.h index c47fd6d..2571b71 100644 --- a/ash/shelf/app_list_button.h +++ b/ash/shelf/app_list_button.h @@ -1,4 +1,4 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,18 +9,21 @@ namespace ash { class ShelfButtonHost; +class ShelfWidget; // Button used for the AppList icon on the shelf. class AppListButton : public views::ImageButton { public: - AppListButton(views::ButtonListener* listener, ShelfButtonHost* host); - virtual ~AppListButton(); + // Bounds size (inset) required for the app icon image (in pixels). + static const int kImageBoundsSize; - void StartLoadingAnimation(); - void StopLoadingAnimation(); + AppListButton(views::ButtonListener* listener, + ShelfButtonHost* host, + ShelfWidget* shelf_widget); + virtual ~AppListButton(); protected: - // views::ImageButton: + // views::ImageButton overrides: virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseCaptureLost() OVERRIDE; @@ -28,10 +31,17 @@ class AppListButton : public views::ImageButton { virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; + // ui::EventHandler overrides: + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + private: ShelfButtonHost* host_; + // Reference to the shelf widget containing this button, owned by the + // root window controller. + ShelfWidget* shelf_widget_; DISALLOW_COPY_AND_ASSIGN(AppListButton); }; diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/shelf/overflow_bubble_view.cc index 720a693..1aa025b 100644 --- a/ash/shelf/overflow_bubble_view.cc +++ b/ash/shelf/overflow_bubble_view.cc @@ -184,7 +184,7 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() { views::BubbleBorder::is_arrow_on_horizontal(arrow()) ? bubble_insets.left() : bubble_insets.top(); const int arrow_offset = border_size + kPadding + kShelfViewLeadingInset + - ShelfLayoutManager::GetPreferredShelfSize() / 2; + kShelfSize / 2; const gfx::Size content_size = GetPreferredSize(); border->set_arrow_offset(arrow_offset); diff --git a/ash/shelf/overflow_button.cc b/ash/shelf/overflow_button.cc index 7a40e6a..5e6c607 100644 --- a/ash/shelf/overflow_button.cc +++ b/ash/shelf/overflow_button.cc @@ -88,56 +88,35 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) { ShelfAlignment alignment = layout_manager->GetAlignment(); gfx::Rect bounds(GetContentsBounds()); - if (ash::switches::UseAlternateShelfLayout()) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - int background_image_id = 0; - if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) - background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; - else if(layout_manager->shelf_widget()->GetDimsShelf()) - background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; - else - background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; - - const gfx::ImageSkia* background = - rb.GetImageNamed(background_image_id).ToImageSkia(); - if (alignment == SHELF_ALIGNMENT_LEFT) { - bounds = gfx::Rect( - bounds.right() - background->width() - - ShelfLayoutManager::kShelfItemInset, - bounds.y() + (bounds.height() - background->height()) / 2, - background->width(), background->height()); - } else if (alignment == SHELF_ALIGNMENT_RIGHT) { - bounds = gfx::Rect( - bounds.x() + ShelfLayoutManager::kShelfItemInset, - bounds.y() + (bounds.height() - background->height()) / 2, - background->width(), background->height()); - } else { - bounds = gfx::Rect( - bounds.x() + (bounds.width() - background->width()) / 2, - bounds.y() + ShelfLayoutManager::kShelfItemInset, - background->width(), background->height()); - } - canvas->DrawImageInt(*background, bounds.x(), bounds.y()); + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + int background_image_id = 0; + if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) + background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; + else if(layout_manager->shelf_widget()->GetDimsShelf()) + background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; + else + background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; + + const gfx::ImageSkia* background = + rb.GetImageNamed(background_image_id).ToImageSkia(); + if (alignment == SHELF_ALIGNMENT_LEFT) { + bounds = gfx::Rect( + bounds.right() - background->width() - + ShelfLayoutManager::kShelfItemInset, + bounds.y() + (bounds.height() - background->height()) / 2, + background->width(), background->height()); + } else if (alignment == SHELF_ALIGNMENT_RIGHT) { + bounds = gfx::Rect( + bounds.x() + ShelfLayoutManager::kShelfItemInset, + bounds.y() + (bounds.height() - background->height()) / 2, + background->width(), background->height()); } else { - if (alignment == SHELF_ALIGNMENT_BOTTOM) { - bounds = gfx::Rect( - bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, - bounds.y() + kBackgroundOffset - 1, - kButtonHoverSize, kButtonHoverSize); - } else { - bounds = gfx::Rect( - bounds.x() + kBackgroundOffset -1, - bounds.y() + ((bounds.height() - kButtonHoverSize) / 2) -1, - kButtonHoverSize, kButtonHoverSize); - } - if (hover_animation_->is_animating()) { - PaintBackground( - canvas, - kButtonHoverAlpha * hover_animation_->GetCurrentValue()); - } else if (state() == STATE_HOVERED || state() == STATE_PRESSED) { - PaintBackground(canvas, kButtonHoverAlpha); - } + bounds = gfx::Rect( + bounds.x() + (bounds.width() - background->width()) / 2, + bounds.y() + ShelfLayoutManager::kShelfItemInset, + background->width(), background->height()); } + canvas->DrawImageInt(*background, bounds.x(), bounds.y()); if (height() < kButtonHoverSize) return; diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc index 2aa6360..fb255d7 100644 --- a/ash/shelf/shelf_button.cc +++ b/ash/shelf/shelf_button.cc @@ -31,20 +31,10 @@ namespace { // if the shelf is aligned horizontally then this is the height of the bar. const int kBarSize = 3; const int kIconSize = 32; -const int kHopSpacing = 2; -const int kIconPad = 8; -const int kAlternateIconPad = 5; -const int kAlternateIconPadVertical = 6; -const int kHopUpMS = 0; -const int kHopDownMS = 200; +const int kIconPad = 5; +const int kIconPadVertical = 6; const int kAttentionThrobDurationMS = 800; -bool ShouldHop(int state) { - return state & ash::ShelfButton::STATE_HOVERED || - state & ash::ShelfButton::STATE_ACTIVE || - state & ash::ShelfButton::STATE_FOCUSED; -} - // Simple AnimationDelegate that owns a single ThrobAnimation instance to // keep all Draw Attention animations in sync. class ShelfButtonAnimation : public gfx::AnimationDelegate { @@ -297,13 +287,6 @@ const gfx::ImageSkia& ShelfButton::GetImage() const { void ShelfButton::AddState(State state) { if (!(state_ & state)) { - if (!ash::switches::UseAlternateShelfLayout() && - (ShouldHop(state) || !ShouldHop(state_))) { - ui::ScopedLayerAnimationSettings scoped_setter( - icon_view_->layer()->GetAnimator()); - scoped_setter.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kHopUpMS)); - } state_ |= state; Layout(); if (state & STATE_ATTENTION) @@ -313,14 +296,6 @@ void ShelfButton::AddState(State state) { void ShelfButton::ClearState(State state) { if (state_ & state) { - if (!ash::switches::UseAlternateShelfLayout() && - (!ShouldHop(state) || ShouldHop(state_))) { - ui::ScopedLayerAnimationSettings scoped_setter( - icon_view_->layer()->GetAnimator()); - scoped_setter.SetTweenType(gfx::Tween::LINEAR); - scoped_setter.SetTransitionDuration( - base::TimeDelta::FromMilliseconds(kHopDownMS)); - } state_ &= ~state; Layout(); if (state & STATE_ATTENTION) @@ -398,12 +373,9 @@ void ShelfButton::GetAccessibleState(ui::AXViewState* state) { void ShelfButton::Layout() { const gfx::Rect button_bounds(GetContentsBounds()); - int icon_pad = kIconPad; - if (ash::switches::UseAlternateShelfLayout()) { - icon_pad = - shelf_layout_manager_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM ? - kAlternateIconPadVertical : kAlternateIconPad; - } + int icon_pad = + shelf_layout_manager_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM ? + kIconPadVertical : kIconPad; int x_offset = shelf_layout_manager_->PrimaryAxisValue(0, icon_pad); int y_offset = shelf_layout_manager_->PrimaryAxisValue(icon_pad, 0); @@ -420,13 +392,6 @@ void ShelfButton::Layout() { if (SHELF_ALIGNMENT_TOP == shelf_layout_manager_->GetAlignment()) y_offset = button_bounds.height() - (kIconSize + icon_pad); - if (ShouldHop(state_) && !ash::switches::UseAlternateShelfLayout()) { - x_offset += shelf_layout_manager_->SelectValueForShelfAlignment( - 0, kHopSpacing, -kHopSpacing, 0); - y_offset += shelf_layout_manager_->SelectValueForShelfAlignment( - -kHopSpacing, 0, 0, kHopSpacing); - } - // Center icon with respect to the secondary axis, and ensure // that the icon doesn't occlude the bar highlight. if (shelf_layout_manager_->IsHorizontalAlignment()) { @@ -544,19 +509,10 @@ void ShelfButton::UpdateBar() { } int bar_id = 0; - if (ash::switches::UseAlternateShelfLayout()) { - if (state_ & STATE_ACTIVE) - bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE_ALTERNATE; - else if (state_ & STATE_RUNNING) - bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING_ALTERNATE; - } else { - if (state_ & (STATE_ACTIVE | STATE_ATTENTION)) - bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; - else if (state_ & (STATE_HOVERED | STATE_FOCUSED)) - bar_id = IDR_ASH_SHELF_UNDERLINE_HOVER; - else - bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; - } + if (state_ & STATE_ACTIVE) + bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; + else if (state_ & STATE_RUNNING) + bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; if (bar_id != 0) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); diff --git a/ash/shelf/shelf_constants.cc b/ash/shelf/shelf_constants.cc index b180496..568c657 100644 --- a/ash/shelf/shelf_constants.cc +++ b/ash/shelf/shelf_constants.cc @@ -6,10 +6,12 @@ namespace ash { -const int kShelfPreferredSize = 48; const int kShelfBackgroundAlpha = 204; const int kInvalidImageResourceID = -1; const int kInvalidShelfID = 0; +const int kShelfSize = 47; +const int kShelfButtonSpacing = 10; +const int kShelfButtonSize = 44; const int kTimeToSwitchBackgroundMs = 1000; } // namespace ash diff --git a/ash/shelf/shelf_constants.h b/ash/shelf/shelf_constants.h index 9ae0b73..67d8489f 100644 --- a/ash/shelf/shelf_constants.h +++ b/ash/shelf/shelf_constants.h @@ -9,9 +9,6 @@ namespace ash { -// Height of the shelf. Hard coded to avoid resizing as items are added/removed. -ASH_EXPORT extern const int kShelfPreferredSize; - // Max alpha of the shelf background. ASH_EXPORT extern const int kShelfBackgroundAlpha; @@ -20,6 +17,15 @@ extern const int kInvalidImageResourceID; extern const int kInvalidShelfID; +// Size of the shelf when visible (height when the shelf is horizontal). +ASH_EXPORT extern const int kShelfSize; + +// Size of the space between buttons on the shelf. +ASH_EXPORT extern const int kShelfButtonSpacing; + +// Size allocated for each button on the shelf. +ASH_EXPORT extern const int kShelfButtonSize; + // Animation duration for switching black shelf and dock background on and off. ASH_EXPORT extern const int kTimeToSwitchBackgroundMs; diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 2a24805..6d72a4a 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -94,16 +94,8 @@ const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5; const int ShelfLayoutManager::kAutoHideSize = 3; // static -const int ShelfLayoutManager::kShelfSize = 47; - -// static const int ShelfLayoutManager::kShelfItemInset = 3; -int ShelfLayoutManager::GetPreferredShelfSize() { - return ash::switches::UseAlternateShelfLayout() ? - ShelfLayoutManager::kShelfSize : kShelfPreferredSize; -} - // ShelfLayoutManager::AutoHideEventFilter ------------------------------------- // Notifies ShelfLayoutManager any time the mouse moves. @@ -758,9 +750,9 @@ void ShelfLayoutManager::GetShelfSize(int* width, int* height) { gfx::Size status_size( shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); if (IsHorizontalAlignment()) - *height = GetPreferredShelfSize(); + *height = kShelfSize; else - *width = GetPreferredShelfSize(); + *width = kShelfSize; } void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, @@ -812,27 +804,21 @@ void ShelfLayoutManager::CalculateTargetBounds( gfx::Rect(available_bounds.x(), available_bounds.y(), available_bounds.width(), shelf_height)); - int status_inset = std::max(0, GetPreferredShelfSize() - - PrimaryAxisValue(status_size.height(), status_size.width())); - - if (ash::switches::UseAlternateShelfLayout()) { - status_inset = 0; - if (IsHorizontalAlignment()) - status_size.set_height(kShelfSize); - else - status_size.set_width(kShelfSize); - } + if (IsHorizontalAlignment()) + status_size.set_height(kShelfSize); + else + status_size.set_width(kShelfSize); target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment( gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), - status_inset, status_size.width(), status_size.height()), - gfx::Rect(shelf_width - (status_size.width() + status_inset), + 0, status_size.width(), status_size.height()), + gfx::Rect(shelf_width - status_size.width(), shelf_height - status_size.height(), status_size.width(), status_size.height()), - gfx::Rect(status_inset, shelf_height - status_size.height(), + gfx::Rect(0, shelf_height - status_size.height(), status_size.width(), status_size.height()), gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), - shelf_height - (status_size.height() + status_inset), + shelf_height - status_size.height(), status_size.width(), status_size.height())); target_bounds->work_area_insets = SelectValueForShelfAlignment( @@ -901,7 +887,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( // changed since then, e.g. because the tray-menu was shown because of the // drag), then allow the drag some resistance-free region at first to make // sure the shelf sticks with the finger until the shelf is visible. - resistance_free_region = GetPreferredShelfSize() - kAutoHideSize; + resistance_free_region = kShelfSize - kAutoHideSize; } bool resist = SelectValueForShelfAlignment( @@ -932,16 +918,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( available_bounds.bottom() - shelf_height); } - if (ash::switches::UseAlternateShelfLayout()) { - target_bounds->status_bounds_in_shelf.set_y(0); - } else { - // The statusbar should be in the center of the shelf. - gfx::Rect status_y = target_bounds->shelf_bounds_in_root; - status_y.set_y(0); - status_y.ClampToCenteredSize( - target_bounds->status_bounds_in_shelf.size()); - target_bounds->status_bounds_in_shelf.set_y(status_y.y()); - } + target_bounds->status_bounds_in_shelf.set_y(0); } else { // Move and size the shelf with the gesture. int shelf_width = target_bounds->shelf_bounds_in_root.width(); @@ -957,21 +934,12 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( available_bounds.right() - shelf_width); } - if (ash::switches::UseAlternateShelfLayout()) { - if (right_aligned) - target_bounds->status_bounds_in_shelf.set_x(0); - else - target_bounds->status_bounds_in_shelf.set_x( - target_bounds->shelf_bounds_in_root.width() - - kShelfSize); - } else { - // The statusbar should be in the center of the shelf. - gfx::Rect status_x = target_bounds->shelf_bounds_in_root; - status_x.set_x(0); - status_x.ClampToCenteredSize( - target_bounds->status_bounds_in_shelf.size()); - target_bounds->status_bounds_in_shelf.set_x(status_x.x()); - } + if (right_aligned) + target_bounds->status_bounds_in_shelf.set_x(0); + else + target_bounds->status_bounds_in_shelf.set_x( + target_bounds->shelf_bounds_in_root.width() - + kShelfSize); } } diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h index 8e1d30b..d1db4d9 100644 --- a/ash/shelf/shelf_layout_manager.h +++ b/ash/shelf/shelf_layout_manager.h @@ -74,18 +74,10 @@ class ASH_EXPORT ShelfLayoutManager : // Size of the shelf when auto-hidden. static const int kAutoHideSize; - // The size of the shelf when shown (currently only used in alternate - // settings see ash::switches::UseAlternateShelfLayout). - static const int kShelfSize; - // Inset between the inner edge of the shelf (towards centre of screen), and // the shelf items, notifications, status area etc. static const int kShelfItemInset; - // Returns the preferred size for the shelf (either kShelfPreferredSize or - // kShelfSize). - static int GetPreferredShelfSize(); - explicit ShelfLayoutManager(ShelfWidget* shelf); virtual ~ShelfLayoutManager(); diff --git a/ash/shelf/shelf_model.cc b/ash/shelf/shelf_model.cc index 2760d8f..e04af42 100644 --- a/ash/shelf/shelf_model.cc +++ b/ash/shelf/shelf_model.cc @@ -14,44 +14,24 @@ namespace ash { namespace { int ShelfItemTypeToWeight(ShelfItemType type) { - if (ash::switches::UseAlternateShelfLayout()) { - switch (type) { - case TYPE_APP_LIST: - // TODO(skuhne): If the app list item becomes movable again, this need - // to be a fallthrough. - return 0; - case TYPE_BROWSER_SHORTCUT: - case TYPE_APP_SHORTCUT: - return 1; - case TYPE_WINDOWED_APP: - case TYPE_PLATFORM_APP: - return 2; - case TYPE_DIALOG: - return 3; - case TYPE_APP_PANEL: - return 4; - case TYPE_UNDEFINED: - NOTREACHED() << "ShelfItemType must be set"; - return -1; - } - } else { - switch (type) { - case TYPE_BROWSER_SHORTCUT: - case TYPE_APP_SHORTCUT: - return 0; - case TYPE_WINDOWED_APP: - case TYPE_PLATFORM_APP: - return 1; - case TYPE_APP_LIST: - return 2; - case TYPE_DIALOG: - return 3; - case TYPE_APP_PANEL: - return 4; - case TYPE_UNDEFINED: - NOTREACHED() << "ShelfItemType must be set"; - return -1; - } + switch (type) { + case TYPE_APP_LIST: + // TODO(skuhne): If the app list item becomes movable again, this need + // to be a fallthrough. + return 0; + case TYPE_BROWSER_SHORTCUT: + case TYPE_APP_SHORTCUT: + return 1; + case TYPE_WINDOWED_APP: + case TYPE_PLATFORM_APP: + return 2; + case TYPE_DIALOG: + return 3; + case TYPE_APP_PANEL: + return 4; + case TYPE_UNDEFINED: + NOTREACHED() << "ShelfItemType must be set"; + return -1; } NOTREACHED() << "Invalid type " << type; @@ -187,8 +167,7 @@ void ShelfModel::RemoveObserver(ShelfModelObserver* observer) { } int ShelfModel::ValidateInsertionIndex(ShelfItemType type, int index) const { - DCHECK(index >= 0 && index <= item_count() + - (ash::switches::UseAlternateShelfLayout() ? 1 : 0)); + DCHECK(index >= 0 && index <= item_count() + 1); // Clamp |index| to the allowed range for the type as determined by |weight|. ShelfItem weight_dummy; diff --git a/ash/shelf/shelf_model_unittest.cc b/ash/shelf/shelf_model_unittest.cc index 8fc120c..817f201 100644 --- a/ash/shelf/shelf_model_unittest.cc +++ b/ash/shelf/shelf_model_unittest.cc @@ -302,89 +302,6 @@ TEST_F(ShelfModelTest, FirstRunningAppIndexUsingPlatformAppFirst) { EXPECT_EQ(running_app_index, model_->FirstRunningAppIndex()); } -// Assertions around where items are added. -TEST_F(ShelfModelTest, AddIndicesForLegacyShelfLayout) { - CommandLine::ForCurrentProcess()->AppendSwitch( - ash::switches::kAshDisableAlternateShelfLayout); - - // Insert browser short cut at index 0. - ShelfItem browser_shortcut; - browser_shortcut.type = TYPE_BROWSER_SHORTCUT; - int browser_shortcut_index = model_->Add(browser_shortcut); - EXPECT_EQ(0, browser_shortcut_index); - - // platform app items should be after browser shortcut. - ShelfItem item; - item.type = TYPE_PLATFORM_APP; - int platform_app_index1 = model_->Add(item); - EXPECT_EQ(1, platform_app_index1); - - // Add another platform app item, it should follow first. - int platform_app_index2 = model_->Add(item); - EXPECT_EQ(2, platform_app_index2); - - // APP_SHORTCUT priority is higher than PLATFORM_APP but same as - // BROWSER_SHORTCUT. So APP_SHORTCUT is located after BROWSER_SHORCUT. - item.type = TYPE_APP_SHORTCUT; - int app_shortcut_index1 = model_->Add(item); - EXPECT_EQ(1, app_shortcut_index1); - - item.type = TYPE_APP_SHORTCUT; - int app_shortcut_index2 = model_->Add(item); - EXPECT_EQ(2, app_shortcut_index2); - - // Check that AddAt() figures out the correct indexes for app shortcuts. - // APP_SHORTCUT and BROWSER_SHORTCUT has the same weight. - // So APP_SHORTCUT is located at index 0. And, BROWSER_SHORTCUT is located at - // index 1. - item.type = TYPE_APP_SHORTCUT; - int app_shortcut_index3 = model_->AddAt(0, item); - EXPECT_EQ(0, app_shortcut_index3); - - item.type = TYPE_APP_SHORTCUT; - int app_shortcut_index4 = model_->AddAt(5, item); - EXPECT_EQ(4, app_shortcut_index4); - - item.type = TYPE_APP_SHORTCUT; - int app_shortcut_index5 = model_->AddAt(2, item); - EXPECT_EQ(2, app_shortcut_index5); - - // Before there are any panels, no icons should be right aligned. - EXPECT_EQ(model_->item_count(), model_->FirstPanelIndex()); - - // Check that AddAt() figures out the correct indexes for platform apps and - // panels. - item.type = TYPE_PLATFORM_APP; - int platform_app_index3 = model_->AddAt(2, item); - EXPECT_EQ(6, platform_app_index3); - - item.type = TYPE_APP_PANEL; - int app_panel_index1 = model_->AddAt(2, item); - EXPECT_EQ(10, app_panel_index1); - - item.type = TYPE_PLATFORM_APP; - int platform_app_index4 = model_->AddAt(11, item); - EXPECT_EQ(9, platform_app_index4); - - item.type = TYPE_APP_PANEL; - int app_panel_index2 = model_->AddAt(12, item); - EXPECT_EQ(12, app_panel_index2); - - item.type = TYPE_PLATFORM_APP; - int platform_app_index5 = model_->AddAt(7, item); - EXPECT_EQ(7, platform_app_index5); - - item.type = TYPE_APP_PANEL; - int app_panel_index3 = model_->AddAt(13, item); - EXPECT_EQ(13, app_panel_index3); - - // Right aligned index should be the first app panel index. - EXPECT_EQ(12, model_->FirstPanelIndex()); - - EXPECT_EQ(TYPE_BROWSER_SHORTCUT, model_->items()[1].type); - EXPECT_EQ(TYPE_APP_LIST, model_->items()[model_->FirstPanelIndex() - 1].type); -} - // Assertions around id generation and usage. TEST_F(ShelfModelTest, ShelfIDTests) { // Get the next to use ID counter. @@ -438,34 +355,4 @@ TEST_F(ShelfModelTest, CorrectMoveItemsWhenStateChange) { EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[4].type); } -TEST_F(ShelfModelTest, CorrectMoveItemsWhenStateChangeForLegacyShelfLayout) { - CommandLine::ForCurrentProcess()->AppendSwitch( - ash::switches::kAshDisableAlternateShelfLayout); - - // The first item is the browser and the second item is app list. - ShelfItem browser_shortcut; - browser_shortcut.type = TYPE_BROWSER_SHORTCUT; - int browser_shortcut_index = model_->Add(browser_shortcut); - EXPECT_EQ(0, browser_shortcut_index); - EXPECT_EQ(TYPE_APP_LIST, model_->items()[1].type); - - // Add three shortcuts. They should all be moved between the two. - ShelfItem item; - item.type = TYPE_APP_SHORTCUT; - int app1_index = model_->Add(item); - EXPECT_EQ(1, app1_index); - int app2_index = model_->Add(item); - EXPECT_EQ(2, app2_index); - int app3_index = model_->Add(item); - EXPECT_EQ(3, app3_index); - - // Now change the type of the second item and make sure that it is moving - // behind the shortcuts. - item.type = TYPE_PLATFORM_APP; - model_->Set(app2_index, item); - - // The item should have moved in front of the app launcher. - EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[3].type); -} - } // namespace ash diff --git a/ash/shelf/shelf_navigator_unittest.cc b/ash/shelf/shelf_navigator_unittest.cc index 7807ecc..0033da7 100644 --- a/ash/shelf/shelf_navigator_unittest.cc +++ b/ash/shelf/shelf_navigator_unittest.cc @@ -69,21 +69,6 @@ class ShelfNavigatorTest : public testing::Test { DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorTest); }; -class ShelfNavigatorLegacyShelfLayoutTest : public ShelfNavigatorTest { - public: - ShelfNavigatorLegacyShelfLayoutTest() : ShelfNavigatorTest() {} - - protected: - virtual void SetUp() OVERRIDE { - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kAshDisableAlternateShelfLayout); - ShelfNavigatorTest::SetUp(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(ShelfNavigatorLegacyShelfLayoutTest); -}; - } // namespace TEST_F(ShelfNavigatorTest, BasicCycle) { @@ -102,22 +87,6 @@ TEST_F(ShelfNavigatorTest, BasicCycle) { EXPECT_EQ(5, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); } -TEST_F(ShelfNavigatorLegacyShelfLayoutTest, BasicCycle) { - // An app shortcut and three platform apps. - ShelfItemType types[] = { - TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, - }; - // ShelfModel automatically adds BROWSER_SHORTCUT item at the - // beginning, so '2' refers the first TYPE_PLATFORM_APP item. - SetupMockShelfModel(types, arraysize(types), 2); - - EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); - - // Fourth one. It will skip the APP_SHORTCUT at the beginning of the list and - // the APP_LIST item which is automatically added at the end of items. - EXPECT_EQ(4, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); -} - TEST_F(ShelfNavigatorTest, WrapToBeginning) { ShelfItemType types[] = { TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, @@ -130,18 +99,6 @@ TEST_F(ShelfNavigatorTest, WrapToBeginning) { EXPECT_EQ(3, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); } -TEST_F(ShelfNavigatorLegacyShelfLayoutTest, WrapToBeginning) { - ShelfItemType types[] = { - TYPE_APP_SHORTCUT, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, - }; - SetupMockShelfModel(types, arraysize(types), 4); - - // Second one. It skips the APP_LIST item at the end of the list, - // wraps to the beginning, and skips BROWSER_SHORTCUT and APP_SHORTCUT - // at the beginning of the list. - EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); -} - TEST_F(ShelfNavigatorTest, Empty) { SetupMockShelfModel(NULL, 0, -1); EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); @@ -158,16 +115,6 @@ TEST_F(ShelfNavigatorTest, SingleEntry) { EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); } -TEST_F(ShelfNavigatorLegacyShelfLayoutTest, SingleEntry) { - ShelfItemType type = TYPE_PLATFORM_APP; - SetupMockShelfModel(&type, 1, 1); - - // If there's only one item there and it is already active, there's no item - // to be activated next. - EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); - EXPECT_EQ(-1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); -} - TEST_F(ShelfNavigatorTest, NoActive) { ShelfItemType types[] = { TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, @@ -180,16 +127,4 @@ TEST_F(ShelfNavigatorTest, NoActive) { EXPECT_EQ(2, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); } -TEST_F(ShelfNavigatorLegacyShelfLayoutTest, NoActive) { - ShelfItemType types[] = { - TYPE_PLATFORM_APP, TYPE_PLATFORM_APP, - }; - // Special case: no items are 'STATUS_ACTIVE'. - SetupMockShelfModel(types, arraysize(types), -1); - - // If there are no active status, pick the first running item as a fallback. - EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_FORWARD)); - EXPECT_EQ(1, GetNextActivatedItemIndex(model(), CYCLE_BACKWARD)); -} - } // namespace ash diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index 590fbf9..26066f5 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -12,7 +12,6 @@ #include "ash/metrics/user_metrics_recorder.h" #include "ash/root_window_controller.h" #include "ash/scoped_target_root_window.h" -#include "ash/shelf/alternate_app_list_button.h" #include "ash/shelf/app_list_button.h" #include "ash/shelf/overflow_bubble.h" #include "ash/shelf/overflow_bubble_view.h" @@ -73,13 +72,6 @@ const int kDefaultLeadingInset = 8; // Minimum distance before drag starts. const int kMinimumDragDistance = 8; -// Size between the buttons. -const int kButtonSpacing = 4; -const int kAlternateButtonSpacing = 10; - -// Size allocated to for each button. -const int kButtonSize = 44; - // Additional spacing for the left and right side of icons. const int kHorizontalIconSpacing = 2; @@ -431,36 +423,18 @@ void ShelfView::Init() { view_model_->Add(child, static_cast<int>(i - items.begin())); AddChildView(child); } - ShelfStatusChanged(); overflow_button_ = new OverflowButton(this); overflow_button_->set_context_menu_controller(this); ConfigureChildView(overflow_button_); AddChildView(overflow_button_); - UpdateFirstButtonPadding(); // We'll layout when our bounds change. } void ShelfView::OnShelfAlignmentChanged() { - UpdateFirstButtonPadding(); overflow_button_->OnShelfAlignmentChanged(); LayoutToIdealBounds(); for (int i=0; i < view_model_->view_size(); ++i) { - // TODO: remove when AppIcon is a Shelf Button. - if (TYPE_APP_LIST == model_->items()[i].type && - !ash::switches::UseAlternateShelfLayout()) { - static_cast<AppListButton*>(view_model_->view_at(i))->SetImageAlignment( - layout_manager_->SelectValueForShelfAlignment( - views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_LEFT, - views::ImageButton::ALIGN_RIGHT, - views::ImageButton::ALIGN_CENTER), - layout_manager_->SelectValueForShelfAlignment( - views::ImageButton::ALIGN_TOP, - views::ImageButton::ALIGN_MIDDLE, - views::ImageButton::ALIGN_MIDDLE, - views::ImageButton::ALIGN_BOTTOM)); - } if (i >= first_visible_index_ && i <= last_visible_index_) view_model_->view_at(i)->Layout(); } @@ -714,14 +688,10 @@ void ShelfView::LayoutToIdealBounds() { void ShelfView::UpdateAllButtonsVisibilityInOverflowMode() { // The overflow button is not shown in overflow mode. overflow_button_->SetVisible(false); - int last_button_index = model_->FirstPanelIndex() - 1; DCHECK_LT(last_visible_index_, view_model_->view_size()); for (int i = 0; i < view_model_->view_size(); ++i) { bool visible = i >= first_visible_index_ && i <= last_visible_index_; - if (!ash::switches::UseAlternateShelfLayout()) - visible &= i != last_button_index; - // To track the dragging of |drag_view_| continuously, its visibility // should be always true regardless of its position. if (dragged_off_from_overflow_to_shelf_ && @@ -741,15 +711,10 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { int first_panel_index = model_->FirstPanelIndex(); int last_button_index = first_panel_index - 1; - // Initial x,y values account both leading_inset in primary - // coordinate and secondary coordinate based on the dynamic edge of the - // shelf (eg top edge on bottom-aligned shelf). - int inset = ash::switches::UseAlternateShelfLayout() ? 0 : leading_inset_; - int x = layout_manager_->SelectValueForShelfAlignment(inset, 0, 0, inset); - int y = layout_manager_->SelectValueForShelfAlignment(0, inset, inset, 0); - - int button_size = GetButtonSize(); - int button_spacing = GetButtonSpacing(); + int x = 0; + int y = 0; + int button_size = kShelfButtonSize; + int button_spacing = kShelfButtonSpacing; int w = layout_manager_->PrimaryAxisValue(button_size, width()); int h = layout_manager_->PrimaryAxisValue(height(), button_size); @@ -771,16 +736,6 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { return; } - // To address Fitt's law, we make the first shelf button include the - // leading inset (if there is one). - if (!ash::switches::UseAlternateShelfLayout()) { - if (view_model_->view_size() > 0) { - view_model_->set_ideal_bounds(0, gfx::Rect(gfx::Size( - layout_manager_->PrimaryAxisValue(inset + w, w), - layout_manager_->PrimaryAxisValue(h, inset + h)))); - } - } - // Right aligned icons. int end_position = available_size - button_spacing; x = layout_manager_->PrimaryAxisValue(end_position, 0); @@ -797,10 +752,7 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { // the available space. int last_icon_position = layout_manager_->PrimaryAxisValue( view_model_->ideal_bounds(last_button_index).right(), - view_model_->ideal_bounds(last_button_index).bottom()) - + button_size + inset; - if (!ash::switches::UseAlternateShelfLayout()) - last_icon_position += button_size; + view_model_->ideal_bounds(last_button_index).bottom()) + button_size; int reserved_icon_space = available_size * kReservedNonPanelIconProportion; if (last_icon_position < reserved_icon_space) end_position = last_icon_position; @@ -811,28 +763,18 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { gfx::Size(layout_manager_->PrimaryAxisValue(w, width()), layout_manager_->PrimaryAxisValue(height(), h))); - if (ash::switches::UseAlternateShelfLayout()) { - last_visible_index_ = DetermineLastVisibleIndex( - end_position - button_size); - } else { - last_visible_index_ = DetermineLastVisibleIndex( - end_position - inset - 2 * button_size); - } + last_visible_index_ = DetermineLastVisibleIndex( + end_position - button_size); last_hidden_index_ = DetermineFirstVisiblePanelIndex(end_position) - 1; - bool show_overflow = - ((ash::switches::UseAlternateShelfLayout() ? 0 : 1) + - last_visible_index_ < last_button_index || - last_hidden_index_ >= first_panel_index); + bool show_overflow = last_visible_index_ < last_button_index || + last_hidden_index_ >= first_panel_index; // Create Space for the overflow button - if (show_overflow && ash::switches::UseAlternateShelfLayout() && + if (show_overflow && last_visible_index_ > 0 && last_visible_index_ < last_button_index) --last_visible_index_; for (int i = 0; i < view_model_->view_size(); ++i) { bool visible = i <= last_visible_index_ || i > last_hidden_index_; - // Always show the app list. - if (!ash::switches::UseAlternateShelfLayout()) - visible |= (i == last_button_index); // To receive drag event continously from |drag_view_| during the dragging // off from the shelf, don't make |drag_view_| invisible. It will be // eventually invisible and removed from the |view_model_| by @@ -846,12 +788,8 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { if (show_overflow) { DCHECK_NE(0, view_model_->view_size()); if (last_visible_index_ == -1) { - x = layout_manager_->SelectValueForShelfAlignment(inset, 0, 0, inset); - y = layout_manager_->SelectValueForShelfAlignment(0, inset, inset, 0); - } else if (last_visible_index_ == last_button_index - && !ash::switches::UseAlternateShelfLayout()) { - x = view_model_->ideal_bounds(last_visible_index_).x(); - y = view_model_->ideal_bounds(last_visible_index_).y(); + x = 0; + y = 0; } else { x = layout_manager_->PrimaryAxisValue( view_model_->ideal_bounds(last_visible_index_).right(), @@ -866,23 +804,11 @@ void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { // Add more space between last visible item and overflow button. // Without this, two buttons look too close compared with other items. - if (ash::switches::UseAlternateShelfLayout()) { - x = layout_manager_->PrimaryAxisValue(x + button_spacing, x); - y = layout_manager_->PrimaryAxisValue(y, y + button_spacing); - } + x = layout_manager_->PrimaryAxisValue(x + button_spacing, x); + y = layout_manager_->PrimaryAxisValue(y, y + button_spacing); bounds->overflow_bounds.set_x(x); bounds->overflow_bounds.set_y(y); - if (!ash::switches::UseAlternateShelfLayout()) { - // Position app list after overflow button. - gfx::Rect app_list_bounds = view_model_->ideal_bounds(last_button_index); - - x = layout_manager_->PrimaryAxisValue(x + w + button_spacing, x); - y = layout_manager_->PrimaryAxisValue(y, y + h + button_spacing); - app_list_bounds.set_x(x); - app_list_bounds.set_y(y); - view_model_->set_ideal_bounds(last_button_index, app_list_bounds); - } if (overflow_bubble_.get() && overflow_bubble_->IsShowing()) UpdateOverflowRange(overflow_bubble_->shelf_view()); } else { @@ -931,8 +857,6 @@ void ShelfView::AnimateToIdealBounds() { // padding of the first gets properly transferred to the new first item. if (i && view->border()) view->SetBorder(views::Border::NullBorder()); - else if (!i && !view->border()) - UpdateFirstButtonPadding(); } overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); } @@ -954,26 +878,7 @@ views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { } case TYPE_APP_LIST: { - if (ash::switches::UseAlternateShelfLayout()) { - view = new AlternateAppListButton(this, - this, - layout_manager_->shelf_widget()); - } else { - // TODO(dave): turn this into a ShelfButton too. - AppListButton* button = new AppListButton(this, this); - button->SetImageAlignment( - layout_manager_->SelectValueForShelfAlignment( - views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_LEFT, - views::ImageButton::ALIGN_RIGHT, - views::ImageButton::ALIGN_CENTER), - layout_manager_->SelectValueForShelfAlignment( - views::ImageButton::ALIGN_TOP, - views::ImageButton::ALIGN_MIDDLE, - views::ImageButton::ALIGN_MIDDLE, - views::ImageButton::ALIGN_BOTTOM)); - view = button; - } + view = new AppListButton(this, this, layout_manager_->shelf_widget()); break; } @@ -1330,22 +1235,6 @@ void ShelfView::ToggleOverflowBubble() { Shell::GetInstance()->UpdateShelfVisibility(); } -void ShelfView::UpdateFirstButtonPadding() { - if (ash::switches::UseAlternateShelfLayout()) - return; - - // Creates an empty border for first shelf 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)->SetBorder(views::Border::CreateEmptyBorder( - layout_manager_->PrimaryAxisValue(0, leading_inset_), - layout_manager_->PrimaryAxisValue(leading_inset_, 0), - 0, - 0)); - } -} - void ShelfView::OnFadeOutAnimationEnded() { AnimateToIdealBounds(); StartFadeInLastVisibleItem(); @@ -1374,16 +1263,6 @@ void ShelfView::UpdateOverflowRange(ShelfView* overflow_view) { overflow_view->last_visible_index_ = last_overflow_index; } -int ShelfView::GetButtonSize() const { - return ash::switches::UseAlternateShelfLayout() ? - kButtonSize : kShelfPreferredSize; -} - -int ShelfView::GetButtonSpacing() const { - return ash::switches::UseAlternateShelfLayout() ? - kAlternateButtonSpacing : kButtonSpacing; -} - bool ShelfView::ShouldHideTooltip(const gfx::Point& cursor_location) { gfx::Rect active_bounds; @@ -1416,8 +1295,6 @@ gfx::Rect ShelfView::GetBoundsForDragInsertInScreen() { owner_overflow_bubble_->bubble_view()->GetBubbleBounds(); preferred_size = bubble_bounds.size(); } else { - const int preferred_shelf_size = layout_manager_->GetPreferredShelfSize(); - const int last_button_index = view_model_->view_size() - 1; gfx::Rect last_button_bounds = view_model_->view_at(last_button_index)->bounds(); @@ -1430,9 +1307,9 @@ gfx::Rect ShelfView::GetBoundsForDragInsertInScreen() { if (layout_manager_->IsHorizontalAlignment()) { preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_, - preferred_shelf_size); + kShelfSize); } else { - preferred_size = gfx::Size(preferred_shelf_size, + preferred_size = gfx::Size(kShelfSize, last_button_bounds.bottom() + leading_inset_); } } @@ -1483,8 +1360,6 @@ gfx::Size ShelfView::GetPreferredSize() { IdealBounds ideal_bounds; CalculateIdealBounds(&ideal_bounds); - const int preferred_size = layout_manager_->GetPreferredShelfSize(); - int last_button_index = is_overflow_mode() ? last_visible_index_ : view_model_->view_size() - 1; @@ -1502,14 +1377,13 @@ gfx::Size ShelfView::GetPreferredSize() { const gfx::Rect last_button_bounds = last_button_index >= first_visible_index_ ? view_model_->ideal_bounds(last_button_index) : - gfx::Rect(gfx::Size(preferred_size, preferred_size)); + gfx::Rect(gfx::Size(kShelfSize, kShelfSize)); if (layout_manager_->IsHorizontalAlignment()) { - return gfx::Size(last_button_bounds.right() + leading_inset_, - preferred_size); + return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize); } - return gfx::Size(preferred_size, + return gfx::Size(kShelfSize, last_button_bounds.bottom() + leading_inset_); } @@ -1674,14 +1548,7 @@ void ShelfView::ShelfItemMoved(int start_index, int target_index) { } void ShelfView::ShelfStatusChanged() { - if (ash::switches::UseAlternateShelfLayout()) - return; - AppListButton* app_list_button = - static_cast<AppListButton*>(GetAppListButtonView()); - if (model_->status() == ShelfModel::STATUS_LOADING) - app_list_button->StartLoadingAnimation(); - else - app_list_button->StopLoadingAnimation(); + // Nothing to do here. } void ShelfView::PointerPressedOnButton(views::View* view, diff --git a/ash/shelf/shelf_view.h b/ash/shelf/shelf_view.h index 0d6f0b7..9f7c2dd 100644 --- a/ash/shelf/shelf_view.h +++ b/ash/shelf/shelf_view.h @@ -231,11 +231,6 @@ class ASH_EXPORT ShelfView : 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(); @@ -245,12 +240,6 @@ class ASH_EXPORT ShelfView : public views::View, // Updates the visible range of overflow items in |overflow_view|. void UpdateOverflowRange(ShelfView* overflow_view); - // Returns the launcher button size. - int GetButtonSize() const; - - // Returns the button spacing. - int GetButtonSpacing() const; - // Overridden from views::View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc index a2faa65..91e54fe 100644 --- a/ash/shelf/shelf_view_unittest.cc +++ b/ash/shelf/shelf_view_unittest.cc @@ -270,8 +270,7 @@ class ShelfViewTest : public AshTestBase { shelf_view_ = ShelfTestAPI(shelf).shelf_view(); // The bounds should be big enough for 4 buttons + overflow chevron. - shelf_view_->SetBounds( - 0, 0, 500, ShelfLayoutManager::GetPreferredShelfSize()); + shelf_view_->SetBounds(0, 0, 500, kShelfSize); test_api_.reset(new ShelfViewTestAPI(shelf_view_)); test_api_->SetAnimationDuration(1); // Speeds up animation for test. @@ -578,24 +577,6 @@ class ShelfViewTest : public AshTestBase { DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); }; -class ShelfViewLegacyShelfLayoutTest : public ShelfViewTest { - public: - ShelfViewLegacyShelfLayoutTest() : ShelfViewTest() { - browser_index_ = 0; - } - - virtual ~ShelfViewLegacyShelfLayoutTest() {} - - virtual void SetUp() OVERRIDE { - CommandLine::ForCurrentProcess()->AppendSwitch( - ash::switches::kAshDisableAlternateShelfLayout); - ShelfViewTest::SetUp(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(ShelfViewLegacyShelfLayoutTest); -}; - class ScopedTextDirectionChange { public: ScopedTextDirectionChange(bool is_rtl) @@ -741,33 +722,6 @@ TEST_F(ShelfViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); } -TEST_F(ShelfViewLegacyShelfLayoutTest, - AddAppShortcutWithBrowserButtonUntilOverflow) { - // All buttons should be visible. - ASSERT_EQ(test_api_->GetButtonCount(), - test_api_->GetLastVisibleIndex() + 1); - - - ShelfID browser_button_id = AddPlatformApp(); - - // Add app shortcut until overflow. - int items_added = 0; - ShelfID last_added = AddAppShortcut(); - while (!test_api_->IsOverflowButtonVisible()) { - // Added button is visible after animation while in this loop. - EXPECT_TRUE(GetButtonByID(last_added)->visible()); - - last_added = AddAppShortcut(); - ++items_added; - ASSERT_LT(items_added, 10000); - } - - // The last added app short button should be visible. - EXPECT_TRUE(GetButtonByID(last_added)->visible()); - // And the platform app button is invisible. - EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); -} - TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { // All buttons should be visible. ASSERT_EQ(test_api_->GetButtonCount(), @@ -796,36 +750,6 @@ TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); } -TEST_F(ShelfViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { - // All buttons should be visible. - ASSERT_EQ(test_api_->GetButtonCount(), - test_api_->GetLastVisibleIndex() + 1); - - // Add platform app button until overflow, remember last visible platform app - // button. - int items_added = 0; - ShelfID first_added = AddPlatformApp(); - EXPECT_TRUE(GetButtonByID(first_added)->visible()); - ShelfID last_visible = first_added; - while (true) { - ShelfID added = AddPlatformApp(); - if (test_api_->IsOverflowButtonVisible()) { - EXPECT_FALSE(GetButtonByID(added)->visible()); - break; - } - last_visible = added; - ++items_added; - ASSERT_LT(items_added, 10000); - } - - ShelfID panel = AddPanel(); - EXPECT_TRUE(GetButtonByID(panel)->visible()); - EXPECT_FALSE(GetButtonByID(last_visible)->visible()); - - RemoveByID(panel); - EXPECT_TRUE(GetButtonByID(last_visible)->visible()); -} - // When there are more panels then platform app buttons we should hide panels // rather than platform apps. TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { @@ -1012,66 +936,6 @@ TEST_F(ShelfViewTest, ModelChangesWhileDragging) { dragged_button, ShelfButtonHost::MOUSE, false); } -TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { - ShelfButtonHost* button_host = shelf_view_; - - std::vector<std::pair<ShelfID, views::View*> > id_map; - SetupForDragTest(&id_map); - - // Dragging browser shortcut at index 0. - EXPECT_TRUE(model_->items()[0].type == TYPE_BROWSER_SHORTCUT); - views::View* dragged_button = SimulateDrag(ShelfButtonHost::MOUSE, 0, 2); - std::rotate(id_map.begin(), - id_map.begin() + 1, - id_map.begin() + 3); - ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); - button_host->PointerReleasedOnButton( - dragged_button, ShelfButtonHost::MOUSE, false); - EXPECT_TRUE(model_->items()[2].type == TYPE_BROWSER_SHORTCUT); - - // Dragging changes model order. - dragged_button = SimulateDrag(ShelfButtonHost::MOUSE, 0, 2); - std::rotate(id_map.begin(), - id_map.begin() + 1, - id_map.begin() + 3); - ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); - - // Cancelling the drag operation restores previous order. - button_host->PointerReleasedOnButton( - dragged_button, ShelfButtonHost::MOUSE, true); - std::rotate(id_map.begin(), - id_map.begin() + 2, - id_map.begin() + 3); - ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); - - // Deleting an item keeps the remaining intact. - dragged_button = SimulateDrag(ShelfButtonHost::MOUSE, 0, 2); - model_->RemoveItemAt(1); - id_map.erase(id_map.begin() + 1); - ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); - button_host->PointerReleasedOnButton( - dragged_button, ShelfButtonHost::MOUSE, false); - - // Adding a shelf item cancels the drag and respects the order. - dragged_button = SimulateDrag(ShelfButtonHost::MOUSE, 0, 2); - ShelfID new_id = AddAppShortcut(); - id_map.insert(id_map.begin() + 5, - std::make_pair(new_id, GetButtonByID(new_id))); - ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); - button_host->PointerReleasedOnButton( - dragged_button, ShelfButtonHost::MOUSE, false); - - // Adding a shelf item at the end (i.e. a panel) canels drag and respects - // the order. - dragged_button = SimulateDrag(ShelfButtonHost::MOUSE, 0, 2); - new_id = AddPanel(); - id_map.insert(id_map.begin() + 7, - std::make_pair(new_id, GetButtonByID(new_id))); - ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); - button_host->PointerReleasedOnButton( - dragged_button, ShelfButtonHost::MOUSE, false); -} - // Check that 2nd drag from the other pointer would be ignored. TEST_F(ShelfViewTest, SimultaneousDrag) { ShelfButtonHost* button_host = shelf_view_; @@ -1159,36 +1023,6 @@ TEST_F(ShelfViewTest, ShelfItemStatus) { ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); } -TEST_F(ShelfViewLegacyShelfLayoutTest, - ShelfItemPositionReflectedOnStateChanged) { - // All buttons should be visible. - ASSERT_EQ(test_api_->GetButtonCount(), - test_api_->GetLastVisibleIndex() + 1); - - // Add 2 items to the shelf. - ShelfID item1_id = AddPlatformApp(); - ShelfID item2_id = AddPlatformAppNoWait(); - ShelfButton* item1_button = GetButtonByID(item1_id); - ShelfButton* item2_button = GetButtonByID(item2_id); - - ShelfButton::State state_mask = static_cast<ShelfButton::State>( - ShelfButton::STATE_NORMAL | ShelfButton::STATE_HOVERED | - ShelfButton::STATE_RUNNING | ShelfButton::STATE_ACTIVE | - ShelfButton::STATE_ATTENTION | ShelfButton::STATE_FOCUSED); - - // Clear the button states. - item1_button->ClearState(state_mask); - item2_button->ClearState(state_mask); - - // Since default alignment in tests is bottom, state is reflected in y-axis. - ASSERT_EQ(item1_button->GetIconBounds().y(), - item2_button->GetIconBounds().y()); - item1_button->AddState(ShelfButton::STATE_HOVERED); - ASSERT_NE(item1_button->GetIconBounds().y(), - item2_button->GetIconBounds().y()); - item1_button->ClearState(ShelfButton::STATE_HOVERED); -} - // Confirm that item status changes are reflected in the buttons // for platform apps. TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { @@ -1446,7 +1280,7 @@ TEST_F(ShelfViewTest, ResizeDuringOverflowAddAnimation) { // Resize shelf view with that animation running and stay overflown. gfx::Rect bounds = shelf_view_->bounds(); - bounds.set_width(bounds.width() - kShelfPreferredSize); + bounds.set_width(bounds.width() - kShelfSize); shelf_view_->SetBoundsRect(bounds); ASSERT_TRUE(test_api_->IsOverflowButtonVisible()); @@ -1518,17 +1352,6 @@ TEST_F(ShelfViewTest, OverflowBubbleSize) { test_for_overflow_view.GetPreferredSize().width()); } -// Check that the first item in the list follows Fitt's law by including the -// first pixel and being therefore bigger then the others. -TEST_F(ShelfViewLegacyShelfLayoutTest, CheckFittsLaw) { - // All buttons should be visible. - ASSERT_EQ(test_api_->GetButtonCount(), - test_api_->GetLastVisibleIndex() + 1); - gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); - gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); - EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); -} - // Check the drag insertion bounds of scrolled overflow bubble. TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { UpdateDisplay("400x300"); @@ -1592,8 +1415,7 @@ TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { ShelfTestAPI(secondary_shelf).shelf_view(); // The bounds should be big enough for 4 buttons + overflow chevron. - shelf_view_for_secondary->SetBounds( - 0, 0, 500, ShelfLayoutManager::GetPreferredShelfSize()); + shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); // Speeds up animation for test. diff --git a/ash/system/chromeos/session/logout_button_tray.cc b/ash/system/chromeos/session/logout_button_tray.cc index 850b850..ffd322a 100644 --- a/ash/system/chromeos/session/logout_button_tray.cc +++ b/ash/system/chromeos/session/logout_button_tray.cc @@ -86,7 +86,7 @@ LogoutButton::LogoutButton(views::ButtonListener* listener) SetBorder(border.PassAs<views::Border>()); set_animate_on_state_change(false); - set_min_size(gfx::Size(0, GetShelfItemHeight())); + set_min_size(gfx::Size(0, kShelfItemHeight)); } LogoutButton::~LogoutButton() { diff --git a/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc b/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc index 9fd239a..9eb190b 100644 --- a/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc +++ b/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc @@ -4,6 +4,7 @@ #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" +#include "ash/shelf/shelf_constants.h" #include "ash/shell.h" #include "ash/system/status_area_widget.h" #include "ash/system/tray/system_tray_notifier.h" @@ -41,7 +42,7 @@ VirtualKeyboardButton::~VirtualKeyboardButton() { } gfx::Size VirtualKeyboardButton::GetPreferredSize() { - const int virtual_keyboard_button_height = GetShelfItemHeight(); + const int virtual_keyboard_button_height = kShelfSize; gfx::Size size = ImageButton::GetPreferredSize(); int padding = virtual_keyboard_button_height - size.height(); size.set_height(virtual_keyboard_button_height); diff --git a/ash/system/status_area_widget_delegate.cc b/ash/system/status_area_widget_delegate.cc index cdac5cb..babe66d 100644 --- a/ash/system/status_area_widget_delegate.cc +++ b/ash/system/status_area_widget_delegate.cc @@ -20,11 +20,6 @@ #include "ui/views/widget/widget.h" namespace ash { -namespace { - -const int kStatusTrayOffsetFromScreenEdge = 4; - -} StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() : focus_cycler_for_testing_(NULL), @@ -88,20 +83,13 @@ void StatusAreaWidgetDelegate::UpdateLayout() { views::ColumnSet* columns = layout->AddColumnSet(0); if (alignment_ == SHELF_ALIGNMENT_BOTTOM || alignment_ == SHELF_ALIGNMENT_TOP) { - // Alternate shelf layout insets are all handled by tray_background_view. - if (!ash::switches::UseAlternateShelfLayout()) { - if (alignment_ == SHELF_ALIGNMENT_TOP) - layout->SetInsets(kStatusTrayOffsetFromScreenEdge, 0, 0, 0); - else - layout->SetInsets(0, 0, kStatusTrayOffsetFromScreenEdge, 0); - } bool is_first_visible_child = true; for (int c = 0; c < child_count(); ++c) { views::View* child = child_at(c); if (!child->visible()) continue; if (!is_first_visible_child) - columns->AddPaddingColumn(0, GetTraySpacing()); + columns->AddPaddingColumn(0, kTraySpacing); is_first_visible_child = false; columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 0, /* resize percent */ @@ -114,12 +102,6 @@ void StatusAreaWidgetDelegate::UpdateLayout() { layout->AddView(child); } } else { - if (!ash::switches::UseAlternateShelfLayout()) { - if (alignment_ == SHELF_ALIGNMENT_LEFT) - layout->SetInsets(0, kStatusTrayOffsetFromScreenEdge, 0, 0); - else - layout->SetInsets(0, 0, 0, kStatusTrayOffsetFromScreenEdge); - } columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0, /* resize percent */ views::GridLayout::USE_PREF, 0, 0); @@ -129,7 +111,7 @@ void StatusAreaWidgetDelegate::UpdateLayout() { if (!child->visible()) continue; if (!is_first_visible_child) - layout->AddPaddingRow(0, GetTraySpacing()); + layout->AddPaddingRow(0, kTraySpacing); is_first_visible_child = false; layout->StartRow(0, 0); layout->AddView(child); diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 7cca731..204a5a2 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -92,11 +92,9 @@ class SystemBubbleWrapper { Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); bubble_->InitView(anchor, login_status, init_params); bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); - if (ash::switches::UseAlternateShelfLayout()) { - // The system bubble should not have an arrow. - bubble_->bubble_view()->SetArrowPaintType( - views::BubbleBorder::PAINT_NONE); - } + // The system bubble should not have an arrow. + bubble_->bubble_view()->SetArrowPaintType( + views::BubbleBorder::PAINT_NONE); is_persistent_ = is_persistent; // If ChromeVox is enabled, focus the default item if no item is focused. @@ -479,8 +477,7 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, menu_width, kTrayPopupMaxWidth); init_params.can_activate = can_activate; - init_params.first_item_has_no_margin = - ash::switches::UseAlternateShelfLayout(); + init_params.first_item_has_no_margin = true; if (detailed) { // This is the case where a volume control or brightness control bubble // is created. @@ -551,8 +548,7 @@ void SystemTray::UpdateNotificationBubble() { GetAnchorAlignment(), kTrayPopupMinWidth, kTrayPopupMaxWidth); - init_params.first_item_has_no_margin = - ash::switches::UseAlternateShelfLayout(); + init_params.first_item_has_no_margin = true; init_params.arrow_color = kBackgroundColor; init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); notification_bubble_.reset(new SystemBubbleWrapper(notification_bubble)); diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc index 2e7b790..fc24c14 100644 --- a/ash/system/tray/tray_background_view.cc +++ b/ash/system/tray/tray_background_view.cc @@ -37,12 +37,6 @@ const int kTrayBackgroundAlpha = 100; const int kTrayBackgroundHoverAlpha = 150; const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244); -// Adjust the size of TrayContainer with additional padding. -const int kTrayContainerVerticalPaddingBottomAlignment = 1; -const int kTrayContainerHorizontalPaddingBottomAlignment = 1; -const int kTrayContainerVerticalPaddingVerticalAlignment = 1; -const int kTrayContainerHorizontalPaddingVerticalAlignment = 1; - const int kAnimationDurationForPopupMS = 200; } // namespace @@ -153,7 +147,8 @@ class TrayBackground : public views::Background { status_area_widget()->GetNativeWindow())->shelf(); } - void PaintForAlternateShelf(gfx::Canvas* canvas, views::View* view) const { + // Overridden from views::Background. + virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { int orientation = kImageHorizontal; ShelfWidget* shelf_widget = GetShelfWidget(); if (shelf_widget && @@ -209,23 +204,6 @@ class TrayBackground : public views::Background { middle_bounds.height()); } - // Overridden from views::Background. - virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { - if (ash::switches::UseAlternateShelfLayout()) { - PaintForAlternateShelf(canvas, view); - } else { - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(color_); - SkPath path; - gfx::Rect bounds(view->GetLocalBounds()); - SkScalar radius = SkIntToScalar(kTrayRoundedBorderRadius); - path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); - canvas->DrawPath(path, paint); - } - } - SkColor color_; // Reference to the TrayBackgroundView for which this is a background. TrayBackgroundView* tray_background_view_; @@ -277,32 +255,22 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() { // empty border. if (alignment_ == SHELF_ALIGNMENT_BOTTOM || alignment_ == SHELF_ALIGNMENT_TOP) { - int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; - int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; - if (ash::switches::UseAlternateShelfLayout()) { - vertical_padding = kPaddingFromEdgeOfShelf; - horizontal_padding = kPaddingFromEdgeOfShelf; - } - SetBorder(views::Border::CreateEmptyBorder(vertical_padding, - horizontal_padding, - vertical_padding, - horizontal_padding)); + SetBorder(views::Border::CreateEmptyBorder( + kPaddingFromEdgeOfShelf, + kPaddingFromEdgeOfShelf, + kPaddingFromEdgeOfShelf, + kPaddingFromEdgeOfShelf)); views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); layout->set_spread_blank_space(true); views::View::SetLayoutManager(layout); } else { - int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; - int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; - if (ash::switches::UseAlternateShelfLayout()) { - vertical_padding = kPaddingFromEdgeOfShelf; - horizontal_padding = kPaddingFromEdgeOfShelf; - } - SetBorder(views::Border::CreateEmptyBorder(vertical_padding, - horizontal_padding, - vertical_padding, - horizontal_padding)); + SetBorder(views::Border::CreateEmptyBorder( + kPaddingFromEdgeOfShelf, + kPaddingFromEdgeOfShelf, + kPaddingFromEdgeOfShelf, + kPaddingFromEdgeOfShelf)); views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); @@ -357,20 +325,10 @@ const char* TrayBackgroundView::GetClassName() const { void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { hovered_ = true; - if (!background_ || draw_background_as_active_ || - ash::switches::UseAlternateShelfLayout()) - return; - hover_background_animator_.SetPaintsBackground( - true, BACKGROUND_CHANGE_ANIMATE); } void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { hovered_ = false; - if (!background_ || draw_background_as_active_ || - ash::switches::UseAlternateShelfLayout()) - return; - hover_background_animator_.SetPaintsBackground( - false, BACKGROUND_CHANGE_ANIMATE); } void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { @@ -404,7 +362,6 @@ void TrayBackgroundView::UpdateBackground(int alpha) { // The animator should never fire when the alternate shelf layout is used. if (!background_ || draw_background_as_active_) return; - DCHECK(!ash::switches::UseAlternateShelfLayout()); background_->set_alpha(hide_background_animator_.alpha() + hover_background_animator_.alpha()); SchedulePaint(); @@ -417,7 +374,6 @@ void TrayBackgroundView::SetContents(views::View* contents) { void TrayBackgroundView::SetPaintsBackground( bool value, BackgroundAnimatorChangeType change_type) { - DCHECK(!ash::switches::UseAlternateShelfLayout()); hide_background_animator_.SetPaintsBackground(value, change_type); } @@ -441,51 +397,24 @@ void TrayBackgroundView::SetTrayBorder() { // Tray views are laid out right-to-left or bottom-to-top bool on_edge = (this == parent->child_at(0)); int left_edge, top_edge, right_edge, bottom_edge; - if (ash::switches::UseAlternateShelfLayout()) { - if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { - top_edge = ShelfLayoutManager::kShelfItemInset; - left_edge = 0; - bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); - right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; - } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { - top_edge = 0; - left_edge = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); - bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; - right_edge = ShelfLayoutManager::kShelfItemInset; - } else { // SHELF_ALIGNMENT_RIGHT - top_edge = 0; - left_edge = ShelfLayoutManager::kShelfItemInset; - bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; - right_edge = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); - } - } else { - // Change the border padding for different shelf alignment. - if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { - top_edge = 0; - left_edge = 0; - bottom_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : - kPaddingFromBottomOfScreenBottomAlignment - 1; - right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; - } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) { - top_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : - kPaddingFromBottomOfScreenBottomAlignment - 1; - left_edge = 0; - bottom_edge = 0; - right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; - } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { - top_edge = 0; - left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; - bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; - right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; - } else { - top_edge = 0; - left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; - bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; - right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; - } + if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { + top_edge = ShelfLayoutManager::kShelfItemInset; + left_edge = 0; + bottom_edge = kShelfSize - + ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; + right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; + } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { + top_edge = 0; + left_edge = kShelfSize - + ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; + bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; + right_edge = ShelfLayoutManager::kShelfItemInset; + } else { // SHELF_ALIGNMENT_RIGHT + top_edge = 0; + left_edge = ShelfLayoutManager::kShelfItemInset; + bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; + right_edge = kShelfSize - + ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; } SetBorder(views::Border::CreateEmptyBorder( top_edge, left_edge, bottom_edge, right_edge)); @@ -520,46 +449,24 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { bool rtl = base::i18n::IsRTL(); - if (!ash::switches::UseAlternateShelfLayout()) { - rect.Inset( - rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, - kTrayBubbleAnchorTopInsetBottomAnchor, - rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, - kPaddingFromBottomOfScreenBottomAlignment); - } else { - rect.Inset( - rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0, - kAlternateLayoutBubblePaddingHorizontalBottom, - rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide, - 0); - } + rect.Inset( + rtl ? kBubblePaddingHorizontalSide : 0, + kBubblePaddingHorizontalBottom, + rtl ? 0 : kBubblePaddingHorizontalSide, + 0); } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { - if (!ash::switches::UseAlternateShelfLayout()) { - rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, - kPaddingFromBottomOfScreenVerticalAlignment); - } else { - rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4, - kAlternateLayoutBubblePaddingVerticalBottom); - } + rect.Inset(0, 0, kBubblePaddingVerticalSide + 4, + kBubblePaddingVerticalBottom); } else { - if (!ash::switches::UseAlternateShelfLayout()) { - rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, - 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); - } else { - rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0, - kAlternateLayoutBubblePaddingVerticalBottom); - } + rect.Inset(kBubblePaddingVerticalSide, 0, 0, + kBubblePaddingVerticalBottom); } } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { // Invert the offsets to align with the bubble below. // Note that with the alternate shelf layout the tips are not shown and // the offsets for left and right alignment do not need to be applied. - int vertical_alignment = ash::switches::UseAlternateShelfLayout() ? - 0 : - kPaddingFromInnerEdgeOfLauncherVerticalAlignment; - int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ? - kAlternateLayoutBubblePaddingVerticalBottom : - kPaddingFromBottomOfScreenVerticalAlignment; + int vertical_alignment = 0; + int horizontal_alignment = kBubblePaddingVerticalBottom; if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) @@ -600,7 +507,7 @@ TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { draw_background_as_active_ = visible; - if (!background_ || !switches::UseAlternateShelfLayout()) + if (!background_) return; // Do not change gradually, changing color between grey and blue is weird. @@ -615,16 +522,7 @@ void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { void TrayBackgroundView::UpdateBubbleViewArrow( views::TrayBubbleView* bubble_view) { - if (switches::UseAlternateShelfLayout()) - return; - - aura::Window* root_window = - bubble_view->GetWidget()->GetNativeView()->GetRootWindow(); - ash::ShelfLayoutManager* shelf = ShelfLayoutManager::ForShelf(root_window); - bubble_view->SetArrowPaintType( - (shelf && shelf->IsVisible()) ? - views::BubbleBorder::PAINT_NORMAL : - views::BubbleBorder::PAINT_TRANSPARENT); + // Nothing to do here. } } // namespace ash diff --git a/ash/system/tray/tray_constants.cc b/ash/system/tray/tray_constants.cc index c035660..ab9871e 100644 --- a/ash/system/tray/tray_constants.cc +++ b/ash/system/tray/tray_constants.cc @@ -16,10 +16,10 @@ const int kPaddingFromInnerEdgeOfLauncherVerticalAlignment = 9; const int kPaddingFromBottomOfScreenVerticalAlignment = 10; // Padding used to position the system menu relative to the status area. -const int kAlternateLayoutBubblePaddingHorizontalBottom = 6; -const int kAlternateLayoutBubblePaddingHorizontalSide = 10; -const int kAlternateLayoutBubblePaddingVerticalBottom = 3; -const int kAlternateLayoutBubblePaddingVerticalSide = 15; +const int kBubblePaddingHorizontalBottom = 6; +const int kBubblePaddingHorizontalSide = 10; +const int kBubblePaddingVerticalBottom = 3; +const int kBubblePaddingVerticalSide = 15; const int kPaddingFromEdgeOfShelf = 3; @@ -79,21 +79,9 @@ const int kTrayNotificationContentsWidth = kTrayPopupMinWidth - (kTrayPopupPaddingHorizontal / 2) * 3); const int kTrayAvatarCornerRadius = 2; -const int kTrayAvatarSize = 27; - -const int kTraySpacing = 8; -const int kAlternateTraySpacing = 4; -const int kShelfItemHeight = 31; -const int kAlternateShelfItemHeight = 38; - -int GetTraySpacing() { - return ash::switches::UseAlternateShelfLayout() ? - kAlternateTraySpacing : kTraySpacing; -} - -int GetShelfItemHeight() { - return ash::switches::UseAlternateShelfLayout() ? - kAlternateShelfItemHeight : kShelfItemHeight; -} +const int kTrayAvatarSize = 32; + +const int kTraySpacing = 4; +const int kShelfItemHeight = 38; } // namespace ash diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h index a3179eb..b55d8fe 100644 --- a/ash/system/tray/tray_constants.h +++ b/ash/system/tray/tray_constants.h @@ -17,10 +17,10 @@ extern const int kPaddingFromOuterEdgeOfLauncherVerticalAlignment; extern const int kPaddingFromInnerEdgeOfLauncherVerticalAlignment; extern const int kPaddingFromBottomOfScreenVerticalAlignment; -extern const int kAlternateLayoutBubblePaddingHorizontalBottom; -extern const int kAlternateLayoutBubblePaddingHorizontalSide; -extern const int kAlternateLayoutBubblePaddingVerticalBottom; -extern const int kAlternateLayoutBubblePaddingVerticalSide; +extern const int kBubblePaddingHorizontalBottom; +extern const int kBubblePaddingHorizontalSide; +extern const int kBubblePaddingVerticalBottom; +extern const int kBubblePaddingVerticalSide; extern const int kPaddingFromEdgeOfShelf; extern const int kTrayBubbleAnchorTopInsetBottomAnchor; @@ -72,16 +72,12 @@ extern const int kNotificationIconWidth; extern const int kNotificationButtonWidth; extern const int kTrayNotificationContentsWidth; + extern const int kTrayAvatarCornerRadius; extern const int kTrayAvatarSize; -// Returns kTraySpacing or kAlternateTraySpacing as applicable -// (Determined by ash::switches::UseAlternateShelfLayout). -int GetTraySpacing(); - -// Returns kShelfItemHeight or kAlternateShelfItemHeight as applicable -// (Determined by ash::switches::UseAlternateShelfLayout). -int GetShelfItemHeight(); +extern const int kTraySpacing; +extern const int kShelfItemHeight; namespace test { const int kSettingsTrayItemViewId = 10000; diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index e22cdf4..2a8dfe1 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -33,9 +33,6 @@ namespace { const int kUserLabelToIconPadding = 5; -const int kTrayAvatarLargeSize = 32; -const int kTrayAvatarLargeCornerRadius = 2; - } // namespace namespace ash { @@ -180,9 +177,9 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { label_->SetText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)); } - if (avatar_ && switches::UseAlternateShelfLayout()) { + if (avatar_) { avatar_->SetCornerRadii( - 0, kTrayAvatarLargeCornerRadius, kTrayAvatarLargeCornerRadius, 0); + 0, kTrayAvatarCornerRadius, kTrayAvatarCornerRadius, 0); avatar_->SetBorder(views::Border::NullBorder()); } UpdateAvatarImage(status); @@ -198,17 +195,9 @@ void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { if (alignment == SHELF_ALIGNMENT_BOTTOM || alignment == SHELF_ALIGNMENT_TOP) { if (avatar_) { - if (switches::UseAlternateShelfLayout()) { - avatar_->SetBorder(views::Border::NullBorder()); - avatar_->SetCornerRadii( - 0, kTrayAvatarLargeCornerRadius, kTrayAvatarLargeCornerRadius, 0); - } else { - avatar_->SetBorder(views::Border::CreateEmptyBorder( - 0, - kTrayImageItemHorizontalPaddingBottomAlignment + 2, - 0, - kTrayImageItemHorizontalPaddingBottomAlignment)); - } + avatar_->SetBorder(views::Border::NullBorder()); + avatar_->SetCornerRadii( + 0, kTrayAvatarCornerRadius, kTrayAvatarCornerRadius, 0); } if (label_) { // If label_ hasn't figured out its size yet, do that first. @@ -228,13 +217,9 @@ void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 0, 0, kUserLabelToIconPadding)); } else { if (avatar_) { - if (switches::UseAlternateShelfLayout()) { - avatar_->SetBorder(views::Border::NullBorder()); - avatar_->SetCornerRadii( - 0, 0, kTrayAvatarLargeCornerRadius, kTrayAvatarLargeCornerRadius); - } else { - SetTrayImageItemBorder(avatar_, alignment); - } + avatar_->SetBorder(views::Border::NullBorder()); + avatar_->SetCornerRadii( + 0, 0, kTrayAvatarCornerRadius, kTrayAvatarCornerRadius); } if (label_) { label_->SetBorder(views::Border::CreateEmptyBorder( @@ -276,17 +261,14 @@ void TrayUser::UpdateAvatarImage(user::LoginStatus status) { GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) return; - int icon_size = switches::UseAlternateShelfLayout() ? kTrayAvatarLargeSize - : kTrayAvatarSize; - content::BrowserContext* context = session_state_delegate-> GetBrowserContextByIndex(GetTrayIndex()); avatar_->SetImage(session_state_delegate->GetUserImage(context), - gfx::Size(icon_size, icon_size)); + gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); // Unit tests might come here with no images for some users. if (avatar_->size().IsEmpty()) - avatar_->SetSize(gfx::Size(icon_size, icon_size)); + avatar_->SetSize(gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); } MultiProfileIndex TrayUser::GetTrayIndex() { diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc index 40c2539..13407c6 100644 --- a/ash/system/web_notification/web_notification_tray.cc +++ b/ash/system/web_notification/web_notification_tray.cc @@ -123,11 +123,10 @@ void WorkAreaObserver::SetSystemTrayHeight(int height) { // should be reduced by the height of shelf's shown height. if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { - system_tray_height_ -= ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kAutoHideSize; + system_tray_height_ -= kShelfSize - ShelfLayoutManager::kAutoHideSize; } - if (system_tray_height_ > 0 && ash::switches::UseAlternateShelfLayout()) + if (system_tray_height_ > 0) system_tray_height_ += message_center::kMarginBetweenItems; if (!shelf_) @@ -173,8 +172,7 @@ void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) { new_state == SHELF_AUTO_HIDE_SHOWN) { // Since the work_area is already reduced by kAutoHideSize, the inset width // should be just the difference. - width = ShelfLayoutManager::GetPreferredShelfSize() - - ShelfLayoutManager::kAutoHideSize; + width = kShelfSize - ShelfLayoutManager::kAutoHideSize; } work_area.Inset(shelf_->SelectValueForShelfAlignment( gfx::Insets(0, 0, width, 0), @@ -219,8 +217,7 @@ class WebNotificationBubbleWrapper { } views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( tray->GetBubbleWindowContainer(), anchor, tray, &init_params); - if (ash::switches::UseAlternateShelfLayout()) - bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); + bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); bubble->InitializeContents(bubble_view); } @@ -272,8 +269,7 @@ class WebNotificationButton : public views::CustomButton { protected: // Overridden from views::ImageButton: virtual gfx::Size GetPreferredSize() OVERRIDE { - const int notification_item_size = GetShelfItemHeight(); - return gfx::Size(notification_item_size, notification_item_size); + return gfx::Size(kShelfItemHeight, kShelfItemHeight); } virtual int GetHeightForWidth(int width) OVERRIDE { @@ -318,7 +314,7 @@ WebNotificationTray::WebNotificationTray(StatusAreaWidget* status_area_widget) kShellWindowId_StatusContainer), message_center(), message_center_tray_.get(), - ash::switches::UseAlternateShelfLayout())); + true)); work_area_observer_.reset(new WorkAreaObserver()); work_area_observer_->StartObserving( popup_collection_.get(), @@ -344,7 +340,7 @@ bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { new message_center::MessageCenterBubble( message_center(), message_center_tray_.get(), - ash::switches::UseAlternateShelfLayout()); + true); int max_height = 0; aura::Window* status_area_window = status_area_widget()->GetNativeView(); @@ -372,7 +368,7 @@ bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { } message_center_bubble->SetMaxHeight(std::max(0, - max_height - GetTraySpacing())); + max_height - kTraySpacing)); if (show_settings) message_center_bubble->SetSettingsVisible(); message_center_bubble_.reset( diff --git a/ash/test/shelf_view_test_api.cc b/ash/test/shelf_view_test_api.cc index d3d545c..d190f95 100644 --- a/ash/test/shelf_view_test_api.cc +++ b/ash/test/shelf_view_test_api.cc @@ -6,6 +6,7 @@ #include "ash/shelf/overflow_button.h" #include "ash/shelf/shelf_button.h" +#include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_view.h" #include "base/message_loop/message_loop.h" @@ -106,11 +107,11 @@ gfx::Size ShelfViewTestAPI::GetPreferredSize() { } int ShelfViewTestAPI::GetButtonSize() { - return shelf_view_->GetButtonSize(); + return kShelfButtonSize; } int ShelfViewTestAPI::GetButtonSpacing() { - return shelf_view_->GetButtonSpacing(); + return kShelfButtonSpacing; } bool ShelfViewTestAPI::SameDragType(ShelfItemType typea, diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index cf5e04d..aaf7012 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -173,7 +173,7 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(), views::BubbleBorder::FLOAT, true /* border_accepts_events */); - } else if (ash::switches::UseAlternateShelfLayout()) { + } else { gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> GetAppListButtonView()->GetBoundsInScreen(); // We need the location of the button within the local screen. @@ -190,14 +190,6 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { GetBubbleArrow(container), true /* border_accepts_events */); view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); - } else { - view->InitAsBubbleAttachedToAnchor( - container, - pagination_model_.get(), - Shelf::ForWindow(container)->GetAppListButtonView(), - gfx::Vector2d(), - GetBubbleArrow(container), - true /* border_accepts_events */); } SetView(view); // By setting us as DnD recipient, the app list knows that we can diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 47b89f5..0ea4798 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -946,14 +946,6 @@ const Experiment kExperiments[] = { }, #if defined(OS_CHROMEOS) { - "ash-use-alternate-shelf", - IDS_FLAGS_ALTERNATE_SHELF_LAYOUT_NAME, - IDS_FLAGS_ALTERNATE_SHELF_LAYOUT_DESCRIPTION, - kOsCrOS, - ENABLE_DISABLE_VALUE_TYPE(ash::switches::kAshUseAlternateShelfLayout, - ash::switches::kAshDisableAlternateShelfLayout) - }, - { "ash-disable-docked-windows", IDS_FLAGS_DOCKED_WINDOWS_NAME, IDS_FLAGS_DOCKED_WINDOWS_DESCRIPTION, diff --git a/chrome/browser/ui/apps/chrome_app_window_delegate.cc b/chrome/browser/ui/apps/chrome_app_window_delegate.cc index 8a8f82d..b0ccf7e 100644 --- a/chrome/browser/ui/apps/chrome_app_window_delegate.cc +++ b/chrome/browser/ui/apps/chrome_app_window_delegate.cc @@ -226,7 +226,7 @@ void ChromeAppWindowDelegate::RequestMediaAccessPermission( int ChromeAppWindowDelegate::PreferredIconSize() { #if defined(USE_ASH) - return ash::kShelfPreferredSize; + return ash::kShelfSize; #else return extension_misc::EXTENSION_ICON_SMALL; #endif diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc index bdfb818..656f47a 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc @@ -1054,8 +1054,7 @@ void ChromeLauncherController::ShelfItemAdded(int index) { // The app list launcher can get added to the shelf after we applied the // preferences. In that case the item might be at the wrong spot. As such we // call the function again. - if (model_->items()[index].type == ash::TYPE_APP_LIST && - ash::switches::UseAlternateShelfLayout()) + if (model_->items()[index].type == ash::TYPE_APP_LIST) UpdateAppLaunchersFromPref(); } @@ -1068,8 +1067,7 @@ void ChromeLauncherController::ShelfItemMoved(int start_index, // We remember the moved item position if it is either pinnable or // it is the app list with the alternate shelf layout. if ((HasItemController(item.id) && IsPinned(item.id)) || - (ash::switches::UseAlternateShelfLayout() && - item.type == ash::TYPE_APP_LIST)) + item.type == ash::TYPE_APP_LIST) PersistPinnedState(); } @@ -1817,18 +1815,17 @@ void ChromeLauncherController::MoveChromeOrApplistToFinalPosition( } int ChromeLauncherController::FindInsertionPoint(bool is_app_list) { - bool alternate = ash::switches::UseAlternateShelfLayout(); // Keeping this change small to backport to M33&32 (see crbug.com/329597). // TODO(skuhne): With the removal of the legacy shelf layout we should remove // the ability to move the app list item since this was never used. We should // instead ask the ShelfModel::ValidateInsertionIndex or similir for an index. - if (is_app_list && alternate) + if (is_app_list) return 0; for (int i = model_->item_count() - 1; i > 0; --i) { ash::ShelfItemType type = model_->items()[i].type; if (type == ash::TYPE_APP_SHORTCUT || - ((is_app_list || alternate) && type == ash::TYPE_APP_LIST) || + (is_app_list && type == ash::TYPE_APP_LIST) || type == ash::TYPE_BROWSER_SHORTCUT) { return i; } @@ -1918,10 +1915,7 @@ ChromeLauncherController::GetListOfPinnedAppsAndBrowser() { // If not added yet, add the app list item either at the end or at the // beginning - depending on the shelf layout. if (!app_list_icon_added) { - if (ash::switches::UseAlternateShelfLayout()) - pinned_apps.insert(pinned_apps.begin(), kAppShelfIdPlaceholder); - else - pinned_apps.push_back(kAppShelfIdPlaceholder); + pinned_apps.insert(pinned_apps.begin(), kAppShelfIdPlaceholder); } return pinned_apps; } diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc index 34576c8..800eecb 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc @@ -11,6 +11,7 @@ #include "ash/display/display_controller.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_button.h" +#include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_util.h" #include "ash/shelf/shelf_view.h" @@ -820,7 +821,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { EXPECT_TRUE(app_item_controller->image_set_by_controller()); EXPECT_TRUE(panel_item_controller->image_set_by_controller()); // Ensure icon heights are correct (see test.js in app_icon/ test directory) - EXPECT_EQ(48, app_item.image.height()); + EXPECT_EQ(ash::kShelfSize, app_item.image.height()); EXPECT_EQ(64, panel_item.image.height()); } diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc index 7dd122d..aee63e8 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc @@ -618,27 +618,6 @@ class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); }; -// The testing framework to test the legacy shelf layout. -class LegacyShelfLayoutChromeLauncherControllerTest - : public ChromeLauncherControllerTest { - protected: - LegacyShelfLayoutChromeLauncherControllerTest() { - } - - virtual ~LegacyShelfLayoutChromeLauncherControllerTest() { - } - - // Overwrite the Setup function to use the legacy shelf layout option. - virtual void SetUp() OVERRIDE { - CommandLine::ForCurrentProcess()->AppendSwitch( - ash::switches::kAshDisableAlternateShelfLayout); - ChromeLauncherControllerTest::SetUp(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(LegacyShelfLayoutChromeLauncherControllerTest); -}; - #if defined(OS_CHROMEOS) // A browser window proxy which is able to associate an aura native window with // it. @@ -967,178 +946,6 @@ class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest }; #endif // defined(OS_CHROMEOS) -TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, DefaultApps) { - InitLauncherController(); - // Model should only contain the browser shortcut and app list items. - EXPECT_EQ(2, model_->item_count()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - - // Installing |extension3_| should add it to the launcher - behind the - // chrome icon. - extension_service_->AddExtension(extension3_.get()); - EXPECT_EQ("Chrome, App3, AppList", GetPinnedAppStatus()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); -} - -// Check that the restauration of launcher items is happening in the same order -// as the user has pinned them (on another system) when they are synced reverse -// order. -TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, - RestoreDefaultAppsReverseOrder) { - InitLauncherController(); - - base::ListValue policy_value; - InsertPrefValue(&policy_value, 0, extension1_->id()); - InsertPrefValue(&policy_value, 1, extension2_->id()); - InsertPrefValue(&policy_value, 2, extension3_->id()); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value.DeepCopy()); - EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); - // Model should only contain the browser shortcut and app list items. - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("Chrome, AppList", GetPinnedAppStatus()); - - // Installing |extension3_| should add it to the shelf - behind the - // chrome icon. - ash::ShelfItem item; - extension_service_->AddExtension(extension3_.get()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); - EXPECT_EQ("Chrome, App3, AppList", GetPinnedAppStatus()); - - // Installing |extension2_| should add it to the launcher - behind the - // chrome icon, but in first location. - extension_service_->AddExtension(extension2_.get()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_EQ("Chrome, App2, App3, AppList", GetPinnedAppStatus()); - - // Installing |extension1_| should add it to the launcher - behind the - // chrome icon, but in first location. - extension_service_->AddExtension(extension1_.get()); - EXPECT_EQ("Chrome, App1, App2, App3, AppList", GetPinnedAppStatus()); -} - -// Check that the restauration of launcher items is happening in the same order -// as the user has pinned them (on another system) when they are synced random -// order. -TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, - RestoreDefaultAppsRandomOrder) { - InitLauncherController(); - - base::ListValue policy_value; - InsertPrefValue(&policy_value, 0, extension1_->id()); - InsertPrefValue(&policy_value, 1, extension2_->id()); - InsertPrefValue(&policy_value, 2, extension3_->id()); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value.DeepCopy()); - EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); - // Model should only contain the browser shortcut and app list items. - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("Chrome, AppList", GetPinnedAppStatus()); - - // Installing |extension2_| should add it to the launcher - behind the - // chrome icon. - extension_service_->AddExtension(extension2_.get()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("Chrome, App2, AppList", GetPinnedAppStatus()); - - // Installing |extension1_| should add it to the launcher - behind the - // chrome icon, but in first location. - extension_service_->AddExtension(extension1_.get()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("Chrome, App1, App2, AppList", GetPinnedAppStatus()); - - // Installing |extension3_| should add it to the launcher - behind the - // chrome icon, but in first location. - extension_service_->AddExtension(extension3_.get()); - EXPECT_EQ("Chrome, App1, App2, App3, AppList", GetPinnedAppStatus()); -} - -// Check that the restauration of launcher items is happening in the same order -// as the user has pinned / moved them (on another system) when they are synced -// random order - including the chrome icon. -TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, - RestoreDefaultAppsRandomOrderChromeMoved) { - InitLauncherController(); - - base::ListValue policy_value; - InsertPrefValue(&policy_value, 0, extension1_->id()); - InsertPrefValue(&policy_value, 1, extension2_->id()); - InsertPrefValue(&policy_value, 2, extension3_->id()); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value.DeepCopy()); - profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, - 1); - // Model should only contain the browser shortcut and app list items. - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("Chrome, AppList", GetPinnedAppStatus()); - - // Installing |extension2_| should add it to the shelf - behind the - // chrome icon. - ash::ShelfItem item; - extension_service_->AddExtension(extension2_.get()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("Chrome, App2, AppList", GetPinnedAppStatus()); - - // Installing |extension1_| should add it to the launcher - behind the - // chrome icon, but in first location. - extension_service_->AddExtension(extension1_.get()); - EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); - EXPECT_EQ("App1, Chrome, App2, AppList", GetPinnedAppStatus()); - - // Installing |extension3_| should add it to the launcher - behind the - // chrome icon, but in first location. - extension_service_->AddExtension(extension3_.get()); - EXPECT_EQ("App1, Chrome, App2, App3, AppList", GetPinnedAppStatus()); -} - -// Check that syncing to a different state does the correct thing. -TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, - RestoreDefaultAppsResyncOrder) { - InitLauncherController(); - base::ListValue policy_value; - InsertPrefValue(&policy_value, 0, extension1_->id()); - InsertPrefValue(&policy_value, 1, extension2_->id()); - InsertPrefValue(&policy_value, 2, extension3_->id()); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value.DeepCopy()); - EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); - extension_service_->AddExtension(extension2_.get()); - extension_service_->AddExtension(extension1_.get()); - extension_service_->AddExtension(extension3_.get()); - EXPECT_EQ("Chrome, App1, App2, App3, AppList", GetPinnedAppStatus()); - - // Change the order with increasing chrome position and decreasing position. - base::ListValue policy_value1; - InsertPrefValue(&policy_value1, 0, extension3_->id()); - InsertPrefValue(&policy_value1, 1, extension1_->id()); - InsertPrefValue(&policy_value1, 2, extension2_->id()); - profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, - 2); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value1.DeepCopy()); - EXPECT_EQ("App3, App1, Chrome, App2, AppList", GetPinnedAppStatus()); - base::ListValue policy_value2; - InsertPrefValue(&policy_value2, 0, extension2_->id()); - InsertPrefValue(&policy_value2, 1, extension3_->id()); - InsertPrefValue(&policy_value2, 2, extension1_->id()); - profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, - 1); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value2.DeepCopy()); - EXPECT_EQ("App2, Chrome, App3, App1, AppList", GetPinnedAppStatus()); -} TEST_F(ChromeLauncherControllerTest, DefaultApps) { InitLauncherController(); @@ -1156,29 +963,6 @@ TEST_F(ChromeLauncherControllerTest, DefaultApps) { EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); } -// Check that changing from the alternate shelf layout to the old shelflayout -// and back does keep the app launcher at location #0. -TEST_F(ChromeLauncherControllerTest, - SwitchingFromAlternateShelfLayoutToLegacyAndBack) { - InitLauncherController(); - - // We simulate this problem by intentionally placing the app list item in - // the middle of several apps which caused a crash (see crbug.com/329597). - const char kAppShelfIdPlaceholder[] = "AppShelfIDPlaceholder--------"; - - base::ListValue policy_value; - InsertPrefValue(&policy_value, 0, extension1_->id()); - InsertPrefValue(&policy_value, 1, kAppShelfIdPlaceholder); - InsertPrefValue(&policy_value, 2, extension2_->id()); - profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, - policy_value.DeepCopy()); - EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); - // Model should only contain the browser shortcut and app list items. - extension_service_->AddExtension(extension1_.get()); - extension_service_->AddExtension(extension2_.get()); - EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); -} - // Check that the restauration of launcher items is happening in the same order // as the user has pinned them (on another system) when they are synced reverse // order. diff --git a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc index 895441e..d1fc953 100644 --- a/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc +++ b/chrome/browser/ui/ash/launcher/launcher_favicon_loader.cc @@ -19,7 +19,7 @@ const int kMaxBitmapSize = 256; //////////////////////////////////////////////////////////////////////////////// // FaviconBitmapHandler fetchs all bitmaps with the 'icon' (or 'shortcut icon') -// link tag, storing the one that best matches ash::kShelfPreferredSize. +// link tag, storing the one that best matches ash::kShelfSize. // These icon bitmaps are not resized and are not cached beyond the lifetime // of the class. Bitmaps larger than kMaxBitmapSize are ignored. @@ -147,7 +147,7 @@ void FaviconBitmapHandler::AddFavicon(const GURL& image_url, if (new_bitmap.height() > kMaxBitmapSize || new_bitmap.width() > kMaxBitmapSize) return; - if (new_bitmap.height() < ash::kShelfPreferredSize) + if (new_bitmap.height() < ash::kShelfSize) return; if (!bitmap_.isNull()) { // We want the smallest icon that is large enough. diff --git a/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc b/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc index 546489f..e408851 100644 --- a/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc +++ b/chrome/browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc @@ -158,8 +158,8 @@ IN_PROC_BROWSER_TEST_F(LauncherFaviconLoaderBrowsertest, ManyLauncherIcons) { EXPECT_FALSE(favicon_loader_->GetFavicon().empty()); // When multiple favicons are present, the correctly sized icon should be - // chosen. The icons are sized assuming ash::kShelfPreferredSize < 128. - EXPECT_GT(128, ash::kShelfPreferredSize); + // chosen. The icons are sized assuming ash::kShelfSize < 128. + EXPECT_GT(128, ash::kShelfSize); EXPECT_EQ(48, favicon_loader_->GetFavicon().height()); } |