Chromium Code Reviews| 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 MASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ |
| 6 #define ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | 6 #define MASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ash/shelf/shelf_layout_manager_observer.h" | |
| 10 #include "ash/shelf/shelf_types.h" | |
| 11 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 13 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "mash/shelf/shelf_types.h" | |
| 14 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 15 #include "ui/gfx/geometry/rect.h" | |
| 16 #include "ui/views/bubble/bubble_border.h" | |
| 17 #include "ui/views/bubble/bubble_delegate.h" | |
| 18 | 14 |
| 19 namespace base { | 15 namespace base { |
| 20 class Timer; | 16 class Timer; |
| 21 } | 17 } |
| 22 | 18 |
| 23 namespace views { | 19 namespace views { |
| 24 class BubbleDelegateView; | 20 class BubbleDelegateView; |
| 25 class Label; | 21 class View; |
| 22 class Widget; | |
| 26 } | 23 } |
| 27 | 24 |
| 28 namespace ash { | 25 namespace mash { |
| 26 namespace shelf { | |
| 27 | |
| 29 class ShelfView; | 28 class ShelfView; |
| 30 class ShelfLayoutManager; | |
| 31 | 29 |
| 32 namespace test { | 30 namespace test { |
| 33 class ShelfTooltipManagerTest; | 31 class ShelfTooltipManagerTest; |
| 34 class ShelfViewTest; | 32 class ShelfViewTest; |
| 35 } | 33 } |
| 36 | 34 |
| 37 // ShelfTooltipManager manages the tooltip balloon poping up on shelf items. | 35 // ShelfTooltipManager manages the tooltip balloon poping up on shelf items. |
| 38 class ASH_EXPORT ShelfTooltipManager : public ui::EventHandler, | 36 class ShelfTooltipManager : public ui::EventHandler { |
| 39 public ShelfLayoutManagerObserver { | |
| 40 public: | 37 public: |
| 41 ShelfTooltipManager(ShelfLayoutManager* shelf_layout_manager, | 38 explicit ShelfTooltipManager(ShelfView* shelf_view); |
| 42 ShelfView* shelf_view); | |
| 43 ~ShelfTooltipManager() override; | 39 ~ShelfTooltipManager() override; |
| 44 | 40 |
| 45 ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; } | |
| 46 | |
| 47 // Called when the bubble is closed. | 41 // Called when the bubble is closed. |
| 48 void OnBubbleClosed(views::BubbleDelegateView* view); | 42 void OnBubbleClosed(views::BubbleDelegateView* view); |
| 49 | 43 |
| 50 // Shows the tooltip after a delay. It also has the appearing animation. | 44 // Shows the tooltip after a delay. It also has the appearing animation. |
| 51 void ShowDelayed(views::View* anchor, const base::string16& text); | 45 void ShowDelayed(views::View* anchor, const base::string16& text); |
| 52 | 46 |
| 53 // Shows the tooltip immediately. It omits the appearing animation. | 47 // Shows the tooltip immediately. It omits the appearing animation. |
| 54 void ShowImmediately(views::View* anchor, const base::string16& text); | 48 void ShowImmediately(views::View* anchor, const base::string16& text); |
| 55 | 49 |
| 56 // Closes the tooltip. | 50 // Closes the tooltip. |
| 57 void Close(); | 51 void Close(); |
| 58 | 52 |
| 59 // Changes the arrow location of the tooltip in case that the launcher | |
| 60 // arrangement has changed. | |
| 61 void UpdateArrow(); | |
| 62 | |
| 63 // Resets the timer for the delayed showing |view_|. If the timer isn't | 53 // Resets the timer for the delayed showing |view_|. If the timer isn't |
| 64 // running, it starts a new timer. | 54 // running, it starts a new timer. |
| 65 void ResetTimer(); | 55 void ResetTimer(); |
| 66 | 56 |
| 67 // Stops the timer for the delayed showing |view_|. | 57 // Stops the timer for the delayed showing |view_|. |
| 68 void StopTimer(); | 58 void StopTimer(); |
| 69 | 59 |
| 70 // Returns true if the tooltip is currently visible. | 60 // Returns true if the tooltip is currently visible. |
| 71 bool IsVisible(); | 61 bool IsVisible() const; |
| 72 | 62 |
| 73 // Returns the view to which the tooltip bubble is anchored. May be NULL. | 63 // Returns the view to which the tooltip bubble is anchored. May be NULL. |
| 74 views::View* GetCurrentAnchorView() { return anchor_; } | 64 views::View* GetCurrentAnchorView() const; |
| 75 | 65 |
| 76 // Create an instant timer for test purposes. | 66 // Create an instant timer for test purposes. |
| 77 void CreateZeroDelayTimerForTest(); | 67 void CreateZeroDelayTimerForTest(); |
| 78 | 68 |
| 69 ShelfView* shelf_view() const { return shelf_view_; } | |
| 70 | |
| 79 protected: | 71 protected: |
| 80 // ui::EventHandler overrides: | 72 // ui::EventHandler overrides: |
| 81 void OnMouseEvent(ui::MouseEvent* event) override; | 73 void OnMouseEvent(ui::MouseEvent* event) override; |
| 82 void OnTouchEvent(ui::TouchEvent* event) override; | 74 void OnTouchEvent(ui::TouchEvent* event) override; |
| 83 void OnGestureEvent(ui::GestureEvent* event) override; | 75 void OnGestureEvent(ui::GestureEvent* event) override; |
| 84 void OnCancelMode(ui::CancelModeEvent* event) override; | 76 void OnCancelMode(ui::CancelModeEvent* event) override; |
| 85 | 77 |
| 86 // ShelfLayoutManagerObserver overrides: | |
|
msw
2016/01/27 07:43:41
Add a comment to restore...
| |
| 87 void WillDeleteShelf() override; | |
| 88 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | |
| 89 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | |
| 90 | |
| 91 private: | 78 private: |
| 92 class ShelfTooltipBubble; | 79 class ShelfTooltipBubble; |
| 93 friend class test::ShelfViewTest; | 80 friend class test::ShelfViewTest; |
| 94 friend class test::ShelfTooltipManagerTest; | 81 friend class test::ShelfTooltipManagerTest; |
| 95 | 82 |
| 96 void CancelHidingAnimation(); | 83 void CancelHidingAnimation(); |
| 97 void CloseSoon(); | 84 void CloseSoon(); |
| 98 void ShowInternal(); | 85 void ShowInternal(); |
| 99 void CreateBubble(views::View* anchor, const base::string16& text); | 86 void CreateBubble(views::View* anchor, const base::string16& text); |
| 100 void CreateTimer(int delay_in_ms); | 87 void CreateTimer(int delay_in_ms); |
| 101 | 88 |
| 102 ShelfTooltipBubble* view_; | 89 ShelfTooltipBubble* view_; |
| 103 views::Widget* widget_; | 90 views::Widget* widget_; |
| 104 views::View* anchor_; | |
| 105 base::string16 text_; | |
| 106 scoped_ptr<base::Timer> timer_; | 91 scoped_ptr<base::Timer> timer_; |
| 107 | |
| 108 ShelfLayoutManager* shelf_layout_manager_; | |
| 109 ShelfView* shelf_view_; | 92 ShelfView* shelf_view_; |
| 110 | 93 |
| 111 base::WeakPtrFactory<ShelfTooltipManager> weak_factory_; | 94 base::WeakPtrFactory<ShelfTooltipManager> weak_factory_; |
| 112 | 95 |
| 113 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManager); | 96 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManager); |
| 114 }; | 97 }; |
| 115 | 98 |
| 116 } // namespace ash | 99 } // namespace shelf |
| 100 } // namespace mash | |
| 117 | 101 |
| 118 #endif // ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | 102 #endif // MASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ |
| OLD | NEW |