@@ -120,45 +120,45 @@ function split(layout::Union{Horizontal,Vertical}, area::Rect)
120
120
]
121
121
s = Solver ()
122
122
for (i, c) in enumerate (layout. constraints)
123
- add_constraint (s, variables[i]. x >= 1 )
124
- add_constraint (s, variables[i]. y >= 1 )
123
+ add_constraint (s, variables[i]. x >= area . x )
124
+ add_constraint (s, variables[i]. y >= area . y )
125
125
add_constraint (s, variables[i]. w <= area. width)
126
126
add_constraint (s, variables[i]. h <= area. height)
127
127
if c isa Auto
128
128
if orientation == :horizontal
129
- add_constraint (s, @constraint variables[i]. w == c. value - 1 strength = KiwiConstraintSolver. STRONG)
129
+ add_constraint (s, @constraint variables[i]. w == c. value strength = KiwiConstraintSolver. STRONG)
130
130
else
131
- add_constraint (s, @constraint variables[i]. h == c. value - 1 strength = KiwiConstraintSolver. STRONG)
131
+ add_constraint (s, @constraint variables[i]. h == c. value strength = KiwiConstraintSolver. STRONG)
132
132
end
133
133
elseif c isa Percent
134
134
if orientation == :horizontal
135
135
add_constraint (
136
136
s,
137
- @constraint variables[i]. w == (c. value * width (area) ÷ 100 ) - 1 strength = KiwiConstraintSolver. MEDIUM
137
+ @constraint variables[i]. w == (c. value * width (area) ÷ 100 ) strength = KiwiConstraintSolver. MEDIUM
138
138
)
139
139
else
140
140
add_constraint (
141
141
s,
142
- @constraint variables[i]. h == (c. value * height (area) ÷ 100 ) - 1 strength = KiwiConstraintSolver. MEDIUM
142
+ @constraint variables[i]. h == (c. value * height (area) ÷ 100 ) strength = KiwiConstraintSolver. MEDIUM
143
143
)
144
144
end
145
145
elseif c isa Fixed
146
146
if orientation == :horizontal
147
- add_constraint (s, variables[i]. w == c. value - 1 )
147
+ add_constraint (s, variables[i]. w == c. value)
148
148
else
149
- add_constraint (s, variables[i]. h == c. value - 1 )
149
+ add_constraint (s, variables[i]. h == c. value)
150
150
end
151
151
elseif c isa Min
152
152
if orientation == :horizontal
153
- add_constraint (s, variables[i]. w >= c. value - 1 )
153
+ add_constraint (s, variables[i]. w >= c. value)
154
154
else
155
- add_constraint (s, variables[i]. h >= c. value - 1 )
155
+ add_constraint (s, variables[i]. h >= c. value)
156
156
end
157
157
elseif c isa Max
158
158
if orientation == :horizontal
159
- add_constraint (s, variables[i]. w <= c. value - 1 )
159
+ add_constraint (s, variables[i]. w <= c. value)
160
160
else
161
- add_constraint (s, variables[i]. h <= c. value - 1 )
161
+ add_constraint (s, variables[i]. h <= c. value)
162
162
end
163
163
end
164
164
end
@@ -179,28 +179,23 @@ function split(layout::Union{Horizontal,Vertical}, area::Rect)
179
179
end
180
180
end
181
181
if orientation == :horizontal
182
- add_constraint (s, sum (variables[i]. w for (i, c) in enumerate (layout. constraints)) == area . width)
182
+ add_constraint (s, sum (variables[i]. w for (i, c) in enumerate (layout. constraints)) == width (area) )
183
183
else
184
- add_constraint (s, sum (variables[i]. h for (i, c) in enumerate (layout. constraints)) == area . height)
184
+ add_constraint (s, sum (variables[i]. h for (i, c) in enumerate (layout. constraints)) == height (area) )
185
185
end
186
186
for (i, c1) in enumerate (layout. constraints), (j, c2) in enumerate (layout. constraints)
187
187
if j <= i
188
188
continue
189
189
end
190
190
if orientation == :horizontal
191
- add_constraint (
192
- s,
193
- KiwiConstraintSolver. Constraint (variables[i]. w - variables[j]. w, KiwiConstraintSolver. WEAK, :(== )),
194
- )
191
+ add_constraint (s, @constraint variables[i]. w == variables[j]. w strength = KiwiConstraintSolver. WEAK)
195
192
else
196
- add_constraint (
197
- s,
198
- KiwiConstraintSolver. Constraint (variables[i]. h - variables[j]. h, KiwiConstraintSolver. WEAK, :(== )),
199
- )
193
+ add_constraint (s, @constraint variables[i]. h == variables[j]. h strength = KiwiConstraintSolver. WEAK)
200
194
end
201
195
end
202
196
update_variables (s)
203
- [Rect (round (v. x. value), round (v. y. value), round (v. w. value), round (v. h. value)) for v in variables]
197
+ rects = [Rect (round (v. x. value), round (v. y. value), round (v. w. value), round (v. h. value)) for v in variables]
198
+ rects
204
199
end
205
200
206
201
@testset " layout-rects" begin
0 commit comments