OLD | NEW |
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void OverflowBubbleView::ScrollByYOffset(int y_offset) { | 101 void OverflowBubbleView::ScrollByYOffset(int y_offset) { |
102 const gfx::Rect visible_bounds(GetContentsBounds()); | 102 const gfx::Rect visible_bounds(GetContentsBounds()); |
103 const gfx::Size contents_size(GetContentsSize()); | 103 const gfx::Size contents_size(GetContentsSize()); |
104 | 104 |
105 DCHECK_GE(contents_size.width(), visible_bounds.width()); | 105 DCHECK_GE(contents_size.width(), visible_bounds.width()); |
106 int y = std::min(contents_size.height() - visible_bounds.height(), | 106 int y = std::min(contents_size.height() - visible_bounds.height(), |
107 std::max(0, scroll_offset_.y() + y_offset)); | 107 std::max(0, scroll_offset_.y() + y_offset)); |
108 scroll_offset_.set_y(y); | 108 scroll_offset_.set_y(y); |
109 } | 109 } |
110 | 110 |
111 gfx::Size OverflowBubbleView::GetPreferredSize() { | 111 gfx::Size OverflowBubbleView::GetPreferredSize() const { |
112 gfx::Size preferred_size = GetContentsSize(); | 112 gfx::Size preferred_size = GetContentsSize(); |
113 | 113 |
114 const gfx::Rect monitor_rect = Shell::GetScreen()->GetDisplayNearestPoint( | 114 const gfx::Rect monitor_rect = Shell::GetScreen()->GetDisplayNearestPoint( |
115 GetAnchorRect().CenterPoint()).work_area(); | 115 GetAnchorRect().CenterPoint()).work_area(); |
116 if (!monitor_rect.IsEmpty()) { | 116 if (!monitor_rect.IsEmpty()) { |
117 if (IsHorizontalAlignment()) { | 117 if (IsHorizontalAlignment()) { |
118 preferred_size.set_width(std::min( | 118 preferred_size.set_width(std::min( |
119 preferred_size.width(), | 119 preferred_size.width(), |
120 static_cast<int>(monitor_rect.width() * | 120 static_cast<int>(monitor_rect.width() * |
121 kMaxBubbleSizeToScreenRatio))); | 121 kMaxBubbleSizeToScreenRatio))); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 bubble_rect.Offset(0, offset); | 215 bubble_rect.Offset(0, offset); |
216 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); | 216 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); |
217 } | 217 } |
218 | 218 |
219 GetBubbleFrameView()->SchedulePaint(); | 219 GetBubbleFrameView()->SchedulePaint(); |
220 return bubble_rect; | 220 return bubble_rect; |
221 } | 221 } |
222 | 222 |
223 } // namespace ash | 223 } // namespace ash |
OLD | NEW |