-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTSStackView.h
163 lines (101 loc) · 3.48 KB
/
TSStackView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//
// TSStackView.h
// BrightPay
//
// Created by Jonathan Mitchell on 04/12/2013.
// Copyright (c) 2013 Thesaurus Software Limited. All rights reserved.
//
#import <Cocoa/Cocoa.h>
typedef NS_OPTIONS(NSUInteger, TSIntrinsicContentSize) {
TSIntrinsicContentSizeNone = 0 << 0,
TSIntrinsicContentSizeWidth = 1 << 0,
TSIntrinsicContentSizeHeight = 1 << 1,
};
typedef NS_OPTIONS(NSUInteger, TSAutoContentSize) {
TSAutoContentSizeNone = 0 << 0,
TSAutoContentSizeWidth = 1 << 0,
TSAutoContentSizeHeight = 1 << 1,
};
@interface TSStackView : NSStackView
/**
A block that will be called when all receiver instances are first instantiated.
*/
@property (class, strong) void (^awakeBlock)(TSStackView *);
/**
A block that will be called when all scroll view containers are first instantiated.
*/
@property (class, strong) void (^scrollViewContainerAwakeBlock)(NSScrollView *);
/*!
Set options to determine whether view automatically resizes to show all content.
*/
@property (assign, nonatomic) TSAutoContentSize autoContentSizeOptions;
/*
TSStackView works by observing NSView -hidden and swapping out hidden views.
NSStackView calls -fittingSize to determine the minimum size of its subviews.
If a view's width or height is not constrained to a value (say the right or bottom
spacing to the superview is missing) then the fitting size will be 0 in that dimension
and the view will not be displayed.
Given the above, other approaches to obtaining the same behaviour could therefore include:
1. Add and remove internal constraints to cause the fittingSize for views to collapse.
2. Add and remove additional external zero dimension constraints to override the internal constraints.
*/
/*!
Create receiver with initial views in gravity.
*/
+ (id)stackViewWithViews:(NSArray *)views inGravity:(NSStackViewGravity)gravity;
/*!
Suspend auto layout triggered by change in subview visibility.
Auto layout may be suspended to improve performance when modiftying the visibility of a number of subviews.
Must be matched with a call to -resumeAutoLayoutWhenSubviewVisibilityChanges
*/
- (void)suspendAutoLayoutWhenSubviewVisibilityChanges;
/*!
Resume auto layout triggered by change in subview visibility.
*/
- (void)resumeAutoLayoutWhenSubviewVisibilityChanges;
/*!
Hide all views in gravity
*/
- (void)hideViewsInGravity:(NSStackViewGravity)gravity;
/*!
Show all views in gravity
*/
- (void)showViewsInGravity:(NSStackViewGravity)gravity;
/*!
add views
*/
- (void)addViews:(NSArray *)views inGravity:(NSStackViewGravity)gravity;
/*!
Show views
*/
- (void)showViews:(NSArray *)views;
/*!
Hide views
*/
- (void)hideViews:(NSArray *)views;
/*!
Scroll view container with constraints to match the stackview width to the scrollview width.
*/
- (NSScrollView *)scrollViewContainer;
/*!
Set options to determine whether view reports an intrinsic content size.
*/
@property (assign, nonatomic) TSIntrinsicContentSize intrinsicContentSizeOptions;
/*!
Background fill color.
*/
@property (strong, nonatomic) NSColor *backgroundColor;
/*!
Remove all views.
*/
- (void)removeAllViews;
- (NSArray<NSView *> *)allViews;
/*!
Block to be called when a given bound view becomes visible.
*/
@property (copy) void(^onBoundViewVisible)(TSStackView *stackView, NSView * view);
/*!
Block to be called when a given bound view becomes hidden.
*/
@property (copy) void(^onBoundViewHidden)(TSStackView *stackView, NSView * view);
@end