Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ash/wm/drag_details.h" |
| 6 | |
| 7 | #include "ash/wm/window_resizer.h" |
| 8 | #include "ui/aura/window.h" |
| 9 | #include "ui/base/hit_test.h" |
| 10 | |
| 11 | namespace ash { |
| 12 | |
| 13 | namespace { |
| 14 | |
| 15 | int GetSizeChangeDirectionForWindowComponent(int window_component) { |
| 16 | int size_change_direction = WindowResizer::kBoundsChangeDirection_None; |
| 17 | switch (window_component) { |
| 18 | case HTTOPLEFT: |
| 19 | case HTTOPRIGHT: |
| 20 | case HTBOTTOMLEFT: |
| 21 | case HTBOTTOMRIGHT: |
| 22 | case HTGROWBOX: |
| 23 | case HTCAPTION: |
| 24 | size_change_direction |= |
| 25 | WindowResizer::kBoundsChangeDirection_Horizontal | |
| 26 | WindowResizer::kBoundsChangeDirection_Vertical; |
| 27 | break; |
| 28 | case HTTOP: |
| 29 | case HTBOTTOM: |
| 30 | size_change_direction |= WindowResizer::kBoundsChangeDirection_Vertical; |
| 31 | break; |
| 32 | case HTRIGHT: |
| 33 | case HTLEFT: |
| 34 | size_change_direction |= WindowResizer::kBoundsChangeDirection_Horizontal; |
| 35 | break; |
| 36 | default: |
| 37 | break; |
| 38 | } |
| 39 | return size_change_direction; |
| 40 | } |
| 41 | |
| 42 | } // namespace |
| 43 | |
| 44 | DragDetails::DragDetails(aura::Window* window, |
| 45 | const gfx::Point& location, |
| 46 | int window_component, |
| 47 | aura::client::WindowMoveSource source) |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 48 | : initial_state_type(wm::GetWindowState(window)->GetStateType()), |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 49 | initial_bounds_in_parent(window->bounds()), |
| 50 | initial_location_in_parent(location), |
| 51 | initial_opacity(window->layer()->opacity()), |
| 52 | window_component(window_component), |
| 53 | bounds_change( |
| 54 | WindowResizer::GetBoundsChangeForWindowComponent(window_component)), |
| 55 | position_change_direction( |
| 56 | WindowResizer::GetPositionChangeDirectionForWindowComponent( |
| 57 | window_component)), |
| 58 | size_change_direction( |
| 59 | GetSizeChangeDirectionForWindowComponent(window_component)), |
| 60 | is_resizable(bounds_change != WindowResizer::kBoundsChangeDirection_None), |
| 61 | source(source), |
| 62 | should_attach_to_shelf(window->type() == ui::wm::WINDOW_TYPE_PANEL && |
| 63 | wm::GetWindowState(window)->panel_attached()) { |
| 64 | wm::WindowState* window_state = wm::GetWindowState(window); |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 65 | if (window_state->IsNormalOrSnapped() && |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 66 | window_state->HasRestoreBounds() && |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 67 | window_component == HTCAPTION) { |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 68 | restore_bounds = window_state->GetRestoreBoundsInScreen(); |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 69 | } |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | DragDetails::~DragDetails() { |
| 73 | } |
| 74 | |
| 75 | } // namespace ash |