| 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_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
| 7 | 7 |
| 8 #include "ash/common/system/tray/actionable_view.h" | 8 #include "ash/common/system/tray/actionable_view.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
| 11 #include "ui/gfx/text_constants.h" | 11 #include "ui/gfx/text_constants.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 class ImageView; |
| 14 class Label; | 15 class Label; |
| 16 class BoxLayout; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace ash { | 19 namespace ash { |
| 18 class ViewClickListener; | 20 class ViewClickListener; |
| 19 | 21 |
| 20 // A view that changes background color on hover, and triggers a callback in the | 22 // A view that changes background color on hover, and triggers a callback in the |
| 21 // associated ViewClickListener on click. The view can also be forced to | 23 // associated ViewClickListener on click. The view can also be forced to |
| 22 // maintain a fixed height. | 24 // maintain a fixed height. |
| 23 class HoverHighlightView : public ActionableView { | 25 class HoverHighlightView : public ActionableView { |
| 24 public: | 26 public: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 bool highlight); | 38 bool highlight); |
| 37 | 39 |
| 38 // Convenience function for adding an icon and a label. This also sets the | 40 // Convenience function for adding an icon and a label. This also sets the |
| 39 // accessible name. The icon has an indent equal to | 41 // accessible name. The icon has an indent equal to |
| 40 // kTrayPopupPaddingHorizontal. | 42 // kTrayPopupPaddingHorizontal. |
| 41 void AddIndentedIconAndLabel(const gfx::ImageSkia& image, | 43 void AddIndentedIconAndLabel(const gfx::ImageSkia& image, |
| 42 const base::string16& text, | 44 const base::string16& text, |
| 43 bool highlight); | 45 bool highlight); |
| 44 | 46 |
| 45 // Convenience function for adding a label with padding on the left for a | 47 // Convenience function for adding a label with padding on the left for a |
| 46 // blank icon. This also sets the accessible name. Returns label after | 48 // blank icon. This also sets the accessible name. Returns label after |
| 47 // parenting it. | 49 // parenting it. |
| 48 views::Label* AddLabel(const base::string16& text, | 50 views::Label* AddLabel(const base::string16& text, |
| 49 gfx::HorizontalAlignment alignment, | 51 gfx::HorizontalAlignment alignment, |
| 50 bool highlight); | 52 bool highlight); |
| 51 | 53 |
| 52 // Convenience function for adding an optional check and a label. In the | 54 // Convenience function for adding an optional check and a label. In the |
| 53 // absence of a check, padding is added to align with checked items. | 55 // absence of a check, padding is added to align with checked items. |
| 54 // Returns label after parenting it. | 56 // Returns label after parenting it. |
| 55 views::Label* AddCheckableLabel(const base::string16& text, | 57 views::Label* AddCheckableLabel(const base::string16& text, |
| 56 bool highlight, | 58 bool highlight, |
| 57 bool checked); | 59 bool checked); |
| 58 | 60 |
| 61 // Add an optional right icon to an already established view (call one of |
| 62 // the other Add* functions first). |
| 63 void AddRightIcon(const gfx::ImageSkia& image); |
| 64 |
| 65 // Hide or show the right icon. |
| 66 void SetRightIconVisible(bool visible); |
| 67 |
| 59 // Allows view to expand its height. | 68 // Allows view to expand its height. |
| 60 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. | 69 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. |
| 61 void SetExpandable(bool expandable); | 70 void SetExpandable(bool expandable); |
| 62 | 71 |
| 72 // Enables or disable highlighting on the label, where a highlighted label |
| 73 // just uses a bold font. |
| 74 void SetHighlight(bool hightlight); |
| 75 |
| 63 void set_highlight_color(SkColor color) { highlight_color_ = color; } | 76 void set_highlight_color(SkColor color) { highlight_color_ = color; } |
| 64 void set_default_color(SkColor color) { default_color_ = color; } | 77 void set_default_color(SkColor color) { default_color_ = color; } |
| 65 void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } | 78 void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } |
| 66 void set_text_default_color(SkColor color) { text_default_color_ = color; } | 79 void set_text_default_color(SkColor color) { text_default_color_ = color; } |
| 67 | 80 |
| 68 views::Label* text_label() { return text_label_; } | 81 views::Label* text_label() { return text_label_; } |
| 69 | 82 |
| 70 bool hover() const { return hover_; } | 83 bool hover() const { return hover_; } |
| 71 | 84 |
| 72 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; } | 85 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 91 gfx::Size GetPreferredSize() const override; | 104 gfx::Size GetPreferredSize() const override; |
| 92 int GetHeightForWidth(int width) const override; | 105 int GetHeightForWidth(int width) const override; |
| 93 void OnMouseEntered(const ui::MouseEvent& event) override; | 106 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 94 void OnMouseExited(const ui::MouseEvent& event) override; | 107 void OnMouseExited(const ui::MouseEvent& event) override; |
| 95 void OnGestureEvent(ui::GestureEvent* event) override; | 108 void OnGestureEvent(ui::GestureEvent* event) override; |
| 96 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 109 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 97 void OnEnabledChanged() override; | 110 void OnEnabledChanged() override; |
| 98 void OnPaintBackground(gfx::Canvas* canvas) override; | 111 void OnPaintBackground(gfx::Canvas* canvas) override; |
| 99 void OnFocus() override; | 112 void OnFocus() override; |
| 100 | 113 |
| 101 ViewClickListener* listener_; | 114 ViewClickListener* listener_ = nullptr; |
| 102 views::Label* text_label_; | 115 views::Label* text_label_ = nullptr; |
| 103 SkColor highlight_color_; | 116 views::BoxLayout* box_layout_ = nullptr; |
| 104 SkColor default_color_; | 117 views::ImageView* right_icon_ = nullptr; |
| 105 SkColor text_highlight_color_; | 118 SkColor highlight_color_ = 0; |
| 106 SkColor text_default_color_; | 119 SkColor default_color_ = 0; |
| 107 bool hover_; | 120 SkColor text_highlight_color_ = 0; |
| 108 bool expandable_; | 121 SkColor text_default_color_ = 0; |
| 109 bool checkable_; | 122 bool hover_ = false; |
| 110 bool checked_; | 123 bool expandable_ = false; |
| 124 bool checkable_ = false; |
| 125 bool checked_ = false; |
| 111 base::string16 tooltip_; | 126 base::string16 tooltip_; |
| 112 | 127 |
| 113 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); | 128 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); |
| 114 }; | 129 }; |
| 115 | 130 |
| 116 } // namespace ash | 131 } // namespace ash |
| 117 | 132 |
| 118 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 133 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
| OLD | NEW |