Auto-cast boolean properties when used in DimOperators

Create issue
Issue #643 resolved
Pavlos Touboulidis created an issue

As the title says, it'd be nice if boolean properties could be cast to floats (0 / 1) when used inside/with a DimOperator. Forgive me if my request happens to be invalid; the project is pretty big and I might have missed something.

This would help when creating WidgetLooks that have children that can be hidden/shown and the layout of the parent depends on their visibility.

A short example to demonstrate this:

<WidgetLook name="sketch/hscroll"> <PropertyLinkDefinition name="DecButtonVisible" initialValue="True" widget="auto_decbtn" targetProperty="Visible" redrawOnWrite="true" layoutOnWrite="true" /> ... <NamedArea name="ThumbTrackArea"> <Area> <Dim type="LeftEdge"> <WidgetDim widget="auto_decbtn" dimension="RightEdge"> <DimOperator op="Multiply"> <PropertyDim name="DecButtonVisible" /> <!-- This fails at the moment --> </DimOperator> </WidgetDim> </Dim> ...

You could say that I could just set the property to "1" instead of "True" but then the PropertyLinkDefinition to a boolean property breaks.

Reproducibility: N/A

Additional information: This was originally reported on the forums, http://www.cegui.org.uk/phpBB2/viewtopic.php?f=3&t=5919

OS: Windows, OS build: XP, Platform: x86

Comments (5)

  1. Pavlos Touboulidis reporter

    After further tests it seems the above is not enough. It looks like it only works for built-in properties. :(

  2. Pavlos Touboulidis reporter

    OK, another attempt in the attached patch. There are several ways it could be done and I think the one I chose will introduce no unintended changes and no performance penalty.

    Feel free to tell me why it sucks, I'll try again. :)

  3. Pavlos Touboulidis reporter

    Now that the properties defined in looknfeel files are typed, the initial approach works and is probably better too (3 sloc). See the attached patch (2012-03-20).

  4. Paul Turner

    The last patch attach is now in. Thanks a lot, and sorry for the delay :)

    changeset: 3245:f6cea3f327a6 user: Paul Turner <paul@cegui.org.uk> date: Mon May 21 09:38:54 2012 +0100 summary: MOD: Automatically convert boolean properties used in dimension calculations to float (1.0 and 0.0) values.

  5. Log in to comment