78 int y = elm->y; |
77 int y = elm->y; |
79 GridDef *col = &cols[x]; |
78 GridDef *col = &cols[x]; |
80 GridDef *row = &rows[y]; |
79 GridDef *row = &rows[y]; |
81 |
80 |
82 NSSize size = elm->view.intrinsicContentSize; |
81 NSSize size = elm->view.intrinsicContentSize; |
|
82 NSSize size2 = elm->view.fittingSize; |
83 NSEdgeInsets alignment = elm->view.alignmentRectInsets; |
83 NSEdgeInsets alignment = elm->view.alignmentRectInsets; |
|
84 // TODO: remove alignment |
|
85 alignment.left = 0; |
|
86 alignment.right = 0; |
|
87 alignment.top = 0; |
|
88 alignment.bottom = 0; |
|
89 if(size.width == NSViewNoIntrinsicMetric) { |
|
90 size.width = size2.width; |
|
91 } |
|
92 if(size.height == NSViewNoIntrinsicMetric) { |
|
93 size.height = size2.height; |
|
94 } |
84 if(size.width != NSViewNoIntrinsicMetric) { |
95 if(size.width != NSViewNoIntrinsicMetric) { |
85 CGFloat width = size.width + alignment.left + alignment.right; |
96 CGFloat width = size.width + alignment.left + alignment.right; |
86 if(width > cols[elm->x].preferred_size && elm->colspan <= 1 && span_max == 1) { |
97 if(width > cols[elm->x].preferred_size && elm->colspan <= 1 && span_max == 1) { |
87 cols[elm->x].preferred_size = width; |
98 cols[elm->x].preferred_size = width; |
88 } |
99 } |
242 end_col = ncols; |
253 end_col = ncols; |
243 } |
254 } |
244 for(int c=elm->x;c<end_col;c++) { |
255 for(int c=elm->x;c<end_col;c++) { |
245 cwidth += cols[c].size; |
256 cwidth += cols[c].size; |
246 } |
257 } |
247 frame.size.width = cwidth; |
258 frame.size.width = cwidth + + alignment.left + alignment.right; |
248 } else { |
259 } else { |
249 frame.size.width = col->size; |
260 frame.size.width = col->size + alignment.left + alignment.right; |
250 } |
261 } |
251 } else { |
262 } else { |
252 frame.size.width = elm->preferred_width; |
263 frame.size.width = elm->preferred_width + alignment.left + alignment.right; |
253 } |
264 } |
254 if(elm->vfill) { |
265 if(elm->vfill) { |
255 if(elm->rowspan > 1) { |
266 if(elm->rowspan > 1) { |
256 int rheight = 0; |
267 int rheight = 0; |
257 int end_row = elm->y + elm->rowspan; |
268 int end_row = elm->y + elm->rowspan; |
266 frame.size.height = row->size; |
277 frame.size.height = row->size; |
267 } else { |
278 } else { |
268 frame.size.height = elm->preferred_height; |
279 frame.size.height = elm->preferred_height; |
269 } |
280 } |
270 frame.origin.x = col->pos - (alignment.left+alignment.right)/2; |
281 frame.origin.x = col->pos - (alignment.left+alignment.right)/2; |
271 frame.origin.y = viewFrame.size.height - row->pos - frame.size.height + ((alignment.top+alignment.right)/2); |
282 //frame.origin.y = viewFrame.size.height - row->pos - frame.size.height + ((alignment.top+alignment.right)/2); |
|
283 frame.origin.y = viewFrame.size.height - row->pos - frame.size.height; |
272 elm->view.frame = frame; |
284 elm->view.frame = frame; |
273 } |
285 } |
274 |
286 |
275 free(cols); |
287 free(cols); |
276 free(rows); |
288 free(rows); |
292 elm.x = _x; |
304 elm.x = _x; |
293 elm.y = _y; |
305 elm.y = _y; |
294 elm.margin = 0; |
306 elm.margin = 0; |
295 elm.colspan = _uilayout.colspan; |
307 elm.colspan = _uilayout.colspan; |
296 elm.rowspan = _uilayout.rowspan; |
308 elm.rowspan = _uilayout.rowspan; |
297 elm.hfill = _uilayout.hfill; |
309 if(_uilayout.fill) { |
298 elm.vfill = _uilayout.vfill; |
310 elm.hfill = TRUE; |
299 elm.hexpand = _uilayout.hexpand; |
311 elm.vfill = TRUE; |
300 elm.vexpand = _uilayout.vexpand; |
312 elm.hexpand = TRUE; |
|
313 elm.vexpand = TRUE; |
|
314 } else { |
|
315 elm.hfill = _uilayout.hfill; |
|
316 elm.vfill = _uilayout.vfill; |
|
317 elm.hexpand = _uilayout.hexpand; |
|
318 elm.vexpand = _uilayout.vexpand; |
|
319 } |
301 elm.view = view; |
320 elm.view = view; |
302 cxListAdd(_children, &elm); |
321 cxListAdd(_children, &elm); |
303 |
322 |
304 [self addSubview:view]; |
323 [self addSubview:view]; |
305 self.needsLayout = YES; |
324 self.needsLayout = YES; |