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

Unified Diff: ash/shelf/shelf_button.cc

Issue 1932433002: Update activity indicator from a light bar to a point (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add antialias flag to draw circle Created 4 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 side-by-side diff with in-line comments
Download patch
« ash/shelf/shelf_button.h ('K') | « ash/shelf/shelf_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_button.cc
diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc
index faf0b4e8c98b5f44a8e8942969528bf88b9bc5b2..f8dcef65320931047bf2a257837a6f62c9ca90f8 100644
--- a/ash/shelf/shelf_button.cc
+++ b/ash/shelf/shelf_button.cc
@@ -8,11 +8,14 @@
#include "ash/ash_constants.h"
#include "ash/ash_switches.h"
+#include "ash/material_design/material_design_controller.h"
#include "ash/shelf/shelf.h"
+#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_view.h"
#include "base/time/time.h"
#include "grit/ash_resources.h"
#include "skia/ext/image_operations.h"
+#include "third_party/skia/include/core/SkPaint.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/layer.h"
@@ -37,6 +40,9 @@ const int kIconPad = 5;
const int kIconPadVertical = 6;
const int kAttentionThrobDurationMS = 800;
const int kMaxAnimationSeconds = 10;
+const int kIndicatorOffsetFromBottom = 2;
+const int kIndicatorRadius = 2;
+const int kIndicatorColor = SK_ColorWHITE;
// Simple AnimationDelegate that owns a single ThrobAnimation instance to
// keep all Draw Attention animations in sync.
@@ -486,8 +492,19 @@ void ShelfButton::UpdateBar() {
if (bar_id != 0) {
Shelf* shelf = shelf_view_->shelf();
- ResourceBundle* rb = &ResourceBundle::GetSharedInstance();
- gfx::ImageSkia image = *rb->GetImageNamed(bar_id).ToImageSkia();
+ gfx::ImageSkia image;
+ if (ash::MaterialDesignController::IsMaterial()) {
+ gfx::Size size = gfx::Size(kShelfButtonSize, kShelfSize);
varkha 2016/05/05 14:40:56 nit: Simpler: gfx::Size size(kShelfButtonSize, kSh
yiyix 2016/05/10 19:30:00 Done.
+ // Chrome os is most common to run with 100% or 200% scale as default
varkha 2016/05/05 14:40:56 nit: s/Chrome os/Chrome OS
yiyix 2016/05/10 19:30:00 Done.
+ // setting, and users can zoom in to 200%. So image scale needs to be at
+ // least 4.
varkha 2016/05/05 14:40:56 I suggest moving the scale to be a constant in ano
yiyix 2016/05/10 19:30:00 I like your comment much more. It explains the pur
+ gfx::Canvas canvas(size, 5 /* image scale*/, true /* is_opaque */);
+ PaintIndicatorOnCanvas(&canvas, size);
+ image = gfx::ImageSkia(canvas.ExtractImageRep());
+ } else {
+ ResourceBundle* rb = &ResourceBundle::GetSharedInstance();
+ image = *rb->GetImageNamed(bar_id).ToImageSkia();
+ }
if (!shelf->IsHorizontalAlignment()) {
image = gfx::ImageSkiaOperations::CreateRotatedImage(
image, shelf->alignment() == wm::SHELF_ALIGNMENT_LEFT
@@ -503,8 +520,18 @@ void ShelfButton::UpdateBar() {
views::ImageView::CENTER));
bar_->SchedulePaint();
}
-
bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL);
}
+void ShelfButton::PaintIndicatorOnCanvas(gfx::Canvas* canvas,
+ const gfx::Size& size) {
+ SkPaint paint;
+ paint.setColor(kIndicatorColor);
+ paint.setFlags(SkPaint::kAntiAlias_Flag);
+ canvas->DrawCircle(
+ gfx::Point(size.width() / 2,
+ size.height() - kIndicatorOffsetFromBottom - kIndicatorRadius),
+ kIndicatorRadius, paint);
+}
+
} // namespace ash
« ash/shelf/shelf_button.h ('K') | « ash/shelf/shelf_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698