Commit b9a79669 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Add icons to wallpaper context menus

Three changes:
 - Add the icons for desktop context menu options.
 - Make the "Autohide Shelf" option a regular menu option.
   - This is because touchable menu items do not use the "check" type
     and was OKed by UX.
 - Remove the "Autohide" and "Shelf position" items in tablet mode.
   - This is requested by UX.

Bug: 850134
Change-Id: I4bc7912687fbd8f1c3543301be511ac02277a859
Reviewed-on: https://chromium-review.googlesource.com/1159735
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580379}
parent 5dc35e99
...@@ -10,6 +10,7 @@ aggregate_vector_icons("ash_vector_icons") { ...@@ -10,6 +10,7 @@ aggregate_vector_icons("ash_vector_icons") {
icons = [ icons = [
"assistant.icon", "assistant.icon",
"auto_hide.icon",
"captive_portal.icon", "captive_portal.icon",
"check_circle.icon", "check_circle.icon",
"dictation_menu.icon", "dictation_menu.icon",
...@@ -101,6 +102,7 @@ aggregate_vector_icons("ash_vector_icons") { ...@@ -101,6 +102,7 @@ aggregate_vector_icons("ash_vector_icons") {
"shelf_overflow.icon", "shelf_overflow.icon",
"shelf_overflow_horizontal_dots.icon", "shelf_overflow_horizontal_dots.icon",
"shelf_overview.icon", "shelf_overview.icon",
"shelf_position.icon",
"shelf_shutdown_button.icon", "shelf_shutdown_button.icon",
"shelf_sign_out_button.icon", "shelf_sign_out_button.icon",
"shelf_unlock_button.icon", "shelf_unlock_button.icon",
...@@ -214,6 +216,7 @@ aggregate_vector_icons("ash_vector_icons") { ...@@ -214,6 +216,7 @@ aggregate_vector_icons("ash_vector_icons") {
"unified_menu_volume_medium.icon", "unified_menu_volume_medium.icon",
"unified_menu_volume_mute.icon", "unified_menu_volume_mute.icon",
"unified_menu_vpn.icon", "unified_menu_vpn.icon",
"wallpaper.icon",
"window_control_back.icon", "window_control_back.icon",
"window_control_dezoom.icon", "window_control_dezoom.icon",
"window_control_menu.icon", "window_control_menu.icon",
......
// Copyright 2018 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, 20,
MOVE_TO, 11, 8,
R_V_LINE_TO, 2,
H_LINE_TO, 9,
V_LINE_TO, 8,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 2, 0,
R_H_LINE_TO, 1,
R_V_LINE_TO, 2,
R_H_LINE_TO, -1,
V_LINE_TO, 8,
CLOSE,
MOVE_TO, 7, 8,
R_V_LINE_TO, 2,
H_LINE_TO, 5,
V_LINE_TO, 8,
R_H_LINE_TO, 2,
CLOSE,
MOVE_TO, 3, 8,
R_V_LINE_TO, 2,
H_LINE_TO, 2,
V_LINE_TO, 8,
R_H_LINE_TO, 1,
CLOSE,
MOVE_TO, 2, 0,
R_H_LINE_TO, 12,
R_ARC_TO, 2, 2, 0, 0, 1, 2, 2,
R_V_LINE_TO, 10,
R_ARC_TO, 2, 2, 0, 0, 1, -2, 2,
H_LINE_TO, 2,
R_ARC_TO, 2, 2, 0, 0, 1, -2, -2,
V_LINE_TO, 2,
R_ARC_TO, 2, 2, 0, 0, 1, 2, -2,
CLOSE,
R_MOVE_TO, 0, 2,
R_V_LINE_TO, 10,
R_H_LINE_TO, 12,
V_LINE_TO, 2,
H_LINE_TO, 2,
CLOSE
// Copyright 2018 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, 20,
MOVE_TO, 6, 8,
R_H_LINE_TO, 4,
V_LINE_TO, 2,
R_H_LINE_TO, 2,
R_V_LINE_TO, 6,
R_H_LINE_TO, 2,
R_V_LINE_TO, 2,
H_LINE_TO, 2,
V_LINE_TO, 8,
R_H_LINE_TO, 2,
V_LINE_TO, 2,
R_H_LINE_TO, 2,
R_V_LINE_TO, 6,
CLOSE,
MOVE_TO, 2, 0,
R_H_LINE_TO, 12,
R_ARC_TO, 2, 2, 0, 0, 1, 2, 2,
R_V_LINE_TO, 10,
R_ARC_TO, 2, 2, 0, 0, 1, -2, 2,
H_LINE_TO, 2,
R_ARC_TO, 2, 2, 0, 0, 1, -2, -2,
V_LINE_TO, 2,
R_ARC_TO, 2, 2, 0, 0, 1, 2, -2,
CLOSE,
R_MOVE_TO, 0, 2,
R_V_LINE_TO, 10,
R_H_LINE_TO, 12,
V_LINE_TO, 2,
H_LINE_TO, 2,
CLOSE
// Copyright 2018 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, 20,
MOVE_TO, 2, 0,
R_H_LINE_TO, 12,
R_ARC_TO, 2, 2, 0, 0, 1, 2, 2,
R_V_LINE_TO, 10,
R_ARC_TO, 2, 2, 0, 0, 1, -2, 2,
H_LINE_TO, 2,
R_ARC_TO, 2, 2, 0, 0, 1, -2, -2,
V_LINE_TO, 2,
R_ARC_TO, 2, 2, 0, 0, 1, 2, -2,
CLOSE,
R_MOVE_TO, 0, 2,
R_V_LINE_TO, 10,
R_H_LINE_TO, 12,
V_LINE_TO, 2,
H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 2, 8,
R_LINE_TO, 3, -6,
R_LINE_TO, 2, 4,
R_LINE_TO, 1, -1.5f,
R_LINE_TO, 2, 3.5f,
H_LINE_TO, 4,
CLOSE
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ash/public/cpp/shelf_item_delegate.h" #include "ash/public/cpp/shelf_item_delegate.h"
#include "ash/public/cpp/shelf_prefs.h" #include "ash/public/cpp/shelf_prefs.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -26,6 +27,8 @@ ...@@ -26,6 +27,8 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/menu/menu_config.h"
using l10n_util::GetStringUTF16; using l10n_util::GetStringUTF16;
using SubmenuList = std::vector<std::unique_ptr<ui::MenuModel>>; using SubmenuList = std::vector<std::unique_ptr<ui::MenuModel>>;
...@@ -58,24 +61,41 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -58,24 +61,41 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
const bool is_tablet_mode = Shell::Get() const bool is_tablet_mode = Shell::Get()
->tablet_mode_controller() ->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled(); ->IsTabletModeWindowManagerEnabled();
// When touchable app context menus are enabled in tablet mode, auto hide and
// shelf alignment options are not shown.
const bool skip_clamshell_only_options =
features::IsTouchableAppContextMenuEnabled() && is_tablet_mode;
const views::MenuConfig& menu_config = views::MenuConfig::instance();
// In fullscreen, the shelf is either hidden or auto-hidden, depending on // In fullscreen, the shelf is either hidden or auto-hidden, depending on
// the type of fullscreen. Do not show the auto-hide menu item while in // the type of fullscreen. Do not show the auto-hide menu item while in
// fullscreen because it is confusing when the preference appears not to // fullscreen because it is confusing when the preference appears not to
// apply. // apply.
if (CanUserModifyShelfAutoHide(prefs) && !IsFullScreenMode(display_id)) { if (CanUserModifyShelfAutoHide(prefs) && !IsFullScreenMode(display_id) &&
!skip_clamshell_only_options) {
mojom::MenuItemPtr auto_hide(mojom::MenuItem::New()); mojom::MenuItemPtr auto_hide(mojom::MenuItem::New());
auto_hide->type = ui::MenuModel::TYPE_CHECK; if (features::IsTouchableAppContextMenuEnabled()) {
auto_hide->type = ui::MenuModel::TYPE_COMMAND;
auto_hide->image =
gfx::CreateVectorIcon(kAutoHideIcon, menu_config.touchable_icon_size,
menu_config.touchable_icon_color);
} else {
auto_hide->type = ui::MenuModel::TYPE_CHECK;
auto_hide->checked = GetShelfAutoHideBehaviorPref(prefs, display_id) ==
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
}
auto_hide->command_id = ShelfContextMenuModel::MENU_AUTO_HIDE; auto_hide->command_id = ShelfContextMenuModel::MENU_AUTO_HIDE;
auto_hide->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); auto_hide->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
auto_hide->checked = GetShelfAutoHideBehaviorPref(prefs, display_id) ==
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
auto_hide->enabled = !is_tablet_mode; auto_hide->enabled = !is_tablet_mode;
menu->push_back(std::move(auto_hide)); menu->push_back(std::move(auto_hide));
} }
// Only allow shelf alignment modifications by the owner or user. // Only allow shelf alignment modifications by the owner or user.
LoginStatus status = Shell::Get()->session_controller()->login_status(); LoginStatus status = Shell::Get()->session_controller()->login_status();
if (status == LoginStatus::USER || status == LoginStatus::OWNER) { if ((status == LoginStatus::USER || status == LoginStatus::OWNER) &&
!skip_clamshell_only_options) {
const ShelfAlignment alignment = GetShelfAlignmentPref(prefs, display_id); const ShelfAlignment alignment = GetShelfAlignmentPref(prefs, display_id);
mojom::MenuItemPtr alignment_menu(mojom::MenuItem::New()); mojom::MenuItemPtr alignment_menu(mojom::MenuItem::New());
alignment_menu->type = ui::MenuModel::TYPE_SUBMENU; alignment_menu->type = ui::MenuModel::TYPE_SUBMENU;
...@@ -83,6 +103,11 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -83,6 +103,11 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
alignment_menu->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_POSITION); alignment_menu->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_POSITION);
alignment_menu->submenu = MenuItemList(); alignment_menu->submenu = MenuItemList();
alignment_menu->enabled = !is_tablet_mode; alignment_menu->enabled = !is_tablet_mode;
if (features::IsTouchableAppContextMenuEnabled()) {
alignment_menu->image = gfx::CreateVectorIcon(
kShelfPositionIcon, menu_config.touchable_icon_size,
menu_config.touchable_icon_color);
}
mojom::MenuItemPtr left(mojom::MenuItem::New()); mojom::MenuItemPtr left(mojom::MenuItem::New());
left->type = ui::MenuModel::TYPE_RADIO; left->type = ui::MenuModel::TYPE_RADIO;
...@@ -117,6 +142,11 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -117,6 +142,11 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
wallpaper->command_id = ShelfContextMenuModel::MENU_CHANGE_WALLPAPER; wallpaper->command_id = ShelfContextMenuModel::MENU_CHANGE_WALLPAPER;
wallpaper->label = GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER); wallpaper->label = GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER);
wallpaper->enabled = true; wallpaper->enabled = true;
if (features::IsTouchableAppContextMenuEnabled()) {
wallpaper->image =
gfx::CreateVectorIcon(kWallpaperIcon, menu_config.touchable_icon_size,
menu_config.touchable_icon_color);
}
menu->push_back(std::move(wallpaper)); menu->push_back(std::move(wallpaper));
} }
} }
......
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