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

Side by Side Diff: ui/views/controls/scrollbar/base_scroll_bar.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/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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (old_state == CustomButton::STATE_PRESSED && 121 if (old_state == CustomButton::STATE_PRESSED &&
122 new_state == CustomButton::STATE_NORMAL && 122 new_state == CustomButton::STATE_NORMAL &&
123 GetThumbTrackState() == CustomButton::STATE_HOVERED) { 123 GetThumbTrackState() == CustomButton::STATE_HOVERED) {
124 SetThumbTrackState(CustomButton::STATE_NORMAL); 124 SetThumbTrackState(CustomButton::STATE_NORMAL);
125 } 125 }
126 } 126 }
127 127
128 /////////////////////////////////////////////////////////////////////////////// 128 ///////////////////////////////////////////////////////////////////////////////
129 // BaseScrollBar, View implementation: 129 // BaseScrollBar, View implementation:
130 130
131 void BaseScrollBar::Layout() {
tapted 2016/02/22 04:42:15 If we keep this here, the identical logic can be r
spqchan 2016/02/22 19:01:37 Done.
132 // Provide a default implementation that sets the thumb's bounds in the
133 // scrollbar.
134 gfx::Rect thumb_bounds = GetTrackBounds();
135 if (IsHorizontal()) {
136 thumb_bounds.set_x(thumb_->x());
137 thumb_bounds.set_width(thumb_->width());
138 } else {
139 thumb_bounds.set_y(thumb_->y());
140 thumb_bounds.set_height(thumb_->height());
141 }
142 thumb_->SetBoundsRect(thumb_bounds);
143 }
144
131 bool BaseScrollBar::OnMousePressed(const ui::MouseEvent& event) { 145 bool BaseScrollBar::OnMousePressed(const ui::MouseEvent& event) {
132 if (event.IsOnlyLeftMouseButton()) 146 if (event.IsOnlyLeftMouseButton())
133 ProcessPressEvent(event); 147 ProcessPressEvent(event);
134 return true; 148 return true;
135 } 149 }
136 150
137 void BaseScrollBar::OnMouseReleased(const ui::MouseEvent& event) { 151 void BaseScrollBar::OnMouseReleased(const ui::MouseEvent& event) {
138 SetState(HitTestPoint(event.location()) ? 152 SetState(HitTestPoint(event.location()) ?
139 CustomButton::STATE_HOVERED : CustomButton::STATE_NORMAL); 153 CustomButton::STATE_HOVERED : CustomButton::STATE_NORMAL);
140 } 154 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 thumb_position = thumb_position - (thumb_->GetSize() / 2); 522 thumb_position = thumb_position - (thumb_->GetSize() / 2);
509 return (thumb_position * contents_size_) / GetTrackSize(); 523 return (thumb_position * contents_size_) / GetTrackSize();
510 } 524 }
511 525
512 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { 526 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) {
513 thumb_track_state_ = state; 527 thumb_track_state_ = state;
514 SchedulePaint(); 528 SchedulePaint();
515 } 529 }
516 530
517 } // namespace views 531 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698