summaryrefslogtreecommitdiffstats
path: root/ash/launcher
diff options
context:
space:
mode:
authorharrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-08 17:46:01 +0000
committerharrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-08 17:46:01 +0000
commit19c0fa9679d9bbf83da4aca041bb6fa13fe29dad (patch)
tree65d60fc9450f5a655c8481684ff30a64c6a985f7 /ash/launcher
parentff7319a88defa09542250dc15a7273f37a7de6d7 (diff)
downloadchromium_src-19c0fa9679d9bbf83da4aca041bb6fa13fe29dad.zip
chromium_src-19c0fa9679d9bbf83da4aca041bb6fa13fe29dad.tar.gz
chromium_src-19c0fa9679d9bbf83da4aca041bb6fa13fe29dad.tar.bz2
Rotated Images
- Update launcher items, and background to use rotated images instead of duplicates. BUG=127583 Review URL: https://codereview.chromium.org/11644033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r--ash/launcher/launcher.cc92
-rw-r--r--ash/launcher/launcher.h1
-rw-r--r--ash/launcher/launcher_button.cc26
3 files changed, 65 insertions, 54 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index a73f402..3df6095 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -16,6 +16,7 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
+#include "ash/wm/property_util.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "grit/ash_resources.h"
@@ -27,6 +28,8 @@
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/skbitmap_operations.h"
#include "ui/views/accessible_pane_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -93,34 +96,37 @@ class Launcher::DelegateView : public views::WidgetDelegate,
// Class used to slightly dim shelf items when maximized and visible. It also
// makes sure the widget changes size to always be of the same size as the
// shelf.
-class DimmerView : public views::WidgetDelegateView,
+class Launcher::DimmerView : public views::WidgetDelegateView,
public aura::WindowObserver {
public:
- explicit DimmerView(views::Widget* launcher)
+ explicit DimmerView(Launcher* launcher)
: launcher_(launcher) {
- launcher_->GetNativeWindow()->AddObserver(this);
+ launcher_->widget()->GetNativeWindow()->AddObserver(this);
}
~DimmerView() {
if (launcher_)
- launcher_->GetNativeWindow()->RemoveObserver(this);
+ launcher_->widget()->GetNativeWindow()->RemoveObserver(this);
}
private:
// views::View overrides:
virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::ImageSkia* launcher_background = rb.GetImageSkiaNamed(
- internal::ShelfLayoutManager::ForLauncher(
- launcher_->GetNativeView())->
- SelectValueForShelfAlignment(IDR_AURA_LAUNCHER_DIMMING_BOTTOM,
- IDR_AURA_LAUNCHER_DIMMING_LEFT,
- IDR_AURA_LAUNCHER_DIMMING_RIGHT));
+ gfx::ImageSkia background_image =
+ *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_DIMMING);
+ if (SHELF_ALIGNMENT_BOTTOM != launcher_->alignment_)
+ background_image = gfx::ImageSkiaOperations::CreateRotatedImage(
+ background_image,
+ (SHELF_ALIGNMENT_LEFT == launcher_->alignment_ ?
+ SkBitmapOperations::ROTATION_90_CW :
+ SkBitmapOperations::ROTATION_270_CW));
+
SkPaint paint;
paint.setAlpha(kDimAlpha);
canvas->DrawImageInt(
- *launcher_background,
- 0, 0, launcher_background->width(), launcher_background->height(),
+ background_image,
+ 0, 0, background_image.width(), background_image.height(),
0, 0, width(), height(),
false,
paint);
@@ -130,17 +136,17 @@ class DimmerView : public views::WidgetDelegateView,
virtual void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE {
- CHECK_EQ(window, launcher_->GetNativeWindow());
+ CHECK_EQ(window, launcher_->widget()->GetNativeWindow());
GetWidget()->GetNativeWindow()->SetBounds(window->bounds());
}
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
- CHECK_EQ(window, launcher_->GetNativeWindow());
- launcher_->GetNativeWindow()->RemoveObserver(this);
+ CHECK_EQ(window, launcher_->widget()->GetNativeWindow());
+ launcher_->widget()->GetNativeWindow()->RemoveObserver(this);
launcher_ = NULL;
}
- views::Widget* launcher_;
+ Launcher* launcher_;
DISALLOW_COPY_AND_ASSIGN(DimmerView);
};
@@ -172,30 +178,33 @@ void Launcher::DelegateView::Layout() {
}
void Launcher::DelegateView::OnPaintBackground(gfx::Canvas* canvas) {
- if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM) {
- SkPaint paint;
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- const gfx::ImageSkia* launcher_background = rb.GetImageSkiaNamed(
- internal::ShelfLayoutManager::ForLauncher(
- launcher_->widget()->GetNativeView())->
- SelectValueForShelfAlignment(IDR_AURA_LAUNCHER_BACKGROUND_BOTTOM,
- IDR_AURA_LAUNCHER_BACKGROUND_LEFT,
- IDR_AURA_LAUNCHER_BACKGROUND_RIGHT));
- paint.setAlpha(alpha_);
- canvas->DrawImageInt(
- *launcher_background,
- 0, 0, launcher_background->width(), launcher_background->height(),
- 0, 0, width(), height(),
- false,
- paint);
- canvas->FillRect(
- gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels),
- SK_ColorBLACK);
- } else {
- // TODO(davemoore): when we get an image for the side launcher background
- // use it, and handle black border.
- canvas->DrawColor(SkColorSetARGB(alpha_, 0, 0, 0));
- }
+ ash::internal::ShelfLayoutManager* shelf = ash::GetRootWindowController(
+ GetWidget()->GetNativeView()->GetRootWindow())->shelf();
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::ImageSkia launcher_background =
+ *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND);
+ if (launcher_->alignment_ != SHELF_ALIGNMENT_BOTTOM)
+ launcher_background = gfx::ImageSkiaOperations::CreateRotatedImage(
+ launcher_background,
+ shelf->SelectValueForShelfAlignment(
+ SkBitmapOperations::ROTATION_90_CW,
+ SkBitmapOperations::ROTATION_90_CW,
+ SkBitmapOperations::ROTATION_270_CW));
+
+ gfx::Rect black_rect = shelf->SelectValueForShelfAlignment(
+ gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels),
+ gfx::Rect(0, 0, kNumBlackPixels, height()),
+ gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height()));
+
+ SkPaint paint;
+ paint.setAlpha(alpha_);
+ canvas->DrawImageInt(
+ launcher_background,
+ 0, 0, launcher_background.width(), launcher_background.height(),
+ 0, 0, width(), height(),
+ false,
+ paint);
+ canvas->FillRect(black_rect, SK_ColorBLACK);
}
void Launcher::DelegateView::UpdateBackground(int alpha) {
@@ -274,6 +283,7 @@ internal::FocusCycler* Launcher::GetFocusCycler() {
void Launcher::SetAlignment(ShelfAlignment alignment) {
alignment_ = alignment;
+ delegate_view_->SchedulePaint();
launcher_view_->OnShelfAlignmentChanged();
// ShelfLayoutManager will resize the launcher.
}
@@ -308,7 +318,7 @@ void Launcher::SetDimsShelf(bool value) {
dimmer_->SetBounds(widget_->GetWindowBoundsInScreen());
// The launcher should not take focus when it is initially shown.
dimmer_->set_focus_on_creation(false);
- dimmer_->SetContentsView(new DimmerView(widget_.get()));
+ dimmer_->SetContentsView(new DimmerView(this));
dimmer_->GetNativeView()->SetName("LauncherDimmerView");
dimmer_->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey,
true);
diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h
index 3b2e424..79389b0 100644
--- a/ash/launcher/launcher.h
+++ b/ash/launcher/launcher.h
@@ -135,6 +135,7 @@ class ASH_EXPORT Launcher: public views::WidgetObserver {
private:
class DelegateView;
+ class DimmerView;
// Widget hosting the view.
scoped_ptr<views::Widget> widget_;
diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc
index 77546f8..dee32e3 100644
--- a/ash/launcher/launcher_button.cc
+++ b/ash/launcher/launcher_button.cc
@@ -20,6 +20,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/skbitmap_operations.h"
#include "ui/views/controls/image_view.h"
namespace {
@@ -362,23 +363,22 @@ void LauncherButton::UpdateState() {
} else {
int bar_id;
if (state_ & STATE_ACTIVE) {
- bar_id = shelf_layout_manager_->SelectValueForShelfAlignment(
- IDR_AURA_LAUNCHER_UNDERLINE_BOTTOM_ACTIVE,
- IDR_AURA_LAUNCHER_UNDERLINE_LEFT_ACTIVE,
- IDR_AURA_LAUNCHER_UNDERLINE_RIGHT_ACTIVE);
+ bar_id = IDR_AURA_LAUNCHER_UNDERLINE_ACTIVE;
} else if (state_ & (STATE_HOVERED | STATE_FOCUSED | STATE_ATTENTION)) {
- bar_id = shelf_layout_manager_->SelectValueForShelfAlignment(
- IDR_AURA_LAUNCHER_UNDERLINE_BOTTOM_HOVER,
- IDR_AURA_LAUNCHER_UNDERLINE_LEFT_HOVER,
- IDR_AURA_LAUNCHER_UNDERLINE_RIGHT_HOVER);
+ bar_id = IDR_AURA_LAUNCHER_UNDERLINE_HOVER;
} else {
- bar_id = shelf_layout_manager_->SelectValueForShelfAlignment(
- IDR_AURA_LAUNCHER_UNDERLINE_BOTTOM_RUNNING,
- IDR_AURA_LAUNCHER_UNDERLINE_LEFT_RUNNING,
- IDR_AURA_LAUNCHER_UNDERLINE_RIGHT_RUNNING);
+ bar_id = IDR_AURA_LAUNCHER_UNDERLINE_RUNNING;
}
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- bar_->SetImage(rb.GetImageNamed(bar_id).ToImageSkia());
+ const gfx::ImageSkia* image = rb.GetImageNamed(bar_id).ToImageSkia();
+ if(SHELF_ALIGNMENT_BOTTOM == shelf_layout_manager_->GetAlignment())
+ bar_->SetImage(*image);
+ else
+ bar_->SetImage(gfx::ImageSkiaOperations::CreateRotatedImage(*image,
+ shelf_layout_manager_->SelectValueForShelfAlignment(
+ SkBitmapOperations::ROTATION_270_CW,
+ SkBitmapOperations::ROTATION_270_CW,
+ SkBitmapOperations::ROTATION_90_CW)));
bar_->SetVisible(true);
}
bool rtl = base::i18n::IsRTL();