OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 (window()->type() != aura::client::WINDOW_TYPE_PANEL || | 415 (window()->type() != aura::client::WINDOW_TYPE_PANEL || |
416 !window()->GetProperty(kPanelAttachedKey)) && | 416 !window()->GetProperty(kPanelAttachedKey)) && |
417 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { | 417 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { |
418 if (!GetRestoreBoundsInScreen(window())) { | 418 if (!GetRestoreBoundsInScreen(window())) { |
419 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( | 419 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( |
420 window()->parent(), details_.initial_bounds_in_parent); | 420 window()->parent(), details_.initial_bounds_in_parent); |
421 SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ? | 421 SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ? |
422 initial_bounds : | 422 initial_bounds : |
423 details_.restore_bounds); | 423 details_.restore_bounds); |
424 } | 424 } |
425 window()->SetBounds(snap_sizer_->target_bounds()); | 425 snap_sizer_->Snap(); |
426 return; | |
427 } | 426 } |
428 } | 427 } |
429 | 428 |
430 void WorkspaceWindowResizer::RevertDrag() { | 429 void WorkspaceWindowResizer::RevertDrag() { |
431 snap_phantom_window_controller_.reset(); | 430 snap_phantom_window_controller_.reset(); |
432 | 431 |
433 if (!did_move_or_resize_) | 432 if (!did_move_or_resize_) |
434 return; | 433 return; |
435 | 434 |
436 window()->SetBounds(details_.initial_bounds_in_parent); | 435 window()->SetBounds(details_.initial_bounds_in_parent); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 NOTREACHED(); | 847 NOTREACHED(); |
849 } | 848 } |
850 return 0; | 849 return 0; |
851 } | 850 } |
852 | 851 |
853 void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, | 852 void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, |
854 const gfx::Rect& bounds) { | 853 const gfx::Rect& bounds) { |
855 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 854 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
856 return; | 855 return; |
857 | 856 |
858 if (!wm::CanSnapWindow(window())) | |
859 return; | |
860 | |
861 if (window()->type() == aura::client::WINDOW_TYPE_PANEL && | 857 if (window()->type() == aura::client::WINDOW_TYPE_PANEL && |
862 window()->GetProperty(kPanelAttachedKey)) { | 858 window()->GetProperty(kPanelAttachedKey)) { |
863 return; | 859 return; |
864 } | 860 } |
865 | 861 |
866 SnapType last_type = snap_type_; | 862 SnapType last_type = snap_type_; |
867 snap_type_ = GetSnapType(location); | 863 snap_type_ = GetSnapType(location); |
868 if (snap_type_ == SNAP_NONE || snap_type_ != last_type) { | 864 using internal::SnapSizer; |
865 SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ? | |
866 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; | |
867 if (snap_type_ == SNAP_NONE || | |
868 !SnapSizer::CanSnapWindow(window(), edge)) { | |
869 snap_type_ = SNAP_NONE; | |
869 snap_phantom_window_controller_.reset(); | 870 snap_phantom_window_controller_.reset(); |
870 snap_sizer_.reset(); | 871 snap_sizer_.reset(); |
871 if (snap_type_ == SNAP_NONE) | 872 return; |
872 return; | |
873 } | 873 } |
874 if (!snap_sizer_) { | 874 |
875 SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ? | 875 if (snap_type_ != last_type || |
varkha
2013/08/30 17:13:25
Will the animations be smoother if we don't re-cre
pkotwicz
2013/08/30 21:10:57
I believe that you always transition through SNAP_
| |
876 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; | 876 !snap_sizer_ || |
877 snap_sizer_.reset(new SnapSizer(window(), | 877 !snap_phantom_window_controller_) { |
878 location, | 878 snap_sizer_.reset( |
879 edge, | 879 new SnapSizer(window(), location, edge, SnapSizer::STEP_YES)); |
880 internal::SnapSizer::OTHER_INPUT)); | 880 snap_phantom_window_controller_.reset( |
881 new PhantomWindowController(window())); | |
881 } else { | 882 } else { |
882 snap_sizer_->Update(location); | 883 snap_sizer_->Update(location); |
883 } | 884 } |
884 if (!snap_phantom_window_controller_) { | |
885 snap_phantom_window_controller_.reset( | |
886 new PhantomWindowController(window())); | |
887 } | |
888 snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( | 885 snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( |
889 window()->parent(), snap_sizer_->target_bounds())); | 886 window()->parent(), snap_sizer_->target_bounds())); |
890 } | 887 } |
891 | 888 |
892 void WorkspaceWindowResizer::RestackWindows() { | 889 void WorkspaceWindowResizer::RestackWindows() { |
893 if (attached_windows_.empty()) | 890 if (attached_windows_.empty()) |
894 return; | 891 return; |
895 // Build a map from index in children to window, returning if there is a | 892 // Build a map from index in children to window, returning if there is a |
896 // window with a different parent. | 893 // window with a different parent. |
897 typedef std::map<size_t, aura::Window*> IndexToWindowMap; | 894 typedef std::map<size_t, aura::Window*> IndexToWindowMap; |
(...skipping 29 matching lines...) Expand all Loading... | |
927 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); | 924 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); |
928 if (location.x() <= area.x()) | 925 if (location.x() <= area.x()) |
929 return SNAP_LEFT_EDGE; | 926 return SNAP_LEFT_EDGE; |
930 if (location.x() >= area.right() - 1) | 927 if (location.x() >= area.right() - 1) |
931 return SNAP_RIGHT_EDGE; | 928 return SNAP_RIGHT_EDGE; |
932 return SNAP_NONE; | 929 return SNAP_NONE; |
933 } | 930 } |
934 | 931 |
935 } // namespace internal | 932 } // namespace internal |
936 } // namespace ash | 933 } // namespace ash |
OLD | NEW |