diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-23 21:20:24 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-23 21:20:24 +0000 |
commit | ccfd691d2bd16c1db2324ec36db225630f551ee9 (patch) | |
tree | 113c53ab11e0782acb643eb6807729d3fcfb0a7c /ash | |
parent | 8d7aa0159fc1c19e0a82a3366e5354de356a2831 (diff) | |
download | chromium_src-ccfd691d2bd16c1db2324ec36db225630f551ee9.zip chromium_src-ccfd691d2bd16c1db2324ec36db225630f551ee9.tar.gz chromium_src-ccfd691d2bd16c1db2324ec36db225630f551ee9.tar.bz2 |
ash: Rename LauncherButton to ShelfButton.
* Move launcher_button.* from launcher/ to shelf/
* Rename to shelf_button.*
BUG=248353
TEST=None, no functional changes
R=jamescook@chromium.org,harrym@chromium.org
Review URL: https://codereview.chromium.org/83953003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 4 | ||||
-rw-r--r-- | ash/launcher/launcher_unittest.cc | 14 | ||||
-rw-r--r-- | ash/shelf/shelf_button.cc (renamed from ash/launcher/launcher_button.cc) | 128 | ||||
-rw-r--r-- | ash/shelf/shelf_button.h (renamed from ash/launcher/launcher_button.h) | 28 | ||||
-rw-r--r-- | ash/shelf/shelf_view.cc | 61 | ||||
-rw-r--r-- | ash/shelf/shelf_view.h | 2 | ||||
-rw-r--r-- | ash/shelf/shelf_view_unittest.cc | 74 | ||||
-rw-r--r-- | ash/shelf/shelf_widget_unittest.cc | 2 | ||||
-rw-r--r-- | ash/test/shelf_view_test_api.cc | 8 | ||||
-rw-r--r-- | ash/test/shelf_view_test_api.h | 4 | ||||
-rw-r--r-- | ash/wm/panels/panel_layout_manager_unittest.cc | 2 |
11 files changed, 161 insertions, 166 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index 0d40a16..515ac76 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -156,8 +156,6 @@ 'keyboard_uma_event_filter.h', 'launcher/launcher.cc', 'launcher/launcher.h', - 'launcher/launcher_button.cc', - 'launcher/launcher_button.h', 'launcher/launcher_delegate.h', 'launcher/launcher_item_delegate_manager.cc', 'launcher/launcher_item_delegate_manager.h', @@ -209,6 +207,8 @@ 'shelf/shelf_alignment_menu.h', 'shelf/shelf_bezel_event_filter.cc', 'shelf/shelf_bezel_event_filter.h', + 'shelf/shelf_button.cc', + 'shelf/shelf_button.h', 'shelf/shelf_button_host.h', 'shelf/shelf_icon_observer.h', 'shelf/shelf_layout_manager.cc', diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc index 32dafb6..6359508 100644 --- a/ash/launcher/launcher_unittest.cc +++ b/ash/launcher/launcher_unittest.cc @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "ash/launcher/launcher.h" -#include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_item_delegate_manager.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" @@ -27,7 +27,7 @@ typedef ash::test::AshTestBase LauncherTest; using ash::internal::ShelfView; -using ash::internal::LauncherButton; +using ash::internal::ShelfButton; namespace ash { @@ -101,8 +101,8 @@ TEST_F(LauncherTest, StatusReflection) { item.status = STATUS_RUNNING; int index = shelf_model()->Add(item); ASSERT_EQ(++button_count, test_api()->GetButtonCount()); - LauncherButton* button = test_api()->GetButton(index); - EXPECT_EQ(LauncherButton::STATE_RUNNING, button->state()); + ShelfButton* button = test_api()->GetButton(index); + EXPECT_EQ(ShelfButton::STATE_RUNNING, button->state()); // Remove it. shelf_model()->RemoveItemAt(index); @@ -127,10 +127,10 @@ TEST_F(LauncherTest, checkHoverAfterMenu) { delegate.Pass()); ASSERT_EQ(++button_count, test_api()->GetButtonCount()); - LauncherButton* button = test_api()->GetButton(index); - button->AddState(LauncherButton::STATE_HOVERED); + ShelfButton* button = test_api()->GetButton(index); + button->AddState(ShelfButton::STATE_HOVERED); button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); - EXPECT_FALSE(button->state() & LauncherButton::STATE_HOVERED); + EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED); // Remove it. shelf_model()->RemoveItemAt(index); diff --git a/ash/launcher/launcher_button.cc b/ash/shelf/shelf_button.cc index 469f4fc..4b10b8f 100644 --- a/ash/launcher/launcher_button.cc +++ b/ash/shelf/shelf_button.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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/launcher/launcher_button.h" +#include "ash/shelf/shelf_button.h" #include <algorithm> @@ -39,14 +39,14 @@ const int kHopDownMS = 200; const int kAttentionThrobDurationMS = 800; bool ShouldHop(int state) { - return state & ash::internal::LauncherButton::STATE_HOVERED || - state & ash::internal::LauncherButton::STATE_ACTIVE || - state & ash::internal::LauncherButton::STATE_FOCUSED; + return state & ash::internal::ShelfButton::STATE_HOVERED || + state & ash::internal::ShelfButton::STATE_ACTIVE || + state & ash::internal::ShelfButton::STATE_FOCUSED; } // Simple AnimationDelegate that owns a single ThrobAnimation instance to // keep all Draw Attention animations in sync. -class LauncherButtonAnimation : public gfx::AnimationDelegate { +class ShelfButtonAnimation : public gfx::AnimationDelegate { public: class Observer { public: @@ -56,8 +56,8 @@ class LauncherButtonAnimation : public gfx::AnimationDelegate { virtual ~Observer() {} }; - static LauncherButtonAnimation* GetInstance() { - static LauncherButtonAnimation* s_instance = new LauncherButtonAnimation(); + static ShelfButtonAnimation* GetInstance() { + static ShelfButtonAnimation* s_instance = new ShelfButtonAnimation(); return s_instance; } @@ -80,13 +80,13 @@ class LauncherButtonAnimation : public gfx::AnimationDelegate { } private: - LauncherButtonAnimation() + ShelfButtonAnimation() : animation_(this) { animation_.SetThrobDuration(kAttentionThrobDurationMS); animation_.SetTweenType(gfx::Tween::SMOOTH_IN_OUT); } - virtual ~LauncherButtonAnimation() { + virtual ~ShelfButtonAnimation() { } gfx::ThrobAnimation& GetThrobAnimation() { @@ -109,7 +109,7 @@ class LauncherButtonAnimation : public gfx::AnimationDelegate { gfx::ThrobAnimation animation_; ObserverList<Observer> observers_; - DISALLOW_COPY_AND_ASSIGN(LauncherButtonAnimation); + DISALLOW_COPY_AND_ASSIGN(ShelfButtonAnimation); }; } // namespace @@ -118,19 +118,19 @@ namespace ash { namespace internal { //////////////////////////////////////////////////////////////////////////////// -// LauncherButton::BarView +// ShelfButton::BarView -class LauncherButton::BarView : public views::ImageView, - public LauncherButtonAnimation::Observer { +class ShelfButton::BarView : public views::ImageView, + public ShelfButtonAnimation::Observer { public: - BarView(LauncherButton* host) + BarView(ShelfButton* host) : host_(host), show_attention_(false) { } virtual ~BarView() { if (show_attention_) - LauncherButtonAnimation::GetInstance()->RemoveObserver(this); + ShelfButtonAnimation::GetInstance()->RemoveObserver(this); } // View @@ -141,7 +141,7 @@ class LauncherButton::BarView : public views::ImageView, virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { if (show_attention_) { - int alpha = LauncherButtonAnimation::GetInstance()->GetAlpha(); + int alpha = ShelfButtonAnimation::GetInstance()->GetAlpha(); canvas->SaveLayerAlpha(alpha); views::ImageView::OnPaint(canvas); canvas->Restore(); @@ -150,7 +150,7 @@ class LauncherButton::BarView : public views::ImageView, } } - // LauncherButtonAnimation::Observer + // ShelfButtonAnimation::Observer virtual void AnimationProgressed() OVERRIDE { UpdateBounds(); SchedulePaint(); @@ -165,9 +165,9 @@ class LauncherButton::BarView : public views::ImageView, if (show_attention_ != show) { show_attention_ = show; if (show_attention_) - LauncherButtonAnimation::GetInstance()->AddObserver(this); + ShelfButtonAnimation::GetInstance()->AddObserver(this); else - LauncherButtonAnimation::GetInstance()->RemoveObserver(this); + ShelfButtonAnimation::GetInstance()->RemoveObserver(this); } UpdateBounds(); } @@ -179,7 +179,7 @@ class LauncherButton::BarView : public views::ImageView, // Scale from .35 to 1.0 of the total width (which is wider than the // visible width of the image, so the animation "rests" briefly at full // visible width. - double animation = LauncherButtonAnimation::GetInstance()->GetAnimation(); + double animation = ShelfButtonAnimation::GetInstance()->GetAnimation(); double scale = (.35 + .65 * animation); if (host_->shelf_layout_manager()->GetAlignment() == SHELF_ALIGNMENT_BOTTOM) { @@ -195,7 +195,7 @@ class LauncherButton::BarView : public views::ImageView, SetBoundsRect(bounds); } - LauncherButton* host_; + ShelfButton* host_; bool show_attention_; gfx::Rect base_bounds_; @@ -203,35 +203,33 @@ class LauncherButton::BarView : public views::ImageView, }; //////////////////////////////////////////////////////////////////////////////// -// LauncherButton::IconView +// ShelfButton::IconView -LauncherButton::IconView::IconView() : icon_size_(kIconSize) { +ShelfButton::IconView::IconView() : icon_size_(kIconSize) { } -LauncherButton::IconView::~IconView() { +ShelfButton::IconView::~IconView() { } -bool LauncherButton::IconView::HitTestRect(const gfx::Rect& rect) const { - // Return false so that LauncherButton gets all the mouse events. +bool ShelfButton::IconView::HitTestRect(const gfx::Rect& rect) const { + // Return false so that ShelfButton gets all the mouse events. return false; } //////////////////////////////////////////////////////////////////////////////// -// LauncherButton - -LauncherButton* LauncherButton::Create( - views::ButtonListener* listener, - ShelfButtonHost* host, - ShelfLayoutManager* shelf_layout_manager) { - LauncherButton* button = - new LauncherButton(listener, host, shelf_layout_manager); +// ShelfButton + +ShelfButton* ShelfButton::Create(views::ButtonListener* listener, + ShelfButtonHost* host, + ShelfLayoutManager* shelf_layout_manager) { + ShelfButton* button = new ShelfButton(listener, host, shelf_layout_manager); button->Init(); return button; } -LauncherButton::LauncherButton(views::ButtonListener* listener, - ShelfButtonHost* host, - ShelfLayoutManager* shelf_layout_manager) +ShelfButton::ShelfButton(views::ButtonListener* listener, + ShelfButtonHost* host, + ShelfLayoutManager* shelf_layout_manager) : CustomButton(listener), host_(host), icon_view_(NULL), @@ -251,17 +249,17 @@ LauncherButton::LauncherButton(views::ButtonListener* listener, AddChildView(bar_); } -LauncherButton::~LauncherButton() { +ShelfButton::~ShelfButton() { if (destroyed_flag_) *destroyed_flag_ = true; } -void LauncherButton::SetShadowedImage(const gfx::ImageSkia& image) { +void ShelfButton::SetShadowedImage(const gfx::ImageSkia& image) { icon_view_->SetImage(gfx::ImageSkiaOperations::CreateImageWithDropShadow( image, icon_shadows_)); } -void LauncherButton::SetImage(const gfx::ImageSkia& image) { +void ShelfButton::SetImage(const gfx::ImageSkia& image) { if (image.isNull()) { // TODO: need an empty image. icon_view_->SetImage(image); @@ -293,11 +291,11 @@ void LauncherButton::SetImage(const gfx::ImageSkia& image) { skia::ImageOperations::RESIZE_BEST, gfx::Size(width, height))); } -const gfx::ImageSkia& LauncherButton::GetImage() const { +const gfx::ImageSkia& ShelfButton::GetImage() const { return icon_view_->GetImage(); } -void LauncherButton::AddState(State state) { +void ShelfButton::AddState(State state) { if (!(state_ & state)) { if (!ash::switches::UseAlternateShelfLayout() && (ShouldHop(state) || !ShouldHop(state_))) { @@ -313,7 +311,7 @@ void LauncherButton::AddState(State state) { } } -void LauncherButton::ClearState(State state) { +void ShelfButton::ClearState(State state) { if (state_ & state) { if (!ash::switches::UseAlternateShelfLayout() && (!ShouldHop(state) || ShouldHop(state_))) { @@ -330,12 +328,12 @@ void LauncherButton::ClearState(State state) { } } -gfx::Rect LauncherButton::GetIconBounds() const { +gfx::Rect ShelfButton::GetIconBounds() const { return icon_view_->bounds(); } -void LauncherButton::ShowContextMenu(const gfx::Point& p, - ui::MenuSourceType source_type) { +void ShelfButton::ShowContextMenu(const gfx::Point& p, + ui::MenuSourceType source_type) { if (!context_menu_controller()) return; @@ -353,52 +351,52 @@ void LauncherButton::ShowContextMenu(const gfx::Point& p, } } -bool LauncherButton::OnMousePressed(const ui::MouseEvent& event) { +bool ShelfButton::OnMousePressed(const ui::MouseEvent& event) { CustomButton::OnMousePressed(event); host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event); return true; } -void LauncherButton::OnMouseReleased(const ui::MouseEvent& event) { +void ShelfButton::OnMouseReleased(const ui::MouseEvent& event) { CustomButton::OnMouseReleased(event); host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, false); } -void LauncherButton::OnMouseCaptureLost() { +void ShelfButton::OnMouseCaptureLost() { ClearState(STATE_HOVERED); host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, true); CustomButton::OnMouseCaptureLost(); } -bool LauncherButton::OnMouseDragged(const ui::MouseEvent& event) { +bool ShelfButton::OnMouseDragged(const ui::MouseEvent& event) { CustomButton::OnMouseDragged(event); host_->PointerDraggedOnButton(this, ShelfButtonHost::MOUSE, event); return true; } -void LauncherButton::OnMouseMoved(const ui::MouseEvent& event) { +void ShelfButton::OnMouseMoved(const ui::MouseEvent& event) { CustomButton::OnMouseMoved(event); host_->MouseMovedOverButton(this); } -void LauncherButton::OnMouseEntered(const ui::MouseEvent& event) { +void ShelfButton::OnMouseEntered(const ui::MouseEvent& event) { AddState(STATE_HOVERED); CustomButton::OnMouseEntered(event); host_->MouseEnteredButton(this); } -void LauncherButton::OnMouseExited(const ui::MouseEvent& event) { +void ShelfButton::OnMouseExited(const ui::MouseEvent& event) { ClearState(STATE_HOVERED); CustomButton::OnMouseExited(event); host_->MouseExitedButton(this); } -void LauncherButton::GetAccessibleState(ui::AccessibleViewState* state) { +void ShelfButton::GetAccessibleState(ui::AccessibleViewState* state) { state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; state->name = host_->GetAccessibleName(this); } -void LauncherButton::Layout() { +void ShelfButton::Layout() { const gfx::Rect button_bounds(GetContentsBounds()); int icon_pad = kIconPad; if (ash::switches::UseAlternateShelfLayout()) { @@ -458,21 +456,21 @@ void LauncherButton::Layout() { UpdateState(); } -void LauncherButton::ChildPreferredSizeChanged(views::View* child) { +void ShelfButton::ChildPreferredSizeChanged(views::View* child) { Layout(); } -void LauncherButton::OnFocus() { +void ShelfButton::OnFocus() { AddState(STATE_FOCUSED); CustomButton::OnFocus(); } -void LauncherButton::OnBlur() { +void ShelfButton::OnBlur() { ClearState(STATE_FOCUSED); CustomButton::OnBlur(); } -void LauncherButton::OnGestureEvent(ui::GestureEvent* event) { +void ShelfButton::OnGestureEvent(ui::GestureEvent* event) { switch (event->type()) { case ui::ET_GESTURE_TAP_DOWN: AddState(STATE_HOVERED); @@ -498,7 +496,7 @@ void LauncherButton::OnGestureEvent(ui::GestureEvent* event) { } } -void LauncherButton::Init() { +void ShelfButton::Init() { icon_view_ = CreateIconView(); // TODO: refactor the layers so each button doesn't require 2. @@ -510,15 +508,15 @@ void LauncherButton::Init() { AddChildView(icon_view_); } -LauncherButton::IconView* LauncherButton::CreateIconView() { +ShelfButton::IconView* ShelfButton::CreateIconView() { return new IconView; } -bool LauncherButton::IsShelfHorizontal() const { +bool ShelfButton::IsShelfHorizontal() const { return shelf_layout_manager_->IsHorizontalAlignment(); } -void LauncherButton::UpdateState() { +void ShelfButton::UpdateState() { UpdateBar(); icon_view_->SetHorizontalAlignment( @@ -530,7 +528,7 @@ void LauncherButton::UpdateState() { SchedulePaint(); } -void LauncherButton::UpdateBar() { +void ShelfButton::UpdateBar() { if (state_ & STATE_HIDDEN) { bar_->SetVisible(false); return; diff --git a/ash/launcher/launcher_button.h b/ash/shelf/shelf_button.h index b148fed..1bfc510 100644 --- a/ash/launcher/launcher_button.h +++ b/ash/shelf/shelf_button.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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_LAUNCHER_LAUNCHER_BUTTON_H_ -#define ASH_LAUNCHER_LAUNCHER_BUTTON_H_ +#ifndef ASH_SHELF_SHELF_BUTTON_H_ +#define ASH_SHELF_SHELF_BUTTON_H_ #include "ash/ash_export.h" #include "ui/gfx/shadow_value.h" @@ -17,7 +17,7 @@ class ShelfButtonHost; class ShelfLayoutManager; // Button used for items on the launcher, except for the AppList. -class ASH_EXPORT LauncherButton : public views::CustomButton { +class ASH_EXPORT ShelfButton : public views::CustomButton { public: // Used to indicate the current state of the button. enum State { @@ -37,12 +37,12 @@ class ASH_EXPORT LauncherButton : public views::CustomButton { STATE_HIDDEN = 1 << 5, }; - virtual ~LauncherButton(); + virtual ~ShelfButton(); - // Called to create an instance of a LauncherButton. - static LauncherButton* Create(views::ButtonListener* listener, - ShelfButtonHost* host, - ShelfLayoutManager* shelf_layout_manager); + // Called to create an instance of a ShelfButton. + static ShelfButton* Create(views::ButtonListener* listener, + ShelfButtonHost* host, + ShelfLayoutManager* shelf_layout_manager); // Sets the image to display for this entry. void SetImage(const gfx::ImageSkia& image); @@ -69,9 +69,9 @@ class ASH_EXPORT LauncherButton : public views::CustomButton { virtual void OnMouseCaptureLost() OVERRIDE; protected: - LauncherButton(views::ButtonListener* listener, - ShelfButtonHost* host, - ShelfLayoutManager* shelf_layout_manager); + ShelfButton(views::ButtonListener* listener, + ShelfButtonHost* host, + ShelfLayoutManager* shelf_layout_manager); // Class that draws the icon part of a button, so it can be animated // independently of the rest. This can be subclassed to provide a custom @@ -150,10 +150,10 @@ class ASH_EXPORT LauncherButton : public views::CustomButton { // showing and used to detect if the menu was deleted while running. bool* destroyed_flag_; - DISALLOW_COPY_AND_ASSIGN(LauncherButton); + DISALLOW_COPY_AND_ASSIGN(ShelfButton); }; } // namespace internal } // namespace ash -#endif // ASH_LAUNCHER_LAUNCHER_BUTTON_H_ +#endif // ASH_SHELF_SHELF_BUTTON_H_ diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index b4ba1f9..87316fb 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -9,7 +9,6 @@ #include "ash/ash_constants.h" #include "ash/ash_switches.h" #include "ash/drag_drop/drag_image_view.h" -#include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_delegate.h" #include "ash/launcher/launcher_item_delegate.h" #include "ash/launcher/launcher_item_delegate_manager.h" @@ -19,6 +18,7 @@ #include "ash/shelf/app_list_button.h" #include "ash/shelf/overflow_bubble.h" #include "ash/shelf/overflow_button.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_icon_observer.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_model.h" @@ -241,10 +241,10 @@ class LauncherFocusSearch : public views::FocusSearch { DISALLOW_COPY_AND_ASSIGN(LauncherFocusSearch); }; -class LauncherButtonFocusBorder : public views::FocusBorder { +class ShelfButtonFocusBorder : public views::FocusBorder { public: - LauncherButtonFocusBorder() {} - virtual ~LauncherButtonFocusBorder() {} + ShelfButtonFocusBorder() {} + virtual ~ShelfButtonFocusBorder() {} private: // views::FocusBorder overrides: @@ -254,7 +254,7 @@ class LauncherButtonFocusBorder : public views::FocusBorder { canvas->DrawRect(rect, kFocusBorderColor); } - DISALLOW_COPY_AND_ASSIGN(LauncherButtonFocusBorder); + DISALLOW_COPY_AND_ASSIGN(ShelfButtonFocusBorder); }; // AnimationDelegate used when inserting a new item. This steadily increases the @@ -285,28 +285,27 @@ class FadeInAnimationDelegate DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate); }; -void ReflectItemStatus(const ash::LauncherItem& item, - LauncherButton* button) { +void ReflectItemStatus(const ash::LauncherItem& item, ShelfButton* button) { switch (item.status) { case STATUS_CLOSED: - button->ClearState(LauncherButton::STATE_ACTIVE); - button->ClearState(LauncherButton::STATE_RUNNING); - button->ClearState(LauncherButton::STATE_ATTENTION); + button->ClearState(ShelfButton::STATE_ACTIVE); + button->ClearState(ShelfButton::STATE_RUNNING); + button->ClearState(ShelfButton::STATE_ATTENTION); break; case STATUS_RUNNING: - button->ClearState(LauncherButton::STATE_ACTIVE); - button->AddState(LauncherButton::STATE_RUNNING); - button->ClearState(LauncherButton::STATE_ATTENTION); + button->ClearState(ShelfButton::STATE_ACTIVE); + button->AddState(ShelfButton::STATE_RUNNING); + button->ClearState(ShelfButton::STATE_ATTENTION); break; case STATUS_ACTIVE: - button->AddState(LauncherButton::STATE_ACTIVE); - button->ClearState(LauncherButton::STATE_RUNNING); - button->ClearState(LauncherButton::STATE_ATTENTION); + button->AddState(ShelfButton::STATE_ACTIVE); + button->ClearState(ShelfButton::STATE_RUNNING); + button->ClearState(ShelfButton::STATE_ATTENTION); break; case STATUS_ATTENTION: - button->ClearState(LauncherButton::STATE_ACTIVE); - button->ClearState(LauncherButton::STATE_RUNNING); - button->AddState(LauncherButton::STATE_ATTENTION); + button->ClearState(ShelfButton::STATE_ACTIVE); + button->ClearState(ShelfButton::STATE_RUNNING); + button->AddState(ShelfButton::STATE_ATTENTION); break; } } @@ -487,8 +486,7 @@ gfx::Rect ShelfView::GetIdealBoundsOfItemIcon(LauncherID id) { return gfx::Rect(); const gfx::Rect& ideal_bounds(view_model_->ideal_bounds(index)); DCHECK_NE(TYPE_APP_LIST, model_->items()[index].type); - LauncherButton* button = - static_cast<LauncherButton*>(view_model_->view_at(index)); + ShelfButton* button = static_cast<ShelfButton*>(view_model_->view_at(index)); gfx::Rect icon_bounds = button->GetIconBounds(); return gfx::Rect(GetMirroredXWithWidthInView( ideal_bounds.x() + icon_bounds.x(), icon_bounds.width()), @@ -921,8 +919,7 @@ views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: case TYPE_APP_PANEL: { - LauncherButton* button = - LauncherButton::Create(this, this, layout_manager_); + ShelfButton* button = ShelfButton::Create(this, this, layout_manager_); button->SetImage(item.image); ReflectItemStatus(item, button); view = button; @@ -935,7 +932,7 @@ views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { this, layout_manager_->shelf_widget()); } else { - // TODO(dave): turn this into a LauncherButton too. + // TODO(dave): turn this into a ShelfButton too. AppListButton* button = new AppListButton(this, this); button->SetImageAlignment( layout_manager_->SelectValueForShelfAlignment( @@ -957,7 +954,7 @@ views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { break; } view->set_context_menu_controller(this); - view->set_focus_border(new LauncherButtonFocusBorder); + view->set_focus_border(new ShelfButtonFocusBorder); DCHECK(view); ConfigureChildView(view); @@ -1103,7 +1100,7 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) { int delta = CalculateShelfDistance(event.root_location()); if (delta > kRipOffDistance) { // Create a proxy view item which can be moved anywhere. - LauncherButton* button = static_cast<LauncherButton*>(drag_view_); + ShelfButton* button = static_cast<ShelfButton*>(drag_view_); CreateDragIconProxy(event.root_location(), button->GetImage(), drag_view_, @@ -1178,8 +1175,8 @@ void ShelfView::FinalizeRipOffDrag(bool cancel) { // animation end the flag gets cleared if |snap_back_from_rip_off_view_| // is set. snap_back_from_rip_off_view_ = drag_view_; - LauncherButton* button = static_cast<LauncherButton*>(drag_view_); - button->AddState(LauncherButton::STATE_HIDDEN); + ShelfButton* button = static_cast<ShelfButton*>(drag_view_); + button->AddState(ShelfButton::STATE_HIDDEN); // When a canceling drag model is happening, the view model is diverged // from the menu model and movements / animations should not be done. model_->Move(current_index, start_drag_index_); @@ -1560,7 +1557,7 @@ void ShelfView::ShelfItemChanged(int model_index, case TYPE_WINDOWED_APP: case TYPE_PLATFORM_APP: case TYPE_APP_PANEL: { - LauncherButton* button = static_cast<LauncherButton*>(view); + ShelfButton* button = static_cast<ShelfButton*>(view); ReflectItemStatus(item, button); // The browser shortcut is currently not a "real" item and as such the // the image is bogous as well. We therefore keep the image as is for it. @@ -1903,15 +1900,15 @@ void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { if (snap_back_from_rip_off_view_ && animator == bounds_animator_) { if (!animator->IsAnimating(snap_back_from_rip_off_view_)) { - // Coming here the animation of the LauncherButton is finished and the + // Coming here the animation of the ShelfButton is finished and the // previously hidden status can be shown again. Since the button itself // might have gone away or changed locations we check that the button // is still in the shelf and show its status again. for (int index = 0; index < view_model_->view_size(); index++) { views::View* view = view_model_->view_at(index); if (view == snap_back_from_rip_off_view_) { - LauncherButton* button = static_cast<LauncherButton*>(view); - button->ClearState(LauncherButton::STATE_HIDDEN); + ShelfButton* button = static_cast<ShelfButton*>(view); + button->ClearState(ShelfButton::STATE_HIDDEN); break; } } diff --git a/ash/shelf/shelf_view.h b/ash/shelf/shelf_view.h index 9f34fdb..4d6545e 100644 --- a/ash/shelf/shelf_view.h +++ b/ash/shelf/shelf_view.h @@ -41,9 +41,9 @@ class ShelfModel; namespace internal { class DragImageView; -class LauncherButton; class OverflowBubble; class OverflowButton; +class ShelfButton; class ShelfLayoutManager; class ShelfTooltipManager; diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc index c9fd32f..21f3f91 100644 --- a/ash/shelf/shelf_view_unittest.cc +++ b/ash/shelf/shelf_view_unittest.cc @@ -9,11 +9,11 @@ #include "ash/ash_switches.h" #include "ash/launcher/launcher.h" -#include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_item_delegate_manager.h" #include "ash/launcher/launcher_types.h" #include "ash/root_window_controller.h" #include "ash/shelf/overflow_bubble.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_icon_observer.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_model.h" @@ -318,7 +318,7 @@ class ShelfViewTest : public AshTestBase { test_api_->RunMessageLoopUntilAnimationsDone(); } - internal::LauncherButton* GetButtonByID(LauncherID id) { + internal::ShelfButton* GetButtonByID(LauncherID id) { int index = model_->ItemIndexByID(id); return test_api_->GetButton(index); } @@ -397,7 +397,7 @@ class ShelfViewTest : public AshTestBase { std::vector<std::pair<LauncherID, views::View*> >* id_map) { // Initialize |id_map| with the automatically-created launcher buttons. for (size_t i = 0; i < model_->items().size(); ++i) { - internal::LauncherButton* button = test_api_->GetButton(i); + internal::ShelfButton* button = test_api_->GetButton(i); id_map->push_back(std::make_pair(model_->items()[i].id, button)); } ASSERT_NO_FATAL_FAILURE(CheckModelIDs(*id_map)); @@ -499,7 +499,7 @@ class ShelfViewTextDirectionTest // in both LTR and RTL. TEST_P(ShelfViewTextDirectionTest, IdealBoundsOfItemIcon) { LauncherID id = AddPlatformApp(); - internal::LauncherButton* button = GetButtonByID(id); + internal::ShelfButton* button = GetButtonByID(id); gfx::Rect item_bounds = button->GetBoundsInScreen(); gfx::Point icon_offset = button->GetIconBounds().origin(); item_bounds.Offset(icon_offset.OffsetFromOrigin()); @@ -792,7 +792,7 @@ TEST_F(ShelfViewTest, AddButtonQuickly) { // Verifies non-overflow buttons are visible. for (int i = 0; i <= test_api_->GetLastVisibleIndex(); ++i) { - internal::LauncherButton* button = test_api_->GetButton(i); + internal::ShelfButton* button = test_api_->GetButton(i); if (button) { EXPECT_TRUE(button->visible()) << "button index=" << i; EXPECT_EQ(1.0f, button->layer()->opacity()) << "button index=" << i; @@ -1014,14 +1014,14 @@ TEST_F(ShelfViewTest, LauncherItemStatus) { LauncherID last_added = AddPlatformApp(); LauncherItem item = GetItemByID(last_added); int index = model_->ItemIndexByID(last_added); - internal::LauncherButton* button = GetButtonByID(last_added); - ASSERT_EQ(internal::LauncherButton::STATE_RUNNING, button->state()); + internal::ShelfButton* button = GetButtonByID(last_added); + ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); item.status = ash::STATUS_ACTIVE; model_->Set(index, item); - ASSERT_EQ(internal::LauncherButton::STATE_ACTIVE, button->state()); + ASSERT_EQ(internal::ShelfButton::STATE_ACTIVE, button->state()); item.status = ash::STATUS_ATTENTION; model_->Set(index, item); - ASSERT_EQ(internal::LauncherButton::STATE_ATTENTION, button->state()); + ASSERT_EQ(internal::ShelfButton::STATE_ATTENTION, button->state()); } TEST_F(ShelfViewLegacyShelfLayoutTest, @@ -1032,17 +1032,17 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, // Add 2 items to the launcher. LauncherID item1_id = AddPlatformApp(); LauncherID item2_id = AddPlatformAppNoWait(); - internal::LauncherButton* item1_button = GetButtonByID(item1_id); - internal::LauncherButton* item2_button = GetButtonByID(item2_id); - - internal::LauncherButton::State state_mask = - static_cast<internal::LauncherButton::State> - (internal::LauncherButton::STATE_NORMAL | - internal::LauncherButton::STATE_HOVERED | - internal::LauncherButton::STATE_RUNNING | - internal::LauncherButton::STATE_ACTIVE | - internal::LauncherButton::STATE_ATTENTION | - internal::LauncherButton::STATE_FOCUSED); + internal::ShelfButton* item1_button = GetButtonByID(item1_id); + internal::ShelfButton* item2_button = GetButtonByID(item2_id); + + internal::ShelfButton::State state_mask = + static_cast<internal::ShelfButton::State>( + internal::ShelfButton::STATE_NORMAL | + internal::ShelfButton::STATE_HOVERED | + internal::ShelfButton::STATE_RUNNING | + internal::ShelfButton::STATE_ACTIVE | + internal::ShelfButton::STATE_ATTENTION | + internal::ShelfButton::STATE_FOCUSED); // Clear the button states. item1_button->ClearState(state_mask); @@ -1051,10 +1051,10 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, // 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(internal::LauncherButton::STATE_HOVERED); + item1_button->AddState(internal::ShelfButton::STATE_HOVERED); ASSERT_NE(item1_button->GetIconBounds().y(), item2_button->GetIconBounds().y()); - item1_button->ClearState(internal::LauncherButton::STATE_HOVERED); + item1_button->ClearState(internal::ShelfButton::STATE_HOVERED); } // Confirm that item status changes are reflected in the buttons @@ -1067,14 +1067,14 @@ TEST_F(ShelfViewTest, LauncherItemStatusPlatformApp) { LauncherID last_added = AddPlatformApp(); LauncherItem item = GetItemByID(last_added); int index = model_->ItemIndexByID(last_added); - internal::LauncherButton* button = GetButtonByID(last_added); - ASSERT_EQ(internal::LauncherButton::STATE_RUNNING, button->state()); + internal::ShelfButton* button = GetButtonByID(last_added); + ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); item.status = ash::STATUS_ACTIVE; model_->Set(index, item); - ASSERT_EQ(internal::LauncherButton::STATE_ACTIVE, button->state()); + ASSERT_EQ(internal::ShelfButton::STATE_ACTIVE, button->state()); item.status = ash::STATUS_ATTENTION; model_->Set(index, item); - ASSERT_EQ(internal::LauncherButton::STATE_ATTENTION, button->state()); + ASSERT_EQ(internal::ShelfButton::STATE_ATTENTION, button->state()); } // Confirm that launcher item bounds are correctly updated on shelf changes. @@ -1098,8 +1098,8 @@ TEST_F(ShelfViewTest, ShelfTooltipTest) { LauncherID app_button_id = AddAppShortcut(); LauncherID platform_button_id = AddPlatformApp(); - internal::LauncherButton* app_button = GetButtonByID(app_button_id); - internal::LauncherButton* platform_button = GetButtonByID(platform_button_id); + internal::ShelfButton* app_button = GetButtonByID(app_button_id); + internal::ShelfButton* platform_button = GetButtonByID(platform_button_id); internal::ShelfButtonHost* button_host = shelf_view_; internal::ShelfTooltipManager* tooltip_manager = @@ -1145,7 +1145,7 @@ TEST_F(ShelfViewTest, RemovingItemClosesTooltip) { // Add an item to the launcher. LauncherID app_button_id = AddAppShortcut(); - internal::LauncherButton* app_button = GetButtonByID(app_button_id); + internal::ShelfButton* app_button = GetButtonByID(app_button_id); // Spawn a tooltip on that item. button_host->MouseEnteredButton(app_button); @@ -1171,7 +1171,7 @@ TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { // Add an item to the launcher. LauncherID app_button_id = AddAppShortcut(); - internal::LauncherButton* app_button = GetButtonByID(app_button_id); + internal::ShelfButton* app_button = GetButtonByID(app_button_id); // Spawn a tooltip on the item. button_host->MouseEnteredButton(app_button); @@ -1191,7 +1191,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipTest) { // The tooltip shouldn't hide if the mouse is on normal buttons. for (int i = 0; i < test_api_->GetButtonCount(); i++) { - internal::LauncherButton* button = test_api_->GetButton(i); + internal::ShelfButton* button = test_api_->GetButton(i); if (!button) continue; @@ -1216,7 +1216,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipTest) { // The tooltip should hide if it's outside of all buttons. gfx::Rect all_area; for (int i = 0; i < test_api_->GetButtonCount(); i++) { - internal::LauncherButton* button = test_api_->GetButton(i); + internal::ShelfButton* button = test_api_->GetButton(i); if (!button) continue; @@ -1242,7 +1242,7 @@ TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { // The tooltip shouldn't hide if the mouse is on normal buttons. for (int i = 1; i < test_api_->GetButtonCount(); i++) { - internal::LauncherButton* button = test_api_->GetButton(i); + internal::ShelfButton* button = test_api_->GetButton(i); if (!button) continue; @@ -1369,7 +1369,7 @@ TEST_F(ShelfViewTest, OverflowBubbleSize) { aura::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), gfx::Point()); - ash::internal::LauncherButton* button = + ash::internal::ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); // Rip off the last visible item. gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); @@ -1452,7 +1452,7 @@ TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { ash::test::ShelfViewTestAPI test_api_for_overflow_view( test_api_->overflow_bubble()->shelf_view()); - ash::internal::LauncherButton* button = test_api_for_overflow_view.GetButton( + ash::internal::ShelfButton* button = test_api_for_overflow_view.GetButton( test_api_for_overflow_view.GetLastVisibleIndex()); // Checks that a point in shelf is contained in drag insert bounds. @@ -1473,7 +1473,7 @@ TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { ash::test::ShelfViewTestAPI test_api_for_overflow_view_of_secondary( test_api_for_secondary.overflow_bubble()->shelf_view()); - ash::internal::LauncherButton* button_in_secondary = + ash::internal::ShelfButton* button_in_secondary = test_api_for_overflow_view_of_secondary.GetButton( test_api_for_overflow_view_of_secondary.GetLastVisibleIndex()); @@ -1502,7 +1502,7 @@ class ShelfViewVisibleBoundsTest : public ShelfViewTest, gfx::Rect launcher_bounds = shelf_view_->GetBoundsInScreen(); EXPECT_TRUE(launcher_bounds.Contains(visible_bounds)); for (int i = 0; i < test_api_->GetButtonCount(); ++i) - if (internal::LauncherButton* button = test_api_->GetButton(i)) + if (internal::ShelfButton* button = test_api_->GetButton(i)) EXPECT_TRUE(visible_bounds.Contains(button->GetBoundsInScreen())); CheckAppListButtonIsInBounds(); } diff --git a/ash/shelf/shelf_widget_unittest.cc b/ash/shelf/shelf_widget_unittest.cc index a0fd9ca..c4e9b87 100644 --- a/ash/shelf/shelf_widget_unittest.cc +++ b/ash/shelf/shelf_widget_unittest.cc @@ -5,8 +5,8 @@ #include "ash/shelf/shelf_widget.h" #include "ash/launcher/launcher.h" -#include "ash/launcher/launcher_button.h" #include "ash/root_window_controller.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_view.h" diff --git a/ash/test/shelf_view_test_api.cc b/ash/test/shelf_view_test_api.cc index 5719488..568eda9 100644 --- a/ash/test/shelf_view_test_api.cc +++ b/ash/test/shelf_view_test_api.cc @@ -4,8 +4,8 @@ #include "ash/test/shelf_view_test_api.h" -#include "ash/launcher/launcher_button.h" #include "ash/shelf/overflow_button.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_view.h" #include "base/message_loop/message_loop.h" @@ -47,12 +47,12 @@ int ShelfViewTestAPI::GetButtonCount() { return shelf_view_->view_model_->view_size(); } -internal::LauncherButton* ShelfViewTestAPI::GetButton(int index) { - // App list button is not a LauncherButton. +internal::ShelfButton* ShelfViewTestAPI::GetButton(int index) { + // App list button is not a ShelfButton. if (shelf_view_->model_->items()[index].type == ash::TYPE_APP_LIST) return NULL; - return static_cast<internal::LauncherButton*>( + return static_cast<internal::ShelfButton*>( shelf_view_->view_model_->view_at(index)); } diff --git a/ash/test/shelf_view_test_api.h b/ash/test/shelf_view_test_api.h index c7a7632..d26c02d 100644 --- a/ash/test/shelf_view_test_api.h +++ b/ash/test/shelf_view_test_api.h @@ -18,8 +18,8 @@ namespace ash { class LauncherDelegate; namespace internal { -class LauncherButton; class OverflowBubble; +class ShelfButton; class ShelfView; } @@ -35,7 +35,7 @@ class ShelfViewTestAPI { int GetButtonCount(); // Retrieve the button at |index|. - internal::LauncherButton* GetButton(int index); + internal::ShelfButton* GetButton(int index); // First visible button index. int GetFirstVisibleIndex(); diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc index 787f1b400..0a71814 100644 --- a/ash/wm/panels/panel_layout_manager_unittest.cc +++ b/ash/wm/panels/panel_layout_manager_unittest.cc @@ -6,9 +6,9 @@ #include "ash/ash_switches.h" #include "ash/launcher/launcher.h" -#include "ash/launcher/launcher_button.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" +#include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_model.h" #include "ash/shelf/shelf_types.h" |