summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorharrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-02 00:25:04 +0000
committerharrym@chromium.org <harrym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-02 00:25:04 +0000
commit2ff9e6ce7a34ef362fe00f0f33eb109cad2d6e89 (patch)
tree2e4fc174ba5831e48c11d59491fab9e684f4068d /ash
parenta4ca8afc664596d6141e827dd8a7ad674bddb4d7 (diff)
downloadchromium_src-2ff9e6ce7a34ef362fe00f0f33eb109cad2d6e89.zip
chromium_src-2ff9e6ce7a34ef362fe00f0f33eb109cad2d6e89.tar.gz
chromium_src-2ff9e6ce7a34ef362fe00f0f33eb109cad2d6e89.tar.bz2
App list icon changes
Create a separate flow for the app list icon (behind alternate-shelf-layout flag) whereby the app list icon has different state indication (background images), can be reordered, and defaults to be the first item in the launcher. BUG=244994 Review URL: https://chromiumcodereview.appspot.com/16831018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/launcher/alternate_app_list_button.cc137
-rw-r--r--ash/launcher/alternate_app_list_button.h58
-rw-r--r--ash/launcher/launcher_model.cc6
-rw-r--r--ash/launcher/launcher_view.cc89
-rw-r--r--ash/resources/ash_resources.grd4
-rw-r--r--ash/shelf/shelf_widget.cc2
-rw-r--r--ash/wm/app_list_controller.cc32
8 files changed, 293 insertions, 37 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 0082676..ddce2fc 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -129,6 +129,8 @@
'keyboard_overlay/keyboard_overlay_delegate.h',
'keyboard_overlay/keyboard_overlay_view.cc',
'keyboard_overlay/keyboard_overlay_view.h',
+ 'launcher/alternate_app_list_button.cc',
+ 'launcher/alternate_app_list_button.h',
'launcher/app_list_button.cc',
'launcher/app_list_button.h',
'launcher/launcher.cc',
diff --git a/ash/launcher/alternate_app_list_button.cc b/ash/launcher/alternate_app_list_button.cc
new file mode 100644
index 0000000..77f1184
--- /dev/null
+++ b/ash/launcher/alternate_app_list_button.cc
@@ -0,0 +1,137 @@
+// Copyright 2013 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 "ash/launcher/alternate_app_list_button.h"
+
+#include "ash/ash_switches.h"
+#include "ash/launcher/launcher_button_host.h"
+#include "ash/launcher/launcher_types.h"
+#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf_widget.h"
+#include "ash/shell.h"
+#include "grit/ash_resources.h"
+#include "grit/ash_strings.h"
+#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/compositor/layer.h"
+#include "ui/compositor/layer_animation_element.h"
+#include "ui/compositor/layer_animation_sequence.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/image/image_skia_operations.h"
+
+namespace ash {
+namespace internal {
+
+// static
+const int AlternateAppListButton::kImageBoundsSize = 7;
+
+
+AlternateAppListButton::AlternateAppListButton(views::ButtonListener* listener,
+ LauncherButtonHost* host,
+ ShelfWidget* shelf_widget)
+ : views::ImageButton(listener),
+ host_(host),
+ shelf_widget_(shelf_widget) {
+ SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE));
+ SetSize(gfx::Size(ShelfLayoutManager::kShelfSize,
+ ShelfLayoutManager::kShelfSize));
+}
+
+AlternateAppListButton::~AlternateAppListButton() {
+}
+
+bool AlternateAppListButton::OnMousePressed(const ui::MouseEvent& event) {
+ ImageButton::OnMousePressed(event);
+ host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event);
+ return true;
+}
+
+void AlternateAppListButton::OnMouseReleased(const ui::MouseEvent& event) {
+ ImageButton::OnMouseReleased(event);
+ host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, false);
+}
+
+void AlternateAppListButton::OnMouseCaptureLost() {
+ host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, true);
+ ImageButton::OnMouseCaptureLost();
+}
+
+bool AlternateAppListButton::OnMouseDragged(const ui::MouseEvent& event) {
+ ImageButton::OnMouseDragged(event);
+ host_->PointerDraggedOnButton(this, LauncherButtonHost::MOUSE, event);
+ return true;
+}
+
+void AlternateAppListButton::OnMouseMoved(const ui::MouseEvent& event) {
+ ImageButton::OnMouseMoved(event);
+ host_->MouseMovedOverButton(this);
+}
+
+void AlternateAppListButton::OnMouseEntered(const ui::MouseEvent& event) {
+ ImageButton::OnMouseEntered(event);
+ host_->MouseEnteredButton(this);
+}
+
+void AlternateAppListButton::OnMouseExited(const ui::MouseEvent& event) {
+ ImageButton::OnMouseExited(event);
+ host_->MouseExitedButton(this);
+}
+
+void AlternateAppListButton::OnPaint(gfx::Canvas* canvas) {
+ // Call the base class first to paint any background/borders.
+ View::OnPaint(canvas);
+
+ int background_image_id = 0;
+ if (Shell::GetInstance()->GetAppListTargetVisibility()) {
+ background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
+ } else {
+ if (shelf_widget_->GetDimsShelf())
+ background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK;
+ else
+ background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
+ }
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ const gfx::ImageSkia* background_image =
+ rb.GetImageNamed(background_image_id).ToImageSkia();
+ const gfx::ImageSkia* forground_image =
+ rb.GetImageNamed(IDR_AURA_LAUNCHER_ICON_APPLIST_ALTERNATE).ToImageSkia();
+
+ gfx::Rect contents_bounds = GetContentsBounds();
+ gfx::Rect background_bounds, forground_bounds;
+
+ background_bounds.set_x(contents_bounds.x() +
+ std::max(0,
+ (contents_bounds.width() - background_image->width()) / 2));
+ background_bounds.set_y(contents_bounds.y() +
+ std::max(kImageBoundsSize,
+ (contents_bounds.height() - background_image->height()) / 2));
+ background_bounds.set_size(background_image->size());
+
+ forground_bounds.set_size(forground_image->size());
+ forground_bounds.set_x(background_bounds.x() +
+ std::max(0,
+ (background_bounds.width() - forground_bounds.width()) / 2));
+ forground_bounds.set_y(background_bounds.y() +
+ std::max(0,
+ (background_bounds.height() - forground_bounds.height()) / 2));
+
+ canvas->DrawImageInt(*background_image,
+ background_bounds.x(),
+ background_bounds.y());
+ canvas->DrawImageInt(*forground_image,
+ forground_bounds.x(),
+ forground_bounds.y());
+
+ OnPaintFocusBorder(canvas);
+}
+
+void AlternateAppListButton::GetAccessibleState(
+ ui::AccessibleViewState* state) {
+ state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
+ state->name = host_->GetAccessibleName(this);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/launcher/alternate_app_list_button.h b/ash/launcher/alternate_app_list_button.h
new file mode 100644
index 0000000..f68207c
--- /dev/null
+++ b/ash/launcher/alternate_app_list_button.h
@@ -0,0 +1,58 @@
+// Copyright 2013 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 ASH_LAUNCHER_ALTERNATE_APP_LIST_BUTTON_H_
+#define ASH_LAUNCHER_ALTERNATE_APP_LIST_BUTTON_H_
+
+#include "ui/views/controls/button/image_button.h"
+
+namespace ash {
+
+class ShelfWidget;
+
+namespace internal {
+
+class LauncherButtonHost;
+
+
+
+// Button used for the AppList icon on the launcher.
+// This class is an alternate implementation to
+// ash::internal::AppListButton for the purposes of testing an
+// alternate shelf layout (see ash_switches: UseAlternateShelfLayout).
+class AlternateAppListButton : public views::ImageButton {
+ public:
+ // Bounds size (inset) required for the app icon image (in pixels).
+ static const int kImageBoundsSize;
+
+ AlternateAppListButton(views::ButtonListener* listener,
+ LauncherButtonHost* host,
+ ShelfWidget* shelf_widget);
+ virtual ~AlternateAppListButton();
+
+ protected:
+ // View overrides:
+ virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
+ virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
+
+ private:
+ LauncherButtonHost* host_;
+ // Reference to the shelf widget containing this button, owned by the
+ // root window controller.
+ ShelfWidget* shelf_widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(AlternateAppListButton);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_LAUNCHER_ALTERNATE_APP_LIST_BUTTON_H_
diff --git a/ash/launcher/launcher_model.cc b/ash/launcher/launcher_model.cc
index 68e57e0..8daf561 100644
--- a/ash/launcher/launcher_model.cc
+++ b/ash/launcher/launcher_model.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "ash/ash_switches.h"
#include "ash/launcher/launcher_model_observer.h"
namespace ash {
@@ -22,7 +23,7 @@ int LauncherItemTypeToWeight(LauncherItemType type) {
case TYPE_PLATFORM_APP:
return 1;
case TYPE_APP_LIST:
- return 2;
+ return ash::switches::UseAlternateShelfLayout() ? 0 : 2;
case TYPE_APP_PANEL:
return 3;
}
@@ -148,7 +149,8 @@ void LauncherModel::RemoveObserver(LauncherModelObserver* observer) {
int LauncherModel::ValidateInsertionIndex(LauncherItemType type,
int index) const {
- DCHECK(index >= 0 && index <= item_count());
+ DCHECK(index >= 0 && index <= item_count() +
+ (ash::switches::UseAlternateShelfLayout() ? 1 : 0));
// Clamp |index| to the allowed range for the type as determined by |weight|.
LauncherItem weight_dummy;
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index 70292f2..ede55d4 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -9,6 +9,7 @@
#include "ash/ash_constants.h"
#include "ash/ash_switches.h"
#include "ash/drag_drop/drag_image_view.h"
+#include "ash/launcher/alternate_app_list_button.h"
#include "ash/launcher/app_list_button.h"
#include "ash/launcher/launcher_button.h"
#include "ash/launcher/launcher_delegate.h"
@@ -441,7 +442,8 @@ void LauncherView::OnShelfAlignmentChanged() {
LayoutToIdealBounds();
for (int i=0; i < view_model_->view_size(); ++i) {
// TODO: remove when AppIcon is a Launcher Button.
- if (TYPE_APP_LIST == model_->items()[i].type) {
+ if (TYPE_APP_LIST == model_->items()[i].type &&
+ !ash::switches::UseAlternateShelfLayout()) {
ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
static_cast<AppListButton*>(view_model_->view_at(i))->SetImageAlignment(
shelf->SelectValueForShelfAlignment(
@@ -683,6 +685,7 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) {
return;
int first_panel_index = model_->FirstPanelIndex();
+ // TODO(harrym): if alternate shelf layout stays, rename app_list_index.
int app_list_index = first_panel_index - 1;
// Initial x,y values account both leading_inset in primary
@@ -698,8 +701,12 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) {
leading_inset(),
leading_inset(),
0);
- int w = shelf->PrimaryAxisValue(kLauncherPreferredSize, width());
- int h = shelf->PrimaryAxisValue(height(), kLauncherPreferredSize);
+
+ int shelf_size = ash::switches::UseAlternateShelfLayout() ?
+ ShelfLayoutManager::kShelfSize : kLauncherPreferredSize;
+
+ int w = shelf->PrimaryAxisValue(shelf_size, width());
+ int h = shelf->PrimaryAxisValue(height(), shelf_size);
for (int i = 0; i < view_model_->view_size(); ++i) {
if (i < first_visible_index_) {
view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0));
@@ -901,21 +908,26 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) {
}
case TYPE_APP_LIST: {
- // TODO(dave): turn this into a LauncherButton too.
- AppListButton* button = new AppListButton(this, this);
- ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
- button->SetImageAlignment(
- shelf->SelectValueForShelfAlignment(
- views::ImageButton::ALIGN_CENTER,
- views::ImageButton::ALIGN_LEFT,
- views::ImageButton::ALIGN_RIGHT,
- views::ImageButton::ALIGN_CENTER),
- shelf->SelectValueForShelfAlignment(
- views::ImageButton::ALIGN_TOP,
- views::ImageButton::ALIGN_MIDDLE,
- views::ImageButton::ALIGN_MIDDLE,
- views::ImageButton::ALIGN_BOTTOM));
- view = button;
+ if (ash::switches::UseAlternateShelfLayout()) {
+ view = new AlternateAppListButton(this, this,
+ tooltip_->shelf_layout_manager()->shelf_widget());
+ } else {
+ // TODO(dave): turn this into a LauncherButton too.
+ AppListButton* button = new AppListButton(this, this);
+ ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
+ button->SetImageAlignment(
+ shelf->SelectValueForShelfAlignment(
+ views::ImageButton::ALIGN_CENTER,
+ views::ImageButton::ALIGN_LEFT,
+ views::ImageButton::ALIGN_RIGHT,
+ views::ImageButton::ALIGN_CENTER),
+ shelf->SelectValueForShelfAlignment(
+ views::ImageButton::ALIGN_TOP,
+ views::ImageButton::ALIGN_MIDDLE,
+ views::ImageButton::ALIGN_MIDDLE,
+ views::ImageButton::ALIGN_BOTTOM));
+ view = button;
+ }
break;
}
@@ -1023,17 +1035,36 @@ void LauncherView::ContinueDrag(const ui::LocatedEvent& event) {
bool LauncherView::SameDragType(LauncherItemType typea,
LauncherItemType typeb) const {
- switch (typea) {
- case TYPE_TABBED:
- case TYPE_PLATFORM_APP:
+ if (ash::switches::UseAlternateShelfLayout()) {
+ // TODO(harrym): Allow app list to be repositionable, if this goes live
+ // (no flag) the pref file has to be updated so the changes persist.
+ switch (typea) {
+ case TYPE_TABBED:
+ case TYPE_PLATFORM_APP:
return (typeb == TYPE_TABBED || typeb == TYPE_PLATFORM_APP);
- case TYPE_APP_SHORTCUT:
- case TYPE_BROWSER_SHORTCUT:
- return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT);
- case TYPE_WINDOWED_APP:
- case TYPE_APP_LIST:
- case TYPE_APP_PANEL:
- return typeb == typea;
+ case TYPE_APP_SHORTCUT:
+ case TYPE_APP_LIST:
+ case TYPE_BROWSER_SHORTCUT:
+ return (typeb == TYPE_APP_SHORTCUT ||
+ typeb == TYPE_APP_LIST ||
+ typeb == TYPE_BROWSER_SHORTCUT);
+ case TYPE_WINDOWED_APP:
+ case TYPE_APP_PANEL:
+ return typeb == typea;
+ }
+ } else {
+ switch (typea) {
+ case TYPE_TABBED:
+ case TYPE_PLATFORM_APP:
+ return (typeb == TYPE_TABBED || typeb == TYPE_PLATFORM_APP);
+ case TYPE_APP_SHORTCUT:
+ case TYPE_BROWSER_SHORTCUT:
+ return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT);
+ case TYPE_WINDOWED_APP:
+ case TYPE_APP_LIST:
+ case TYPE_APP_PANEL:
+ return typeb == typea;
+ }
}
NOTREACHED();
return false;
@@ -1339,6 +1370,8 @@ void LauncherView::LauncherItemMoved(int start_index, int target_index) {
}
void LauncherView::LauncherStatusChanged() {
+ if (ash::switches::UseAlternateShelfLayout())
+ return;
AppListButton* app_list_button =
static_cast<AppListButton*>(GetAppListButtonView());
if (model_->status() == LauncherModel::STATUS_LOADING)
diff --git a/ash/resources/ash_resources.grd b/ash/resources/ash_resources.grd
index e061fb1..b9e20ac 100644
--- a/ash/resources/ash_resources.grd
+++ b/ash/resources/ash_resources.grd
@@ -20,6 +20,7 @@
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_BROWSER_SHORTCUT" file="common/chromium-32.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_DIMMING" file="common/launcher/launcher_dimming.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_ICON_APPLIST" file="common/launcher/launcher_appmenu.png" />
+ <structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_ICON_APPLIST_ALTERNATE" file="common/alt_launcher/status_app_menu_icon.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_ICON_APPLIST_HOT" file="common/launcher/launcher_appmenu_hover.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_ICON_APPLIST_PUSHED" file="common/launcher/launcher_appmenu_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_INCOGNITO_BROWSER" file="common/launcher/launcher_incognito_browser.png" />
@@ -33,6 +34,9 @@
<structure type="chrome_scaled_image" name="IDR_AURA_LAUNCHER_ICON_TASK_MANAGER" file="common/launcher/task_manager.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_MULTI_WINDOW_RESIZE_H" file="common/multi_window_resize_horizontal.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_MULTI_WINDOW_RESIZE_V" file="common/multi_window_resize_vertical.png" />
+ <structure type="chrome_scaled_image" name="IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL" file="common/alt_launcher/status_icon_background_normal.png" />
+ <structure type="chrome_scaled_image" name="IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK" file="common/alt_launcher/status_icon_background_onblack_normal.png" />
+ <structure type="chrome_scaled_image" name="IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED" file="common/alt_launcher/status_icon_background_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_RESIZE_SHADOW_BOTTOM" file="common/resize_shadow_bottom.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_RESIZE_SHADOW_BOTTOM_LEFT" file="common/resize_shadow_bottom_left.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_RESIZE_SHADOW_BOTTOM_RIGHT" file="common/resize_shadow_bottom_right.png" />
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 8774f89..7fe0a4e 100644
--- a/ash/shelf/shelf_widget.cc
+++ b/ash/shelf/shelf_widget.cc
@@ -489,6 +489,8 @@ void ShelfWidget::SetAlignment(ShelfAlignment alignment) {
void ShelfWidget::SetDimsShelf(bool dimming) {
delegate_view_->SetDimmed(dimming);
+ if (launcher_)
+ launcher_->GetAppListButtonView()->SchedulePaint();
}
bool ShelfWidget::GetDimsShelf() const {
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index a13ba65..96b90f6 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -121,13 +121,31 @@ void AppListController::SetVisible(bool visible, aura::Window* window) {
Shell::GetInstance()->delegate()->CreateAppListViewDelegate());
aura::Window* container = GetRootWindowController(window->GetRootWindow())->
GetContainer(kShellWindowId_AppListContainer);
- view->InitAsBubble(
- container,
- pagination_model_.get(),
- Launcher::ForWindow(container)->GetAppListButtonView(),
- gfx::Point(),
- GetBubbleArrow(container),
- true /* border_accepts_events */);
+ // TODO(harrym): find a better solution for this.
+ if (ash::switches::UseAlternateShelfLayout()) {
+ gfx::Rect applist_button_bounds = Launcher::ForWindow(container)->
+ GetAppListButtonView()->GetBoundsInScreen();
+ gfx::Point anchor = applist_button_bounds.origin();
+ if (anchor.x() == 0)
+ anchor.set_x(applist_button_bounds.right());
+ if (anchor.y() == 0)
+ anchor.set_y(applist_button_bounds.bottom());
+ view->InitAsBubble(
+ container,
+ pagination_model_.get(),
+ NULL,
+ anchor,
+ GetBubbleArrow(container),
+ true /* border_accepts_events */);
+ } else {
+ view->InitAsBubble(
+ container,
+ pagination_model_.get(),
+ Launcher::ForWindow(container)->GetAppListButtonView(),
+ gfx::Point(),
+ GetBubbleArrow(container),
+ true /* border_accepts_events */);
+ }
if (ash::switches::UseAlternateShelfLayout())
view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
SetView(view);