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

Side by Side Diff: ui/views/controls/scrollbar/base_scroll_bar.cc

Issue 2496643002: Implement Sebastien's overlay scrollbars for native UI (Views). (Closed)
Patch Set: clarify comment Created 4 years, 1 month 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/scrollbar/base_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/base_scroll_bar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 contents_scroll_offset = 0; 400 contents_scroll_offset = 0;
401 if (contents_scroll_offset > content_size) 401 if (contents_scroll_offset > content_size)
402 contents_scroll_offset = content_size; 402 contents_scroll_offset = content_size;
403 contents_scroll_offset_ = contents_scroll_offset; 403 contents_scroll_offset_ = contents_scroll_offset;
404 404
405 // Thumb Height and Thumb Pos. 405 // Thumb Height and Thumb Pos.
406 // The height of the thumb is the ratio of the Viewport height to the 406 // The height of the thumb is the ratio of the Viewport height to the
407 // content size multiplied by the height of the thumb track. 407 // content size multiplied by the height of the thumb track.
408 double ratio = 408 double ratio =
409 std::min(1.0, static_cast<double>(viewport_size) / contents_size_); 409 std::min(1.0, static_cast<double>(viewport_size) / contents_size_);
410 int thumb_size = static_cast<int>(ratio * GetTrackSize()); 410 thumb_->SetLength(static_cast<int>(ratio * GetTrackSize()));
411 thumb_->SetSize(thumb_size);
412 411
413 int thumb_position = CalculateThumbPosition(contents_scroll_offset); 412 int thumb_position = CalculateThumbPosition(contents_scroll_offset);
414 thumb_->SetPosition(thumb_position); 413 thumb_->SetPosition(thumb_position);
415 } 414 }
416 415
417 int BaseScrollBar::GetPosition() const { 416 int BaseScrollBar::GetPosition() const {
418 return thumb_->GetPosition(); 417 return thumb_->GetPosition();
419 } 418 }
420 419
421 /////////////////////////////////////////////////////////////////////////////// 420 ///////////////////////////////////////////////////////////////////////////////
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 return (thumb_position * (contents_size_ - viewport_size_)) / 505 return (thumb_position * (contents_size_ - viewport_size_)) /
507 (track_size - thumb_size); 506 (track_size - thumb_size);
508 } 507 }
509 508
510 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { 509 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) {
511 thumb_track_state_ = state; 510 thumb_track_state_ = state;
512 SchedulePaint(); 511 SchedulePaint();
513 } 512 }
514 513
515 } // namespace views 514 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698