Commit ad8e631a authored by prasadt@chromium.org's avatar prasadt@chromium.org

Fix bug where panels sometimes don't align on bottom.

This happens when a move animation starts while a resize animation, typically during creation is in progress. Now the animation starts from where the last one left.

Fixes a bug where from bounds and to bounds are reversed in the called StartBoundsAnimation in OnSizeChanged.

BUG=106573
TEST=Instructions in bug report.


Review URL: http://codereview.chromium.org/8879005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113746 0039d316-1c4b-4281-b951-d872f2087c98
parent e0b22c9e
...@@ -147,7 +147,7 @@ void PanelBrowserWindowGtk::OnSizeChanged(int width, int height) { ...@@ -147,7 +147,7 @@ void PanelBrowserWindowGtk::OnSizeChanged(int width, int height) {
int left = bounds_.right() - width; int left = bounds_.right() - width;
gtk_window_move(window_, left, top); gtk_window_move(window_, left, top);
StartBoundsAnimation(bounds_, gfx::Rect(left, top, width, height)); StartBoundsAnimation(gfx::Rect(left, top, width, height), bounds_);
panel_->OnWindowSizeAvailable(); panel_->OnWindowSizeAvailable();
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
...@@ -422,11 +422,17 @@ int PanelBrowserWindowGtk::TitleOnlyHeight() const { ...@@ -422,11 +422,17 @@ int PanelBrowserWindowGtk::TitleOnlyHeight() const {
void PanelBrowserWindowGtk::StartBoundsAnimation( void PanelBrowserWindowGtk::StartBoundsAnimation(
const gfx::Rect& from_bounds, const gfx::Rect& to_bounds) { const gfx::Rect& from_bounds, const gfx::Rect& to_bounds) {
animation_start_bounds_ = from_bounds; if (bounds_animator_.get() && bounds_animator_->is_animating()) {
animation_start_bounds_ = last_animation_progressed_bounds_;
} else {
animation_start_bounds_ = from_bounds;
}
bounds_animator_.reset(new PanelSlideAnimation( bounds_animator_.reset(new PanelSlideAnimation(
this, panel_.get(), from_bounds, to_bounds)); this, panel_.get(), from_bounds, to_bounds));
bounds_animator_->Show(); bounds_animator_->Show();
last_animation_progressed_bounds_ = animation_start_bounds_;
} }
bool PanelBrowserWindowGtk::IsAnimatingBounds() const { bool PanelBrowserWindowGtk::IsAnimatingBounds() const {
...@@ -506,6 +512,8 @@ void PanelBrowserWindowGtk::AnimationProgressed( ...@@ -506,6 +512,8 @@ void PanelBrowserWindowGtk::AnimationProgressed(
(animation_start_bounds_.right() != bounds_.right()); (animation_start_bounds_.right() != bounds_.right());
if (move) if (move)
gtk_window_move(window_, new_bounds.x(), new_bounds.y()); gtk_window_move(window_, new_bounds.x(), new_bounds.y());
last_animation_progressed_bounds_ = new_bounds;
} }
void PanelBrowserWindowGtk::CreateDragWidget() { void PanelBrowserWindowGtk::CreateDragWidget() {
......
...@@ -193,6 +193,12 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk, ...@@ -193,6 +193,12 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk,
scoped_ptr<ui::SlideAnimation> bounds_animator_; scoped_ptr<ui::SlideAnimation> bounds_animator_;
gfx::Rect animation_start_bounds_; gfx::Rect animation_start_bounds_;
// This records the bounds set on the last animation progress notification.
// We need this for the case where a new bounds animation starts before the
// current one completes. In this case, we want to start the new animation
// from where the last one left.
gfx::Rect last_animation_progressed_bounds_;
DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk); DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk);
}; };
......
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