[OS X] Main frame scrollbars should appear on the left on RTL systems
[WebKit-https.git] / Source / WebCore / platform / spi / mac / NSScrollerImpSPI.h
1 /*
2  * Copyright (C) 2016 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef NSScrollerImpSPI_h
27 #define NSScrollerImpSPI_h
28
29 #if USE(APPKIT)
30
31 #if USE(APPLE_INTERNAL_SDK)
32
33 #import <AppKit/NSScrollerImpPair_Private.h>
34 #import <AppKit/NSScrollerImp_Private.h>
35
36 @interface NSScrollerImp ()
37 @property(getter=isTracking) BOOL tracking;
38 @end
39
40 #else
41
42 enum {
43     NSOverlayScrollerStateHidden = 0,
44     NSOverlayScrollerStateThumbShown = 1,
45     NSOverlayScrollerStateAllShown = 2,
46     NSOverlayScrollerStatePulseThumb = 3,
47 };
48 typedef NSUInteger NSOverlayScrollerState;
49
50 @protocol NSScrollerImpDelegate;
51
52 @interface NSScrollerImp : NSObject
53 + (NSScrollerImp *)scrollerImpWithStyle:(NSScrollerStyle)newScrollerStyle controlSize:(NSControlSize)newControlSize horizontal:(BOOL)horizontal replacingScrollerImp:(id)previous;
54 @property(retain) CALayer *layer;
55 - (void)setNeedsDisplay:(BOOL)flag;
56 @property NSScrollerKnobStyle knobStyle;
57 @property(getter=isHorizontal) BOOL horizontal;
58 @property NSSize boundsSize;
59 @property(getter=isEnabled) BOOL enabled;
60 @property double doubleValue;
61 @property double presentationValue;
62 @property(getter=shouldUsePresentationValue) BOOL usePresentationValue;
63 @property CGFloat knobProportion;
64 @property CGFloat uiStateTransitionProgress;
65 @property CGFloat expansionTransitionProgress;
66 @property CGFloat trackAlpha;
67 @property CGFloat knobAlpha;
68 @property(getter=isExpanded) BOOL expanded;
69 @property(assign) id<NSScrollerImpDelegate> delegate;
70 @property(readonly) CGFloat trackBoxWidth;
71 @property(readonly) CGFloat trackWidth;
72 @property(readonly) CGFloat trackSideInset;
73 @property(readonly) CGFloat trackEndInset;
74 @property(readonly) CGFloat knobEndInset;
75 @property(readonly) CGFloat knobMinLength;
76 @property(readonly) CGFloat knobOverlapEndInset;
77 @property(readonly) CGFloat trackOverlapEndInset;
78 - (NSRect)rectForPart:(NSScrollerPart)partCode;
79 - (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag alpha:(CGFloat)alpha;
80 - (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag;
81 - (void)drawKnob;
82 - (void)mouseEnteredScroller;
83 - (void)mouseExitedScroller;
84 @end
85
86 @interface NSScrollerImp ()
87 @property(getter=isTracking) BOOL tracking;
88 @end
89
90 @protocol NSScrollerImpDelegate
91 @required
92 - (NSRect)convertRectToBacking:(NSRect)aRect;
93 - (NSRect)convertRectFromBacking:(NSRect)aRect;
94 - (CALayer *)layer;
95 - (void)scrollerImp:(NSScrollerImp *)scrollerImp animateKnobAlphaTo:(CGFloat)newKnobAlpha duration:(NSTimeInterval)duration;
96 - (void)scrollerImp:(NSScrollerImp *)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration;
97 - (void)scrollerImp:(NSScrollerImp *)scrollerImp overlayScrollerStateChangedTo:(NSOverlayScrollerState)newOverlayScrollerState;
98 @optional
99 - (void)scrollerImp:(NSScrollerImp *)scrollerImp animateUIStateTransitionWithDuration:(NSTimeInterval)duration;
100 - (void)scrollerImp:(NSScrollerImp *)scrollerImp animateExpansionTransitionWithDuration:(NSTimeInterval)duration;
101 - (NSPoint)mouseLocationInScrollerForScrollerImp:(NSScrollerImp *)scrollerImp;
102 - (NSRect)convertRectToLayer:(NSRect)aRect;
103 - (BOOL)shouldUseLayerPerPartForScrollerImp:(NSScrollerImp *)scrollerImp;
104 @end
105
106 @protocol NSScrollerImpPairDelegate;
107
108 @interface NSScrollerImpPair : NSObject
109 @property(assign) id<NSScrollerImpPairDelegate> delegate;
110 @property(retain) NSScrollerImp *verticalScrollerImp;
111 @property(retain) NSScrollerImp *horizontalScrollerImp;
112 @property NSScrollerStyle scrollerStyle;
113 + (NSUserInterfaceLayoutDirection)scrollerLayoutDirection;
114 - (void)flashScrollers;
115 - (void)hideOverlayScrollers;
116 - (void)lockOverlayScrollerState:(NSOverlayScrollerState)state;
117 - (void)unlockOverlayScrollerState;
118 - (BOOL)overlayScrollerStateIsLocked;
119 - (void)contentAreaScrolled;
120 - (void)contentAreaScrolledInDirection:(NSPoint)direction;
121 - (void)contentAreaWillDraw;
122 - (void)windowOrderedOut;
123 - (void)windowOrderedIn;
124 - (void)mouseEnteredContentArea;
125 - (void)mouseExitedContentArea;
126 - (void)mouseMovedInContentArea;
127 - (void)startLiveResize;
128 - (void)contentAreaDidResize;
129 - (void)endLiveResize;
130 - (void)beginScrollGesture;
131 - (void)endScrollGesture;
132 @end
133
134 @protocol NSScrollerImpPairDelegate
135 @required
136 - (NSRect)contentAreaRectForScrollerImpPair:(NSScrollerImpPair *)scrollerImpPair;
137 - (BOOL)inLiveResizeForScrollerImpPair:(NSScrollerImpPair *)scrollerImpPair;
138 - (NSPoint)mouseLocationInContentAreaForScrollerImpPair:(NSScrollerImpPair *)scrollerImpPair;
139 - (NSPoint)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair convertContentPoint:(NSPoint)pointInContentArea toScrollerImp:(NSScrollerImp *)scrollerImp;
140 - (void)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair setContentAreaNeedsDisplayInRect:(NSRect)rect;
141 - (void)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair updateScrollerStyleForNewRecommendedScrollerStyle:(NSScrollerStyle)newRecommendedScrollerStyle;
142 @optional
143 - (BOOL)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair isContentPointVisible:(NSPoint)pointInContentArea;
144 @end
145
146 #endif
147
148 #endif // USE(APPKIT)
149
150 #endif // NSScrollerImpSPI_h