[SOLVED] Child controls

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

HorizonDefeated
Just popping in
Just popping in
Posts: 19
Joined: Tue Feb 16, 2010 00:17

[SOLVED] Child controls

Postby HorizonDefeated » Wed Feb 17, 2010 00:02

Hello,

I seem to be having trouble with a custom control:

Code: Select all

<!--
***************************************************
    ProcerusLook/IconButton
***************************************************
-->
<WidgetLook name="ProcerusLook/IconButton">
   <PropertyDefinition name="IconImage" initialValue="" redrawOnWrite="true" />
   <PropertyDefinition name="VertImageFormatting" initialValue="TopAligned" redrawOnWrite="true" />
   <PropertyDefinition name="HorzImageFormatting" initialValue="CentreAligned" redrawOnWrite="true" />
   <PropertyDefinition name="ImageAreaRect" initialValue="{{0,0},{0,0},{1,0},{1,0}}" redrawOnWrite="true"  layoutOnWrite="true"/>
   <PropertyDefinition name="VertTextFormatting" initialValue="TopAligned" redrawOnWrite="true" />
   <PropertyDefinition name="HorzTextFormatting" initialValue="CentreAligned" redrawOnWrite="true" />
   <PropertyDefinition name="TextAreaRect" initialValue="{{0,0},{0,0},{1,0},{1,0}}" redrawOnWrite="true" layoutOnWrite="true"/>
   <PropertyDefinition name="ButtonColor" initialValue="ff1e3cba" redrawOnWrite="true"/>
   <PropertyDefinition name="NormalHighlightColor" initialValue="tl:ff8fa1ed tr:ff8fa1ed bl:ff1e3cba br:ff1e3cba" redrawOnWrite="true"/>
   <PropertyDefinition name="PushedHighlightColor" initialValue="tl:ff1e3cba tr:ff1e3cba bl:ff8fa1ed br:ff8fa1ed" redrawOnWrite="true"/>
   <PropertyDefinition name="HoverHighlightColor" initialValue="ff131352" redrawOnWrite="true"/>
   <Property name="Font" value="ArialBold-8"/>
   <ImagerySection name="icon">
      <ImageryComponent>
         <Area>
            <AreaProperty name="ImageAreaRect" />
         </Area>
         <ImageProperty name="IconImage" />
         <VertFormatProperty name="VertImageFormatting" />
         <HorzFormatProperty name="HorzImageFormatting"/>
      </ImageryComponent>
   </ImagerySection>
   <ImagerySection name="label">
      <TextComponent>
         <Area>
            <AreaProperty name="TextAreaRect" />
         </Area>
         <Text/>
         <VertFormatProperty name="VertTextFormatting" />
         <HorzFormatProperty name="HorzTextFormatting" />
      </TextComponent>
   </ImagerySection>
   <StateImagery name="Normal">
      <Layer>
         <Section look="ProcerusLook/Button" section="ButtonFace" />
         <Section look="ProcerusLook/Button" section="HighlightNormal" />
         <Section section="icon" />
         <Section section="label" />
      </Layer>
   </StateImagery>
   <StateImagery name="Hover">
      <Layer>
         <Section look="ProcerusLook/Button" section="ButtonFace" />
         <Section look="ProcerusLook/Button" section="HighlightNormal" />
         <Section look="ProcerusLook/Button" section="HoverHighlight" />
         <Section section="icon" />
         <Section section="label" />
      </Layer>
   </StateImagery>
   <StateImagery name="Pushed">
      <Layer>
         <Section look="ProcerusLook/Button" section="ButtonFace" />
         <Section look="ProcerusLook/Button" section="HighlightPushed" />
         <Section section="icon" />
         <Section section="label" />
      </Layer>
   </StateImagery>
   <StateImagery name="PushedOff">
      <Layer>
         <Section look="ProcerusLook/Button" section="ButtonFace" />
         <Section look="ProcerusLook/Button" section="HighlightNormal" />
         <Section section="icon" />
         <Section section="label" />
      </Layer>
   </StateImagery>
   <StateImagery name="Disabled">
      <Layer>
         <Section look="ProcerusLook/Button" section="ButtonFace" >
            <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
         </Section>
         <Section look="ProcerusLook/Button" section="HighlightNormal" >
            <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
         </Section>
         <Section look="ProcerusLook/Button" section="HoverHighlight" >
            <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
         </Section>
         <Section section="icon" >
            <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
         </Section>
         <Section section="label" >
            <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
         </Section>
      </Layer>
   </StateImagery>
</WidgetLook>


It works fine when one of these is instantiated from a layout file:

Code: Select all

<Window Type="ProcerusLook/IconButton" Name="ModeButtons/UAVModes/TestButton2" >
   <Property Name="Font" Value="ArialBold-10" />
   <Property Name="Text" Value="Stuff" />
   <Property Name="IconImage" Value="set:ProcerusLook image:SplitButton" />
   <Property Name="VertImageFormatting" Value="CentreAligned" />
   <Property Name="HorzImageFormatting" Value="CentreAligned" />
   <Property Name="ImageAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
   <Property Name="VertTextFormatting" Value="CentreAligned" />
   <Property Name="HorzTextFormatting" Value="CentreAligned" />
   <Property Name="TextAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
   <Property Name="Tooltip" Value="Go to GPS Home" />
   <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
   <Property Name="UnifiedPosition" Value="{{0.0,0},{0.0,0.0}}" />
   <Property Name="UnifiedSize" Value="{{0,54},{0,60}}" />
</Window>


But it does not work when I try to define this as a child control in a looknfeel file:

Code: Select all

<Child type="ProcerusLook/IconButton" nameSuffix="__auto_dd_button__">
   <Area>
      <Dim type="LeftEdge" >
         <AbsoluteDim value="0" />
      </Dim>
      <Dim type="TopEdge" >
         <AbsoluteDim value="0" />
      </Dim>
      <Dim type="Width" >
         <AbsoluteDim value="50"/>
      </Dim>
      <Dim type="Height" >
         <AbsoluteDim value="50"/>
      </Dim>
   </Area>
   <Property Name="Text" Value="Stuff" />
   <Property Name="IconImage" Value="set:ProcerusLook image:SplitButton" />
   <Property Name="VertImageFormatting" Value="CentreAligned" />
   <Property Name="HorzImageFormatting" Value="CentreAligned" />
   <Property Name="ImageAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
   <Property Name="VertTextFormatting" Value="CentreAligned" />
   <Property Name="HorzTextFormatting" Value="CentreAligned" />
   <Property Name="TextAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
</Child>


The button does show up but there is not an image on it. Also if I try to put text on it, that doesn't work either. I am confused why it works from the layout file but not as a child within another control. I'm stumped at the moment and any help would be appreciated. I realize there are several details I have not included. Please let me know what I can elaborate on.

Thanks!

PS Here is the complete snippet of the parent control from the looknfeel file. This control is a "SplitButton" and I used Combobox for inspiration.

Code: Select all

<!--
***************************************************
    ProcerusLook/SplitButton
***************************************************
-->
<WidgetLook name="ProcerusLook/SplitButton">
   <Child  type="ProcerusLook/Button" nameSuffix="__auto_primary_button__">
      <Area>
         <Dim type="LeftEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="TopEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="RightEdge" >
            <UnifiedDim scale="1" type="RightEdge">
               <DimOperator op="Subtract">
                  <FontDim type="LineSpacing" padding="10" />
               </DimOperator>
            </UnifiedDim>
         </Dim>
         <Dim type="Height" >
            <FontDim type="LineSpacing" padding="10" />
         </Dim>
      </Area>
   </Child>
   <Child  type="TaharezLook/ComboDropList" nameSuffix="__auto_droplist__">
      <Area>
         <Dim type="LeftEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="TopEdge" >
            <WidgetDim widget="__auto_primary_button__" dimension="BottomEdge" />
         </Dim>
         <Dim type="Width" >
            <UnifiedDim scale="1" type="Width" />
         </Dim>
         <Dim type="BottomEdge" >
            <UnifiedDim scale="1" type="BottomEdge" />
         </Dim>
      </Area>
   </Child>
   <Child type="ProcerusLook/IconButton" nameSuffix="__auto_dd_button__">
      <Area>
         <Dim type="LeftEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="TopEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="Width" >
            <AbsoluteDim value="50"/>
         </Dim>
         <Dim type="Height" >
            <AbsoluteDim value="50"/>
         </Dim>
      </Area>
      <Property Name="Text" Value="Stuff" />
      <Property Name="IconImage" Value="set:ProcerusLook image:SplitButton" />
      <Property Name="VertImageFormatting" Value="CentreAligned" />
      <Property Name="HorzImageFormatting" Value="CentreAligned" />
      <Property Name="ImageAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
      <Property Name="VertTextFormatting" Value="CentreAligned" />
      <Property Name="HorzTextFormatting" Value="CentreAligned" />
      <Property Name="TextAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
   </Child>
   <StateImagery name="Enabled" />
   <StateImagery name="Disabled" />
</WidgetLook>
Last edited by HorizonDefeated on Thu Feb 18, 2010 16:22, edited 1 time in total.

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

Re: Child controls

Postby CrazyEddie » Wed Feb 17, 2010 11:13

Hi,

Annoying issue :)

Now, I think this could be some kind of bug related to the size of the areas (those sourced from properties ImageAreaRect and TextAreaRect) not getting updated properly. As a test, if you subsequently resize the parent widget, does the image and text pop into view?

CE.

HorizonDefeated
Just popping in
Just popping in
Posts: 19
Joined: Tue Feb 16, 2010 00:17

Re: Child controls

Postby HorizonDefeated » Wed Feb 17, 2010 16:30

I tried resizing both the SplitButton and the IconButton child itself. No luck yet. I'll keep looking, but look forward to any word.

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

Re: Child controls

Postby CrazyEddie » Thu Feb 18, 2010 09:32

Ok, thanks for testing that. I'll run a couple of tests myself, and see if I can reproduce this issue; I can't see anything particularly wrong with the XML you posted, so at the moment I'm operating on the assumption that this is actually a bug in our code - though I'll let you know for sure once I've run some tests...

CE.

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

Re: Child controls

Postby CrazyEddie » Thu Feb 18, 2010 11:09

Hi :)

I tested this, reproduced the issue, and then after some head scratching, realised where the issue was...

There is an inconsistency as regards to the capitalisation requirement for attribute names in the XML between layouts and the looknfeel. So, in the child definition for the icon button, where you have:

Code: Select all

<Child>
   ...
   <Property Name="Text" Value="Stuff" />
   <Property Name="IconImage" Value="set:ProcerusLook image:SplitButton" />
   <Property Name="VertImageFormatting" Value="CentreAligned" />
   <Property Name="HorzImageFormatting" Value="CentreAligned" />
   <Property Name="ImageAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
   <Property Name="VertTextFormatting" Value="CentreAligned" />
   <Property Name="HorzTextFormatting" Value="CentreAligned" />
   <Property Name="TextAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
</Child>


The attributes 'Name' and 'Value', need to be changed to 'name' and 'value'. So, sorry I did not spot this immediately - it's very easy to overlook ;) I already have an intention to relax this at some stage in the future so that (at least for non xerces-c++ use) attribute names are case insensitive.

CE.

HorizonDefeated
Just popping in
Just popping in
Posts: 19
Joined: Tue Feb 16, 2010 00:17

Re: Child controls

Postby HorizonDefeated » Thu Feb 18, 2010 16:21

CE,

Awesome! Worked like a charm.

Yes, I had no idea about the case change, for some reason I was assuming it was the same as the .layout. I was able to solve some other issues I was seeing (I'll start a new thread about that) and I was just getting back to this, so thanks again! I'm not sure how long it would have taken me to realize such a simple mistake :)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 6 guests