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

Side by Side Diff: ui/message_center/views/toast_contents_view.cc

Issue 259253002: Add OnDisplayMetricsChanged in DisplayObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_orientation
Patch Set: Created 6 years, 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/message_center/views/toast_contents_view.h" 5 #include "ui/message_center/views/toast_contents_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 10 matching lines...) Expand all
21 #include "ui/message_center/views/message_view.h" 21 #include "ui/message_center/views/message_view.h"
22 #include "ui/views/background.h" 22 #include "ui/views/background.h"
23 #include "ui/views/view.h" 23 #include "ui/views/view.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_delegate.h" 25 #include "ui/views/widget/widget_delegate.h"
26 26
27 #if defined(OS_WIN) && defined(USE_ASH) 27 #if defined(OS_WIN) && defined(USE_ASH)
28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
29 #endif 29 #endif
30 30
31 using gfx::Screen;
32
31 namespace message_center { 33 namespace message_center {
32 namespace { 34 namespace {
33 35
34 // The width of a toast before animated reveal and after closing. 36 // The width of a toast before animated reveal and after closing.
35 const int kClosedToastWidth = 5; 37 const int kClosedToastWidth = 5;
36 38
37 // FadeIn/Out look a bit better if they are slightly longer then default slide. 39 // FadeIn/Out look a bit better if they are slightly longer then default slide.
38 const int kFadeInOutDuration = 200; 40 const int kFadeInOutDuration = 200;
39 41
40 } // namespace. 42 } // namespace.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 242
241 void ToastContentsView::OnDisplayChanged() { 243 void ToastContentsView::OnDisplayChanged() {
242 views::Widget* widget = GetWidget(); 244 views::Widget* widget = GetWidget();
243 if (!widget) 245 if (!widget)
244 return; 246 return;
245 247
246 gfx::NativeView native_view = widget->GetNativeView(); 248 gfx::NativeView native_view = widget->GetNativeView();
247 if (!native_view || !collection_.get()) 249 if (!native_view || !collection_.get())
248 return; 250 return;
249 251
250 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( 252 const int metrics = gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS |
251 native_view)->GetDisplayNearestWindow(native_view)); 253 gfx::DisplayObserver::DISPLAY_METRICS_WORK_AREA;
254 collection_->OnDisplayMetricsChanged(
255 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
256 static_cast<gfx::DisplayObserver::DisplayMetrics>(metrics));
252 } 257 }
253 258
254 void ToastContentsView::OnWorkAreaChanged() { 259 void ToastContentsView::OnWorkAreaChanged() {
255 views::Widget* widget = GetWidget(); 260 views::Widget* widget = GetWidget();
256 if (!widget) 261 if (!widget)
257 return; 262 return;
258 263
259 gfx::NativeView native_view = widget->GetNativeView(); 264 gfx::NativeView native_view = widget->GetNativeView();
260 if (!native_view || !collection_.get()) 265 if (!native_view || !collection_.get())
261 return; 266 return;
262 267
263 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( 268 collection_->OnDisplayMetricsChanged(
264 native_view)->GetDisplayNearestWindow(native_view)); 269 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
270 gfx::DisplayObserver::DISPLAY_METRICS_WORK_AREA);
265 } 271 }
266 272
267 // views::View 273 // views::View
268 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { 274 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) {
269 if (collection_) 275 if (collection_)
270 collection_->OnMouseEntered(this); 276 collection_->OnMouseEntered(this);
271 } 277 }
272 278
273 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { 279 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) {
274 if (collection_) 280 if (collection_)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 358 }
353 359
354 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { 360 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) {
355 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, 361 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth,
356 bounds.y(), 362 bounds.y(),
357 kClosedToastWidth, 363 kClosedToastWidth,
358 bounds.height()); 364 bounds.height());
359 } 365 }
360 366
361 } // namespace message_center 367 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698