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

Side by Side Diff: ash/shelf/overflow_bubble_view.cc

Issue 1659283002: ash: Explicitly teach various components about ShelfLayoutManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ozone-ui-event-platform-event
Patch Set: fix-test Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « ash/shelf/overflow_bubble_view.h ('k') | ash/shelf/overflow_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/overflow_bubble_view.h" 5 #include "ash/shelf/overflow_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_constants.h" 10 #include "ash/shelf/shelf_constants.h"
(...skipping 23 matching lines...) Expand all
34 34
35 OverflowBubbleView::OverflowBubbleView() 35 OverflowBubbleView::OverflowBubbleView()
36 : shelf_view_(NULL) { 36 : shelf_view_(NULL) {
37 } 37 }
38 38
39 OverflowBubbleView::~OverflowBubbleView() { 39 OverflowBubbleView::~OverflowBubbleView() {
40 } 40 }
41 41
42 void OverflowBubbleView::InitOverflowBubble(views::View* anchor, 42 void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
43 ShelfView* shelf_view) { 43 ShelfView* shelf_view) {
44 // set_anchor_view needs to be called before GetShelfLayoutManager() can be
45 // called.
46 SetAnchorView(anchor); 44 SetAnchorView(anchor);
47 set_arrow(GetBubbleArrow()); 45 set_arrow(GetBubbleArrow());
48 set_background(NULL); 46 set_background(NULL);
49 set_color(SkColorSetARGB(kShelfBackgroundAlpha, 0, 0, 0)); 47 set_color(SkColorSetARGB(kShelfBackgroundAlpha, 0, 0, 0));
50 set_margins(gfx::Insets(kPadding, kPadding, kPadding, kPadding)); 48 set_margins(gfx::Insets(kPadding, kPadding, kPadding, kPadding));
51 // Overflow bubble should not get focus. If it get focus when it is shown, 49 // Overflow bubble should not get focus. If it get focus when it is shown,
52 // active state item is changed to running state. 50 // active state item is changed to running state.
53 set_can_activate(false); 51 set_can_activate(false);
54 52
55 // Makes bubble view has a layer and clip its children layers. 53 // Makes bubble view has a layer and clip its children layers.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void OverflowBubbleView::ScrollByYOffset(int y_offset) { 99 void OverflowBubbleView::ScrollByYOffset(int y_offset) {
102 const gfx::Rect visible_bounds(GetContentsBounds()); 100 const gfx::Rect visible_bounds(GetContentsBounds());
103 const gfx::Size contents_size(GetContentsSize()); 101 const gfx::Size contents_size(GetContentsSize());
104 102
105 DCHECK_GE(contents_size.width(), visible_bounds.width()); 103 DCHECK_GE(contents_size.width(), visible_bounds.width());
106 int y = std::min(contents_size.height() - visible_bounds.height(), 104 int y = std::min(contents_size.height() - visible_bounds.height(),
107 std::max(0, scroll_offset_.y() + y_offset)); 105 std::max(0, scroll_offset_.y() + y_offset));
108 scroll_offset_.set_y(y); 106 scroll_offset_.set_y(y);
109 } 107 }
110 108
109 ShelfLayoutManager* OverflowBubbleView::GetShelfLayoutManager() const {
110 return shelf_view_ ? shelf_view_->shelf_layout_manager() : nullptr;
111 }
112
111 gfx::Size OverflowBubbleView::GetPreferredSize() const { 113 gfx::Size OverflowBubbleView::GetPreferredSize() const {
112 gfx::Size preferred_size = GetContentsSize(); 114 gfx::Size preferred_size = GetContentsSize();
113 115
114 const gfx::Rect monitor_rect = 116 const gfx::Rect monitor_rect =
115 gfx::Screen::GetScreen() 117 gfx::Screen::GetScreen()
116 ->GetDisplayNearestPoint(GetAnchorRect().CenterPoint()) 118 ->GetDisplayNearestPoint(GetAnchorRect().CenterPoint())
117 .work_area(); 119 .work_area();
118 if (!monitor_rect.IsEmpty()) { 120 if (!monitor_rect.IsEmpty()) {
119 if (IsHorizontalAlignment()) { 121 if (IsHorizontalAlignment()) {
120 preferred_size.set_width(std::min( 122 preferred_size.set_width(std::min(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // directions as in OverflowBubbleView::OnScrollEvent. 159 // directions as in OverflowBubbleView::OnScrollEvent.
158 if (IsHorizontalAlignment()) 160 if (IsHorizontalAlignment())
159 ScrollByXOffset(-event.y_offset()); 161 ScrollByXOffset(-event.y_offset());
160 else 162 else
161 ScrollByYOffset(-event.y_offset()); 163 ScrollByYOffset(-event.y_offset());
162 Layout(); 164 Layout();
163 165
164 return true; 166 return true;
165 } 167 }
166 168
167 ShelfLayoutManager* OverflowBubbleView::GetShelfLayoutManager() const {
168 return GetAnchorView() ? ShelfLayoutManager::ForShelf(
169 GetAnchorView()->GetWidget()->GetNativeView())
170 : NULL;
171 }
172
173 void OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) { 169 void OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) {
174 ScrollByXOffset(-event->x_offset()); 170 ScrollByXOffset(-event->x_offset());
175 ScrollByYOffset(-event->y_offset()); 171 ScrollByYOffset(-event->y_offset());
176 Layout(); 172 Layout();
177 event->SetHandled(); 173 event->SetHandled();
178 } 174 }
179 175
180 gfx::Rect OverflowBubbleView::GetBubbleBounds() { 176 gfx::Rect OverflowBubbleView::GetBubbleBounds() {
181 views::BubbleBorder* border = GetBubbleFrameView()->bubble_border(); 177 views::BubbleBorder* border = GetBubbleFrameView()->bubble_border();
182 gfx::Insets bubble_insets = border->GetInsets(); 178 gfx::Insets bubble_insets = border->GetInsets();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 214
219 bubble_rect.Offset(0, offset); 215 bubble_rect.Offset(0, offset);
220 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); 216 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y());
221 } 217 }
222 218
223 GetBubbleFrameView()->SchedulePaint(); 219 GetBubbleFrameView()->SchedulePaint();
224 return bubble_rect; 220 return bubble_rect;
225 } 221 }
226 222
227 } // namespace ash 223 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/overflow_bubble_view.h ('k') | ash/shelf/overflow_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698