Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dexario

Pages: [1]
1
Thanks !

2
Hi,

I need to send some arguments in a callback but it doesn't seem to be possible in an object. Basically, I saw that in the callback tutorial:

Code: (cpp) [Select]
void function(tgui::Gui& gui);
button->bindCallback(std::bind(function, std::ref(gui)), tgui::CheckBox::Checked | tgui::CheckBox::Unchecked);

And I wanted to do that:

Code: (cpp) [Select]
p.button->bindCallback(std::bind(&AddObjectDialog::CloseAndSaveCallback, p.object), this, tgui::Button::LeftMouseClicked);
But it doesn't seem to be possible, I get the following error:

Code: (xml) [Select]
'tgui::CallbackManager::bindCallback' : no overloaded function takes 3 arguments
Thanks.

3
Ok, thanks for the tip.

4
:o It works, thank you very much :)

5
Here is the code: https://puu.sh/iosxw/d67636b3bb.zip

You will find to projects:
    -Isolated files: contains only the most important files from the full project
    -full project

I am sorry I was not able to provide an executable because I was guessing you use Linux and I don't know how to compile for Linux using Windows.

I found an interesting fact: if you look at isolated files project -> NewObjectDialog, you will see that there is also a canvas. I noticed that if you delete that code:

Code: (cpp) [Select]
void NewObjectDialog::Display(sf::RenderWindow *w)
{
m_canvas->clear(sf::Color(80, 80, 80));
m_canvas->draw(*m_image);
}

The widgets will be hidden. The weird thing is that if I do the same in the full project, the widgets will not be hidden, even though the NewObjectDialog files are the same.

6
I changed the initialisations of the widgets because they used to use the default constructors:
Code: (cpp) [Select]
tgui::Button::Ptr()
So I changed it to:

Code: (cpp) [Select]
//Create the panel
m_panel = tgui::Panel::Ptr(*m_win);
m_panel->setPosition(0, 0);
m_panel->setSize(300, 400);
m_panel->setBackgroundColor(sf::Color(200, 200, 200));

//Add some widgets to it
m_b_ok = tgui::Button::Ptr(*m_panel);
m_b_ok->load(THEME_CONFIG_FILE);
m_b_ok->setSize(130, 30);
m_b_ok->setPosition(0, 0);
m_b_ok->setText("Ok");
//m_panel->add(m_b_ok);

m_b_cancel = tgui::Button::Ptr(*m_panel);
m_b_cancel->load(THEME_CONFIG_FILE);
m_b_cancel->setSize(130, 30);
m_b_cancel->setPosition(0, 40);
m_b_cancel->setText("Cancel");
//m_panel->add(m_b_cancel);

//Add the scrollbar
m_scrollbar = tgui::Scrollbar::Ptr(*m_win);
m_scrollbar->load(THEME_CONFIG_FILE);
m_scrollbar->setSize(20, 400);
m_scrollbar->setPosition(m_panel->getPosition() + sf::Vector2f(m_panel->getSize().x, 0));
m_scrollbar->setArrowScrollAmount(30);
m_scrollbar->setLowValue(360); // Viewable area (height of the panel)
m_scrollbar->setMaximum(400); // Total area (height of the 5 images)

// Call the scrollPanel function that we defined above when scrolling
m_scrollbar->bindCallback(&NewObjectDialog::ScrollPanel, this, tgui::Scrollbar::ValueChanged);

I also got rid of all the "->add".

The text problem is now fixed but not the problem where the buttons aren't hidden:



Thanks.

7
Hi,

I am making a program using tgui. So far, everything was working fine. I am now trying to implement a scrollable panel, like in this example https://tgui.eu/example-code/v06/scrollable-panel/ (I use widgets instead of pics). It works fine except for the fact that the text in the buttons isn't being displayed. Screenshot here:



As you can see, the other buttons work fine but not those that are in the scrollable panel.

Here is the code that inits the panel and the two buttons that are in it:

Code: (cpp) [Select]
//Create the panel
m_panel->setPosition(0, 0);
m_panel->setSize(300, 400);
m_panel->setBackgroundColor(sf::Color(200, 200, 200));

//Add some widgets to it
        //Button ok
m_b_ok->load(THEME_CONFIG_FILE);
m_b_ok->setSize(130, 30);
m_b_ok->setPosition(0, 0);
m_b_ok->setText("Ok");
m_panel->add(m_b_ok);

        //Button cancel
m_b_cancel->load(THEME_CONFIG_FILE);
m_b_cancel->setSize(130, 30);
m_b_cancel->setPosition(0, 40);
m_b_cancel->setText("Cancel");
m_panel->add(m_b_cancel);

//Add the scrollbar
m_scrollbar->load(THEME_CONFIG_FILE);
m_scrollbar->setSize(20, 400);
m_scrollbar->setPosition(m_panel->getPosition() + sf::Vector2f(m_panel->getSize().x, 0));
m_scrollbar->setArrowScrollAmount(30);
m_scrollbar->setLowValue(360); // Viewable area (height of the panel)
m_scrollbar->setMaximum(5 * 180); // Total area (height of the 5 images)

// Call the scrollPanel function that we defined above when scrolling
m_scrollbar->bindCallback(&NewObjectDialog::ScrollPanel, this, tgui::Scrollbar::ValueChanged);

m_win->add(m_panel);
m_win->add(m_scrollbar);

m_win is the child window in which these widgets are.

Also, if we look back at the screenshot, we can see that the widgets that are in the panel aren't hidden when they get out of it (I don't know if this is a normal behaviour since it's supposed to be a static panel).

Thanks.

Pages: [1]