Commit 0135e496 authored by David Black's avatar David Black Committed by Commit Bot

Implement DialogPlate motion spec (part 2).

This builds off of DialogPlate motion spec part 1:
https://chromium-review.googlesource.com/c/chromium/src/+/1137843

This CL:
- Fixes issue which caused settings to fade in/out. Previously we used
  two settings buttons, now we use a single button which exists outside
  of the layout containers being animated.
- Implements translation phase of the animation.

See bug for spec/demo.

Bug: b:111500701
Change-Id: I269666dafa815018e0cf65df299aa734eaf80b79
Reviewed-on: https://chromium-review.googlesource.com/1139031
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575901}
parent d8235928
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
#include "ui/views/controls/textfield/textfield_controller.h" #include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/view.h" #include "ui/views/view.h"
namespace views {
class ImageButton;
} // namespace views
namespace ash { namespace ash {
class AssistantController; class AssistantController;
...@@ -92,18 +88,17 @@ class DialogPlate : public views::View, ...@@ -92,18 +88,17 @@ class DialogPlate : public views::View,
private: private:
void InitLayout(); void InitLayout();
void InitKeyboardLayoutContainer(); void InitKeyboardLayoutContainer(
void InitVoiceLayoutContainer(); views::View* input_modality_layout_container);
void InitVoiceLayoutContainer(views::View* input_modality_layout_container);
void OnButtonPressed(DialogPlateButtonId id); void OnButtonPressed(DialogPlateButtonId id);
AssistantController* const assistant_controller_; // Owned by Shell. AssistantController* const assistant_controller_; // Owned by Shell.
views::ImageButton* keyboard_input_toggle_; // Owned by view hierarchy.
views::View* keyboard_layout_container_; // Owned by view hierarchy. views::View* keyboard_layout_container_; // Owned by view hierarchy.
views::Textfield* textfield_; // Owned by view hierarchy.
views::ImageButton* voice_input_toggle_; // Owned by view hierarchy.
views::View* voice_layout_container_; // Owned by view hierarchy. views::View* voice_layout_container_; // Owned by view hierarchy.
views::Textfield* textfield_; // Owned by view hierarchy.
base::ObserverList<DialogPlateObserver> observers_; base::ObserverList<DialogPlateObserver> observers_;
......
...@@ -13,15 +13,22 @@ namespace assistant { ...@@ -13,15 +13,22 @@ namespace assistant {
namespace util { namespace util {
ui::LayerAnimationSequence* CreateLayerAnimationSequence( ui::LayerAnimationSequence* CreateLayerAnimationSequence(
std::unique_ptr<ui::LayerAnimationElement> layer_animation_element) { std::unique_ptr<ui::LayerAnimationElement> a,
return CreateLayerAnimationSequenceWithDelay( std::unique_ptr<ui::LayerAnimationElement> b) {
std::move(layer_animation_element), ui::LayerAnimationSequence* layer_animation_sequence =
/*delay=*/base::TimeDelta()); new ui::LayerAnimationSequence();
layer_animation_sequence->AddElement(std::move(a));
if (b)
layer_animation_sequence->AddElement(std::move(b));
return layer_animation_sequence;
} }
ui::LayerAnimationSequence* CreateLayerAnimationSequenceWithDelay( ui::LayerAnimationSequence* CreateLayerAnimationSequenceWithDelay(
std::unique_ptr<ui::LayerAnimationElement> layer_animation_element, std::unique_ptr<ui::LayerAnimationElement> layer_animation_element,
base::TimeDelta delay) { const base::TimeDelta& delay) {
DCHECK(delay.InMilliseconds() >= 0); DCHECK(delay.InMilliseconds() >= 0);
ui::LayerAnimationSequence* layer_animation_sequence = ui::LayerAnimationSequence* layer_animation_sequence =
...@@ -38,6 +45,26 @@ ui::LayerAnimationSequence* CreateLayerAnimationSequenceWithDelay( ...@@ -38,6 +45,26 @@ ui::LayerAnimationSequence* CreateLayerAnimationSequenceWithDelay(
return layer_animation_sequence; return layer_animation_sequence;
} }
std::unique_ptr<ui::LayerAnimationElement> CreateOpacityElement(
float opacity,
const base::TimeDelta& duration,
const gfx::Tween::Type& tween) {
std::unique_ptr<ui::LayerAnimationElement> layer_animation_element =
ui::LayerAnimationElement::CreateOpacityElement(opacity, duration);
layer_animation_element->set_tween_type(tween);
return layer_animation_element;
}
std::unique_ptr<ui::LayerAnimationElement> CreateTransformElement(
const gfx::Transform& transform,
const base::TimeDelta& duration,
const gfx::Tween::Type& tween) {
std::unique_ptr<ui::LayerAnimationElement> layer_animation_element =
ui::LayerAnimationElement::CreateTransformElement(transform, duration);
layer_animation_element->set_tween_type(tween);
return layer_animation_element;
}
} // namespace util } // namespace util
} // namespace assistant } // namespace assistant
} // namespace ash } // namespace ash
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <memory> #include <memory>
#include "ui/gfx/animation/tween.h"
namespace base { namespace base {
class TimeDelta; class TimeDelta;
} // namespace base } // namespace base
...@@ -21,17 +23,31 @@ namespace assistant { ...@@ -21,17 +23,31 @@ namespace assistant {
namespace util { namespace util {
// Creates a LayerAnimationSequence containing the specified // Creates a LayerAnimationSequence containing the specified
// |layer_animation_element|. The method caller assumes ownership of the // LayerAnimationElements. The method caller assumes ownership of the
// returned pointer. // returned pointer.
ui::LayerAnimationSequence* CreateLayerAnimationSequence( ui::LayerAnimationSequence* CreateLayerAnimationSequence(
std::unique_ptr<ui::LayerAnimationElement> layer_animation_element); std::unique_ptr<ui::LayerAnimationElement> a,
std::unique_ptr<ui::LayerAnimationElement> b = nullptr);
// Creates a LayerAnimationSequence containing the specified // Creates a LayerAnimationSequence containing the specified
// |layer_animation_element| to be started after the given |delay|. The method // |layer_animation_element| to be started after the given |delay|. The method
// caller assumes ownership of the returned pointer. // caller assumes ownership of the returned pointer.
ui::LayerAnimationSequence* CreateLayerAnimationSequenceWithDelay( ui::LayerAnimationSequence* CreateLayerAnimationSequenceWithDelay(
std::unique_ptr<ui::LayerAnimationElement> layer_animation_element, std::unique_ptr<ui::LayerAnimationElement> layer_animation_element,
base::TimeDelta delay); const base::TimeDelta& delay);
// Creates a LayerAnimationElement to animate opacity with the given parameters.
std::unique_ptr<ui::LayerAnimationElement> CreateOpacityElement(
float opacity,
const base::TimeDelta& duration,
const gfx::Tween::Type& tween = gfx::Tween::Type::LINEAR);
// Creates a LayerAnimationElement to animate transform with the given
// parameters.
std::unique_ptr<ui::LayerAnimationElement> CreateTransformElement(
const gfx::Transform& transform,
const base::TimeDelta& duration,
const gfx::Tween::Type& tween = gfx::Tween::Type::LINEAR);
} // namespace util } // namespace util
} // namespace assistant } // namespace assistant
......
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