Commit be149a3f authored by sky@chromium.org's avatar sky@chromium.org

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
parent f15841fb
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
// Max number of tabs we'll send icons over for. // Max number of tabs we'll send icons over for.
const int kMaxCount = 2; const int kMaxCount = 3;
LauncherIconUpdater::LauncherIconUpdater( LauncherIconUpdater::LauncherIconUpdater(
TabStripModel* tab_model, TabStripModel* tab_model,
......
...@@ -51,7 +51,7 @@ class ShellDelegateImpl : public aura_shell::ShellDelegate { ...@@ -51,7 +51,7 @@ class ShellDelegateImpl : public aura_shell::ShellDelegate {
i == 1 ? 255 : 0, i == 1 ? 255 : 0,
i == 2 ? 255 : 0); i == 2 ? 255 : 0);
} }
image_count = (image_count + 1) % 2; image_count = (image_count + 1) % 3;
return true; // Makes the entry show up in the launcher. return true; // Makes the entry show up in the launcher.
} }
}; };
......
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/insets.h" #include "ui/gfx/insets.h"
#include "views/painter.h"
namespace aura_shell { namespace aura_shell {
namespace internal { namespace internal {
// The images drawn inside the background tab are drawn at this offset from // The images drawn inside the background tab are drawn at this offset from
...@@ -34,16 +32,22 @@ const int kBgBottomInset = 12; ...@@ -34,16 +32,22 @@ const int kBgBottomInset = 12;
const int kBgRightInset = 8; const int kBgRightInset = 8;
// static // 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, TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener,
LauncherButtonHost* host) LauncherButtonHost* host)
: views::CustomButton(listener), : views::CustomButton(listener),
host_(host) { host_(host) {
if (!bg_image_) { if (!bg_image_1_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
bg_image_ = new SkBitmap( bg_image_1_ = new SkBitmap(
*rb.GetImageNamed(IDR_AURA_LAUNCHER_TABBED_BROWSER).ToSkBitmap()); *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) { ...@@ -55,42 +59,28 @@ void TabbedLauncherButton::SetImages(const LauncherTabbedImages& images) {
} }
gfx::Size TabbedLauncherButton::GetPreferredSize() { gfx::Size TabbedLauncherButton::GetPreferredSize() {
if (images_.empty()) return gfx::Size(bg_image_1_->width(), bg_image_1_->height());
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());
} }
void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) { void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) {
if (width() == bg_image_->width()) { SkBitmap* bg_image = NULL;
canvas->DrawBitmapInt(*bg_image_, 0, 0); if (images_.size() <= 1)
} else { bg_image = bg_image_1_;
scoped_ptr<views::Painter> bg_painter(views::Painter::CreateImagePainter( else if (images_.size() == 2)
*bg_image_, gfx::Insets(kBgTopInset, kBgLeftInset, kBgBottomInset, bg_image = bg_image_2_;
kBgRightInset), true)); else
bg_painter->Paint(width(), height(), canvas); bg_image = bg_image_3_;
} canvas->DrawBitmapInt(*bg_image, 0, 0);
if (images_.empty()) if (images_.empty())
return; return;
int num_images = static_cast<int>(images_.size()); // Only show the first icon.
int padding = (num_images - 1) * kImagePadding; // TODO(sky): if we settle on just 1 icon, then we should simplify surrounding
int x = std::max(kBgImageContentInset, // code (don't use a vector of images).
(width() - num_images * images_[0].image.width() - padding) / 2); int x = (width() - images_[0].image.width()) / 2;
int y = (height() - images_[0].image.height()) / 2; int y = (height() - images_[0].image.height()) / 2;
for (LauncherTabbedImages::const_iterator i = images_.begin(); canvas->DrawBitmapInt(images_[0].image, x, y);
i != images_.end(); ++i) {
canvas->DrawBitmapInt(i->image, x, y);
x += i->image.width() + kImagePadding;
}
} }
bool TabbedLauncherButton::OnMousePressed(const views::MouseEvent& event) { bool TabbedLauncherButton::OnMousePressed(const views::MouseEvent& event) {
......
...@@ -40,7 +40,11 @@ class TabbedLauncherButton : public views::CustomButton { ...@@ -40,7 +40,11 @@ class TabbedLauncherButton : public views::CustomButton {
LauncherButtonHost* host_; 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); DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton);
}; };
......
...@@ -117,7 +117,9 @@ ...@@ -117,7 +117,9 @@
<!-- Images only used by Aura. --> <!-- Images only used by Aura. -->
<if expr="pp_ifdef('use_aura')"> <if expr="pp_ifdef('use_aura')">
<include name="IDR_AURA_LAUNCHER_ICON_CHROME" file="aura/chromium-32.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_ICON_CHROME" file="aura/chromium-32.png" type="BINDATA" />
<include name="IDR_AURA_LAUNCHER_TABBED_BROWSER" file="aura/browser_instance.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_TABBED_BROWSER_1" file="aura/browser_instance_1.png" type="BINDATA" />
<include name="IDR_AURA_LAUNCHER_TABBED_BROWSER_2" file="aura/browser_instance_2.png" type="BINDATA" />
<include name="IDR_AURA_LAUNCHER_TABBED_BROWSER_3" file="aura/browser_instance_3.png" type="BINDATA" />
<include name="IDR_AURA_LAUNCHER_ICON_APPLIST" file="aura/applist.png" type="BINDATA" /> <include name="IDR_AURA_LAUNCHER_ICON_APPLIST" file="aura/applist.png" type="BINDATA" />
<include name="IDR_AURA_STATUS_MOCK" file="aura/statusbar.png" type="BINDATA" /> <include name="IDR_AURA_STATUS_MOCK" file="aura/statusbar.png" type="BINDATA" />
<include name="IDR_AURA_WALLPAPER" file="aura/damask.png" type="BINDATA" /> <include name="IDR_AURA_WALLPAPER" file="aura/damask.png" type="BINDATA" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment