diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 20:51:18 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 20:51:18 +0000 |
commit | ef681d93b2c06bd04c4e126376fc6fab4f37bc03 (patch) | |
tree | 3b5c611e4dc117074b4e82ced8cc3c7a988d2333 /ash | |
parent | b2908faa9fb9be5a6b1710c81c9dad11e2b48335 (diff) | |
download | chromium_src-ef681d93b2c06bd04c4e126376fc6fab4f37bc03.zip chromium_src-ef681d93b2c06bd04c4e126376fc6fab4f37bc03.tar.gz chromium_src-ef681d93b2c06bd04c4e126376fc6fab4f37bc03.tar.bz2 |
Add black border to bottom of launcher so that new resources
have some contrast.
Also fix problem w/ HDPI launcher images.
BUG=123698
TEST=Visual check
Review URL: https://chromiumcodereview.appspot.com/10915149
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155822 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/launcher/launcher.cc | 72 | ||||
-rw-r--r-- | ash/launcher/launcher.h | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 1 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.cc | 28 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.h | 12 |
5 files changed, 80 insertions, 38 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index 20902b9..58db767 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -16,7 +16,9 @@ #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" #include "ash/wm/shelf_layout_manager.h" +#include "grit/ui_resources.h" #include "ui/aura/window.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image.h" @@ -24,12 +26,18 @@ #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" +namespace { +// Size of black border at bottom (or side) of launcher. +const int kNumBlackPixels = 3; +} + namespace ash { // The contents view of the Widget. This view contains LauncherView and // sizes it to the width of the widget minus the size of the status area. class Launcher::DelegateView : public views::WidgetDelegate, - public views::AccessiblePaneView { + public views::AccessiblePaneView, + public internal::BackgroundAnimatorDelegate { public: explicit DelegateView(Launcher* launcher); virtual ~DelegateView(); @@ -44,6 +52,7 @@ class Launcher::DelegateView : public views::WidgetDelegate, // views::View overrides virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; + virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; // views::WidgetDelegateView overrides: virtual views::Widget* GetWidget() OVERRIDE { @@ -58,16 +67,21 @@ class Launcher::DelegateView : public views::WidgetDelegate, return focus_cycler_ && focus_cycler_->widget_activating() == GetWidget(); } + // BackgroundAnimatorDelegate overrides: + virtual void UpdateBackground(int alpha) OVERRIDE; + private: Launcher* launcher_; internal::FocusCycler* focus_cycler_; + int alpha_; DISALLOW_COPY_AND_ASSIGN(DelegateView); }; Launcher::DelegateView::DelegateView(Launcher* launcher) : launcher_(launcher), - focus_cycler_(NULL) { + focus_cycler_(NULL), + alpha_(0) { } Launcher::DelegateView::~DelegateView() { @@ -80,32 +94,64 @@ gfx::Size Launcher::DelegateView::GetPreferredSize() { void Launcher::DelegateView::Layout() { if (child_count() == 0) return; + View* launcher_view = child_at(0); + if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM) { int w = std::max(0, width() - launcher_->status_size_.width()); - int h = std::min(height(), child_at(0)->GetPreferredSize().height()); + int h = std::min(height(), launcher_view->GetPreferredSize().height()); int move_up = height() > h ? sqrtf(height() - h) : 0; - child_at(0)->SetBounds(0, std::max(0, height() - h) - move_up, w, h); + launcher_view->SetBounds(0, std::max(0, height() - h) - move_up, w, h); } else { int h = std::max(0, height() - launcher_->status_size_.height()); - int w = std::min(width(), child_at(0)->GetPreferredSize().width()); + int w = std::min(width(), launcher_view->GetPreferredSize().width()); int x = width() > w ? sqrtf(width() - w) : 0; if (launcher_->alignment_ == SHELF_ALIGNMENT_RIGHT) x = width() - w - x; - child_at(0)->SetBounds(x, 0, w, h); + launcher_view->SetBounds(x, 0, w, h); } } +void Launcher::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { + if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM) { + SkPaint paint; + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + static const gfx::ImageSkia* launcher_background = NULL; + if (!launcher_background) { + launcher_background = + rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND).ToImageSkia(); + } + 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)); + } +} + +void Launcher::DelegateView::UpdateBackground(int alpha) { + alpha_ = alpha; + SchedulePaint(); +} + // Launcher -------------------------------------------------------------------- Launcher::Launcher(aura::Window* window_container, internal::ShelfLayoutManager* shelf_layout_manager) : widget_(NULL), window_container_(window_container), - delegate_view_(NULL), + delegate_view_(new DelegateView(this)), launcher_view_(NULL), alignment_(SHELF_ALIGNMENT_BOTTOM), - ALLOW_THIS_IN_INITIALIZER_LIST( - background_animator_(this, 0, kLauncherBackgroundAlpha)) { + background_animator_(delegate_view_, 0, kLauncherBackgroundAlpha) { model_.reset(new LauncherModel); if (Shell::GetInstance()->delegate()) { delegate_.reset( @@ -115,8 +161,6 @@ Launcher::Launcher(aura::Window* window_container, widget_.reset(new views::Widget); views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - // The launcher only ever draws a solid color. - params.layer_type = ui::LAYER_SOLID_COLOR; params.transparent = true; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.parent = Shell::GetContainer( @@ -125,7 +169,6 @@ Launcher::Launcher(aura::Window* window_container, launcher_view_ = new internal::LauncherView( model_.get(), delegate_.get(), shelf_layout_manager); launcher_view_->Init(); - delegate_view_ = new DelegateView(this); delegate_view_->AddChildView(launcher_view_); params.delegate = delegate_view_; widget_->Init(params); @@ -228,9 +271,4 @@ internal::LauncherView* Launcher::GetLauncherViewForTest() { return launcher_view_; } -void Launcher::UpdateBackground(int alpha) { - ui::Layer* layer = widget_->GetNativeView()->layer(); - layer->SetColor(SkColorSetARGB(alpha, 0, 0, 0)); -} - } // namespace ash diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h index eb35297..d889e61 100644 --- a/ash/launcher/launcher.h +++ b/ash/launcher/launcher.h @@ -38,7 +38,7 @@ class LauncherIconObserver; class LauncherDelegate; class LauncherModel; -class ASH_EXPORT Launcher : public internal::BackgroundAnimatorDelegate { +class ASH_EXPORT Launcher { public: Launcher(aura::Window* window_container, internal::ShelfLayoutManager* shelf_layout_manager); @@ -98,9 +98,6 @@ class ASH_EXPORT Launcher : public internal::BackgroundAnimatorDelegate { aura::Window* window_container() { return window_container_; } - // BackgroundAnimatorDelegate overrides: - virtual void UpdateBackground(int alpha) OVERRIDE; - private: class DelegateView; diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index 53b65f4..17eb877 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -26,6 +26,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" +#include "ui/gfx/canvas.h" #include "ui/views/animation/bounds_animator.h" #include "ui/views/border.h" #include "ui/views/controls/menu/menu_model_adapter.h" diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc index 7add7cf..5e6ab7d 100644 --- a/ash/launcher/tabbed_launcher_button.cc +++ b/ash/launcher/tabbed_launcher_button.cc @@ -25,15 +25,14 @@ TabbedLauncherButton::IconView::IconView( if (!browser_image_) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - browser_image_ = new SkBitmap( - *rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER).ToSkBitmap()); - incognito_browser_image_ = new SkBitmap( - *rb.GetImageNamed(IDR_AURA_LAUNCHER_INCOGNITO_BROWSER).ToSkBitmap()); - browser_panel_image_ = new SkBitmap( - *rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER_PANEL).ToSkBitmap()); - incognito_browser_panel_image_ = new SkBitmap( - *rb.GetImageNamed( - IDR_AURA_LAUNCHER_INCOGNITO_BROWSER_PANEL).ToSkBitmap()); + browser_image_ = rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER).ToImageSkia(); + incognito_browser_image_ = + rb.GetImageNamed(IDR_AURA_LAUNCHER_INCOGNITO_BROWSER).ToImageSkia(); + browser_panel_image_ = + rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER_PANEL).ToImageSkia(); + incognito_browser_panel_image_ = + rb.GetImageNamed( + IDR_AURA_LAUNCHER_INCOGNITO_BROWSER_PANEL).ToImageSkia(); } set_icon_size(0); if (host->is_incognito() == STATE_NOT_INCOGNITO) @@ -101,10 +100,13 @@ void TabbedLauncherButton::IconView::OnPaint(gfx::Canvas* canvas) { } // static -SkBitmap* TabbedLauncherButton::IconView::browser_image_ = NULL; -SkBitmap* TabbedLauncherButton::IconView::incognito_browser_image_ = NULL; -SkBitmap* TabbedLauncherButton::IconView::browser_panel_image_ = NULL; -SkBitmap* TabbedLauncherButton::IconView::incognito_browser_panel_image_ = NULL; +const gfx::ImageSkia* TabbedLauncherButton::IconView::browser_image_ = NULL; +const gfx::ImageSkia* TabbedLauncherButton::IconView::incognito_browser_image_ = + NULL; +const gfx::ImageSkia* TabbedLauncherButton::IconView::browser_panel_image_ = + NULL; +const gfx::ImageSkia* + TabbedLauncherButton::IconView::incognito_browser_panel_image_ = NULL; TabbedLauncherButton* TabbedLauncherButton::Create( views::ButtonListener* listener, diff --git a/ash/launcher/tabbed_launcher_button.h b/ash/launcher/tabbed_launcher_button.h index 2cc864d..f78ec07 100644 --- a/ash/launcher/tabbed_launcher_button.h +++ b/ash/launcher/tabbed_launcher_button.h @@ -12,6 +12,10 @@ #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/glow_hover_controller.h" +namespace gfx { +class ImageSkia; +} + namespace ui { class MultiAnimation; } @@ -80,11 +84,11 @@ class TabbedLauncherButton : public LauncherButton { scoped_ptr<ui::MultiAnimation> animation_; // Background images. Which one is chosen depends on the type of the window. - static SkBitmap* browser_image_; - static SkBitmap* incognito_browser_image_; + static const gfx::ImageSkia* browser_image_; + static const gfx::ImageSkia* incognito_browser_image_; // TODO[dave] implement panel specific image. - static SkBitmap* browser_panel_image_; - static SkBitmap* incognito_browser_panel_image_; + static const gfx::ImageSkia* browser_panel_image_; + static const gfx::ImageSkia* incognito_browser_panel_image_; DISALLOW_COPY_AND_ASSIGN(IconView); }; |