Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Side by Side Diff: ash/launcher/launcher_button.cc

Issue 11644033: Rotated Images (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/launcher/launcher_button.h" 5 #include "ash/launcher/launcher_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/launcher/launcher_button_host.h" 9 #include "ash/launcher/launcher_button_host.h"
10 #include "ash/wm/shelf_layout_manager.h" 10 #include "ash/wm/shelf_layout_manager.h"
11 #include "grit/ash_resources.h" 11 #include "grit/ash_resources.h"
12 #include "skia/ext/image_operations.h" 12 #include "skia/ext/image_operations.h"
13 #include "ui/base/accessibility/accessible_view_state.h" 13 #include "ui/base/accessibility/accessible_view_state.h"
14 #include "ui/base/animation/animation_delegate.h" 14 #include "ui/base/animation/animation_delegate.h"
15 #include "ui/base/animation/throb_animation.h" 15 #include "ui/base/animation/throb_animation.h"
16 #include "ui/base/events/event_constants.h" 16 #include "ui/base/events/event_constants.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/compositor/layer.h" 18 #include "ui/compositor/layer.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 19 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/image/image_skia_operations.h" 22 #include "ui/gfx/image/image_skia_operations.h"
23 #include "ui/gfx/skbitmap_operations.h"
23 #include "ui/views/controls/image_view.h" 24 #include "ui/views/controls/image_view.h"
24 25
25 namespace { 26 namespace {
26 27
27 // Size of the bar. This is along the opposite axis of the shelf. For example, 28 // Size of the bar. This is along the opposite axis of the shelf. For example,
28 // if the shelf is aligned horizontally then this is the height of the bar. 29 // if the shelf is aligned horizontally then this is the height of the bar.
29 const int kBarSize = 3; 30 const int kBarSize = 3;
30 const int kBarSpacing = 5; 31 const int kBarSpacing = 5;
31 const int kIconSize = 32; 32 const int kIconSize = 32;
32 const int kHopSpacing = 2; 33 const int kHopSpacing = 2;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 bool LauncherButton::IsShelfHorizontal() const { 356 bool LauncherButton::IsShelfHorizontal() const {
356 return shelf_layout_manager_->IsHorizontalAlignment(); 357 return shelf_layout_manager_->IsHorizontalAlignment();
357 } 358 }
358 359
359 void LauncherButton::UpdateState() { 360 void LauncherButton::UpdateState() {
360 if (state_ == STATE_NORMAL) { 361 if (state_ == STATE_NORMAL) {
361 bar_->SetVisible(false); 362 bar_->SetVisible(false);
362 } else { 363 } else {
363 int bar_id; 364 int bar_id;
364 if (state_ & STATE_ACTIVE) { 365 if (state_ & STATE_ACTIVE) {
365 bar_id = shelf_layout_manager_->SelectValueForShelfAlignment( 366 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_ACTIVE;
366 IDR_AURA_LAUNCHER_UNDERLINE_BOTTOM_ACTIVE,
367 IDR_AURA_LAUNCHER_UNDERLINE_LEFT_ACTIVE,
368 IDR_AURA_LAUNCHER_UNDERLINE_RIGHT_ACTIVE);
369 } else if (state_ & (STATE_HOVERED | STATE_FOCUSED | STATE_ATTENTION)) { 367 } else if (state_ & (STATE_HOVERED | STATE_FOCUSED | STATE_ATTENTION)) {
370 bar_id = shelf_layout_manager_->SelectValueForShelfAlignment( 368 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_HOVER;
371 IDR_AURA_LAUNCHER_UNDERLINE_BOTTOM_HOVER,
372 IDR_AURA_LAUNCHER_UNDERLINE_LEFT_HOVER,
373 IDR_AURA_LAUNCHER_UNDERLINE_RIGHT_HOVER);
374 } else { 369 } else {
375 bar_id = shelf_layout_manager_->SelectValueForShelfAlignment( 370 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_RUNNING;
376 IDR_AURA_LAUNCHER_UNDERLINE_BOTTOM_RUNNING,
377 IDR_AURA_LAUNCHER_UNDERLINE_LEFT_RUNNING,
378 IDR_AURA_LAUNCHER_UNDERLINE_RIGHT_RUNNING);
379 } 371 }
380 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 372 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
381 bar_->SetImage(rb.GetImageNamed(bar_id).ToImageSkia()); 373 const gfx::ImageSkia* image = rb.GetImageNamed(bar_id).ToImageSkia();
374 if(SHELF_ALIGNMENT_BOTTOM == shelf_layout_manager_->GetAlignment())
375 bar_->SetImage(*image);
376 else
377 bar_->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage(*image,
378 shelf_layout_manager_->SelectValueForShelfAlignment(
379 SkBitmapOperations::ROTATION_270_CW,
380 SkBitmapOperations::ROTATION_270_CW,
381 SkBitmapOperations::ROTATION_90_CW)));
382 bar_->SetVisible(true); 382 bar_->SetVisible(true);
383 } 383 }
384 bool rtl = base::i18n::IsRTL(); 384 bool rtl = base::i18n::IsRTL();
385 bar_->SetHorizontalAlignment( 385 bar_->SetHorizontalAlignment(
386 shelf_layout_manager_->SelectValueForShelfAlignment( 386 shelf_layout_manager_->SelectValueForShelfAlignment(
387 views::ImageView::CENTER, 387 views::ImageView::CENTER,
388 rtl ? views::ImageView::TRAILING : views::ImageView::LEADING, 388 rtl ? views::ImageView::TRAILING : views::ImageView::LEADING,
389 rtl ? views::ImageView::LEADING : views::ImageView::TRAILING)); 389 rtl ? views::ImageView::LEADING : views::ImageView::TRAILING));
390 bar_->SetVerticalAlignment( 390 bar_->SetVerticalAlignment(
391 shelf_layout_manager_->SelectValueForShelfAlignment( 391 shelf_layout_manager_->SelectValueForShelfAlignment(
(...skipping 22 matching lines...) Expand all
414 414
415 // Force bar to layout as alignment may have changed but not bounds. 415 // Force bar to layout as alignment may have changed but not bounds.
416 bar_->Layout(); 416 bar_->Layout();
417 Layout(); 417 Layout();
418 bar_->SchedulePaint(); 418 bar_->SchedulePaint();
419 SchedulePaint(); 419 SchedulePaint();
420 } 420 }
421 421
422 } // namespace internal 422 } // namespace internal
423 } // namespace ash 423 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher.cc ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698