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

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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 238
237 void ToastContentsView::OnDisplayChanged() { 239 void ToastContentsView::OnDisplayChanged() {
238 views::Widget* widget = GetWidget(); 240 views::Widget* widget = GetWidget();
239 if (!widget) 241 if (!widget)
240 return; 242 return;
241 243
242 gfx::NativeView native_view = widget->GetNativeView(); 244 gfx::NativeView native_view = widget->GetNativeView();
243 if (!native_view || !collection_.get()) 245 if (!native_view || !collection_.get())
244 return; 246 return;
245 247
246 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( 248 collection_->OnDisplayMetricsChanged(
247 native_view)->GetDisplayNearestWindow(native_view)); 249 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
250 gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
251 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
248 } 252 }
249 253
250 void ToastContentsView::OnWorkAreaChanged() { 254 void ToastContentsView::OnWorkAreaChanged() {
251 views::Widget* widget = GetWidget(); 255 views::Widget* widget = GetWidget();
252 if (!widget) 256 if (!widget)
253 return; 257 return;
254 258
255 gfx::NativeView native_view = widget->GetNativeView(); 259 gfx::NativeView native_view = widget->GetNativeView();
256 if (!native_view || !collection_.get()) 260 if (!native_view || !collection_.get())
257 return; 261 return;
258 262
259 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( 263 collection_->OnDisplayMetricsChanged(
260 native_view)->GetDisplayNearestWindow(native_view)); 264 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
265 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
261 } 266 }
262 267
263 // views::View 268 // views::View
264 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { 269 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) {
265 if (collection_) 270 if (collection_)
266 collection_->OnMouseEntered(this); 271 collection_->OnMouseEntered(this);
267 } 272 }
268 273
269 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { 274 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) {
270 if (collection_) 275 if (collection_)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 353 }
349 354
350 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { 355 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) {
351 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, 356 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth,
352 bounds.y(), 357 bounds.y(),
353 kClosedToastWidth, 358 kClosedToastWidth,
354 bounds.height()); 359 bounds.height());
355 } 360 }
356 361
357 } // namespace message_center 362 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_popup_collection.cc ('k') | ui/views/widget/desktop_aura/desktop_screen_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698