Commit ec445aa5 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: Let the navigation widget update its own layout

Issue: 1021698
Change-Id: I4ce164922f1e5f33c127a1e61602682f4cdcca13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949666Reviewed-by: default avatarAndrew Xu <andrewxu@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721285}
parent bfba8821
......@@ -1033,6 +1033,13 @@ void ShelfLayoutManager::OnDeskSwitchAnimationFinished() {
UpdateVisibilityState();
}
gfx::Rect ShelfLayoutManager::GetNavigationBounds() const {
gfx::Vector2d nav_offset = target_bounds_.shelf_bounds.OffsetFromOrigin();
gfx::Rect nav_bounds = target_bounds_.nav_bounds_in_shelf;
nav_bounds.Offset(nav_offset);
return nav_bounds;
}
int ShelfLayoutManager::CalculateHotseatYInShelf(
HotseatState hotseat_target_state) const {
DCHECK(shelf_->IsHorizontalAlignment());
......@@ -1451,10 +1458,8 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(
status_bounds.Offset(target_bounds_.shelf_bounds.OffsetFromOrigin());
status_widget->SetBounds(status_bounds);
gfx::Vector2d nav_offset = target_bounds_.shelf_bounds.OffsetFromOrigin();
gfx::Rect nav_bounds = target_bounds_.nav_bounds_in_shelf;
nav_bounds.Offset(nav_offset);
nav_widget->SetBounds(nav_bounds);
// Let the navigation widget handle its own layout changes.
nav_widget->UpdateLayout();
gfx::Vector2d hotseat_offset =
target_bounds_.shelf_bounds.OffsetFromOrigin();
......
......@@ -245,6 +245,8 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
// coordinates.
int CalculateHotseatYInShelf(HotseatState hotseat_target_state) const;
gfx::Rect GetNavigationBounds() const;
bool updating_bounds() const { return updating_bounds_; }
ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
HotseatState hotseat_state() const {
......
......@@ -8,6 +8,7 @@
#include "ash/shelf/back_button.h"
#include "ash/shelf/home_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
......@@ -318,6 +319,8 @@ void ShelfNavigationWidget::OnShelfConfigUpdated() {
void ShelfNavigationWidget::UpdateLayout() {
bool is_back_button_shown = IsBackButtonShown();
SetBounds(shelf_->shelf_layout_manager()->GetNavigationBounds());
// Show the back button right away so that the animation is visible.
if (is_back_button_shown)
GetBackButton()->SetVisible(true);
......
......@@ -76,6 +76,10 @@ class ASH_EXPORT ShelfNavigationWidget : public views::Widget,
// ShelfConfig::Observer:
void OnShelfConfigUpdated() override;
// Updates this widget's layout according to current constraints: tablet
// mode and shelf orientation.
void UpdateLayout();
views::BoundsAnimator* get_bounds_animator_for_testing() {
return bounds_animator_.get();
}
......@@ -83,10 +87,6 @@ class ASH_EXPORT ShelfNavigationWidget : public views::Widget,
private:
class Delegate;
// Updates this widget's layout according to current constraints: tablet
// mode and shelf orientation.
void UpdateLayout();
Shelf* shelf_ = nullptr;
Delegate* delegate_ = nullptr;
std::unique_ptr<views::BoundsAnimator> bounds_animator_;
......
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