Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: ash/system/tray/tray_item_view.h

Issue 2063813002: mash: Move SystemTrayImage and TrayImageItem to //ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wmnotifier
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "base/macros.h"
12 #include "ui/gfx/animation/animation_delegate.h"
13 #include "ui/views/view.h"
14
15 namespace gfx {
16 class SlideAnimation;
17 }
18
19 namespace views {
20 class ImageView;
21 class Label;
22 }
23
24 namespace ash {
25 class SystemTrayItem;
26
27 // Base-class for items in the tray. It makes sure the widget is updated
28 // correctly when the visibility/size of the tray item changes. It also adds
29 // animation when showing/hiding the item in the tray.
30 class ASH_EXPORT TrayItemView : public views::View,
31 public gfx::AnimationDelegate {
32 public:
33 explicit TrayItemView(SystemTrayItem* owner);
34 ~TrayItemView() override;
35
36 static void DisableAnimationsForTest();
37
38 // Convenience function for creating a child Label or ImageView.
39 void CreateLabel();
40 void CreateImageView();
41
42 SystemTrayItem* owner() const { return owner_; }
43 views::Label* label() const { return label_; }
44 views::ImageView* image_view() const { return image_view_; }
45
46 // Overridden from views::View.
47 void SetVisible(bool visible) override;
48 gfx::Size GetPreferredSize() const override;
49 int GetHeightForWidth(int width) const override;
50
51 protected:
52 // Makes sure the widget relayouts after the size/visibility of the view
53 // changes.
54 void ApplyChange();
55
56 // This should return the desired size of the view. For most views, this
57 // returns GetPreferredSize. But since this class overrides GetPreferredSize
58 // for animation purposes, we allow a different way to get this size, and do
59 // not allow GetPreferredSize to be overridden.
60 virtual gfx::Size DesiredSize() const;
61
62 // The default animation duration is 200ms. But each view can customize this.
63 virtual int GetAnimationDurationMS();
64
65 private:
66 // Overridden from views::View.
67 void ChildPreferredSizeChanged(View* child) override;
68
69 // Overridden from gfx::AnimationDelegate.
70 void AnimationProgressed(const gfx::Animation* animation) override;
71 void AnimationEnded(const gfx::Animation* animation) override;
72 void AnimationCanceled(const gfx::Animation* animation) override;
73
74 SystemTrayItem* owner_;
75 std::unique_ptr<gfx::SlideAnimation> animation_;
76 views::Label* label_;
77 views::ImageView* image_view_;
78
79 DISALLOW_COPY_AND_ASSIGN(TrayItemView);
80 };
81
82 } // namespace ash
83
84 #endif // ASH_SYSTEM_TRAY_TRAY_ITEM_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698