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 "ui/views/controls/resize_area.h" | 5 #include "ui/views/controls/resize_area.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/views/controls/resize_area_delegate.h" | 10 #include "ui/views/controls/resize_area_delegate.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 initial_position_(0) { | 25 initial_position_(0) { |
26 } | 26 } |
27 | 27 |
28 ResizeArea::~ResizeArea() { | 28 ResizeArea::~ResizeArea() { |
29 } | 29 } |
30 | 30 |
31 std::string ResizeArea::GetClassName() const { | 31 std::string ResizeArea::GetClassName() const { |
32 return kViewClassName; | 32 return kViewClassName; |
33 } | 33 } |
34 | 34 |
35 gfx::NativeCursor ResizeArea::GetCursor(const MouseEvent& event) { | 35 gfx::NativeCursor ResizeArea::GetCursor(const ui::MouseEvent& event) { |
36 if (!enabled()) | 36 if (!enabled()) |
37 return gfx::kNullCursor; | 37 return gfx::kNullCursor; |
38 #if defined(USE_AURA) | 38 #if defined(USE_AURA) |
39 return ui::kCursorEastWestResize; | 39 return ui::kCursorEastWestResize; |
40 #elif defined(OS_WIN) | 40 #elif defined(OS_WIN) |
41 static HCURSOR g_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); | 41 static HCURSOR g_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); |
42 return g_resize_cursor; | 42 return g_resize_cursor; |
43 #endif | 43 #endif |
44 } | 44 } |
45 | 45 |
46 bool ResizeArea::OnMousePressed(const views::MouseEvent& event) { | 46 bool ResizeArea::OnMousePressed(const ui::MouseEvent& event) { |
47 if (!event.IsOnlyLeftMouseButton()) | 47 if (!event.IsOnlyLeftMouseButton()) |
48 return false; | 48 return false; |
49 | 49 |
50 // The resize area obviously will move once you start dragging so we need to | 50 // The resize area obviously will move once you start dragging so we need to |
51 // convert coordinates to screen coordinates so that we don't lose our | 51 // convert coordinates to screen coordinates so that we don't lose our |
52 // bearings. | 52 // bearings. |
53 gfx::Point point(event.x(), 0); | 53 gfx::Point point(event.x(), 0); |
54 View::ConvertPointToScreen(this, &point); | 54 View::ConvertPointToScreen(this, &point); |
55 initial_position_ = point.x(); | 55 initial_position_ = point.x(); |
56 | 56 |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 bool ResizeArea::OnMouseDragged(const views::MouseEvent& event) { | 60 bool ResizeArea::OnMouseDragged(const ui::MouseEvent& event) { |
61 if (!event.IsLeftMouseButton()) | 61 if (!event.IsLeftMouseButton()) |
62 return false; | 62 return false; |
63 | 63 |
64 ReportResizeAmount(event.x(), false); | 64 ReportResizeAmount(event.x(), false); |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 void ResizeArea::OnMouseReleased(const views::MouseEvent& event) { | 68 void ResizeArea::OnMouseReleased(const ui::MouseEvent& event) { |
69 ReportResizeAmount(event.x(), true); | 69 ReportResizeAmount(event.x(), true); |
70 } | 70 } |
71 | 71 |
72 void ResizeArea::OnMouseCaptureLost() { | 72 void ResizeArea::OnMouseCaptureLost() { |
73 ReportResizeAmount(initial_position_, true); | 73 ReportResizeAmount(initial_position_, true); |
74 } | 74 } |
75 | 75 |
76 void ResizeArea::GetAccessibleState(ui::AccessibleViewState* state) { | 76 void ResizeArea::GetAccessibleState(ui::AccessibleViewState* state) { |
77 state->role = ui::AccessibilityTypes::ROLE_SEPARATOR; | 77 state->role = ui::AccessibilityTypes::ROLE_SEPARATOR; |
78 } | 78 } |
79 | 79 |
80 void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { | 80 void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { |
81 gfx::Point point(resize_amount, 0); | 81 gfx::Point point(resize_amount, 0); |
82 View::ConvertPointToScreen(this, &point); | 82 View::ConvertPointToScreen(this, &point); |
83 resize_amount = point.x() - initial_position_; | 83 resize_amount = point.x() - initial_position_; |
84 delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount, | 84 delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount, |
85 last_update); | 85 last_update); |
86 } | 86 } |
87 | 87 |
88 } // namespace views | 88 } // namespace views |
OLD | NEW |