Changeset 37 for trunk/luigi/arranger.d
- Timestamp:
- 12/05/06 20:00:24 (2 years ago)
- Files:
-
- trunk/luigi/arranger.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/arranger.d
r11 r37 306 306 FlowRow currentRow = new FlowRow(xgap); 307 307 foreach(Arrangeable c ; m_items) 308 { 309 Size s = c.preferred_size(rect.size); 310 currentWidth += s.width + xgap; 311 if(currentWidth > rect.width) 308 312 { 309 Size s = c.preferred_size(rect.size); 310 currentWidth += s.width + xgap; 311 if(currentWidth > rect.width) 312 { 313 currentWidth = s.width - xgap; 314 rows ~= currentRow; 315 currentRow = new FlowRow(xgap); 316 } 317 currentRow.add(c); 313 currentWidth = s.width - xgap; 314 rows ~= currentRow; 315 currentRow = new FlowRow(xgap); 318 316 } 317 currentRow.add(c); 318 } 319 319 rows ~= currentRow; 320 320 float totalHeight = 0; 321 321 foreach(FlowRow r ; rows) 322 {323 totalHeight += r.size.height;324 }322 { 323 totalHeight += r.size.height; 324 } 325 325 totalHeight += ygap*(rows.length - 1); 326 326 … … 346 346 case A.Left: 347 347 foreach(FlowRow r; rows) 348 {349 r.position = Point(0, y-rect.y);350 r.arrange();351 y += r.size.height + ygap;352 }348 { 349 r.position = Point(0, y-rect.y); 350 r.arrange(); 351 y += r.size.height + ygap; 352 } 353 353 break; 354 354 case A.Right: 355 355 foreach(FlowRow r; rows) 356 {357 float x = rect.x2 - r.size.width;358 r.position = Point(x-rect.x, y-rect.y);359 r.arrange();360 y += r.size.height + ygap;361 }356 { 357 float x = rect.x2 - r.size.width; 358 r.position = Point(x-rect.x, y-rect.y); 359 r.arrange(); 360 y += r.size.height + ygap; 361 } 362 362 break; 363 363 … … 365 365 default: 366 366 foreach(FlowRow r; rows) 367 {368 float x = rect.x + (rect.width - r.size.width)/2;369 r.position = Point(x-rect.x, y-rect.y);370 r.arrange();371 y += r.size.height + ygap;372 }367 { 368 float x = rect.x + (rect.width - r.size.width)/2; 369 r.position = Point(x-rect.x, y-rect.y); 370 r.arrange(); 371 y += r.size.height + ygap; 372 } 373 373 break; 374 374 } 375 375 foreach(Arrangeable item ; m_items) 376 {377 item.arrange();378 }376 { 377 item.arrange(); 378 } 379 379 } 380 380 … … 428 428 float y = y0 + (rect.height / 2); 429 429 foreach(Arrangeable item ; m_items) 430 {431 Size s = item.preferred_size(rect.size);432 item.set_rect(Rect(x, y-(s.height/2), s.width, s.height));433 x += s.width + xgap;434 }430 { 431 Size s = item.preferred_size(rect.size); 432 item.set_rect(Rect(x, y-(s.height/2), s.width, s.height)); 433 x += s.width + xgap; 434 } 435 435 } 436 436 … … 440 440 float width = 0; 441 441 foreach(Arrangeable item ; m_items) 442 {443 Size s = item.preferred_size(rect.size);444 width += s.width;445 }442 { 443 Size s = item.preferred_size(rect.size); 444 width += s.width; 445 } 446 446 width += xgap * (m_items.length - 1); 447 447 m_rect.width = width; … … 453 453 float maxHeight = 0; 454 454 foreach(Arrangeable item ; m_items) 455 {456 maxHeight = math.fmax(maxHeight, item.preferred_size(rect.size).height);457 }455 { 456 maxHeight = math.fmax(maxHeight, item.preferred_size(rect.size).height); 457 } 458 458 return maxHeight; 459 459 } … … 637 637 heights[] = 0; 638 638 639 foreach(c, inout w; widths) { 640 foreach(r, inout h; heights) { 639 foreach(c, inout w; widths) 640 { 641 foreach(r, inout h; heights) 642 { 641 643 int i = r * grid.cols + c; 642 644 if(i < m_items.length)
