Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: ui/aura_shell/launcher/tabbed_launcher_button.cc

Issue 8418006: Changes around the launcher so that it only shows the most recently (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/launcher/tabbed_launcher_button.h ('k') | ui/resources/aura/browser_instance.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « ui/aura_shell/launcher/tabbed_launcher_button.h ('k') | ui/resources/aura/browser_instance.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698