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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Shelf* shelf = shelf_view_->shelf(); | 367 Shelf* shelf = shelf_view_->shelf(); |
368 int icon_pad = shelf->PrimaryAxisValue(kIconPad, kIconPadVertical); | 368 int icon_pad = shelf->PrimaryAxisValue(kIconPad, kIconPadVertical); |
369 int x_offset = shelf->PrimaryAxisValue(0, icon_pad); | 369 int x_offset = shelf->PrimaryAxisValue(0, icon_pad); |
370 int y_offset = shelf->PrimaryAxisValue(icon_pad, 0); | 370 int y_offset = shelf->PrimaryAxisValue(icon_pad, 0); |
371 | 371 |
372 int icon_width = std::min(kIconSize, button_bounds.width() - x_offset); | 372 int icon_width = std::min(kIconSize, button_bounds.width() - x_offset); |
373 int icon_height = std::min(kIconSize, button_bounds.height() - y_offset); | 373 int icon_height = std::min(kIconSize, button_bounds.height() - y_offset); |
374 | 374 |
375 // If on the left or top 'invert' the inset so the constant gap is on | 375 // If on the left or top 'invert' the inset so the constant gap is on |
376 // the interior (towards the center of display) edge of the shelf. | 376 // the interior (towards the center of display) edge of the shelf. |
377 if (SHELF_ALIGNMENT_LEFT == shelf->alignment()) | 377 if (wm::SHELF_ALIGNMENT_LEFT == shelf->alignment()) |
378 x_offset = button_bounds.width() - (kIconSize + icon_pad); | 378 x_offset = button_bounds.width() - (kIconSize + icon_pad); |
379 | 379 |
380 // Center icon with respect to the secondary axis, and ensure | 380 // Center icon with respect to the secondary axis, and ensure |
381 // that the icon doesn't occlude the bar highlight. | 381 // that the icon doesn't occlude the bar highlight. |
382 if (shelf->IsHorizontalAlignment()) { | 382 if (shelf->IsHorizontalAlignment()) { |
383 x_offset = std::max(0, button_bounds.width() - icon_width) / 2; | 383 x_offset = std::max(0, button_bounds.width() - icon_width) / 2; |
384 if (y_offset + icon_height + kBarSize > button_bounds.height()) | 384 if (y_offset + icon_height + kBarSize > button_bounds.height()) |
385 icon_height = button_bounds.height() - (y_offset + kBarSize); | 385 icon_height = button_bounds.height() - (y_offset + kBarSize); |
386 } else { | 386 } else { |
387 y_offset = std::max(0, button_bounds.height() - icon_height) / 2; | 387 y_offset = std::max(0, button_bounds.height() - icon_height) / 2; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Shelf* shelf = shelf_view_->shelf(); | 488 Shelf* shelf = shelf_view_->shelf(); |
489 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); | 489 ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); |
490 gfx::ImageSkia image = *rb->GetImageNamed(bar_id).ToImageSkia(); | 490 gfx::ImageSkia image = *rb->GetImageNamed(bar_id).ToImageSkia(); |
491 if (!shelf->IsHorizontalAlignment()) { | 491 if (!shelf->IsHorizontalAlignment()) { |
492 image = gfx::ImageSkiaOperations::CreateRotatedImage( | 492 image = gfx::ImageSkiaOperations::CreateRotatedImage( |
493 image, shelf->alignment() == SHELF_ALIGNMENT_LEFT | 493 image, shelf->alignment() == wm::SHELF_ALIGNMENT_LEFT |
494 ? SkBitmapOperations::ROTATION_90_CW | 494 ? SkBitmapOperations::ROTATION_90_CW |
495 : SkBitmapOperations::ROTATION_270_CW); | 495 : SkBitmapOperations::ROTATION_270_CW); |
496 } | 496 } |
497 bar_->SetImage(image); | 497 bar_->SetImage(image); |
498 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( | 498 bar_->SetHorizontalAlignment(shelf->SelectValueForShelfAlignment( |
499 views::ImageView::CENTER, views::ImageView::LEADING, | 499 views::ImageView::CENTER, views::ImageView::LEADING, |
500 views::ImageView::TRAILING)); | 500 views::ImageView::TRAILING)); |
501 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( | 501 bar_->SetVerticalAlignment(shelf->SelectValueForShelfAlignment( |
502 views::ImageView::TRAILING, views::ImageView::CENTER, | 502 views::ImageView::TRAILING, views::ImageView::CENTER, |
503 views::ImageView::CENTER)); | 503 views::ImageView::CENTER)); |
504 bar_->SchedulePaint(); | 504 bar_->SchedulePaint(); |
505 } | 505 } |
506 | 506 |
507 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); | 507 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); |
508 } | 508 } |
509 | 509 |
510 } // namespace ash | 510 } // namespace ash |
OLD | NEW |