Scrollbars on StaticText

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
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Sat Aug 21, 2004 15:17

Hehe, well its something I really should have spotted myself, so I'll put 'splinter' back in the cupboard now :P

Yup, it solves it. I have just now made a nice tab pane with two different tabs attached. Very cool, thanks again to you and Sinbad for this.

There may be a little bug remaining with the tab selection though, I think.
On app initialisation, the tab control looks fine; both tab buttons are there and so is the correct content in the content pane.
If I click on the second tab, it switches the content pane as expected. But click on the first again MORE THAN ONCE, and the second tab button disappears. Clicking back on the space where the second tab button was, it reappears. Clicking on each button on and off makes the second tab button come and go, sometimes it doesnt display again.

Heres a pic of what Im talking about:

Image

Heres the code:

Code: Select all

   StaticText* TabTestPanel1 = (StaticText*)WindowManager::getSingleton().createWindow((utf8*)"Taharez StaticText", (utf8*)"Tab Test Panel 1");
   TabTestPanel1->setPosition(Point(0.01f, 0.1f));
   TabTestPanel1->setSize(Size(0.96f, 0.82f));
   TabTestPanel1->setFrameEnabled(false);
   TabTestPanel1->setBackgroundEnabled(false);
   TabTestPanel1->setText( (utf8*) "BOB");

   StaticText* TabTestPanel2 = (StaticText*)WindowManager::getSingleton().createWindow((utf8*)"Taharez StaticText", (utf8*)"Tab Test Panel 2");
   TabTestPanel2->setPosition(Point(0.01f, 0.1f));
   TabTestPanel2->setSize(Size(0.96f, 0.82f));
   TabTestPanel2->setFrameEnabled(false);
   TabTestPanel2->setBackgroundEnabled(false);
   TabTestPanel2->setText( (utf8*) "BOBs brother");

   TabControl* testTab = (TabControl*)winMgr.createWindow((utf8*)"Taharez Tab Control", (utf8*)"test tab control");
   testTab->setPosition(Point(0.1f, 0.5f));
   testTab->setSize(Size(0.4f, 0.4f));
   testTab->addTab(TabTestPanel1);
   testTab->addTab(TabTestPanel2);
   testTab->setSelectedTab( (utf8*) "Tab Test Panel 1");
   testTab->setTabHeight(0.2f);

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

Scrollbars on StaticText

Postby CrazyEddie » Sat Aug 21, 2004 19:42

Okay, thanks for the report. I'll take a look at it tomorrow probably :)

CE.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Sat Aug 21, 2004 20:00

Cool, cheers man :)

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

Scrollbars on StaticText

Postby CrazyEddie » Sun Aug 22, 2004 10:15

I checked into this and it all works okay here. Do you have other GUI stuff on the screen at the same time? If so, the only thing I can think of is that you could be hitting the quad limit specified when you created the GUI Renderer object.

Very soon I'm going to write some replacement renderers that have no limits like this and do some performance tests - if things are okay these new renderers will replace the current ones and remove the need to specify a 'maximum quad count'.

Anyway, let me know if this is/isn't the cause of the issue and if need be I'll do some more digging :)

CE.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Sun Aug 22, 2004 11:00

I checked into this and it all works okay here. Do you have other GUI stuff on the screen at the same time? If so, the only thing I can think of is that you could be hitting the quad limit specified when you created the GUI Renderer object.


Yeah, I do have quite a few other stuff on screen, but not a massive amount. I increased my number of quads by 1000, but unfortunately it made no difference.

I did some more tests. I attached the tab control directly to my 'DefaultGUISheet', in case other panels underneath my previous attempt were interfering. I also added a third tab to the control, and made it a bit bigger. I still get the same problem; heres what happened in three steps:

When initialised, looks fine.
Image

I click on the second tab button, and it does what it should.
Image

I click on the third tab button...and it gets shifted along!?
Image

So it appears that my tabs areant disappearing at all, they are simply getting shifted along incorrectly. Its lucky that I made my tab size larger than it was, otherwise I wouldnt have seen this behaviour.

Still, this is a bit strange how neither you nor Sinbad seem to have come across this problem. Anyway, I hope this helps you find the problem, and thanks for looking into this for me!

EDIT: I hope this isnt some sort of sick joke...it reminds me of those trick VB apps where you try clicking on the button but it keeps running away hehe.

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

Scrollbars on StaticText

Postby CrazyEddie » Sun Aug 22, 2004 12:45

I hope this isnt some sort of sick joke...it reminds me of those trick VB apps where you try clicking on the button but it keeps running away hehe.

:lol: How'd you guess!? Now you've spoilt our fun :(

Seriously though, I have just managed to reproduce the problem :) Expect a fix as soon as I work out how it all works :D

CE.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Sun Aug 22, 2004 13:07

Woohoo! :D

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

Scrollbars on StaticText

Postby CrazyEddie » Sun Aug 22, 2004 14:18

I'm about to commit a fix for this to CVS. I have also fixed another minor issue relating to the 'fill' imagery (from the end of the last tab to the right edge of the widget).

Here's the patch:

Code: Select all

Index: WidgetSets/TaharezLook/src/TLTabControl.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/WidgetSets/TaharezLook/src/TLTabControl.cpp,v
retrieving revision 1.1
diff -u -r1.1 TLTabControl.cpp
--- WidgetSets/TaharezLook/src/TLTabControl.cpp   19 Aug 2004 12:14:04 -0000   1.1
+++ WidgetSets/TaharezLook/src/TLTabControl.cpp   22 Aug 2004 14:13:01 -0000
@@ -93,17 +93,22 @@
         if (d_tabButtonPane)
         {
             // Calculate the positions and sizes of the tab buttons
+         d_fillerSize.d_width = d_tabButtonPane->getWidth(Absolute);
+         d_fillerSize.d_height = d_fillerImage->getHeight();
             d_fillerPos.d_x = d_tabButtonPane->getAbsoluteXPosition();
-            d_fillerPos.d_y = d_tabButtonPane->getAbsoluteYPosition() + d_abs_tabHeight - 1; // 1 pixel filler
-            d_fillerSize.d_width = d_tabButtonPane->getWidth(Absolute);
-            d_fillerSize.d_height = 1;
-            for (uint i = 0; i < getTabCount(); ++i)
-            {
-                Window* btn = d_tabButtonPane->getChildAtIdx(i);
-                d_fillerPos.d_x = d_tabButtonPane->getAbsoluteXPosition() +
-                    btn->getAbsoluteXPosition() + btn->getWidth(Absolute);
-            }
-            d_fillerSize.d_width -= d_fillerPos.d_x;
+            d_fillerPos.d_y = d_tabButtonPane->getAbsoluteYPosition() + d_tabButtonPane->getAbsoluteHeight() - d_fillerSize.d_height;
+
+         if (getTabCount() > 0)
+         {
+            TabButtonIndexMap::iterator iter = d_tabButtonIndexMap.end();
+            std::advance(iter, -1);
+            Window* btn = iter->second;
+
+            d_fillerPos.d_x = d_tabButtonPane->getAbsoluteXPosition() +
+               btn->getAbsoluteXPosition() + btn->getWidth(Absolute);
+
+            d_fillerSize.d_width -= d_fillerPos.d_x;
+         }
 
         }
 
Index: src/elements/CEGUITabControl.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/src/elements/CEGUITabControl.cpp,v
retrieving revision 1.1
diff -u -r1.1 CEGUITabControl.cpp
--- src/elements/CEGUITabControl.cpp   19 Aug 2004 12:14:08 -0000   1.1
+++ src/elements/CEGUITabControl.cpp   22 Aug 2004 14:13:01 -0000
@@ -338,7 +338,7 @@
 
 }
 /*************************************************************************
-Add tab button
+   Calculate size and position for a tab button
 *************************************************************************/
 void TabControl::calculateTabButtonSizePosition(TabButton* btn, uint targetIndex)
 {
@@ -349,8 +349,11 @@
     // x position is based on previous button
     if (targetIndex > 0)
     {
-        Window* prevButton = d_tabButtonPane->getChildAtIdx(targetIndex - 1);
-        // position is prev pos + width
+      TabButtonIndexMap::iterator iter = d_tabButtonIndexMap.begin();
+      std::advance(iter, targetIndex - 1);
+      Window* prevButton = iter->second;
+
+      // position is prev pos + width
         btn->setXPosition(Relative,
             prevButton->getXPosition(Relative)
             + prevButton->getWidth(Relative));
@@ -365,7 +368,6 @@
     btn->setWidth(Absolute,
         fnt->getTextExtent(btn->getText()) + getAbsoluteTabTextPadding()*2);
     btn->requestRedraw();
-
 }
 /*************************************************************************
 Remove tab button


HTH

CE.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Sun Aug 22, 2004 15:27

The support round here is exceptional. Thank you very much!

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Mon Aug 23, 2004 09:45

Just some feedback to say that the tab control is working as expected now, thanks again for your ultra speedy help :)

For future reference, or just as my personal feedback, I have some comments on this new widget:

1) Setting the Tab button text (title)

At the moment, the tab buttons take their title from the text within the tab you have added. The user may not actually want to supply the tab with any text, but if they don’t then the tab button will be blank.

This could really do with a tabButton->setTitle("String") method, or even modify the addTab method slightly, something like addTab( panel, String "TabButtonTitle") would do nicely.

2) Tab Button and Tab Contentpane imagery

Currently the Taharez tab control is drawn similar to a standard Taharez StaticText widget. Unfortunately, there doesn’t seem to be a way to use methods similar to what StaticText uses, such as setFrameEnabled or enableBackground. Basically, it would be nice to be able to customise it much more.

Ideally, it would be cool if the user could, through code, easily change the imagery of the tab control, in a similar fashion to what you can do with the push buttons. I think you said that you were going to introduce a change to make it easier for users to modify all widget imagery anyway, so this is probably a void point.


Anyway, that’s just my thoughts. I understand Sinbad said that he simply created a basic implementation ("without any bells or whistles"), so if in the future you decide to add those bells and whistles, then these are my suggestions.

Cheers :)

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

Scrollbars on StaticText

Postby CrazyEddie » Mon Aug 23, 2004 10:34

Thanks for the ideas :)

Some of these ideas, along with some other bits (the "bells and whistles"), will likely be put in when I do the 'second batch' of widgets (and released as beta-2). This was when the tab widget was originally going to be written anyway, sinbad's contribution has enabled us all to get the use of this widget much earlier than would otherwise have been so :)

The planned data-driven rendering enhancements will be a huge asset for the system, though these changes are off in the future somewhere (maybe for a beta-3 or possibly a beta-4 release depending on what happens).

And now to magically bring the thread back on-topic ;) I'm hoping to get those scrollbars on the static text widget sometime on Wednesday; I had wanted to do it earlier but things don't always work out that way. I have added line-break support though; this ended up being done in the Font class itself, which means that everything now supports this. Some widgets may need some minor updates to the rendering code so that they properly handle >1 line of text.

CE.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Mon Aug 23, 2004 11:15

Thanks for the ideas :)


No probs!

Some of these ideas, along with some other bits (the "bells and whistles"), will likely be put in when I do the 'second batch' of widgets (and released as beta-2). This was when the tab widget was originally going to be written anyway, sinbad's contribution has enabled us all to get the use of this widget much earlier than would otherwise have been so :)


Hehe, yeah I know, dont worry I wasnt hinting otherwise ;)

The planned data-driven rendering enhancements will be a huge asset for the system, though these changes are off in the future somewhere (maybe for a beta-3 or possibly a beta-4 release depending on what happens).


Cool. Will definately be a great addition.

And now to magically bring the thread back on-topic ;) I'm hoping to get those scrollbars on the static text widget sometime on Wednesday; I had wanted to do it earlier but things don't always work out that way. I have added line-break support though; this ended up being done in the Font class itself, which means that everything now supports this. Some widgets may need some minor updates to the rendering code so that they properly handle >1 line of text.


What, we were off topic? Oh yeah, funny how that happens :)
The scrollbars on the static text will be fantastic! Looking forward to them (it sure will help solve a lot of space issues we are having).

Cheers

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

Scrollbars on StaticText

Postby CrazyEddie » Wed Aug 25, 2004 10:40

Work to add scroll bars on the static text widget is now completed. CVS has a five hour sync time, although the snapshots should have the code now.

There is still a couple of bits that could be added; for example there is currently no interface to control the scroll bar position within your code, though this can be done by getting access to the scrollbars and changing the position that way. I'll probably go back at some stage and add something like this properly though.

To use the scroll bars you just have to enable them, everything else is automatic.

Code: Select all

myStatic->setVerticalScrollbarEnabled(true);

and/or

myStatic->setHorizontalScrollbarEnabled(true);


or from within your layout file, like this:

Code: Select all

<Window Type="Taharez StaticText" Name="Sample StaticText">
   <Property Name="Position" Value="x:0.05 y:0.1" />
   <Property Name="RelativeMaxSize" Value="w:1 h:1" />
   <Property Name="Size" Value="w:0.9 h:0.3" />
   <Property Name="HorzFormatting" Value="LeftAligned" />
   <Property Name="VertFormatting" Value="TopAligned" />
   <Property Name="VertScrollbar" Value="True" />
   <Property Name="HorzScrollbar" Value="True" />
   <Property Name="Text" Value="Sample of how to use scrollbars in static text!" />
</Window>


Let me know when you find bugs ;)

CE.

User avatar
psyclonist
Just popping in
Just popping in
Posts: 9
Joined: Wed Jan 12, 2005 12:06
Contact:

Scrollbars on StaticText

Postby psyclonist » Wed Aug 25, 2004 18:41

"ease of use" is the keyword here. Great work!

-psy

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Scrollbars on StaticText

Postby spannerman » Wed Aug 25, 2004 21:39

The newline and the vertical / horizontal scrollbers for StaticText are working perfectly here! 8)

Great work, cheers :)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 1 guest