Page 1 of 1

[Solved] Area of flat colour without using images?

Posted: Tue Feb 04, 2014 21:27
by zuur
Hi All,

Simple question: I'm wanting to add an area of flat colour to my widget, either over the whole widget or over a specified rectangular area, and can't find any obvious way of doing it other than to stretch a white pixel over the area I want and then modulating that with a color in the <Layer>...

Seems like there should be an obvious way to just say "make this area red", but I'm missing it...

edit: Using CEGUI 0.7.5

Re: Area of flat colour without using images?

Posted: Fri Feb 07, 2014 14:49
by Ident
I think the best way to do this is to modify the LNF to contain a ColourRectProperty or ColourProperty after defining one or multiple connected images (or a white 1pixel dummy texture image).
You can address it using a variable, e.g.:

Code: Select all

<ColourRectProperty name="BackgroundColours" />

and on top of your file you can use a PropertyDefinition, which also allows you to address this via setProperty in runtime:

Code: Select all

<PropertyDefinition name="BackgroundColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />


The way CEGUI renders its widgets always uses texture+colour. Unfortunately we do not currently offer a way to just render a rectangular coloured area. Obviously, it would also need to have its dimensions defined in some way.
Either way, if you want to add this feature feel free to try and add this to falagard and create a pull request for us on mercurial so we can review and once it meets our quality standards we will add it.

In any other case use the above workaround.
PS:
You can write a section e.g.:

Code: Select all

        <ImagerySection name="frame">
            <FrameComponent>
                <Area>
                    <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>
                <Image type="TopLeftCorner" imageset="TaharezLook" image="PopupMenuFrameTopLeft" />
                <Image type="TopRightCorner" imageset="TaharezLook" image="PopupMenuFrameTopRight" />
                <Image type="BottomLeftCorner" imageset="TaharezLook" image="PopupMenuFrameBottomLeft" />
                <Image type="BottomRightCorner" imageset="TaharezLook" image="PopupMenuFrameBottomRight" />
                <Image type="LeftEdge" imageset="TaharezLook" image="PopupMenuFrameLeft" />
                <Image type="RightEdge" imageset="TaharezLook" image="PopupMenuFrameRight" />
                <Image type="TopEdge" imageset="TaharezLook" image="PopupMenuFrameTop" />
                <Image type="BottomEdge" imageset="TaharezLook" image="PopupMenuFrameBottom" />
                <Image type="Background" imageset="TaharezLook" image="PopupMenuMiddle" />
            </FrameComponent>
        </ImagerySection>

and then inside a layer you can reference the section and use your ColourProperty or ColourRectProperty:

Code: Select all

            <Layer>
                <Section section="frame">
                    <ColourRectProperty name="BackgroundColours" />
                </Section>
            </Layer>

Re: Area of flat colour without using images?

Posted: Tue Feb 11, 2014 03:50
by zuur
Wow @Ident, thanks for such a full and well explained reply! - it's at least good to know that I wasn't just missing something obvious :)

I've started out with just stretching a white pixel where needed, and might go ahead and implement something less hackey soon to clean up. Will post back here if I come up with anything useful.

Thanks again,
-zuur.

Re: [Solved] Area of flat colour without using images?

Posted: Tue Feb 11, 2014 04:02
by Ident
Any code snippets of your solution will be well appreciated and might also help other users in the future.