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

Side by Side Diff: views/controls/button/text_button.h

Issue 3058011: Add "pushed" as a state a TextButton can show (alongside "normal" and "hover"... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/wrench_menu.cc ('k') | views/controls/button/text_button.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 5 #ifndef VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
6 #define VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 6 #define VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
7 #pragma once 7 #pragma once
8 8
9 #include "gfx/font.h" 9 #include "gfx/font.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ALIGN_CENTER, 99 ALIGN_CENTER,
100 ALIGN_RIGHT 100 ALIGN_RIGHT
101 }; 101 };
102 102
103 void set_alignment(TextAlignment alignment) { alignment_ = alignment; } 103 void set_alignment(TextAlignment alignment) { alignment_ = alignment; }
104 104
105 void set_prefix_type(PrefixType type) { prefix_type_ = type; } 105 void set_prefix_type(PrefixType type) { prefix_type_ = type; }
106 106
107 // Sets the icon. 107 // Sets the icon.
108 void SetIcon(const SkBitmap& icon); 108 void SetIcon(const SkBitmap& icon);
109 SkBitmap icon() const { return icon_; }
110 void SetHoverIcon(const SkBitmap& icon); 109 void SetHoverIcon(const SkBitmap& icon);
111 SkBitmap icon_hover() const { return icon_hover_; } 110 void SetPushedIcon(const SkBitmap& icon);
111
112 bool HasIcon() const { return !icon_.empty(); }
112 113
113 // Meanings are reversed for right-to-left layouts. 114 // Meanings are reversed for right-to-left layouts.
114 enum IconPlacement { 115 enum IconPlacement {
115 ICON_ON_LEFT, 116 ICON_ON_LEFT,
116 ICON_ON_RIGHT 117 ICON_ON_RIGHT
117 }; 118 };
118 119
119 IconPlacement icon_placement() { return icon_placement_; } 120 IconPlacement icon_placement() { return icon_placement_; }
120 void set_icon_placement(IconPlacement icon_placement) { 121 void set_icon_placement(IconPlacement icon_placement) {
121 icon_placement_ = icon_placement; 122 icon_placement_ = icon_placement;
122 } 123 }
123 124
124 // TextButton remembers the maximum display size of the text passed to 125 // TextButton remembers the maximum display size of the text passed to
125 // SetText. This method resets the cached maximum display size to the 126 // SetText. This method resets the cached maximum display size to the
126 // current size. 127 // current size.
127 void ClearMaxTextSize(); 128 void ClearMaxTextSize();
128 129
129 void set_max_width(int max_width) { max_width_ = max_width; } 130 void set_max_width(int max_width) { max_width_ = max_width; }
130 void SetFont(const gfx::Font& font); 131 void SetFont(const gfx::Font& font);
131 void SetEnabledColor(SkColor color); 132 void SetEnabledColor(SkColor color);
132 void SetDisabledColor(SkColor color); 133 void SetDisabledColor(SkColor color);
133 void SetHighlightColor(SkColor color); 134 void SetHighlightColor(SkColor color);
134 void SetHoverColor(SkColor color); 135 void SetHoverColor(SkColor color);
135 void SetNormalHasBorder(bool normal_has_border); 136 void SetNormalHasBorder(bool normal_has_border);
136 // Sets whether or not to show the highlighed (i.e. hot) state. Default true. 137 // Sets whether or not to show the hot and pushed states in addition to the
137 void SetShowHighlighted(bool show_highlighted); 138 // normal state. Defaults to true.
139 void SetShowMultipleStates(bool show_multiple_states);
Ben Goodger (Google) 2010/07/27 21:20:09 I think this should be SetShowMultipleIconStates t
138 140
139 // Paint the button into the specified canvas. If |for_drag| is true, the 141 // Paint the button into the specified canvas. If |for_drag| is true, the
140 // function paints a drag image representation into the canvas. 142 // function paints a drag image representation into the canvas.
141 virtual void Paint(gfx::Canvas* canvas, bool for_drag); 143 virtual void Paint(gfx::Canvas* canvas, bool for_drag);
142 144
143 // Overridden from View: 145 // Overridden from View:
144 virtual gfx::Size GetPreferredSize(); 146 virtual gfx::Size GetPreferredSize();
145 virtual gfx::Size GetMinimumSize(); 147 virtual gfx::Size GetMinimumSize();
146 virtual void SetEnabled(bool enabled); 148 virtual void SetEnabled(bool enabled);
147 149
148 // Text colors. 150 // Text colors.
149 static const SkColor kEnabledColor; 151 static const SkColor kEnabledColor;
150 static const SkColor kHighlightColor; 152 static const SkColor kHighlightColor;
151 static const SkColor kDisabledColor; 153 static const SkColor kDisabledColor;
152 static const SkColor kHoverColor; 154 static const SkColor kHoverColor;
153 155
154 protected: 156 protected:
157 SkBitmap icon() const { return icon_; }
158
155 virtual void Paint(gfx::Canvas* canvas); 159 virtual void Paint(gfx::Canvas* canvas);
156 160
157 // Called when enabled or disabled state changes, or the colors for those 161 // Called when enabled or disabled state changes, or the colors for those
158 // states change. 162 // states change.
159 virtual void UpdateColor(); 163 virtual void UpdateColor();
160 164
161 private: 165 private:
162 // Updates text_size_ and max_text_size_ from the current text/font. This is 166 // Updates text_size_ and max_text_size_ from the current text/font. This is
163 // invoked when the font or text changes. 167 // invoked when the font or text changes.
164 void UpdateTextSize(); 168 void UpdateTextSize();
(...skipping 26 matching lines...) Expand all
191 SkColor color_highlight_; 195 SkColor color_highlight_;
192 SkColor color_hover_; 196 SkColor color_hover_;
193 197
194 // An icon displayed with the text. 198 // An icon displayed with the text.
195 SkBitmap icon_; 199 SkBitmap icon_;
196 200
197 // An optional different version of the icon for hover state. 201 // An optional different version of the icon for hover state.
198 SkBitmap icon_hover_; 202 SkBitmap icon_hover_;
199 bool has_hover_icon_; 203 bool has_hover_icon_;
200 204
205 // An optional different version of the icon for pushed state.
206 SkBitmap icon_pushed_;
207 bool has_pushed_icon_;
208
201 // The width of the button will never be larger than this value. A value <= 0 209 // The width of the button will never be larger than this value. A value <= 0
202 // indicates the width is not constrained. 210 // indicates the width is not constrained.
203 int max_width_; 211 int max_width_;
204 212
205 // This is true if normal state has a border frame; default is false. 213 // This is true if normal state has a border frame; default is false.
206 bool normal_has_border_; 214 bool normal_has_border_;
207 215
208 // Whether or not to show the highlighted (i.e. hot) state. 216 // Whether or not to show the hot and pushed states.
209 bool show_highlighted_; 217 bool show_multiple_states_;
210 218
211 PrefixType prefix_type_; 219 PrefixType prefix_type_;
212 220
213 DISALLOW_COPY_AND_ASSIGN(TextButton); 221 DISALLOW_COPY_AND_ASSIGN(TextButton);
214 }; 222 };
215 223
216 } // namespace views 224 } // namespace views
217 225
218 #endif // VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 226 #endif // VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/wrench_menu.cc ('k') | views/controls/button/text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698