| 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_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void UpdateBounds() { | 173 void UpdateBounds() { |
| 174 gfx::Rect bounds = base_bounds_; | 174 gfx::Rect bounds = base_bounds_; |
| 175 if (show_attention_) { | 175 if (show_attention_) { |
| 176 // Scale from .35 to 1.0 of the total width (which is wider than the | 176 // Scale from .35 to 1.0 of the total width (which is wider than the |
| 177 // visible width of the image), so the animation "rests" briefly at full | 177 // visible width of the image), so the animation "rests" briefly at full |
| 178 // visible width. Cap bounds length at kIconSize to prevent visual | 178 // visible width. Cap bounds length at kIconSize to prevent visual |
| 179 // flutter while centering bar within further expanding bounds. | 179 // flutter while centering bar within further expanding bounds. |
| 180 double animation = animating_ ? | 180 double animation = animating_ ? |
| 181 ShelfButtonAnimation::GetInstance()->GetAnimation() : 1.0; | 181 ShelfButtonAnimation::GetInstance()->GetAnimation() : 1.0; |
| 182 double scale = .35 + .65 * animation; | 182 double scale = .35 + .65 * animation; |
| 183 if (shelf_->alignment() == SHELF_ALIGNMENT_BOTTOM) { | 183 if (shelf_->IsHorizontalAlignment()) { |
| 184 int width = base_bounds_.width() * scale; | 184 int width = base_bounds_.width() * scale; |
| 185 bounds.set_width(std::min(width, kIconSize)); | 185 bounds.set_width(std::min(width, kIconSize)); |
| 186 int x_offset = (base_bounds_.width() - bounds.width()) / 2; | 186 int x_offset = (base_bounds_.width() - bounds.width()) / 2; |
| 187 bounds.set_x(base_bounds_.x() + x_offset); | 187 bounds.set_x(base_bounds_.x() + x_offset); |
| 188 UpdateAnimating(bounds.width() == kIconSize); | 188 UpdateAnimating(bounds.width() == kIconSize); |
| 189 } else { | 189 } else { |
| 190 int height = base_bounds_.height() * scale; | 190 int height = base_bounds_.height() * scale; |
| 191 bounds.set_height(std::min(height, kIconSize)); | 191 bounds.set_height(std::min(height, kIconSize)); |
| 192 int y_offset = (base_bounds_.height() - bounds.height()) / 2; | 192 int y_offset = (base_bounds_.height() - bounds.height()) / 2; |
| 193 bounds.set_y(base_bounds_.y() + y_offset); | 193 bounds.set_y(base_bounds_.y() + y_offset); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 478 |
| 479 int bar_id = 0; | 479 int bar_id = 0; |
| 480 if (state_ & (STATE_ACTIVE)) | 480 if (state_ & (STATE_ACTIVE)) |
| 481 bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; | 481 bar_id = IDR_ASH_SHELF_UNDERLINE_ACTIVE; |
| 482 else if (state_ & STATE_ATTENTION) | 482 else if (state_ & STATE_ATTENTION) |
| 483 bar_id = IDR_ASH_SHELF_UNDERLINE_ATTENTION; | 483 bar_id = IDR_ASH_SHELF_UNDERLINE_ATTENTION; |
| 484 else if (state_ & STATE_RUNNING) | 484 else if (state_ & STATE_RUNNING) |
| 485 bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; | 485 bar_id = IDR_ASH_SHELF_UNDERLINE_RUNNING; |
| 486 | 486 |
| 487 if (bar_id != 0) { | 487 if (bar_id != 0) { |
| 488 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 489 const gfx::ImageSkia* image = rb.GetImageNamed(bar_id).ToImageSkia(); | |
| 490 | |
| 491 Shelf* shelf = shelf_view_->shelf(); | 488 Shelf* shelf = shelf_view_->shelf(); |
| 492 if (shelf->alignment() == SHELF_ALIGNMENT_BOTTOM) { | 489 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); |
| 493 bar_->SetImage(*image); | 490 gfx::ImageSkia image = *rb->GetImageNamed(bar_id).ToImageSkia(); |
| 494 } else { | 491 if (!shelf->IsHorizontalAlignment()) { |
| 495 bar_->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage( | 492 image = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 496 *image, shelf->SelectValueForShelfAlignment( | 493 image, shelf->alignment() == SHELF_ALIGNMENT_LEFT |
| 497 SkBitmapOperations::ROTATION_90_CW, | 494 ? SkBitmapOperations::ROTATION_90_CW |
| 498 SkBitmapOperations::ROTATION_90_CW, | 495 : SkBitmapOperations::ROTATION_270_CW); |
| 499 SkBitmapOperations::ROTATION_270_CW))); | |
| 500 } | 496 } |
| 497 bar_->SetImage(image); |
| 501 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( | 498 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( |
| 502 views::ImageView::CENTER, views::ImageView::LEADING, | 499 views::ImageView::CENTER, views::ImageView::LEADING, |
| 503 views::ImageView::TRAILING)); | 500 views::ImageView::TRAILING)); |
| 504 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( | 501 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( |
| 505 views::ImageView::TRAILING, views::ImageView::CENTER, | 502 views::ImageView::TRAILING, views::ImageView::CENTER, |
| 506 views::ImageView::CENTER)); | 503 views::ImageView::CENTER)); |
| 507 bar_->SchedulePaint(); | 504 bar_->SchedulePaint(); |
| 508 } | 505 } |
| 509 | 506 |
| 510 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); | 507 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); |
| 511 } | 508 } |
| 512 | 509 |
| 513 } // namespace ash | 510 } // namespace ash |
| OLD | NEW |