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

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

Issue 1214693005: Introduce some util code for drawing vector assets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile? Created 5 years, 5 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/throbber.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/throbber.cc
diff --git a/ui/views/controls/throbber.cc b/ui/views/controls/throbber.cc
index 9ecdbd7303236fe9870900ce12a67147ba30c205..759bf5294f886b0a6b1d9e48198fb842563da678 100644
--- a/ui/views/controls/throbber.cc
+++ b/ui/views/controls/throbber.cc
@@ -10,6 +10,7 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/paint_throbber.h"
+#include "ui/gfx/vector_icons.h"
#include "ui/native_theme/common_theme.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
@@ -17,7 +18,14 @@
namespace views {
-Throbber::Throbber() : checked_(false), checkmark_(nullptr) {
+// The default diameter of a Throbber. If you change this, also change
+// kCheckmarkDipSize.
+static const int kDefaultDiameter = 16;
+// The size of the checkmark, in DIP. This magic number matches the default
+// diamater plus padding inherent in the checkmark SVG.
+static const int kCheckmarkDipSize = 18;
+
+Throbber::Throbber() : checked_(false) {
}
Throbber::~Throbber() {
@@ -52,28 +60,23 @@ void Throbber::SetChecked(bool checked) {
}
gfx::Size Throbber::GetPreferredSize() const {
- const int kDefaultDiameter = 16;
return gfx::Size(kDefaultDiameter, kDefaultDiameter);
}
void Throbber::OnPaint(gfx::Canvas* canvas) {
+ SkColor color = GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_ThrobberSpinningColor);
+
if (!IsRunning()) {
if (checked_) {
- if (!checkmark_) {
- checkmark_ = ui::ResourceBundle::GetSharedInstance()
- .GetImageNamed(IDR_CHECKMARK)
- .ToImageSkia();
- }
-
- int checkmark_x = (width() - checkmark_->width()) / 2;
- int checkmark_y = (height() - checkmark_->height()) / 2;
- canvas->DrawImageInt(*checkmark_, checkmark_x, checkmark_y);
+ canvas->Translate(gfx::Vector2d((width() - kCheckmarkDipSize) / 2,
+ (height() - kCheckmarkDipSize) / 2));
+ gfx::PaintVectorIcon(canvas, gfx::VectorIconId::CHECK_CIRCLE,
+ kCheckmarkDipSize, color);
}
return;
}
- SkColor color = GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_ThrobberSpinningColor);
base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_;
gfx::PaintThrobberSpinning(canvas, GetContentsBounds(), color, elapsed_time);
}
« no previous file with comments | « ui/views/controls/throbber.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698