OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_COMMON_SHELF_OVERFLOW_BUTTON_H_ | 5 #ifndef ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ |
6 #define ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ | 6 #define ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/gfx/image/image_skia.h" | 9 #include "ui/gfx/image/image_skia.h" |
10 #include "ui/views/controls/button/custom_button.h" | 10 #include "ui/views/controls/button/custom_button.h" |
11 | 11 |
12 namespace ash { | 12 namespace ash { |
13 class InkDropButtonListener; | 13 class InkDropButtonListener; |
14 class WmShelf; | 14 class WmShelf; |
15 | 15 |
16 // Shelf overflow chevron button. | 16 // Shelf overflow chevron button. |
17 class OverflowButton : public views::CustomButton { | 17 class OverflowButton : public views::CustomButton { |
18 public: | 18 public: |
19 OverflowButton(InkDropButtonListener* listener, WmShelf* wm_shelf); | 19 OverflowButton(InkDropButtonListener* listener, WmShelf* wm_shelf); |
20 ~OverflowButton() override; | 20 ~OverflowButton() override; |
21 | 21 |
22 void OnShelfAlignmentChanged(); | 22 void OnShelfAlignmentChanged(); |
| 23 void OnOverflowBubbleShown(); |
| 24 void OnOverflowBubbleHidden(); |
23 | 25 |
24 private: | 26 private: |
25 // views::View: | 27 // views::CustomButton: |
26 void OnPaint(gfx::Canvas* canvas) override; | 28 void OnPaint(gfx::Canvas* canvas) override; |
27 | 29 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
28 // views::CustomButton: | 30 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 31 bool ShouldShowInkDropHighlight() const override; |
29 void NotifyClick(const ui::Event& event) override; | 32 void NotifyClick(const ui::Event& event) override; |
30 | 33 |
31 // Helper functions to paint the background and foreground of the button | 34 // Helper functions to paint the background and foreground of the button |
32 // at |bounds|. | 35 // at |bounds|. |
33 void PaintBackground(gfx::Canvas* canvas, const gfx::Rect& bounds); | 36 void PaintBackground(gfx::Canvas* canvas, const gfx::Rect& bounds); |
34 void PaintForeground(gfx::Canvas* canvas, const gfx::Rect& bounds); | 37 void PaintForeground(gfx::Canvas* canvas, const gfx::Rect& bounds); |
35 | 38 |
36 // Returns the id of the asset to use for the button backgound based on the | 39 // Returns the id of the asset to use for the button backgound based on the |
37 // current shelf state. | 40 // current shelf state. |
38 // TODO(tdanderson): Remove this once the material design shelf is enabled | 41 // TODO(tdanderson): Remove this once the material design shelf is enabled |
39 // by default. See crbug.com/614453. | 42 // by default. See crbug.com/614453. |
40 int NonMaterialBackgroundImageId(); | 43 int NonMaterialBackgroundImageId() const; |
41 | 44 |
42 // Calculates the bounds of the overflow button based on the shelf alignment. | 45 // Calculates the bounds of the overflow button based on the shelf alignment. |
43 gfx::Rect CalculateButtonBounds(); | 46 gfx::Rect CalculateButtonBounds() const; |
44 | 47 |
45 // Used for bottom shelf alignment. |bottom_image_| points to | 48 // Used for bottom shelf alignment. |bottom_image_| points to |
46 // |bottom_image_md_| for material design, otherwise it is points to a | 49 // |bottom_image_md_| for material design, otherwise it is points to a |
47 // resource owned by the ResourceBundle. | 50 // resource owned by the ResourceBundle. |
48 // TODO(tdanderson): Remove the non-md code once the material design shelf is | 51 // TODO(tdanderson): Remove the non-md code once the material design shelf is |
49 // enabled by default. See crbug.com/614453. | 52 // enabled by default. See crbug.com/614453. |
50 const gfx::ImageSkia* bottom_image_; | 53 const gfx::ImageSkia* bottom_image_; |
51 gfx::ImageSkia bottom_image_md_; | 54 gfx::ImageSkia bottom_image_md_; |
52 | 55 |
53 // Cached rotations of |bottom_image_| used for left and right shelf | 56 // Cached rotations of |bottom_image_| used for left and right shelf |
54 // alignments. | 57 // alignments. |
55 gfx::ImageSkia left_image_; | 58 gfx::ImageSkia left_image_; |
56 gfx::ImageSkia right_image_; | 59 gfx::ImageSkia right_image_; |
57 | 60 |
58 InkDropButtonListener* listener_; | 61 InkDropButtonListener* listener_; |
59 WmShelf* wm_shelf_; | 62 WmShelf* wm_shelf_; |
60 | 63 |
61 DISALLOW_COPY_AND_ASSIGN(OverflowButton); | 64 DISALLOW_COPY_AND_ASSIGN(OverflowButton); |
62 }; | 65 }; |
63 | 66 |
64 } // namespace ash | 67 } // namespace ash |
65 | 68 |
66 #endif // ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ | 69 #endif // ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ |
OLD | NEW |