| 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 ShelfView; | 13 class ShelfView; |
| 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 // |shelf_view| is the view containing this button. | 19 // |shelf_view| is the view containing this button. |
| 20 OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf); | 20 OverflowButton(ShelfView* shelf_view, WmShelf* wm_shelf); |
| 21 ~OverflowButton() override; | 21 ~OverflowButton() override; |
| 22 | 22 |
| 23 void OnShelfAlignmentChanged(); | 23 void OnShelfAlignmentChanged(); |
| 24 void OnOverflowBubbleShown(); |
| 25 void OnOverflowBubbleHidden(); |
| 24 | 26 |
| 25 // Sets alpha value of the background and schedules a paint. | 27 // Sets alpha value of the background and schedules a paint. |
| 26 void SetBackgroundAlpha(int alpha); | 28 void SetBackgroundAlpha(int alpha); |
| 27 | 29 |
| 28 private: | 30 private: |
| 29 // views::View: | 31 // views::CustomButton: |
| 30 void OnPaint(gfx::Canvas* canvas) override; | 32 void OnPaint(gfx::Canvas* canvas) override; |
| 31 | 33 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
| 32 // views::CustomButton: | 34 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 35 bool ShouldShowInkDropHighlight() const override; |
| 33 void NotifyClick(const ui::Event& event) override; | 36 void NotifyClick(const ui::Event& event) override; |
| 34 | 37 |
| 35 // Helper functions to paint the background and foreground of the button | 38 // Helper functions to paint the background and foreground of the button |
| 36 // at |bounds|. | 39 // at |bounds|. |
| 37 void PaintBackground(gfx::Canvas* canvas, const gfx::Rect& bounds); | 40 void PaintBackground(gfx::Canvas* canvas, const gfx::Rect& bounds); |
| 38 void PaintForeground(gfx::Canvas* canvas, const gfx::Rect& bounds); | 41 void PaintForeground(gfx::Canvas* canvas, const gfx::Rect& bounds); |
| 39 | 42 |
| 40 // Returns the id of the asset to use for the button backgound based on the | 43 // Returns the id of the asset to use for the button backgound based on the |
| 41 // current shelf state. | 44 // current shelf state. |
| 42 // TODO(tdanderson): Remove this once the material design shelf is enabled | 45 // TODO(tdanderson): Remove this once the material design shelf is enabled |
| 43 // by default. See crbug.com/614453. | 46 // by default. See crbug.com/614453. |
| 44 int NonMaterialBackgroundImageId(); | 47 int NonMaterialBackgroundImageId() const; |
| 45 | 48 |
| 46 // Calculates the bounds of the overflow button based on the shelf alignment. | 49 // Calculates the bounds of the overflow button based on the shelf alignment. |
| 47 gfx::Rect CalculateButtonBounds(); | 50 gfx::Rect CalculateButtonBounds() const; |
| 48 | 51 |
| 49 // Used for bottom shelf alignment. |bottom_image_| points to | 52 // Used for bottom shelf alignment. |bottom_image_| points to |
| 50 // |bottom_image_md_| for material design, otherwise it is points to a | 53 // |bottom_image_md_| for material design, otherwise it is points to a |
| 51 // resource owned by the ResourceBundle. | 54 // resource owned by the ResourceBundle. |
| 52 // TODO(tdanderson): Remove the non-md code once the material design shelf is | 55 // TODO(tdanderson): Remove the non-md code once the material design shelf is |
| 53 // enabled by default. See crbug.com/614453. | 56 // enabled by default. See crbug.com/614453. |
| 54 const gfx::ImageSkia* bottom_image_; | 57 const gfx::ImageSkia* bottom_image_; |
| 55 gfx::ImageSkia bottom_image_md_; | 58 gfx::ImageSkia bottom_image_md_; |
| 56 | 59 |
| 57 // Cached rotations of |bottom_image_| used for left and right shelf | 60 // Cached rotations of |bottom_image_| used for left and right shelf |
| 58 // alignments. | 61 // alignments. |
| 59 gfx::ImageSkia left_image_; | 62 gfx::ImageSkia left_image_; |
| 60 gfx::ImageSkia right_image_; | 63 gfx::ImageSkia right_image_; |
| 61 | 64 |
| 62 ShelfView* shelf_view_; | 65 ShelfView* shelf_view_; |
| 63 WmShelf* wm_shelf_; | 66 WmShelf* wm_shelf_; |
| 64 | 67 |
| 65 // Alpha value used to paint the background. | 68 // Alpha value used to paint the background. |
| 66 int background_alpha_; | 69 int background_alpha_; |
| 67 | 70 |
| 68 DISALLOW_COPY_AND_ASSIGN(OverflowButton); | 71 DISALLOW_COPY_AND_ASSIGN(OverflowButton); |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace ash | 74 } // namespace ash |
| 72 | 75 |
| 73 #endif // ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ | 76 #endif // ASH_COMMON_SHELF_OVERFLOW_BUTTON_H_ |
| OLD | NEW |