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_PINCH_ZOOM_SCROLLBARS_MANAGER_H_ | |
6 #define CC_PINCH_ZOOM_SCROLLBARS_MANAGER_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "cc/scoped_resource.h" | |
10 #include "cc/scrollbar_geometry_fixed_thumb.h" | |
11 #include "cc/scrollbar_layer_impl.h" | |
12 #include <public/WebRect.h> | |
13 #include <public/WebScrollbar.h> | |
14 | |
15 namespace cc { | |
16 | |
17 class PinchZoomScrollbarsManager { | |
18 public: | |
19 static scoped_ptr<PinchZoomScrollbarsManager> create(); | |
20 ~PinchZoomScrollbarsManager(); | |
21 | |
22 void updateThumbTextures(ResourceProvider* resourceProvider); | |
23 void setContentBounds(const gfx::Size&); | |
24 void setPinchZoomViewportPosition(const gfx::Vector2dF&, float scale); | |
25 void setPinchZoomViewportBounds(const gfx::Size&); | |
26 void setRootScrollLayerOffset(const gfx::Vector2d& offset, const gfx::Vector 2d& maxOffset); | |
27 | |
28 void setDeviceScaleFactor(float scale) { m_deviceScaleFactor = scale; } | |
29 | |
30 void setScrollbarVertical(ScrollbarLayerImpl* scrollbar); | |
31 void setScrollbarHorizontal(ScrollbarLayerImpl* scrollbar); | |
32 | |
33 ScrollbarLayerImpl* scrollbarVertical() const { return m_pinchZoomScrollbarV ertical; } | |
34 ScrollbarLayerImpl* scrollbarHorizontal() const { return m_pinchZoomScrollba rHorizontal; } | |
35 | |
36 void setEnabled(bool enabled) { m_enabled = enabled; } | |
37 | |
38 private: | |
39 PinchZoomScrollbarsManager(); | |
40 | |
41 class Scrollbar : public WebKit::WebScrollbar { | |
42 public: | |
43 Scrollbar(PinchZoomScrollbarsManager* owner, WebScrollbar::Orientation o rientation) | |
44 : m_owner(owner) | |
45 , m_orientation(orientation) | |
46 { } | |
47 | |
48 // WebScrollbar implementation | |
49 virtual bool isOverlay() const; | |
50 virtual int value() const; | |
51 virtual WebKit::WebPoint location() const; | |
52 virtual WebKit::WebSize size() const; | |
53 virtual bool enabled() const; | |
54 virtual int maximum() const; | |
55 virtual int totalSize() const; | |
56 virtual bool isScrollViewScrollbar() const; | |
57 virtual bool isScrollableAreaActive() const; | |
58 virtual void getTickmarks(WebKit::WebVector<WebKit::WebRect>& tickmarks) const; | |
59 virtual WebScrollbar::ScrollbarControlSize controlSize() const; | |
60 virtual WebScrollbar::ScrollbarPart pressedPart() const; | |
61 virtual WebScrollbar::ScrollbarPart hoveredPart() const; | |
62 virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() cons t; | |
63 virtual WebScrollbar::Orientation orientation() const; | |
64 virtual bool isCustomScrollbar() const; | |
65 | |
66 private: | |
67 PinchZoomScrollbarsManager* m_owner; | |
68 WebScrollbar::Orientation m_orientation; | |
69 }; | |
70 | |
71 class ScrollbarThemeGeometry : public WebKit::WebScrollbarThemeGeometry { | |
72 public: | |
73 explicit ScrollbarThemeGeometry(PinchZoomScrollbarsManager* owner) : m_o wner(owner) { } | |
74 | |
75 virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE; | |
76 virtual int thumbPosition(WebKit::WebScrollbar*) OVERRIDE; | |
77 virtual int thumbLength(WebKit::WebScrollbar*) OVERRIDE; | |
78 virtual int trackPosition(WebKit::WebScrollbar*) OVERRIDE; | |
79 virtual int trackLength(WebKit::WebScrollbar*) OVERRIDE; | |
80 virtual bool hasButtons(WebKit::WebScrollbar*) OVERRIDE; | |
81 virtual bool hasThumb(WebKit::WebScrollbar*) OVERRIDE; | |
82 virtual WebKit::WebRect trackRect(WebKit::WebScrollbar*) OVERRIDE; | |
83 virtual WebKit::WebRect thumbRect(WebKit::WebScrollbar*) OVERRIDE; | |
84 virtual int minimumThumbLength(WebKit::WebScrollbar*) OVERRIDE; | |
85 virtual int scrollbarThickness(WebKit::WebScrollbar*) OVERRIDE; | |
86 virtual WebKit::WebRect backButtonStartRect(WebKit::WebScrollbar*) OVERR IDE; | |
87 virtual WebKit::WebRect backButtonEndRect(WebKit::WebScrollbar*) OVERRID E; | |
88 virtual WebKit::WebRect forwardButtonStartRect(WebKit::WebScrollbar*) OV ERRIDE; | |
89 virtual WebKit::WebRect forwardButtonEndRect(WebKit::WebScrollbar*) OVER RIDE; | |
90 virtual WebKit::WebRect constrainTrackRectToTrackPieces(WebKit::WebScrol lbar*, const WebKit::WebRect&) OVERRIDE; | |
91 virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& tr ack, WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTr ack) OVERRIDE; | |
92 | |
93 private: | |
94 PinchZoomScrollbarsManager* m_owner; | |
95 }; | |
96 | |
97 // We need to override (at least) the splitTrack() function from ScrollbarGe ometryFixedThumb, | |
98 // so this interface exists to allow us to implement the required functions. | |
99 class PZScrollbarGeometry : public ScrollbarGeometryFixedThumb { | |
enne (OOO)
2012/12/13 17:43:38
Why are you using FixedThumb?
wjmaclean
2012/12/13 18:26:50
Primarily because ScrollbarLayerImpl requires this
enne (OOO)
2012/12/13 18:57:42
Ah, just curious. FixedThumb is there because Scr
| |
100 public: | |
101 static scoped_ptr<ScrollbarGeometryFixedThumb> create(scoped_ptr<WebKit: :WebScrollbarThemeGeometry>, PinchZoomScrollbarsManager* owner); | |
102 virtual ~PZScrollbarGeometry(); | |
103 | |
104 virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE; | |
105 virtual int thumbLength(WebKit::WebScrollbar*) OVERRIDE; | |
106 virtual int thumbPosition(WebKit::WebScrollbar*) OVERRIDE; | |
107 virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& tr ack, WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTr ack) OVERRIDE; | |
108 | |
109 private: | |
110 explicit PZScrollbarGeometry(scoped_ptr<WebKit::WebScrollbarThemeGeometr y>, PinchZoomScrollbarsManager* owner); | |
111 | |
112 PinchZoomScrollbarsManager* m_owner; | |
113 }; | |
114 | |
115 static const int kTrackWidth = 15; | |
116 WebKit::WebRect thumbRect(const WebKit::WebScrollbar*) const; | |
117 WebKit::WebRect trackRect(const WebKit::WebScrollbar*) const; | |
118 int thumbLength(const WebKit::WebScrollbar*) const ; | |
119 int trackLength(const WebKit::WebScrollbar*) const ; | |
120 // The following function allows us to include device scale factor in the | |
121 // track width at some later time, if we wish. | |
122 int trackWidth() const { return kTrackWidth; } | |
123 int position(const WebKit::WebScrollbar*) const; | |
124 int maximum(const WebKit::WebScrollbar*) const; | |
125 | |
126 void updateOneThumb(ScrollbarLayerImpl* scrollbarImpl, | |
127 Scrollbar& scrollbar, | |
128 scoped_ptr<ScopedResource>& thumbTexture, | |
129 scoped_ptr<SkCanvas>& thumbCanvas, | |
130 ResourceProvider* resourceProvider); | |
131 | |
132 void updateScrollbarImpl(ScrollbarLayerImpl*, WebKit::WebScrollbar*); | |
133 | |
134 Scrollbar m_scrollbarVertical; | |
135 Scrollbar m_scrollbarHorizontal; | |
136 | |
137 // The layer tree owns the scrollbar impl pointers. | |
138 ScrollbarLayerImpl* m_pinchZoomScrollbarVertical; | |
enne (OOO)
2012/12/13 17:43:38
This class is way too smart and the layers are way
wjmaclean
2012/12/13 18:26:50
OK, I'll create a derived class to do it.
| |
139 ScrollbarLayerImpl* m_pinchZoomScrollbarHorizontal; | |
140 | |
141 scoped_ptr<ScopedResource> m_verticalThumbTexture; | |
142 scoped_ptr<ScopedResource> m_horizontalThumbTexture; | |
143 | |
144 scoped_ptr<SkCanvas> m_verticalThumbCanvas; | |
145 scoped_ptr<SkCanvas> m_horizontalThumbCanvas; | |
146 | |
147 gfx::Vector2dF m_layoutViewportPosition; | |
148 gfx::Size m_layoutViewportSize; | |
149 gfx::Size m_layoutDocumentSize; | |
150 gfx::Vector2d m_rootScrollOffset; | |
151 gfx::Vector2d m_rootMaxScrollOffset; | |
152 float m_viewportScale; | |
153 float m_deviceScaleFactor; | |
154 | |
155 bool m_enabled; | |
156 }; | |
157 } | |
158 #endif // CC_PINCH_ZOOM_SCROLLBARS_MANAGER_H_ | |
OLD | NEW |