forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelayer.livecodescript
More file actions
278 lines (214 loc) · 7.78 KB
/
Copy pathrelayer.livecodescript
File metadata and controls
278 lines (214 loc) · 7.78 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
script "CoreInterfaceRelayer"
/*
Copyright (C) 2017 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
on TestSetLayerToTopAndBottom
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
local tButton
create button
put it into tButton
local tField
create field
put it into tField
set the layer of tField to bottom
TestAssert "set layer to bottom", the layer of tField is 1
set the layer of tField to top
TestAssert "set layer to top", the layer of tField is (the number of controls)
end TestSetLayerToTopAndBottom
on TestSetLayerToLayerOfControl
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
create graphic
local tButton
create button
put it into tButton
local tField
create field
put it into tField
local tButtonLayer
put the layer of tButton into tButtonLayer
set the layer of tField to tButtonLayer
TestAssert "set layer to layer of control", the layer of tField is tButtonLayer
end TestSetLayerToLayerOfControl
on TestSetLayerToLayerOfGroup
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
local tGroup
create group
put it into tGroup
local tField
create field
put it into tField
set the relayerGroupedControls to false
set the layer of tField to the layer of tGroup
// Replaces group in layers, so should end up on bottom layer where
// group was
TestAssert "set layer to layer of group with relayer grouped true - " \
& "layer value", the layer of tField is (the layer of tGroup - 1)
TestAssert "set layer to layer of group with relayer grouped true - " \
& "field owner", the long id of the owner of tField is the long \
id of this card of tStack
set the relayerGroupedControls to true
set the layer of tField to the layer of tGroup
// Setting to layer of target group relayers into group as bottom
// control in group
TestAssert "set layer to layer of group with relayer grouped true - " \
& "layer value", the layer of tField is (the layer of tGroup) + 1
TestAssert "set layer to layer of group with relayer grouped true - " \
& "field owner", the long id of the owner of tField is the long \
id of tGroup
end TestSetLayerToLayerOfGroup
on TestSetLayerToLayerOfGroupedControl
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
local tGroup
create group
put it into tGroup
local tButton
create button in tGroup
put it into tButton
local tField
create field
put it into tField
set the relayerGroupedControls to false
set the layer of tField to the layer of tButton
TestAssert "set layer to layer of grouped control with relayer " \
& "grouped false - layer value", the layer of tField is (the \
layer of tButton) + 1
TestAssert "set layer to layer of grouped control with relayer " \
& "grouped false - field owner", the long id of the owner of tField is the long \
id of this card of tStack
set the relayerGroupedControls to true
set the layer of tField to the layer of tButton
TestAssert "set layer to layer of grouped control with relayer " \
& "grouped true - layer value", the layer of tField is (the \
layer of tButton) - 1
TestAssert "set layer to layer of grouped control with relayer " \
& "grouped true - field owner", the long id of the owner of tField is the long \
id of tGroup
end TestSetLayerToLayerOfGroupedControl
on TestSetLayerToLayerOfGroupedControlNotFirst
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
create graphic
local tGroup
create group
put it into tGroup
create button in tGroup
// Create second control in group
local tButton
create button in tGroup
put it into tButton
local tField
create field
put it into tField
set the relayerGroupedControls to true
set the layer of tField to the layer of tButton
TestAssert "set layer to layer of second grouped control" \
& " with relayer grouped true - layer value", \
the layer of tField is the layer of tButton - 1
TestAssert "sset layer to layer of second grouped control" \
& " with relayer grouped true - field owner", \
the long id of the owner of tField is tGroup
end TestSetLayerToLayerOfGroupedControlNotFirst
// The following tests are needed as a result of the code that implements
// this behavior: http://quality.livecode.com/show_bug.cgi?id=19455
// Should be removed when bug 19455 is resolved.
on TestSetLayerToLayerOfGroupedControlAnomaly
repeat for each item tDesc in "on bottom layer,not on bottom layer"
_TestSetLayerToLayerOfGroupedControlAnomaly tDesc
end repeat
end TestSetLayerToLayerOfGroupedControlAnomaly
private command _TestSetLayerToLayerOfGroupedControlAnomaly pDesc
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
// A distinct code path is taken in the case where the layer of a
// control is set to the layer of any control in a group except the
// first, where the outer group is on the bottom layer.
if pDesc is not "on bottom layer" then
create graphic
end if
local tGroup
create group
put it into tGroup
create button in tGroup
// Create second control in group
local tButton
create button in tGroup
put it into tButton
local tField
create field
put it into tField
set the relayerGroupedControls to false
set the layer of tField to the layer of tButton
TestAssert "set layer to layer of second grouped control of outer group " \
& pDesc & " with relayer grouped false - layer value", \
the layer of tField is the layer of tGroup - 1
TestAssert "set layer to layer of second grouped control of outer group " \
& pDesc & " with relayer grouped false - field owner", \
the long id of the owner of tField is the long id of this card of tStack
end _TestSetLayerToLayerOfGroupedControlAnomaly
command _TestSetLayerOfGroupedControlError pControl
set the relayerGroupedControls to false
set the layer of pControl to "bottom"
end _TestSetLayerOfGroupedControlError
on TestSetLayerOfGroupedControl
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
local tGroup
create group
put it into tGroup
local tButton
create button in tGroup
put it into tButton
TestAssertThrow "set layer of grouped control with relayerGroupedControls false", \
"_TestSetLayerOfGroupedControlError", the long id of me, \
"EE_OBJECT_BADRELAYER", tButton
set the relayerGroupedControls to true
set the layer of tButton to "bottom"
-- Long id of button will change
TestAssert "set layer of grouped control with relayerGroupedControls true " \
& "- layer value", the layer of button 1 is 1
TestAssert "set layer of grouped control with relayerGroupedControls true " \
& "- owner", the long id of the owner of button 1 is the long id of \
this card of tStack
end TestSetLayerOfGroupedControl
on TestSetLayerOfControlOutOfRange
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
local tButton
create button
put it into tButton
local tField
create field
put it into tField
set the layer of tButton to 10000
TestAssert "layer property clamped to feasible values", \
the layer of tButton is (the layer of tField) + 1
end TestSetLayerOfControlOutOfRange