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

Side by Side Diff: ui/views/controls/link.cc

Issue 2389453002: Remove IsModeMaterial checks in ui/views/ (Closed)
Patch Set: oops Created 4 years, 2 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 | « ui/views/controls/link.h ('k') | ui/views/controls/menu/menu_item_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/views/controls/link.h" 5 #include "ui/views/controls/link.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace views { 24 namespace views {
25 25
26 const char Link::kViewClassName[] = "Link"; 26 const char Link::kViewClassName[] = "Link";
27 27
28 Link::Link() : Link(base::string16()) {} 28 Link::Link() : Link(base::string16()) {}
29 29
30 Link::Link(const base::string16& title) 30 Link::Link(const base::string16& title)
31 : Label(title), 31 : Label(title),
32 requested_enabled_color_(gfx::kPlaceholderColor), 32 requested_enabled_color_(gfx::kPlaceholderColor),
33 requested_enabled_color_set_(false), 33 requested_enabled_color_set_(false) {
34 requested_pressed_color_(gfx::kPlaceholderColor),
35 requested_pressed_color_set_(false) {
36 Init(); 34 Init();
37 } 35 }
38 36
39 Link::~Link() { 37 Link::~Link() {
40 } 38 }
41 39
42 const char* Link::GetClassName() const { 40 const char* Link::GetClassName() const {
43 return kViewClassName; 41 return kViewClassName;
44 } 42 }
45 43
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 SetDisabledColor( 167 SetDisabledColor(
170 theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled)); 168 theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled));
171 } 169 }
172 170
173 void Link::SetEnabledColor(SkColor color) { 171 void Link::SetEnabledColor(SkColor color) {
174 requested_enabled_color_set_ = true; 172 requested_enabled_color_set_ = true;
175 requested_enabled_color_ = color; 173 requested_enabled_color_ = color;
176 Label::SetEnabledColor(GetEnabledColor()); 174 Label::SetEnabledColor(GetEnabledColor());
177 } 175 }
178 176
179 void Link::SetPressedColor(SkColor color) {
180 requested_pressed_color_set_ = true;
181 requested_pressed_color_ = color;
182 Label::SetEnabledColor(GetEnabledColor());
183 }
184
185 void Link::SetUnderline(bool underline) { 177 void Link::SetUnderline(bool underline) {
186 if (underline_ == underline) 178 if (underline_ == underline)
187 return; 179 return;
188 underline_ = underline; 180 underline_ = underline;
189 RecalculateFont(); 181 RecalculateFont();
190 } 182 }
191 183
192 void Link::Init() { 184 void Link::Init() {
193 listener_ = NULL; 185 listener_ = NULL;
194 pressed_ = false; 186 pressed_ = false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } else { 226 } else {
235 #if defined(OS_MACOSX) 227 #if defined(OS_MACOSX)
236 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 228 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
237 #else 229 #else
238 SetFocusBehavior(FocusBehavior::ALWAYS); 230 SetFocusBehavior(FocusBehavior::ALWAYS);
239 #endif 231 #endif
240 } 232 }
241 } 233 }
242 234
243 SkColor Link::GetEnabledColor() { 235 SkColor Link::GetEnabledColor() {
244 // In material mode, there is no pressed effect, so always use the unpressed 236 if (requested_enabled_color_set_)
Evan Stade 2016/09/30 22:57:38 here is a behavior change. The default NativeThem
245 // color. 237 return requested_enabled_color_;
246 if (!pressed_ || ui::MaterialDesignController::IsModeMaterial()) {
247 if (!requested_enabled_color_set_ && GetNativeTheme())
248 return GetNativeTheme()->GetSystemColor(
249 ui::NativeTheme::kColorId_LinkEnabled);
250 238
251 return requested_enabled_color_; 239 if (GetNativeTheme()) {
240 return GetNativeTheme()->GetSystemColor(
241 pressed_ ? ui::NativeTheme::kColorId_LinkPressed
242 : ui::NativeTheme::kColorId_LinkEnabled);
252 } 243 }
253 244
254 if (!requested_pressed_color_set_ && GetNativeTheme()) 245 return gfx::kPlaceholderColor;
255 return GetNativeTheme()->GetSystemColor(
256 ui::NativeTheme::kColorId_LinkPressed);
257
258 return requested_pressed_color_;
259 } 246 }
260 247
261 } // namespace views 248 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/link.h ('k') | ui/views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698