| Index: ui/aura_shell/launcher/tabbed_launcher_button.cc
|
| diff --git a/ui/aura_shell/launcher/tabbed_launcher_button.cc b/ui/aura_shell/launcher/tabbed_launcher_button.cc
|
| index 620e57bffcf8d2702b803f7fe147204928efc80c..f1a1e277c870e47a01f1f352148b2abbe3e5d2fa 100644
|
| --- a/ui/aura_shell/launcher/tabbed_launcher_button.cc
|
| +++ b/ui/aura_shell/launcher/tabbed_launcher_button.cc
|
| @@ -12,10 +12,8 @@
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/gfx/insets.h"
|
| -#include "views/painter.h"
|
|
|
| namespace aura_shell {
|
| -
|
| namespace internal {
|
|
|
| // The images drawn inside the background tab are drawn at this offset from
|
| @@ -34,16 +32,22 @@ const int kBgBottomInset = 12;
|
| const int kBgRightInset = 8;
|
|
|
| // static
|
| -SkBitmap* TabbedLauncherButton::bg_image_ = NULL;
|
| +SkBitmap* TabbedLauncherButton::bg_image_1_ = NULL;
|
| +SkBitmap* TabbedLauncherButton::bg_image_2_ = NULL;
|
| +SkBitmap* TabbedLauncherButton::bg_image_3_ = NULL;
|
|
|
| TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener,
|
| LauncherButtonHost* host)
|
| : views::CustomButton(listener),
|
| host_(host) {
|
| - if (!bg_image_) {
|
| + if (!bg_image_1_) {
|
| ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| - bg_image_ = new SkBitmap(
|
| - *rb.GetImageNamed(IDR_AURA_LAUNCHER_TABBED_BROWSER).ToSkBitmap());
|
| + bg_image_1_ = new SkBitmap(
|
| + *rb.GetImageNamed(IDR_AURA_LAUNCHER_TABBED_BROWSER_1).ToSkBitmap());
|
| + bg_image_2_ = new SkBitmap(
|
| + *rb.GetImageNamed(IDR_AURA_LAUNCHER_TABBED_BROWSER_2).ToSkBitmap());
|
| + bg_image_3_ = new SkBitmap(
|
| + *rb.GetImageNamed(IDR_AURA_LAUNCHER_TABBED_BROWSER_3).ToSkBitmap());
|
| }
|
| }
|
|
|
| @@ -55,42 +59,28 @@ void TabbedLauncherButton::SetImages(const LauncherTabbedImages& images) {
|
| }
|
|
|
| gfx::Size TabbedLauncherButton::GetPreferredSize() {
|
| - if (images_.empty())
|
| - return gfx::Size(bg_image_->width(), bg_image_->height());
|
| -
|
| - // Assume all images are the same size.
|
| - int num_images = static_cast<int>(images_.size());
|
| - int padding = (num_images - 1) * kImagePadding;
|
| - return gfx::Size(
|
| - std::max(kBgImageContentInset * 2 +
|
| - images_[0].image.width() * num_images + padding,
|
| - bg_image_->width()),
|
| - bg_image_->height());
|
| + return gfx::Size(bg_image_1_->width(), bg_image_1_->height());
|
| }
|
|
|
| void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) {
|
| - if (width() == bg_image_->width()) {
|
| - canvas->DrawBitmapInt(*bg_image_, 0, 0);
|
| - } else {
|
| - scoped_ptr<views::Painter> bg_painter(views::Painter::CreateImagePainter(
|
| - *bg_image_, gfx::Insets(kBgTopInset, kBgLeftInset, kBgBottomInset,
|
| - kBgRightInset), true));
|
| - bg_painter->Paint(width(), height(), canvas);
|
| - }
|
| + SkBitmap* bg_image = NULL;
|
| + if (images_.size() <= 1)
|
| + bg_image = bg_image_1_;
|
| + else if (images_.size() == 2)
|
| + bg_image = bg_image_2_;
|
| + else
|
| + bg_image = bg_image_3_;
|
| + canvas->DrawBitmapInt(*bg_image, 0, 0);
|
|
|
| if (images_.empty())
|
| return;
|
|
|
| - int num_images = static_cast<int>(images_.size());
|
| - int padding = (num_images - 1) * kImagePadding;
|
| - int x = std::max(kBgImageContentInset,
|
| - (width() - num_images * images_[0].image.width() - padding) / 2);
|
| + // Only show the first icon.
|
| + // TODO(sky): if we settle on just 1 icon, then we should simplify surrounding
|
| + // code (don't use a vector of images).
|
| + int x = (width() - images_[0].image.width()) / 2;
|
| int y = (height() - images_[0].image.height()) / 2;
|
| - for (LauncherTabbedImages::const_iterator i = images_.begin();
|
| - i != images_.end(); ++i) {
|
| - canvas->DrawBitmapInt(i->image, x, y);
|
| - x += i->image.width() + kImagePadding;
|
| - }
|
| + canvas->DrawBitmapInt(images_[0].image, x, y);
|
| }
|
|
|
| bool TabbedLauncherButton::OnMousePressed(const views::MouseEvent& event) {
|
|
|