Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | |
| 6 #define ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "ui/base/animation/animation_delegate.h" | |
| 10 #include "ui/views/view.h" | |
| 11 | |
| 12 namespace ui { | |
| 13 class SlideAnimation; | |
| 14 } | |
| 15 | |
| 16 namespace views { | |
| 17 class ImageView; | |
| 18 class Label; | |
| 19 } | |
| 20 | |
| 21 namespace ash { | |
| 22 namespace internal { | |
| 23 | |
| 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 | |
| 26 // animation when showing/hiding the item in the tray. | |
| 27 class TrayItemView : public views::View, | |
| 28 public ui::AnimationDelegate { | |
| 29 public: | |
| 30 TrayItemView(); | |
| 31 virtual ~TrayItemView(); | |
| 32 | |
| 33 // Conveniece function for creating a child Label or ImageView. | |
| 34 void CreateLabel(); | |
| 35 void CreateImageView(); | |
| 36 | |
| 37 views::Label* label() { return label_; } | |
| 38 views::ImageView* image_view() { return image_view_; } | |
| 39 | |
| 40 // Overridden from views::View. | |
| 41 virtual void SetVisible(bool visible) OVERRIDE; | |
| 42 | |
| 43 protected: | |
| 44 // Makes sure the widget relayouts after the size/visibility of the view | |
| 45 // changes. | |
| 46 void ApplyChange(); | |
| 47 | |
| 48 // This should return the desired size of the view. For most views, this | |
| 49 // returns GetPreferredSize. But since this class overrides GetPreferredSize | |
| 50 // for animation purposes, we allow a different way to get this size, and do | |
| 51 // not allow GetPreferredSize to be overridden. | |
| 52 virtual gfx::Size DesiredSize(); | |
| 53 | |
| 54 // The default animation duration is 200ms. But each view can customize this. | |
| 55 virtual int GetAnimationDurationMS(); | |
| 56 | |
| 57 // Overridden from views::View. | |
| 58 virtual void PreferredSizeChanged() OVERRIDE; | |
| 59 | |
| 60 // Overridden from ui::AnimationDelegate. | |
|
Ben Goodger (Google)
2012/04/23 15:33:42
Can these be private? If so, flow them after GetPr
sadrul
2012/04/23 16:07:58
Done.
| |
| 61 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
| 62 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
| 63 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | |
| 64 | |
| 65 private: | |
| 66 // Overridden from views::View. | |
| 67 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 68 | |
| 69 scoped_ptr<ui::SlideAnimation> animation_; | |
| 70 views::Label* label_; | |
| 71 views::ImageView* image_view_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(TrayItemView); | |
| 74 }; | |
| 75 | |
| 76 } // namespace internal | |
| 77 } // namespace ash | |
| 78 | |
| 79 #endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_ | |
| OLD | NEW |