Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2486)

Unified Diff: ash/common/shelf/overflow_bubble_view.cc

Issue 2164733002: mash: Convert ash shelf overflow bubble to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/overflow_bubble_view.h ('k') | ash/common/shelf/overflow_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/overflow_bubble_view.cc
diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/common/shelf/overflow_bubble_view.cc
similarity index 82%
rename from ash/shelf/overflow_bubble_view.cc
rename to ash/common/shelf/overflow_bubble_view.cc
index 79b8df110a94ab5769226004f67a0feb015da8c9..ec899740c930139072a4b09202533713dee1d71e 100644
--- a/ash/shelf/overflow_bubble_view.cc
+++ b/ash/common/shelf/overflow_bubble_view.cc
@@ -2,22 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/shelf/overflow_bubble_view.h"
+#include "ash/common/shelf/overflow_bubble_view.h"
#include <algorithm>
#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/shelf/shelf_constants.h"
+#include "ash/common/shelf/wm_shelf.h"
+#include "ash/common/shelf/wm_shelf_util.h"
#include "ash/common/shell_window_ids.h"
-#include "ash/root_window_controller.h"
-#include "ash/shelf/shelf.h"
-#include "ash/shelf/shelf_view.h"
-#include "ash/shell.h"
+#include "ash/common/wm_lookup.h"
+#include "ash/common/wm_root_window_controller.h"
+#include "ash/common/wm_window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/bubble/bubble_frame_view.h"
+#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace ash {
@@ -34,12 +36,13 @@ const int kShelfViewLeadingInset = 8;
} // namespace
-OverflowBubbleView::OverflowBubbleView() : shelf_view_(NULL) {}
+OverflowBubbleView::OverflowBubbleView(WmShelf* wm_shelf)
+ : wm_shelf_(wm_shelf), shelf_view_(nullptr) {}
OverflowBubbleView::~OverflowBubbleView() {}
void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
- ShelfView* shelf_view) {
+ views::View* shelf_view) {
shelf_view_ = shelf_view;
SetAnchorView(anchor);
@@ -61,28 +64,32 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
layer()->SetFillsBoundsOpaquely(false);
layer()->SetMasksToBounds(true);
- set_parent_window(Shell::GetContainer(
- anchor->GetWidget()->GetNativeWindow()->GetRootWindow(),
- kShellWindowId_ShelfBubbleContainer));
+ // Calls into OnBeforeBubbleWidgetInit to set the window parent container.
views::BubbleDialogDelegateView::CreateBubble(this);
AddChildView(shelf_view_);
}
bool OverflowBubbleView::IsHorizontalAlignment() const {
- return shelf_view_ ? shelf_view_->shelf()->IsHorizontalAlignment() : false;
+ return ::ash::IsHorizontalAlignment(wm_shelf_->GetAlignment());
}
const gfx::Size OverflowBubbleView::GetContentsSize() const {
- return static_cast<views::View*>(shelf_view_)->GetPreferredSize();
+ return shelf_view_->GetPreferredSize();
}
// Gets arrow location based on shelf alignment.
views::BubbleBorder::Arrow OverflowBubbleView::GetBubbleArrow() const {
- if (!shelf_view_)
- return views::BubbleBorder::NONE;
- return shelf_view_->shelf()->SelectValueForShelfAlignment(
- views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP,
- views::BubbleBorder::RIGHT_TOP);
+ switch (wm_shelf_->GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ case SHELF_ALIGNMENT_BOTTOM_LOCKED:
+ return views::BubbleBorder::BOTTOM_LEFT;
+ case SHELF_ALIGNMENT_LEFT:
+ return views::BubbleBorder::LEFT_TOP;
+ case SHELF_ALIGNMENT_RIGHT:
+ return views::BubbleBorder::RIGHT_TOP;
+ }
+ NOTREACHED();
+ return views::BubbleBorder::NONE;
}
void OverflowBubbleView::ScrollByXOffset(int x_offset) {
@@ -172,6 +179,17 @@ int OverflowBubbleView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
+void OverflowBubbleView::OnBeforeBubbleWidgetInit(
+ views::Widget::InitParams* params,
+ views::Widget* bubble_widget) const {
+ // Place the bubble in the same root window as the anchor.
+ WmLookup::Get()
+ ->GetWindowForWidget(anchor_widget())
+ ->GetRootWindowController()
+ ->ConfigureWidgetInitParamsForContainer(
+ bubble_widget, kShellWindowId_ShelfBubbleContainer, params);
+}
+
gfx::Rect OverflowBubbleView::GetBubbleBounds() {
views::BubbleBorder* border = GetBubbleFrameView()->bubble_border();
gfx::Insets bubble_insets = border->GetInsets();
« no previous file with comments | « ash/common/shelf/overflow_bubble_view.h ('k') | ash/common/shelf/overflow_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698