Commit 106459ae authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

CrOS Shelf: Add ink drop padding to first and last app in the hotseat.

This change adds padding to the ink drop for the first and last app
buttons in the scrollable shelf. This padding is added so that when the
ink drop is shown for the left-most or right-most app, the ink drop
appears to cover from the behind the app to the left/right edges of the
hotseat. This means that a "one app hotseat" will be completely filled
by the app's inkdrop.

Bug: 1035263
Change-Id: I91383bf73865f6807d878bde3afeb904ddacb3f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1999767
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731865}
parent 22cf225b
...@@ -170,6 +170,9 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver, ...@@ -170,6 +170,9 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// Returns the current blur radius to use for the control buttons. // Returns the current blur radius to use for the control buttons.
int GetShelfControlButtonBlurRadius() const; int GetShelfControlButtonBlurRadius() const;
// The padding between the app icon and the end of the scrollable shelf.
int GetAppIconEndPadding() const;
private: private:
friend class ShelfConfigTest; friend class ShelfConfigTest;
...@@ -264,6 +267,10 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver, ...@@ -264,6 +267,10 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// The height inset on the control buttons when in-app shelf is shown. // The height inset on the control buttons when in-app shelf is shown.
const int in_app_control_button_height_inset_; const int in_app_control_button_height_inset_;
// The padding between the app icon and the end of the scrollable shelf in
// tablet mode.
const int app_icon_end_padding_;
base::ObserverList<Observer> observers_; base::ObserverList<Observer> observers_;
DISALLOW_COPY_AND_ASSIGN(ShelfConfig); DISALLOW_COPY_AND_ASSIGN(ShelfConfig);
......
...@@ -123,12 +123,6 @@ bool IsInTabletMode() { ...@@ -123,12 +123,6 @@ bool IsInTabletMode() {
return true; return true;
} }
// Returns the padding between the app icon and the end of the ScrollableShelf.
int GetAppIconEndPadding() {
return (chromeos::switches::ShouldShowShelfHotseat() && IsInTabletMode()) ? 4
: 0;
}
} // namespace } // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -394,9 +388,9 @@ void ScrollableShelfContainerView::Layout() { ...@@ -394,9 +388,9 @@ void ScrollableShelfContainerView::Layout() {
local_bounds.Contains(ideal_bounds) ? local_bounds : ideal_bounds; local_bounds.Contains(ideal_bounds) ? local_bounds : ideal_bounds;
if (shelf_view_->shelf()->IsHorizontalAlignment()) if (shelf_view_->shelf()->IsHorizontalAlignment())
shelf_view_bounds.set_x(GetAppIconEndPadding()); shelf_view_bounds.set_x(ShelfConfig::Get()->GetAppIconEndPadding());
else else
shelf_view_bounds.set_y(GetAppIconEndPadding()); shelf_view_bounds.set_y(ShelfConfig::Get()->GetAppIconEndPadding());
shelf_view_->SetBoundsRect(shelf_view_bounds); shelf_view_->SetBoundsRect(shelf_view_bounds);
} }
...@@ -614,7 +608,8 @@ int ScrollableShelfView::CalculateScrollUpperBound() const { ...@@ -614,7 +608,8 @@ int ScrollableShelfView::CalculateScrollUpperBound() const {
return 0; return 0;
// Calculate the length of the available space. // Calculate the length of the available space.
int available_length = GetSpaceForIcons() - 2 * GetAppIconEndPadding(); int available_length =
GetSpaceForIcons() - 2 * ShelfConfig::Get()->GetAppIconEndPadding();
// Calculate the length of the preferred size. // Calculate the length of the preferred size.
const gfx::Size shelf_preferred_size( const gfx::Size shelf_preferred_size(
...@@ -1207,7 +1202,7 @@ gfx::Insets ScrollableShelfView::CalculateEdgePadding() const { ...@@ -1207,7 +1202,7 @@ gfx::Insets ScrollableShelfView::CalculateEdgePadding() const {
const int icons_size = shelf_view_->GetSizeOfAppIcons( const int icons_size = shelf_view_->GetSizeOfAppIcons(
shelf_view_->number_of_visible_apps(), false) + shelf_view_->number_of_visible_apps(), false) +
2 * GetAppIconEndPadding(); 2 * ShelfConfig::Get()->GetAppIconEndPadding();
const int base_padding = ShelfConfig::Get()->app_icon_group_margin(); const int base_padding = ShelfConfig::Get()->app_icon_group_margin();
const int available_size_for_app_icons = const int available_size_for_app_icons =
...@@ -1237,7 +1232,7 @@ gfx::Insets ScrollableShelfView::CalculateEdgePadding() const { ...@@ -1237,7 +1232,7 @@ gfx::Insets ScrollableShelfView::CalculateEdgePadding() const {
gfx::Insets ScrollableShelfView::CalculatePaddingForDisplayCentering() const { gfx::Insets ScrollableShelfView::CalculatePaddingForDisplayCentering() const {
const int icons_size = shelf_view_->GetSizeOfAppIcons( const int icons_size = shelf_view_->GetSizeOfAppIcons(
shelf_view_->number_of_visible_apps(), false) + shelf_view_->number_of_visible_apps(), false) +
2 * GetAppIconEndPadding(); 2 * ShelfConfig::Get()->GetAppIconEndPadding();
const gfx::Rect display_bounds = const gfx::Rect display_bounds =
screen_util::GetDisplayBoundsWithShelf(GetWidget()->GetNativeWindow()); screen_util::GetDisplayBoundsWithShelf(GetWidget()->GetNativeWindow());
const int display_size_primary = GetShelf()->PrimaryAxisValue( const int display_size_primary = GetShelf()->PrimaryAxisValue(
...@@ -1485,7 +1480,7 @@ float ScrollableShelfView::CalculatePageScrollingOffset( ...@@ -1485,7 +1480,7 @@ float ScrollableShelfView::CalculatePageScrollingOffset(
// After scrolling, the left arrow button will show. Adapts the offset // After scrolling, the left arrow button will show. Adapts the offset
// to the extra arrow button. // to the extra arrow button.
const int offset_for_extra_arrow = const int offset_for_extra_arrow =
kArrowButtonGroupWidth - GetAppIconEndPadding(); kArrowButtonGroupWidth - ShelfConfig::Get()->GetAppIconEndPadding();
const int mod = space_excluding_arrow % GetUnit(); const int mod = space_excluding_arrow % GetUnit();
offset = space_excluding_arrow - mod - offset_for_extra_arrow; offset = space_excluding_arrow - mod - offset_for_extra_arrow;
...@@ -1501,7 +1496,7 @@ float ScrollableShelfView::CalculatePageScrollingOffset( ...@@ -1501,7 +1496,7 @@ float ScrollableShelfView::CalculatePageScrollingOffset(
const int extra_offset = const int extra_offset =
-ShelfConfig::Get()->button_spacing() - -ShelfConfig::Get()->button_spacing() -
(GetSpaceForIcons() - kArrowButtonGroupWidth) % GetUnit() + (GetSpaceForIcons() - kArrowButtonGroupWidth) % GetUnit() +
GetAppIconEndPadding(); ShelfConfig::Get()->GetAppIconEndPadding();
offset += extra_offset; offset += extra_offset;
} }
} }
...@@ -1662,7 +1657,7 @@ int ScrollableShelfView::GetActualScrollOffset( ...@@ -1662,7 +1657,7 @@ int ScrollableShelfView::GetActualScrollOffset(
return (layout_strategy == kShowButtons || return (layout_strategy == kShowButtons ||
layout_strategy == kShowLeftArrowButton) layout_strategy == kShowLeftArrowButton)
? (main_axis_scroll_distance + kArrowButtonGroupWidth - ? (main_axis_scroll_distance + kArrowButtonGroupWidth -
GetAppIconEndPadding()) ShelfConfig::Get()->GetAppIconEndPadding())
: main_axis_scroll_distance; : main_axis_scroll_distance;
} }
...@@ -1741,7 +1736,7 @@ bool ScrollableShelfView::CanFitAllAppsWithoutScrolling() const { ...@@ -1741,7 +1736,7 @@ bool ScrollableShelfView::CanFitAllAppsWithoutScrolling() const {
int preferred_length = GetShelf()->IsHorizontalAlignment() int preferred_length = GetShelf()->IsHorizontalAlignment()
? preferred_size.width() ? preferred_size.width()
: preferred_size.height(); : preferred_size.height();
preferred_length += 2 * GetAppIconEndPadding(); preferred_length += 2 * ShelfConfig::Get()->GetAppIconEndPadding();
return available_length >= preferred_length; return available_length >= preferred_length;
} }
......
...@@ -731,13 +731,34 @@ void ShelfAppButton::OnGestureEvent(ui::GestureEvent* event) { ...@@ -731,13 +731,34 @@ void ShelfAppButton::OnGestureEvent(ui::GestureEvent* event) {
std::unique_ptr<views::InkDropRipple> ShelfAppButton::CreateInkDropRipple() std::unique_ptr<views::InkDropRipple> ShelfAppButton::CreateInkDropRipple()
const { const {
const int ink_drop_small_size = ShelfConfig::Get()->hotseat_size(); int ink_drop_small_size = ShelfConfig::Get()->hotseat_size();
gfx::Point center_point = GetLocalBounds().CenterPoint();
const int padding = ShelfConfig::Get()->GetAppIconEndPadding();
// Add padding to the ink drop for the left-most and right-most app buttons in
// the shelf.
if (padding > 0) {
const int current_index = shelf_view_->view_model()->GetIndexOfView(this);
int left_padding =
(shelf_view_->first_visible_index() == current_index) ? padding : 0;
int right_padding =
(shelf_view_->last_visible_index() == current_index) ? padding : 0;
if (base::i18n::IsRTL())
std::swap(left_padding, right_padding);
ink_drop_small_size += left_padding + right_padding;
const int x_offset = (-left_padding / 2) + (right_padding / 2);
center_point.Offset(x_offset, 0);
}
return std::make_unique<views::SquareInkDropRipple>( return std::make_unique<views::SquareInkDropRipple>(
gfx::Size(GetInkDropLargeSize(), GetInkDropLargeSize()), gfx::Size(GetInkDropLargeSize(), GetInkDropLargeSize()),
ink_drop_large_corner_radius(), ink_drop_large_corner_radius(),
gfx::Size(ink_drop_small_size, ink_drop_small_size), gfx::Size(ink_drop_small_size, ink_drop_small_size),
ink_drop_small_corner_radius(), GetLocalBounds().CenterPoint(), ink_drop_small_corner_radius(), center_point, GetInkDropBaseColor(),
GetInkDropBaseColor(), ink_drop_visible_opacity()); ink_drop_visible_opacity());
} }
std::unique_ptr<views::InkDropMask> ShelfAppButton::CreateInkDropMask() const { std::unique_ptr<views::InkDropMask> ShelfAppButton::CreateInkDropMask() const {
......
...@@ -61,7 +61,8 @@ ShelfConfig::ShelfConfig() ...@@ -61,7 +61,8 @@ ShelfConfig::ShelfConfig()
shelf_tooltip_preview_min_ratio_(0.666), // = 2/3 shelf_tooltip_preview_min_ratio_(0.666), // = 2/3
shelf_blur_radius_(30), shelf_blur_radius_(30),
mousewheel_scroll_offset_threshold_(20), mousewheel_scroll_offset_threshold_(20),
in_app_control_button_height_inset_(4) { in_app_control_button_height_inset_(4),
app_icon_end_padding_(4) {
UpdateConfig(is_app_list_visible_); UpdateConfig(is_app_list_visible_);
} }
...@@ -312,6 +313,12 @@ int ShelfConfig::GetShelfControlButtonBlurRadius() const { ...@@ -312,6 +313,12 @@ int ShelfConfig::GetShelfControlButtonBlurRadius() const {
return 0; return 0;
} }
int ShelfConfig::GetAppIconEndPadding() const {
return (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode())
? app_icon_end_padding_
: 0;
}
void ShelfConfig::OnShelfConfigUpdated() { void ShelfConfig::OnShelfConfigUpdated() {
for (auto& observer : observers_) for (auto& observer : observers_)
observer.OnShelfConfigUpdated(); observer.OnShelfConfigUpdated();
......
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