[Solved] Area of flat colour without using images?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

zuur
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Tue Apr 01, 2008 21:17

[Solved] Area of flat colour without using images?

Postby zuur » Tue Feb 04, 2014 21:27

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
Last edited by zuur on Tue Feb 11, 2014 03:50, edited 1 time in total.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Area of flat colour without using images?

Postby Ident » Fri Feb 07, 2014 14:49

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>
CrazyEddie: "I don't like GUIs"

zuur
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Tue Apr 01, 2008 21:17

Re: Area of flat colour without using images?

Postby zuur » Tue Feb 11, 2014 03:50

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.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

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

Postby Ident » Tue Feb 11, 2014 04:02

Any code snippets of your solution will be well appreciated and might also help other users in the future.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: Baidu [Spider] and 32 guests