summaryrefslogtreecommitdiffstats
path: root/ui/aura_shell
diff options
context:
space:
mode:
authorsaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-14 19:31:54 +0000
committersaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-14 19:31:54 +0000
commit88e31385ab21d4c197e81961e1dd9e16b1793bdb (patch)
treeb0536e8753a6b60c2ea01d8e601c585677eec7ca /ui/aura_shell
parentcc12785ecca7f7f346bde96b66a6eb3b4110cc08 (diff)
downloadchromium_src-88e31385ab21d4c197e81961e1dd9e16b1793bdb.zip
chromium_src-88e31385ab21d4c197e81961e1dd9e16b1793bdb.tar.gz
chromium_src-88e31385ab21d4c197e81961e1dd9e16b1793bdb.tar.bz2
Reverting issues 8873036 and issues 8933010
http://codereview.chromium.org/8933010/ caused a regression in interactive_ui_tests on Linux+Aura+ChromeOS http://codereview.chromium.org/8873036/ was rebased on the above and had to be reverted TBR=sky@chromium.org BUG=none TEST=none Review URL: http://codereview.chromium.org/8916010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura_shell')
-rw-r--r--ui/aura_shell/examples/aura_shell_main.cc5
-rw-r--r--ui/aura_shell/launcher/launcher.cc5
-rw-r--r--ui/aura_shell/launcher/launcher_view.cc97
-rw-r--r--ui/aura_shell/launcher/tabbed_launcher_button.cc72
-rw-r--r--ui/aura_shell/launcher/tabbed_launcher_button.h23
-rw-r--r--ui/aura_shell/shelf_layout_manager.cc2
-rw-r--r--ui/aura_shell/shell_delegate.h5
-rw-r--r--ui/aura_shell/test/test_shell_delegate.cc6
-rw-r--r--ui/aura_shell/test/test_shell_delegate.h1
-rw-r--r--ui/aura_shell/toplevel_layout_manager.cc9
10 files changed, 92 insertions, 133 deletions
diff --git a/ui/aura_shell/examples/aura_shell_main.cc b/ui/aura_shell/examples/aura_shell_main.cc
index 93363a8..0700047 100644
--- a/ui/aura_shell/examples/aura_shell_main.cc
+++ b/ui/aura_shell/examples/aura_shell_main.cc
@@ -7,7 +7,6 @@
#include "base/i18n/icu_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
-#include "grit/ui_resources.h"
#include "ui/aura/root_window.h"
#include "ui/aura_shell/examples/toplevel_window.h"
#include "ui/aura_shell/launcher/launcher_types.h"
@@ -93,10 +92,6 @@ class ShellDelegateImpl : public aura_shell::ShellDelegate {
image_count = (image_count + 1) % 3;
return true; // Makes the entry show up in the launcher.
}
-
- virtual int GetResourceIDForNewBrowserWindow() OVERRIDE {
- return IDR_AURA_LAUNCHER_ICON_CHROME;
- }
};
} // namespace
diff --git a/ui/aura_shell/launcher/launcher.cc b/ui/aura_shell/launcher/launcher.cc
index 7dddc94..8b0ae38 100644
--- a/ui/aura_shell/launcher/launcher.cc
+++ b/ui/aura_shell/launcher/launcher.cc
@@ -24,8 +24,9 @@ Launcher::Launcher(aura::Window* window_container)
widget_ = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
- params.create_texture_for_layer = true;
- params.transparent = true;
+ // All the content is drawn by the launcher buttons. Turn off the widget's
+ // layer's texture to avoid unnecessary memory use.
+ params.create_texture_for_layer = false;
params.parent = Shell::GetInstance()->GetContainer(
aura_shell::internal::kShellWindowId_LauncherContainer);
internal::LauncherView* launcher_view =
diff --git a/ui/aura_shell/launcher/launcher_view.cc b/ui/aura_shell/launcher/launcher_view.cc
index 7be436c..0cba08b 100644
--- a/ui/aura_shell/launcher/launcher_view.cc
+++ b/ui/aura_shell/launcher/launcher_view.cc
@@ -12,21 +12,18 @@
#include "ui/aura_shell/launcher/tabbed_launcher_button.h"
#include "ui/aura_shell/launcher/view_model.h"
#include "ui/aura_shell/launcher/view_model_utils.h"
-#include "ui/aura_shell/shelf_layout_manager.h"
#include "ui/aura_shell/shell.h"
#include "ui/aura_shell/shell_delegate.h"
#include "ui/base/animation/animation.h"
#include "ui/base/animation/throb_animation.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/canvas.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/image/image.h"
#include "ui/views/animation/bounds_animator.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
-#include "ui/views/painter.h"
#include "ui/views/widget/widget.h"
using ui::Animation;
@@ -85,6 +82,48 @@ class MenuDelegateImpl : public ui::SimpleMenuModel::Delegate {
DISALLOW_COPY_AND_ASSIGN(MenuDelegateImpl);
};
+// ImageButton subclass that animates transition changes using the opacity of
+// the layer.
+class FadeButton : public views::ImageButton {
+ public:
+ explicit FadeButton(views::ButtonListener* listener)
+ : ImageButton(listener) {
+ SetPaintToLayer(true);
+ layer()->SetFillsBoundsOpaquely(false);
+ layer()->SetOpacity(kDimmedButtonOpacity);
+ }
+
+ protected:
+ // ImageButton overrides:
+ virtual SkBitmap GetImageToPaint() OVERRIDE {
+ // ImageButton::GetImageToPaint returns an alpha blended image based on
+ // hover_animation_. FadeButton uses hover_animation to change the opacity
+ // of the layer, so this can be overriden to return the normal image always.
+ return images_[BS_NORMAL];
+ }
+ virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE {
+ layer()->SetOpacity(kDimmedButtonOpacity + (1.0f - kDimmedButtonOpacity) *
+ animation->GetCurrentValue());
+ layer()->ScheduleDraw();
+ }
+ virtual void StateChanged() OVERRIDE {
+ if (!hover_animation_->is_animating()) {
+ float opacity = state_ == BS_NORMAL ? kDimmedButtonOpacity : 1.0f;
+ if (layer()->opacity() != opacity) {
+ layer()->SetOpacity(opacity);
+ layer()->ScheduleDraw();
+ }
+ }
+ }
+ virtual void SchedulePaint() OVERRIDE {
+ // All changes we care about trigger a draw on the layer, so this can be
+ // overriden to do nothing.
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FadeButton);
+};
+
// AnimationDelegate that deletes a view when done. This is used when a launcher
// item is removed, which triggers a remove animation. When the animation is
// done we delete the view.
@@ -128,25 +167,6 @@ class FadeInAnimationDelegate :
DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate);
};
-// Used to draw the background of the shelf.
-class ShelfPainter : public views::Painter {
- public:
- ShelfPainter() {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- image_ = *rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND).ToSkBitmap();
- }
-
- virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE {
- canvas->TileImageInt(image_, 0, 0, w, h);
- }
-
- private:
- SkBitmap image_;
-
- DISALLOW_COPY_AND_ASSIGN(ShelfPainter);
-};
-
-
} // namespace
// AnimationDelegate used when inserting a new item. This steadily decreased the
@@ -224,18 +244,12 @@ LauncherView::~LauncherView() {
}
void LauncherView::Init() {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
model_->AddObserver(this);
-
- set_background(
- views::Background::CreateBackgroundPainter(true, new ShelfPainter()));
-
- new_browser_button_ = new views::ImageButton(this);
- int new_browser_button_image_id =
- Shell::GetInstance()->delegate()->GetResourceIDForNewBrowserWindow();
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ new_browser_button_ = new FadeButton(this);
new_browser_button_->SetImage(
views::CustomButton::BS_NORMAL,
- rb.GetImageNamed(new_browser_button_image_id).ToSkBitmap());
+ rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_CHROME).ToSkBitmap());
ConfigureChildView(new_browser_button_);
AddChildView(new_browser_button_);
@@ -247,29 +261,18 @@ void LauncherView::Init() {
AddChildView(child);
}
- show_apps_button_ = new views::ImageButton(this);
+ show_apps_button_ = new FadeButton(this);
show_apps_button_->SetImage(
views::CustomButton::BS_NORMAL,
rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST).ToSkBitmap());
- show_apps_button_->SetImage(
- views::CustomButton::BS_HOT,
- rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_HOT).ToSkBitmap());
- show_apps_button_->SetImage(
- views::CustomButton::BS_PUSHED,
- rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_PUSHED).ToSkBitmap());
ConfigureChildView(show_apps_button_);
AddChildView(show_apps_button_);
- overflow_button_ = new views::ImageButton(this);
+ overflow_button_ = new FadeButton(this);
+ // TODO: need image for this.
overflow_button_->SetImage(
views::CustomButton::BS_NORMAL,
rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW).ToSkBitmap());
- overflow_button_->SetImage(
- views::CustomButton::BS_HOT,
- rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW_HOT).ToSkBitmap());
- overflow_button_->SetImage(
- views::CustomButton::BS_PUSHED,
- rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW_PUSHED).ToSkBitmap());
ConfigureChildView(overflow_button_);
AddChildView(overflow_button_);
@@ -333,8 +336,8 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) {
(kPreferredHeight - bounds->overflow_bounds.height()) / 2);
x = bounds->overflow_bounds.right() + kHorizontalPadding;
}
- // TODO(sky): -6 is a hack, remove when we get better images.
- bounds->show_apps_bounds.set_x(x - 6);
+ // TODO(sky): -8 is a hack, remove when we get better images.
+ bounds->show_apps_bounds.set_x(x - 8);
bounds->show_apps_bounds.set_y(
(kPreferredHeight - bounds->show_apps_bounds.height()) / 2);
}
diff --git a/ui/aura_shell/launcher/tabbed_launcher_button.cc b/ui/aura_shell/launcher/tabbed_launcher_button.cc
index aac9205..f1a1e27 100644
--- a/ui/aura_shell/launcher/tabbed_launcher_button.cc
+++ b/ui/aura_shell/launcher/tabbed_launcher_button.cc
@@ -32,27 +32,23 @@ const int kBgBottomInset = 12;
const int kBgRightInset = 8;
// static
-TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_1_ = NULL;
-TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_2_ = NULL;
-TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_3_ = 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::ImageButton(listener),
+ : views::CustomButton(listener),
host_(host) {
if (!bg_image_1_) {
- bg_image_1_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_1,
- IDR_AURA_LAUNCHER_TABBED_BROWSER_1_PUSHED,
- IDR_AURA_LAUNCHER_TABBED_BROWSER_1_HOT);
- bg_image_2_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_2,
- IDR_AURA_LAUNCHER_TABBED_BROWSER_2_PUSHED,
- IDR_AURA_LAUNCHER_TABBED_BROWSER_2_HOT);
- bg_image_3_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_3,
- IDR_AURA_LAUNCHER_TABBED_BROWSER_3_PUSHED,
- IDR_AURA_LAUNCHER_TABBED_BROWSER_3_HOT);
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ 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());
}
- SetImageAlignment(views::ImageButton::ALIGN_CENTER,
- views::ImageButton::ALIGN_MIDDLE);
}
TabbedLauncherButton::~TabbedLauncherButton() {
@@ -60,20 +56,21 @@ TabbedLauncherButton::~TabbedLauncherButton() {
void TabbedLauncherButton::SetImages(const LauncherTabbedImages& images) {
images_ = images;
- ImageSet* set;
- if (images_.size() <= 1)
- set = bg_image_1_;
- else if (images_.size() == 2)
- set = bg_image_2_;
- else
- set = bg_image_3_;
- SetImage(BS_NORMAL, set->normal_image);
- SetImage(BS_HOT, set->hot_image);
- SetImage(BS_PUSHED, set->pushed_image);
+}
+
+gfx::Size TabbedLauncherButton::GetPreferredSize() {
+ return gfx::Size(bg_image_1_->width(), bg_image_1_->height());
}
void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) {
- ImageButton::OnPaint(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;
@@ -82,44 +79,31 @@ void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) {
// 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 + 1;
+ int y = (height() - images_[0].image.height()) / 2;
canvas->DrawBitmapInt(images_[0].image, x, y);
}
bool TabbedLauncherButton::OnMousePressed(const views::MouseEvent& event) {
- ImageButton::OnMousePressed(event);
+ CustomButton::OnMousePressed(event);
host_->MousePressedOnButton(this, event);
return true;
}
void TabbedLauncherButton::OnMouseReleased(const views::MouseEvent& event) {
host_->MouseReleasedOnButton(this, false);
- ImageButton::OnMouseReleased(event);
+ CustomButton::OnMouseReleased(event);
}
void TabbedLauncherButton::OnMouseCaptureLost() {
host_->MouseReleasedOnButton(this, true);
- ImageButton::OnMouseCaptureLost();
+ CustomButton::OnMouseCaptureLost();
}
bool TabbedLauncherButton::OnMouseDragged(const views::MouseEvent& event) {
- ImageButton::OnMouseDragged(event);
+ CustomButton::OnMouseDragged(event);
host_->MouseDraggedOnButton(this, event);
return true;
}
-// static
-TabbedLauncherButton::ImageSet* TabbedLauncherButton::CreateImageSet(
- int normal_id,
- int pushed_id,
- int hot_id) {
- ImageSet* set = new ImageSet;
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- set->normal_image = new SkBitmap(*rb.GetImageNamed(normal_id).ToSkBitmap());
- set->pushed_image = new SkBitmap(*rb.GetImageNamed(pushed_id).ToSkBitmap());
- set->hot_image = new SkBitmap(*rb.GetImageNamed(hot_id).ToSkBitmap());
- return set;
-}
-
} // 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
index a945074..5534e1f 100644
--- a/ui/aura_shell/launcher/tabbed_launcher_button.h
+++ b/ui/aura_shell/launcher/tabbed_launcher_button.h
@@ -7,7 +7,7 @@
#pragma once
#include "ui/aura_shell/launcher/launcher_types.h"
-#include "ui/views/controls/button/image_button.h"
+#include "ui/views/controls/button/custom_button.h"
namespace aura_shell {
namespace internal {
@@ -15,7 +15,7 @@ namespace internal {
class LauncherButtonHost;
// Button used for items on the launcher corresponding to tabbed windows.
-class TabbedLauncherButton : public views::ImageButton {
+class TabbedLauncherButton : public views::CustomButton {
public:
TabbedLauncherButton(views::ButtonListener* listener,
LauncherButtonHost* host);
@@ -24,6 +24,9 @@ class TabbedLauncherButton : public views::ImageButton {
// 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;
@@ -33,25 +36,15 @@ class TabbedLauncherButton : public views::ImageButton {
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
private:
- struct ImageSet {
- SkBitmap* normal_image;
- SkBitmap* pushed_image;
- SkBitmap* hot_image;
- };
-
- // Creates an ImageSet using the specified image ids. Caller owns the returned
- // value.
- static ImageSet* CreateImageSet(int normal_id, int pushed_id, int hot_id);
-
LauncherTabbedImages images_;
LauncherButtonHost* host_;
// Background images. Which one is chosen depends upon how many images are
// provided.
- static ImageSet* bg_image_1_;
- static ImageSet* bg_image_2_;
- static ImageSet* bg_image_3_;
+ static SkBitmap* bg_image_1_;
+ static SkBitmap* bg_image_2_;
+ static SkBitmap* bg_image_3_;
DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton);
};
diff --git a/ui/aura_shell/shelf_layout_manager.cc b/ui/aura_shell/shelf_layout_manager.cc
index d9f58e2..c422aa7 100644
--- a/ui/aura_shell/shelf_layout_manager.cc
+++ b/ui/aura_shell/shelf_layout_manager.cc
@@ -122,7 +122,7 @@ void ShelfLayoutManager::CalculateTargetBounds(bool visible,
gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds());
target_bounds->launcher_bounds = gfx::Rect(
available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2,
- available_bounds.width(),
+ available_bounds.width() - status_bounds.width(),
launcher_bounds.height());
if (visible)
target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0);
diff --git a/ui/aura_shell/shell_delegate.h b/ui/aura_shell/shell_delegate.h
index 1239bc8..3771b1a 100644
--- a/ui/aura_shell/shell_delegate.h
+++ b/ui/aura_shell/shell_delegate.h
@@ -50,11 +50,8 @@ class AURA_SHELL_EXPORT ShellDelegate {
// an entry for |item->window| it should configure |item| appropriately and
// return true.
virtual bool ConfigureLauncherItem(LauncherItem* item) = 0;
-
- // Returns the resource id of the image to show on the button that creates a
- // new browser window.
- virtual int GetResourceIDForNewBrowserWindow() = 0;
};
+
} // namespace aura_shell
#endif // UI_AURA_SHELL_SHELL_DELEGATE_H_
diff --git a/ui/aura_shell/test/test_shell_delegate.cc b/ui/aura_shell/test/test_shell_delegate.cc
index 98057f9..42414b7 100644
--- a/ui/aura_shell/test/test_shell_delegate.cc
+++ b/ui/aura_shell/test/test_shell_delegate.cc
@@ -4,8 +4,6 @@
#include "ui/aura_shell/test/test_shell_delegate.h"
-#include "grit/ui_resources.h"
-
namespace aura_shell {
namespace test {
@@ -34,9 +32,5 @@ bool TestShellDelegate::ConfigureLauncherItem(LauncherItem* item) {
return true;
}
-int TestShellDelegate::GetResourceIDForNewBrowserWindow() {
- return IDR_AURA_LAUNCHER_ICON_CHROME;
-}
-
} // namespace test
} // namespace aura_shell
diff --git a/ui/aura_shell/test/test_shell_delegate.h b/ui/aura_shell/test/test_shell_delegate.h
index 91a55b4..6811d45 100644
--- a/ui/aura_shell/test/test_shell_delegate.h
+++ b/ui/aura_shell/test/test_shell_delegate.h
@@ -25,7 +25,6 @@ class TestShellDelegate : public ShellDelegate {
const SetWidgetCallback& callback) OVERRIDE;
virtual void LauncherItemClicked(const LauncherItem& item) OVERRIDE;
virtual bool ConfigureLauncherItem(LauncherItem* item) OVERRIDE;
- virtual int GetResourceIDForNewBrowserWindow() OVERRIDE;
};
} // namespace test
diff --git a/ui/aura_shell/toplevel_layout_manager.cc b/ui/aura_shell/toplevel_layout_manager.cc
index 00b44aa..05d5f47 100644
--- a/ui/aura_shell/toplevel_layout_manager.cc
+++ b/ui/aura_shell/toplevel_layout_manager.cc
@@ -48,14 +48,7 @@ void ToplevelLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
void ToplevelLayoutManager::SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) {
- const static int kTitleHeight = 12;
- gfx::Rect child_bounds(requested_bounds);
- gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestWindow(child);
- if (child_bounds.y() < 0)
- child_bounds.set_y(0);
- else if (child_bounds.y() + kTitleHeight > work_area.bottom())
- child_bounds.set_y(work_area.bottom() - kTitleHeight);
- SetChildBoundsDirect(child, child_bounds);
+ SetChildBoundsDirect(child, requested_bounds);
}
void ToplevelLayoutManager::OnWindowPropertyChanged(aura::Window* window,