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/accessibility/ax_view_state.h" | 8 #include "ui/accessibility/ax_view_state.h" |
9 #include "ui/base/cursor/cursor.h" | 9 #include "ui/base/cursor/cursor.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/views/controls/resize_area_delegate.h" | 11 #include "ui/views/controls/resize_area_delegate.h" |
| 12 #include "ui/views/native_cursor.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 | 15 |
15 const char ResizeArea::kViewClassName[] = "ResizeArea"; | 16 const char ResizeArea::kViewClassName[] = "ResizeArea"; |
16 | 17 |
17 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
18 // ResizeArea | 19 // ResizeArea |
19 | 20 |
20 ResizeArea::ResizeArea(ResizeAreaDelegate* delegate) | 21 ResizeArea::ResizeArea(ResizeAreaDelegate* delegate) |
21 : delegate_(delegate), | 22 : delegate_(delegate), |
22 initial_position_(0) { | 23 initial_position_(0) { |
23 } | 24 } |
24 | 25 |
25 ResizeArea::~ResizeArea() { | 26 ResizeArea::~ResizeArea() { |
26 } | 27 } |
27 | 28 |
28 const char* ResizeArea::GetClassName() const { | 29 const char* ResizeArea::GetClassName() const { |
29 return kViewClassName; | 30 return kViewClassName; |
30 } | 31 } |
31 | 32 |
32 gfx::NativeCursor ResizeArea::GetCursor(const ui::MouseEvent& event) { | 33 gfx::NativeCursor ResizeArea::GetCursor(const ui::MouseEvent& event) { |
33 return enabled() ? ui::kCursorEastWestResize : gfx::kNullCursor; | 34 return enabled() ? GetNativeEastWestResizeCursor() |
| 35 : gfx::kNullCursor; |
34 } | 36 } |
35 | 37 |
36 bool ResizeArea::OnMousePressed(const ui::MouseEvent& event) { | 38 bool ResizeArea::OnMousePressed(const ui::MouseEvent& event) { |
37 if (!event.IsOnlyLeftMouseButton()) | 39 if (!event.IsOnlyLeftMouseButton()) |
38 return false; | 40 return false; |
39 | 41 |
40 // The resize area obviously will move once you start dragging so we need to | 42 // The resize area obviously will move once you start dragging so we need to |
41 // convert coordinates to screen coordinates so that we don't lose our | 43 // convert coordinates to screen coordinates so that we don't lose our |
42 // bearings. | 44 // bearings. |
43 gfx::Point point(event.x(), 0); | 45 gfx::Point point(event.x(), 0); |
(...skipping 25 matching lines...) Expand all Loading... |
69 | 71 |
70 void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { | 72 void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { |
71 gfx::Point point(resize_amount, 0); | 73 gfx::Point point(resize_amount, 0); |
72 View::ConvertPointToScreen(this, &point); | 74 View::ConvertPointToScreen(this, &point); |
73 resize_amount = point.x() - initial_position_; | 75 resize_amount = point.x() - initial_position_; |
74 delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount, | 76 delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount, |
75 last_update); | 77 last_update); |
76 } | 78 } |
77 | 79 |
78 } // namespace views | 80 } // namespace views |
OLD | NEW |