OLD | NEW |
| (Empty) |
1 // Copyright 2012 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. | |
4 | |
5 #ifndef CC_SCROLLBAR_LAYER_IMPL_H_ | |
6 #define CC_SCROLLBAR_LAYER_IMPL_H_ | |
7 | |
8 #include "cc/base/cc_export.h" | |
9 #include "cc/scrollbar_geometry_fixed_thumb.h" | |
10 #include "cc/scrollbar_layer_impl_base.h" | |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | |
13 | |
14 namespace cc { | |
15 | |
16 class ScrollView; | |
17 | |
18 class CC_EXPORT ScrollbarLayerImpl : public ScrollbarLayerImplBase { | |
19 public: | |
20 static scoped_ptr<ScrollbarLayerImpl> Create( | |
21 LayerTreeImpl* tree_impl, | |
22 int id, | |
23 scoped_ptr<ScrollbarGeometryFixedThumb> geometry); | |
24 virtual ~ScrollbarLayerImpl(); | |
25 | |
26 virtual ScrollbarLayerImpl* ToScrollbarLayer() OVERRIDE; | |
27 int scroll_layer_id() const { return scroll_layer_id_; } | |
28 void set_scroll_layer_id(int id) { scroll_layer_id_ = id; } | |
29 | |
30 void SetScrollbarData(WebKit::WebScrollbar* scrollbar); | |
31 void SetThumbSize(gfx::Size size); | |
32 | |
33 void set_vertical_adjust(float vertical_adjust) { | |
34 vertical_adjust_ = vertical_adjust; | |
35 } | |
36 void SetViewportWithinScrollableArea(gfx::RectF scrollable_viewport, | |
37 gfx::SizeF scrollable_area); | |
38 | |
39 void set_back_track_resource_id(ResourceProvider::ResourceId id) { | |
40 back_track_resource_id_ = id; | |
41 } | |
42 void set_fore_track_resource_id(ResourceProvider::ResourceId id) { | |
43 fore_track_resource_id_ = id; | |
44 } | |
45 void set_thumb_resource_id(ResourceProvider::ResourceId id) { | |
46 thumb_resource_id_ = id; | |
47 } | |
48 bool HasThumbTexture() { return thumb_resource_id_; } | |
49 | |
50 | |
51 // ScrollbarLayerImplBase implementation. | |
52 virtual float CurrentPos() const OVERRIDE; | |
53 virtual int TotalSize() const OVERRIDE; | |
54 virtual int Maximum() const OVERRIDE; | |
55 | |
56 void SetCurrentPos(float current_pos) { current_pos_ = current_pos; } | |
57 void SetTotalSize(int total_size) { total_size_ = total_size; } | |
58 void SetMaximum(int maximum) { maximum_ = maximum; } | |
59 | |
60 virtual WebKit::WebScrollbar::Orientation Orientation() const OVERRIDE; | |
61 | |
62 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | |
63 OVERRIDE; | |
64 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | |
65 | |
66 virtual void AppendQuads(QuadSink* quad_sink, | |
67 AppendQuadsData* append_quads_data) OVERRIDE; | |
68 | |
69 virtual void DidLoseOutputSurface() OVERRIDE; | |
70 | |
71 protected: | |
72 ScrollbarLayerImpl(LayerTreeImpl* tree_impl, | |
73 int id, | |
74 scoped_ptr<ScrollbarGeometryFixedThumb> geometry); | |
75 | |
76 private: | |
77 // nested class only to avoid namespace problem | |
78 class Scrollbar : public WebKit::WebScrollbar { | |
79 public: | |
80 explicit Scrollbar(ScrollbarLayerImpl* owner) : owner_(owner) {} | |
81 | |
82 // WebScrollbar implementation | |
83 virtual bool isOverlay() const; | |
84 virtual int value() const; | |
85 virtual WebKit::WebPoint location() const; | |
86 virtual WebKit::WebSize size() const; | |
87 virtual bool enabled() const; | |
88 virtual int maximum() const; | |
89 virtual int totalSize() const; | |
90 virtual bool isScrollViewScrollbar() const; | |
91 virtual bool isScrollableAreaActive() const; | |
92 virtual void getTickmarks(WebKit::WebVector<WebKit::WebRect>& tickmarks) | |
93 const; | |
94 virtual WebScrollbar::ScrollbarControlSize controlSize() const; | |
95 virtual WebScrollbar::ScrollbarPart pressedPart() const; | |
96 virtual WebScrollbar::ScrollbarPart hoveredPart() const; | |
97 virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const; | |
98 virtual WebScrollbar::Orientation orientation() const; | |
99 virtual bool isCustomScrollbar() const; | |
100 | |
101 private: | |
102 ScrollbarLayerImpl* owner_; | |
103 | |
104 }; | |
105 | |
106 virtual const char* LayerTypeAsString() const OVERRIDE; | |
107 | |
108 gfx::Rect ScrollbarLayerRectToContentRect(gfx::RectF layer_rect) const; | |
109 | |
110 Scrollbar scrollbar_; | |
111 | |
112 ResourceProvider::ResourceId back_track_resource_id_; | |
113 ResourceProvider::ResourceId fore_track_resource_id_; | |
114 ResourceProvider::ResourceId thumb_resource_id_; | |
115 | |
116 scoped_ptr<ScrollbarGeometryFixedThumb> geometry_; | |
117 | |
118 float current_pos_; | |
119 int total_size_; | |
120 int maximum_; | |
121 gfx::Size thumb_size_; | |
122 | |
123 // Difference between the clip layer's height and the visible viewport | |
124 // height (which may differ in the presence of top-controls hiding). | |
125 float vertical_adjust_; | |
126 | |
127 // Specifies the position and size of the viewport within the scrollable | |
128 // area (normalized as if the scrollable area is a unit-sized box | |
129 // [0, 0, 1, 1]). | |
130 gfx::RectF normalized_viewport_; | |
131 | |
132 int scroll_layer_id_; | |
133 | |
134 // Data to implement Scrollbar | |
135 WebKit::WebScrollbar::ScrollbarOverlayStyle scrollbar_overlay_style_; | |
136 WebKit::WebVector<WebKit::WebRect> tickmarks_; | |
137 WebKit::WebScrollbar::Orientation orientation_; | |
138 WebKit::WebScrollbar::ScrollbarControlSize control_size_; | |
139 WebKit::WebScrollbar::ScrollbarPart pressed_part_; | |
140 WebKit::WebScrollbar::ScrollbarPart hovered_part_; | |
141 | |
142 bool is_scrollable_area_active_; | |
143 bool is_scroll_view_scrollbar_; | |
144 bool enabled_; | |
145 bool is_custom_scrollbar_; | |
146 bool is_overlay_scrollbar_; | |
147 }; | |
148 | |
149 } | |
150 #endif // CC_SCROLLBAR_LAYER_IMPL_H_ | |
OLD | NEW |