Changing background colour of CEGUI::MenuItem

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

schnorr
Just popping in
Just popping in
Posts: 14
Joined: Fri Jan 11, 2008 09:39

Changing background colour of CEGUI::MenuItem

Postby schnorr » Tue Feb 12, 2008 13:09

Hello,

I tried to change the background colour of a CEGUI::MenuItem to indicate that this "option" is selected. I am using the WindowsLook looknfeel, so I checked the entry for MenuItem there. I added
<PropertyDefinition name="SelectedColour" initialValue="F0FF0000" redrawOnWrite="true" />
and also
<StateImagery name="EnabledSelected">
<Layer>
<Section section="label">
<ColourProperty name="SelectedColour" />
</Section>
</Layer>
</StateImagery>
<StateImagery name="DisabledSelected">
<Layer>
<Section section="label">
<ColourProperty name="DisabledSelectedColour" />
</Section>
</Layer>
</StateImagery>

Now, how do I change the colour during the runtime? I tried to use the methods of CEGUI::PropertySet, superclass of CEGUI::MenuItem but I actually do not know if I really created a new property, or if there is a property for the color. The alterations above I did based in the Falagard tutorial. What am I missing? :(

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Feb 12, 2008 18:53

Forgive me if I misunderstood the nature of what you're trying to do, but don't the existing properties:
    HoverColour
    PushedColour
    PushedOffColour
    OpenedColour

Offer what you want?

I do seriously get the feeling I missed the point somewhere, though

CE

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Feb 12, 2008 20:07

WidgetGalore to the rescue. Within the code for the StaticText you'll find this line

Code: Select all

// The colors are aarrggbb in Hexadecimal
// Where aa is alpha, rr is red, gg is green, and bb is blue
// tl: top left,  tr: top right,  bl: bottom left,  br: bottom right
staticText->setProperty("TextColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");


You would use the same principle to modify the properties of the menu items, something like

Code: Select all

// 100% alpha, 100% red, 0% green, 0% blue
myNewMenuItem->setProperty("OpenedColour", "FFFF0000");

Is this what you were asking for?

schnorr
Just popping in
Just popping in
Posts: 14
Joined: Fri Jan 11, 2008 09:39

Postby schnorr » Wed Feb 13, 2008 09:02

Hello,

It is the perfect solution if the MenuItem keeps its colour after
that, which I think so. To give a try, I changed the callback function that receives the clicks of the MenuItems involved to this:

Code: Select all

bool CEGUIManager::bundleMenuOption (const CEGUI::EventArgs &e)
{
        const CEGUI::WindowEventArgs& we = static_cast<const
CEGUI::WindowEventArgs&>(e);

        CEGUI::MenuItem *m = (CEGUI::MenuItem*) &we.window;
        m->setProperty("OpenedColour", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");
        return true;
}

I executed the app, but it gives me a SegFault. GDB tells me this:
(gdb) up
#7 0xb78d9987 in CEGUI::PropertySet::setProperty (this=0xbfb351b8,
name=@0xbfb35018, value=@0xbfb34f80) at CEGUIPropertySet.cpp:124
124 CEGUIPropertySet.cpp: No such file or directory.
in CEGUIPropertySet.cpp
Current language: auto; currently c++
(gdb) up
Segmentation fault (core dumped)

I changed the

Code: Select all

m->setProperty("OpenedColour", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");
to this

Code: Select all

m->setProperty("OpenedColour", "FFFF0000");
but it also gives me the same segfault.

So, my setProperty has anything wrong?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Feb 13, 2008 09:58

Line 124 of CEGUIPropertySet.cpp is an exception throw for when it can't find the property.

Does the property in question exist in your version of the skin? Does CEGUI.log mention anything about missing properties (right before it crashes)?

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Feb 13, 2008 12:00

Have a read through the Property Finder thread, which points to the source code for that tool. With it you'll be able to examine the properties available to you.


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 24 guests