Commit 4d44198c authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Overflow bubble view refactor

Move the code block that updates the layout strategy of OverflowBubble-
View from CalculatePreferredSize to Layout. It makes preparations for
landing the CL of focus rings for OverflowBubbleView

Bug: 918024
Change-Id: I1a032e21d1a7b0fe307d62da9d94e7fa7fe3395b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783479Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692887}
parent 970a71de
......@@ -406,16 +406,9 @@ void OverflowBubbleView::StartShelfScrollAnimation(float scroll_distance) {
shelf_view()->layer()->SetTransform(current_transform);
}
gfx::Size OverflowBubbleView::CalculatePreferredSize() const {
gfx::Rect monitor_rect =
display::Screen::GetScreen()
->GetDisplayNearestPoint(GetAnchorRect().CenterPoint())
.work_area();
monitor_rect.Inset(gfx::Insets(kMinimumMargin));
int available_length = GetShelf()->IsHorizontalAlignment()
? monitor_rect.width()
: monitor_rect.height();
void OverflowBubbleView::UpdateLayoutStrategy() {
const int available_length =
GetShelf()->IsHorizontalAlignment() ? width() : height();
gfx::Size preferred_size = shelf_container_view_->GetPreferredSize();
int preferred_length = GetShelf()->IsHorizontalAlignment()
? preferred_size.width()
......@@ -439,6 +432,20 @@ gfx::Size OverflowBubbleView::CalculatePreferredSize() const {
// There are invisible shelf buttons at both sides. So show two buttons.
layout_strategy_ = SHOW_BUTTONS;
}
}
gfx::Size OverflowBubbleView::CalculatePreferredSize() const {
gfx::Rect monitor_rect =
display::Screen::GetScreen()
->GetDisplayNearestPoint(GetAnchorRect().CenterPoint())
.work_area();
monitor_rect.Inset(gfx::Insets(kMinimumMargin));
gfx::Size preferred_size = shelf_container_view_->GetPreferredSize();
int preferred_length = GetShelf()->IsHorizontalAlignment()
? preferred_size.width()
: preferred_size.height();
preferred_length += 2 * kEndPadding;
if (GetShelf()->IsHorizontalAlignment()) {
preferred_size.set_width(std::min(preferred_length, monitor_rect.width()));
......@@ -450,6 +457,8 @@ gfx::Size OverflowBubbleView::CalculatePreferredSize() const {
}
void OverflowBubbleView::Layout() {
UpdateLayoutStrategy();
const gfx::Size shelf_button_size(ShelfConstants::button_size(),
ShelfConstants::button_size());
const gfx::Size arrow_button_size(GetArrowButtonSize(), GetArrowButtonSize());
......
......@@ -102,6 +102,9 @@ class ASH_EXPORT OverflowBubbleView : public ShelfBubble,
// Creates the animation for scrolling shelf by |scroll_distance|.
void StartShelfScrollAnimation(float scroll_distance);
// Update the layout strategy based on the available space.
void UpdateLayoutStrategy();
// views::View:
gfx::Size CalculatePreferredSize() const override;
void Layout() override;
......
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