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