Commit dddcd182 authored by David Black's avatar David Black Committed by Commit Bot

Remove standalone UI code from AssistantProgressIndicator.

Bug: b:148080975
Change-Id: I5553e75f42bc8d4d08cba33cc8dce9f164306f0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036395Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#738015}
parent f901a63d
...@@ -25,31 +25,16 @@ namespace { ...@@ -25,31 +25,16 @@ namespace {
// Appearance. // Appearance.
constexpr int kDotCount = 3; constexpr int kDotCount = 3;
constexpr float kDotLargeSizeDip = 9.f; constexpr float kDotLargeSizeDip = 6.f;
constexpr float kDotSmallSizeDip = 6.f; constexpr float kDotSmallSizeDip = 4.f;
constexpr int kSpacingDip = 4; constexpr int kDotSpacingDip = 3;
constexpr float kEmbeddedUiDotLargeSizeDip = 6.f; constexpr int kPreferredHeightDip = 9;
constexpr float kEmbeddedUiDotSmallSizeDip = 4.f;
constexpr int kEmbeddedUiSpacingDip = 3;
constexpr int kEmbeddedUiPreferredHeightDip = 9;
float GetDotLargeSizeDip() {
return app_list_features::IsAssistantLauncherUIEnabled()
? kEmbeddedUiDotLargeSizeDip
: kDotLargeSizeDip;
}
float GetDotSmallSizeDip() { // Animation.
return app_list_features::IsAssistantLauncherUIEnabled() constexpr float kTranslationDip = -(kDotLargeSizeDip - kDotSmallSizeDip) / 2.f;
? kEmbeddedUiDotSmallSizeDip constexpr float kScaleFactor = kDotLargeSizeDip / kDotSmallSizeDip;
: kDotSmallSizeDip;
}
int GetDotSpacingDip() { // Helpers ---------------------------------------------------------------------
return app_list_features::IsAssistantLauncherUIEnabled()
? kEmbeddedUiSpacingDip
: kSpacingDip;
}
bool AreAnimationsEnabled() { bool AreAnimationsEnabled() {
return ui::ScopedAnimationDurationScaleMode::duration_scale_mode() != return ui::ScopedAnimationDurationScaleMode::duration_scale_mode() !=
...@@ -100,9 +85,7 @@ gfx::Size AssistantProgressIndicator::CalculatePreferredSize() const { ...@@ -100,9 +85,7 @@ gfx::Size AssistantProgressIndicator::CalculatePreferredSize() const {
} }
int AssistantProgressIndicator::GetHeightForWidth(int width) const { int AssistantProgressIndicator::GetHeightForWidth(int width) const {
return app_list_features::IsAssistantLauncherUIEnabled() return kPreferredHeightDip;
? kEmbeddedUiPreferredHeightDip
: views::View::GetHeightForWidth(width);
} }
void AssistantProgressIndicator::AddedToWidget() { void AssistantProgressIndicator::AddedToWidget() {
...@@ -144,11 +127,8 @@ void AssistantProgressIndicator::VisibilityChanged(views::View* starting_from, ...@@ -144,11 +127,8 @@ void AssistantProgressIndicator::VisibilityChanged(views::View* starting_from,
// illusion that scaling is being performed about the center of the view as // illusion that scaling is being performed about the center of the view as
// the transformation origin, we also need to perform a translation. // the transformation origin, we also need to perform a translation.
gfx::Transform transform; gfx::Transform transform;
const float translation_dip = transform.Translate(kTranslationDip, kTranslationDip);
-(GetDotLargeSizeDip() - GetDotSmallSizeDip()) / 2.f; transform.Scale(kScaleFactor, kScaleFactor);
const float scale_factor = GetDotLargeSizeDip() / GetDotSmallSizeDip();
transform.Translate(translation_dip, translation_dip);
transform.Scale(scale_factor, scale_factor);
// Don't animate if animations are disabled (during unittests). // Don't animate if animations are disabled (during unittests).
// Otherwise we get in an infinite loop due to the cyclic animation used here // Otherwise we get in an infinite loop due to the cyclic animation used here
...@@ -188,7 +168,7 @@ void AssistantProgressIndicator::InitLayout() { ...@@ -188,7 +168,7 @@ void AssistantProgressIndicator::InitLayout() {
views::BoxLayout* layout_manager = views::BoxLayout* layout_manager =
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets(), views::BoxLayout::Orientation::kHorizontal, gfx::Insets(),
GetDotSpacingDip())); kDotSpacingDip));
layout_manager->set_cross_axis_alignment( layout_manager->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter); views::BoxLayout::CrossAxisAlignment::kCenter);
...@@ -197,8 +177,7 @@ void AssistantProgressIndicator::InitLayout() { ...@@ -197,8 +177,7 @@ void AssistantProgressIndicator::InitLayout() {
for (int i = 0; i < kDotCount; ++i) { for (int i = 0; i < kDotCount; ++i) {
views::View* dot_view = new views::View(); views::View* dot_view = new views::View();
dot_view->SetBackground(std::make_unique<DotBackground>()); dot_view->SetBackground(std::make_unique<DotBackground>());
dot_view->SetPreferredSize( dot_view->SetPreferredSize(gfx::Size(kDotSmallSizeDip, kDotSmallSizeDip));
gfx::Size(GetDotSmallSizeDip(), GetDotSmallSizeDip()));
// Dots will animate on their own layers. // Dots will animate on their own layers.
dot_view->SetPaintToLayer(); dot_view->SetPaintToLayer();
......
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