[SOLVED][0.7] tgui::bindWidth doesn't work with menu
« on: 03 December 2014, 16:08:18 »
with this code :
Code: [Select]
auto menu = tgui::MenuBar::create(THEME);
menu->setSize(tgui::bindWidth(mGui.getContainer())*0.5, 22); // Half size ?? 
    menu->addMenu("Fichier");
    menu->addMenuItem("Fichier", "Importer image");
    menu->addMenuItem("Fichier", "Enregistrer");
    menu->addMenuItem("Fichier", "Enregistrer sous...");
    menu->addMenuItem("Fichier", "Quitter");
menu->addMenu("Affichage");
    menu->addMenuItem("Affichage", "Basculer en plein écran");
menu->connectEx("MenuItemClicked", &Application::OnMenuClick,this );
    mGui.add(menu);

and inside my run method :

Code: [Select]
sf::Event event;
while (mWindow.pollEvent(event))
{

// window closed
if (event.type == sf::Event::Closed)
{
mWindow.close();
mRun = false;
}

// window resized
if (event.type == sf::Event::Resized)
{
mWindowSize.x = event.size.width;
mWindowSize.y = event.size.height;
mGui.setView(sf::View{{0, 0, (float)event.size.width, (float)event.size.height}});
}

mGui.handleEvent(event);
}

the menu is not streched  , but is not resized at the desired value.
« Last Edit: 03 December 2014, 16:30:22 by cpl.bator »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: [0.7] tgui::bindWidth doesn't work with menu
« Reply #1 on: 03 December 2014, 16:17:18 »
This seems to be a bug.
I'll see if I can find what is causing this exactly.

Btw, tgui::bindWidth(mGui.getContainer()) can also be written as tgui::bindWidth(mGui).

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: [0.7] tgui::bindWidth doesn't work with menu
« Reply #2 on: 03 December 2014, 16:26:00 »
I found the problem.

When you add the menu to the gui, it is given the width of the gui. This was done so that you didn't have to specify a width for the menu bar as it would just fill the whole width.

I'll fix it so that it will only give the menu bar a width when the width has not yet manually been set (ie different from 0).

But in the meantime just call the setSize function after the mGui.add(menu) line, that will make the code work.

[SOLVED] [0.7] tgui::bindWidth doesn't work with menu
« Reply #3 on: 03 December 2014, 16:30:14 »
Work fine by this way. thanks