Transparent list/editbox with visible text

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

User avatar
wizzler
Just popping in
Just popping in
Posts: 10
Joined: Sat Jan 30, 2010 15:28

Transparent list/editbox with visible text

Postby wizzler » Mon Feb 08, 2010 12:34

I've got a Listbox and an Editbox which i want to lower the alpha to make it more transparent but I don't want to have the textitems lowered too. How can i achieve this?

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

Re: Transparent list/editbox with visible text

Postby CrazyEddie » Mon Feb 08, 2010 13:59

Hi,

I think the way that I would do this would be to modify the looknfeel skin. There's a couple of approaches depending on your needs. If you just want all lists to have that effect you can add an appropriate XML element in there to set the alpha for individual imagery sections - if you want it configurable, it's a similar approach but you have to define a property that will control the colours applied instead.

Example the first: Setting 0.4 alpha for all lists, for TaharezLook...
In the TaharezLook.looknfeel file, find the definition of the "TaharezLook/Listbox" and where you see this:

Code: Select all

        <StateImagery name="Enabled">
            <Layer>
                <Section section="main" />
            </Layer>
        </StateImagery>

Change it to, for example, this:

Code: Select all

        <StateImagery name="Enabled">
            <Layer>
                <Section section="main">
                    <Colours topLeft="66FFFFFF" topRight="66FFFFFF" bottomLeft="66FFFFFF" bottomRight="66FFFFFF" />
                </Section>
            </Layer>
        </StateImagery>


Example the second: Using a property to control the colours (and therefore alpha):
Again, in TaharezLook.looknfeel file the Listbox definition, and at the top add a new property definition:

Code: Select all

        <PropertyDefinition name="BoxColour" initialValue="FFFFFFFF" redrawOnWrite="true" />

This creates a new property called "BoxColour" that we can set to affect the colouring of the box later.

Now again we find the StateImagery sections and get it to use our property as the source of the colours:

Code: Select all

        <StateImagery name="Enabled">
            <Layer>
                <Section section="main">
                    <ColourProperty name="BoxColour" />
                </Section>
            </Layer>
        </StateImagery>


Then you can set the BoxColour in code or XML via the regular properties interface.

HTH

CE.

User avatar
wizzler
Just popping in
Just popping in
Posts: 10
Joined: Sat Jan 30, 2010 15:28

Re: Transparent list/editbox with visible text

Postby wizzler » Mon Feb 08, 2010 18:15

CrazyEddie wrote:Hi,

I think the way that I would do this would be to modify the looknfeel skin. There's a couple of approaches depe...
/.../
HTH

CE.


I've played around with the looknfeel now and i seem to get it. I think i need to read up some on the Falagard system.

The problem you describe is that i can set this look for all listboxes, but when I load it in a .layout like so:

Code: Select all

<GUILayout >
    <Window Type="DefaultWindow" Name="Root" >
        <Property Name="UnifiedAreaRect" Value="{{-0.000976563,0},{0,0},{0.999023,0},{1,0}}" />
        <Window Type="TaharezLook/Listbox" Name="/ChatBox/List" >
            <Property Name="Alpha" Value="0.4" />
            <Property Name="UnifiedAreaRect" Value="{{0.0109374,0},{0.784375,0},{0.33418,0},{0.947135,0}}" />
        </Window>
        <Window Type="TaharezLook/Editbox" Name="/ChatBox/Text" >
      <Property Name="Alpha" Value="1" />
      <Property Name="MaxTextLength" Value="1073741823" />
      <Property Name="UnifiedAreaRect" Value="{{0.00996085,0},{0.954948,0},{0.332227,0},{0.990104,0}}" />
      <Property Name="TextParsingEnabled" Value="True" />
        </Window>
        <Window Type="TaharezLook/ImageButton" Name="/Button/Fireball" >
       <Property Name="NormalImage" Value="set:Spells image:Fireball" />
            <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.90,0},{0.76,0},{0.98,0}}" />
        </Window>
        <Window Type="TaharezLook/ImageButton" Name="/Button/Scourge" >
      <Property Name="NormalImage" Value="set:Spells image:Scourge" />
            <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.82,0},{0.76,0},{0.9,0}}" />
        </Window>
    </Window>
</GUILayout>


then the alpha is affecting the whole listbox. I guess i need to rebuild it in the .looknfeel.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Transparent list/editbox with visible text

Postby Jamarr » Tue Feb 09, 2010 00:44

I'm not sure if I fully understand the question, but wouldn't it be simpler to call setInheritsAlpha(false) whenever you add an item to the listbox?
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

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

Re: Transparent list/editbox with visible text

Postby CrazyEddie » Tue Feb 09, 2010 10:17

Yes I understand that setting the Alpha affects the text, it's supposed to ;) Using the second solution that I suggested above would give you a new property for the Listbox named "BoxColour". You could then set that in the layout instead of Alpha, and you should get the results you desire. So that part of the layout might look like this instead:

Code: Select all

        <Window Type="TaharezLook/Listbox" Name="/ChatBox/List" >
            <Property Name="BoxColour" Value="66FFFFFF" />
            <Property Name="UnifiedAreaRect" Value="{{0.0109374,0},{0.784375,0},{0.33418,0},{0.947135,0}}" />
        </Window>


To get that working you just have to add those two small changes to the TaharezLook.looknfeel.

Another option is to subclass the ListboxItem based class you're using and override the draw function so that it does not use the alpha from the owning window.

@Jamarr: Alas, in this case setting the inherited alpha to disabled does not have the desired effect because the old style ListboxItem content is not window based. So I think setting it would have no effect.

CE.

User avatar
wizzler
Just popping in
Just popping in
Posts: 10
Joined: Sat Jan 30, 2010 15:28

Re: Transparent list/editbox with visible text

Postby wizzler » Tue Feb 09, 2010 13:42

CrazyEddie wrote:Yes I understand that setting the Alpha affects the text, it's supposed to ;) Using the second solution that I suggested above would give you a new property for the Listbox named "BoxColour". You could then set that in the layout instead of Alpha, and you should get the results you desire. So that part of the layout might look like this instead:

Code: Select all

        <Window Type="TaharezLook/Listbox" Name="/ChatBox/List" >
            <Property Name="BoxColour" Value="66FFFFFF" />
            <Property Name="UnifiedAreaRect" Value="{{0.0109374,0},{0.784375,0},{0.33418,0},{0.947135,0}}" />
        </Window>


To get that working you just have to add those two small changes to the TaharezLook.looknfeel.

Another option is to subclass the ListboxItem based class you're using and override the draw function so that it does not use the alpha from the owning window.

@Jamarr: Alas, in this case setting the inherited alpha to disabled does not have the desired effect because the old style ListboxItem content is not window based. So I think setting it would have no effect.

CE.


Thanks CE. You're the best! ;)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 7 guests