| 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/tooltips/tooltip_controller.h" | 5 #include "ash/tooltips/tooltip_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void TooltipController::OnKeyEvent(ui::KeyEvent* event) { | 252 void TooltipController::OnKeyEvent(ui::KeyEvent* event) { |
| 253 // On key press, we want to hide the tooltip and not show it until change. | 253 // On key press, we want to hide the tooltip and not show it until change. |
| 254 // This is the same behavior as hiding tooltips on timeout. Hence, we can | 254 // This is the same behavior as hiding tooltips on timeout. Hence, we can |
| 255 // simply simulate a timeout. | 255 // simply simulate a timeout. |
| 256 if (tooltip_shown_timer_.IsRunning()) { | 256 if (tooltip_shown_timer_.IsRunning()) { |
| 257 tooltip_shown_timer_.Stop(); | 257 tooltip_shown_timer_.Stop(); |
| 258 TooltipShownTimerFired(); | 258 TooltipShownTimerFired(); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 ui::EventResult TooltipController::OnMouseEvent(ui::MouseEvent* event) { | 262 void TooltipController::OnMouseEvent(ui::MouseEvent* event) { |
| 263 aura::Window* target = static_cast<aura::Window*>(event->target()); | 263 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 264 switch (event->type()) { | 264 switch (event->type()) { |
| 265 case ui::ET_MOUSE_MOVED: | 265 case ui::ET_MOUSE_MOVED: |
| 266 case ui::ET_MOUSE_DRAGGED: | 266 case ui::ET_MOUSE_DRAGGED: |
| 267 if (tooltip_window_ != target) { | 267 if (tooltip_window_ != target) { |
| 268 if (tooltip_window_) | 268 if (tooltip_window_) |
| 269 tooltip_window_->RemoveObserver(this); | 269 tooltip_window_->RemoveObserver(this); |
| 270 tooltip_window_ = target; | 270 tooltip_window_ = target; |
| 271 tooltip_window_->AddObserver(this); | 271 tooltip_window_->AddObserver(this); |
| 272 } | 272 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 291 // We will not received a mouse release, so reset mouse pressed state. | 291 // We will not received a mouse release, so reset mouse pressed state. |
| 292 mouse_pressed_ = false; | 292 mouse_pressed_ = false; |
| 293 case ui::ET_MOUSEWHEEL: | 293 case ui::ET_MOUSEWHEEL: |
| 294 // Hide the tooltip for click, release, drag, wheel events. | 294 // Hide the tooltip for click, release, drag, wheel events. |
| 295 if (GetTooltip()->IsVisible()) | 295 if (GetTooltip()->IsVisible()) |
| 296 GetTooltip()->Hide(); | 296 GetTooltip()->Hide(); |
| 297 break; | 297 break; |
| 298 default: | 298 default: |
| 299 break; | 299 break; |
| 300 } | 300 } |
| 301 return ui::ER_UNHANDLED; | |
| 302 } | 301 } |
| 303 | 302 |
| 304 void TooltipController::OnTouchEvent(ui::TouchEvent* event) { | 303 void TooltipController::OnTouchEvent(ui::TouchEvent* event) { |
| 305 // TODO(varunjain): need to properly implement tooltips for | 304 // TODO(varunjain): need to properly implement tooltips for |
| 306 // touch events. | 305 // touch events. |
| 307 // Hide the tooltip for touch events. | 306 // Hide the tooltip for touch events. |
| 308 if (GetTooltip()->IsVisible()) | 307 if (GetTooltip()->IsVisible()) |
| 309 GetTooltip()->Hide(); | 308 GetTooltip()->Hide(); |
| 310 if (tooltip_window_) | 309 if (tooltip_window_) |
| 311 tooltip_window_->RemoveObserver(this); | 310 tooltip_window_->RemoveObserver(this); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 } | 478 } |
| 480 | 479 |
| 481 TooltipController::Tooltip* TooltipController::GetTooltip() { | 480 TooltipController::Tooltip* TooltipController::GetTooltip() { |
| 482 if (!tooltip_.get()) | 481 if (!tooltip_.get()) |
| 483 tooltip_.reset(new Tooltip(this)); | 482 tooltip_.reset(new Tooltip(this)); |
| 484 return tooltip_.get(); | 483 return tooltip_.get(); |
| 485 } | 484 } |
| 486 | 485 |
| 487 } // namespace internal | 486 } // namespace internal |
| 488 } // namespace ash | 487 } // namespace ash |
| OLD | NEW |