Main Menu
Menu

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.

Show posts Menu

Topics - Ezekiel

#1
Greetings All...

I have been trying to get a SpinButton to adjust another value, but I can't seem to make it send the Callback.  Is there anything I missing?

Here is some code I made from the "Full example" with most things removed.



//#include <TGUI/TGUI.hpp>
#include <tgui.h>
#include <string>
#include <sstream>

#define THEME_CONFIG_FILE "../../widgets/Black.conf"

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI window");
    tgui::Gui gui(window);
tgui::setResourcePath("../../../TGUI-0.6/examples/FullExample");

    if (gui.setGlobalFont("../../fonts/DejaVuSans.ttf") == false)
        return 1;

unsigned int callback_count = 0;

//control
int current_mouse_x = 0;
int current_mouse_y = 0;


//fonts
sf::Font font;
font.loadFromFile("arial.ttf");
sf::Font fixedfont;
fixedfont.loadFromFile("courbd.ttf");

    tgui::Picture::Ptr picture(gui);
    picture->load("../Linux.jpg");


    tgui::MenuBar::Ptr menu(gui);
    menu->load(THEME_CONFIG_FILE);
    menu->setSize(window.getSize().x, 20);
    menu->addMenu("File");
    menu->addMenuItem("File", "Load");
    menu->addMenuItem("File", "Save");
    menu->addMenuItem("File", "Exit");
    menu->bindCallback(tgui::MenuBar::MenuItemClicked);
    menu->setCallbackId(2);


    tgui::SpinButton::Ptr spinButton(gui);
    spinButton->load(THEME_CONFIG_FILE);
    spinButton->setCallbackId(1);
    spinButton->setPosition(100, 80);
    spinButton->setVerticalScroll(false);
    spinButton->setSize(40, 20);


    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
//exits
if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
            || (event.type == sf::Event::Closed))
                window.close();
if(event.type == sf::Event::MouseMoved)
{
current_mouse_x = event.mouseMove.x;//keep track of mouse current position
current_mouse_y = event.mouseMove.y;
}

            gui.handleEvent(event);
        }

        tgui::Callback callback;
        while (gui.pollCallback(callback))
        {
            if (callback.id == 1)sf::sleep(sf::seconds(0.016f));//spinbutton, does nothing important

            if (callback.id == 2)
            {
                if (callback.text == "Exit")
                    window.close();
            }
callback_count++;
        }

        window.clear();
        gui.draw();

//test text
std::stringstream info_conv;
info_conv << "CallBack Count: " << callback_count <<
//"\nchecked " << (int)checkbox->Checked <<
//"\nunchecked " << (int)checkbox->Unchecked <<
"\nX: " << current_mouse_x << "\nY: " << current_mouse_y;
sf::Text info_text;
info_text.setFont(font);
info_text.setCharacterSize(18);
info_text.setPosition(240.0f, 70.0f);
info_text.setString(info_conv.str());
window.draw(info_text);


        window.display();
sf::sleep(sf::seconds(0.016f));
    }

    return 0;
}


There are a few modifications...
-I used a <tgui.h> file to select the libs required for debug/release.  It may changed back on another computer.
-Added "spinButton->setCallbackId(1);" so it should function.
-Added some text for displaying "CallBack Count" and X and Y just for testing.
-I kept the menu so if the "Save" or "Load" were selected, it will increase the "CallBack Count".  "Quit" it too quick to see.
-I changed "if(callback.id == 1)" to do nothing important so a click from the SpinButton doesn't Quit the program, it should only increment the "CallBack Count", however it doesn't.

That's where I ran into the issue and haven't figured out how to solve yet.

I hope that provides enough information.

Ezk.
#2
Greetings All...

I have been battling the widgets for a while on my code, so I tried to use the "FullExample" code to see if I was missing something, however the response was quite similar.

I had to make some code changes to pass compilation since my project and the folders don't have the same relation position...

///////////////////////////////////////////////////////
tgui::Gui gui(window);
tgui::setResourcePath("../../../TGUI-0.6/examples/FullExample");//added below above line
//////////////////////////////////////////////////////
//child->setIcon("../icon.jpg");
child->setIcon("../../../TGUI-0.6/examples/icon.jpg");//added below above line
//////////////////////////////////////////////////////
//texture.loadFromFile("../ThinkLinux.jpg");
texture.loadFromFile("../../../TGUI-0.6/examples/ThinkLinux.jpg");//added below above line
//////////////////////////////////////////////////////


In Debug, in the console I received 10 copies of the same warning...
"An internal OpenGL call failed in Texture.cpp (391) : GL_INVALID_OPERATION, the specified operation is not allowed in the current state"

The Window works fine, except the graphics...

...screenshot.png is attached, it didn't tell me how attach the image.  I can click and move the strange blocks around if I check the picture on the webpage to expect what should happen.

My current computer setup
-AMD 64 X2 5200
-Widows 7 64
-Radeon X1950
-Visual Studio 2013
-SFML-2.3-windows-vc12-32-bit
-TGUI-0.6.8 Visual C++12 (2013) - 32bit

I hope I provided the proper information.

Ezk.