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

Side by Side Diff: cc/layers/scrollbar_layer_impl_base.cc

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: weiliangc comment addressed Created 3 years, 7 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
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.h ('k') | cc/trees/layer_tree_host_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/layers/scrollbar_layer_impl_base.h" 5 #include "cc/layers/scrollbar_layer_impl_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "cc/trees/effect_node.h" 8 #include "cc/trees/effect_node.h"
9 #include "cc/trees/layer_tree_impl.h" 9 #include "cc/trees/layer_tree_impl.h"
10 #include "ui/gfx/geometry/rect_conversions.h" 10 #include "ui/gfx/geometry/rect_conversions.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 bool ScrollbarLayerImplBase::SetThumbThicknessScaleFactor(float factor) { 102 bool ScrollbarLayerImplBase::SetThumbThicknessScaleFactor(float factor) {
103 if (thumb_thickness_scale_factor_ == factor) 103 if (thumb_thickness_scale_factor_ == factor)
104 return false; 104 return false;
105 thumb_thickness_scale_factor_ = factor; 105 thumb_thickness_scale_factor_ = factor;
106 NoteLayerPropertyChanged(); 106 NoteLayerPropertyChanged();
107 return true; 107 return true;
108 } 108 }
109 109
110 gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const { 110 gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRectWithThumbThicknessScale(
111 float thumb_thickness_scale_factor) const {
111 // Thumb extent is the length of the thumb in the scrolling direction, thumb 112 // Thumb extent is the length of the thumb in the scrolling direction, thumb
112 // thickness is in the perpendicular direction. Here's an example of a 113 // thickness is in the perpendicular direction. Here's an example of a
113 // horizontal scrollbar - inputs are above the scrollbar, computed values 114 // horizontal scrollbar - inputs are above the scrollbar, computed values
114 // below: 115 // below:
115 // 116 //
116 // |<------------------- track_length_ ------------------->| 117 // |<------------------- track_length_ ------------------->|
117 // 118 //
118 // |--| <-- start_offset 119 // |--| <-- start_offset
119 // 120 //
120 // +--+----------------------------+------------------+-------+--+ 121 // +--+----------------------------+------------------+-------+--+
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 float clamped_current_pos = std::min(std::max(current_pos_, 0.f), maximum); 179 float clamped_current_pos = std::min(std::max(current_pos_, 0.f), maximum);
179 180
180 int thumb_offset = TrackStart(); 181 int thumb_offset = TrackStart();
181 if (maximum > 0) { 182 if (maximum > 0) {
182 float ratio = clamped_current_pos / maximum; 183 float ratio = clamped_current_pos / maximum;
183 float max_offset = track_length - thumb_length; 184 float max_offset = track_length - thumb_length;
184 thumb_offset += static_cast<int>(ratio * max_offset); 185 thumb_offset += static_cast<int>(ratio * max_offset);
185 } 186 }
186 187
187 float thumb_thickness_adjustment = 188 float thumb_thickness_adjustment =
188 thumb_thickness * (1.f - thumb_thickness_scale_factor_); 189 thumb_thickness * (1.f - thumb_thickness_scale_factor);
189 190
190 gfx::RectF thumb_rect; 191 gfx::RectF thumb_rect;
191 if (orientation_ == HORIZONTAL) { 192 if (orientation_ == HORIZONTAL) {
192 thumb_rect = gfx::RectF(thumb_offset, 193 thumb_rect = gfx::RectF(thumb_offset,
193 vertical_adjust_ + thumb_thickness_adjustment, 194 vertical_adjust_ + thumb_thickness_adjustment,
194 thumb_length, 195 thumb_length,
195 thumb_thickness - thumb_thickness_adjustment); 196 thumb_thickness - thumb_thickness_adjustment);
196 } else { 197 } else {
197 thumb_rect = gfx::RectF( 198 thumb_rect = gfx::RectF(
198 is_left_side_vertical_scrollbar_ 199 is_left_side_vertical_scrollbar_
199 ? bounds().width() - thumb_thickness 200 ? bounds().width() - thumb_thickness
200 : thumb_thickness_adjustment, 201 : thumb_thickness_adjustment,
201 thumb_offset, 202 thumb_offset,
202 thumb_thickness - thumb_thickness_adjustment, 203 thumb_thickness - thumb_thickness_adjustment,
203 thumb_length); 204 thumb_length);
204 } 205 }
205 206
206 return gfx::ToEnclosingRect(thumb_rect); 207 return gfx::ToEnclosingRect(thumb_rect);
207 } 208 }
208 209
210 gfx::Rect ScrollbarLayerImplBase::ComputeExpandedThumbQuadRect() const {
211 DCHECK(is_overlay_scrollbar());
212 return ComputeThumbQuadRectWithThumbThicknessScale(1.f);
213 }
214
215 gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const {
216 return ComputeThumbQuadRectWithThumbThicknessScale(
217 thumb_thickness_scale_factor_);
218 }
219
209 void ScrollbarLayerImplBase::SetOverlayScrollbarLayerOpacityAnimated( 220 void ScrollbarLayerImplBase::SetOverlayScrollbarLayerOpacityAnimated(
210 float opacity) { 221 float opacity) {
211 DCHECK(is_overlay_scrollbar()); 222 DCHECK(is_overlay_scrollbar());
212 if (!layer_tree_impl()) 223 if (!layer_tree_impl())
213 return; 224 return;
214 225
215 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 226 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
216 int effect_node_index = 227 int effect_node_index =
217 property_trees->effect_tree.FindNodeIndexFromOwningLayerId(id()); 228 property_trees->effect_tree.FindNodeIndexFromOwningLayerId(id());
218 // If this method is called during LayerImpl::PushPropertiesTo, we may not yet 229 // If this method is called during LayerImpl::PushPropertiesTo, we may not yet
(...skipping 12 matching lines...) Expand all
231 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); 242 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity);
232 243
233 node->opacity = opacity; 244 node->opacity = opacity;
234 node->effect_changed = true; 245 node->effect_changed = true;
235 property_trees->changed = true; 246 property_trees->changed = true;
236 property_trees->effect_tree.set_needs_update(true); 247 property_trees->effect_tree.set_needs_update(true);
237 layer_tree_impl()->set_needs_update_draw_properties(); 248 layer_tree_impl()->set_needs_update_draw_properties();
238 } 249 }
239 250
240 } // namespace cc 251 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698