Commit 3b2e7b9e authored by David Black's avatar David Black Committed by Commit Bot

Hide DialogPlate when using stylus.

This also requires modifying layout padding on visibility change.

Bug: b:79387198
Change-Id: I6b7b734badd3bf054b63d6517d82b2c976a9ddf2
Reviewed-on: https://chromium-review.googlesource.com/1050734Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#557068}
parent d3391833
......@@ -385,13 +385,26 @@ void AssistantBubbleView::ChildPreferredSizeChanged(views::View* child) {
}
void AssistantBubbleView::ChildVisibilityChanged(views::View* child) {
// When toggling the visibility of the dialog plate, we also need to update
// the bottom padding of the layout.
if (child == dialog_plate_) {
const int padding_bottom_dip = dialog_plate_->visible() ? 0 : kPaddingDip;
layout_manager_->set_inside_border_insets(
gfx::Insets(kPaddingDip, 0, padding_bottom_dip, 0));
}
PreferredSizeChanged();
}
void AssistantBubbleView::InitLayout() {
SetLayoutManager(std::make_unique<views::BoxLayout>(
// Dialog plate is not visible when using the stylus input modality.
const bool show_dialog_plate =
assistant_controller_->interaction_model()->input_modality() !=
InputModality::kStylus;
layout_manager_ = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical,
gfx::Insets(kPaddingDip, 0, 0, 0), kSpacingDip));
gfx::Insets(kPaddingDip, 0, show_dialog_plate ? 0 : kPaddingDip, 0),
kSpacingDip));
// Interaction container.
AddChildView(interaction_container_);
......@@ -405,6 +418,7 @@ void AssistantBubbleView::InitLayout() {
AddChildView(suggestions_container_);
// Dialog plate.
dialog_plate_->SetVisible(show_dialog_plate);
AddChildView(dialog_plate_);
}
......@@ -430,6 +444,9 @@ void AssistantBubbleView::ProcessPendingUiElements() {
}
void AssistantBubbleView::OnInputModalityChanged(InputModality input_modality) {
// Dialog plate is not visible when using stylus input modality.
dialog_plate_->SetVisible(input_modality != InputModality::kStylus);
// If the query for the interaction is empty, we may need to update the prompt
// to reflect the current input modality.
if (assistant_controller_->interaction_model()->query().empty()) {
......
......@@ -15,6 +15,10 @@
#include "ui/app_list/views/suggestion_chip_view.h"
#include "ui/views/view.h"
namespace views {
class BoxLayout;
} // namespace views
namespace ash {
class AshAssistantController;
......@@ -77,6 +81,8 @@ class AssistantBubbleView : public views::View,
SuggestionsContainer* suggestions_container_; // Owned by view hierarchy.
DialogPlate* dialog_plate_; // Owned by view hierarchy.
views::BoxLayout* layout_manager_ = nullptr; // Owned by view hierarchy.
// Uniquely identifies cards owned by AssistantCardRenderer.
std::vector<base::UnguessableToken> id_token_list_;
......
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