ui/cocoa/GridLayout.m

changeset 800
814d374fb689
parent 799
f8ff8df41713
child 810
7b5ba65b246f
equal deleted inserted replaced
799:f8ff8df41713 800:814d374fb689
78 int x = elm->x; 78 int x = elm->x;
79 int y = elm->y; 79 int y = elm->y;
80 GridDef *col = &cols[x]; 80 GridDef *col = &cols[x];
81 GridDef *row = &rows[y]; 81 GridDef *row = &rows[y];
82 82
83 if(elm->margin.left + elm->margin.right > 0) {
84 printf(""); // break
85 }
86
83 NSSize size = elm->view.intrinsicContentSize; 87 NSSize size = elm->view.intrinsicContentSize;
84 NSSize size2 = elm->view.fittingSize; 88 NSSize size2 = elm->view.fittingSize;
85 if(size.width == NSViewNoIntrinsicMetric) { 89 if(size.width == NSViewNoIntrinsicMetric) {
86 size.width = size2.width; 90 size.width = size2.width;
87 } 91 }
88 if(size.height == NSViewNoIntrinsicMetric) { 92 if(size.height == NSViewNoIntrinsicMetric) {
89 size.height = size2.height; 93 size.height = size2.height;
90 } 94 }
91 if(size.width != NSViewNoIntrinsicMetric) { 95 if(size.width != NSViewNoIntrinsicMetric) {
92 CGFloat width = size.width; 96 CGFloat width = size.width + elm->margin.left + elm->margin.right;
93 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) {
94 cols[elm->x].preferred_size = width; 98 cols[elm->x].preferred_size = width;
95 } 99 }
96 elm->preferred_width = width; 100 elm->preferred_width = width;
97 } 101 }
98 if(size.height != NSViewNoIntrinsicMetric) { 102 if(size.height != NSViewNoIntrinsicMetric) {
99 CGFloat height = size.height; 103 CGFloat height = size.height + elm->margin.top + elm->margin.bottom;
100 //CGFloat height = size.height;
101 if(height > rows[elm->y].preferred_size && elm->rowspan <= 1 && span_max == 1) { 104 if(height > rows[elm->y].preferred_size && elm->rowspan <= 1 && span_max == 1) {
102 rows[elm->y].preferred_size = height; 105 rows[elm->y].preferred_size = height;
103 } 106 }
104 elm->preferred_height = height; 107 elm->preferred_height = height;
105 } 108 }
109
106 110
107 if(elm->rowspan > span_max || elm->colspan > span_max) { 111 if(elm->rowspan > span_max || elm->colspan > span_max) {
108 continue; 112 continue;
109 } 113 }
110 114
252 int cwidth = 0; 256 int cwidth = 0;
253 int end_col = elm->x + elm->colspan; 257 int end_col = elm->x + elm->colspan;
254 if(end_col > ncols) { 258 if(end_col > ncols) {
255 end_col = ncols; 259 end_col = ncols;
256 } 260 }
261 int real_span = 0;
257 for(int c=elm->x;c<end_col;c++) { 262 for(int c=elm->x;c<end_col;c++) {
258 cwidth += cols[c].size; 263 cwidth += cols[c].size;
259 } 264 real_span++;
260 frame.size.width = cwidth + + alignment.left + alignment.right; 265 }
266 if(real_span > 0) {
267 cwidth += (real_span-1) * colspacing;
268 }
269 frame.size.width = cwidth + alignment.left + alignment.right;
261 } else { 270 } else {
262 frame.size.width = col->size + alignment.left + alignment.right; 271 frame.size.width = col->size + alignment.left + alignment.right;
263 } 272 }
264 } else { 273 } else {
265 frame.size.width = elm->preferred_width + alignment.left + alignment.right; 274 frame.size.width = elm->preferred_width + alignment.left + alignment.right;
266 } 275 }
276 frame.size.width -= elm->margin.left + elm->margin.right;
267 if(elm->vfill) { 277 if(elm->vfill) {
268 if(elm->rowspan > 1) { 278 if(elm->rowspan > 1) {
269 int rheight = 0; 279 int rheight = 0;
270 int end_row = elm->y + elm->rowspan; 280 int end_row = elm->y + elm->rowspan;
271 if(end_row > nrows) { 281 if(end_row > nrows) {
272 end_row = nrows; 282 end_row = nrows;
273 } 283 }
284 int real_span = 0;
274 for(int r=elm->y;r<end_row;r++) { 285 for(int r=elm->y;r<end_row;r++) {
275 rheight += rows[r].size; 286 rheight += rows[r].size;
287 real_span++;
288 }
289 if(real_span > 0) {
290 rheight += (real_span-1) * rowspacing;
276 } 291 }
277 frame.size.height = rheight; 292 frame.size.height = rheight;
278 } 293 }
279 frame.size.height = row->size; 294 frame.size.height = row->size;
280 } else { 295 } else {
281 frame.size.height = elm->preferred_height; 296 frame.size.height = elm->preferred_height;
282 } 297 }
283 frame.origin.x = col->pos - (alignment.left+alignment.right)/2; 298 frame.size.height -= elm->margin.top + elm->margin.bottom;
299 frame.origin.x = col->pos + elm->margin.left - (alignment.left+alignment.right)/2;
284 //frame.origin.y = viewFrame.size.height - row->pos - frame.size.height + ((alignment.top+alignment.right)/2); 300 //frame.origin.y = viewFrame.size.height - row->pos - frame.size.height + ((alignment.top+alignment.right)/2);
285 frame.origin.y = viewFrame.size.height - row->pos - frame.size.height; 301 frame.origin.y = viewFrame.size.height - row->pos - elm->margin.top - frame.size.height;
286 elm->view.frame = frame; 302 elm->view.frame = frame;
287 } 303 }
288 304
289 free(cols); 305 free(cols);
290 free(rows); 306 free(rows);

mercurial