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/base/cursor/cursor.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
11 #include "ui/views/background.h" | 11 #include "ui/views/background.h" |
12 #include "ui/views/controls/single_split_view_listener.h" | 12 #include "ui/views/controls/single_split_view_listener.h" |
| 13 #include "ui/views/native_cursor.h" |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 | 16 |
16 // static | 17 // static |
17 const char SingleSplitView::kViewClassName[] = "SingleSplitView"; | 18 const char SingleSplitView::kViewClassName[] = "SingleSplitView"; |
18 | 19 |
19 // Size of the divider in pixels. | 20 // Size of the divider in pixels. |
20 static const int kDividerSize = 4; | 21 static const int kDividerSize = 4; |
21 | 22 |
22 SingleSplitView::SingleSplitView(View* leading, | 23 SingleSplitView::SingleSplitView(View* leading, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (is_horizontal_) | 82 if (is_horizontal_) |
82 width += GetDividerSize(); | 83 width += GetDividerSize(); |
83 else | 84 else |
84 height += GetDividerSize(); | 85 height += GetDividerSize(); |
85 return gfx::Size(width, height); | 86 return gfx::Size(width, height); |
86 } | 87 } |
87 | 88 |
88 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) { | 89 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) { |
89 if (!IsPointInDivider(event.location())) | 90 if (!IsPointInDivider(event.location())) |
90 return gfx::kNullCursor; | 91 return gfx::kNullCursor; |
91 return is_horizontal_ ? | 92 return is_horizontal_ ? GetNativeEastWestResizeCursor() |
92 ui::kCursorEastWestResize : ui::kCursorNorthSouthResize; | 93 : GetNativeNorthSouthResizeCursor(); |
93 } | 94 } |
94 | 95 |
95 int SingleSplitView::GetDividerSize() const { | 96 int SingleSplitView::GetDividerSize() const { |
96 bool both_visible = child_count() > 1 && child_at(0)->visible() && | 97 bool both_visible = child_count() > 1 && child_at(0)->visible() && |
97 child_at(1)->visible(); | 98 child_at(1)->visible(); |
98 return both_visible && !resize_disabled_ ? kDividerSize : 0; | 99 return both_visible && !resize_disabled_ ? kDividerSize : 0; |
99 } | 100 } |
100 | 101 |
101 void SingleSplitView::CalculateChildrenBounds( | 102 void SingleSplitView::CalculateChildrenBounds( |
102 const gfx::Rect& bounds, | 103 const gfx::Rect& bounds, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 const gfx::Rect& bounds) const { | 244 const gfx::Rect& bounds) const { |
244 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); | 245 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); |
245 if (divider_offset < 0) | 246 if (divider_offset < 0) |
246 // primary_axis_size may < GetDividerSize during initial layout. | 247 // primary_axis_size may < GetDividerSize during initial layout. |
247 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); | 248 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); |
248 return std::min(divider_offset, | 249 return std::min(divider_offset, |
249 std::max(primary_axis_size - GetDividerSize(), 0)); | 250 std::max(primary_axis_size - GetDividerSize(), 0)); |
250 } | 251 } |
251 | 252 |
252 } // namespace views | 253 } // namespace views |
OLD | NEW |