Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: ash/system/tray/hover_highlight_view.h

Issue 2865533002: Reset HoverHighlightView state before re-populating (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/network/vpn_list_view.cc ('k') | ash/system/tray/hover_highlight_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ 5 #ifndef ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_
6 #define ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ 6 #define ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_
7 7
8 #include "ash/system/tray/actionable_view.h" 8 #include "ash/system/tray/actionable_view.h"
9 #include "ash/system/tray/tray_popup_item_style.h" 9 #include "ash/system/tray/tray_popup_item_style.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 20 matching lines...) Expand all
31 // This view is a checked checkbox. 31 // This view is a checked checkbox.
32 CHECKED_CHECKBOX, 32 CHECKED_CHECKBOX,
33 // This view is an unchecked checkbox. 33 // This view is an unchecked checkbox.
34 UNCHECKED_CHECKBOX 34 UNCHECKED_CHECKBOX
35 }; 35 };
36 36
37 // If |listener| is null then no action is taken on click. 37 // If |listener| is null then no action is taken on click.
38 explicit HoverHighlightView(ViewClickListener* listener); 38 explicit HoverHighlightView(ViewClickListener* listener);
39 ~HoverHighlightView() override; 39 ~HoverHighlightView() override;
40 40
41 // Convenience function for adding an icon and a label. This also sets the 41 // Convenience function for populating the view with an icon and a label. This
42 // accessible name. Primarily used for scrollable rows in detailed views. 42 // also sets the accessible name. Primarily used for scrollable rows in
43 // detailed views.
43 void AddIconAndLabel(const gfx::ImageSkia& image, const base::string16& text); 44 void AddIconAndLabel(const gfx::ImageSkia& image, const base::string16& text);
44 45
45 // Convenience function for adding an icon, a main label, and a sub label. 46 // Convenience function for populating the view with an icon, a main label,
46 // This also sets the accessible name besed on the main label. Used for 47 // and a sub label. This also sets the accessible name based on the main
47 // scrollable rows in detailed views. 48 // label. Used for scrollable rows in detailed views.
48 void AddIconAndLabels(const gfx::ImageSkia& image, 49 void AddIconAndLabels(const gfx::ImageSkia& image,
49 const base::string16& text, 50 const base::string16& text,
50 const base::string16& sub_text); 51 const base::string16& sub_text);
51 52
52 // A convenience function for adding an icon and label for a system menu 53 // A convenience function for populating the view with an icon and a label for
53 // default view row. 54 // a system menu default view row.
54 void AddIconAndLabelForDefaultView(const gfx::ImageSkia& image, 55 void AddIconAndLabelForDefaultView(const gfx::ImageSkia& image,
55 const base::string16& text); 56 const base::string16& text);
56 57
57 // Adds a row containing only a text label, inset on the left by the 58 // Populates the view with a text label, inset on the left by the horizontal
58 // horizontal space that would normally be occupied by an icon. 59 // space that would normally be occupied by an icon.
59 void AddLabelRow(const base::string16& text); 60 void AddLabelRow(const base::string16& text);
60 61
61 // Add an optional right icon to an already established view (call one of 62 // Adds an optional right icon to an already populated view. |icon_size| is
62 // the other Add* functions first). |icon_size| is the size of the icon in DP. 63 // the size of the icon in DP.
63 void AddRightIcon(const gfx::ImageSkia& image, int icon_size); 64 void AddRightIcon(const gfx::ImageSkia& image, int icon_size);
64 65
65 // Add an optional right view to an already established view (call one of 66 // Adds an optional right view to an already populated view.
66 // the other Add* functions first).
67 void AddRightView(views::View* view); 67 void AddRightView(views::View* view);
68 68
69 // Hide or show the right view. 69 // Hides or shows the right view for an already populated view.
70 void SetRightViewVisible(bool visible); 70 void SetRightViewVisible(bool visible);
71 71
72 // Sets the text of |sub_text_label_| to |sub_text|. Prior to calling this 72 // Sets the text of the sub label for an already populated view. |sub_text|
73 // function, |text_label_| must not be null and |sub_text| must not be empty. 73 // must not be empty and prior to calling this function, |text_label_| must
74 // not be null.
74 void SetSubText(const base::string16& sub_text); 75 void SetSubText(const base::string16& sub_text);
75 76
76 // Allows view to expand its height. Size of unexapandable view is fixed and 77 // Allows view to expand its height. Size of unexapandable view is fixed and
77 // equals to kTrayPopupItemHeight. 78 // equals to kTrayPopupItemHeight.
78 void SetExpandable(bool expandable); 79 void SetExpandable(bool expandable);
79 80
80 // Changes the view's current accessibility state. This will fire an 81 // Changes the view's current accessibility state. This will fire an
81 // accessibility event if needed. 82 // accessibility event if needed.
82 void SetAccessiblityState(AccessibilityState accessibility_state); 83 void SetAccessiblityState(AccessibilityState accessibility_state);
83 84
85 // Removes current children of the view so that it can be re-populated.
86 void Reset();
87
84 views::Label* text_label() { return text_label_; } 88 views::Label* text_label() { return text_label_; }
85 views::Label* sub_text_label() { return sub_text_label_; } 89 views::Label* sub_text_label() { return sub_text_label_; }
86 90
87 protected: 91 protected:
88 // views::View: 92 // views::View:
89 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 93 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
90 94
91 TriView* tri_view() { return tri_view_; } 95 TriView* tri_view() { return tri_view_; }
92 96
93 private: 97 private:
(...skipping 13 matching lines...) Expand all
107 111
108 // ActionableView: 112 // ActionableView:
109 bool PerformAction(const ui::Event& event) override; 113 bool PerformAction(const ui::Event& event) override;
110 114
111 // views::View: 115 // views::View:
112 gfx::Size GetPreferredSize() const override; 116 gfx::Size GetPreferredSize() const override;
113 int GetHeightForWidth(int width) const override; 117 int GetHeightForWidth(int width) const override;
114 void OnEnabledChanged() override; 118 void OnEnabledChanged() override;
115 void OnFocus() override; 119 void OnFocus() override;
116 120
117 ViewClickListener* listener_ = nullptr; 121 // Determines whether the view is populated or not. If it is, Reset() should
122 // be called before re-populating the view.
123 bool is_populated_ = false;
124
125 ViewClickListener* const listener_ = nullptr;
118 views::Label* text_label_ = nullptr; 126 views::Label* text_label_ = nullptr;
119 views::Label* sub_text_label_ = nullptr; 127 views::Label* sub_text_label_ = nullptr;
120 views::ImageView* left_icon_ = nullptr; 128 views::ImageView* left_icon_ = nullptr;
121 views::View* right_view_ = nullptr; 129 views::View* right_view_ = nullptr;
122 TriView* tri_view_ = nullptr; 130 TriView* tri_view_ = nullptr;
123 bool expandable_ = false; 131 bool expandable_ = false;
124 AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT; 132 AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT;
125 133
126 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); 134 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView);
127 }; 135 };
128 136
129 } // namespace ash 137 } // namespace ash
130 138
131 #endif // ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ 139 #endif // ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_
OLDNEW
« no previous file with comments | « ash/system/network/vpn_list_view.cc ('k') | ash/system/tray/hover_highlight_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698