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_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | 5 #ifndef ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ |
6 #define ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | 6 #define ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ui/gfx/animation/animation_delegate.h" | 9 #include "ui/gfx/animation/animation_delegate.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace ash { | 21 namespace ash { |
22 class SystemTrayItem; | 22 class SystemTrayItem; |
23 | 23 |
24 // Base-class for items in the tray. It makes sure the widget is updated | 24 // Base-class for items in the tray. It makes sure the widget is updated |
25 // correctly when the visibility/size of the tray item changes. It also adds | 25 // correctly when the visibility/size of the tray item changes. It also adds |
26 // animation when showing/hiding the item in the tray. | 26 // animation when showing/hiding the item in the tray. |
27 class ASH_EXPORT TrayItemView : public views::View, | 27 class ASH_EXPORT TrayItemView : public views::View, |
28 public gfx::AnimationDelegate { | 28 public gfx::AnimationDelegate { |
29 public: | 29 public: |
30 explicit TrayItemView(SystemTrayItem* owner); | 30 explicit TrayItemView(SystemTrayItem* owner); |
31 virtual ~TrayItemView(); | 31 ~TrayItemView() override; |
32 | 32 |
33 static void DisableAnimationsForTest(); | 33 static void DisableAnimationsForTest(); |
34 | 34 |
35 // Convenience function for creating a child Label or ImageView. | 35 // Convenience function for creating a child Label or ImageView. |
36 void CreateLabel(); | 36 void CreateLabel(); |
37 void CreateImageView(); | 37 void CreateImageView(); |
38 | 38 |
39 SystemTrayItem* owner() const { return owner_; } | 39 SystemTrayItem* owner() const { return owner_; } |
40 views::Label* label() const { return label_; } | 40 views::Label* label() const { return label_; } |
41 views::ImageView* image_view() const { return image_view_; } | 41 views::ImageView* image_view() const { return image_view_; } |
42 | 42 |
43 // Overridden from views::View. | 43 // Overridden from views::View. |
44 virtual void SetVisible(bool visible) override; | 44 void SetVisible(bool visible) override; |
45 virtual gfx::Size GetPreferredSize() const override; | 45 gfx::Size GetPreferredSize() const override; |
46 virtual int GetHeightForWidth(int width) const override; | 46 int GetHeightForWidth(int width) const override; |
47 | 47 |
48 protected: | 48 protected: |
49 // Makes sure the widget relayouts after the size/visibility of the view | 49 // Makes sure the widget relayouts after the size/visibility of the view |
50 // changes. | 50 // changes. |
51 void ApplyChange(); | 51 void ApplyChange(); |
52 | 52 |
53 // This should return the desired size of the view. For most views, this | 53 // This should return the desired size of the view. For most views, this |
54 // returns GetPreferredSize. But since this class overrides GetPreferredSize | 54 // returns GetPreferredSize. But since this class overrides GetPreferredSize |
55 // for animation purposes, we allow a different way to get this size, and do | 55 // for animation purposes, we allow a different way to get this size, and do |
56 // not allow GetPreferredSize to be overridden. | 56 // not allow GetPreferredSize to be overridden. |
57 virtual gfx::Size DesiredSize() const; | 57 virtual gfx::Size DesiredSize() const; |
58 | 58 |
59 // The default animation duration is 200ms. But each view can customize this. | 59 // The default animation duration is 200ms. But each view can customize this. |
60 virtual int GetAnimationDurationMS(); | 60 virtual int GetAnimationDurationMS(); |
61 | 61 |
62 private: | 62 private: |
63 // Overridden from views::View. | 63 // Overridden from views::View. |
64 virtual void ChildPreferredSizeChanged(View* child) override; | 64 void ChildPreferredSizeChanged(View* child) override; |
65 | 65 |
66 // Overridden from gfx::AnimationDelegate. | 66 // Overridden from gfx::AnimationDelegate. |
67 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 67 void AnimationProgressed(const gfx::Animation* animation) override; |
68 virtual void AnimationEnded(const gfx::Animation* animation) override; | 68 void AnimationEnded(const gfx::Animation* animation) override; |
69 virtual void AnimationCanceled(const gfx::Animation* animation) override; | 69 void AnimationCanceled(const gfx::Animation* animation) override; |
70 | 70 |
71 SystemTrayItem* owner_; | 71 SystemTrayItem* owner_; |
72 scoped_ptr<gfx::SlideAnimation> animation_; | 72 scoped_ptr<gfx::SlideAnimation> animation_; |
73 views::Label* label_; | 73 views::Label* label_; |
74 views::ImageView* image_view_; | 74 views::ImageView* image_view_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(TrayItemView); | 76 DISALLOW_COPY_AND_ASSIGN(TrayItemView); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace ash | 79 } // namespace ash |
80 | 80 |
81 #endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | 81 #endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ |
OLD | NEW |