Scrollable Pane Child Windows not Offsetting

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

User avatar
malachy1681
Just popping in
Just popping in
Posts: 19
Joined: Thu Sep 01, 2005 05:29
Contact:

Scrollable Pane Child Windows not Offsetting

Postby malachy1681 » Fri Sep 09, 2005 12:18

Okay, I have a frame window with a scrollable pane as a child. Then I have a tab control as a child of the scrollable pane, but when I set an offset (either absolute or relative) the tab control always lines up at 0, 0 relative to the scrollable pane. I'm using the source download of 0.4.0 and the Falagard system. Any help here would be greatly appreciated.

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

Re: Scrollable Pane Child Windows not Offsetting

Postby CrazyEddie » Fri Sep 09, 2005 20:15

I think you're seeing the pane "auto size" itself.

By default, if the total content does not exceed the bounds of the viewing pane, the position/size will auto-adjust so that the content appears as if to be at (0,0).

You either need to add content that exceeds the size of the view area, or disable the auto-sizing of the content pane via setContentPaneAutoSized, and then get the content pane, and set its size explicitly.

User avatar
malachy1681
Just popping in
Just popping in
Posts: 19
Joined: Thu Sep 01, 2005 05:29
Contact:

Re: Scrollable Pane Child Windows not Offsetting

Postby malachy1681 » Sat Sep 10, 2005 01:19

Well, now the problem I'm having is that 'getContentPane' returns a const pointer which doesn't allow me to set its size.

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

Re: Scrollable Pane Child Windows not Offsetting

Postby CrazyEddie » Sat Sep 10, 2005 08:08

Yeah, my mistake :)

What you want is ScrollablePane::setContentPaneArea

User avatar
malachy1681
Just popping in
Just popping in
Posts: 19
Joined: Thu Sep 01, 2005 05:29
Contact:

Re: Scrollable Pane Child Windows not Offsetting

Postby malachy1681 » Sat Sep 10, 2005 12:53

Okay, got it all worked out now. Thanks a million! :D

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: Scrollable Pane Child Windows not Offsetting

Postby Van » Wed Sep 28, 2005 22:56

Hmmm. I'm having the same problem. I am trying to display some StaticImage windows inside a ScrollablePane (icons) and the scrollable pane keeps stacking my Icons, even after I do the above..

Here is where I create the pane:

Code: Select all

   mInventoryWindow = (CEGUI::ScrollablePane *)mWinMgr->createWindow(
      (CEGUI::utf8*)CEGUILOOK"/ScrollablePane", (CEGUI::utf8*)mStr);

   mInventoryWindow->setMetricsMode(CEGUI::Absolute);
   mInventoryWindow->setPosition(CEGUI::Absolute, CEGUI::Point(10.0f, 30.00f) );
   mInventoryWindow->setSize(CEGUI::Absolute,
      CEGUI::Size(mFrameWindow->getAbsoluteWidth() - 10.0f, mFrameWindow->getAbsoluteHeight() - 40.0f) );
   mInventoryWindow->setVisible(true);
   mInventoryWindow->setContentPaneAutoSized(false);

   
   mInventoryWindow->setContentPaneArea(
      CEGUI::Rect( CEGUI::Point(10.0f, 30.00f),
      CEGUI::Size(mFrameWindow->getAbsoluteWidth() - 10.0f, mFrameWindow->getAbsoluteHeight() - 40.0f) ) );



and here is where I try to align my icons.

Code: Select all

   for (mCount = 0; mCount < mChildCount; mCount++ )
   {
      mChild = mInventoryWindow->getChildAtIdx(mCount);
      if ( !mChild ) break;

      mChild->setPosition(CEGUI::Absolute, CEGUI::Point(mCol * 60.0f, mRow * 60.0f) );
      
      mCol++;
      if (mCol > mMaxCol )
      {
         mRow++;
         mCol = 0;
      }
   } // for


Now, if I use DefaultWindow instead of ScrollablePane, my icons align without a problem. It only occurs when I use the scrollable pane type window.

Any suggestions?

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

Re: Scrollable Pane Child Windows not Offsetting

Postby CrazyEddie » Thu Sep 29, 2005 09:43

The way that ScrollablePane is implemented means that the windows that you attach do not get added to the ScrollablePane itself, but rather to an attached 'ContentPane' window. So you'll need to get that window, and perform from there (since that's where your icons are really attached).

ScrollablePane::getContentPane will return you this window.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: Scrollable Pane Child Windows not Offsetting

Postby Van » Thu Sep 29, 2005 13:23

That did it! Works great, thank you!

For future readers:

I changed this line:

Code: Select all

mChild = mInventoryWindow->getChildAtIdx(mCount);


to this line

Code: Select all

mChild = mInventoryWindow->getContentPane()->getChildAtIdx(mCount);



And here is the whole quick and dirty arrange window routine I used:

Code: Select all


void <YOUR CLASS HERE>::WindowInit(void)
{
  ...
     mInventoryWindow = (CEGUI::ScrollablePane *)mWinMgr->createWindow(
      (CEGUI::utf8*)CEGUILOOK"/ScrollablePane", (CEGUI::utf8*)mStr);

   mInventoryWindow->setMetricsMode(CEGUI::Absolute);
   mInventoryWindow->setPosition(CEGUI::Absolute, CEGUI::Point(10.0f, 30.00f) );
   mInventoryWindow->setSize(CEGUI::Absolute,
      CEGUI::Size(mFrameWindow->getAbsoluteWidth() - 10.0f, mFrameWindow->getAbsoluteHeight() - 40.0f) );
   mInventoryWindow->setVisible(true);
   mInventoryWindow->setContentPaneAutoSized(false);
   mInventoryWindow->setContentPaneArea(
      CEGUI::Rect( CEGUI::Point(10.0f, 30.00f),
      CEGUI::Size(mFrameWindow->getAbsoluteWidth() - 10.0f, mFrameWindow->getAbsoluteHeight() - 40.0f) ) );

 ...

} // WindowInit


void <YOUR CLASS HERE>::arrangeItems(void)
{
   if ( !mInventoryWindow ) return;
   if ( mInventoryWindow->getContentPane()->getChildCount() < 1 ) return;
   
   unsigned int mChildCount=0, mCount=0, mRow=0, mCol=0, mMaxCol=0;
   float mFCol=0.0f;
   CEGUI::Window *mChild=NULL;

   mFCol = mInventoryWindow->getContentPaneArea().getWidth() / 60.0f;
   mMaxCol = mFCol;
   mFCol = mFCol - mMaxCol;
   if ( mFCol > 0.0f ) mMaxCol--;
   if ( mMaxCol < 1 ) mMaxCol = 1;

   mChildCount = mInventoryWindow->getContentPane()->getChildCount();

   for (mCount = 0; mCount < mChildCount; mCount++ )
   {
      mChild = mInventoryWindow->getContentPane()->getChildAtIdx(mCount);
      if ( !mChild ) break;

      mChild->setPosition(CEGUI::Absolute, CEGUI::Point(mCol * 60.0f, mRow * 60.0f) );
      
      mCol++;
      if (mCol > mMaxCol )
      {
         mRow++;
         mCol = 0;
      }
   } // for
} // arrangeItems


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 7 guests