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

Side by Side Diff: ash/common/shelf/shelf_button.h

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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 2013 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_COMMON_SHELF_SHELF_BUTTON_H_
6 #define ASH_COMMON_SHELF_SHELF_BUTTON_H_
7
8 #include "ash/ash_export.h"
9 #include "base/macros.h"
10 #include "ui/gfx/shadow_value.h"
11 #include "ui/views/controls/button/custom_button.h"
12
13 namespace views {
14 class ImageView;
15 }
16
17 namespace ash {
18 class InkDropButtonListener;
19 class ShelfView;
20
21 // Button used for items on the launcher, except for the AppList.
22 class ASH_EXPORT ShelfButton : public views::CustomButton {
23 public:
24 static const char kViewClassName[];
25
26 // Used to indicate the current state of the button.
27 enum State {
28 // Nothing special. Usually represents an app shortcut item with no running
29 // instance.
30 STATE_NORMAL = 0,
31 // Button has mouse hovering on it.
32 STATE_HOVERED = 1 << 0,
33 // Underlying ShelfItem has a running instance.
34 STATE_RUNNING = 1 << 1,
35 // Underlying ShelfItem is active (i.e. has focus).
36 STATE_ACTIVE = 1 << 2,
37 // Underlying ShelfItem needs user's attention.
38 STATE_ATTENTION = 1 << 3,
39 STATE_FOCUSED = 1 << 4,
40 // Hide the status (temporarily for some animations).
41 STATE_HIDDEN = 1 << 5,
42 };
43
44 ShelfButton(InkDropButtonListener* listener, ShelfView* shelf_view);
45 ~ShelfButton() override;
46
47 // Sets the image to display for this entry.
48 void SetImage(const gfx::ImageSkia& image);
49
50 // Retrieve the image to show proxy operations.
51 const gfx::ImageSkia& GetImage() const;
52
53 // |state| is or'd into the current state.
54 void AddState(State state);
55 void ClearState(State state);
56 int state() const { return state_; }
57
58 // Returns the bounds of the icon.
59 gfx::Rect GetIconBounds() const;
60
61 // Called when user started dragging the shelf button.
62 void OnDragStarted(const ui::LocatedEvent* event);
63
64 // Overrides to views::CustomButton:
65 void ShowContextMenu(const gfx::Point& p,
66 ui::MenuSourceType source_type) override;
67
68 // View override - needed by unit test.
69 void OnMouseCaptureLost() override;
70
71 protected:
72 // View overrides:
73 const char* GetClassName() const override;
74 bool OnMousePressed(const ui::MouseEvent& event) override;
75 void OnMouseReleased(const ui::MouseEvent& event) override;
76 bool OnMouseDragged(const ui::MouseEvent& event) override;
77 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
78 void Layout() override;
79 void ChildPreferredSizeChanged(views::View* child) override;
80 void OnFocus() override;
81 void OnBlur() override;
82 void OnPaint(gfx::Canvas* canvas) override;
83
84 // ui::EventHandler overrides:
85 void OnGestureEvent(ui::GestureEvent* event) override;
86
87 // views::CustomButton overrides:
88 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
89 bool ShouldEnterPushedState(const ui::Event& event) override;
90 std::unique_ptr<views::InkDrop> CreateInkDrop() override;
91 void NotifyClick(const ui::Event& event) override;
92
93 // Sets the icon image with a shadow.
94 void SetShadowedImage(const gfx::ImageSkia& bitmap);
95
96 private:
97 class AppStatusIndicatorView;
98
99 // Updates the parts of the button to reflect the current |state_| and
100 // alignment. This may add or remove views, layout and paint.
101 void UpdateState();
102
103 InkDropButtonListener* listener_;
104
105 // The shelf view hosting this button.
106 ShelfView* shelf_view_;
107
108 // The icon part of a button can be animated independently of the rest.
109 views::ImageView* icon_view_;
110
111 // Draws an indicator underneath the image to represent the state of the
112 // application.
113 AppStatusIndicatorView* indicator_;
114
115 // The current application state, a bitfield of State enum values.
116 int state_;
117
118 gfx::ShadowValues icon_shadows_;
119
120 // If non-null the destuctor sets this to true. This is set while the menu is
121 // showing and used to detect if the menu was deleted while running.
122 bool* destroyed_flag_;
123
124 DISALLOW_COPY_AND_ASSIGN(ShelfButton);
125 };
126
127 } // namespace ash
128
129 #endif // ASH_COMMON_SHELF_SHELF_BUTTON_H_
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_background_animator_unittest.cc ('k') | ash/common/shelf/shelf_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698