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/single_split_view.h" | 5 #include "ui/views/controls/single_split_view.h" |
6 | 6 |
7 #include "skia/ext/skia_utils_win.h" | 7 #include "skia/ext/skia_utils_win.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/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
10 #include "ui/views/background.h" | 11 #include "ui/views/background.h" |
11 #include "ui/views/controls/single_split_view_listener.h" | 12 #include "ui/views/controls/single_split_view_listener.h" |
12 | 13 |
13 #if defined(USE_AURA) | |
14 #include "ui/base/cursor/cursor.h" | |
15 #endif | |
16 | |
17 namespace views { | 14 namespace views { |
18 | 15 |
19 // static | 16 // static |
20 const char SingleSplitView::kViewClassName[] = "SingleSplitView"; | 17 const char SingleSplitView::kViewClassName[] = "SingleSplitView"; |
21 | 18 |
22 // Size of the divider in pixels. | 19 // Size of the divider in pixels. |
23 static const int kDividerSize = 4; | 20 static const int kDividerSize = 4; |
24 | 21 |
25 SingleSplitView::SingleSplitView(View* leading, | 22 SingleSplitView::SingleSplitView(View* leading, |
26 View* trailing, | 23 View* trailing, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (is_horizontal_) | 81 if (is_horizontal_) |
85 width += GetDividerSize(); | 82 width += GetDividerSize(); |
86 else | 83 else |
87 height += GetDividerSize(); | 84 height += GetDividerSize(); |
88 return gfx::Size(width, height); | 85 return gfx::Size(width, height); |
89 } | 86 } |
90 | 87 |
91 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) { | 88 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) { |
92 if (!IsPointInDivider(event.location())) | 89 if (!IsPointInDivider(event.location())) |
93 return gfx::kNullCursor; | 90 return gfx::kNullCursor; |
94 #if defined(USE_AURA) | |
95 return is_horizontal_ ? | 91 return is_horizontal_ ? |
96 ui::kCursorEastWestResize : ui::kCursorNorthSouthResize; | 92 ui::kCursorEastWestResize : ui::kCursorNorthSouthResize; |
97 #elif defined(OS_WIN) | |
98 static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); | |
99 static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS); | |
100 return is_horizontal_ ? we_resize_cursor : ns_resize_cursor; | |
101 #endif | |
102 } | 93 } |
103 | 94 |
104 int SingleSplitView::GetDividerSize() const { | 95 int SingleSplitView::GetDividerSize() const { |
105 bool both_visible = child_count() > 1 && child_at(0)->visible() && | 96 bool both_visible = child_count() > 1 && child_at(0)->visible() && |
106 child_at(1)->visible(); | 97 child_at(1)->visible(); |
107 return both_visible && !resize_disabled_ ? kDividerSize : 0; | 98 return both_visible && !resize_disabled_ ? kDividerSize : 0; |
108 } | 99 } |
109 | 100 |
110 void SingleSplitView::CalculateChildrenBounds( | 101 void SingleSplitView::CalculateChildrenBounds( |
111 const gfx::Rect& bounds, | 102 const gfx::Rect& bounds, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const gfx::Rect& bounds) const { | 243 const gfx::Rect& bounds) const { |
253 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); | 244 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); |
254 if (divider_offset < 0) | 245 if (divider_offset < 0) |
255 // primary_axis_size may < GetDividerSize during initial layout. | 246 // primary_axis_size may < GetDividerSize during initial layout. |
256 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); | 247 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); |
257 return std::min(divider_offset, | 248 return std::min(divider_offset, |
258 std::max(primary_axis_size - GetDividerSize(), 0)); | 249 std::max(primary_axis_size - GetDividerSize(), 0)); |
259 } | 250 } |
260 | 251 |
261 } // namespace views | 252 } // namespace views |
OLD | NEW |