Commit 1af146a0 authored by David Black's avatar David Black Committed by Commit Bot

Fixed horizontal alignment in Dialog Plate.

Previously, the animated voice input toggle was slightly off center:
https://screenshot.googleplex.com/tODAXyEw64F

Bug: 924624
Change-Id: I30b230a22afa152a4081aa9f25347a696a002179
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506381
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638325}
parent 99d553b3
...@@ -335,10 +335,20 @@ void DialogPlate::InitVoiceLayoutContainer() { ...@@ -335,10 +335,20 @@ void DialogPlate::InitVoiceLayoutContainer() {
layout_manager->set_cross_axis_alignment( layout_manager->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::CROSS_AXIS_ALIGNMENT_CENTER); views::BoxLayout::CrossAxisAlignment::CROSS_AXIS_ALIGNMENT_CENTER);
// Offset.
// To make the |animated_voice_input_toggle_| horizontally centered in the
// dialog plate we need to offset by the difference in width between the
// |molecule_icon_| and the |keyboard_input_toggle_|.
constexpr int difference =
/*keyboard_input_toggle_width=*/kButtonSizeDip -
/*molecule_icon_width=*/kIconSizeDip;
views::View* offset = new views::View();
offset->SetPreferredSize(gfx::Size(difference, 1));
voice_layout_container_->AddChildView(offset);
// Spacer. // Spacer.
views::View* spacer = new views::View(); views::View* spacer = new views::View();
voice_layout_container_->AddChildView(spacer); voice_layout_container_->AddChildView(spacer);
layout_manager->SetFlexForView(spacer, 1); layout_manager->SetFlexForView(spacer, 1);
// Animated voice input toggle. // Animated voice input toggle.
...@@ -351,19 +361,8 @@ void DialogPlate::InitVoiceLayoutContainer() { ...@@ -351,19 +361,8 @@ void DialogPlate::InitVoiceLayoutContainer() {
// Spacer. // Spacer.
spacer = new views::View(); spacer = new views::View();
voice_layout_container_->AddChildView(spacer); voice_layout_container_->AddChildView(spacer);
layout_manager->SetFlexForView(spacer, 1); layout_manager->SetFlexForView(spacer, 1);
// Spacer.
// To make the mic icon in the center of the |assistant_page_view_|
// compensate for the width of molecule icon and keyboard input toggle.
spacer = new views::View();
constexpr int spacing =
/*molecule_icon_width=*/kIconSizeDip -
/*keyboard_input_toggle_width*/ kButtonSizeDip;
spacer->SetPreferredSize(gfx::Size(spacing, 1));
voice_layout_container_->AddChildView(spacer);
// Keyboard input toggle. // Keyboard input toggle.
keyboard_input_toggle_ = ash::AssistantButton::Create( keyboard_input_toggle_ = ash::AssistantButton::Create(
this, ash::kKeyboardIcon, kButtonSizeDip, kIconSizeDip, this, ash::kKeyboardIcon, kButtonSizeDip, kIconSizeDip,
......
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