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_impl.h"
16 class CC_EXPORT ScrollbarLayerImplBase
: public LayerImpl
{
18 int ScrollLayerId() const { return scroll_layer_id_
; }
19 void set_scroll_layer_id(int id
) { scroll_layer_id_
= id
; }
21 float current_pos() const { return current_pos_
; }
22 void SetCurrentPos(float current_pos
);
23 int maximum() const { return maximum_
; }
24 void SetMaximum(int maximum
);
26 void SetVerticalAdjust(float vertical_adjust
);
28 bool is_overlay_scrollbar() const { return is_overlay_scrollbar_
; }
29 void set_is_overlay_scrollbar(bool is_overlay
) {
30 is_overlay_scrollbar_
= is_overlay
;
33 ScrollbarOrientation
orientation() const { return orientation_
; }
34 bool is_left_side_vertical_scrollbar() {
35 return is_left_side_vertical_scrollbar_
;
38 virtual void PushPropertiesTo(LayerImpl
* layer
) OVERRIDE
;
39 virtual ScrollbarLayerImplBase
* ToScrollbarLayer() OVERRIDE
;
41 void SetVisibleToTotalLengthRatio(float ratio
);
42 virtual gfx::Rect
ComputeThumbQuadRect() const;
44 float thumb_thickness_scale_factor() {
45 return thumb_thickness_scale_factor_
;
47 void SetThumbThicknessScaleFactor(float thumb_thickness_scale_factor
);
50 ScrollbarLayerImplBase(LayerTreeImpl
* tree_impl
,
52 ScrollbarOrientation orientation
,
53 bool is_left_side_vertical_scrollbar
);
54 virtual ~ScrollbarLayerImplBase() {}
56 gfx::Rect
ScrollbarLayerRectToContentRect(const gfx::RectF
& layer_rect
) const;
58 float visible_to_total_length_ratio() const {
59 return visible_to_total_length_ratio_
;
61 float vertical_adjust() const { return vertical_adjust_
; }
63 virtual int ThumbThickness() const = 0;
64 virtual int ThumbLength() const = 0;
65 virtual float TrackLength() const = 0;
66 virtual int TrackStart() const = 0;
67 // Indicates whether the thumb length can be changed without going back to the
69 virtual bool IsThumbResizable() const = 0;
73 bool is_overlay_scrollbar_
;
75 float thumb_thickness_scale_factor_
;
78 ScrollbarOrientation orientation_
;
79 bool is_left_side_vertical_scrollbar_
;
81 // Difference between the clip layer's height and the visible viewport
82 // height (which may differ in the presence of top-controls hiding).
83 float vertical_adjust_
;
85 float visible_to_total_length_ratio_
;
87 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayerImplBase
);
92 #endif // CC_LAYERS_SCROLLBAR_LAYER_IMPL_BASE_H_