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

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

Issue 11155002: views: Fix progress bar tooltip text function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix review comments Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/controls/progress_bar_unittest.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/progress_bar.h" 5 #include "ui/views/controls/progress_bar.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 23 matching lines...) Expand all
34 const SkColor kBackgroundColorStart = SkColorSetRGB(212, 212, 212); 34 const SkColor kBackgroundColorStart = SkColorSetRGB(212, 212, 212);
35 const SkColor kBackgroundColorEnd = SkColorSetRGB(252, 252, 252); 35 const SkColor kBackgroundColorEnd = SkColorSetRGB(252, 252, 252);
36 const SkColor kBorderColor = SkColorSetRGB(144, 144, 144); 36 const SkColor kBorderColor = SkColorSetRGB(144, 144, 144);
37 37
38 void AddRoundRectPathWithPadding(int x, int y, 38 void AddRoundRectPathWithPadding(int x, int y,
39 int w, int h, 39 int w, int h,
40 int corner_radius, 40 int corner_radius,
41 SkScalar padding, 41 SkScalar padding,
42 SkPath* path) { 42 SkPath* path) {
43 DCHECK(path); 43 DCHECK(path);
44 if (path == NULL)
45 return;
46 SkRect rect; 44 SkRect rect;
47 rect.set( 45 rect.set(
48 SkIntToScalar(x) + padding, SkIntToScalar(y) + padding, 46 SkIntToScalar(x) + padding, SkIntToScalar(y) + padding,
49 SkIntToScalar(x + w) - padding, SkIntToScalar(y + h) - padding); 47 SkIntToScalar(x + w) - padding, SkIntToScalar(y + h) - padding);
50 path->addRoundRect( 48 path->addRoundRect(
51 rect, 49 rect,
52 SkIntToScalar(corner_radius) - padding, 50 SkIntToScalar(corner_radius) - padding,
53 SkIntToScalar(corner_radius) - padding); 51 SkIntToScalar(corner_radius) - padding);
54 } 52 }
55 53
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 SchedulePaint(); 160 SchedulePaint();
163 } 161 }
164 } 162 }
165 163
166 void ProgressBar::SetTooltipText(const string16& tooltip_text) { 164 void ProgressBar::SetTooltipText(const string16& tooltip_text) {
167 tooltip_text_ = tooltip_text; 165 tooltip_text_ = tooltip_text;
168 } 166 }
169 167
170 bool ProgressBar::GetTooltipText(const gfx::Point& p, string16* tooltip) const { 168 bool ProgressBar::GetTooltipText(const gfx::Point& p, string16* tooltip) const {
171 DCHECK(tooltip); 169 DCHECK(tooltip);
172 if (tooltip == NULL) 170 *tooltip = tooltip_text_;
173 return false;
174 tooltip->assign(tooltip_text_);
175 return !tooltip_text_.empty(); 171 return !tooltip_text_.empty();
176 } 172 }
177 173
178 void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) { 174 void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) {
179 state->role = ui::AccessibilityTypes::ROLE_PROGRESSBAR; 175 state->role = ui::AccessibilityTypes::ROLE_PROGRESSBAR;
180 state->state = ui::AccessibilityTypes::STATE_READONLY; 176 state->state = ui::AccessibilityTypes::STATE_READONLY;
181 } 177 }
182 178
183 gfx::Size ProgressBar::GetPreferredSize() { 179 gfx::Size ProgressBar::GetPreferredSize() {
184 return gfx::Size(100, 16); 180 return gfx::Size(100, 16);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (progress_width > 1) { 291 if (progress_width > 1) {
296 FillRoundRect(canvas, 0, 0, progress_width, height(), kCornerRadius, 292 FillRoundRect(canvas, 0, 0, progress_width, height(), kCornerRadius,
297 kBarColorStart, kBarColorEnd, false); 293 kBarColorStart, kBarColorEnd, false);
298 } 294 }
299 StrokeRoundRect(canvas, 0, 0, width(), height(), kCornerRadius, 295 StrokeRoundRect(canvas, 0, 0, width(), height(), kCornerRadius,
300 kBorderColor, kBorderWidth); 296 kBorderColor, kBorderWidth);
301 #endif 297 #endif
302 } 298 }
303 299
304 } // namespace views 300 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/progress_bar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698