Skip to content

Commit

Permalink
saved_desks: Clean up names for saved desk (Part 1)
Browse files Browse the repository at this point in the history
This CL clean up some comments, variables, and function names for saved
desk in ash to use the new term instead of Desks Templates. There are no
functionality changes in this CL.

Test: SavedDeskTest.*, DeskSaveAndRecallTest.*, DesksClientTest.*
Bug: b/248647932
Change-Id: I05901e2affaf6f3bdb19079bcdd649243137fcd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4099551
Reviewed-by: Yongshun Liu <yongshun@chromium.org>
Reviewed-by: Daniel Andersson <dandersson@chromium.org>
Commit-Queue: Hongyu Long <hongyulong@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1085093}
  • Loading branch information
Hongyu Long authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent 6eb94b3 commit 2d5a78f
Show file tree
Hide file tree
Showing 35 changed files with 371 additions and 376 deletions.
7 changes: 3 additions & 4 deletions ash/wm/desks/desk.cc
Expand Up @@ -203,10 +203,9 @@ class DeskContainerObserver : public aura::WindowObserver {
}

void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
// We need this for desks templates, where new app windows can be created
// while in overview. The window may not be visible when `OnWindowAdded` is
// called so updating the previews then wouldn't show the new window
// preview.
// We need this for saved desks, where new app windows can be created while
// in overview. The window may not be visible when `OnWindowAdded` is called
// so updating the previews then wouldn't show the new window preview.

if (!Shell::Get()->overview_controller()->InOverviewSession())
return;
Expand Down
3 changes: 1 addition & 2 deletions ash/wm/desks/desk_mini_view.h
Expand Up @@ -89,8 +89,7 @@ class ASH_EXPORT DeskMiniView : public views::View,
void OnWidgetGestureTap(const gfx::Rect& screen_rect, bool is_long_gesture);

// Updates the focus color of the `DeskPreviewView` based on the activation
// state of the corresponding desk and whether the desks template grid is
// visible.
// state of the corresponding desk and whether the saved desk grid is visible.
void UpdateFocusColor();

// Gets the preview border's insets.
Expand Down
28 changes: 15 additions & 13 deletions ash/wm/desks/desk_mini_view_animations.cc
Expand Up @@ -238,7 +238,7 @@ void PerformNewDeskMiniViewAnimation(
std::vector<DeskMiniView*> mini_views_left,
std::vector<DeskMiniView*> mini_views_right,
ExpandedDesksBarButton* expanded_state_new_desk_button,
ExpandedDesksBarButton* expanded_state_desks_templates_button,
ExpandedDesksBarButton* expanded_state_library_button,
int shift_x) {
DCHECK(expanded_state_new_desk_button);
gfx::Transform mini_views_left_begin_transform;
Expand All @@ -262,14 +262,15 @@ void PerformNewDeskMiniViewAnimation(
AnimateMiniViews(mini_views_left, mini_views_left_begin_transform);
AnimateMiniViews(mini_views_right, mini_views_right_begin_transform);

// The new desk button and the desk templates button in the expanded desks bar
// The new desk button and the library button in the expanded desks bar
// always move to the right when a new desk is added.
const auto& button_transform = base::i18n::IsRTL()
? mini_views_left_begin_transform
: mini_views_right_begin_transform;
AnimateView(expanded_state_new_desk_button, button_transform);
if (expanded_state_desks_templates_button)
AnimateView(expanded_state_desks_templates_button, button_transform);
if (expanded_state_library_button) {
AnimateView(expanded_state_library_button, button_transform);
}
}

void PerformRemoveDeskMiniViewAnimation(
Expand All @@ -278,7 +279,7 @@ void PerformRemoveDeskMiniViewAnimation(
std::vector<DeskMiniView*> mini_views_left,
std::vector<DeskMiniView*> mini_views_right,
ExpandedDesksBarButton* expanded_state_new_desk_button,
ExpandedDesksBarButton* expanded_state_desks_templates_button,
ExpandedDesksBarButton* expanded_state_library_button,
int shift_x) {
gfx::Transform mini_views_left_begin_transform;
mini_views_left_begin_transform.Translate(shift_x, 0);
Expand All @@ -295,8 +296,9 @@ void PerformRemoveDeskMiniViewAnimation(
? mini_views_left_begin_transform
: mini_views_right_begin_transform;
AnimateView(expanded_state_new_desk_button, button_transform);
if (expanded_state_desks_templates_button)
AnimateView(expanded_state_desks_templates_button, button_transform);
if (expanded_state_library_button) {
AnimateView(expanded_state_library_button, button_transform);
}
}

void PerformZeroStateToExpandedStateMiniViewAnimation(DesksBarView* bar_view) {
Expand All @@ -307,9 +309,9 @@ void PerformZeroStateToExpandedStateMiniViewAnimation(DesksBarView* bar_view) {

ScaleUpAndFadeInView(bar_view->expanded_state_new_desk_button(),
bar_x_center);
if (auto* expanded_state_desks_templates_button =
bar_view->expanded_state_desks_templates_button()) {
ScaleUpAndFadeInView(expanded_state_desks_templates_button, bar_x_center);
if (auto* expanded_state_library_button =
bar_view->expanded_state_library_button()) {
ScaleUpAndFadeInView(expanded_state_library_button, bar_x_center);
}
PositionWindowsInOverview();
}
Expand All @@ -323,9 +325,9 @@ void PerformExpandedStateToZeroStateMiniViewAnimation(
const gfx::Rect bounds = bar_view->bounds();
ScaleDownAndFadeOutView(bar_view->expanded_state_new_desk_button(),
bounds.CenterPoint().x());
if (auto* expanded_state_desks_templates_button =
bar_view->expanded_state_desks_templates_button()) {
ScaleDownAndFadeOutView(expanded_state_desks_templates_button,
if (auto* expanded_state_library_button =
bar_view->expanded_state_library_button()) {
ScaleDownAndFadeOutView(expanded_state_library_button,
bounds.CenterPoint().x());
}

Expand Down
8 changes: 4 additions & 4 deletions ash/wm/desks/desk_mini_view_animations.h
Expand Up @@ -24,7 +24,7 @@ class ExpandedDesksBarButton;
// the newly-created mini_views. `mini_views_left` are the mini views on the
// left of the new mini views in the desks bar, while `mini_views_right` are the
// mini views on the right side of the new mini views.
// `expanded_state_new_desk_button` and `expanded_state_desks_templates_button`
// `expanded_state_new_desk_button` and `expanded_state_library_button`
// (if it exists) will be moved to the right. `shift_x` is the amount by which
// the mini_views (new and existing) will be moved horizontally as a result of
// creating the new mini_views.
Expand All @@ -38,7 +38,7 @@ void PerformNewDeskMiniViewAnimation(
std::vector<DeskMiniView*> mini_views_left,
std::vector<DeskMiniView*> mini_views_right,
ExpandedDesksBarButton* expanded_state_new_desk_button,
ExpandedDesksBarButton* expanded_state_desks_templates_button,
ExpandedDesksBarButton* expanded_state_library_button,
int shift_x);

// Performs the mini_view removal animation. It is in charge of removing the
Expand All @@ -47,7 +47,7 @@ void PerformNewDeskMiniViewAnimation(
// |mini_views_left|, and |mini_views_right| are lists of the remaining
// mini_views to left and to the right of the removed mini_view respectively.
// |expanded_state_new_desk_button| will be moved to right the same as
// |mini_views_right|. If |expanded_state_desks_templates_button| is non-null,
// |mini_views_right|. If |expanded_state_library_button| is non-null,
// it will also be moved to the right the same as |mini_views_right|. Either
// list can be empty (e.g. if the removed mini_view is the last one on the
// right). |shift_x| is the amount by which the remaining mini_views will be
Expand All @@ -60,7 +60,7 @@ void PerformRemoveDeskMiniViewAnimation(
std::vector<DeskMiniView*> mini_views_left,
std::vector<DeskMiniView*> mini_views_right,
ExpandedDesksBarButton* expanded_state_new_desk_button,
ExpandedDesksBarButton* expanded_state_desks_templates_button,
ExpandedDesksBarButton* expanded_state_library_button,
int shift_x);

// Performs the animation of switching from zero state desks bar to expanded
Expand Down
4 changes: 2 additions & 2 deletions ash/wm/desks/desk_preview_view.cc
Expand Up @@ -272,8 +272,8 @@ void GetLayersData(aura::Window* window,
layer_data.should_force_mirror_visible = true;

// Since floated window is not stored in desk container and will be hidden
// when the desk is inactive, or when we switch to the template/save desk grid
// on overview (via `HideForSavedDeskLibrary` etc.). We need to make sure it's
// when the desk is inactive, or when we switch to the saved desk grid on
// overview (via `HideForSavedDeskLibrary` etc.). We need to make sure it's
// visible in the desk mini view at anytime, except when it's minimized (which
// has been handled above). Currently we force the floated window to be
// visible at all time, since we don't have a use case where we need to hide
Expand Down
83 changes: 38 additions & 45 deletions ash/wm/desks/desks_bar_view.cc
Expand Up @@ -246,22 +246,20 @@ class DesksBarScrollViewLayout : public views::LayoutManager {
saved_desk_util::IsSavedDesksEnabled() && session &&
!session->is_shutting_down() &&
session->saved_desk_presenter()->should_show_saved_desk_library();
auto* zero_state_desks_templates_button =
bar_view_->zero_state_desks_templates_button();
const gfx::Size zero_state_desks_templates_button_size =
auto* zero_state_library_button = bar_view_->zero_state_library_button();
const gfx::Size zero_state_library_button_size =
should_show_saved_desk_library
? zero_state_desks_templates_button->GetPreferredSize()
? zero_state_library_button->GetPreferredSize()
: gfx::Size();
const int width_for_zero_state_desks_templates_button =
const int width_for_zero_state_library_button =
should_show_saved_desk_library
? zero_state_desks_templates_button_size.width() +
kZeroStateButtonSpacing
? zero_state_library_button_size.width() + kZeroStateButtonSpacing
: 0;

const int content_width = zero_state_default_desk_button_size.width() +
kZeroStateButtonSpacing +
zero_state_new_desk_button_size.width() +
width_for_zero_state_desks_templates_button;
width_for_zero_state_library_button;
zero_state_default_desk_button->SetBoundsRect(gfx::Rect(
gfx::Point((scroll_bounds.width() - content_width) / 2, kZeroStateY),
zero_state_default_desk_button_size));
Expand All @@ -278,14 +276,13 @@ class DesksBarScrollViewLayout : public views::LayoutManager {
kZeroStateY),
zero_state_new_desk_button_size));

if (zero_state_desks_templates_button) {
zero_state_desks_templates_button->SetBoundsRect(
if (zero_state_library_button) {
zero_state_library_button->SetBoundsRect(
gfx::Rect(gfx::Point(zero_state_new_desk_button->bounds().right() +
kZeroStateButtonSpacing,
kZeroStateY),
zero_state_desks_templates_button_size));
zero_state_desks_templates_button->SetVisible(
should_show_saved_desk_library);
zero_state_library_button_size));
zero_state_library_button->SetVisible(should_show_saved_desk_library);
}
return;
}
Expand All @@ -299,19 +296,18 @@ class DesksBarScrollViewLayout : public views::LayoutManager {
if (base::i18n::IsRTL())
base::ranges::reverse(mini_views);

auto* expanded_state_desks_templates_button =
bar_view_->expanded_state_desks_templates_button();
const bool expanded_state_desks_templates_button_visible =
expanded_state_desks_templates_button &&
expanded_state_desks_templates_button->GetVisible();
auto* expanded_state_library_button =
bar_view_->expanded_state_library_button();
const bool expanded_state_library_button_visible =
expanded_state_library_button &&
expanded_state_library_button->GetVisible();

gfx::Size mini_view_size = mini_views[0]->GetPreferredSize();

// The new desk button and template button in the expanded bar view has the
// The new desk button and library button in the expanded bar view has the
// same size as mini view.
const int num_items =
static_cast<int>(mini_views.size()) +
(expanded_state_desks_templates_button_visible ? 2 : 1);
const int num_items = static_cast<int>(mini_views.size()) +
(expanded_state_library_button_visible ? 2 : 1);

// Content width is sum of the width of all views, and plus the spacing
// between the views, the focus ring's thickness and padding on each sides.
Expand Down Expand Up @@ -339,9 +335,9 @@ class DesksBarScrollViewLayout : public views::LayoutManager {
bar_view_->expanded_state_new_desk_button()->SetBoundsRect(
gfx::Rect(gfx::Point(x, y), mini_view_size));

if (expanded_state_desks_templates_button) {
if (expanded_state_library_button) {
x += (mini_view_size.width() + kMiniViewsSpacing);
expanded_state_desks_templates_button->SetBoundsRect(
expanded_state_library_button->SetBoundsRect(
gfx::Rect(gfx::Point(x, y), mini_view_size));
}
}
Expand Down Expand Up @@ -438,15 +434,14 @@ DesksBarView::DesksBarView(OverviewGrid* overview_grid)
if (!saved_desk_util::AreDesksTemplatesEnabled())
button_text_id = IDS_ASH_DESKS_TEMPLATES_DESKS_BAR_BUTTON_SAVED_FOR_LATER;

expanded_state_desks_templates_button_ =
scroll_view_contents_->AddChildView(
std::make_unique<ExpandedDesksBarButton>(
this, &kDesksTemplatesIcon,
l10n_util::GetStringUTF16(button_text_id),
/*initially_enabled=*/true,
base::BindRepeating(&DesksBarView::OnLibraryButtonPressed,
base::Unretained(this))));
zero_state_desks_templates_button_ = scroll_view_contents_->AddChildView(
expanded_state_library_button_ = scroll_view_contents_->AddChildView(
std::make_unique<ExpandedDesksBarButton>(
this, &kDesksTemplatesIcon,
l10n_util::GetStringUTF16(button_text_id),
/*initially_enabled=*/true,
base::BindRepeating(&DesksBarView::OnLibraryButtonPressed,
base::Unretained(this))));
zero_state_library_button_ = scroll_view_contents_->AddChildView(
std::make_unique<ZeroStateIconButton>(
&kDesksTemplatesIcon, l10n_util::GetStringUTF16(button_text_id),
base::BindRepeating(&DesksBarView::OnLibraryButtonPressed,
Expand Down Expand Up @@ -896,7 +891,7 @@ void DesksBarView::OnDeskRemoved(const Desk* desk) {
this, removed_mini_view,
std::vector<DeskMiniView*>(mini_views_.begin(), partition_iter),
std::vector<DeskMiniView*>(partition_iter, mini_views_.end()),
expanded_state_new_desk_button_, expanded_state_desks_templates_button_,
expanded_state_new_desk_button_, expanded_state_library_button_,
begin_x - GetFirstMiniViewXOffset());

MaybeUpdateCombineDesksTooltips();
Expand Down Expand Up @@ -988,7 +983,7 @@ void DesksBarView::UpdateNewMiniViews(bool initializing_bar_view,
new_mini_views,
std::vector<DeskMiniView*>(mini_views_.begin(), left_partition_iter),
std::vector<DeskMiniView*>(right_partition_iter, mini_views_.end()),
expanded_state_new_desk_button_, expanded_state_desks_templates_button_,
expanded_state_new_desk_button_, expanded_state_library_button_,
begin_x - GetFirstMiniViewXOffset());
}

Expand Down Expand Up @@ -1023,9 +1018,9 @@ void DesksBarView::UpdateButtonsForSavedDeskGrid() {

FindMiniViewForDesk(Shell::Get()->desks_controller()->active_desk())
->UpdateFocusColor();
expanded_state_desks_templates_button_->set_active(
expanded_state_library_button_->set_active(
overview_grid_->IsShowingSavedDeskLibrary());
expanded_state_desks_templates_button_->UpdateFocusColor();
expanded_state_library_button_->UpdateFocusColor();
}

void DesksBarView::UpdateDeskButtonsVisibility() {
Expand All @@ -1048,20 +1043,18 @@ void DesksBarView::UpdateLibraryButtonVisibility() {
->should_show_saved_desk_library();
const bool is_zero_state = IsZeroState();

zero_state_desks_templates_button_->SetVisible(should_show_ui &&
is_zero_state);
expanded_state_desks_templates_button_->SetVisible(should_show_ui &&
!is_zero_state);
zero_state_library_button_->SetVisible(should_show_ui && is_zero_state);
expanded_state_library_button_->SetVisible(should_show_ui && !is_zero_state);

// Removes the button from the tabbing order if it becomes invisible.
auto* highlight_controller = GetHighlightController();
if (!zero_state_desks_templates_button_->GetVisible()) {
if (!zero_state_library_button_->GetVisible()) {
highlight_controller->OnViewDestroyingOrDisabling(
zero_state_desks_templates_button_);
zero_state_library_button_);
}
if (!expanded_state_desks_templates_button_->GetVisible()) {
if (!expanded_state_library_button_->GetVisible()) {
highlight_controller->OnViewDestroyingOrDisabling(
expanded_state_desks_templates_button_->GetInnerButton());
expanded_state_library_button_->GetInnerButton());
}

const int begin_x = GetFirstMiniViewXOffset();
Expand Down
20 changes: 10 additions & 10 deletions ash/wm/desks/desks_bar_view.h
Expand Up @@ -72,12 +72,12 @@ class ASH_EXPORT DesksBarView : public views::View,
return expanded_state_new_desk_button_;
}

ZeroStateIconButton* zero_state_desks_templates_button() const {
return zero_state_desks_templates_button_;
ZeroStateIconButton* zero_state_library_button() const {
return zero_state_library_button_;
}

ExpandedDesksBarButton* expanded_state_desks_templates_button() const {
return expanded_state_desks_templates_button_;
ExpandedDesksBarButton* expanded_state_library_button() const {
return expanded_state_library_button_;
}

const std::vector<DeskMiniView*>& mini_views() const { return mini_views_; }
Expand Down Expand Up @@ -187,9 +187,9 @@ class ASH_EXPORT DesksBarView : public views::View,
DesksCreationRemovalSource desks_creation_removal_source);

// If in expanded state, updates the border color of the
// `expanded_state_desks_templates_button_` and the active desk's mini view
// `expanded_state_library_button_` and the active desk's mini view
// after the saved desk library has been shown. If not in expanded state,
// updates the background color of the `zero_state_desks_templates_button_`
// updates the background color of the `zero_state_library_button_`
// and the `zero_state_default_desk_button_`.
void UpdateButtonsForSavedDeskGrid();

Expand Down Expand Up @@ -287,7 +287,7 @@ class ASH_EXPORT DesksBarView : public views::View,

// Contents of `scroll_view_`, which includes `mini_views_`,
// `expanded_state_new_desk_button_` and optionally
// `expanded_state_desks_templates_button_` currently.
// `expanded_state_library_button_` currently.
views::View* scroll_view_contents_ = nullptr;

// True if the `DesksBarBoundsAnimation` is started and hasn't finished yet.
Expand All @@ -304,9 +304,9 @@ class ASH_EXPORT DesksBarView : public views::View,
ZeroStateIconButton* zero_state_new_desk_button_ = nullptr;
ExpandedDesksBarButton* expanded_state_new_desk_button_ = nullptr;

// Buttons to show the desks templates grid.
ZeroStateIconButton* zero_state_desks_templates_button_ = nullptr;
ExpandedDesksBarButton* expanded_state_desks_templates_button_ = nullptr;
// Buttons to show the saved desk grid.
ZeroStateIconButton* zero_state_library_button_ = nullptr;
ExpandedDesksBarButton* expanded_state_library_button_ = nullptr;

ScrollArrowButton* left_scroll_button_ = nullptr;
ScrollArrowButton* right_scroll_button_ = nullptr;
Expand Down
8 changes: 4 additions & 4 deletions ash/wm/desks/desks_controller.cc
Expand Up @@ -858,7 +858,7 @@ bool DesksController::MoveWindowFromActiveDeskTo(
} else if (visible_on_all_desks) {
// Create an item for a visible on all desks window if it doesn't have one
// already. This can happen when launching a template. When we are in the
// templates grid, there are no items.
// saved desk grid, there are no items.
overview_session->AppendItem(window,
/*reposition=*/true, /*animate=*/true);
}
Expand Down Expand Up @@ -1150,9 +1150,9 @@ const Desk* DesksController::CreateNewDeskForSavedDesk(

if (template_type == DeskTemplateType::kTemplate ||
template_type == DeskTemplateType::kFloatingWorkspace) {
// We're staying in overview mode, so move desks bar window and the save
// template button to the new desk. They would otherwise disappear when the
// new desk is activated.
// We're staying in overview mode, so move desks bar window and the
// save desk buttons to the new desk. They would otherwise disappear
// when the new desk is activated.
DCHECK(active_desk_);

// Since we're going to move certain windows from the currently active desk,
Expand Down

0 comments on commit 2d5a78f

Please sign in to comment.