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

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: resolve compilation errors 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
« no previous file with comments | « ash/material_design/material_design_controller.cc ('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..70adc8c43270de7649fe2051108f8bbfd8d961f2 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,24 @@ 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 SkColor kIndicatorColor = SK_ColorWHITE;
+
+// Canvas scale to ensure that the activity indicator is not pixelated even at
+// the highest possible device scale factors.
+const int kIndicatorCanvasScale = 5;
+
+// Paints an activity indicator on |canvas| whose |size| is specified in DIP.
+void 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);
+}
// Simple AnimationDelegate that owns a single ThrobAnimation instance to
// keep all Draw Attention animations in sync.
@@ -486,8 +507,16 @@ 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::IsShelfMaterial()) {
+ gfx::Size size(kShelfButtonSize, kShelfSize);
+ gfx::Canvas canvas(size, kIndicatorCanvasScale, 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,7 +532,6 @@ void ShelfButton::UpdateBar() {
views::ImageView::CENTER));
bar_->SchedulePaint();
}
-
bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL);
}
« no previous file with comments | « ash/material_design/material_design_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698