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

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

Issue 1671313002: MacViews: Overlay Scrollbars with Show/Hide Animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/native_theme/native_theme.h" 11 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/border.h" 12 #include "ui/views/border.h"
13 #include "ui/views/controls/scrollbar/native_scroll_bar.h" 13 #include "ui/views/style/platform_style.h"
14 #include "ui/views/widget/root_view.h" 14 #include "ui/views/widget/root_view.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 const char ScrollView::kViewClassName[] = "ScrollView"; 18 const char ScrollView::kViewClassName[] = "ScrollView";
19 19
20 namespace { 20 namespace {
21 21
22 // Subclass of ScrollView that resets the border when the theme changes. 22 // Subclass of ScrollView that resets the border when the theme changes.
23 class ScrollViewWithBorder : public views::ScrollView { 23 class ScrollViewWithBorder : public views::ScrollView {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 private: 118 private:
119 DISALLOW_COPY_AND_ASSIGN(Viewport); 119 DISALLOW_COPY_AND_ASSIGN(Viewport);
120 }; 120 };
121 121
122 ScrollView::ScrollView() 122 ScrollView::ScrollView()
123 : contents_(NULL), 123 : contents_(NULL),
124 contents_viewport_(new Viewport()), 124 contents_viewport_(new Viewport()),
125 header_(NULL), 125 header_(NULL),
126 header_viewport_(new Viewport()), 126 header_viewport_(new Viewport()),
127 horiz_sb_(new NativeScrollBar(true)), 127 horiz_sb_(PlatformStyle::CreateScrollBar(true).release()),
128 vert_sb_(new NativeScrollBar(false)), 128 vert_sb_(PlatformStyle::CreateScrollBar(false).release()),
129 corner_view_(new ScrollCornerView()), 129 corner_view_(new ScrollCornerView()),
130 min_height_(-1), 130 min_height_(-1),
131 max_height_(-1), 131 max_height_(-1),
132 hide_horizontal_scrollbar_(false) { 132 hide_horizontal_scrollbar_(false) {
133 set_notify_enter_exit_on_child(true); 133 set_notify_enter_exit_on_child(true);
134 134
135 AddChildView(contents_viewport_); 135 AddChildView(contents_viewport_);
136 AddChildView(header_viewport_); 136 AddChildView(header_viewport_);
137 137
138 // Don't add the scrollbars as children until we discover we need them 138 // Don't add the scrollbars as children until we discover we need them
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 viewport_bounds.set_height( 293 viewport_bounds.set_height(
294 std::max(0, viewport_bounds.height() - horiz_sb_height)); 294 std::max(0, viewport_bounds.height() - horiz_sb_height));
295 should_layout_contents = true; 295 should_layout_contents = true;
296 } 296 }
297 // Default. 297 // Default.
298 if (!vert_sb_required) { 298 if (!vert_sb_required) {
299 viewport_bounds.set_width(viewport_bounds.width() + vert_sb_width); 299 viewport_bounds.set_width(viewport_bounds.width() + vert_sb_width);
300 should_layout_contents = true; 300 should_layout_contents = true;
301 } 301 }
302 302
303 int height_offset = horiz_sb_required ?
304 horiz_sb_->GetContentOverlapSize() : 0;
305 int width_offset = vert_sb_required ?
306 vert_sb_->GetContentOverlapSize() : 0;
307
303 if (horiz_sb_required) { 308 if (horiz_sb_required) {
304 int height_offset = horiz_sb_->GetContentOverlapSize();
305 horiz_sb_->SetBounds(contents_x, 309 horiz_sb_->SetBounds(contents_x,
306 viewport_bounds.bottom() - height_offset, 310 viewport_bounds.bottom() - height_offset,
307 viewport_bounds.right() - contents_x, 311 viewport_bounds.right() - contents_x - width_offset,
308 horiz_sb_height + height_offset); 312 horiz_sb_height + height_offset);
309 } 313 }
310 if (vert_sb_required) { 314 if (vert_sb_required) {
311 int width_offset = vert_sb_->GetContentOverlapSize(); 315 int width_offset = vert_sb_->GetContentOverlapSize();
312 vert_sb_->SetBounds(viewport_bounds.right() - width_offset, 316 vert_sb_->SetBounds(viewport_bounds.right() - width_offset,
313 contents_y, 317 contents_y,
314 vert_sb_width + width_offset, 318 vert_sb_width + width_offset,
315 viewport_bounds.bottom() - contents_y); 319 viewport_bounds.bottom() - contents_y - height_offset);
316 } 320 }
317 if (corner_view_required) { 321 if (corner_view_required) {
318 // Show the resize corner. 322 // Show the resize corner.
319 corner_view_->SetBounds(vert_sb_->bounds().x(), horiz_sb_->bounds().y(), 323 corner_view_->SetBounds(vert_sb_->bounds().x(), horiz_sb_->bounds().y(),
320 vert_sb_width, horiz_sb_height); 324 vert_sb_width, horiz_sb_height);
321 } 325 }
322 326
323 // Update to the real client size with the visible scrollbars. 327 // Update to the real client size with the visible scrollbars.
324 contents_viewport_->SetBoundsRect(viewport_bounds); 328 contents_viewport_->SetBoundsRect(viewport_bounds);
325 if (should_layout_contents && contents_) 329 if (should_layout_contents && contents_)
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 636
633 VariableRowHeightScrollHelper::RowInfo 637 VariableRowHeightScrollHelper::RowInfo
634 FixedRowHeightScrollHelper::GetRowInfo(int y) { 638 FixedRowHeightScrollHelper::GetRowInfo(int y) {
635 if (y < top_margin_) 639 if (y < top_margin_)
636 return RowInfo(0, top_margin_); 640 return RowInfo(0, top_margin_);
637 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, 641 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_,
638 row_height_); 642 row_height_);
639 } 643 }
640 644
641 } // namespace views 645 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698