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

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

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: rebase Created 4 years 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/slider.h ('k') | ui/views/painter.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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "third_party/skia/include/core/SkPaint.h" 15 #include "third_party/skia/include/core/SkPaint.h"
16 #include "ui/accessibility/ax_node_data.h" 16 #include "ui/accessibility/ax_node_data.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/events/event.h" 18 #include "ui/events/event.h"
19 #include "ui/gfx/animation/slide_animation.h" 19 #include "ui/gfx/animation/slide_animation.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/point.h"
22 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
23 #include "ui/native_theme/native_theme.h"
23 #include "ui/resources/grit/ui_resources.h" 24 #include "ui/resources/grit/ui_resources.h"
24 #include "ui/views/controls/md_slider.h" 25 #include "ui/views/controls/md_slider.h"
25 #include "ui/views/controls/non_md_slider.h" 26 #include "ui/views/controls/non_md_slider.h"
26 #include "ui/views/resources/grit/views_resources.h" 27 #include "ui/views/resources/grit/views_resources.h"
27 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
28 29
29 namespace { 30 namespace {
30 const int kSlideValueChangeDurationMs = 150; 31 const int kSlideValueChangeDurationMs = 150;
31 32
32 // The image chunks. 33 // The image chunks.
(...skipping 29 matching lines...) Expand all
62 accessible_name_ = name; 63 accessible_name_ = name;
63 } 64 }
64 65
65 Slider::Slider(SliderListener* listener) 66 Slider::Slider(SliderListener* listener)
66 : listener_(listener), 67 : listener_(listener),
67 value_(0.f), 68 value_(0.f),
68 keyboard_increment_(0.1f), 69 keyboard_increment_(0.1f),
69 initial_animating_value_(0.f), 70 initial_animating_value_(0.f),
70 value_is_valid_(false), 71 value_is_valid_(false),
71 accessibility_events_enabled_(true), 72 accessibility_events_enabled_(true),
72 focus_border_color_(0),
73 initial_button_offset_(0) { 73 initial_button_offset_(0) {
74 EnableCanvasFlippingForRTLUI(true); 74 EnableCanvasFlippingForRTLUI(true);
75 #if defined(OS_MACOSX) 75 #if defined(OS_MACOSX)
76 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 76 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
77 #else 77 #else
78 SetFocusBehavior(FocusBehavior::ALWAYS); 78 SetFocusBehavior(FocusBehavior::ALWAYS);
79 #endif 79 #endif
80 } 80 }
81 81
82 float Slider::GetAnimatingValue() const{ 82 float Slider::GetAnimatingValue() const{
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 : point.x() - inset.left() - initial_button_offset_; 160 : point.x() - inset.left() - initial_button_offset_;
161 SetValueInternal( 161 SetValueInternal(
162 static_cast<float>(amount) / (width() - inset.width() - thumb_width), 162 static_cast<float>(amount) / (width() - inset.width() - thumb_width),
163 VALUE_CHANGED_BY_USER); 163 VALUE_CHANGED_BY_USER);
164 } 164 }
165 165
166 void Slider::OnPaintFocus(gfx::Canvas* canvas) { 166 void Slider::OnPaintFocus(gfx::Canvas* canvas) {
167 if (!HasFocus()) 167 if (!HasFocus())
168 return; 168 return;
169 169
170 if (!focus_border_color_) { 170 // TODO(estade): make this a glow effect instead: crbug.com/658783
171 canvas->DrawFocusRect(GetLocalBounds()); 171 gfx::Rect focus_bounds = GetLocalBounds();
172 } else if (HasFocus()) { 172 focus_bounds.Inset(gfx::Insets(1));
173 canvas->DrawSolidFocusRect( 173 canvas->DrawSolidFocusRect(
174 gfx::Rect(1, 1, width() - 3, height() - 3), 174 gfx::RectF(focus_bounds),
175 focus_border_color_); 175 SkColorSetA(GetNativeTheme()->GetSystemColor(
176 } 176 ui::NativeTheme::kColorId_FocusedBorderColor),
177 0x99),
178 2.f);
177 } 179 }
178 180
179 void Slider::OnSliderDragStarted() { 181 void Slider::OnSliderDragStarted() {
180 SetHighlighted(true); 182 SetHighlighted(true);
181 if (listener_) 183 if (listener_)
182 listener_->SliderDragStarted(this); 184 listener_->SliderDragStarted(this);
183 } 185 }
184 186
185 void Slider::OnSliderDragEnded() { 187 void Slider::OnSliderDragEnded() {
186 SetHighlighted(false); 188 SetHighlighted(false);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 event->SetHandled(); 266 event->SetHandled();
265 if (event->details().touch_points() <= 1) 267 if (event->details().touch_points() <= 1)
266 OnSliderDragEnded(); 268 OnSliderDragEnded();
267 break; 269 break;
268 default: 270 default:
269 break; 271 break;
270 } 272 }
271 } 273 }
272 274
273 } // namespace views 275 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/slider.h ('k') | ui/views/painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698