Changeset 5056
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebContent/ITMILL/themes/default/orderedlayout/orderedlayout.css
r5040 r5056 1 .i-orderedlayout-margin-top { 1 . 2 /* Ordered layout spacing and margins are currently fixed. 3 This is considered to be a bug. For more info, see 4 http://dev.itmill.com/ticket/1904 5 6 i-orderedlayout-margin-top { 2 7 padding-top: 15px; 3 8 } … … 19 24 } 20 25 26 */ 27 21 28 /* Placing error indicator right after the widget with empty caption */ 22 29 .i-orderedlayout-w:after, .i-orderedlayout-c:after { -
trunk/WebContent/ITMILL/themes/default/styles.css
r5042 r5056 698 698 white-space: nowrap; 699 699 } 700 .i-orderedlayout-margin-top { 700 . 701 /* Ordered layout spacing and margins are currently fixed. 702 This is considered to be a bug. For more info, see 703 http://dev.itmill.com/ticket/1904 704 705 i-orderedlayout-margin-top { 701 706 padding-top: 15px; 702 707 } … … 717 722 padding-left: 8px; 718 723 } 724 725 */ 719 726 720 727 /* Placing error indicator right after the widget with empty caption */ -
trunk/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
r5055 r5056 19 19 import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; 20 20 import com.itmill.toolkit.terminal.gwt.client.Paintable; 21 import com.itmill.toolkit.terminal.gwt.client.StyleConstants;22 21 import com.itmill.toolkit.terminal.gwt.client.UIDL; 23 22 import com.itmill.toolkit.terminal.gwt.client.Util; … … 40 39 public static final int ORIENTATION_HORIZONTAL = 1; 41 40 42 // TODO Read this from CSS as in #1904 43 private static final int SPACING_SIZE = 8; 41 // TODO Read these from CSS as in #1904 42 private static final int HSPACING = 8; 43 private static final int VSPACING = 8; 44 private static final int MARGIN_TOP = 15; 45 private static final int MARGIN_BOTTOM = 15; 46 private static final int MARGIN_LEFT = 18; 47 private static final int MARGIN_RIGHT = 18; 44 48 45 49 int orientationMode = ORIENTATION_VERTICAL; … … 203 207 updateOrientation(uidl); 204 208 205 // Ensure correct implementation206 if (client.updateComponent(this, uidl, false)) {207 return;208 }209 210 209 // Handle layout margins 211 210 if (margins.getBitMask() != uidl.getIntAttribute("margins")) { … … 215 214 // Handle component spacing later in handleAlignments() method 216 215 hasComponentSpacing = uidl.getBooleanAttribute("spacing"); 216 217 // Update sizes, ... 218 if (client.updateComponent(this, uidl, false)) { 219 return; 220 } 217 221 218 222 // Collect the list of contained widgets after this update … … 318 322 if (width == null || "".equals(width)) { 319 323 DOM.setStyleAttribute(margin, "width", ""); 324 320 325 if (fixedCellSize && orientationMode == ORIENTATION_HORIZONTAL) { 321 326 removeFixedSizes(); 322 327 } 323 328 } else { 324 DOM.setStyleAttribute(margin, "width", "100%"); 329 330 // Calculate margin pixel width 331 int cw = DOM.getElementPropertyInt(root, "offsetWidth"); 332 cw -= margins.hasLeft() ? MARGIN_LEFT : 0; 333 cw -= margins.hasRight() ? MARGIN_RIGHT : 0; 334 DOM.setStyleAttribute(margin, "width", cw + "px"); 335 325 336 if (orientationMode == ORIENTATION_HORIZONTAL) { 326 337 fixedCellSize = true; … … 347 358 } 348 359 } else { 349 DOM.setStyleAttribute(margin, "height", "100%"); 360 361 // Calculate margin pixel height 362 int ch = DOM.getElementPropertyInt(root, "offsetHeight"); 363 ch -= margins.hasTop() ? MARGIN_TOP : 0; 364 ch -= margins.hasBottom() ? MARGIN_BOTTOM : 0; 365 DOM.setStyleAttribute(margin, "height", ch + "px"); 366 367 // Turn on vertical orientation mode if needed 350 368 if (orientationMode == ORIENTATION_VERTICAL) { 351 369 fixedCellSize = true; … … 399 417 } 400 418 401 DOM.setStyleAttribute(margin, 402 (orientationMode == ORIENTATION_HORIZONTAL) ? "width" 403 : "height", "100%"); 404 405 int size = DOM.getElementPropertyInt(margin, 419 // Calculate the space for fixed contents minus marginals 420 int size = DOM.getElementPropertyInt(root, 406 421 (orientationMode == ORIENTATION_HORIZONTAL) ? "offsetWidth" 407 422 : "offsetHeight"); 423 if (orientationMode == ORIENTATION_HORIZONTAL) { 424 size -= margins.hasLeft() ? MARGIN_LEFT : 0; 425 size -= margins.hasRight() ? MARGIN_RIGHT : 0; 426 } else { 427 size -= margins.hasTop() ? MARGIN_TOP : 0; 428 size -= margins.hasBottom() ? MARGIN_BOTTOM : 0; 429 } 408 430 409 431 // Horizontal layouts need fixed mode tables … … 417 439 int numChild = childWidgets.size(); 418 440 if (hasComponentSpacing) { 419 size -= SPACING_SIZE * (numChild - 1); 441 size -= ((orientationMode == ORIENTATION_HORIZONTAL) ? HSPACING 442 : VSPACING) 443 * (numChild - 1); 420 444 } 421 445 … … 459 483 460 484 // Update margin classes 461 setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, 462 margins.hasTop()); 463 setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, 464 margins.hasRight()); 465 setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM, 466 margins.hasBottom()); 467 setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, 468 margins.hasLeft()); 485 DOM.setStyleAttribute(margin, "paddingTop", 486 margins.hasTop() ? MARGIN_TOP + "px" : "0"); 487 DOM.setStyleAttribute(margin, "paddingLeft", 488 margins.hasLeft() ? MARGIN_LEFT + "px" : "0"); 489 DOM.setStyleAttribute(margin, "paddingBottom", 490 margins.hasBottom() ? MARGIN_BOTTOM + "px" : "0"); 491 DOM.setStyleAttribute(margin, "paddingRight", 492 margins.hasRight() ? MARGIN_RIGHT + "px" : "0"); 493 494 // Update calculated height if needed 495 String currentMarginHeight = DOM.getStyleAttribute(margin, "height"); 496 if (currentMarginHeight != null && !"".equals(currentMarginHeight)) { 497 int ch = DOM.getElementPropertyInt(root, "offsetHeight"); 498 ch -= margins.hasTop() ? MARGIN_TOP : 0; 499 ch -= margins.hasBottom() ? MARGIN_BOTTOM : 0; 500 DOM.setStyleAttribute(margin, "height", ch + "px"); 501 } 502 String currentMarginWidth = DOM.getStyleAttribute(margin, "width"); 503 if (currentMarginWidth != null && !"".equals(currentMarginWidth)) { 504 int cw = DOM.getElementPropertyInt(root, "offsetWidth"); 505 cw -= margins.hasLeft() ? MARGIN_LEFT : 0; 506 cw -= margins.hasRight() ? MARGIN_RIGHT : 0; 507 DOM.setStyleAttribute(margin, "width", cw + "px"); 508 } 469 509 470 510 // Update child layouts … … 703 743 /** Set class for spacing */ 704 744 void setSpacingEnabled(boolean b) { 705 setStyleName( 706 getElement(), 707 CLASSNAME 708 + "-" 709 + (orientationMode == ORIENTATION_HORIZONTAL ? StyleConstants.HORIZONTAL_SPACING 710 : StyleConstants.VERTICAL_SPACING), b); 711 } 712 745 DOM.setStyleAttribute(getElement(), 746 orientationMode == ORIENTATION_HORIZONTAL ? "paddingLeft" 747 : "marginTop", 748 b ? (orientationMode == ORIENTATION_HORIZONTAL ? HSPACING 749 : VSPACING) 750 + "px" : "0"); 751 } 713 752 } 714 753
