Add Game Dashboard Tiles to Menu
Creates a row of tiles to the main menu whose functionality will be implemented in a future CL. Bug: b:275424971 Test: Ran GameDashboard* ash_unittests Change-Id: I4a92b594f052439d7f85984f0197f7fd7a10f79e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4569940 Commit-Queue: Gina Domergue <gdomergue@google.com> Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Cr-Commit-Position: refs/heads/main@{#1155599}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
3b1c97daf7
commit
48e5f82dbd
@@ -6743,10 +6743,23 @@ To shut down the device, press and hold the power button on the device again.
|
|||||||
[i18n] Frequently used controls like Wi-Fi, Bluetooth and volume controls are in Quick Settings. You can also go here to take screenshots.
|
[i18n] Frequently used controls like Wi-Fi, Bluetooth and volume controls are in Quick Settings. You can also go here to take screenshots.
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<!-- TODO(b/286455407): Update strings once finalized with UX Writing -->
|
||||||
<!-- Game Dashboard strings -->
|
<!-- Game Dashboard strings -->
|
||||||
|
<message name="IDS_ASH_GAME_DASHBOARD_CONTROLS_TILE_BUTTON_TITLE" translateable="false" desc="The display name for the Game Dashboard game controls tile.">
|
||||||
|
Controls
|
||||||
|
</message>
|
||||||
<message name="IDS_ASH_GAME_DASHBOARD_MAIN_MENU_BUTTON_TITLE" desc="The title of the Game Dashboard main menu button.">
|
<message name="IDS_ASH_GAME_DASHBOARD_MAIN_MENU_BUTTON_TITLE" desc="The title of the Game Dashboard main menu button.">
|
||||||
Game Dashboard
|
Game Dashboard
|
||||||
</message>
|
</message>
|
||||||
|
<message name="IDS_ASH_GAME_DASHBOARD_RECORD_GAME_TILE_BUTTON_TITLE" translateable="false" desc="The display name for the Game Dashboard record game tile.">
|
||||||
|
Record game
|
||||||
|
</message>
|
||||||
|
<message name="IDS_ASH_GAME_DASHBOARD_SCREENSHOT_TILE_BUTTON_TITLE" translateable="false" desc="The display name for the Game Dashboard screenshot tile.">
|
||||||
|
Take screenshot
|
||||||
|
</message>
|
||||||
|
<message name="IDS_ASH_GAME_DASHBOARD_TOOLBAR_TILE_BUTTON_TITLE" translateable="false" desc="The display name for the Game Dashboard toolbar tile.">
|
||||||
|
Toolbar
|
||||||
|
</message>
|
||||||
</messages>
|
</messages>
|
||||||
</release>
|
</release>
|
||||||
</grit>
|
</grit>
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
5e5b18224581ab5e95c7c60a0569215d7c517d03
|
@@ -0,0 +1 @@
|
|||||||
|
a2bbb87cc5826ca13dd1c349f08485b09607a38a
|
@@ -0,0 +1 @@
|
|||||||
|
b96eb0c8a42b7322cd25830f270ed2c81fa4c2e2
|
@@ -0,0 +1 @@
|
|||||||
|
a73f270b85623a86ad712e33a145a22239953426
|
@@ -6,24 +6,52 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "ash/public/cpp/app_types_util.h"
|
||||||
|
#include "ash/public/cpp/ash_view_ids.h"
|
||||||
|
#include "ash/strings/grit/ash_strings.h"
|
||||||
|
#include "ash/system/unified/feature_tile.h"
|
||||||
|
#include "components/vector_icons/vector_icons.h"
|
||||||
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||||
#include "ui/views/layout/table_layout.h"
|
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
#include "ui/views/widget/widget.h"
|
#include "ui/views/widget/widget.h"
|
||||||
|
#include "ui/wm/core/window_util.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr int kBubbleCornerRadius = 8;
|
constexpr int kBubbleCornerRadius = 8;
|
||||||
// Padding between the edges of the menu and the elements.
|
// Horizontal padding for the border around the main menu.
|
||||||
constexpr int kPaddingWidth = 12;
|
constexpr int kPaddingWidth = 12;
|
||||||
|
// Vertical padding for the border around the main menu.
|
||||||
|
constexpr int kPaddingHeight = 15;
|
||||||
|
// Padding between children in a row or column.
|
||||||
|
constexpr int kCenterPadding = 8;
|
||||||
|
|
||||||
|
// Creates an individual Game Dashboard Tile.
|
||||||
|
std::unique_ptr<FeatureTile> CreateTile(base::RepeatingClosure callback,
|
||||||
|
bool is_togglable,
|
||||||
|
FeatureTile::TileType type,
|
||||||
|
int id,
|
||||||
|
const gfx::VectorIcon& icon,
|
||||||
|
const std::u16string& text) {
|
||||||
|
auto tile =
|
||||||
|
std::make_unique<FeatureTile>(std::move(callback), is_togglable, type);
|
||||||
|
tile->SetID(id);
|
||||||
|
tile->SetVisible(true);
|
||||||
|
tile->SetVectorIcon(icon);
|
||||||
|
tile->SetLabel(text);
|
||||||
|
tile->SetTooltipText(text);
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
GameDashboardMainMenuView::GameDashboardMainMenuView(
|
GameDashboardMainMenuView::GameDashboardMainMenuView(
|
||||||
views::Widget* main_menu_button_widget) {
|
views::Widget* main_menu_button_widget) {
|
||||||
DCHECK(main_menu_button_widget);
|
DCHECK(main_menu_button_widget);
|
||||||
|
|
||||||
set_corner_radius(kBubbleCornerRadius);
|
set_corner_radius(kBubbleCornerRadius);
|
||||||
set_close_on_deactivate(false);
|
set_close_on_deactivate(false);
|
||||||
set_internal_name("GameDashboardMainMenuView");
|
set_internal_name("GameDashboardMainMenuView");
|
||||||
@@ -32,21 +60,59 @@ GameDashboardMainMenuView::GameDashboardMainMenuView(
|
|||||||
SetAnchorView(main_menu_button_widget->GetContentsView());
|
SetAnchorView(main_menu_button_widget->GetContentsView());
|
||||||
SetArrow(views::BubbleBorder::Arrow::NONE);
|
SetArrow(views::BubbleBorder::Arrow::NONE);
|
||||||
SetButtons(ui::DIALOG_BUTTON_NONE);
|
SetButtons(ui::DIALOG_BUTTON_NONE);
|
||||||
|
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||||
|
views::BoxLayout::Orientation::kVertical,
|
||||||
|
gfx::Insets::VH(kPaddingHeight, kPaddingWidth), kCenterPadding));
|
||||||
|
|
||||||
auto* layout = SetLayoutManager(std::make_unique<views::TableLayout>());
|
AddShortcutTilesRow();
|
||||||
layout->AddPaddingColumn(views::TableLayout::kFixedSize, kPaddingWidth)
|
|
||||||
.AddColumn(views::LayoutAlignment::kStart,
|
SizeToPreferredSize();
|
||||||
views::LayoutAlignment::kCenter,
|
|
||||||
views::TableLayout::kFixedSize,
|
|
||||||
views::TableLayout::ColumnSize::kUsePreferred, 0, 0)
|
|
||||||
.AddPaddingColumn(views::TableLayout::kFixedSize, kPaddingWidth)
|
|
||||||
.AddPaddingRow(views::TableLayout::kFixedSize, kPaddingWidth)
|
|
||||||
.AddRows(1, views::TableLayout::kFixedSize)
|
|
||||||
.AddPaddingRow(views::TableLayout::kFixedSize, kPaddingWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameDashboardMainMenuView::~GameDashboardMainMenuView() = default;
|
GameDashboardMainMenuView::~GameDashboardMainMenuView() = default;
|
||||||
|
|
||||||
|
void GameDashboardMainMenuView::OnToolbarTilePressed() {
|
||||||
|
// TODO(b/273641426): Add support when toolbar tile is pressed.
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameDashboardMainMenuView::OnRecordGameTilePressed() {
|
||||||
|
// TODO(b/273641250): Add support when record game tile is pressed.
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameDashboardMainMenuView::OnScreenshotTilePressed() {
|
||||||
|
// TODO(b/273641464): Add support when screenshot tile is pressed.
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameDashboardMainMenuView::AddShortcutTilesRow() {
|
||||||
|
views::BoxLayoutView* container =
|
||||||
|
AddChildView(std::make_unique<views::BoxLayoutView>());
|
||||||
|
container->SetOrientation(views::BoxLayout::Orientation::kHorizontal);
|
||||||
|
container->SetBetweenChildSpacing(kCenterPadding);
|
||||||
|
|
||||||
|
container->AddChildView(CreateTile(
|
||||||
|
base::BindRepeating(&GameDashboardMainMenuView::OnToolbarTilePressed,
|
||||||
|
base::Unretained(this)),
|
||||||
|
/*is_togglable=*/false, FeatureTile::TileType::kCompact,
|
||||||
|
VIEW_ID_GD_TOOLBAR_TILE, vector_icons::kVideogameAssetOutlineIcon,
|
||||||
|
l10n_util::GetStringUTF16(
|
||||||
|
IDS_ASH_GAME_DASHBOARD_TOOLBAR_TILE_BUTTON_TITLE)));
|
||||||
|
// TODO(b/273641132): Filter out record game button based on device info.
|
||||||
|
container->AddChildView(CreateTile(
|
||||||
|
base::BindRepeating(&GameDashboardMainMenuView::OnRecordGameTilePressed,
|
||||||
|
base::Unretained(this)),
|
||||||
|
/*is_togglable=*/false, FeatureTile::TileType::kCompact,
|
||||||
|
VIEW_ID_GD_RECORD_TILE, vector_icons::kVideocamIcon,
|
||||||
|
l10n_util::GetStringUTF16(
|
||||||
|
IDS_ASH_GAME_DASHBOARD_RECORD_GAME_TILE_BUTTON_TITLE)));
|
||||||
|
container->AddChildView(CreateTile(
|
||||||
|
base::BindRepeating(&GameDashboardMainMenuView::OnScreenshotTilePressed,
|
||||||
|
base::Unretained(this)),
|
||||||
|
/*is_togglable=*/true, FeatureTile::TileType::kCompact,
|
||||||
|
VIEW_ID_GD_SCREENSHOT_TILE, vector_icons::kVideocamIcon,
|
||||||
|
l10n_util::GetStringUTF16(
|
||||||
|
IDS_ASH_GAME_DASHBOARD_SCREENSHOT_TILE_BUTTON_TITLE)));
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN_METADATA(GameDashboardMainMenuView, views::BubbleDialogDelegateView)
|
BEGIN_METADATA(GameDashboardMainMenuView, views::BubbleDialogDelegateView)
|
||||||
END_METADATA
|
END_METADATA
|
||||||
|
|
||||||
|
@@ -21,6 +21,19 @@ class GameDashboardMainMenuView : public views::BubbleDialogDelegateView {
|
|||||||
GameDashboardMainMenuView& operator=(const GameDashboardMainMenuView) =
|
GameDashboardMainMenuView& operator=(const GameDashboardMainMenuView) =
|
||||||
delete;
|
delete;
|
||||||
~GameDashboardMainMenuView() override;
|
~GameDashboardMainMenuView() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Callbacks for the tiles and buttons in the main menu view.
|
||||||
|
// Handles showing and hiding the toolbar.
|
||||||
|
void OnToolbarTilePressed();
|
||||||
|
// Handles toggling the game recording.
|
||||||
|
void OnRecordGameTilePressed();
|
||||||
|
// Handles taking a screenshot of the game window when pressed.
|
||||||
|
void OnScreenshotTilePressed();
|
||||||
|
|
||||||
|
// Adds a row of shortcut tiles to the main menu view for users to quickly
|
||||||
|
// access common functionality.
|
||||||
|
void AddShortcutTilesRow();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ash
|
} // namespace ash
|
||||||
|
@@ -34,6 +34,13 @@ enum ViewID {
|
|||||||
VIEW_ID_CAST_CAST_VIEW_LABEL,
|
VIEW_ID_CAST_CAST_VIEW_LABEL,
|
||||||
VIEW_ID_CAST_MAIN_VIEW,
|
VIEW_ID_CAST_MAIN_VIEW,
|
||||||
VIEW_ID_CAST_SELECT_VIEW,
|
VIEW_ID_CAST_SELECT_VIEW,
|
||||||
|
|
||||||
|
// Game Dashboard elements
|
||||||
|
VIEW_ID_GD_CONTROLS_TILE,
|
||||||
|
VIEW_ID_GD_RECORD_TILE,
|
||||||
|
VIEW_ID_GD_SCREENSHOT_TILE,
|
||||||
|
VIEW_ID_GD_TOOLBAR_TILE,
|
||||||
|
|
||||||
// The entry to add wifi network in the quick settings network subpage.
|
// The entry to add wifi network in the quick settings network subpage.
|
||||||
VIEW_ID_JOIN_NETWORK_ENTRY,
|
VIEW_ID_JOIN_NETWORK_ENTRY,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user