diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-28 21:12:43 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-28 21:12:43 +0000 |
commit | be149a3f00285713d18efe9c0fbe8d95b8b343a7 (patch) | |
tree | 70638e19d017e78b0a9654db5460e0443c2fa235 /ui/aura_shell/launcher | |
parent | f15841fb802ccfd27e9fd914734e38f64e6b880d (diff) | |
download | chromium_src-be149a3f00285713d18efe9c0fbe8d95b8b343a7.zip chromium_src-be149a3f00285713d18efe9c0fbe8d95b8b343a7.tar.gz chromium_src-be149a3f00285713d18efe9c0fbe8d95b8b343a7.tar.bz2 |
Changes around the launcher so that it only shows the most recently
used icon, and the icon has a couple of different states indicating
how many tabs are there.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: http://codereview.chromium.org/8418006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107794 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura_shell/launcher')
-rw-r--r-- | ui/aura_shell/launcher/tabbed_launcher_button.cc | 58 | ||||
-rw-r--r-- | ui/aura_shell/launcher/tabbed_launcher_button.h | 6 |
2 files changed, 29 insertions, 35 deletions
diff --git a/ui/aura_shell/launcher/tabbed_launcher_button.cc b/ui/aura_shell/launcher/tabbed_launcher_button.cc index 620e57b..f1a1e27 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) { diff --git a/ui/aura_shell/launcher/tabbed_launcher_button.h b/ui/aura_shell/launcher/tabbed_launcher_button.h index 28264f5..f8ec69d 100644 --- a/ui/aura_shell/launcher/tabbed_launcher_button.h +++ b/ui/aura_shell/launcher/tabbed_launcher_button.h @@ -40,7 +40,11 @@ class TabbedLauncherButton : public views::CustomButton { LauncherButtonHost* host_; - static SkBitmap* bg_image_; + // Background images. Which one is chosen depends upon how many images are + // provided. + static SkBitmap* bg_image_1_; + static SkBitmap* bg_image_2_; + static SkBitmap* bg_image_3_; DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton); }; |