OLD | NEW |
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/launcher_tooltip_manager.h" | 5 #include "ash/launcher/launcher_tooltip_manager.h" |
6 | 6 |
7 #include "ash/launcher/launcher_view.h" | 7 #include "ash/launcher/launcher_view.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "ui/aura/event.h" | |
16 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
17 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/base/event.h" |
18 #include "ui/base/events.h" | 18 #include "ui/base/events.h" |
19 #include "ui/gfx/insets.h" | 19 #include "ui/gfx/insets.h" |
20 #include "ui/views/bubble/bubble_delegate.h" | 20 #include "ui/views/bubble/bubble_delegate.h" |
21 #include "ui/views/bubble/bubble_frame_view.h" | 21 #include "ui/views/bubble/bubble_frame_view.h" |
22 #include "ui/views/bubble/bubble_border_2.h" | 22 #include "ui/views/bubble/bubble_border_2.h" |
23 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
24 #include "ui/views/layout/fill_layout.h" | 24 #include "ui/views/layout/fill_layout.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 283 } |
284 | 284 |
285 bool LauncherTooltipManager::IsVisible() { | 285 bool LauncherTooltipManager::IsVisible() { |
286 if (timer_.get() && timer_->IsRunning()) | 286 if (timer_.get() && timer_->IsRunning()) |
287 return false; | 287 return false; |
288 | 288 |
289 return widget_ && widget_->IsVisible(); | 289 return widget_ && widget_->IsVisible(); |
290 } | 290 } |
291 | 291 |
292 bool LauncherTooltipManager::PreHandleKeyEvent(aura::Window* target, | 292 bool LauncherTooltipManager::PreHandleKeyEvent(aura::Window* target, |
293 aura::KeyEvent* event) { | 293 ui::KeyEvent* event) { |
294 // Not handled. | 294 // Not handled. |
295 return false; | 295 return false; |
296 } | 296 } |
297 | 297 |
298 bool LauncherTooltipManager::PreHandleMouseEvent(aura::Window* target, | 298 bool LauncherTooltipManager::PreHandleMouseEvent(aura::Window* target, |
299 aura::MouseEvent* event) { | 299 ui::MouseEvent* event) { |
300 DCHECK(target); | 300 DCHECK(target); |
301 DCHECK(event); | 301 DCHECK(event); |
302 if (!widget_ || !widget_->IsVisible()) | 302 if (!widget_ || !widget_->IsVisible()) |
303 return false; | 303 return false; |
304 | 304 |
305 DCHECK(view_); | 305 DCHECK(view_); |
306 DCHECK(launcher_view_); | 306 DCHECK(launcher_view_); |
307 | 307 |
308 if (widget_->GetNativeWindow()->GetRootWindow() != target->GetRootWindow()) { | 308 if (widget_->GetNativeWindow()->GetRootWindow() != target->GetRootWindow()) { |
309 CloseSoon(); | 309 CloseSoon(); |
310 return false; | 310 return false; |
311 } | 311 } |
312 | 312 |
313 gfx::Point location_in_launcher_view = event->location(); | 313 gfx::Point location_in_launcher_view = event->location(); |
314 aura::Window::ConvertPointToWindow( | 314 aura::Window::ConvertPointToTarget( |
315 target, launcher_view_->GetWidget()->GetNativeWindow(), | 315 target, launcher_view_->GetWidget()->GetNativeWindow(), |
316 &location_in_launcher_view); | 316 &location_in_launcher_view); |
317 | 317 |
318 gfx::Point location_on_screen = event->location(); | 318 gfx::Point location_on_screen = event->location(); |
319 aura::Window::ConvertPointToWindow( | 319 aura::Window::ConvertPointToTarget( |
320 target, target->GetRootWindow(), &location_on_screen); | 320 target, target->GetRootWindow(), &location_on_screen); |
321 gfx::Rect bubble_rect = widget_->GetWindowBoundsInScreen(); | 321 gfx::Rect bubble_rect = widget_->GetWindowBoundsInScreen(); |
322 | 322 |
323 if (launcher_view_->ShouldHideTooltip(location_in_launcher_view) && | 323 if (launcher_view_->ShouldHideTooltip(location_in_launcher_view) && |
324 !bubble_rect.Contains(location_on_screen)) { | 324 !bubble_rect.Contains(location_on_screen)) { |
325 // Because this mouse event may arrive to |view_|, here we just schedule | 325 // Because this mouse event may arrive to |view_|, here we just schedule |
326 // the closing event rather than directly calling Close(). | 326 // the closing event rather than directly calling Close(). |
327 CloseSoon(); | 327 CloseSoon(); |
328 } | 328 } |
329 | 329 |
330 return false; | 330 return false; |
331 } | 331 } |
332 | 332 |
333 ui::TouchStatus LauncherTooltipManager::PreHandleTouchEvent( | 333 ui::TouchStatus LauncherTooltipManager::PreHandleTouchEvent( |
334 aura::Window* target, aura::TouchEvent* event) { | 334 aura::Window* target, ui::TouchEventImpl* event) { |
335 if (widget_ && widget_->IsVisible() && widget_->GetNativeWindow() != target) | 335 if (widget_ && widget_->IsVisible() && widget_->GetNativeWindow() != target) |
336 Close(); | 336 Close(); |
337 return ui::TOUCH_STATUS_UNKNOWN; | 337 return ui::TOUCH_STATUS_UNKNOWN; |
338 } | 338 } |
339 | 339 |
340 ui::GestureStatus LauncherTooltipManager::PreHandleGestureEvent( | 340 ui::GestureStatus LauncherTooltipManager::PreHandleGestureEvent( |
341 aura::Window* target, aura::GestureEvent* event) { | 341 aura::Window* target, ui::GestureEventImpl* event) { |
342 if (widget_ && widget_->IsVisible()) { | 342 if (widget_ && widget_->IsVisible()) { |
343 // Because this mouse event may arrive to |view_|, here we just schedule | 343 // Because this mouse event may arrive to |view_|, here we just schedule |
344 // the closing event rather than directly calling Close(). | 344 // the closing event rather than directly calling Close(). |
345 CloseSoon(); | 345 CloseSoon(); |
346 } | 346 } |
347 | 347 |
348 return ui::GESTURE_STATUS_UNKNOWN; | 348 return ui::GESTURE_STATUS_UNKNOWN; |
349 } | 349 } |
350 | 350 |
351 void LauncherTooltipManager::WillDeleteShelf() { | 351 void LauncherTooltipManager::WillDeleteShelf() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 view_->SetText(text_); | 404 view_->SetText(text_); |
405 | 405 |
406 gfx::NativeView native_view = widget_->GetNativeView(); | 406 gfx::NativeView native_view = widget_->GetNativeView(); |
407 SetWindowVisibilityAnimationType( | 407 SetWindowVisibilityAnimationType( |
408 native_view, WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); | 408 native_view, WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); |
409 SetWindowVisibilityAnimationTransition(native_view, ANIMATE_HIDE); | 409 SetWindowVisibilityAnimationTransition(native_view, ANIMATE_HIDE); |
410 } | 410 } |
411 | 411 |
412 } // namespace internal | 412 } // namespace internal |
413 } // namespace ash | 413 } // namespace ash |
OLD | NEW |