| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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_SYSTEM_USER_BUTTON_FROM_VIEW_H_ | |
| 6 #define ASH_COMMON_SYSTEM_USER_BUTTON_FROM_VIEW_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/common/system/tray/tray_popup_ink_drop_style.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "ui/views/controls/button/custom_button.h" | |
| 13 | |
| 14 namespace views { | |
| 15 class InkDropContainerView; | |
| 16 } // namespace views | |
| 17 | |
| 18 namespace ash { | |
| 19 namespace tray { | |
| 20 | |
| 21 // This view is used to wrap it's content and transform it into button. | |
| 22 class ButtonFromView : public views::CustomButton { | |
| 23 public: | |
| 24 // The |content| is the content which is shown within the button. The | |
| 25 // |button_listener| will be informed - if provided - when a button was | |
| 26 // pressed. | |
| 27 ButtonFromView(views::View* content, | |
| 28 views::ButtonListener* listener, | |
| 29 TrayPopupInkDropStyle ink_drop_style); | |
| 30 ~ButtonFromView() override; | |
| 31 | |
| 32 // views::View: | |
| 33 void OnMouseEntered(const ui::MouseEvent& event) override; | |
| 34 void OnMouseExited(const ui::MouseEvent& event) override; | |
| 35 void OnPaint(gfx::Canvas* canvas) override; | |
| 36 void OnFocus() override; | |
| 37 void OnBlur() override; | |
| 38 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | |
| 39 void Layout() override; | |
| 40 | |
| 41 // Check if the item is hovered. | |
| 42 bool is_hovered_for_test() { return button_hovered_; } | |
| 43 | |
| 44 protected: | |
| 45 // views::CustomButton: | |
| 46 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | |
| 47 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; | |
| 48 std::unique_ptr<views::InkDrop> CreateInkDrop() override; | |
| 49 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | |
| 50 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | |
| 51 const override; | |
| 52 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override; | |
| 53 | |
| 54 private: | |
| 55 // Content of button. | |
| 56 views::View* content_; | |
| 57 | |
| 58 // Defines the flavor of ink drop ripple/highlight that should be constructed. | |
| 59 TrayPopupInkDropStyle ink_drop_style_; | |
| 60 | |
| 61 // True if button is hovered. | |
| 62 bool button_hovered_; | |
| 63 | |
| 64 // A separate view is necessary to hold the ink drop layer so that |this| can | |
| 65 // host labels with subpixel anti-aliasing enabled. | |
| 66 views::InkDropContainerView* ink_drop_container_; | |
| 67 | |
| 68 std::unique_ptr<views::InkDropMask> ink_drop_mask_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(ButtonFromView); | |
| 71 }; | |
| 72 | |
| 73 } // namespace tray | |
| 74 } // namespace ash | |
| 75 | |
| 76 #endif // ASH_COMMON_SYSTEM_USER_BUTTON_FROM_VIEW_H_ | |
| OLD | NEW |