diff options
author | sadrul <sadrul@chromium.org> | 2016-02-02 19:39:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-03 03:40:56 +0000 |
commit | d33c56b9855e28aa28565c0ea39bc70aacabe1b7 (patch) | |
tree | cae170e754d90ab10f6f77de73ee344f1b7fa2d8 /ash/shelf | |
parent | fdd1a307580d2be75a5f7a40557a3102cd713ca7 (diff) | |
download | chromium_src-d33c56b9855e28aa28565c0ea39bc70aacabe1b7.zip chromium_src-d33c56b9855e28aa28565c0ea39bc70aacabe1b7.tar.gz chromium_src-d33c56b9855e28aa28565c0ea39bc70aacabe1b7.tar.bz2 |
ash: Explicitly teach various components about ShelfLayoutManager.
. StatusAreaWidget is created by the ShelfWidget instance. So there's no need
for StatusAreaWidget to go throug the root window to get at the
ShelfLayoutManager.
. TrayBackgroundView, AshPopupAlignmentDelegate etc. should get the
ShelfLayoutManager from their associated StatusAreaWidget.
. OverflowButton is created by the shelf itself. There's no reason to look
it up from the root-window.
BUG=none
Review URL: https://codereview.chromium.org/1659283002
Cr-Commit-Position: refs/heads/master@{#373159}
Diffstat (limited to 'ash/shelf')
-rw-r--r-- | ash/shelf/overflow_bubble.cc | 3 | ||||
-rw-r--r-- | ash/shelf/overflow_bubble_view.cc | 12 | ||||
-rw-r--r-- | ash/shelf/overflow_bubble_view.h | 4 | ||||
-rw-r--r-- | ash/shelf/overflow_button.cc | 18 | ||||
-rw-r--r-- | ash/shelf/overflow_button.h | 5 | ||||
-rw-r--r-- | ash/shelf/shelf.h | 1 | ||||
-rw-r--r-- | ash/shelf/shelf_view.cc | 2 | ||||
-rw-r--r-- | ash/shelf/shelf_widget.cc | 14 |
8 files changed, 26 insertions, 33 deletions
diff --git a/ash/shelf/overflow_bubble.cc b/ash/shelf/overflow_bubble.cc index f7cc659..6290099 100644 --- a/ash/shelf/overflow_bubble.cc +++ b/ash/shelf/overflow_bubble.cc @@ -94,9 +94,8 @@ void OverflowBubble::OnWidgetDestroying(views::Widget* widget) { DCHECK(widget == bubble_->GetWidget()); bubble_ = NULL; anchor_ = NULL; + shelf_view_->shelf_layout_manager()->shelf_widget()->shelf()->SchedulePaint(); shelf_view_ = NULL; - ShelfLayoutManager::ForShelf( - widget->GetNativeView())->shelf_widget()->shelf()->SchedulePaint(); } } // namespace ash diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/shelf/overflow_bubble_view.cc index 5273e506..b15f7b7 100644 --- a/ash/shelf/overflow_bubble_view.cc +++ b/ash/shelf/overflow_bubble_view.cc @@ -41,8 +41,6 @@ OverflowBubbleView::~OverflowBubbleView() { void OverflowBubbleView::InitOverflowBubble(views::View* anchor, ShelfView* shelf_view) { - // set_anchor_view needs to be called before GetShelfLayoutManager() can be - // called. SetAnchorView(anchor); set_arrow(GetBubbleArrow()); set_background(NULL); @@ -108,6 +106,10 @@ void OverflowBubbleView::ScrollByYOffset(int y_offset) { scroll_offset_.set_y(y); } +ShelfLayoutManager* OverflowBubbleView::GetShelfLayoutManager() const { + return shelf_view_ ? shelf_view_->shelf_layout_manager() : nullptr; +} + gfx::Size OverflowBubbleView::GetPreferredSize() const { gfx::Size preferred_size = GetContentsSize(); @@ -164,12 +166,6 @@ bool OverflowBubbleView::OnMouseWheel(const ui::MouseWheelEvent& event) { return true; } -ShelfLayoutManager* OverflowBubbleView::GetShelfLayoutManager() const { - return GetAnchorView() ? ShelfLayoutManager::ForShelf( - GetAnchorView()->GetWidget()->GetNativeView()) - : NULL; -} - void OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) { ScrollByXOffset(-event->x_offset()); ScrollByYOffset(-event->y_offset()); diff --git a/ash/shelf/overflow_bubble_view.h b/ash/shelf/overflow_bubble_view.h index 8859fe2..5feeeed 100644 --- a/ash/shelf/overflow_bubble_view.h +++ b/ash/shelf/overflow_bubble_view.h @@ -43,6 +43,8 @@ class ASH_EXPORT OverflowBubbleView : public views::BubbleDelegateView { void ScrollByXOffset(int x_offset); void ScrollByYOffset(int y_offset); + ShelfLayoutManager* GetShelfLayoutManager() const; + // views::View overrides: gfx::Size GetPreferredSize() const override; void Layout() override; @@ -52,8 +54,6 @@ class ASH_EXPORT OverflowBubbleView : public views::BubbleDelegateView { // ui::EventHandler overrides: void OnScrollEvent(ui::ScrollEvent* event) override; - ShelfLayoutManager* GetShelfLayoutManager() const; - ShelfView* shelf_view_; // Owned by views hierarchy. gfx::Vector2d scroll_offset_; diff --git a/ash/shelf/overflow_button.cc b/ash/shelf/overflow_button.cc index 66bc2b8..16db6f8 100644 --- a/ash/shelf/overflow_button.cc +++ b/ash/shelf/overflow_button.cc @@ -34,9 +34,9 @@ const int kBackgroundOffset = (48 - kButtonHoverSize) / 2; } // namesapce -OverflowButton::OverflowButton(views::ButtonListener* listener) - : CustomButton(listener), - bottom_image_(NULL) { +OverflowButton::OverflowButton(views::ButtonListener* listener, + ShelfLayoutManager* shelf) + : CustomButton(listener), bottom_image_(nullptr), shelf_(shelf) { ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); bottom_image_ = rb->GetImageNamed(IDR_ASH_SHELF_OVERFLOW).ToImageSkia(); @@ -53,11 +53,9 @@ void OverflowButton::OnShelfAlignmentChanged() { void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) { gfx::Rect bounds(GetContentsBounds()); gfx::Rect rect(0, 0, kButtonHoverSize, kButtonHoverSize); - ShelfLayoutManager* shelf = - ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); // Nudge the background a little to line up right. - if (shelf->IsHorizontalAlignment()) { + if (shelf_->IsHorizontalAlignment()) { rect.set_origin(gfx::Point( bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, bounds.y() + kBackgroundOffset - 1)); @@ -82,16 +80,14 @@ void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) { } void OverflowButton::OnPaint(gfx::Canvas* canvas) { - ShelfLayoutManager* layout_manager = - ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); - ShelfAlignment alignment = layout_manager->GetAlignment(); + ShelfAlignment alignment = shelf_->GetAlignment(); gfx::Rect bounds(GetContentsBounds()); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); int background_image_id = 0; - if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) + if (shelf_->shelf_widget()->shelf()->IsShowingOverflowBubble()) background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; - else if(layout_manager->shelf_widget()->GetDimsShelf()) + else if (shelf_->shelf_widget()->GetDimsShelf()) background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; else background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; diff --git a/ash/shelf/overflow_button.h b/ash/shelf/overflow_button.h index 04f01fa..23270dd 100644 --- a/ash/shelf/overflow_button.h +++ b/ash/shelf/overflow_button.h @@ -13,10 +13,12 @@ namespace ash { +class ShelfLayoutManager; + // Shelf overflow chevron button. class OverflowButton : public views::CustomButton { public: - explicit OverflowButton(views::ButtonListener* listener); + OverflowButton(views::ButtonListener* listener, ShelfLayoutManager* shelf); ~OverflowButton() override; void OnShelfAlignmentChanged(); @@ -33,6 +35,7 @@ class OverflowButton : public views::CustomButton { gfx::ImageSkia right_image_; // Bottom image is owned by the resource bundle. const gfx::ImageSkia* bottom_image_; + ShelfLayoutManager* shelf_; DISALLOW_COPY_AND_ASSIGN(OverflowButton); }; diff --git a/ash/shelf/shelf.h b/ash/shelf/shelf.h index ebd2a6a..59cb009 100644 --- a/ash/shelf/shelf.h +++ b/ash/shelf/shelf.h @@ -33,7 +33,6 @@ namespace ash { class FocusCycler; class ShelfDelegate; class ShelfIconObserver; -class ShelfLayoutManager; class ShelfModel; class ShelfView; class ShelfWidget; diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index b27b4a2..438ac43 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -421,7 +421,7 @@ void ShelfView::Init() { view_model_->Add(child, static_cast<int>(i - items.begin())); AddChildView(child); } - overflow_button_ = new OverflowButton(this); + overflow_button_ = new OverflowButton(this, shelf_layout_manager()); overflow_button_->set_context_menu_controller(this); ConfigureChildView(overflow_button_); AddChildView(overflow_button_); diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc index d93153a..feb9cbe 100644 --- a/ash/shelf/shelf_widget.cc +++ b/ash/shelf/shelf_widget.cc @@ -627,7 +627,13 @@ ShelfWidget::ShelfWidget(aura::Window* shelf_container, SetContentsView(delegate_view_); delegate_view_->SetParentLayer(GetLayer()); - status_area_widget_ = new StatusAreaWidget(status_container); + shelf_layout_manager_ = new ShelfLayoutManager(this); + shelf_layout_manager_->AddObserver(this); + shelf_container->SetLayoutManager(shelf_layout_manager_); + shelf_layout_manager_->set_workspace_controller(workspace_controller); + workspace_controller->SetShelf(shelf_layout_manager_); + + status_area_widget_ = new StatusAreaWidget(status_container, this); status_area_widget_->CreateTrayViews(); if (Shell::GetInstance()->session_state_delegate()-> IsActiveUserSessionStarted()) { @@ -635,12 +641,6 @@ ShelfWidget::ShelfWidget(aura::Window* shelf_container, } Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); - shelf_layout_manager_ = new ShelfLayoutManager(this); - shelf_layout_manager_->AddObserver(this); - shelf_container->SetLayoutManager(shelf_layout_manager_); - shelf_layout_manager_->set_workspace_controller(workspace_controller); - workspace_controller->SetShelf(shelf_layout_manager_); - status_container->SetLayoutManager( new StatusAreaLayoutManager(status_container, this)); |