Page 1 of 1

Giving a Window a colored background

Posted: Tue Feb 14, 2012 13:00
by matt
Hello!

Is there a special Widget ("DefaultWindow", "StaticImage" etc...) that has a property "background-color" ?
I looked on this page (http://cegui.org.uk/static/TaharezLookProperties.html), but I didn't manage to find what I needed.

I actually need to build some widgets, that contain some controls (buttons, sliders etc....), and the parent Window of these widgets must have a colored background with an alpha.
Is there a way to acheive it without using a StaticImage (what i'm currently doing), and a colored .png ?

Thanx in advance

Re: Giving a Window a colored background

Posted: Wed Feb 15, 2012 11:40
by CrazyEddie
Widgets do not specify this type of thing. In general it comes 100% from the looknfeel specification.

Basically you would create a really simple WidgetLook that stretches some generic brush image (i.e. a small, all white area of an Imageset) over it's area and applies some colour to that (optionally sourced via a PropertyDefinition). You would then make a mapping in your scheme so that the defined WidgetLook is applied to some type (using DefaultWindow target class ans window renderer).

The WidgetLook might be something like this:

Code: Select all

    <WidgetLook name="MySkin/ContainerWindow">
        <PropertyDefinition name="BackgroundColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
        <ImagerySection name="main">
            <ImageryComponent>
                <Area>
                    <Dim type="LeftEdge">
                        <AbsoluteDim value="0" />
                    </Dim>
                    <Dim type="TopEdge">
                        <AbsoluteDim value="0" />
                    </Dim>
                    <Dim type="RightEdge">
                        <UnifiedDim scale="1" type="RightEdge" />
                    </Dim>
                    <Dim type="BottomEdge">
                        <UnifiedDim scale="1" type="BottomEdge" />
                    </Dim>
                </Area>
                <Image imageset="MyImageset" image="GenericBrush" />
                <ColourRectProperty name="BackgroundColours" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
        <StateImagery name="Enabled">
            <Layer>
                <Section section="main" />
            </Layer>
        </StateImagery>
        <StateImagery name="Disabled">
            <Layer>
                <Section section="main" />
            </Layer>
        </StateImagery>
    </WidgetLook>


The scheme entry like this:

Code: Select all

<FalagardMapping WindowType="MySkin/ContainerWindow"    TargetType="DefaultWindow"    Renderer="Falagard/Default"    LookNFeel="MySkin/ContainerWindow" />


HTH

CE.

Re: Giving a Window a colored background

Posted: Wed Feb 22, 2012 14:08
by matt
Thanx Eddy for your answer! It works like a charm! :)

2 little more questions:
  • Is it possible to specify in the widget definition, the property MousePassThroughEnabled to false ?
    It doesn't seems possible because this property isn't a Falagard property link defintion (according to http://cegui.org.uk/static/TaharezLookProperties.html)
  • Is it possible to define a new widget inherited from this widget in the looknfeel file, with its color fixed? (=not modifiable with SetProperty("BackgroundColours", "tr:....")) ?

Re: Giving a Window a colored background

Posted: Thu Feb 23, 2012 08:29
by CrazyEddie
matt wrote:Is it possible to specify in the widget definition, the property MousePassThroughEnabled to false ?
It doesn't seems possible because this property isn't a Falagard property link defintion (according to http://cegui.org.uk/static/TaharezLookProperties.html)

Yes. The properties on those pages with the colour highlight are defined in the WidgetLook - meaning, they do not otherwise exist. The non-highlighted properties are defined either in the base widget class or in the window renderer class. You can set any property in the WidgetLook, if you're not defining the property at the same time, then use the <Property> element.

matt wrote:Is it possible to define a new widget inherited from this widget in the looknfeel file, with its color fixed? (=not modifiable with SetProperty("BackgroundColours", "tr:....")) ?[/list]

I don't understand your use of the word inherited :? It is possible to specify a colour (that is not a property) by way of the <Colours> element.

To be explicit about the difference, instead of:

Code: Select all

...
</Area>
<Image imageset="MyImageset" image="GenericBrush" />
<!-- Colour is sourced from property named BackgroundColours -->
<ColourRectProperty name="BackgroundColours" />
<VertFormat type="Stretched" />
...

Use:

Code: Select all

...
</Area>
<Image imageset="MyImageset" image="GenericBrush" />
<!-- Colour is always GREEN! -->
<Colours topLeft="FF00FF00" topRight="FF00FF00" bottomLeft="FF00FF00" bottomRight="FF00FF00" />
<VertFormat type="Stretched" />
...


CE.