summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-14 03:44:34 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-14 03:44:34 +0000
commit2fcd9d2dbe87c349113ed6512f701ef101fc295f (patch)
treed6ca089ec5d334020404be435f413dffd6646daa /ui
parent9f2d2f4a768ea8edaf7a6ff2efa73214d25f6a61 (diff)
downloadchromium_src-2fcd9d2dbe87c349113ed6512f701ef101fc295f.zip
chromium_src-2fcd9d2dbe87c349113ed6512f701ef101fc295f.tar.gz
chromium_src-2fcd9d2dbe87c349113ed6512f701ef101fc295f.tar.bz2
Shrinks the launcher down to 48 pixels high, changes chromium image
appropriately, and gets browser window entry to match mocks. For aura_shell I'm randomly adding 3 images to test that it works. BUG=97262 TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/8274019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura_shell/aura_shell.gyp2
-rw-r--r--ui/aura_shell/examples/aura_shell_main.cc11
-rw-r--r--ui/aura_shell/launcher/launcher_view.cc21
-rw-r--r--ui/aura_shell/launcher/tabbed_launcher_button.cc94
-rw-r--r--ui/aura_shell/launcher/tabbed_launcher_button.h45
-rw-r--r--ui/resources/aura/chromium-32.pngbin0 -> 1180 bytes
-rw-r--r--ui/resources/aura/chromium-48.pngbin1790 -> 0 bytes
-rw-r--r--ui/resources/ui_resources.grd2
8 files changed, 169 insertions, 6 deletions
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index c009523..338992f 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -45,6 +45,8 @@
'launcher/launcher_types.h',
'launcher/launcher_view.cc',
'launcher/launcher_view.h',
+ 'launcher/tabbed_launcher_button.cc',
+ 'launcher/tabbed_launcher_button.h',
'shell.cc',
'shell.h',
'shell_delegate.h',
diff --git a/ui/aura_shell/examples/aura_shell_main.cc b/ui/aura_shell/examples/aura_shell_main.cc
index 1d02144..486554b 100644
--- a/ui/aura_shell/examples/aura_shell_main.cc
+++ b/ui/aura_shell/examples/aura_shell_main.cc
@@ -40,6 +40,17 @@ class ShellDelegateImpl : public aura_shell::ShellDelegate {
}
virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE {
+ static int image_count = 0;
+ item->tab_images.resize(image_count + 1);
+ for (int i = 0; i < image_count + 1; ++i) {
+ item->tab_images[i].image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
+ item->tab_images[i].image.allocPixels();
+ item->tab_images[i].image.eraseARGB(255,
+ i == 0 ? 255 : 0,
+ i == 1 ? 255 : 0,
+ i == 2 ? 255 : 0);
+ }
+ image_count = (image_count + 1) % 3;
return true; // Makes the entry show up in the launcher.
}
};
diff --git a/ui/aura_shell/launcher/launcher_view.cc b/ui/aura_shell/launcher/launcher_view.cc
index 22b44a5..ed2f362 100644
--- a/ui/aura_shell/launcher/launcher_view.cc
+++ b/ui/aura_shell/launcher/launcher_view.cc
@@ -7,6 +7,7 @@
#include "base/utf_string_conversions.h"
#include "grit/ui_resources.h"
#include "ui/aura_shell/launcher/launcher_model.h"
+#include "ui/aura_shell/launcher/tabbed_launcher_button.h"
#include "ui/aura_shell/shell.h"
#include "ui/aura_shell/shell_delegate.h"
#include "ui/base/resource/resource_bundle.h"
@@ -22,9 +23,12 @@ namespace internal {
// Padding between each view.
static const int kHorizontalPadding = 12;
+// Amount content is inset on the left edge.
+static const int kLeadingInset = 8;
+
// Height of the LauncherView. Hard coded to avoid resizing as items are
// added/removed.
-static const int kPreferredHeight = 64;
+static const int kPreferredHeight = 48;
LauncherView::LauncherView(LauncherModel* model)
: model_(model),
@@ -58,7 +62,11 @@ void LauncherView::Init() {
}
views::View* LauncherView::CreateViewForItem(const LauncherItem& item) {
- // TODO: need to support images.
+ if (item.type == TYPE_TABBED) {
+ TabbedLauncherButton* button = new TabbedLauncherButton(this);
+ button->SetImages(item.tab_images);
+ return button;
+ }
views::ImageButton* button = new views::ImageButton(this);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
button->SetImage(
@@ -74,8 +82,7 @@ void LauncherView::Resize() {
}
void LauncherView::Layout() {
- // TODO: need to deal with overflow.
- int x = kHorizontalPadding;
+ int x = kLeadingInset;
for (int i = 0; i < child_count(); ++i) {
View* child = child_at(i);
if (child->IsVisible()) {
@@ -85,10 +92,12 @@ void LauncherView::Layout() {
x += child->width() + kHorizontalPadding;
}
}
+ // TODO: remove this when we get a better image.
+ show_apps_button_->SetX(show_apps_button_->x() - 8);
}
gfx::Size LauncherView::GetPreferredSize() {
- int x = kHorizontalPadding;
+ int x = kLeadingInset;
for (int i = 0; i < child_count(); ++i) {
View* child = child_at(i);
if (child->IsVisible()) {
@@ -96,6 +105,8 @@ gfx::Size LauncherView::GetPreferredSize() {
x += pref_size.width() + kHorizontalPadding;
}
}
+ // TODO: remove this when we get a better image.
+ x -= 10;
return gfx::Size(x, kPreferredHeight);
}
diff --git a/ui/aura_shell/launcher/tabbed_launcher_button.cc b/ui/aura_shell/launcher/tabbed_launcher_button.cc
new file mode 100644
index 0000000..5106688
--- /dev/null
+++ b/ui/aura_shell/launcher/tabbed_launcher_button.cc
@@ -0,0 +1,94 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura_shell/launcher/tabbed_launcher_button.h"
+
+#include <algorithm>
+
+#include "grit/ui_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+#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
+// the edge.
+const int kBgImageContentInset = 12;
+
+// Insets used in painting the background if it's rendered bigger than the size
+// of the background image. See ImagePainter::CreateImagePainter for how these
+// are interpreted.
+const int kBgTopInset = 12;
+const int kBgLeftInset = 30;
+const int kBgBottomInset = 12;
+const int kBgRightInset = 8;
+
+// static
+SkBitmap* TabbedLauncherButton::bg_image_ = NULL;
+
+TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener)
+ : views::CustomButton(listener) {
+ if (!bg_image_) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ bg_image_ = new SkBitmap(
+ *rb.GetImageNamed(IDR_AURA_LAUNCHER_TABBED_BROWSER).ToSkBitmap());
+ }
+}
+
+TabbedLauncherButton::~TabbedLauncherButton() {
+}
+
+void TabbedLauncherButton::SetImages(const LauncherTabbedImages& images) {
+ images_ = 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());
+ return gfx::Size(
+ std::max(kBgImageContentInset * 2 + images_[0].image.width() * num_images,
+ bg_image_->width()),
+ bg_image_->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);
+ }
+
+ if (images_.empty())
+ return;
+
+ int num_images = static_cast<int>(images_.size());
+ int x = std::max(kBgImageContentInset,
+ (width() - num_images * 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();
+ }
+}
+
+void TabbedLauncherButton::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
+ // TODO: something interesting here.
+}
+
+} // namespace internal
+} // namespace aura_shell
diff --git a/ui/aura_shell/launcher/tabbed_launcher_button.h b/ui/aura_shell/launcher/tabbed_launcher_button.h
new file mode 100644
index 0000000..df987f7
--- /dev/null
+++ b/ui/aura_shell/launcher/tabbed_launcher_button.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
+#define UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
+#pragma once
+
+#include "ui/aura_shell/launcher/launcher_types.h"
+#include "views/controls/button/custom_button.h"
+
+namespace aura_shell {
+namespace internal {
+
+// Button used for items on the launcher corresponding to tabbed windows.
+class TabbedLauncherButton : public views::CustomButton {
+ public:
+ explicit TabbedLauncherButton(views::ButtonListener* listener);
+ virtual ~TabbedLauncherButton();
+
+ // Sets the images to display for this entry.
+ void SetImages(const LauncherTabbedImages& images);
+
+ // View overrides:
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ protected:
+ // View overrides:
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual void ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) OVERRIDE;
+
+ private:
+ LauncherTabbedImages images_;
+
+ static SkBitmap* bg_image_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton);
+};
+
+} // namespace internal
+} // namespace aura_shell
+
+#endif // UI_AURA_SHELL_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_
diff --git a/ui/resources/aura/chromium-32.png b/ui/resources/aura/chromium-32.png
new file mode 100644
index 0000000..5e3adba
--- /dev/null
+++ b/ui/resources/aura/chromium-32.png
Binary files differ
diff --git a/ui/resources/aura/chromium-48.png b/ui/resources/aura/chromium-48.png
deleted file mode 100644
index 9085a79..0000000
--- a/ui/resources/aura/chromium-48.png
+++ /dev/null
Binary files differ
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index dcb3a99..ab8899e 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -116,7 +116,7 @@
<!-- Images only used by Aura. -->
<if expr="pp_ifdef('use_aura')">
- <include name="IDR_AURA_LAUNCHER_ICON_CHROME" file="aura/chromium-48.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_ICON_APPLIST" file="aura/applist.png" type="BINDATA" />
<include name="IDR_AURA_STATUS_MOCK" file="aura/statusbar.png" type="BINDATA" />