Index: ash/shelf/shelf_button.cc |
diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc |
index faf0b4e8c98b5f44a8e8942969528bf88b9bc5b2..69defc150f2638325a732b7548648e98ebffeddd 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,13 @@ 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; |
+ |
+// Canvas scale to ensures that the activity indicator is not pixelated even at |
varkha
2016/05/10 21:04:11
nit: s/ensures/ensure
yiyix
2016/05/13 22:24:11
Done.
|
+// the highest possible device scale factors. |
+const int kIndicatorCanvasScale = 5; |
// Simple AnimationDelegate that owns a single ThrobAnimation instance to |
// keep all Draw Attention animations in sync. |
@@ -486,8 +496,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::IsMaterial()) { |
+ 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,8 +521,18 @@ void ShelfButton::UpdateBar() { |
views::ImageView::CENTER)); |
bar_->SchedulePaint(); |
} |
- |
bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); |
} |
+void ShelfButton::PaintIndicatorOnCanvas(gfx::Canvas* canvas, |
sky
2016/05/12 15:27:03
Make this a non-member function (see Effective C++
yiyix
2016/05/13 22:24:11
Done.
|
+ 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 |