| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | 5 #ifndef ASH_COMMON_SHELF_SHELF_TOOLTIP_MANAGER_H_ |
| 6 #define ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | 6 #define ASH_COMMON_SHELF_SHELF_TOOLTIP_MANAGER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/shelf/shelf_layout_manager_observer.h" | 9 #include "ash/common/shelf/wm_shelf_observer.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "ui/aura/window_observer.h" | |
| 14 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 15 #include "ui/views/pointer_watcher.h" | 14 #include "ui/views/pointer_watcher.h" |
| 16 | 15 |
| 17 namespace views { | 16 namespace views { |
| 18 class BubbleDialogDelegateView; | 17 class BubbleDialogDelegateView; |
| 19 class View; | 18 class View; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace ash { | 21 namespace ash { |
| 23 class ShelfLayoutManager; | |
| 24 class ShelfView; | 22 class ShelfView; |
| 25 | 23 |
| 26 namespace test { | 24 namespace test { |
| 27 class ShelfTooltipManagerTest; | 25 class ShelfTooltipManagerTest; |
| 28 class ShelfViewTest; | 26 class ShelfViewTest; |
| 29 } | 27 } |
| 30 | 28 |
| 31 // ShelfTooltipManager manages the tooltip bubble that appears for shelf items. | 29 // ShelfTooltipManager manages the tooltip bubble that appears for shelf items. |
| 32 class ASH_EXPORT ShelfTooltipManager : public ui::EventHandler, | 30 class ASH_EXPORT ShelfTooltipManager : public ui::EventHandler, |
| 33 public aura::WindowObserver, | |
| 34 public views::PointerWatcher, | 31 public views::PointerWatcher, |
| 35 public ShelfLayoutManagerObserver { | 32 public WmShelfObserver { |
| 36 public: | 33 public: |
| 37 explicit ShelfTooltipManager(ShelfView* shelf_view); | 34 explicit ShelfTooltipManager(ShelfView* shelf_view); |
| 38 ~ShelfTooltipManager() override; | 35 ~ShelfTooltipManager() override; |
| 39 | 36 |
| 40 // Initializes the tooltip manager once the shelf is shown. | 37 // Initializes the tooltip manager once the shelf is shown. |
| 41 void Init(); | 38 void Init(); |
| 42 | 39 |
| 43 // Closes the tooltip. | 40 // Closes the tooltip. |
| 44 void Close(); | 41 void Close(); |
| 45 | 42 |
| 46 // Returns true if the tooltip is currently visible. | 43 // Returns true if the tooltip is currently visible. |
| 47 bool IsVisible() const; | 44 bool IsVisible() const; |
| 48 | 45 |
| 49 // Returns the view to which the tooltip bubble is anchored. May be null. | 46 // Returns the view to which the tooltip bubble is anchored. May be null. |
| 50 views::View* GetCurrentAnchorView() const; | 47 views::View* GetCurrentAnchorView() const; |
| 51 | 48 |
| 52 // Show the tooltip bubble for the specified view. | 49 // Show the tooltip bubble for the specified view. |
| 53 void ShowTooltip(views::View* view); | 50 void ShowTooltip(views::View* view); |
| 54 void ShowTooltipWithDelay(views::View* view); | 51 void ShowTooltipWithDelay(views::View* view); |
| 55 | 52 |
| 56 // Set the timer delay in ms for testing. | 53 // Set the timer delay in ms for testing. |
| 57 void set_timer_delay_for_test(int timer_delay) { timer_delay_ = timer_delay; } | 54 void set_timer_delay_for_test(int timer_delay) { timer_delay_ = timer_delay; } |
| 58 | 55 |
| 59 protected: | 56 protected: |
| 60 // ui::EventHandler overrides: | 57 // ui::EventHandler overrides: |
| 61 void OnEvent(ui::Event* event) override; | 58 void OnMouseEvent(ui::MouseEvent* event) override; |
| 62 | |
| 63 // aura::WindowObserver overrides: | |
| 64 void OnWindowDestroying(aura::Window* window) override; | |
| 65 | 59 |
| 66 // views::PointerWatcher overrides: | 60 // views::PointerWatcher overrides: |
| 67 void OnMousePressed(const ui::MouseEvent& event, | 61 void OnMousePressed(const ui::MouseEvent& event, |
| 68 const gfx::Point& location_in_screen, | 62 const gfx::Point& location_in_screen, |
| 69 views::Widget* target) override; | 63 views::Widget* target) override; |
| 70 void OnTouchPressed(const ui::TouchEvent& event, | 64 void OnTouchPressed(const ui::TouchEvent& event, |
| 71 const gfx::Point& location_in_screen, | 65 const gfx::Point& location_in_screen, |
| 72 views::Widget* target) override; | 66 views::Widget* target) override; |
| 73 | 67 |
| 74 // ShelfLayoutManagerObserver overrides: | 68 // WmShelfObserver overrides: |
| 75 void WillDeleteShelfLayoutManager() override; | |
| 76 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | 69 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| 77 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | 70 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
| 78 | 71 |
| 79 private: | 72 private: |
| 80 class ShelfTooltipBubble; | 73 class ShelfTooltipBubble; |
| 81 friend class test::ShelfViewTest; | 74 friend class test::ShelfViewTest; |
| 82 friend class test::ShelfTooltipManagerTest; | 75 friend class test::ShelfTooltipManagerTest; |
| 83 | 76 |
| 84 // A helper function to check for shelf visibility and view validity. | 77 // A helper function to check for shelf visibility and view validity. |
| 85 bool ShouldShowTooltipForView(views::View* view); | 78 bool ShouldShowTooltipForView(views::View* view); |
| 86 | 79 |
| 87 int timer_delay_; | 80 int timer_delay_; |
| 88 base::OneShotTimer timer_; | 81 base::OneShotTimer timer_; |
| 89 | 82 |
| 90 ShelfView* shelf_view_; | 83 ShelfView* shelf_view_; |
| 91 aura::Window* root_window_; | |
| 92 ShelfLayoutManager* shelf_layout_manager_; | |
| 93 views::BubbleDialogDelegateView* bubble_; | 84 views::BubbleDialogDelegateView* bubble_; |
| 94 | 85 |
| 95 base::WeakPtrFactory<ShelfTooltipManager> weak_factory_; | 86 base::WeakPtrFactory<ShelfTooltipManager> weak_factory_; |
| 96 | 87 |
| 97 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManager); | 88 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManager); |
| 98 }; | 89 }; |
| 99 | 90 |
| 100 } // namespace ash | 91 } // namespace ash |
| 101 | 92 |
| 102 #endif // ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | 93 #endif // ASH_COMMON_SHELF_SHELF_TOOLTIP_MANAGER_H_ |
| OLD | NEW |