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

Unified Diff: ui/views/controls/md_slider.cc

Issue 2692043009: Remove last MD reference from TrayPopupUtils. (Closed)
Patch Set: rebase Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/md_slider.h ('k') | ui/views/controls/non_md_slider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/md_slider.cc
diff --git a/ui/views/controls/md_slider.cc b/ui/views/controls/md_slider.cc
deleted file mode 100644
index 64bed2fac3d083e1bff9778592433134fa340550..0000000000000000000000000000000000000000
--- a/ui/views/controls/md_slider.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/controls/md_slider.h"
-
-#include "cc/paint/paint_flags.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkPaint.h"
-#include "ui/gfx/animation/slide_animation.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/views/controls/slider.h"
-
-namespace views {
-
-// Color of slider at the active and the disabled state, respectively.
-const SkColor kActiveColor = SkColorSetARGB(0xFF, 0x42, 0x85, 0xF4);
-const SkColor kDisabledColor = SkColorSetARGB(0xFF, 0xBD, 0xBD, 0xBD);
-const uint8_t kHighlightColorAlpha = 0x4D;
-
-// The thickness of the slider.
-const int kLineThickness = 2;
-
-// The radius used to draw rounded slider ends.
-const float kSliderRoundedRadius = 2.f;
-
-// The radius of the thumb and the highlighted thumb of the slider,
-// respectively.
-const float kThumbRadius = 6.f;
-const float kThumbHighlightRadius = 10.f;
-
-// The stroke of the thumb when the slider is disabled.
-const int kThumbStroke = 2;
-
-// Duration of the thumb highlight growing effect animation.
-const int kSlideHighlightChangeDurationMs = 150;
-
-MdSlider::MdSlider(SliderListener* listener)
- : Slider(listener), is_active_(true), thumb_highlight_radius_(0.f) {
- SchedulePaint();
-}
-
-MdSlider::~MdSlider() {}
-
-void MdSlider::OnPaint(gfx::Canvas* canvas) {
- Slider::OnPaint(canvas);
-
- // Paint the slider.
- const gfx::Rect content = GetContentsBounds();
- const int width = content.width() - kThumbRadius * 2;
- const int full = GetAnimatingValue() * width;
- const int empty = width - full;
- const int y = content.height() / 2 - kLineThickness / 2;
- const int x = content.x() + full + kThumbRadius;
- const SkColor current_thumb_color =
- is_active_ ? kActiveColor : kDisabledColor;
-
- // Extra space used to hide slider ends behind the thumb.
- const int extra_padding = 1;
-
- cc::PaintFlags slider_flags;
- slider_flags.setAntiAlias(true);
- slider_flags.setColor(current_thumb_color);
- canvas->DrawRoundRect(
- gfx::Rect(content.x(), y, full + extra_padding, kLineThickness),
- kSliderRoundedRadius, slider_flags);
- slider_flags.setColor(kDisabledColor);
- canvas->DrawRoundRect(gfx::Rect(x + kThumbRadius - extra_padding, y,
- empty + extra_padding, kLineThickness),
- kSliderRoundedRadius, slider_flags);
-
- gfx::Point thumb_center(x, content.height() / 2);
-
- // Paint the thumb highlight if it exists.
- const int thumb_highlight_radius =
- HasFocus() ? kThumbHighlightRadius : thumb_highlight_radius_;
- if (is_active_ && thumb_highlight_radius > kThumbRadius) {
- cc::PaintFlags highlight;
- SkColor kHighlightColor = SkColorSetA(kActiveColor, kHighlightColorAlpha);
- highlight.setColor(kHighlightColor);
- highlight.setFlags(cc::PaintFlags::kAntiAlias_Flag);
- canvas->DrawCircle(thumb_center, thumb_highlight_radius, highlight);
- }
-
- // Paint the thumb of the slider.
- cc::PaintFlags flags;
- flags.setColor(current_thumb_color);
- flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
-
- if (!is_active_) {
- flags.setStrokeWidth(kThumbStroke);
- flags.setStyle(cc::PaintFlags::kStroke_Style);
- }
- canvas->DrawCircle(
- thumb_center,
- is_active_ ? kThumbRadius : (kThumbRadius - kThumbStroke / 2), flags);
-}
-
-const char* MdSlider::GetClassName() const {
- return "MdSlider";
-}
-
-void MdSlider::UpdateState(bool control_on) {
- is_active_ = control_on;
- SchedulePaint();
-}
-
-int MdSlider::GetThumbWidth() {
- return kThumbRadius * 2;
-}
-
-void MdSlider::SetHighlighted(bool is_highlighted) {
- if (!highlight_animation_) {
- if (!is_highlighted)
- return;
-
- highlight_animation_.reset(new gfx::SlideAnimation(this));
- highlight_animation_->SetSlideDuration(kSlideHighlightChangeDurationMs);
- }
- if (is_highlighted)
- highlight_animation_->Show();
- else
- highlight_animation_->Hide();
-}
-
-void MdSlider::AnimationProgressed(const gfx::Animation* animation) {
- if (animation != highlight_animation_.get()) {
- Slider::AnimationProgressed(animation);
- return;
- }
- thumb_highlight_radius_ =
- animation->CurrentValueBetween(kThumbRadius, kThumbHighlightRadius);
- SchedulePaint();
-}
-
-void MdSlider::AnimationEnded(const gfx::Animation* animation) {
- if (animation != highlight_animation_.get()) {
- Slider::AnimationEnded(animation);
- return;
- }
- if (animation == highlight_animation_.get() &&
- !highlight_animation_->IsShowing()) {
- highlight_animation_.reset();
- }
-}
-
-} // namespace views
« no previous file with comments | « ui/views/controls/md_slider.h ('k') | ui/views/controls/non_md_slider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698