OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/panels/panel.h" | 9 #include "chrome/browser/ui/panels/panel.h" |
10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 BrowserWindowGtk::OnSizeChanged(width, height); | 142 BrowserWindowGtk::OnSizeChanged(width, height); |
143 | 143 |
144 if (window_size_known_) | 144 if (window_size_known_) |
145 return; | 145 return; |
146 | 146 |
147 window_size_known_ = true; | 147 window_size_known_ = true; |
148 int top = bounds_.bottom() - height; | 148 int top = bounds_.bottom() - height; |
149 int left = bounds_.right() - width; | 149 int left = bounds_.right() - width; |
150 | 150 |
151 gtk_window_move(window_, left, top); | 151 gtk_window_move(window_, left, top); |
152 | |
152 StartBoundsAnimation(gfx::Rect(left, top, width, height)); | 153 StartBoundsAnimation(gfx::Rect(left, top, width, height)); |
153 panel_->OnWindowSizeAvailable(); | 154 panel_->OnWindowSizeAvailable(); |
154 | 155 |
155 content::NotificationService::current()->Notify( | 156 content::NotificationService::current()->Notify( |
156 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 157 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
157 content::Source<Panel>(panel_.get()), | 158 content::Source<Panel>(panel_.get()), |
158 content::NotificationService::NoDetails()); | 159 content::NotificationService::NoDetails()); |
159 } | 160 } |
160 | 161 |
161 bool PanelBrowserWindowGtk::UseCustomFrame() { | 162 bool PanelBrowserWindowGtk::UseCustomFrame() { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 return gfx::Size(window_size.width() - frame.width(), | 407 return gfx::Size(window_size.width() - frame.width(), |
407 window_size.height() - frame.height()); | 408 window_size.height() - frame.height()); |
408 } | 409 } |
409 | 410 |
410 int PanelBrowserWindowGtk::TitleOnlyHeight() const { | 411 int PanelBrowserWindowGtk::TitleOnlyHeight() const { |
411 return titlebar_widget()->allocation.height; | 412 return titlebar_widget()->allocation.height; |
412 } | 413 } |
413 | 414 |
414 void PanelBrowserWindowGtk::StartBoundsAnimation( | 415 void PanelBrowserWindowGtk::StartBoundsAnimation( |
415 const gfx::Rect& current_bounds) { | 416 const gfx::Rect& current_bounds) { |
416 animation_start_bounds_ = current_bounds; | 417 if (bounds_animator_.get() && bounds_animator_->IsShowing()) { |
Dmitry Titov
2011/12/08 19:04:45
should it be is_animating()? I think IsShowing() i
prasadt
2011/12/08 21:41:45
Done.
| |
418 animation_start_bounds_ = last_animation_progressed_bounds_; | |
419 bounds_animator_->Reset(); | |
Dmitry Titov
2011/12/08 19:04:45
Reset() says it goes back to 0, will it eventually
prasadt
2011/12/08 21:41:45
Done. That line doesn't exist after merging with l
| |
420 } else { | |
421 animation_start_bounds_ = current_bounds; | |
422 } | |
417 | 423 |
418 if (!bounds_animator_.get()) { | 424 if (!bounds_animator_.get()) { |
419 bounds_animator_.reset(new ui::SlideAnimation(this)); | 425 bounds_animator_.reset(new ui::SlideAnimation(this)); |
420 bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs); | 426 bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs); |
421 } | 427 } |
422 | 428 |
423 if (bounds_animator_->IsShowing()) | |
424 bounds_animator_->Reset(); | |
425 bounds_animator_->Show(); | 429 bounds_animator_->Show(); |
430 last_animation_progressed_bounds_ = animation_start_bounds_; | |
426 } | 431 } |
427 | 432 |
428 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { | 433 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { |
429 return bounds_animator_.get() && bounds_animator_->is_animating(); | 434 return bounds_animator_.get() && bounds_animator_->is_animating(); |
430 } | 435 } |
431 | 436 |
432 void PanelBrowserWindowGtk::WillProcessEvent(GdkEvent* event) { | 437 void PanelBrowserWindowGtk::WillProcessEvent(GdkEvent* event) { |
433 // Nothing to do. | 438 // Nothing to do. |
434 } | 439 } |
435 | 440 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 // - Say you minimize the window to 100x3 and move it to 900,997 to keep it | 500 // - Say you minimize the window to 100x3 and move it to 900,997 to keep it |
496 // anchored to the bottom. | 501 // anchored to the bottom. |
497 // - resize is an async operation and the window manager will decide that | 502 // - resize is an async operation and the window manager will decide that |
498 // the move will take the window off screen and it won't honor the | 503 // the move will take the window off screen and it won't honor the |
499 // request. | 504 // request. |
500 // - When resize finally happens, you'll have a 100x3 window a x,y=900,900. | 505 // - When resize finally happens, you'll have a 100x3 window a x,y=900,900. |
501 bool move = (animation_start_bounds_.bottom() != bounds_.bottom()) || | 506 bool move = (animation_start_bounds_.bottom() != bounds_.bottom()) || |
502 (animation_start_bounds_.right() != bounds_.right()); | 507 (animation_start_bounds_.right() != bounds_.right()); |
503 if (move) | 508 if (move) |
504 gtk_window_move(window_, new_bounds.x(), new_bounds.y()); | 509 gtk_window_move(window_, new_bounds.x(), new_bounds.y()); |
510 | |
511 last_animation_progressed_bounds_ = new_bounds; | |
505 } | 512 } |
506 | 513 |
507 void PanelBrowserWindowGtk::CreateDragWidget() { | 514 void PanelBrowserWindowGtk::CreateDragWidget() { |
508 DCHECK(!drag_widget_); | 515 DCHECK(!drag_widget_); |
509 drag_widget_ = gtk_invisible_new(); | 516 drag_widget_ = gtk_invisible_new(); |
510 g_signal_connect_after(drag_widget_, "drag-begin", | 517 g_signal_connect_after(drag_widget_, "drag-begin", |
511 G_CALLBACK(OnDragBeginThunk), this); | 518 G_CALLBACK(OnDragBeginThunk), this); |
512 g_signal_connect(drag_widget_, "drag-failed", | 519 g_signal_connect(drag_widget_, "drag-failed", |
513 G_CALLBACK(OnDragFailedThunk), this); | 520 G_CALLBACK(OnDragFailedThunk), this); |
514 g_signal_connect(drag_widget_, "button-release-event", | 521 g_signal_connect(drag_widget_, "button-release-event", |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 } | 764 } |
758 } | 765 } |
759 | 766 |
760 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 767 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
761 return panel_browser_window_gtk_->window_size_known_; | 768 return panel_browser_window_gtk_->window_size_known_; |
762 } | 769 } |
763 | 770 |
764 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 771 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
765 return panel_browser_window_gtk_->IsAnimatingBounds(); | 772 return panel_browser_window_gtk_->IsAnimatingBounds(); |
766 } | 773 } |
OLD | NEW |