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

cros: Make the Autohide Shelf context menu option toggle

The Autohide Shelf context menu option lets the user make
the shelf hide when a window is maximized. This option used to
have a check mark signifying that autohide was enabled. With touchable
app context menus, there is no check mark.

To work like a checkmark, we will add a new selection option which
toggles with "Autohide Shelf". It is called "Always Show Shelf".

Bug: 875781
Change-Id: I6ed9f42cd6ac3e67f70110ea69944cc18a7abba7
Reviewed-on: https://chromium-review.googlesource.com/1188888Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586027}
parent 18826b80
......@@ -145,6 +145,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE" desc="Title of the menu item in the context menu for auto-hiding the shelf when the current window is not maximized">
Autohide shelf
</message>
<message name="IDS_ASH_SHELF_CONTEXT_MENU_ALWAYS_SHOW_SHELF" desc="Title of the menu item in the context menu for always showing the shelf">
Always Show Shelf
</message>
<message name="IDS_ASH_SHELF_CONTEXT_MENU_POSITION" desc="Title of the menu item in the context menu for aligning the shelf">
Shelf position
</message>
......
......@@ -9,6 +9,7 @@ aggregate_vector_icons("ash_vector_icons") {
icon_directory = "."
icons = [
"always_show_shelf.icon",
"auto_hide.icon",
"captive_portal.icon",
"check_circle.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, 4, 11,
R_H_LINE_TO, 12,
R_V_LINE_TO, 2,
H_LINE_TO, 4,
V_LINE_TO, 11,
CLOSE,
R_MOVE_TO, 0, -8,
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, 4,
R_ARC_TO, 2, 2, 0, 0, 1, -2, -2,
V_LINE_TO, 5,
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, 5,
H_LINE_TO, 4,
CLOSE
......@@ -76,18 +76,23 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
if (CanUserModifyShelfAutoHide(prefs) && !IsFullScreenMode(display_id) &&
!skip_clamshell_only_options) {
mojom::MenuItemPtr auto_hide(mojom::MenuItem::New());
const bool is_autohide_set =
GetShelfAutoHideBehaviorPref(prefs, display_id) ==
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
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);
auto_hide->image = gfx::CreateVectorIcon(
is_autohide_set ? kAlwaysShowShelfIcon : kAutoHideIcon,
menu_config.touchable_icon_size, menu_config.touchable_icon_color);
auto_hide->label = GetStringUTF16(
is_autohide_set ? IDS_ASH_SHELF_CONTEXT_MENU_ALWAYS_SHOW_SHELF
: IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
} else {
auto_hide->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
auto_hide->type = ui::MenuModel::TYPE_CHECK;
auto_hide->checked = GetShelfAutoHideBehaviorPref(prefs, display_id) ==
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
auto_hide->checked = is_autohide_set;
}
auto_hide->command_id = ShelfContextMenuModel::MENU_AUTO_HIDE;
auto_hide->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
auto_hide->enabled = !is_tablet_mode;
menu->push_back(std::move(auto_hide));
}
......
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