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

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

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/slider.h ('k') | ui/views/controls/styled_label.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) 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/slider.h" 5 #include "ui/views/controls/slider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 if (!focus_border_color_) { 178 if (!focus_border_color_) {
179 canvas->DrawFocusRect(GetLocalBounds()); 179 canvas->DrawFocusRect(GetLocalBounds());
180 } else if (HasFocus()) { 180 } else if (HasFocus()) {
181 canvas->DrawSolidFocusRect( 181 canvas->DrawSolidFocusRect(
182 gfx::Rect(1, 1, width() - 3, height() - 3), 182 gfx::Rect(1, 1, width() - 3, height() - 3),
183 focus_border_color_); 183 focus_border_color_);
184 } 184 }
185 } 185 }
186 186
187 gfx::Size Slider::GetPreferredSize() { 187 gfx::Size Slider::GetPreferredSize() const {
188 const int kSizeMajor = 200; 188 const int kSizeMajor = 200;
189 const int kSizeMinor = 40; 189 const int kSizeMinor = 40;
190 190
191 if (orientation_ == HORIZONTAL) 191 if (orientation_ == HORIZONTAL)
192 return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor); 192 return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor);
193 return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor)); 193 return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor));
194 } 194 }
195 195
196 void Slider::OnPaint(gfx::Canvas* canvas) { 196 void Slider::OnPaint(gfx::Canvas* canvas) {
197 gfx::Rect content = GetContentsBounds(); 197 gfx::Rect content = GetContentsBounds();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 335
336 void Slider::GetAccessibleState(ui::AXViewState* state) { 336 void Slider::GetAccessibleState(ui::AXViewState* state) {
337 state->role = ui::AX_ROLE_SLIDER; 337 state->role = ui::AX_ROLE_SLIDER;
338 state->name = accessible_name_; 338 state->name = accessible_name_;
339 state->value = base::UTF8ToUTF16( 339 state->value = base::UTF8ToUTF16(
340 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); 340 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5)));
341 } 341 }
342 342
343 } // namespace views 343 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/slider.h ('k') | ui/views/controls/styled_label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698