Commit bbb93918 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Remove remaining code for scaling app list main view

Removes code that was used to scaled the app list main view on small
screens (when apps grid did not fit into the available space).

CL:1759856 changed approach to update the item sizes inside the apps
grid instead. The following is thus no longer necessary:
*   AppsContainerView::GetMinimumSize() override
    -   was used to calculate whether and what scale to use (the usage
        has been removed; not used during container layout
*   ContentsView::GetAppListMainViewScale()
    -   the scale transform on the main view does not get set any
        longer, so the scale should always be 1

Change-Id: I2bcafd63b7e34c2c40167d365cfbe83b192f71e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1789467Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695287}
parent be5dec24
...@@ -422,21 +422,6 @@ void AppsContainerView::OnGestureEvent(ui::GestureEvent* event) { ...@@ -422,21 +422,6 @@ void AppsContainerView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled(); event->SetHandled();
} }
gfx::Size AppsContainerView::GetMinimumSize() const {
const bool switch_cols_and_rows = ShouldSwitchColsAndRows();
const int cols = switch_cols_and_rows
? AppListConfig::instance().preferred_rows()
: AppListConfig::instance().preferred_cols();
const int rows = switch_cols_and_rows
? AppListConfig::instance().preferred_cols()
: AppListConfig::instance().preferred_rows();
gfx::Size min_size = apps_grid_view_->GetMinimumTileGridSize(cols, rows);
const gfx::Size non_apps_grid_size = GetNonAppsGridSize();
min_size.Enlarge(non_apps_grid_size.width(), non_apps_grid_size.height());
return min_size;
}
void AppsContainerView::OnWillBeHidden() { void AppsContainerView::OnWillBeHidden() {
if (show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) if (show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT)
apps_grid_view_->EndDrag(true); apps_grid_view_->EndDrag(true);
......
...@@ -81,7 +81,6 @@ class APP_LIST_EXPORT AppsContainerView : public HorizontalPage { ...@@ -81,7 +81,6 @@ class APP_LIST_EXPORT AppsContainerView : public HorizontalPage {
bool OnKeyPressed(const ui::KeyEvent& event) override; bool OnKeyPressed(const ui::KeyEvent& event) override;
const char* GetClassName() const override; const char* GetClassName() const override;
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
gfx::Size GetMinimumSize() const override;
// HorizontalPage overrides: // HorizontalPage overrides:
void OnWillBeHidden() override; void OnWillBeHidden() override;
......
...@@ -2124,8 +2124,7 @@ void AppsGridView::StartDragAndDropHostDrag(const gfx::Point& grid_location) { ...@@ -2124,8 +2124,7 @@ void AppsGridView::StartDragAndDropHostDrag(const gfx::Point& grid_location) {
DCHECK(!IsDraggingForReparentInRootLevelGridView()); DCHECK(!IsDraggingForReparentInRootLevelGridView());
drag_and_drop_host_->CreateDragIconProxyByLocationWithNoAnimation( drag_and_drop_host_->CreateDragIconProxyByLocationWithNoAnimation(
drag_view_->GetIconBoundsInScreen().origin(), drag_view_->GetIconImage(), drag_view_->GetIconBoundsInScreen().origin(), drag_view_->GetIconImage(),
drag_view_, drag_view_, kDragAndDropProxyScale,
kDragAndDropProxyScale * contents_view_->GetAppListMainViewScale(),
drag_view_->item()->is_folder() && IsTabletMode() drag_view_->item()->is_folder() && IsTabletMode()
? GetAppListConfig().blur_radius() ? GetAppListConfig().blur_radius()
: 0); : 0);
......
...@@ -370,9 +370,6 @@ void ContentsView::InitializeSearchBoxAnimation( ...@@ -370,9 +370,6 @@ void ContentsView::InitializeSearchBoxAnimation(
// to be original bounds. Note that this transform shouldn't be animated // to be original bounds. Note that this transform shouldn't be animated
// through ui::LayerAnimator since intermediate transformed bounds might not // through ui::LayerAnimator since intermediate transformed bounds might not
// match with other animation and that could look janky. // match with other animation and that could look janky.
const float scale = GetAppListMainViewScale();
target_bounds.set_origin(
gfx::Point(target_bounds.x() * scale, target_bounds.y() * scale));
search_box->GetWidget()->SetBounds(target_bounds); search_box->GetWidget()->SetBounds(target_bounds);
UpdateSearchBoxAnimation(0.0f, current_state, target_state); UpdateSearchBoxAnimation(0.0f, current_state, target_state);
...@@ -385,8 +382,6 @@ void ContentsView::UpdateSearchBoxAnimation(double progress, ...@@ -385,8 +382,6 @@ void ContentsView::UpdateSearchBoxAnimation(double progress,
if (!search_box->GetWidget()) if (!search_box->GetWidget())
return; return;
const float scale = GetAppListMainViewScale();
gfx::Rect previous_bounds = GetSearchBoxBoundsForState(current_state); gfx::Rect previous_bounds = GetSearchBoxBoundsForState(current_state);
previous_bounds = search_box->GetViewBoundsForSearchBoxContentsBounds( previous_bounds = search_box->GetViewBoundsForSearchBoxContentsBounds(
ConvertRectToWidgetWithoutTransform(previous_bounds)); ConvertRectToWidgetWithoutTransform(previous_bounds));
...@@ -398,14 +393,11 @@ void ContentsView::UpdateSearchBoxAnimation(double progress, ...@@ -398,14 +393,11 @@ void ContentsView::UpdateSearchBoxAnimation(double progress,
gfx::Tween::RectValueBetween(progress, previous_bounds, target_bounds); gfx::Tween::RectValueBetween(progress, previous_bounds, target_bounds);
gfx::Transform transform; gfx::Transform transform;
if (current_bounds == target_bounds) { if (current_bounds != target_bounds) {
transform.Scale(scale, scale);
} else {
transform.Translate(current_bounds.origin() - target_bounds.origin()); transform.Translate(current_bounds.origin() - target_bounds.origin());
// The existence of |scale| casts the width/height to float, so it's safe to transform.Scale(
// divide. static_cast<float>(current_bounds.width()) / target_bounds.width(),
transform.Scale(scale * current_bounds.width() / target_bounds.width(), static_cast<float>(current_bounds.height()) / target_bounds.height());
scale * current_bounds.height() / target_bounds.height());
} }
search_box->GetWidget()->GetLayer()->SetTransform(transform); search_box->GetWidget()->GetLayer()->SetTransform(transform);
} }
...@@ -607,16 +599,11 @@ void ContentsView::Layout() { ...@@ -607,16 +599,11 @@ void ContentsView::Layout() {
gfx::Rect search_box_bounds = GetSearchBoxBoundsForState(current_state); gfx::Rect search_box_bounds = GetSearchBoxBoundsForState(current_state);
search_box_bounds = search_box->GetViewBoundsForSearchBoxContentsBounds( search_box_bounds = search_box->GetViewBoundsForSearchBoxContentsBounds(
ConvertRectToWidgetWithoutTransform(search_box_bounds)); ConvertRectToWidgetWithoutTransform(search_box_bounds));
const float scale = GetAppListMainViewScale();
search_box_bounds.set_origin(
gfx::Point(search_box_bounds.x() * scale, search_box_bounds.y() * scale));
search_box->GetWidget()->SetBounds(search_box_bounds); search_box->GetWidget()->SetBounds(search_box_bounds);
search_box->UpdateLayout(1.f, current_state, current_state); search_box->UpdateLayout(1.f, current_state, current_state);
search_box->UpdateBackground(1.f, current_state, current_state); search_box->UpdateBackground(1.f, current_state, current_state);
// Reset the transform which can be set through animation. // Reset the transform which can be set through animation.
gfx::Transform transform; search_box->GetWidget()->GetLayer()->SetTransform(gfx::Transform());
transform.Scale(scale, scale);
search_box->GetWidget()->GetLayer()->SetTransform(transform);
} }
const char* ContentsView::GetClassName() const { const char* ContentsView::GetClassName() const {
...@@ -716,13 +703,6 @@ void ContentsView::UpdateYPositionAndOpacity() { ...@@ -716,13 +703,6 @@ void ContentsView::UpdateYPositionAndOpacity() {
gfx::Rect search_rect = search_box->GetViewBoundsForSearchBoxContentsBounds( gfx::Rect search_rect = search_box->GetViewBoundsForSearchBoxContentsBounds(
ConvertRectToWidgetWithoutTransform( ConvertRectToWidgetWithoutTransform(
apps_container_view->GetSearchBoxExpectedBounds())); apps_container_view->GetSearchBoxExpectedBounds()));
// Search box is in a different widget with AppListMainView, so we need to
// manually transform the search box position using the same scale based on
// the same origin.
const float scale = GetAppListMainViewScale();
search_rect.set_origin(
gfx::Point(search_rect.x() * scale, search_rect.y() * scale));
search_box->GetWidget()->SetBounds(search_rect); search_box->GetWidget()->SetBounds(search_rect);
search_results_page_view()->SetBoundsRect( search_results_page_view()->SetBoundsRect(
...@@ -731,11 +711,6 @@ void ContentsView::UpdateYPositionAndOpacity() { ...@@ -731,11 +711,6 @@ void ContentsView::UpdateYPositionAndOpacity() {
apps_container_view->UpdateYPositionAndOpacity(); apps_container_view->UpdateYPositionAndOpacity();
} }
float ContentsView::GetAppListMainViewScale() const {
// The x and y scale are the same.
return app_list_view_->app_list_main_view()->GetTransform().Scale2d().x();
}
void ContentsView::SetExpandArrowViewVisibility(bool show) { void ContentsView::SetExpandArrowViewVisibility(bool show) {
if (expand_arrow_view_->GetVisible() == show) if (expand_arrow_view_->GetVisible() == show)
return; return;
......
...@@ -214,10 +214,6 @@ class APP_LIST_EXPORT ContentsView : public views::View, ...@@ -214,10 +214,6 @@ class APP_LIST_EXPORT ContentsView : public views::View,
// Updates y position and opacity of the items in this view during dragging. // Updates y position and opacity of the items in this view during dragging.
void UpdateYPositionAndOpacity(); void UpdateYPositionAndOpacity();
// Returns the scale that is used to transform the AppListMainView. The scale
// is also applied to search box window.
float GetAppListMainViewScale() const;
// Show/hide the expand arrow view button when contents view is in fullscreen // Show/hide the expand arrow view button when contents view is in fullscreen
// and tablet mode is enabled. // and tablet mode is enabled.
void SetExpandArrowViewVisibility(bool show); void SetExpandArrowViewVisibility(bool show);
......
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