delta3d
 Forum Index >  > delta3d Support New Topic Post Reply
 CEGUI: Can't get combox items to appear
Prev Topic Next Topic
   
asjt3
 10/25/2010 03:17PM (Read 2850 times)  

Chatty

Status: offline
Forum User

Registered: 05/29/2009
Posts: 68
Hey guys,

This is a question pertaining to CEGUI. I'm using the following code in an xml layout file to try and populate a droplist. I can't seem to get the items to appear in the list, as of now it is blank.

Before when I was creating the GUI at runtime, I just used Combobox along with ListBoxTextItem and it worked.

As you can see, for the first listbox item I tried setting different property values to make it visible, but to no avail. any ideas?

Thanks,

alex


PHP Formatted Code
<Window Type='TaharezLook/Static' Name='Cam Panel'>
      <Property Name='UnifiedAreaRect' Value='{{0.000000,0.000000},{0.0,0.000000},{1.0,0.000000},{0.3,0.000000}}'/>
      <Property Name='FrameEnabled' Value='false'/>

      <Window Type='TaharezLook/Combobox' Name='CamList'>
        <Property Name='ReadOnly' Value='true'/>
        <Property Name='FrameEnabled' Value='false'/>
        <Property Name='UnifiedAreaRect' Value='{{0.000000,0.000000},{0.0,0.000000},{1.0,0.000000},{1.0,0.000000}}'/>

        <Window Type ='TaharezLook/ComboDropList' Name='DropList'>
          <Property Name='Visible' Value='true'/>
         
          <Window Type ='TaharezLook/ListboxItem' Name='Port'>
            <Property Name='Text' Value='PORT'/>
            <Property Name='Visible' Value='true'/>
            <Property Name='TextColour' Value='FFFFFF'/>
            <Property Name='AlwaysOnTop' Value='true'/>
          </Window>
         
          <Window Type ='TaharezLook/ListboxItem' Name='Starboard'>
            <Property Name='Text' Value='STBD'/>
          </Window>
     </Window>
  </Window>
  </Window>

 
Profile Email
 Quote
Anonymous: crodgers
 10/26/2010 10:31AM  
Hi Alex,

It has been a while since I have used the XML file to create the items of a list-type container, but I am pretty sure such containers require an absolute pixel height to be set on items. From what I can remember, items would be lain out by that dimension without depending on the parent window's height. It seemed that a relative height dimension for items would not work based on how the order of layout calculations are performed between the items and their parent container.

Try inserting this line into your item definition:
PHP Formatted Code
<Property Name="UnifiedSize" Value="{{1.0,0},{0.0,30}}"/>
...so that your item would look something like this:
PHP Formatted Code
          <Window Type ='TaharezLook/ListboxItem' Name='Port'>
            <Property Name="UnifiedSize" Value="{{1.0,0},{0.0,30}}"/>
            <Property Name='Text' Value='PORT'/>
            <Property Name='Visible' Value='true'/>
            <Property Name='TextColour' Value='FFFFFF'/>
            <Property Name='AlwaysOnTop' Value='true'/>
          </Window>
 
Within the value {{1.0,0},{0.0,30}}, the first set {1.0,0} pertains to the width dimension, and the second set {0.0,30} thus pertains to the height dimension.

Within each pair, the first number (usually somewhere between 0.0 to 1.0) is the relative size ratio to its parent window; so in this case the 1.0 means the item should take on the full width of the parent combobox.

The second number in a pair is an absolute pixel dimension/offset; so in this case the height is 30 pixels (it is independent of the parent dimension but is dependent on the screen resolution).

If inserting that code does not fix the problem and you are certain your code is correct, you may want to visit the CEGUI forums for help on this. The sample line of code posted here was pulled from an earlier version of one of my XML files that had Item Entry items declared for an Item Listbox rather than for a Combo Drop List (so there may be some nuances differentiating the two container types).

Hope this helps you out Alex

Chris
 
 Quote
asjt3
 10/27/2010 02:08PM  

Chatty

Status: offline
Forum User

Registered: 05/29/2009
Posts: 68
Thanks for the reply Chris, unfortunately the solution didn't work . I'll try posting on CEGUI forums.

Thanks,

alex
 
Profile Email
 Quote
asjt3
 10/29/2010 11:12AM  

Chatty

Status: offline
Forum User

Registered: 05/29/2009
Posts: 68
Thanks for the reply Chris, unfortunately the solution didn't work . I'll try posting on CEGUI forums.

Thanks,

alex
 
Profile Email
 Quote
keltie
 03/23/2011 04:39AM  

Regular Poster

Status: offline
Forum User

Registered: 02/13/2005
Posts: 115
Hi Alex,

Wondering if you got this resolved?

I am trying to implement a Combobox via a layout file as well with mixed results. Listbox works fine but not the visual I want.

Cheers

/ ... .... .. - / .... .- .--. .--. . -. . -..
 
Profile Email Website
 Quote
asjt3
 03/28/2011 03:43PM  

Chatty

Status: offline
Forum User

Registered: 05/29/2009
Posts: 68
Quote by keltie: Hi Alex,

Wondering if you got this resolved?

I am trying to implement a Combobox via a layout file as well with mixed results. Listbox works fine but not the visual I want.

Cheers


No, unfortunately not resolved and apparently not possible. Please see this thread on CEGUI forums

-Alex
 
Profile Email
 Quote
keltie
 03/31/2011 02:06AM  

Regular Poster

Status: offline
Forum User

Registered: 02/13/2005
Posts: 115
Hi Alex,

Thanks for that info & link. I have to say the response on the CEGUI forum sounded a bit confusing, probably largely due to some of the class names being very similar.

So, until updates in CEGUI make it simpler still, I thought I would post back my findings as I was close to giving up even on the Combobox created entirely in code.

I also referred to some another posts and may help clarify parts of these topics too.
'Problem with getID()' for a ListboxTextItem
'ComboDropList' not displaying

I have used a combination of layout xml and the api to achieve a combobox to my needs. The Combobox is declared/defined in the layout file, the ListboxTextItem uses a helper class (from the CEGUI samples: demo7, not required but neater). The list in my case is populated from found objects only but could be of a fixed size.

From testInputDI.layout
PHP Formatted Code

<Window Type="WindowsLook/Combobox" Name="Device Selection ComboBox" >
 <Property Name="Text" Value="Select a Device" />
 <Property Name='ReadOnly' Value='true'/>
 <Property Name='AlwaysOnTop' Value='true'/>
 <Property Name="UnifiedSize" Value="{{0.7,0},{0.5,0}}"/>
 <Property Name="UnifiedPosition" Value="{{0.02,0},{0.2,0}}"/>
 <Property Name='ClippedByParent' Value='false'/>
</Window>
 


And my cpp file
PHP Formatted Code

// Sample sub-class for ListboxTextItem that auto-sets the selection brush
// image.  This saves doing it manually every time in the code.
// Ammended slightly to pass user ID data as an index to use in handling selections

class GUIListItem : public CEGUI::ListboxTextItem
{
public:
   GUIListItem(const CEGUI::String& text, CEGUI::uint id) : ListboxTextItem(text, id)
   {
      CEGUI::ListboxItem::setSelectionBrushImage("WindowsLook", "MultiListSelectionBrush");
      CEGUI::ListboxTextItem::setTextColours(CEGUI::colour(0.f, 0.f, 0.f, 1.f));
   }
};


I found an issue with WindowsLook and MultiListSelectionBrush in that the file 'WindowsLook.imageset' has the following entry:
PHP Formatted Code

<Image Name="MultiListSelectionBrush" XPos="9" YPos="71" Width="14" Height="14" />

Changed to:

<Image Name="MultiListSelectionBrush" XPos="20" YPos="20" Width="14" Height="14" />

The original coordinates cover some imagedata in WindowsLook.tga that will give a strange blurred effect as could have been described in: 'ComboDropList' not displaying. It looks like a cut'n'paste line from TaharezLook.imageset in which the coords cover clear space in the TaharezLook.tga image. The new coords above cover clear space in the WindowsLook.tga image.

The following is one method of populating the list
PHP Formatted Code

// Create, add to combobox and set item text field from found device friendly names

void GUIListItemInit(void)
{
   mDeviceSelectionCombobox = static_cast<CEGUI::Combobox*>
      (mUIDrawable->GetWidget("Device Selection ComboBox"));

   for (int i = 0; i < dtInputDI::DirectInput::GetNumDIDevices(); i++)
   {
      if (dtInputDI::DirectInput::GetDIDeviceList(i) != NULL)
      {
         std::ostringstream deviceName;
         deviceName << dtInputDI::DirectInput::GetDIDeviceInstanceList(i)->tszProductName;
         
         mDeviceSelectionCombobox->addItem(new GUIListItem(deviceName.str(), i));
      }
   }
}


And one way of handling the selection. This should cover the issue in 'Problem with getID()' for a ListboxTextItem
PHP Formatted Code

// Subscribe handler that processes changes to the itemlistbox selection state

void GUIEventWiring(void)
{
   mDeviceSelectionCombobox->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,
   CEGUI::Event::Subscriber(&TestInputDIApp::HandleChangeDeviceSelectionCombobox, this));
}


// Listens for and acts upon itemlistbox selections

bool HandleChangeDeviceSelectionCombobox(const CEGUI::EventArgs& e)
{
   if(mDeviceSelectionCombobox->getItemCount() > 0)
   {
      if(mDeviceSelectionCombobox->getSelectedItem() != NULL)
      {
         int itemIndex = mDeviceSelectionCombobox->getSelectedItem()->getID();

         if (dtInputDI::DirectInput::GetDIDeviceList(itemIndex) !=NULL )
         {
            mAppJoystick = dtInputDI::Joystick::GetInstance(itemIndex);
            MapDeviceInfo(mAppJoystick);
         }
      }
   }
   return true;
}


Hope this helps someone in the same boat

/ ... .... .. - / .... .- .--. .--. . -. . -..
 
Profile Email Website
 Quote
Content generated in: 1.33 seconds New Topic Post Reply
 All times are UTC. The time is now 08:30 AM.
Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 

About delta3d

delta3d is a game and simulation engine appropriate for a wide variety of simulation and entertainment applications. delta3d uses best-of-breed open source technologies to create a fully integrated game engine and with content creation tools.MORE

Twitter

User Functions





Don't have an account yet? Sign up as a New User!

Lost your password?