Commit b9918821 authored by jdufault's avatar jdufault Committed by Commit bot

Add palette tray to ash.

Design doc: go/caebn

This is dependent on a number of CLs:
- https://codereview.chromium.org/2147783002/
- https://codereview.chromium.org/2140343002/
- https://codereview.chromium.org/2143073003/
- https://codereview.chromium.org/2116033002/

BUG=625251

Review-Url: https://codereview.chromium.org/2148573002
Cr-Commit-Position: refs/heads/master@{#407654}
parent 3429dff8
......@@ -190,6 +190,8 @@
'common/system/chromeos/palette/palette_tool.h',
'common/system/chromeos/palette/palette_tool_manager.cc',
'common/system/chromeos/palette/palette_tool_manager.h',
'common/system/chromeos/palette/palette_tray.cc',
'common/system/chromeos/palette/palette_tray.h',
'common/system/chromeos/power/battery_notification.cc',
'common/system/chromeos/power/battery_notification.h',
'common/system/chromeos/power/dual_role_notification.cc',
......
......@@ -363,6 +363,10 @@ Press Ctrl+Alt+Z to disable.
Previous menu
</message>
<message name="IDS_ASH_PALETTE_TITLE" desc="The title of the palette in the ash shelf.">
Palette
</message>
<message name="IDS_ASH_TOAST_DISMISS_BUTTON" desc="The text button shown in toasts to close the toast immediately without waiting timeout.">
DISMISS
</message>
......
......@@ -72,7 +72,7 @@ PaletteToolId PaletteToolManager::GetActiveTool(PaletteGroup group) {
gfx::VectorIconId PaletteToolManager::GetActiveTrayIcon(PaletteToolId tool_id) {
PaletteTool* tool = FindToolById(tool_id);
if (!tool)
return gfx::VectorIconId::VECTOR_ICON_NONE;
return gfx::VectorIconId::PALETTE_TRAY_ICON_DEFAULT;
return tool->GetActiveTrayIcon();
}
......
This diff is collapsed.
// Copyright 2016 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_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_
#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_
#include <map>
#include <memory>
#include "ash/ash_export.h"
#include "ash/common/session/session_state_observer.h"
#include "ash/common/shell_observer.h"
#include "ash/common/system/chromeos/palette/palette_tool_manager.h"
#include "ash/common/system/tray/tray_background_view.h"
#include "base/macros.h"
namespace views {
class ImageView;
class Widget;
}
namespace ash {
class TrayBubbleWrapper;
class PaletteToolManager;
// The PaletteTray shows the palette in the bottom area of the screen. This
// class also controls the lifetime for all of the tools available in the
// palette.
class ASH_EXPORT PaletteTray : public TrayBackgroundView,
public SessionStateObserver,
public ShellObserver,
public PaletteToolManager::Delegate,
public views::TrayBubbleView::Delegate {
public:
explicit PaletteTray(WmShelf* wm_shelf);
~PaletteTray() override;
// ActionableView:
bool PerformAction(const ui::Event& event) override;
// SessionStateObserver:
void SessionStateChanged(SessionStateDelegate::SessionState state) override;
// TrayBackgroundView:
void ClickedOutsideBubble() override;
base::string16 GetAccessibleNameForTray() override;
void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override;
void SetShelfAlignment(ShelfAlignment alignment) override;
void AnchorUpdated() override;
private:
// views::TrayBubbleView::Delegate:
void BubbleViewDestroyed() override;
void OnMouseEnteredView() override;
void OnMouseExitedView() override;
base::string16 GetAccessibleNameForBubble() override;
gfx::Rect GetAnchorRect(views::Widget* anchor_widget,
AnchorType anchor_type,
AnchorAlignment anchor_alignment) const override;
void OnBeforeBubbleWidgetInit(
views::Widget* anchor_widget,
views::Widget* bubble_widget,
views::Widget::InitParams* params) const override;
void HideBubble(const views::TrayBubbleView* bubble_view) override;
// PaletteToolManager::Delegate:
void HidePalette() override;
void OnActiveToolChanged() override;
WmWindow* GetWindow() override;
// Creates a new border for the icon. The padding is determined based on the
// alignment of the shelf.
void SetIconBorderForShelfAlignment();
// Updates the tray icon from the palette tool manager.
void UpdateTrayIcon();
// Sets the icon to visible if the palette can be used.
void UpdateIconVisibility();
bool OpenBubble();
void AddToolsToView(views::View* host);
std::unique_ptr<PaletteToolManager> palette_tool_manager_;
std::unique_ptr<TrayBubbleWrapper> bubble_;
// Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_;
DISALLOW_COPY_AND_ASSIGN(PaletteTray);
};
} // namespace ash
#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_
......@@ -19,6 +19,7 @@
#if defined(OS_CHROMEOS)
#include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
#include "ash/common/system/chromeos/palette/palette_tray.h"
#include "ash/common/system/chromeos/session/logout_button_tray.h"
#include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
#endif
......@@ -28,12 +29,13 @@ namespace ash {
StatusAreaWidget::StatusAreaWidget(WmWindow* status_container,
WmShelf* wm_shelf)
: status_area_widget_delegate_(new StatusAreaWidgetDelegate),
overview_button_tray_(NULL),
system_tray_(NULL),
web_notification_tray_(NULL),
overview_button_tray_(nullptr),
system_tray_(nullptr),
web_notification_tray_(nullptr),
#if defined(OS_CHROMEOS)
logout_button_tray_(NULL),
virtual_keyboard_tray_(NULL),
logout_button_tray_(nullptr),
palette_tray_(nullptr),
virtual_keyboard_tray_(nullptr),
ime_menu_tray_(nullptr),
#endif
login_status_(LoginStatus::NOT_LOGGED_IN),
......@@ -59,6 +61,7 @@ void StatusAreaWidget::CreateTrayViews() {
AddWebNotificationTray();
#if defined(OS_CHROMEOS)
AddLogoutButtonTray();
AddPaletteTray();
AddVirtualKeyboardTray();
AddImeMenuTray();
#endif
......@@ -84,20 +87,20 @@ void StatusAreaWidget::Shutdown() {
// hierarchy. Do not used scoped pointers since we don't want to destroy them
// in the destructor if Shutdown() is not called (e.g. in tests).
delete web_notification_tray_;
web_notification_tray_ = NULL;
web_notification_tray_ = nullptr;
// Must be destroyed after |web_notification_tray_|.
delete system_tray_;
system_tray_ = NULL;
system_tray_ = nullptr;
#if defined(OS_CHROMEOS)
delete ime_menu_tray_;
ime_menu_tray_ = nullptr;
delete virtual_keyboard_tray_;
virtual_keyboard_tray_ = NULL;
virtual_keyboard_tray_ = nullptr;
delete logout_button_tray_;
logout_button_tray_ = NULL;
logout_button_tray_ = nullptr;
#endif
delete overview_button_tray_;
overview_button_tray_ = NULL;
overview_button_tray_ = nullptr;
}
bool StatusAreaWidget::ShouldShowShelf() const {
......@@ -130,6 +133,7 @@ void StatusAreaWidget::SchedulePaint() {
virtual_keyboard_tray_->SchedulePaint();
logout_button_tray_->SchedulePaint();
ime_menu_tray_->SchedulePaint();
palette_tray_->SchedulePaint();
#endif
overview_button_tray_->SchedulePaint();
}
......@@ -168,6 +172,11 @@ void StatusAreaWidget::AddLogoutButtonTray() {
status_area_widget_delegate_->AddTray(logout_button_tray_);
}
void StatusAreaWidget::AddPaletteTray() {
palette_tray_ = new PaletteTray(wm_shelf_);
status_area_widget_delegate_->AddTray(palette_tray_);
}
void StatusAreaWidget::AddVirtualKeyboardTray() {
virtual_keyboard_tray_ = new VirtualKeyboardTray(wm_shelf_);
status_area_widget_delegate_->AddTray(virtual_keyboard_tray_);
......@@ -197,6 +206,8 @@ void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
virtual_keyboard_tray_->SetShelfAlignment(alignment);
if (ime_menu_tray_)
ime_menu_tray_->SetShelfAlignment(alignment);
if (palette_tray_)
palette_tray_->SetShelfAlignment(alignment);
#endif
if (overview_button_tray_)
overview_button_tray_->SetShelfAlignment(alignment);
......
......@@ -22,6 +22,7 @@ class WmWindow;
#if defined(OS_CHROMEOS)
class ImeMenuTray;
class LogoutButtonTray;
class PaletteTray;
class VirtualKeyboardTray;
#endif
......@@ -79,6 +80,7 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
void AddWebNotificationTray();
#if defined(OS_CHROMEOS)
void AddLogoutButtonTray();
void AddPaletteTray();
void AddVirtualKeyboardTray();
void AddImeMenuTray();
#endif
......@@ -91,6 +93,7 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
WebNotificationTray* web_notification_tray_;
#if defined(OS_CHROMEOS)
LogoutButtonTray* logout_button_tray_;
PaletteTray* palette_tray_;
VirtualKeyboardTray* virtual_keyboard_tray_;
ImeMenuTray* ime_menu_tray_;
#endif
......
......@@ -31,6 +31,7 @@ class TrayBubbleWrapper : public views::WidgetObserver {
const TrayBackgroundView* tray() const { return tray_; }
TrayBackgroundView* tray() { return tray_; }
views::TrayBubbleView* bubble_view() { return bubble_view_; }
const views::TrayBubbleView* bubble_view() const { return bubble_view_; }
const views::Widget* bubble_widget() const { return bubble_widget_; }
......
// Copyright 2015 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.
CANVAS_DIMENSIONS, 16,
MOVE_TO, 13.8f, 3.75f,
R_CUBIC_TO, 0.26f, 0.26f, 0, 0.81f, 0, 0.81f,
LINE_TO, 9.82f, 8.21f,
R_LINE_TO, -2.26f, -2.08f,
R_LINE_TO, 2.03f, -1.94f,
R_LINE_TO, -0.79f, -0.76f,
R_LINE_TO, -4.05f, 3.68f,
R_LINE_TO, -0.82f, -0.61f,
R_LINE_TO, 4.36f, -4.3f,
R_CUBIC_TO, 0.26f, -0.26f, 0.87f, -0.26f, 1.12f, 0,
R_LINE_TO, 0.95f, 0.94f,
R_LINE_TO, 0.95f, -0.94f,
R_CUBIC_TO, 0.25f, -0.26f, 0.68f, -0.26f, 0.94f, 0,
R_LINE_TO, 1.56f, 1.55f,
CLOSE,
MOVE_TO, 2.02f, 11.66f,
LINE_TO, 2, 14,
R_H_LINE_TO, 2.34f,
R_LINE_TO, 5.1f, -5.17f,
R_LINE_TO, -2.22f, -2.02f,
R_LINE_TO, -5.21f, 4.86f,
CLOSE,
END
// Copyright 2015 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.
CANVAS_DIMENSIONS, 32,
MOVE_TO, 24.49f, 4.4f,
R_LINE_TO, 3.12f, 3.11f,
R_CUBIC_TO, 0.52f, 0.52f, 0.53f, 1.37f, 0.01f, 1.89f,
R_LINE_TO, -7.16f, 7.15f,
R_LINE_TO, -5.01f, -5.01f,
R_LINE_TO, 3.37f, -3.37f,
R_LINE_TO, -0.97f, -0.97f,
R_LINE_TO, -7.54f, 7.55f,
R_LINE_TO, -1.87f, -1.87f,
R_LINE_TO, 8.49f, -8.48f,
R_CUBIC_TO, 0.52f, -0.52f, 1.39f, -0.51f, 1.89f, 0.01f,
R_LINE_TO, 1.89f, 1.88f,
R_LINE_TO, 1.89f, -1.88f,
R_CUBIC_TO, 0.51f, -0.52f, 1.36f, -0.52f, 1.88f, 0,
CLOSE,
MOVE_TO, 4, 23,
R_V_LINE_TO, 5,
R_H_LINE_TO, 4.99f,
R_LINE_TO, 10.05f, -10.04f,
R_LINE_TO, -5, -5,
LINE_TO, 4, 23,
CLOSE,
END
......@@ -103,6 +103,8 @@
'vector_icons/overflow_chevron.1x.icon',
'vector_icons/overflow_chevron.icon',
'vector_icons/paintbrush.icon',
'vector_icons/palette_tray_icon_default.1x.icon',
'vector_icons/palette_tray_icon_default.icon',
'vector_icons/pdf.1x.icon',
'vector_icons/pdf.icon',
'vector_icons/photo_camera.icon',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment