| 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 #ifndef ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ |
| 6 #define ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/wm/shelf_layout_manager.h" |
| 10 #include "ash/wm/shelf_types.h" | 11 #include "ash/wm/shelf_types.h" |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/string16.h" | 13 #include "base/string16.h" |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 14 #include "ui/views/bubble/bubble_border.h" | 15 #include "ui/views/bubble/bubble_border.h" |
| 15 #include "ui/views/bubble/bubble_delegate.h" | 16 #include "ui/views/bubble/bubble_delegate.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class Timer; | 19 class Timer; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace views { | 22 namespace views { |
| 22 class BubbleDelegateView; | 23 class BubbleDelegateView; |
| 23 class Label; | 24 class Label; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace ash { | 27 namespace ash { |
| 27 namespace test { | 28 namespace test { |
| 29 class LauncherTooltipManagerTest; |
| 28 class LauncherViewTest; | 30 class LauncherViewTest; |
| 29 } | 31 } |
| 30 | 32 |
| 31 namespace internal { | 33 namespace internal { |
| 32 | 34 |
| 33 // LauncherTooltipManager manages the tooltip balloon poping up on launcher | 35 // LauncherTooltipManager manages the tooltip balloon poping up on launcher |
| 34 // items. | 36 // items. |
| 35 class ASH_EXPORT LauncherTooltipManager { | 37 class ASH_EXPORT LauncherTooltipManager : public ShelfLayoutManager::Observer { |
| 36 public: | 38 public: |
| 37 LauncherTooltipManager(ShelfAlignment alignment); | 39 LauncherTooltipManager(ShelfAlignment alignment, |
| 38 ~LauncherTooltipManager(); | 40 ShelfLayoutManager* shelf_layout_manager); |
| 41 virtual ~LauncherTooltipManager(); |
| 39 | 42 |
| 40 // Called when the bubble is closed. | 43 // Called when the bubble is closed. |
| 41 void OnBubbleClosed(views::BubbleDelegateView* view); | 44 void OnBubbleClosed(views::BubbleDelegateView* view); |
| 42 | 45 |
| 43 // Shows the tooltip after a delay. It also has the appearing animation. | 46 // Shows the tooltip after a delay. It also has the appearing animation. |
| 44 void ShowDelayed(views::View* anchor, const string16& text); | 47 void ShowDelayed(views::View* anchor, const string16& text); |
| 45 | 48 |
| 46 // Shows the tooltip immediately. It omits the appearing animation. | 49 // Shows the tooltip immediately. It omits the appearing animation. |
| 47 void ShowImmediately(views::View* anchor, const string16& text); | 50 void ShowImmediately(views::View* anchor, const string16& text); |
| 48 | 51 |
| 49 // Closes the tooltip. | 52 // Closes the tooltip. |
| 50 void Close(); | 53 void Close(); |
| 51 | 54 |
| 52 // Changes the arrow location of the tooltip in case that the launcher | 55 // Changes the arrow location of the tooltip in case that the launcher |
| 53 // arrangement has changed. | 56 // arrangement has changed. |
| 54 void SetArrowLocation(ShelfAlignment alignment); | 57 void SetArrowLocation(ShelfAlignment alignment); |
| 55 | 58 |
| 56 // Resets the timer for the delayed showing |view_|. If the timer isn't | 59 // Resets the timer for the delayed showing |view_|. If the timer isn't |
| 57 // running, it starts a new timer. | 60 // running, it starts a new timer. |
| 58 void ResetTimer(); | 61 void ResetTimer(); |
| 59 | 62 |
| 60 // Stops the timer for the delayed showing |view_|. | 63 // Stops the timer for the delayed showing |view_|. |
| 61 void StopTimer(); | 64 void StopTimer(); |
| 62 | 65 |
| 63 // Returns true if the tooltip is currently visible. | 66 // Returns true if the tooltip is currently visible. |
| 64 bool IsVisible(); | 67 bool IsVisible(); |
| 65 | 68 |
| 69 protected: |
| 70 // ShelfLayoutManager::Observer overrides: |
| 71 virtual void WillVisibilityStateChange( |
| 72 ShelfLayoutManager::VisibilityState new_state) OVERRIDE; |
| 73 virtual void OnAutoHideStateChanged( |
| 74 ShelfLayoutManager::AutoHideState new_state) OVERRIDE; |
| 75 |
| 66 private: | 76 private: |
| 67 class LauncherTooltipBubble; | 77 class LauncherTooltipBubble; |
| 68 friend class test::LauncherViewTest; | 78 friend class test::LauncherViewTest; |
| 79 friend class test::LauncherTooltipManagerTest; |
| 69 | 80 |
| 70 void ShowInternal(); | 81 void ShowInternal(); |
| 71 void CreateBubble(views::View* anchor, const string16& text); | 82 void CreateBubble(views::View* anchor, const string16& text); |
| 72 | 83 |
| 73 LauncherTooltipBubble* view_; | 84 LauncherTooltipBubble* view_; |
| 74 views::View* anchor_; | 85 views::View* anchor_; |
| 75 string16 text_; | 86 string16 text_; |
| 76 ShelfAlignment alignment_; | 87 ShelfAlignment alignment_; |
| 77 scoped_ptr<base::Timer> timer_; | 88 scoped_ptr<base::Timer> timer_; |
| 78 | 89 |
| 90 ShelfLayoutManager* shelf_layout_manager_; |
| 91 |
| 79 DISALLOW_COPY_AND_ASSIGN(LauncherTooltipManager); | 92 DISALLOW_COPY_AND_ASSIGN(LauncherTooltipManager); |
| 80 }; | 93 }; |
| 81 | 94 |
| 82 } // namespace internal | 95 } // namespace internal |
| 83 } // namespace ash | 96 } // namespace ash |
| 84 | 97 |
| 85 #endif // ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ | 98 #endif // ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ |
| OLD | NEW |