[Laszlo-dev] Adding default style attribute values (was Re: [Laszlo-reviews] For Review: Change 20090924-maxcarlson-T Summary: Compile style attribute for <attribute/>)
Max Carlson
max at openlaszlo.org
Sat Oct 3 19:27:39 PDT 2009
I definitely think we should try assigning standard CSS style
properties. That way, many $style declarations can go away.
A few options come to mind:
1. A LzInheritedHash of default stylename -> attribute mappings
2. Separate class properties similar to setter names, e.g. style_visible
= 'display';
3. Somehow hacking them into the existing attributes LzInheritedHash
Then LzNode would call __LZstyleBindAttribute() for matching attribute
names...
I hate to create a parallel mechanism to that used by the compiler, but
I don't see a way around it. All three of these should support inheritance.
While we're on the subject, should compiler/AttributeSpec.java be
updated to know about styles?
P T Withington wrote:
> Approved!
>
> This is great to have this working. We need to figure out how to get it
> to show up in the documentation, and we should announce the feature and
> let people start using it (esp. Webtop). I think it will make a lot of
> code much cleaner.
>
> The next question is whether to assign standard CSS style properties to
> <view> (like background-color for bgcolor);
>
> On 2009-10-03, at 03:25, Max Carlson wrote:
>
>> Change 20090924-maxcarlson-T by maxcarlson at bank.lan on 2009-09-24
>> 08:57:17 PDT
>> in /Users/maxcarlson/openlaszlo/trunk-clean
>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>
>> Summary: Compile style attribute for <attribute/>
>>
>> Bugs Fixed: LPP-7357 - Simple mechanism for making <attribute>s CSS
>> styleable (partial)
>>
>> Technical Reviewer: ptw
>>
>> Details: lzx.rnc - Add style attribute to attributeElement declaration
>>
>> LzNode.lzs - Add a fallback argument to __LZstyleBindAttribute() which
>> is used to compute the value if the style lookup fails.
>>
>> ViewSchema.java - Add "style" to the <attribute/> schema.
>>
>> NodeModel.java - Add a fallbackexpression property and setter to
>> CompiledAttribute. When computing the binder method for a style,
>> include the fallback expression if it's been defined. In
>> addAttributeElement() look for a style attribute. If one is found, it
>> takes precedance over any existing value attribute - but the value is
>> preserved as a fallbackexpression, and binder and dependancy methods
>> are still installed.
>>
>>
>> Tests:
>> <canvas>
>> <stylesheet>
>> stylableclass {
>> background-color: #555588;
>> textColor: #FFFFFF;
>> }
>> </stylesheet>
>>
>> <class name="stylableclass">
>> <attribute name="foo" type="color" value="red"/>
>> <attribute name="bgcolor" style="background-color" value="$
>> {this.foo}"/>
>> <text fontsize="24" fgcolor="$style
>> {'textColor'}">stylableclass</text>
>> </class>
>>
>> <stylableclass/>
>> </canvas>
>>
>> matched the correct style when the style attribute is set to something
>> that matches, e.g. 'background-color'. If style is set to something
>> that fails, the value attribute works for simple values, e.g. 'red'
>> and also for $once and $always constraints.
>>
>> Files:
>> M WEB-INF/lps/schema/lzx.rnc
>> M WEB-INF/lps/lfc/core/LzNode.lzs
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
>>
>> Changeset:
>> http://svn.openlaszlo.org/openlaszlo/patches/20090924-maxcarlson-T.tar
>> _______________________________________________
>> Laszlo-reviews mailing list
>> Laszlo-reviews at www.openlaszlo.org
>> http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews
>
--
Regards,
Max Carlson
OpenLaszlo.org
More information about the Laszlo-dev
mailing list