| 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" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 if (is_horizontal_) | 82 if (is_horizontal_) |
| 83 width += GetDividerSize(); | 83 width += GetDividerSize(); |
| 84 else | 84 else |
| 85 height += GetDividerSize(); | 85 height += GetDividerSize(); |
| 86 return gfx::Size(width, height); | 86 return gfx::Size(width, height); |
| 87 } | 87 } |
| 88 | 88 |
| 89 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) { | 89 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) { |
| 90 if (!IsPointInDivider(event.location())) | 90 if (!IsPointInDivider(gfx::ToFlooredPoint(event.location()))) |
| 91 return gfx::kNullCursor; | 91 return gfx::kNullCursor; |
| 92 return is_horizontal_ ? GetNativeEastWestResizeCursor() | 92 return is_horizontal_ ? GetNativeEastWestResizeCursor() |
| 93 : GetNativeNorthSouthResizeCursor(); | 93 : GetNativeNorthSouthResizeCursor(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 int SingleSplitView::GetDividerSize() const { | 96 int SingleSplitView::GetDividerSize() const { |
| 97 bool both_visible = child_count() > 1 && child_at(0)->visible() && | 97 bool both_visible = child_count() > 1 && child_at(0)->visible() && |
| 98 child_at(1)->visible(); | 98 child_at(1)->visible(); |
| 99 return both_visible && !resize_disabled_ ? kDividerSize : 0; | 99 return both_visible && !resize_disabled_ ? kDividerSize : 0; |
| 100 } | 100 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 gfx::Rect(0, divider_at + divider_size, bounds.width(), | 138 gfx::Rect(0, divider_at + divider_size, bounds.width(), |
| 139 std::max(0, bounds.height() - divider_at - divider_size)); | 139 std::max(0, bounds.height() - divider_at - divider_size)); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void SingleSplitView::SetAccessibleName(const base::string16& name) { | 143 void SingleSplitView::SetAccessibleName(const base::string16& name) { |
| 144 accessible_name_ = name; | 144 accessible_name_ = name; |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool SingleSplitView::OnMousePressed(const ui::MouseEvent& event) { | 147 bool SingleSplitView::OnMousePressed(const ui::MouseEvent& event) { |
| 148 if (!IsPointInDivider(event.location())) | 148 if (!IsPointInDivider(gfx::ToFlooredPoint(event.location()))) |
| 149 return false; | 149 return false; |
| 150 drag_info_.initial_mouse_offset = GetPrimaryAxisSize(event.x(), event.y()); | 150 drag_info_.initial_mouse_offset = GetPrimaryAxisSize(event.x(), event.y()); |
| 151 drag_info_.initial_divider_offset = | 151 drag_info_.initial_divider_offset = |
| 152 NormalizeDividerOffset(divider_offset_, bounds()); | 152 NormalizeDividerOffset(divider_offset_, bounds()); |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool SingleSplitView::OnMouseDragged(const ui::MouseEvent& event) { | 156 bool SingleSplitView::OnMouseDragged(const ui::MouseEvent& event) { |
| 157 if (child_count() < 2) | 157 if (child_count() < 2) |
| 158 return false; | 158 return false; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 const gfx::Rect& bounds) const { | 244 const gfx::Rect& bounds) const { |
| 245 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); | 245 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); |
| 246 if (divider_offset < 0) | 246 if (divider_offset < 0) |
| 247 // primary_axis_size may < GetDividerSize during initial layout. | 247 // primary_axis_size may < GetDividerSize during initial layout. |
| 248 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); | 248 return std::max(0, (primary_axis_size - GetDividerSize()) / 2); |
| 249 return std::min(divider_offset, | 249 return std::min(divider_offset, |
| 250 std::max(primary_axis_size - GetDividerSize(), 0)); | 250 std::max(primary_axis_size - GetDividerSize(), 0)); |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace views | 253 } // namespace views |
| OLD | NEW |