forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desk Templates: Create delete button
This CL adds in the UI elements for the delete button, as well as the show on hover functionality by having the GridView listen for mouse and touch events, then updating the visibility of the delete button. A PreTargetHandler was required to ensure that events are not accidentally captured by other views. Actual delete functionality (hooking it up to DeskModel) and style will be added in later. Bug: 1255300 Test: manual Change-Id: I3202c7c3c4377d94940ecc8b1d387f914eb41e76 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3200479 Commit-Queue: Richard Chui <richui@chromium.org> Reviewed-by: Sammie Quon <sammiequon@chromium.org> Cr-Commit-Position: refs/heads/main@{#930645}
- Loading branch information
Richard Chui
authored and
Chromium LUCI CQ
committed
Oct 12, 2021
1 parent
be0664d
commit b414fa4
Showing
9 changed files
with
229 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2021 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/wm/desks/templates/desks_templates_delete_button.h" | ||
|
||
#include "ash/resources/vector_icons/vector_icons.h" | ||
#include "ash/style/element_style.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
#include "ui/base/metadata/metadata_impl_macros.h" | ||
#include "ui/strings/grit/ui_strings.h" | ||
|
||
namespace ash { | ||
|
||
DesksTemplatesDeleteButton::DesksTemplatesDeleteButton() { | ||
views::Builder<DesksTemplatesDeleteButton>(this) | ||
.SetImageHorizontalAlignment(views::ImageButton::ALIGN_CENTER) | ||
.SetImageVerticalAlignment(views::ImageButton::ALIGN_MIDDLE) | ||
.SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_DELETE)) | ||
.BuildChildren(); | ||
} | ||
|
||
DesksTemplatesDeleteButton::~DesksTemplatesDeleteButton() = default; | ||
|
||
void DesksTemplatesDeleteButton::OnThemeChanged() { | ||
views::ImageButton::OnThemeChanged(); | ||
element_style::DecorateMediumCloseButton(this, kTrashCanIcon); | ||
} | ||
|
||
BEGIN_METADATA(DesksTemplatesDeleteButton, views::ImageButton) | ||
END_METADATA | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2021 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_WM_DESKS_TEMPLATES_DESKS_TEMPLATES_DELETE_BUTTON_H_ | ||
#define ASH_WM_DESKS_TEMPLATES_DESKS_TEMPLATES_DELETE_BUTTON_H_ | ||
|
||
#include "ui/base/metadata/metadata_header_macros.h" | ||
#include "ui/views/controls/button/image_button.h" | ||
|
||
namespace ash { | ||
|
||
// A button view that shows up when hovering over the associated grid item. | ||
// Allows the user to delete the template. | ||
class DesksTemplatesDeleteButton : public views::ImageButton { | ||
public: | ||
METADATA_HEADER(DesksTemplatesDeleteButton); | ||
|
||
DesksTemplatesDeleteButton(); | ||
DesksTemplatesDeleteButton(const DesksTemplatesDeleteButton&) = delete; | ||
DesksTemplatesDeleteButton& operator=(const DesksTemplatesDeleteButton&) = | ||
delete; | ||
~DesksTemplatesDeleteButton() override; | ||
|
||
// views::ImageButton: | ||
void OnThemeChanged() override; | ||
}; | ||
|
||
BEGIN_VIEW_BUILDER(/* no export */, | ||
DesksTemplatesDeleteButton, | ||
views::ImageButton) | ||
END_VIEW_BUILDER | ||
|
||
} // namespace ash | ||
|
||
DEFINE_VIEW_BUILDER(/* no export */, ash::DesksTemplatesDeleteButton) | ||
|
||
#endif // ASH_WM_DESKS_TEMPLATES_DESKS_TEMPLATES_DELETE_BUTTON_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.