I have a tabcontrol with tabs in it. But I cant see all the tabs. There are two buttons for scrolling the tabs but when I press them nothing happens. I am using Irrlicht 1.5 version.
Can anybody help on this ?
[fixed]TabControl Scrolling
Seems to be a bug, I can reproduce it here. I'll add it to the bugtracker (https://sourceforge.net/tracker/?func=d ... tid=540676).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
It's now fixed in current svn and will also be in Irrlicht 1.6
test:
test:
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
struct SAppContext
{
IrrlichtDevice * device;
array<IGUIElement*> mGuiElements;
};
void AddTestGuiElements(IGUIEnvironment* env, IGUIElement * parent, SAppContext & context)
{
context.mGuiElements.push_back( env->addToolBar (parent, /*s32 id=*/-1) );
core::rect<s32> rect1(10, 40, 10 + 150, 40 + 100);
IGUITabControl * tabctrl = env->addTabControl (rect1, parent, /*bool fillbackground=*/true, /*bool border=*/true, /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab1", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab2", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab3", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab4", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab5", /*s32 id=*/-1);
core::rect<s32> rect2(180, 40, 180 + 150, 40 + 100);
tabctrl = env->addTabControl (rect2, parent, /*bool fillbackground=*/true, /*bool border=*/true, /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab1", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab2", /*s32 id=*/-1);
core::rect<s32> rect3(10, 150, 10 + 150, 150 + 100);
tabctrl = env->addTabControl (rect3, parent, /*bool fillbackground=*/true, /*bool border=*/true, /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"a", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"b", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"c", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"d", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"e", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"f", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"g", /*s32 id=*/-1);
core::rect<s32> rect4(180, 150, 180 + 150, 150 + 100);
tabctrl = env->addTabControl (rect4, parent, /*bool fillbackground=*/true, /*bool border=*/true, /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"how long can tabs be anyway? Give me the max!", /*s32 id=*/-1);
core::rect<s32> rect5(10, 250, 10 + 150, 260 + 100);
tabctrl = env->addTabControl (rect5, parent, /*bool fillbackground=*/true, /*bool border=*/true, /*s32 id=*/-1);
tabctrl->setTabVerticalAlignment(EGUIA_LOWERRIGHT);
tabctrl->addTab(/*const wchar_t *caption*/L"tab1", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab2", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab3", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab4", /*s32 id=*/-1);
tabctrl->addTab(/*const wchar_t *caption*/L"tab5", /*s32 id=*/-1);
context.mGuiElements.push_back( tabctrl );
}
int main()
{
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
SAppContext context;
context.device = device;
AddTestGuiElements(env, 0, context);
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 53
- Joined: Tue May 19, 2009 12:18 am
I have tried your fix but there seems to have another problem.You seem to cut the tab width. why are you doing so ?
I have fixed the same issue with simple swap of pointers in array <CGUITAB*>Tabs , under the code whenever there is a click for left or right mouse button.
Below is the changed code snippet.
/***************************************/
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (event.GUIEvent.Caller == UpButton)
{
recalculateScrollBar();
tab = Tabs[Tabs.size()-1];
for(i=Tabs.size()-1; i>0; i-- ){
Tabs = Tabs[i-1];
}
Tabs = tab;
return true;
}
else if (event.GUIEvent.Caller == DownButton)
{
recalculateScrollBar();
tab = Tabs[0];
for(i=0; i<Tabs.size()-1; i++ ){
Tabs = Tabs[i+1];
}
Tabs = tab;
return true;
}
break;
/******************************/
I have fixed the same issue with simple swap of pointers in array <CGUITAB*>Tabs , under the code whenever there is a click for left or right mouse button.
Below is the changed code snippet.
/***************************************/
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (event.GUIEvent.Caller == UpButton)
{
recalculateScrollBar();
tab = Tabs[Tabs.size()-1];
for(i=Tabs.size()-1; i>0; i-- ){
Tabs = Tabs[i-1];
}
Tabs = tab;
return true;
}
else if (event.GUIEvent.Caller == DownButton)
{
recalculateScrollBar();
tab = Tabs[0];
for(i=0; i<Tabs.size()-1; i++ ){
Tabs = Tabs[i+1];
}
Tabs = tab;
return true;
}
break;
/******************************/
There had been some more problems. Like tabs drawn below the buttons and tabs selected when one of the scroll-buttons was clicked. But restricting the tab-width wouldn't be really necessary. Main reason I added it was because there was a variable TabMaxWidth which a) was the reason for some of the problems b) was messed up - like set to different values at different places because it was abused for other stuff and c) it didn't do the thing it said it would do (set the tab max width).manik_sheeri wrote:I have tried your fix but there seems to have another problem.You seem to cut the tab width. why are you doing so ?
It's not actually needed, thought I guess it is rather useful. But it probably needs a setter-function. I didn't want to add that because we already have a feature-freeze for 1.6, but well, I guess it just belongs in there and won't hurt, so I'm going to add it.
edit: setTabMaxWidth is now in svn and the default is now 0 which means - no restriction. There are still minor problems (like buttons enabled/disable not yet correct and the buttons show up more often than strictly necessary), but those will probably have to wait as I'm too short on time atm. But I'll get back to it some day.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm