Skip to content

Commit

Permalink
Tweaks for the launcher:
Browse files Browse the repository at this point in the history
. App list and browser shortcut buttons can be moved around.
. Clicking the tabbed button cycles windows (creating a new one if
  there isn't one).

BUG=110094
TEST=see bug
R=ben@chromium.org,jamescook@chromium.org


Review URL: http://codereview.chromium.org/9231030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118112 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sky@chromium.org committed Jan 18, 2012
1 parent 783eb30 commit 194ad1d
Show file tree
Hide file tree
Showing 24 changed files with 443 additions and 186 deletions.
4 changes: 4 additions & 0 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
'launcher/launcher_types.h',
'launcher/launcher_view.cc',
'launcher/launcher_view.h',
'launcher/launcher_window_cycler.cc',
'launcher/launcher_window_cycler.h',
'launcher/tabbed_launcher_button.cc',
'launcher/tabbed_launcher_button.h',
'launcher/view_model.cc',
Expand Down Expand Up @@ -147,6 +149,8 @@
'wm/toplevel_window_event_filter.h',
'wm/window_cycle_controller.cc',
'wm/window_cycle_controller.h',
'wm/window_cycle_list.cc',
'wm/window_cycle_list.h',
'wm/window_frame.cc',
'wm/window_frame.h',
'wm/window_modality_controller.cc',
Expand Down
8 changes: 6 additions & 2 deletions ash/launcher/app_launcher_button.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.

Expand All @@ -19,7 +19,6 @@ AppLauncherButton::AppLauncherButton(views::ButtonListener* listener,
LauncherButtonHost* host)
: views::ImageButton(listener),
host_(host) {
SetPreferredSize(gfx::Size(kImageSize, kImageSize));
SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
}
Expand Down Expand Up @@ -76,5 +75,10 @@ bool AppLauncherButton::OnMouseDragged(const views::MouseEvent& event) {
return true;
}

void AppLauncherButton::OnMouseExited(const views::MouseEvent& event) {
ImageButton::OnMouseExited(event);
host_->MouseExitedButton(this);
}

} // namespace internal
} // namespace ash
6 changes: 4 additions & 2 deletions ash/launcher/app_launcher_button.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.

Expand All @@ -13,7 +13,8 @@ namespace internal {

class LauncherButtonHost;

// Button used for items on the launcher corresponding to an app window.
// Button used for items on the launcher corresponding to an app window as
// well as one of the preset types (TYPE_APP_LIST or TYPE_BROWSER_SHORTCUT).
class AppLauncherButton : public views::ImageButton {
public:
AppLauncherButton(views::ButtonListener* listener,
Expand All @@ -29,6 +30,7 @@ class AppLauncherButton : public views::ImageButton {
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;

private:
LauncherButtonHost* host_;
Expand Down
5 changes: 4 additions & 1 deletion ash/launcher/launcher_button_host.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.

Expand Down Expand Up @@ -30,6 +30,9 @@ class LauncherButtonHost {
virtual void MouseReleasedOnButton(views::View* view,
bool canceled) = 0;

// Invoked when the mouse exits the item.
virtual void MouseExitedButton(views::View* view) = 0;

protected:
virtual ~LauncherButtonHost() {}
};
Expand Down
5 changes: 5 additions & 0 deletions ash/launcher/launcher_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace ash {

LauncherModel::LauncherModel() {
Add(0, LauncherItem(TYPE_APP_LIST, NULL));
Add(1, LauncherItem(TYPE_BROWSER_SHORTCUT, NULL));
}

LauncherModel::~LauncherModel() {
Expand All @@ -24,6 +26,9 @@ void LauncherModel::Add(int index, const LauncherItem& item) {

void LauncherModel::RemoveItemAt(int index) {
DCHECK(index >= 0 && index < item_count());
// The app list and browser shortcut can't be removed.
DCHECK(items_[index].type != TYPE_APP_LIST &&
items_[index].type != TYPE_BROWSER_SHORTCUT);
items_.erase(items_.begin() + index);
FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
LauncherItemRemoved(index));
Expand Down
8 changes: 6 additions & 2 deletions ash/launcher/launcher_model_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ class TestLauncherModelObserver : public LauncherModelObserver {
TEST(LauncherModel, BasicAssertions) {
TestLauncherModelObserver observer;
LauncherModel model;

// Model is initially populated with two items.
EXPECT_EQ(2, model.item_count());

// Add an item.
model.AddObserver(&observer);
LauncherItem item;
model.Add(0, item);
EXPECT_EQ(1, model.item_count());
EXPECT_EQ(3, model.item_count());
EXPECT_EQ("added=1",
observer.StateStringAndClear());

Expand All @@ -87,7 +91,7 @@ TEST(LauncherModel, BasicAssertions) {

// Remove the item.
model.RemoveItemAt(0);
EXPECT_EQ(0, model.item_count());
EXPECT_EQ(2, model.item_count());
EXPECT_EQ("removed=1", observer.StateStringAndClear());

// Add an app item.
Expand Down
11 changes: 10 additions & 1 deletion ash/launcher/launcher_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ namespace ash {

// Type the LauncherItem represents.
enum ASH_EXPORT LauncherItemType {
// Represents a tabbed browser.
TYPE_TABBED,
TYPE_APP

// Represents an app window.
TYPE_APP,

// Toggles visiblity of the app list.
TYPE_APP_LIST,

// The browser shortcut button.
TYPE_BROWSER_SHORTCUT,
};

struct ASH_EXPORT LauncherItem {
Expand Down
Loading

0 comments on commit 194ad1d

Please sign in to comment.