diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 02:18:17 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 02:18:17 +0000 |
commit | e8a097b80123a7e0f4b379d3cb76ff272e0cdfff (patch) | |
tree | 3ee658c80b83851a045cdcd5afa2fd6d39df53fc /ash | |
parent | 6009ca9cf529d88a9fff4509dccb424a3ee0a57f (diff) | |
download | chromium_src-e8a097b80123a7e0f4b379d3cb76ff272e0cdfff.zip chromium_src-e8a097b80123a7e0f4b379d3cb76ff272e0cdfff.tar.gz chromium_src-e8a097b80123a7e0f4b379d3cb76ff272e0cdfff.tar.bz2 |
Removes support for multiple images from launcher. Doesn't look like
we're going to use it, so I'm nuking it. This also fixes the bug where
we would only even show one tab in the launcher even though the window
had more than one.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: http://codereview.chromium.org/9139077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/launcher/launcher_model.cc | 24 | ||||
-rw-r--r-- | ash/launcher/launcher_model.h | 12 | ||||
-rw-r--r-- | ash/launcher/launcher_model_observer.h | 12 | ||||
-rw-r--r-- | ash/launcher/launcher_model_unittest.cc | 35 | ||||
-rw-r--r-- | ash/launcher/launcher_types.cc | 8 | ||||
-rw-r--r-- | ash/launcher/launcher_types.h | 31 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 14 | ||||
-rw-r--r-- | ash/launcher/launcher_view.h | 6 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.cc | 21 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.h | 7 | ||||
-rw-r--r-- | ash/shell/shell_main.cc | 16 | ||||
-rw-r--r-- | ash/wm/workspace_controller.cc | 4 | ||||
-rw-r--r-- | ash/wm/workspace_controller.h | 6 |
13 files changed, 79 insertions, 117 deletions
diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc index 9f5c659..c1778fa 100644 --- a/ash/launcher/launcher_model.cc +++ b/ash/launcher/launcher_model.cc @@ -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. @@ -39,26 +39,20 @@ void LauncherModel::Move(int index, int target_index) { LauncherItemMoved(index, target_index)); } -void LauncherModel::SetTabbedImages(int index, - const LauncherTabbedImages& images) { +void LauncherModel::Set(int index, const LauncherItem& item) { DCHECK(index >= 0 && index < item_count()); - DCHECK_EQ(TYPE_TABBED, items_[index].type); - items_[index].tab_images = images; + LauncherItemType type = items_[index].type; + aura::Window* window = items_[index].window; + items_[index] = item; + items_[index].type = type; + items_[index].window = window; FOR_EACH_OBSERVER(LauncherModelObserver, observers_, - LauncherItemImagesChanged(index)); -} - -void LauncherModel::SetAppImage(int index, const SkBitmap& image) { - DCHECK(index >= 0 && index < item_count()); - DCHECK_EQ(TYPE_APP, items_[index].type); - items_[index].app_image = image; - FOR_EACH_OBSERVER(LauncherModelObserver, observers_, - LauncherItemImagesChanged(index)); + LauncherItemChanged(index)); } void LauncherModel::SetPendingUpdate(int index) { FOR_EACH_OBSERVER(LauncherModelObserver, observers_, - LauncherItemImagesWillChange(index)); + LauncherItemWillChange(index)); } int LauncherModel::ItemIndexByWindow(aura::Window* window) { diff --git a/ash/launcher/launcher_model.h b/ash/launcher/launcher_model.h index 231493a..0a5abeb 100644 --- a/ash/launcher/launcher_model.h +++ b/ash/launcher/launcher_model.h @@ -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. @@ -36,12 +36,12 @@ class ASH_EXPORT LauncherModel { // of the model *after* the item at |index| is removed. void Move(int index, int target_index); - // Changes the images of the specified item. - void SetTabbedImages(int index, const LauncherTabbedImages& images); - void SetAppImage(int index, const SkBitmap& image); + // Reset everything but the type and window of the item at the specified + // index. + void Set(int index, const LauncherItem& item); - // Sends LauncherItemImagesWillChange() to the observers. Used when the images - // are going to change for an item, but not for a while. + // Sends LauncherItemWillChange() to the observers. Used when the images are + // going to change for an item, but not for a while. void SetPendingUpdate(int index); // Returns the index of the item with the specified window. diff --git a/ash/launcher/launcher_model_observer.h b/ash/launcher/launcher_model_observer.h index 817dc9b..e79b5f8 100644 --- a/ash/launcher/launcher_model_observer.h +++ b/ash/launcher/launcher_model_observer.h @@ -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. @@ -23,12 +23,12 @@ class ASH_EXPORT LauncherModelObserver { // of the arguments. virtual void LauncherItemMoved(int start_index, int target_index) = 0; - // Invoked when the images of an item change. - virtual void LauncherItemImagesChanged(int index) = 0; + // Invoked when the the state of an item changes. The type is the same, but + // the number of images or image may have changed. + virtual void LauncherItemChanged(int index) = 0; - // Signals that LauncherItemImagesChanged() is going to be sent in the - // near future. - virtual void LauncherItemImagesWillChange(int index) = 0; + // Signals that LauncherItemChanged() is going to be sent in the near future. + virtual void LauncherItemWillChange(int index) = 0; protected: virtual ~LauncherModelObserver() {} diff --git a/ash/launcher/launcher_model_unittest.cc b/ash/launcher/launcher_model_unittest.cc index 0ace0be..e332a29 100644 --- a/ash/launcher/launcher_model_unittest.cc +++ b/ash/launcher/launcher_model_unittest.cc @@ -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. @@ -18,7 +18,7 @@ class TestLauncherModelObserver : public LauncherModelObserver { TestLauncherModelObserver() : added_count_(0), removed_count_(0), - images_changed_count_(0), + changed_count_(0), moved_count_(0) { } @@ -28,9 +28,9 @@ class TestLauncherModelObserver : public LauncherModelObserver { std::string result; AddToResult("added=%d", added_count_, &result); AddToResult("removed=%d", removed_count_, &result); - AddToResult("images_changed=%d", images_changed_count_, &result); + AddToResult("changed=%d", changed_count_, &result); AddToResult("moved=%d", moved_count_, &result); - added_count_ = removed_count_ = images_changed_count_ = moved_count_ = 0; + added_count_ = removed_count_ = changed_count_ = moved_count_ = 0; return result; } @@ -41,13 +41,13 @@ class TestLauncherModelObserver : public LauncherModelObserver { virtual void LauncherItemRemoved(int index) OVERRIDE { removed_count_++; } - virtual void LauncherItemImagesChanged(int index) OVERRIDE { - images_changed_count_++; + virtual void LauncherItemChanged(int index) OVERRIDE { + changed_count_++; } virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE { moved_count_++; } - virtual void LauncherItemImagesWillChange(int index) OVERRIDE { + virtual void LauncherItemWillChange(int index) OVERRIDE { } private: @@ -61,7 +61,7 @@ class TestLauncherModelObserver : public LauncherModelObserver { int added_count_; int removed_count_; - int images_changed_count_; + int changed_count_; int moved_count_; DISALLOW_COPY_AND_ASSIGN(TestLauncherModelObserver); @@ -81,42 +81,37 @@ TEST(LauncherModel, BasicAssertions) { observer.StateStringAndClear()); // Change a tabbed image. - model.SetTabbedImages(0, LauncherTabbedImages()); - EXPECT_EQ("images_changed=1", - observer.StateStringAndClear()); + model.Set(0, LauncherItem()); + EXPECT_EQ("changed=1", observer.StateStringAndClear()); // Remove the item. model.RemoveItemAt(0); EXPECT_EQ(0, model.item_count()); EXPECT_EQ("removed=1", observer.StateStringAndClear()); + EXPECT_EQ(TYPE_TABBED, model.items()[0].type); // Add an app item. item.type = TYPE_APP; - item.user_data = reinterpret_cast<void*>(1); model.Add(0, item); observer.StateStringAndClear(); - // Change an app image. - model.SetAppImage(0, SkBitmap()); - EXPECT_EQ("images_changed=1", observer.StateStringAndClear()); + // Change everything. + model.Set(0, item); + EXPECT_EQ("changed=1", observer.StateStringAndClear()); + EXPECT_EQ(TYPE_APP, model.items()[0].type); // Add another item. item.type = TYPE_APP; - item.user_data = reinterpret_cast<void*>(2); model.Add(1, item); observer.StateStringAndClear(); // Move the second item to be first. model.Move(1, 0); EXPECT_EQ("moved=1", observer.StateStringAndClear()); - EXPECT_EQ(reinterpret_cast<void*>(2), model.items()[0].user_data); - EXPECT_EQ(reinterpret_cast<void*>(1), model.items()[1].user_data); // Move the first item to the second item. model.Move(0, 1); EXPECT_EQ("moved=1", observer.StateStringAndClear()); - EXPECT_EQ(reinterpret_cast<void*>(1), model.items()[0].user_data); - EXPECT_EQ(reinterpret_cast<void*>(2), model.items()[1].user_data); } } // namespace ash diff --git a/ash/launcher/launcher_types.cc b/ash/launcher/launcher_types.cc index ca6e932..036fb36 100644 --- a/ash/launcher/launcher_types.cc +++ b/ash/launcher/launcher_types.cc @@ -9,15 +9,13 @@ namespace ash { LauncherItem::LauncherItem() : type(TYPE_TABBED), window(NULL), - user_data(NULL) { + num_tabs(1) { } -LauncherItem::LauncherItem(LauncherItemType type, - aura::Window* window, - void* user_data) +LauncherItem::LauncherItem(LauncherItemType type, aura::Window* window) : type(type), window(window), - user_data(user_data) { + num_tabs(1) { } LauncherItem::~LauncherItem() { diff --git a/ash/launcher/launcher_types.h b/ash/launcher/launcher_types.h index 93c7876..4bcb4b5 100644 --- a/ash/launcher/launcher_types.h +++ b/ash/launcher/launcher_types.h @@ -23,39 +23,20 @@ enum ASH_EXPORT LauncherItemType { TYPE_APP }; -// Represents an image in a launcher item of type TYPE_APP. -struct ASH_EXPORT LauncherTabbedImage { - LauncherTabbedImage() : user_data(NULL) {} - LauncherTabbedImage(const SkBitmap& image, void* user_data) - : image(image), - user_data(user_data) { - } - - // The image to show. - SkBitmap image; - - // Used to identify the image. - void* user_data; -}; - -typedef std::vector<LauncherTabbedImage> LauncherTabbedImages; - struct ASH_EXPORT LauncherItem { LauncherItem(); - LauncherItem(LauncherItemType type, - aura::Window* window, - void* user_data); + LauncherItem(LauncherItemType type, aura::Window* window); ~LauncherItem(); LauncherItemType type; aura::Window* window; - void* user_data; - // Image to display in the launcher if the item is of type TYPE_APP. - SkBitmap app_image; + // Number of tabs. Only used if this is TYPE_TABBED. + int num_tabs; - // Image to display in the launcher if the item is of type TYPE_TABBED. - LauncherTabbedImages tab_images; + // Image to display in the launcher. If this item is TYPE_TABBED the image is + // a favicon image. + SkBitmap image; }; typedef std::vector<LauncherItem> LauncherItems; diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index 9920072..cc047cb 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -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. @@ -344,12 +344,12 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { views::View* view = NULL; if (item.type == TYPE_TABBED) { TabbedLauncherButton* button = new TabbedLauncherButton(this, this); - button->SetImages(item.tab_images); + button->SetTabImage(item.image, item.num_tabs); view = button; } else { DCHECK_EQ(TYPE_APP, item.type); AppLauncherButton* button = new AppLauncherButton(this, this); - button->SetAppImage(item.app_image); + button->SetAppImage(item.image); view = button; } ConfigureChildView(view); @@ -514,13 +514,13 @@ void LauncherView::LauncherItemRemoved(int model_index) { view, new FadeOutAnimationDelegate(this, view), true); } -void LauncherView::LauncherItemImagesChanged(int model_index) { +void LauncherView::LauncherItemChanged(int model_index) { const LauncherItem& item(model_->items()[model_index]); views::View* view = view_model_->view_at(model_index); if (item.type == TYPE_TABBED) { TabbedLauncherButton* button = static_cast<TabbedLauncherButton*>(view); gfx::Size pref = button->GetPreferredSize(); - button->SetImages(item.tab_images); + button->SetTabImage(item.image, item.num_tabs); if (pref != button->GetPreferredSize()) AnimateToIdealBounds(); else @@ -528,7 +528,7 @@ void LauncherView::LauncherItemImagesChanged(int model_index) { } else { DCHECK_EQ(TYPE_APP, item.type); AppLauncherButton* button = static_cast<AppLauncherButton*>(view); - button->SetAppImage(item.app_image); + button->SetAppImage(item.image); button->SchedulePaint(); } } @@ -538,7 +538,7 @@ void LauncherView::LauncherItemMoved(int start_index, int target_index) { AnimateToIdealBounds(); } -void LauncherView::LauncherItemImagesWillChange(int index) { +void LauncherView::LauncherItemWillChange(int index) { const LauncherItem& item(model_->items()[index]); views::View* view = view_model_->view_at(index); if (item.type == TYPE_TABBED) diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index 782f1cf..78b502bc 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -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. @@ -94,9 +94,9 @@ class LauncherView : public views::WidgetDelegateView, // Overridden from LauncherModelObserver: virtual void LauncherItemAdded(int model_index) OVERRIDE; virtual void LauncherItemRemoved(int model_index) OVERRIDE; - virtual void LauncherItemImagesChanged(int model_index) OVERRIDE; + virtual void LauncherItemChanged(int model_index) OVERRIDE; virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; - virtual void LauncherItemImagesWillChange(int index) OVERRIDE; + virtual void LauncherItemWillChange(int index) OVERRIDE; // Overridden from LauncherButtonHost: virtual void MousePressedOnButton(views::View* view, diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc index 61a2d5a..71214d0 100644 --- a/ash/launcher/tabbed_launcher_button.cc +++ b/ash/launcher/tabbed_launcher_button.cc @@ -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. @@ -98,14 +98,14 @@ void TabbedLauncherButton::PrepareForImageChange() { animation_->Start(); } -void TabbedLauncherButton::SetImages(const LauncherTabbedImages& images) { +void TabbedLauncherButton::SetTabImage(const SkBitmap& image, int count) { animation_.reset(); show_image_ = true; - images_ = images; + image_ = image; ImageSet* set; - if (images_.size() <= 1) + if (count <= 1) set = bg_image_1_; - else if (images_.size() == 2) + else if (count == 2) set = bg_image_2_; else set = bg_image_3_; @@ -120,7 +120,7 @@ void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) { hover_controller_.Draw(canvas, *bg_image_1_->normal_image); - if (images_.empty() || images_[0].image.empty() || !show_image_) + if (image_.empty() || !show_image_) return; bool save_layer = (animation_.get() && animation_->is_animating() && @@ -128,12 +128,9 @@ void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) { if (save_layer) canvas->SaveLayerAlpha(animation_->CurrentValueBetween(255, 0)); - // 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 + 1; - canvas->DrawBitmapInt(images_[0].image, x, y); + int x = (width() - image_.width()) / 2; + int y = (height() - image_.height()) / 2 + 1; + canvas->DrawBitmapInt(image_, x, y); if (save_layer) canvas->Restore(); diff --git a/ash/launcher/tabbed_launcher_button.h b/ash/launcher/tabbed_launcher_button.h index 3a42951..c950a11 100644 --- a/ash/launcher/tabbed_launcher_button.h +++ b/ash/launcher/tabbed_launcher_button.h @@ -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. @@ -6,7 +6,6 @@ #define ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ #pragma once -#include "ash/launcher/launcher_types.h" #include "base/memory/scoped_ptr.h" #include "base/timer.h" #include "ui/base/animation/animation_delegate.h" @@ -33,7 +32,7 @@ class TabbedLauncherButton : public views::ImageButton { void PrepareForImageChange(); // Sets the images to display for this entry. - void SetImages(const LauncherTabbedImages& images); + void SetTabImage(const SkBitmap& image, int count); protected: // View overrides: @@ -75,7 +74,7 @@ class TabbedLauncherButton : public views::ImageButton { // value. static ImageSet* CreateImageSet(int normal_id, int pushed_id, int hot_id); - LauncherTabbedImages images_; + SkBitmap image_; LauncherButtonHost* host_; diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc index bf26a4e..a002c5e 100644 --- a/ash/shell/shell_main.cc +++ b/ash/shell/shell_main.cc @@ -81,15 +81,13 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual bool ConfigureLauncherItem(ash::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); - } + item->num_tabs = image_count + 1; + item->image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); + item->image.allocPixels(); + item->image.eraseARGB(255, + image_count == 0 ? 255 : 0, + image_count == 1 ? 255 : 0, + image_count == 2 ? 255 : 0); image_count = (image_count + 1) % 3; return true; // Makes the entry show up in the launcher. } diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc index 7cfa2eb..0514a87 100644 --- a/ash/wm/workspace_controller.cc +++ b/ash/wm/workspace_controller.cc @@ -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. @@ -120,7 +120,7 @@ void WorkspaceController::LauncherItemMoved(int start_index, int target_index) { ignore_move_event_ = false; } -void WorkspaceController::LauncherItemImagesChanged(int index) { +void WorkspaceController::LauncherItemChanged(int index) { } } // namespace internal diff --git a/ash/wm/workspace_controller.h b/ash/wm/workspace_controller.h index d1304f4..f17a395 100644 --- a/ash/wm/workspace_controller.h +++ b/ash/wm/workspace_controller.h @@ -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. @@ -69,8 +69,8 @@ class ASH_EXPORT WorkspaceController : virtual void LauncherItemAdded(int index) OVERRIDE; virtual void LauncherItemRemoved(int index) OVERRIDE; virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; - virtual void LauncherItemImagesChanged(int index) OVERRIDE; - virtual void LauncherItemImagesWillChange(int index) OVERRIDE {} + virtual void LauncherItemChanged(int index) OVERRIDE; + virtual void LauncherItemWillChange(int index) OVERRIDE {} private: scoped_ptr<WorkspaceManager> workspace_manager_; |