| 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_SYSTEM_USER_BUTTON_FROM_VIEW_H_ | |
| 6 #define ASH_SYSTEM_USER_BUTTON_FROM_VIEW_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ui/gfx/geometry/insets.h" | |
| 10 #include "ui/views/controls/button/custom_button.h" | |
| 11 | |
| 12 namespace ash { | |
| 13 namespace tray { | |
| 14 | |
| 15 // This view is used to wrap it's content and transform it into button. | |
| 16 class ButtonFromView : public views::CustomButton { | |
| 17 public: | |
| 18 // The |content| is the content which is shown within the button. The | |
| 19 // |button_listener| will be informed - if provided - when a button was | |
| 20 // pressed. If |highlight_on_hover| is set to true, the button will be | |
| 21 // highlighted upon hover and show the accessibility caret. | |
| 22 // The |tab_frame_inset| will be used to inset the blue tab frame inside the | |
| 23 // button. | |
| 24 // An accessible label gets computed based upon descendant views of this view. | |
| 25 ButtonFromView(views::View* content, | |
| 26 views::ButtonListener* listener, | |
| 27 bool highlight_on_hover, | |
| 28 const gfx::Insets& tab_frame_inset); | |
| 29 ~ButtonFromView() override; | |
| 30 | |
| 31 // Called when the border should remain even in the non highlighted state. | |
| 32 void ForceBorderVisible(bool show); | |
| 33 | |
| 34 // Overridden from views::View | |
| 35 void OnMouseEntered(const ui::MouseEvent& event) override; | |
| 36 void OnMouseExited(const ui::MouseEvent& event) override; | |
| 37 void OnPaint(gfx::Canvas* canvas) override; | |
| 38 void OnFocus() override; | |
| 39 void OnBlur() override; | |
| 40 void GetAccessibleState(ui::AXViewState* state) override; | |
| 41 | |
| 42 // Check if the item is hovered. | |
| 43 bool is_hovered_for_test() { return button_hovered_; } | |
| 44 | |
| 45 private: | |
| 46 // Change the hover/active state of the "button" when the status changes. | |
| 47 void ShowActive(); | |
| 48 | |
| 49 // Content of button. | |
| 50 views::View* content_; | |
| 51 | |
| 52 // Whether button should be highligthed on hover. | |
| 53 bool highlight_on_hover_; | |
| 54 | |
| 55 // True if button is hovered. | |
| 56 bool button_hovered_; | |
| 57 | |
| 58 // True if the border should be always visible. | |
| 59 bool show_border_; | |
| 60 | |
| 61 // The insets which get used for the drawn accessibility (tab) frame. | |
| 62 gfx::Insets tab_frame_inset_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(ButtonFromView); | |
| 65 }; | |
| 66 | |
| 67 } // namespace tray | |
| 68 } // namespace ash | |
| 69 | |
| 70 #endif // ASH_SYSTEM_USER_BUTTON_FROM_VIEW_H_ | |
| OLD | NEW |