Page 1 of 1

Scrollable Pane Child Windows not Offsetting

Posted: Fri Sep 09, 2005 12:18
by malachy1681
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.

Re: Scrollable Pane Child Windows not Offsetting

Posted: Fri Sep 09, 2005 20:15
by CrazyEddie
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.

Re: Scrollable Pane Child Windows not Offsetting

Posted: Sat Sep 10, 2005 01:19
by malachy1681
Well, now the problem I'm having is that 'getContentPane' returns a const pointer which doesn't allow me to set its size.

Re: Scrollable Pane Child Windows not Offsetting

Posted: Sat Sep 10, 2005 08:08
by CrazyEddie
Yeah, my mistake :)

What you want is ScrollablePane::setContentPaneArea

Re: Scrollable Pane Child Windows not Offsetting

Posted: Sat Sep 10, 2005 12:53
by malachy1681
Okay, got it all worked out now. Thanks a million! :D

Re: Scrollable Pane Child Windows not Offsetting

Posted: Wed Sep 28, 2005 22:56
by Van
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?

Re: Scrollable Pane Child Windows not Offsetting

Posted: Thu Sep 29, 2005 09:43
by CrazyEddie
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.

Re: Scrollable Pane Child Windows not Offsetting

Posted: Thu Sep 29, 2005 13:23
by Van
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