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

Side by Side Diff: ash/launcher/overflow_bubble.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some new gfx::Screen additions Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/launcher/overflow_bubble.h" 5 #include "ash/launcher/overflow_bubble.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/launcher/launcher_types.h" 9 #include "ash/launcher/launcher_types.h"
10 #include "ash/launcher/launcher_view.h" 10 #include "ash/launcher/launcher_view.h"
11 #include "ash/shell.h"
11 #include "ui/gfx/insets.h" 12 #include "ui/gfx/insets.h"
12 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
13 #include "ui/views/bubble/bubble_delegate.h" 14 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/bubble/bubble_frame_view.h" 15 #include "ui/views/bubble/bubble_frame_view.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 17
17 namespace ash { 18 namespace ash {
18 namespace internal { 19 namespace internal {
19 20
20 namespace { 21 namespace {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 const gfx::Size contents_size(GetContentsSize()); 139 const gfx::Size contents_size(GetContentsSize());
139 140
140 int y = std::min(contents_size.height() - visible_bounds.height(), 141 int y = std::min(contents_size.height() - visible_bounds.height(),
141 std::max(0, scroll_offset_.y() + y_offset)); 142 std::max(0, scroll_offset_.y() + y_offset));
142 scroll_offset_.set_y(y); 143 scroll_offset_.set_y(y);
143 } 144 }
144 145
145 gfx::Size OverflowBubbleView::GetPreferredSize() { 146 gfx::Size OverflowBubbleView::GetPreferredSize() {
146 gfx::Size preferred_size = GetContentsSize(); 147 gfx::Size preferred_size = GetContentsSize();
147 148
148 const gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( 149 const gfx::Rect monitor_rect = Shell::GetAshScreen()->GetDisplayNearestPoint(
149 GetAnchorRect().CenterPoint()).work_area(); 150 GetAnchorRect().CenterPoint()).work_area();
150 if (!monitor_rect.IsEmpty()) { 151 if (!monitor_rect.IsEmpty()) {
151 if (is_horizontal_alignment()) { 152 if (is_horizontal_alignment()) {
152 preferred_size.set_width(std::min( 153 preferred_size.set_width(std::min(
153 preferred_size.width(), 154 preferred_size.width(),
154 static_cast<int>(monitor_rect.width() * 155 static_cast<int>(monitor_rect.width() *
155 kMaxBubbleSizeToScreenRatio))); 156 kMaxBubbleSizeToScreenRatio)));
156 } else { 157 } else {
157 preferred_size.set_height(std::min( 158 preferred_size.set_height(std::min(
158 preferred_size.height(), 159 preferred_size.height(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 const gfx::Size content_size = GetPreferredSize(); 210 const gfx::Size content_size = GetPreferredSize();
210 border->set_arrow_offset(arrow_offset); 211 border->set_arrow_offset(arrow_offset);
211 212
212 const gfx::Rect anchor_rect = GetAnchorRect(); 213 const gfx::Rect anchor_rect = GetAnchorRect();
213 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds( 214 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds(
214 anchor_rect, 215 anchor_rect,
215 content_size, 216 content_size,
216 false); 217 false);
217 218
218 gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( 219 gfx::Rect monitor_rect = Shell::GetAshScreen()->GetDisplayNearestPoint(
219 anchor_rect.CenterPoint()).work_area(); 220 anchor_rect.CenterPoint()).work_area();
220 221
221 int offset = 0; 222 int offset = 0;
222 if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) { 223 if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) {
223 if (bubble_rect.x() < monitor_rect.x()) 224 if (bubble_rect.x() < monitor_rect.x())
224 offset = monitor_rect.x() - bubble_rect.x(); 225 offset = monitor_rect.x() - bubble_rect.x();
225 else if (bubble_rect.right() > monitor_rect.right()) 226 else if (bubble_rect.right() > monitor_rect.right())
226 offset = monitor_rect.right() - bubble_rect.right(); 227 offset = monitor_rect.right() - bubble_rect.right();
227 228
228 bubble_rect.Offset(offset, 0); 229 bubble_rect.Offset(offset, 0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 bubble_ = NULL; 280 bubble_ = NULL;
280 } 281 }
281 282
282 void OverflowBubble::OnWidgetClosing(views::Widget* widget) { 283 void OverflowBubble::OnWidgetClosing(views::Widget* widget) {
283 DCHECK(widget == bubble_->GetWidget()); 284 DCHECK(widget == bubble_->GetWidget());
284 bubble_ = NULL; 285 bubble_ = NULL;
285 } 286 }
286 287
287 } // namespace internal 288 } // namespace internal
288 } // namespace ash 289 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698