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; | |
42 | |
sadrul
2012/07/19 16:46:28
-extra new line
jennyz
2012/07/19 18:33:33
Done.
| |
41 | 43 |
42 protected: | 44 protected: |
43 // Makes sure the widget relayouts after the size/visibility of the view | 45 // Makes sure the widget relayouts after the size/visibility of the view |
44 // changes. | 46 // changes. |
45 void ApplyChange(); | 47 void ApplyChange(); |
46 | 48 |
47 // This should return the desired size of the view. For most views, this | 49 // This should return the desired size of the view. For most views, this |
48 // returns GetPreferredSize. But since this class overrides GetPreferredSize | 50 // returns GetPreferredSize. But since this class overrides GetPreferredSize |
49 // for animation purposes, we allow a different way to get this size, and do | 51 // for animation purposes, we allow a different way to get this size, and do |
50 // not allow GetPreferredSize to be overridden. | 52 // not allow GetPreferredSize to be overridden. |
51 virtual gfx::Size DesiredSize(); | 53 virtual gfx::Size DesiredSize(); |
52 | 54 |
53 // The default animation duration is 200ms. But each view can customize this. | 55 // The default animation duration is 200ms. But each view can customize this. |
54 virtual int GetAnimationDurationMS(); | 56 virtual int GetAnimationDurationMS(); |
55 | 57 |
56 private: | 58 private: |
57 // Overridden from views::View. | 59 // Overridden from views::View. |
58 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
59 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 60 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
60 | 61 |
61 // Overridden from ui::AnimationDelegate. | 62 // Overridden from ui::AnimationDelegate. |
62 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 63 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
63 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 64 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
64 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | 65 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; |
65 | 66 |
66 scoped_ptr<ui::SlideAnimation> animation_; | 67 scoped_ptr<ui::SlideAnimation> animation_; |
67 views::Label* label_; | 68 views::Label* label_; |
68 views::ImageView* image_view_; | 69 views::ImageView* image_view_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(TrayItemView); | 71 DISALLOW_COPY_AND_ASSIGN(TrayItemView); |
71 }; | 72 }; |
72 | 73 |
73 } // namespace internal | 74 } // namespace internal |
74 } // namespace ash | 75 } // namespace ash |
75 | 76 |
76 #endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | 77 #endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ |
OLD | NEW |