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
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_
6 #define CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/input/scrollbar.h"
10 #include "cc/layers/layer.h"
11 #include "cc/layers/layer_impl.h"
17 class CC_EXPORT ScrollbarLayerImplBase
: public LayerImpl
{
19 int ScrollLayerId() const {
20 return scroll_layer_
? scroll_layer_
->id() : Layer::INVALID_ID
;
22 int ClipLayerId() const {
23 return clip_layer_
? clip_layer_
->id() : Layer::INVALID_ID
;
26 void SetScrollLayerAndClipLayerByIds(int scroll_layer_id
, int clip_layer_id
);
27 void ClearScrollLayer() { scroll_layer_
= NULL
; }
28 void ClearClipLayer() { clip_layer_
= NULL
; }
30 float current_pos() const { return current_pos_
; }
31 void SetCurrentPos(float current_pos
);
32 int maximum() const { return maximum_
; }
33 void SetMaximum(int maximum
);
35 void SetVerticalAdjust(float vertical_adjust
);
37 bool is_overlay_scrollbar() const { return is_overlay_scrollbar_
; }
38 void set_is_overlay_scrollbar(bool is_overlay
) {
39 is_overlay_scrollbar_
= is_overlay
;
42 ScrollbarOrientation
orientation() const { return orientation_
; }
43 bool is_left_side_vertical_scrollbar() {
44 return is_left_side_vertical_scrollbar_
;
47 virtual void PushPropertiesTo(LayerImpl
* layer
) OVERRIDE
;
48 virtual ScrollbarLayerImplBase
* ToScrollbarLayer() OVERRIDE
;
49 void PushScrollClipPropertiesTo(LayerImpl
* layer
);
51 void SetVisibleToTotalLengthRatio(float ratio
);
52 virtual gfx::Rect
ComputeThumbQuadRect() const;
54 float thumb_thickness_scale_factor() {
55 return thumb_thickness_scale_factor_
;
57 void SetThumbThicknessScaleFactor(float thumb_thickness_scale_factor
);
59 void ScrollbarParametersDidChange();
62 ScrollbarLayerImplBase(LayerTreeImpl
* tree_impl
,
64 ScrollbarOrientation orientation
,
65 bool is_left_side_vertical_scrollbar
,
67 virtual ~ScrollbarLayerImplBase();
69 gfx::Rect
ScrollbarLayerRectToContentRect(const gfx::RectF
& layer_rect
) const;
71 float visible_to_total_length_ratio() const {
72 return visible_to_total_length_ratio_
;
74 float vertical_adjust() const { return vertical_adjust_
; }
76 virtual int ThumbThickness() const = 0;
77 virtual int ThumbLength() const = 0;
78 virtual float TrackLength() const = 0;
79 virtual int TrackStart() const = 0;
80 // Indicates whether the thumb length can be changed without going back to the
82 virtual bool IsThumbResizable() const = 0;
85 LayerImpl
* scroll_layer_
;
86 LayerImpl
* clip_layer_
;
87 bool is_overlay_scrollbar_
;
89 float thumb_thickness_scale_factor_
;
92 ScrollbarOrientation orientation_
;
93 bool is_left_side_vertical_scrollbar_
;
95 // Difference between the clip layer's height and the visible viewport
96 // height (which may differ in the presence of top-controls hiding).
97 float vertical_adjust_
;
99 float visible_to_total_length_ratio_
;
101 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayerImplBase
);
106 #endif // CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_