Ticket #1904 (closed defect: fixed)

Opened 5 months ago

Last modified 3 months ago

IOrderedLayout spacing and margincs should be specifiable in CSS

Reported by: Joonas Lehtinen Owned by: Joonas Lehtinen
Priority: blocker Milestone: User Interface Library 5.3.0 RC
Component: gwt-adapter-client Version: 5.2.5
Keywords: Cc:
Known Issue description:
Hours estimate: Deadline (dd.mm.yyyy):
Known Issue version (since): Known Issue title:
Hours done: Depends to:
Affects documentation: no
Known Issue workaround:
Affects release notes: no Contract:

Description (last modified by Joonas Lehtinen) (diff)

See IOrderedLayout.HSPACING

Attachments

MarginCalcTest.html (1.2 kB) - added by Mauno Haukila 3 months ago.

Change History

Changed 5 months ago by Joonas Lehtinen

  • priority changed from minor to major
  • summary changed from IOrderedLayout fixed mode assumes certain spacing width/height, it should be read from CSS instead to IOrderedLayout spacing and margincs should be specifiable in CSS
  • description modified (diff)
  • milestone changed from User Interface Library 5.3.0 RC1 to User Interface Library 5 stable branch backlog

Changed 5 months ago by Joonas Lehtinen

Write robust groundwork in [5056]

Changed 5 months ago by Jouni Koivuviita

Committed a helper class for this in [5058] (com.itmill.toolkit.terminal.gwt.client.CSSRule.java).

Usage:

CSSRule rule = new CSSRule(".i-orderedlayout-vspacing");
String spacing = rule.getPropertyValue("marginTop");

Cache these for faster access. Add support for changing spacing and margin sizes with stylenames.

Changed 5 months ago by Joonas Lehtinen

Added stubs for using CSS reader in [5059].

Changed 5 months ago by Joonas Lehtinen

  • owner changed from Marko Gronroos to Joonas Lehtinen
  • status changed from new to accepted

Changed 3 months ago by Joonas Lehtinen

  • milestone changed from User Interface Library 5 stable branch backlog to User Interface Library 5.3.0 RC1

Changed 3 months ago by Joonas Lehtinen

  • priority changed from major to blocker

Changed 3 months ago by Joonas Lehtinen

  • status changed from accepted to closed
  • resolution set to fixed

Fixed in [5245]

Jouni: Sorry, decided not to use your parser as I was not able to figure out a strategy for robustly obtaining different CSS attributes related to spacing, margins, padding, ...

Changed 3 months ago by Jouni Koivuviita

No problem :)

The CSSRule class is somewhat limited, because it doesn't resolve any attribute inheritance or multiple classnames on one element, but I guess it is usable in some limited cases. Calculating dimensions/margins/paddings for some element in the DOM tree is not one of them.

Maybe for something like controlling the position of a splitpanel's splitter, e.g.

.i-splitpanel-control-attributes {
    width: 100%;
    height: 100%;
    margin: 20px;
    left: 230px;
    /* or */
    right: 300px;
    /* or */
    top: 120px;
    /* or */
    bottom: 80px;
}

These attributes wouldn't actually refer to any DOM element, but they would be used when drawing a specific splitpanel. That way we wouldn't need any helper stylenames like ".i-orderedlayout-margin-top", we would just get it the value of a specific margin to use like this:

CSSRule rule = CSSRule(".i-orderedlayout-mylayout-control-attributes");
String marginLeft = rule.getAttribute("margin-left");
// Then use this value when calculating layout dimensions
...

Changed 3 months ago by Mauno Haukila

Note: Could you use just Window.getComputedStyle? (Ie has it's own alternative: element.currentStyle)

"Returns computed style of the element. Computed style represents the final computed values of all CSS properties for the element. "

Changed 3 months ago by Mauno Haukila

Changed 3 months ago by Mauno Haukila

Added small test for getComputed style method. It gets current padding, but you can get anything. Tested with ie6, ie7, fx2.0, fx3.0.. It should work with opera and webkit.

Note: See TracTickets for help on using tickets.