Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Side by Side Diff: ui/views/controls/single_split_view.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/single_split_view.h ('k') | ui/views/controls/single_split_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/accessibility/accessible_view_state.h" 8 #include "ui/base/accessibility/accessible_view_state.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 height += pref.height(); 83 height += pref.height();
84 } 84 }
85 } 85 }
86 if (is_horizontal_) 86 if (is_horizontal_)
87 width += kDividerSize; 87 width += kDividerSize;
88 else 88 else
89 height += kDividerSize; 89 height += kDividerSize;
90 return gfx::Size(width, height); 90 return gfx::Size(width, height);
91 } 91 }
92 92
93 gfx::NativeCursor SingleSplitView::GetCursor(const MouseEvent& event) { 93 gfx::NativeCursor SingleSplitView::GetCursor(const ui::MouseEvent& event) {
94 if (!IsPointInDivider(event.location())) 94 if (!IsPointInDivider(event.location()))
95 return gfx::kNullCursor; 95 return gfx::kNullCursor;
96 #if defined(USE_AURA) 96 #if defined(USE_AURA)
97 return is_horizontal_ ? 97 return is_horizontal_ ?
98 ui::kCursorEastWestResize : ui::kCursorNorthSouthResize; 98 ui::kCursorEastWestResize : ui::kCursorNorthSouthResize;
99 #elif defined(OS_WIN) 99 #elif defined(OS_WIN)
100 static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); 100 static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE);
101 static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS); 101 static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS);
102 return is_horizontal_ ? we_resize_cursor : ns_resize_cursor; 102 return is_horizontal_ ? we_resize_cursor : ns_resize_cursor;
103 #endif 103 #endif
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 *trailing_bounds = 142 *trailing_bounds =
143 gfx::Rect(0, divider_at + divider_size, bounds.width(), 143 gfx::Rect(0, divider_at + divider_size, bounds.width(),
144 std::max(0, bounds.height() - divider_at - divider_size)); 144 std::max(0, bounds.height() - divider_at - divider_size));
145 } 145 }
146 } 146 }
147 147
148 void SingleSplitView::SetAccessibleName(const string16& name) { 148 void SingleSplitView::SetAccessibleName(const string16& name) {
149 accessible_name_ = name; 149 accessible_name_ = name;
150 } 150 }
151 151
152 bool SingleSplitView::OnMousePressed(const MouseEvent& event) { 152 bool SingleSplitView::OnMousePressed(const ui::MouseEvent& event) {
153 if (!IsPointInDivider(event.location())) 153 if (!IsPointInDivider(event.location()))
154 return false; 154 return false;
155 drag_info_.initial_mouse_offset = GetPrimaryAxisSize(event.x(), event.y()); 155 drag_info_.initial_mouse_offset = GetPrimaryAxisSize(event.x(), event.y());
156 drag_info_.initial_divider_offset = 156 drag_info_.initial_divider_offset =
157 NormalizeDividerOffset(divider_offset_, bounds()); 157 NormalizeDividerOffset(divider_offset_, bounds());
158 return true; 158 return true;
159 } 159 }
160 160
161 bool SingleSplitView::OnMouseDragged(const MouseEvent& event) { 161 bool SingleSplitView::OnMouseDragged(const ui::MouseEvent& event) {
162 if (child_count() < 2) 162 if (child_count() < 2)
163 return false; 163 return false;
164 164
165 int delta_offset = GetPrimaryAxisSize(event.x(), event.y()) - 165 int delta_offset = GetPrimaryAxisSize(event.x(), event.y()) -
166 drag_info_.initial_mouse_offset; 166 drag_info_.initial_mouse_offset;
167 if (is_horizontal_ && base::i18n::IsRTL()) 167 if (is_horizontal_ && base::i18n::IsRTL())
168 delta_offset *= -1; 168 delta_offset *= -1;
169 // Honor the minimum size when resizing. 169 // Honor the minimum size when resizing.
170 gfx::Size min = child_at(0)->GetMinimumSize(); 170 gfx::Size min = child_at(0)->GetMinimumSize();
171 int new_size = std::max(GetPrimaryAxisSize(min.width(), min.height()), 171 int new_size = std::max(GetPrimaryAxisSize(min.width(), min.height()),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 const gfx::Rect& bounds) const { 243 const gfx::Rect& bounds) const {
244 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); 244 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height());
245 if (divider_offset < 0) 245 if (divider_offset < 0)
246 // primary_axis_size may < kDividerSize during initial layout. 246 // primary_axis_size may < kDividerSize during initial layout.
247 return std::max(0, (primary_axis_size - kDividerSize) / 2); 247 return std::max(0, (primary_axis_size - kDividerSize) / 2);
248 return std::min(divider_offset, 248 return std::min(divider_offset,
249 std::max(primary_axis_size - kDividerSize, 0)); 249 std::max(primary_axis_size - kDividerSize, 0));
250 } 250 }
251 251
252 } // namespace views 252 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/single_split_view.h ('k') | ui/views/controls/single_split_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698