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

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

Issue 16171010: Introduces a new scrollbar for message_center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: GetVisibleSize -> GetContentOverlapSize Created 7 years, 6 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/scroll_view.h ('k') | ui/views/controls/scrollbar/overlay_scroll_bar.h » ('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/scroll_view.h" 5 #include "ui/views/controls/scroll_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/events/event.h" 8 #include "ui/base/events/event.h"
9 #include "ui/native_theme/native_theme.h" 9 #include "ui/native_theme/native_theme.h"
10 #include "ui/views/border.h" 10 #include "ui/views/border.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 ScrollView::ScrollView() 111 ScrollView::ScrollView()
112 : contents_(NULL), 112 : contents_(NULL),
113 contents_viewport_(new Viewport()), 113 contents_viewport_(new Viewport()),
114 header_(NULL), 114 header_(NULL),
115 header_viewport_(new Viewport()), 115 header_viewport_(new Viewport()),
116 horiz_sb_(new NativeScrollBar(true)), 116 horiz_sb_(new NativeScrollBar(true)),
117 vert_sb_(new NativeScrollBar(false)), 117 vert_sb_(new NativeScrollBar(false)),
118 resize_corner_(NULL), 118 resize_corner_(NULL),
119 hide_horizontal_scrollbar_(false) { 119 hide_horizontal_scrollbar_(false) {
120 set_notify_enter_exit_on_child(true);
121
120 AddChildView(contents_viewport_); 122 AddChildView(contents_viewport_);
121 AddChildView(header_viewport_); 123 AddChildView(header_viewport_);
122 124
123 // Don't add the scrollbars as children until we discover we need them 125 // Don't add the scrollbars as children until we discover we need them
124 // (ShowOrHideScrollBar). 126 // (ShowOrHideScrollBar).
125 horiz_sb_->SetVisible(false); 127 horiz_sb_->SetVisible(false);
126 horiz_sb_->set_controller(this); 128 horiz_sb_->set_controller(this);
127 vert_sb_->SetVisible(false); 129 vert_sb_->SetVisible(false);
128 vert_sb_->set_controller(this); 130 vert_sb_->set_controller(this);
129 if (resize_corner_) 131 if (resize_corner_)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 std::max(0, viewport_bounds.height() - horiz_sb_height)); 247 std::max(0, viewport_bounds.height() - horiz_sb_height));
246 should_layout_contents = true; 248 should_layout_contents = true;
247 } 249 }
248 // Default. 250 // Default.
249 if (!vert_sb_required) { 251 if (!vert_sb_required) {
250 viewport_bounds.set_width(viewport_bounds.width() + vert_sb_width); 252 viewport_bounds.set_width(viewport_bounds.width() + vert_sb_width);
251 should_layout_contents = true; 253 should_layout_contents = true;
252 } 254 }
253 255
254 if (horiz_sb_required) { 256 if (horiz_sb_required) {
257 int height_offset = horiz_sb_->GetContentOverlapSize();
255 horiz_sb_->SetBounds(0, 258 horiz_sb_->SetBounds(0,
256 viewport_bounds.bottom(), 259 viewport_bounds.bottom() - height_offset,
257 viewport_bounds.right(), 260 viewport_bounds.right(),
258 horiz_sb_height); 261 horiz_sb_height + height_offset);
259 } 262 }
260 if (vert_sb_required) { 263 if (vert_sb_required) {
261 vert_sb_->SetBounds(viewport_bounds.right(), 264 int width_offset = vert_sb_->GetContentOverlapSize();
265 vert_sb_->SetBounds(viewport_bounds.right() - width_offset,
262 0, 266 0,
263 vert_sb_width, 267 vert_sb_width + width_offset,
264 viewport_bounds.bottom()); 268 viewport_bounds.bottom());
265 } 269 }
266 if (resize_corner_required) { 270 if (resize_corner_required) {
267 // Show the resize corner. 271 // Show the resize corner.
268 resize_corner_->SetBounds(viewport_bounds.right(), 272 resize_corner_->SetBounds(viewport_bounds.right(),
269 viewport_bounds.bottom(), 273 viewport_bounds.bottom(),
270 vert_sb_width, 274 vert_sb_width,
271 horiz_sb_height); 275 horiz_sb_height);
272 } 276 }
273 277
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // Give vertical scrollbar priority 309 // Give vertical scrollbar priority
306 if (vert_sb_->visible()) 310 if (vert_sb_->visible())
307 processed = vert_sb_->OnMouseWheel(e); 311 processed = vert_sb_->OnMouseWheel(e);
308 312
309 if (!processed && horiz_sb_->visible()) 313 if (!processed && horiz_sb_->visible())
310 processed = horiz_sb_->OnMouseWheel(e); 314 processed = horiz_sb_->OnMouseWheel(e);
311 315
312 return processed; 316 return processed;
313 } 317 }
314 318
319 void ScrollView::OnMouseEntered(const ui::MouseEvent& event) {
320 if (horiz_sb_)
321 horiz_sb_->OnMouseEnteredScrollView(event);
322 if (vert_sb_)
323 vert_sb_->OnMouseEnteredScrollView(event);
324 }
325
326 void ScrollView::OnMouseExited(const ui::MouseEvent& event) {
327 if (horiz_sb_)
328 horiz_sb_->OnMouseExitedScrollView(event);
329 if (vert_sb_)
330 vert_sb_->OnMouseExitedScrollView(event);
331 }
332
315 void ScrollView::OnGestureEvent(ui::GestureEvent* event) { 333 void ScrollView::OnGestureEvent(ui::GestureEvent* event) {
316 // If the event happened on one of the scrollbars, then those events are 334 // If the event happened on one of the scrollbars, then those events are
317 // sent directly to the scrollbars. Otherwise, only scroll events are sent to 335 // sent directly to the scrollbars. Otherwise, only scroll events are sent to
318 // the scrollbars. 336 // the scrollbars.
319 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE || 337 bool scroll_event = event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
320 event->type() == ui::ET_GESTURE_SCROLL_BEGIN || 338 event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||
321 event->type() == ui::ET_GESTURE_SCROLL_END || 339 event->type() == ui::ET_GESTURE_SCROLL_END ||
322 event->type() == ui::ET_SCROLL_FLING_START; 340 event->type() == ui::ET_SCROLL_FLING_START;
323 341
324 if (vert_sb_->visible()) { 342 if (vert_sb_->visible()) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 587
570 VariableRowHeightScrollHelper::RowInfo 588 VariableRowHeightScrollHelper::RowInfo
571 FixedRowHeightScrollHelper::GetRowInfo(int y) { 589 FixedRowHeightScrollHelper::GetRowInfo(int y) {
572 if (y < top_margin_) 590 if (y < top_margin_)
573 return RowInfo(0, top_margin_); 591 return RowInfo(0, top_margin_);
574 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 592 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
575 row_height_); 593 row_height_);
576 } 594 }
577 595
578 } // namespace views 596 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/scrollbar/overlay_scroll_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698