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

Side by Side Diff: views/controls/label.cc

Issue 6976048: views: Add OnEnabledChanged() method to View class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DisableOnHover test? Created 9 years, 6 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 | « views/controls/label.h ('k') | views/controls/link.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/label.h" 5 #include "views/controls/label.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (!is_multi_line_) 199 if (!is_multi_line_)
200 return View::GetHeightForWidth(w); 200 return View::GetHeightForWidth(w);
201 201
202 w = std::max(0, w - GetInsets().width()); 202 w = std::max(0, w - GetInsets().width());
203 int h = font_.GetHeight(); 203 int h = font_.GetHeight();
204 gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h, 204 gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h,
205 ComputeMultiLineFlags()); 205 ComputeMultiLineFlags());
206 return h + GetInsets().height(); 206 return h + GetInsets().height();
207 } 207 }
208 208
209 void Label::SetEnabled(bool enabled) { 209 void Label::OnEnabledChanged() {
210 if (enabled == enabled_) 210 View::OnEnabledChanged();
211 return; 211 SetColor(IsEnabled() ? kEnabledColor : kDisabledColor);
212 View::SetEnabled(enabled);
213 SetColor(enabled ? kEnabledColor : kDisabledColor);
214 } 212 }
215 213
216 std::string Label::GetClassName() const { 214 std::string Label::GetClassName() const {
217 return kViewClassName; 215 return kViewClassName;
218 } 216 }
219 217
220 void Label::OnMouseMoved(const MouseEvent& event) { 218 void Label::OnMouseMoved(const MouseEvent& event) {
221 UpdateContainsMouse(event); 219 UpdateContainsMouse(event);
222 } 220 }
223 221
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 font_, GetAvailableRect().width(), true)); 452 font_, GetAvailableRect().width(), true));
455 } else { 453 } else {
456 *paint_text = UTF16ToWideHack(text_); 454 *paint_text = UTF16ToWideHack(text_);
457 } 455 }
458 456
459 *text_bounds = GetTextBounds(); 457 *text_bounds = GetTextBounds();
460 *flags = ComputeMultiLineFlags(); 458 *flags = ComputeMultiLineFlags();
461 } 459 }
462 460
463 } // namespace views 461 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/label.h ('k') | views/controls/link.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698