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