Commit 8ffa1567 authored by David Black's avatar David Black Committed by Commit Bot

Change height of Assistant caption bar.

A previous version of this CL was reverted because it caused any cards
in the first Assistant response to be laid out with zero width:
https://chromium-review.googlesource.com/c/chromium/src/+/1336525

This was caused by UiElementContainerView's width being set to zero
due to its flex behavior when animating growth for the first time. We
now impose a minimum height restriction on UiElementContainerView so
that its width will not be set to zero and cards, which are sized
according to the width of UiElementContainerView, will be laid out
appropriately.

Bug: b:119498360
Change-Id: I7c7a85aa1f3b506ed6a0f6dbdca628ae639e232b
Reviewed-on: https://chromium-review.googlesource.com/c/1338960Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#608983}
parent 6bd66a17
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -24,7 +23,7 @@ namespace { ...@@ -24,7 +23,7 @@ namespace {
// Appearance. // Appearance.
constexpr int kCaptionButtonSizeDip = 32; constexpr int kCaptionButtonSizeDip = 32;
constexpr int kPreferredHeightDip = 32; constexpr int kPreferredHeightDip = 48;
constexpr int kVectorIconSizeDip = 12; constexpr int kVectorIconSizeDip = 12;
// CaptionButton --------------------------------------------------------------- // CaptionButton ---------------------------------------------------------------
......
...@@ -292,7 +292,8 @@ void AssistantMainStage::InitContentLayoutContainer() { ...@@ -292,7 +292,8 @@ void AssistantMainStage::InitContentLayoutContainer() {
ui_element_container_->AddObserver(this); ui_element_container_->AddObserver(this);
content_layout_container_->AddChildView(ui_element_container_); content_layout_container_->AddChildView(ui_element_container_);
layout_manager->SetFlexForView(ui_element_container_, 1); layout_manager->SetFlexForView(ui_element_container_, 1,
/*use_min_size=*/true);
// Footer. // Footer.
// Note that the |footer_| is placed within its own view container so that as // Note that the |footer_| is placed within its own view container so that as
......
...@@ -269,6 +269,19 @@ int UiElementContainerView::GetHeightForWidth(int width) const { ...@@ -269,6 +269,19 @@ int UiElementContainerView::GetHeightForWidth(int width) const {
return content_view()->GetHeightForWidth(width); return content_view()->GetHeightForWidth(width);
} }
gfx::Size UiElementContainerView::GetMinimumSize() const {
// AssistantMainStage uses BoxLayout's flex property to grow/shrink
// UiElementContainerView to fill available space as needed. When height is
// shrunk to zero, as is temporarily the case during the initial container
// growth animation for the first Assistant response, UiElementContainerView
// will be laid out with zero width. We do not recover from this state until
// the next layout pass, which causes Assistant cards for the first response
// to be laid out with zero width. We work around this by imposing a minimum
// height restriction of 1 dip that is factored into BoxLayout's flex
// calculations to make sure that our width is never being set to zero.
return gfx::Size(INT_MAX, 1);
}
void UiElementContainerView::OnContentsPreferredSizeChanged( void UiElementContainerView::OnContentsPreferredSizeChanged(
views::View* content_view) { views::View* content_view) {
const int preferred_height = content_view->GetHeightForWidth(width()); const int preferred_height = content_view->GetHeightForWidth(width());
......
...@@ -44,6 +44,7 @@ class UiElementContainerView : public AssistantScrollView, ...@@ -44,6 +44,7 @@ class UiElementContainerView : public AssistantScrollView,
const char* GetClassName() const override; const char* GetClassName() const override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
int GetHeightForWidth(int width) const override; int GetHeightForWidth(int width) const override;
gfx::Size GetMinimumSize() const override;
void OnContentsPreferredSizeChanged(views::View* content_view) override; void OnContentsPreferredSizeChanged(views::View* content_view) override;
void PreferredSizeChanged() override; void PreferredSizeChanged() 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