| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef SKY_ENGINE_PLATFORM_SCROLL_SCROLLBAR_H_ | |
| 27 #define SKY_ENGINE_PLATFORM_SCROLL_SCROLLBAR_H_ | |
| 28 | |
| 29 #include "sky/engine/platform/Timer.h" | |
| 30 #include "sky/engine/platform/Widget.h" | |
| 31 #include "sky/engine/platform/scroll/ScrollTypes.h" | |
| 32 #include "sky/engine/platform/scroll/Scrollbar.h" | |
| 33 #include "sky/engine/wtf/MathExtras.h" | |
| 34 #include "sky/engine/wtf/PassRefPtr.h" | |
| 35 | |
| 36 namespace blink { | |
| 37 | |
| 38 class GraphicsContext; | |
| 39 class IntRect; | |
| 40 class ScrollableArea; | |
| 41 | |
| 42 class PLATFORM_EXPORT Scrollbar final : public Widget { | |
| 43 public: | |
| 44 static PassRefPtr<Scrollbar> create(ScrollableArea*, ScrollbarOrientation); | |
| 45 | |
| 46 virtual ~Scrollbar(); | |
| 47 | |
| 48 bool isScrollableAreaActive() const; | |
| 49 | |
| 50 ScrollbarOrientation orientation() const { return m_orientation; } | |
| 51 bool isLeftSideVerticalScrollbar() const; | |
| 52 | |
| 53 int value() const { return lroundf(m_currentPos); } | |
| 54 float currentPos() const { return m_currentPos; } | |
| 55 int visibleSize() const { return m_visibleSize; } | |
| 56 int totalSize() const { return m_totalSize; } | |
| 57 int maximum() const { return m_totalSize - m_visibleSize; } | |
| 58 | |
| 59 // Called by the ScrollableArea when the scroll offset changes. | |
| 60 void offsetDidChange(); | |
| 61 | |
| 62 void disconnectFromScrollableArea() { m_scrollableArea = 0; } | |
| 63 ScrollableArea* scrollableArea() const { return m_scrollableArea; } | |
| 64 | |
| 65 int pressedPos() const { return m_pressedPos; } | |
| 66 | |
| 67 void setHoveredPart(ScrollbarPart); | |
| 68 void setPressedPart(ScrollbarPart); | |
| 69 | |
| 70 void setProportion(int visibleSize, int totalSize); | |
| 71 void setPressedPos(int p) { m_pressedPos = p; } | |
| 72 | |
| 73 virtual void paint(GraphicsContext*, const IntRect& damageRect) override; | |
| 74 | |
| 75 bool isOverlayScrollbar() const; | |
| 76 bool shouldParticipateInHitTesting(); | |
| 77 | |
| 78 virtual IntRect convertToContainingView(const IntRect&) const override; | |
| 79 virtual IntRect convertFromContainingView(const IntRect&) const override; | |
| 80 | |
| 81 virtual IntPoint convertToContainingView(const IntPoint&) const override; | |
| 82 virtual IntPoint convertFromContainingView(const IntPoint&) const override; | |
| 83 | |
| 84 void moveThumb(int pos); | |
| 85 | |
| 86 static int scrollbarThickness(); | |
| 87 | |
| 88 // The position of the thumb relative to the track. | |
| 89 int thumbPosition(); | |
| 90 // The length of the thumb along the axis of the scrollbar. | |
| 91 int thumbLength(); | |
| 92 // The position of the track relative to the scrollbar. | |
| 93 int trackPosition(); | |
| 94 // The length of the track along the axis of the scrollbar. | |
| 95 int trackLength(); | |
| 96 | |
| 97 IntRect trackRect(); | |
| 98 IntRect thumbRect(); | |
| 99 int thumbThickness(); | |
| 100 | |
| 101 int minimumThumbLength(); | |
| 102 | |
| 103 void splitTrack(const IntRect& track, IntRect& startTrack, IntRect& thumb, I
ntRect& endTrack); | |
| 104 | |
| 105 void paintThumb(GraphicsContext*, const IntRect&); | |
| 106 | |
| 107 double initialAutoscrollTimerDelay() { return 0.25; } | |
| 108 double autoscrollTimerDelay() { return 0.05; } | |
| 109 | |
| 110 protected: | |
| 111 Scrollbar(ScrollableArea*, ScrollbarOrientation); | |
| 112 | |
| 113 void autoscrollTimerFired(Timer<Scrollbar>*); | |
| 114 void startTimerIfNeeded(double delay); | |
| 115 void stopTimerIfNeeded(); | |
| 116 void autoscrollPressedPart(double delay); | |
| 117 ScrollDirection pressedPartScrollDirection(); | |
| 118 ScrollGranularity pressedPartScrollGranularity(); | |
| 119 | |
| 120 ScrollableArea* m_scrollableArea; | |
| 121 ScrollbarOrientation m_orientation; | |
| 122 | |
| 123 int m_visibleSize; | |
| 124 int m_totalSize; | |
| 125 float m_currentPos; | |
| 126 float m_dragOrigin; | |
| 127 | |
| 128 // FIXME(sky): Does any of this hovered/pressed tracking do anything | |
| 129 // since we only have overlay scrollbars? | |
| 130 ScrollbarPart m_hoveredPart; | |
| 131 ScrollbarPart m_pressedPart; | |
| 132 int m_pressedPos; | |
| 133 float m_scrollPos; | |
| 134 int m_documentDragPos; | |
| 135 | |
| 136 Timer<Scrollbar> m_scrollTimer; | |
| 137 bool m_overlapsResizer; | |
| 138 | |
| 139 private: | |
| 140 virtual bool isScrollbar() const override { return true; } | |
| 141 | |
| 142 float scrollableAreaCurrentPos() const; | |
| 143 }; | |
| 144 | |
| 145 DEFINE_TYPE_CASTS(Scrollbar, Widget, widget, widget->isScrollbar(), widget.isScr
ollbar()); | |
| 146 | |
| 147 } // namespace blink | |
| 148 | |
| 149 #endif // SKY_ENGINE_PLATFORM_SCROLL_SCROLLBAR_H_ | |
| OLD | NEW |