| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shelf/shelf_button.h" | 5 #include "ash/shelf/shelf_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; | 502 bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; |
| 503 else if (state_ & STATE_ATTENTION) | 503 else if (state_ & STATE_ATTENTION) |
| 504 bar_id = IDR_ASH_SHELF_UNDERLINE_ATTENTION; | 504 bar_id = IDR_ASH_SHELF_UNDERLINE_ATTENTION; |
| 505 else if (state_ & STATE_RUNNING) | 505 else if (state_ & STATE_RUNNING) |
| 506 bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; | 506 bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; |
| 507 | 507 |
| 508 if (bar_id != 0) { | 508 if (bar_id != 0) { |
| 509 Shelf* shelf = shelf_view_->shelf(); | 509 Shelf* shelf = shelf_view_->shelf(); |
| 510 gfx::ImageSkia image; | 510 gfx::ImageSkia image; |
| 511 if (ash::MaterialDesignController::IsShelfMaterial()) { | 511 if (ash::MaterialDesignController::IsShelfMaterial()) { |
| 512 gfx::Size size(kShelfButtonSize, kShelfSize); | 512 gfx::Size size(GetShelfConstant(SHELF_BUTTON_SIZE), |
| 513 GetShelfConstant(SHELF_SIZE)); |
| 513 gfx::Canvas canvas(size, kIndicatorCanvasScale, true /* is_opaque */); | 514 gfx::Canvas canvas(size, kIndicatorCanvasScale, true /* is_opaque */); |
| 514 PaintIndicatorOnCanvas(&canvas, size); | 515 PaintIndicatorOnCanvas(&canvas, size); |
| 515 image = gfx::ImageSkia(canvas.ExtractImageRep()); | 516 image = gfx::ImageSkia(canvas.ExtractImageRep()); |
| 516 } else { | 517 } else { |
| 517 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); | 518 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); |
| 518 image = *rb->GetImageNamed(bar_id).ToImageSkia(); | 519 image = *rb->GetImageNamed(bar_id).ToImageSkia(); |
| 519 } | 520 } |
| 520 if (!shelf->IsHorizontalAlignment()) { | 521 if (!shelf->IsHorizontalAlignment()) { |
| 521 image = gfx::ImageSkiaOperations::CreateRotatedImage( | 522 image = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 522 image, shelf->alignment() == SHELF_ALIGNMENT_LEFT | 523 image, shelf->alignment() == SHELF_ALIGNMENT_LEFT |
| 523 ? SkBitmapOperations::ROTATION_90_CW | 524 ? SkBitmapOperations::ROTATION_90_CW |
| 524 : SkBitmapOperations::ROTATION_270_CW); | 525 : SkBitmapOperations::ROTATION_270_CW); |
| 525 } | 526 } |
| 526 bar_->SetImage(image); | 527 bar_->SetImage(image); |
| 527 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( | 528 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( |
| 528 views::ImageView::CENTER, views::ImageView::LEADING, | 529 views::ImageView::CENTER, views::ImageView::LEADING, |
| 529 views::ImageView::TRAILING)); | 530 views::ImageView::TRAILING)); |
| 530 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( | 531 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( |
| 531 views::ImageView::TRAILING, views::ImageView::CENTER, | 532 views::ImageView::TRAILING, views::ImageView::CENTER, |
| 532 views::ImageView::CENTER)); | 533 views::ImageView::CENTER)); |
| 533 bar_->SchedulePaint(); | 534 bar_->SchedulePaint(); |
| 534 } | 535 } |
| 535 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); | 536 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); |
| 536 } | 537 } |
| 537 | 538 |
| 538 } // namespace ash | 539 } // namespace ash |
| OLD | NEW |