Commit 9a3e910e authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

cros: Use current shelf size within AppListView.

Allow app_list_view and other code within app_list to access the
current shelf size where needed. This has become necessary
because, when the hotseat flag is enabled, shelf size can change
during runtime.

Bug: 973483
Change-Id: I90b52cae00ccb90d9d151283804444226fd4a097
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815601
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699505}
parent 225f398a
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "ash/public/cpp/app_list/app_list_metrics.h" #include "ash/public/cpp/app_list/app_list_metrics.h"
#include "ash/public/cpp/app_list/app_list_types.h" #include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
...@@ -1223,6 +1224,10 @@ gfx::Rect AppListControllerImpl::SnapBoundsToDisplayEdge( ...@@ -1223,6 +1224,10 @@ gfx::Rect AppListControllerImpl::SnapBoundsToDisplayEdge(
return ash::screen_util::SnapBoundsToDisplayEdge(bounds, window); return ash::screen_util::SnapBoundsToDisplayEdge(bounds, window);
} }
int AppListControllerImpl::GetShelfHeight() {
return ShelfConfig::Get()->shelf_size();
}
void AppListControllerImpl::RecordAppLaunched( void AppListControllerImpl::RecordAppLaunched(
AppListLaunchedFrom launched_from) { AppListLaunchedFrom launched_from) {
app_list::RecordAppListAppLaunched(launched_from, GetAppListViewState(), app_list::RecordAppListAppLaunched(launched_from, GetAppListViewState(),
......
...@@ -211,6 +211,7 @@ class ASH_EXPORT AppListControllerImpl ...@@ -211,6 +211,7 @@ class ASH_EXPORT AppListControllerImpl
void GetAppLaunchedMetricParams( void GetAppLaunchedMetricParams(
app_list::AppLaunchedMetricParams* metric_params) override; app_list::AppLaunchedMetricParams* metric_params) override;
gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds) override; gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds) override;
int GetShelfHeight() override;
void AddObserver(AppListControllerObserver* observer); void AddObserver(AppListControllerObserver* observer);
void RemoveObserver(AppListControllerObserver* obsever); void RemoveObserver(AppListControllerObserver* obsever);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ash/keyboard/keyboard_controller_impl.h" #include "ash/keyboard/keyboard_controller_impl.h"
#include "ash/public/cpp/app_list/app_list_config.h" #include "ash/public/cpp/app_list/app_list_config.h"
#include "ash/public/cpp/presentation_time_recorder.h" #include "ash/public/cpp/presentation_time_recorder.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_layout_manager.h"
...@@ -185,8 +186,7 @@ TEST_F(AppListControllerImplTest, HideRoundingCorners) { ...@@ -185,8 +186,7 @@ TEST_F(AppListControllerImplTest, HideRoundingCorners) {
EXPECT_EQ(0, app_list_screen_bounds.y()); EXPECT_EQ(0, app_list_screen_bounds.y());
EXPECT_EQ(ash::AppListViewState::kHalf, GetAppListView()->app_list_state()); EXPECT_EQ(ash::AppListViewState::kHalf, GetAppListView()->app_list_state());
gfx::Transform expected_transform; gfx::Transform expected_transform;
expected_transform.Translate( expected_transform.Translate(0, -(ShelfConfig::Get()->shelf_size() / 2));
0, -app_list::AppListConfig::instance().background_radius());
EXPECT_EQ( EXPECT_EQ(
expected_transform, expected_transform,
GetAppListView()->GetAppListBackgroundShieldForTest()->GetTransform()); GetAppListView()->GetAppListBackgroundShieldForTest()->GetTransform());
...@@ -236,8 +236,7 @@ TEST_F(AppListControllerImplTest, HideRoundingCornersWhenEmojiShows) { ...@@ -236,8 +236,7 @@ TEST_F(AppListControllerImplTest, HideRoundingCornersWhenEmojiShows) {
// AppListBackgroundShield is translated to hide the rounded corners. // AppListBackgroundShield is translated to hide the rounded corners.
gfx::Transform expected_transform; gfx::Transform expected_transform;
expected_transform.Translate( expected_transform.Translate(0, -(ShelfConfig::Get()->shelf_size() / 2));
0, -app_list::AppListConfig::instance().background_radius());
EXPECT_EQ( EXPECT_EQ(
expected_transform, expected_transform,
GetAppListView()->GetAppListBackgroundShieldForTest()->GetTransform()); GetAppListView()->GetAppListBackgroundShieldForTest()->GetTransform());
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/keyboard/keyboard_switches.h" #include "ash/public/cpp/keyboard/keyboard_switches.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_item_delegate.h" #include "ash/public/cpp/shelf_item_delegate.h"
#include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
...@@ -1746,8 +1747,7 @@ TEST_F(AppListPresenterDelegateTest, BackgroundCornerRadiusDuringDrag) { ...@@ -1746,8 +1747,7 @@ TEST_F(AppListPresenterDelegateTest, BackgroundCornerRadiusDuringDrag) {
->GetShelfViewForTesting() ->GetShelfViewForTesting()
->GetBoundsInScreen() ->GetBoundsInScreen()
.top_center(); .top_center();
const int background_radius = const int background_radius = ShelfConfig::Get()->shelf_size() / 2;
app_list::AppListConfig::instance().background_radius();
app_list::AppListView* view = GetAppListView(); app_list::AppListView* view = GetAppListView();
const views::View* const background_shield = const views::View* const background_shield =
...@@ -1825,8 +1825,7 @@ TEST_F(AppListPresenterDelegateTest, ...@@ -1825,8 +1825,7 @@ TEST_F(AppListPresenterDelegateTest,
->GetShelfViewForTesting() ->GetShelfViewForTesting()
->GetBoundsInScreen() ->GetBoundsInScreen()
.top_center(); .top_center();
const int background_radius = const int background_radius = ShelfConfig::Get()->shelf_size() / 2;
app_list::AppListConfig::instance().background_radius();
app_list::AppListView* view = GetAppListView(); app_list::AppListView* view = GetAppListView();
const views::View* const background_shield = const views::View* const background_shield =
...@@ -1949,7 +1948,7 @@ class AppListPresenterDelegateScalableAppListTest ...@@ -1949,7 +1948,7 @@ class AppListPresenterDelegateScalableAppListTest
ExpectedSuggestionChipContainerTop(search_box_bounds) + ExpectedSuggestionChipContainerTop(search_box_bounds) +
32 /*suggestion chip container height*/; 32 /*suggestion chip container height*/;
const int available_height = const int available_height =
display_height - config.shelf_height() - display_height - ShelfConfig::Get()->shelf_size() -
config.search_box_fullscreen_top_padding() - config.search_box_fullscreen_top_padding() -
search_box_bounds.height() - 32 /*suggestion chip container height*/ search_box_bounds.height() - 32 /*suggestion chip container height*/
- 24 /*margin between suggestion chip and search box*/; - 24 /*margin between suggestion chip and search box*/;
...@@ -2015,7 +2014,7 @@ INSTANTIATE_TEST_SUITE_P(ScalableAppListEnabled, ...@@ -2015,7 +2014,7 @@ INSTANTIATE_TEST_SUITE_P(ScalableAppListEnabled,
TEST_P(AppListPresenterDelegateScalableAppListTest, TEST_P(AppListPresenterDelegateScalableAppListTest,
AppsPagePositionDuringDrag) { AppsPagePositionDuringDrag) {
const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig(); const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig();
const int shelf_height = config.shelf_height(); const int shelf_height = ShelfConfig::Get()->shelf_size();
const int fullscreen_y = 0; const int fullscreen_y = 0;
const int closed_y = 900 - shelf_height; const int closed_y = 900 - shelf_height;
const int fullscreen_search_box_padding = const int fullscreen_search_box_padding =
...@@ -2128,7 +2127,7 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, ...@@ -2128,7 +2127,7 @@ TEST_P(AppListPresenterDelegateScalableAppListTest,
GetAppListTestHelper()->CheckState(AppListViewState::kHalf); GetAppListTestHelper()->CheckState(AppListViewState::kHalf);
const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig(); const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig();
const int shelf_height = config.shelf_height(); const int shelf_height = ShelfConfig::Get()->shelf_size();
const int search_results_height = 440; const int search_results_height = 440;
const int fullscreen_y = 0; const int fullscreen_y = 0;
const int closed_y = 900 - shelf_height; const int closed_y = 900 - shelf_height;
...@@ -2274,7 +2273,7 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageDuringDrag) { ...@@ -2274,7 +2273,7 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageDuringDrag) {
GetAppListView()->GetBoundsInScreen().top_center(); GetAppListView()->GetBoundsInScreen().top_center();
const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig(); const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig();
const int shelf_height = config.shelf_height(); const int shelf_height = ShelfConfig::Get()->shelf_size();
const int search_results_height = 440; const int search_results_height = 440;
const int fullscreen_y = 0; const int fullscreen_y = 0;
const int fullscreen_search_box_padding = const int fullscreen_search_box_padding =
...@@ -2381,7 +2380,7 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageInFullscreen) { ...@@ -2381,7 +2380,7 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageInFullscreen) {
GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps); GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps);
const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig(); const app_list::AppListConfig& config = GetAppListView()->GetAppListConfig();
const int shelf_height = config.shelf_height(); const int shelf_height = ShelfConfig::Get()->shelf_size();
const int search_results_height = 440; const int search_results_height = 440;
const int fullscreen_y = 0; const int fullscreen_y = 0;
const int fullscreen_search_box_padding = const int fullscreen_search_box_padding =
......
...@@ -209,6 +209,9 @@ class ASH_PUBLIC_EXPORT AppListViewDelegate { ...@@ -209,6 +209,9 @@ class ASH_PUBLIC_EXPORT AppListViewDelegate {
// Adjusts the bounds by snapping it to the edge of the display in pixel // Adjusts the bounds by snapping it to the edge of the display in pixel
// space. This prevents 1px gaps on displays with non-integer scale factors. // space. This prevents 1px gaps on displays with non-integer scale factors.
virtual gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds) = 0; virtual gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds) = 0;
// Gets the current shelf height from the ShelfConfig.
virtual int GetShelfHeight() = 0;
}; };
} // namespace app_list } // namespace app_list
......
...@@ -195,6 +195,12 @@ gfx::Rect AppListTestViewDelegate::SnapBoundsToDisplayEdge( ...@@ -195,6 +195,12 @@ gfx::Rect AppListTestViewDelegate::SnapBoundsToDisplayEdge(
return bounds; return bounds;
} }
int AppListTestViewDelegate::GetShelfHeight() {
// TODO(mmourgos): change this to 48 once shelf-hotseat flag is enabled.
// Return the height of the shelf when clamshell mode is active.
return 56;
}
void AppListTestViewDelegate::RecordAppLaunched( void AppListTestViewDelegate::RecordAppLaunched(
ash::AppListLaunchedFrom launched_from) { ash::AppListLaunchedFrom launched_from) {
app_list::RecordAppListAppLaunched(launched_from, model_->state_fullscreen(), app_list::RecordAppListAppLaunched(launched_from, model_->state_fullscreen(),
......
...@@ -115,6 +115,7 @@ class AppListTestViewDelegate : public AppListViewDelegate, ...@@ -115,6 +115,7 @@ class AppListTestViewDelegate : public AppListViewDelegate,
void GetAppLaunchedMetricParams( void GetAppLaunchedMetricParams(
app_list::AppLaunchedMetricParams* metric_params) override; app_list::AppLaunchedMetricParams* metric_params) override;
gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds) override; gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds) override;
int GetShelfHeight() override;
// Do a bulk replacement of the items in the model. // Do a bulk replacement of the items in the model.
void ReplaceTestModel(int item_count); void ReplaceTestModel(int item_count);
......
...@@ -188,10 +188,10 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kExcludeWindowFromEventHandling, false) ...@@ -188,10 +188,10 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kExcludeWindowFromEventHandling, false)
// state). // state).
// |height|: App list view height, relative to the shelf top (i.e. distance // |height|: App list view height, relative to the shelf top (i.e. distance
// between app list top and shelf top edge). // between app list top and shelf top edge).
double GetBackgroundRadiusForAppListHeight(double height) { double GetBackgroundRadiusForAppListHeight(double height,
return std::min( int shelf_background_corner_radius) {
static_cast<double>(AppListConfig::instance().background_radius()), return std::min(static_cast<double>(shelf_background_corner_radius),
std::max(height, 0.)); std::max(height, 0.));
} }
// This targeter prevents routing events to sub-windows, such as // This targeter prevents routing events to sub-windows, such as
...@@ -422,10 +422,12 @@ class BoundsAnimationObserver : public ui::ImplicitAnimationObserver { ...@@ -422,10 +422,12 @@ class BoundsAnimationObserver : public ui::ImplicitAnimationObserver {
// The view for the app list background shield which changes color and radius. // The view for the app list background shield which changes color and radius.
class AppListBackgroundShieldView : public views::View { class AppListBackgroundShieldView : public views::View {
public: public:
AppListBackgroundShieldView() : color_(AppListView::kDefaultBackgroundColor) { explicit AppListBackgroundShieldView(int shelf_background_corner_radius)
: color_(AppListView::kDefaultBackgroundColor),
shelf_background_corner_radius_(shelf_background_corner_radius) {
SetPaintToLayer(ui::LAYER_SOLID_COLOR); SetPaintToLayer(ui::LAYER_SOLID_COLOR);
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
SetBackgroundRadius(AppListConfig::instance().background_radius()); SetBackgroundRadius(shelf_background_corner_radius_);
layer()->SetColor(color_); layer()->SetColor(color_);
} }
...@@ -451,7 +453,7 @@ class AppListBackgroundShieldView : public views::View { ...@@ -451,7 +453,7 @@ class AppListBackgroundShieldView : public views::View {
const double target_corner_radius = const double target_corner_radius =
(state == ash::AppListViewState::kClosed && !shelf_has_rounded_corners) (state == ash::AppListViewState::kClosed && !shelf_has_rounded_corners)
? 0 ? 0
: AppListConfig::instance().background_radius(); : shelf_background_corner_radius_;
if (radius_ == target_corner_radius) if (radius_ == target_corner_radius)
return; return;
...@@ -490,8 +492,7 @@ class AppListBackgroundShieldView : public views::View { ...@@ -490,8 +492,7 @@ class AppListBackgroundShieldView : public views::View {
// add the inset to the bottom to keep padding at the top of the AppList the // add the inset to the bottom to keep padding at the top of the AppList the
// same. // same.
gfx::Rect new_bounds = bounds; gfx::Rect new_bounds = bounds;
new_bounds.Inset(0, 0, 0, new_bounds.Inset(0, 0, 0, -shelf_background_corner_radius_ * 2);
-AppListConfig::instance().background_radius() * 2);
SetBoundsRect(new_bounds); SetBoundsRect(new_bounds);
} }
...@@ -509,6 +510,8 @@ class AppListBackgroundShieldView : public views::View { ...@@ -509,6 +510,8 @@ class AppListBackgroundShieldView : public views::View {
SkColor color_; SkColor color_;
int shelf_background_corner_radius_ = 0;
DISALLOW_COPY_AND_ASSIGN(AppListBackgroundShieldView); DISALLOW_COPY_AND_ASSIGN(AppListBackgroundShieldView);
}; };
...@@ -592,7 +595,8 @@ void AppListView::InitContents(bool is_tablet_mode) { ...@@ -592,7 +595,8 @@ void AppListView::InitContents(bool is_tablet_mode) {
DCHECK(!search_box_view_); DCHECK(!search_box_view_);
DCHECK(!announcement_view_); DCHECK(!announcement_view_);
app_list_background_shield_ = new AppListBackgroundShieldView(); app_list_background_shield_ =
new AppListBackgroundShieldView(delegate_->GetShelfHeight() / 2);
app_list_background_shield_->UpdateBackground(/*use_blur*/ !is_tablet_mode && app_list_background_shield_->UpdateBackground(/*use_blur*/ !is_tablet_mode &&
is_background_blur_enabled_); is_background_blur_enabled_);
AddChildView(app_list_background_shield_); AddChildView(app_list_background_shield_);
...@@ -778,7 +782,7 @@ void AppListView::Layout() { ...@@ -778,7 +782,7 @@ void AppListView::Layout() {
// Exclude the shelf height from the contents bounds to avoid apps grid from // Exclude the shelf height from the contents bounds to avoid apps grid from
// overlapping with shelf. // overlapping with shelf.
gfx::Rect main_bounds = contents_bounds; gfx::Rect main_bounds = contents_bounds;
main_bounds.Inset(0, 0, 0, AppListConfig::instance().shelf_height()); main_bounds.Inset(0, 0, 0, delegate_->GetShelfHeight());
app_list_main_view_->SetBoundsRect(main_bounds); app_list_main_view_->SetBoundsRect(main_bounds);
...@@ -811,7 +815,7 @@ void AppListView::UpdateAppListConfig(aura::Window* parent_window) { ...@@ -811,7 +815,7 @@ void AppListView::UpdateAppListConfig(aura::Window* parent_window) {
gfx::Size available_apps_grid_size = parent_window->bounds().size(); gfx::Size available_apps_grid_size = parent_window->bounds().size();
available_apps_grid_size.Enlarge( available_apps_grid_size.Enlarge(
-non_apps_grid_size.width(), -non_apps_grid_size.width(),
-non_apps_grid_size.height() - AppListConfig::instance().shelf_height()); -non_apps_grid_size.height() - delegate_->GetShelfHeight());
// Create the app list configuration override if it's needed for the current // Create the app list configuration override if it's needed for the current
// display bounds and the available apps grid size. // display bounds and the available apps grid size.
...@@ -1663,8 +1667,7 @@ void AppListView::ApplyBoundsAnimation(ash::AppListViewState target_state, ...@@ -1663,8 +1667,7 @@ void AppListView::ApplyBoundsAnimation(ash::AppListViewState target_state,
gfx::Transform shield_transform; gfx::Transform shield_transform;
if (ShouldHideRoundedCorners(target_state, target_bounds)) { if (ShouldHideRoundedCorners(target_state, target_bounds)) {
shield_transform.Translate(0, shield_transform.Translate(0, -(delegate_->GetShelfHeight() / 2));
-AppListConfig::instance().background_radius());
} }
app_list_background_shield_->SetTransform(shield_transform); app_list_background_shield_->SetTransform(shield_transform);
...@@ -1747,7 +1750,7 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen, ...@@ -1747,7 +1750,7 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen,
gfx::Rect new_widget_bounds = GetWidget()->GetWindowBoundsInScreen(); gfx::Rect new_widget_bounds = GetWidget()->GetWindowBoundsInScreen();
app_list_y_position_in_screen_ = std::min( app_list_y_position_in_screen_ = std::min(
std::max(y_position_in_screen, GetDisplayNearestView().work_area().y()), std::max(y_position_in_screen, GetDisplayNearestView().work_area().y()),
GetScreenBottom() - AppListConfig::instance().shelf_height()); GetScreenBottom() - delegate_->GetShelfHeight());
new_widget_bounds.set_y(app_list_y_position_in_screen_); new_widget_bounds.set_y(app_list_y_position_in_screen_);
gfx::NativeView native_view = GetWidget()->GetNativeView(); gfx::NativeView native_view = GetWidget()->GetNativeView();
::wm::ConvertRectFromScreen(native_view->parent(), &new_widget_bounds); ::wm::ConvertRectFromScreen(native_view->parent(), &new_widget_bounds);
...@@ -1817,7 +1820,7 @@ int AppListView::GetScreenBottom() const { ...@@ -1817,7 +1820,7 @@ int AppListView::GetScreenBottom() const {
int AppListView::GetCurrentAppListHeight() const { int AppListView::GetCurrentAppListHeight() const {
if (!GetWidget()) if (!GetWidget())
return AppListConfig::instance().shelf_height(); return delegate_->GetShelfHeight();
return GetScreenBottom() - GetWidget()->GetWindowBoundsInScreen().y(); return GetScreenBottom() - GetWidget()->GetWindowBoundsInScreen().y();
} }
...@@ -1958,7 +1961,7 @@ void AppListView::OnWindowBoundsChanged(aura::Window* window, ...@@ -1958,7 +1961,7 @@ void AppListView::OnWindowBoundsChanged(aura::Window* window,
gfx::Transform transform; gfx::Transform transform;
if (ShouldHideRoundedCorners(app_list_state_, new_bounds)) if (ShouldHideRoundedCorners(app_list_state_, new_bounds))
transform.Translate(0, -AppListConfig::instance().background_radius()); transform.Translate(0, -(delegate_->GetShelfHeight() / 2));
// Avoid setting new transform if the shield is animating to (or already has) // Avoid setting new transform if the shield is animating to (or already has)
// the target value. // the target value.
...@@ -2116,7 +2119,7 @@ void AppListView::OnParentWindowBoundsChanged() { ...@@ -2116,7 +2119,7 @@ void AppListView::OnParentWindowBoundsChanged() {
float AppListView::GetAppListBackgroundOpacityDuringDragging() { float AppListView::GetAppListBackgroundOpacityDuringDragging() {
float top_of_applist = GetWidget()->GetWindowBoundsInScreen().y(); float top_of_applist = GetWidget()->GetWindowBoundsInScreen().y();
const int shelf_height = AppListConfig::instance().shelf_height(); const int shelf_height = delegate_->GetShelfHeight();
float dragging_height = float dragging_height =
std::max((GetScreenBottom() - shelf_height - top_of_applist), 0.f); std::max((GetScreenBottom() - shelf_height - top_of_applist), 0.f);
float coefficient = float coefficient =
...@@ -2225,6 +2228,8 @@ gfx::Rect AppListView::GetPreferredWidgetBoundsForState( ...@@ -2225,6 +2228,8 @@ gfx::Rect AppListView::GetPreferredWidgetBoundsForState(
void AppListView::UpdateAppListBackgroundYPosition( void AppListView::UpdateAppListBackgroundYPosition(
ash::AppListViewState state) { ash::AppListViewState state) {
const int app_list_background_corner_radius = delegate_->GetShelfHeight() / 2;
// Update the y position of the background shield. // Update the y position of the background shield.
gfx::Transform transform; gfx::Transform transform;
if (is_in_drag_) { if (is_in_drag_) {
...@@ -2234,17 +2239,18 @@ void AppListView::UpdateAppListBackgroundYPosition( ...@@ -2234,17 +2239,18 @@ void AppListView::UpdateAppListBackgroundYPosition(
const float shelf_height = const float shelf_height =
GetScreenBottom() - GetDisplayNearestView().work_area().bottom(); GetScreenBottom() - GetDisplayNearestView().work_area().bottom();
app_list_background_shield_->SetBackgroundRadius( app_list_background_shield_->SetBackgroundRadius(
GetBackgroundRadiusForAppListHeight(GetCurrentAppListHeight() - GetBackgroundRadiusForAppListHeight(
shelf_height)); GetCurrentAppListHeight() - shelf_height,
app_list_background_corner_radius));
} else if (app_list_transition_progress >= 1 && } else if (app_list_transition_progress >= 1 &&
app_list_transition_progress <= 2) { app_list_transition_progress <= 2) {
// Translate background shield so that it ends drag at a y position // Translate background shield so that it ends drag at a y position
// according to the background radius in peeking and fullscreen. // according to the background radius in peeking and fullscreen.
transform.Translate(0, -AppListConfig::instance().background_radius() * transform.Translate(0, -app_list_background_corner_radius *
(app_list_transition_progress - 1)); (app_list_transition_progress - 1));
} }
} else if (ShouldHideRoundedCorners(state, GetBoundsInScreen())) { } else if (ShouldHideRoundedCorners(state, GetBoundsInScreen())) {
transform.Translate(0, -AppListConfig::instance().background_radius()); transform.Translate(0, -app_list_background_corner_radius);
} }
// Avoid setting new transform if the shield is animating to (or already has) // Avoid setting new transform if the shield is animating to (or already has)
......
...@@ -252,7 +252,7 @@ class AppListViewTest : public views::ViewsTestBase, ...@@ -252,7 +252,7 @@ class AppListViewTest : public views::ViewsTestBase,
view_->search_box_view()->GetWidget()->GetWindowBoundsInScreen(); view_->search_box_view()->GetWidget()->GetWindowBoundsInScreen();
} }
int ShelfHeight() const { return AppListConfig::instance().shelf_height(); } int ShelfHeight() const { return delegate_->GetShelfHeight(); }
// Gets the PaginationModel owned by |view_|. // Gets the PaginationModel owned by |view_|.
ash::PaginationModel* GetPaginationModel() const { ash::PaginationModel* GetPaginationModel() const {
...@@ -1893,7 +1893,7 @@ TEST_F(AppListViewTest, ShowFullscreenWhenInSideShelfMode) { ...@@ -1893,7 +1893,7 @@ TEST_F(AppListViewTest, ShowFullscreenWhenInSideShelfMode) {
EXPECT_EQ(ash::AppListViewState::kFullscreenAllApps, view_->app_list_state()); EXPECT_EQ(ash::AppListViewState::kFullscreenAllApps, view_->app_list_state());
// The rounded corners should be off screen in side shelf. // The rounded corners should be off screen in side shelf.
gfx::Transform translation; gfx::Transform translation;
translation.Translate(0, -AppListConfig::instance().background_radius()); translation.Translate(0, -(delegate_->GetShelfHeight() / 2));
// The rounded corners should be off screen in side shelf. // The rounded corners should be off screen in side shelf.
EXPECT_EQ(translation, EXPECT_EQ(translation,
view_->GetAppListBackgroundShieldForTest()->GetTransform()); view_->GetAppListBackgroundShieldForTest()->GetTransform());
......
...@@ -380,7 +380,7 @@ void SearchBoxView::UpdateOpacity() { ...@@ -380,7 +380,7 @@ void SearchBoxView::UpdateOpacity() {
->ShouldShowSearchBox()) { ->ShouldShowSearchBox()) {
return; return;
} }
const int shelf_height = AppListConfig::instance().shelf_height(); const int shelf_height = view_delegate_->GetShelfHeight();
float fraction = float fraction =
std::max<float>( std::max<float>(
0, contents_view_->app_list_view()->GetCurrentAppListHeight() - 0, contents_view_->app_list_view()->GetCurrentAppListHeight() -
......
...@@ -307,10 +307,6 @@ AppListConfig::AppListConfig(ash::AppListConfigType type) ...@@ -307,10 +307,6 @@ AppListConfig::AppListConfig(ash::AppListConfigType type)
folder_background_color_(gfx::kGoogleGrey100), folder_background_color_(gfx::kGoogleGrey100),
page_flip_zone_size_(20), page_flip_zone_size_(20),
grid_tile_spacing_in_folder_(8), grid_tile_spacing_in_folder_(8),
// TODO(manucornet): Share the value with ShelfConstants and use
// 48 when the new shelf UI is turned off.
shelf_height_(chromeos::switches::ShouldShowShelfHotseat() ? 48 : 56),
background_radius_(shelf_height_ / 2),
blur_radius_(30), blur_radius_(30),
contents_background_color_(SkColorSetRGB(0xF2, 0xF2, 0xF2)), contents_background_color_(SkColorSetRGB(0xF2, 0xF2, 0xF2)),
grid_selected_color_(gfx::kGoogleBlue300), grid_selected_color_(gfx::kGoogleBlue300),
...@@ -445,8 +441,6 @@ AppListConfig::AppListConfig(const AppListConfig& base_config, ...@@ -445,8 +441,6 @@ AppListConfig::AppListConfig(const AppListConfig& base_config,
MinScale(base_config.grid_tile_spacing_in_folder_, MinScale(base_config.grid_tile_spacing_in_folder_,
scale_x, scale_x,
inner_tile_scale_y)), inner_tile_scale_y)),
shelf_height_(base_config.shelf_height_),
background_radius_(base_config.background_radius_),
blur_radius_(base_config.blur_radius_), blur_radius_(base_config.blur_radius_),
contents_background_color_(base_config.contents_background_color_), contents_background_color_(base_config.contents_background_color_),
grid_selected_color_(base_config.grid_selected_color_), grid_selected_color_(base_config.grid_selected_color_),
......
...@@ -127,8 +127,6 @@ class ASH_PUBLIC_EXPORT AppListConfig { ...@@ -127,8 +127,6 @@ class ASH_PUBLIC_EXPORT AppListConfig {
int grid_tile_spacing_in_folder() const { int grid_tile_spacing_in_folder() const {
return grid_tile_spacing_in_folder_; return grid_tile_spacing_in_folder_;
} }
int shelf_height() const { return shelf_height_; }
int background_radius() const { return background_radius_; }
int blur_radius() const { return blur_radius_; } int blur_radius() const { return blur_radius_; }
SkColor contents_background_color() const { SkColor contents_background_color() const {
return contents_background_color_; return contents_background_color_;
...@@ -366,12 +364,6 @@ class ASH_PUBLIC_EXPORT AppListConfig { ...@@ -366,12 +364,6 @@ class ASH_PUBLIC_EXPORT AppListConfig {
// The spacing between tile views in folder. // The spacing between tile views in folder.
const int grid_tile_spacing_in_folder_; const int grid_tile_spacing_in_folder_;
// The height/width of the shelf from the bottom/side of the screen.
const int shelf_height_;
// The background corner radius used for the app list.
const int background_radius_;
// The blur radius used in the app list. // The blur radius used in the app list.
const int blur_radius_; const int blur_radius_;
......
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