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); |
} |