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

Messages - Ezekiel

#1
Greetings All...

My apologies, I forgot to add something to the demo code I posted, here's what I should have included, so the correct answer should have been...

"Change..."

spinButton->bindCallback(tgui::SpinButton::LeftMouseClicked);


"...to..."

spinButton->bindCallback(tgui::SpinButton::ValueChanged);


Making the change made it work properly.  Thank you for the prompt response.

Is there any documentation I should read over before miss some differences between the widgets, I followed information on the "Full example" and it shows many widgets but few bindCallback's covering the different types of the callbacks used by different widgets.

This answer should give me enough information to complete my project, a little more work of course.  This is way better than when I tried to make my own menu and buttons when I couldn't use this since XP limited Visual Studio 2008, which didn't allow C++11.

Ezk.
#2
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.
#3
I have swapped out my X1950XTX with the lower GeForce 7600GT and the FullExample looks as it should, your graphics card driver prediction was accurate, however there was no better driver available as I feared.  At least now I can proceed on my project now.

Good find on my post I couldn't find.  I signed in the other day and thought I didn't have anything posted when it said I have 0 messages, I know now messages and posts are completely different and I didn't check the correct page displaying the post records.

It's good to hear TGUI-0.6.8 can be used with SFML-2.1 can work with cmake.  Sometime the progress is one direction, for instance if the 2.3 version has added or altered interface functions.  With a working graphics card installed, I can procrastinate learning everything I need to know about cmake a little longer.  I can keep that as an option if I switch back to my more powerful card if I need to use it before I find a better one.

Ezk.
#4
I found there is an SFML 2.3 error displaying a picture file.  I have previous projects that work fine when compiled with SMFL 2.1, however recompiling them with SFML 2.3 has some text that resemble the screenshots I attached previously.

I did have a suggestion on the SFML forum about a year ago telling me my problem was due to my graphics card, and upgrading my driver solved it.  However, now there's no more-up-to-date driver available than the one I'm using.  That subject is no longer posted on the forum or I can't find it, so I can't check what the exactly graphics issue was.  I have an inferior graphics card I can swap out to test if that's the problem.

Anyway, I appreciate your response and this looks like it's an SFML 2.3 issue, so I will take that there after my graphics card testing is finished.  There wouldn't be a way of testing SFML 2.1 with TGUI-0.6.8 Visual C++12 (2013) - 32bit?

Ezk.
#5
I have already done that with my own project yesterday to see if it was working, see the screenshot_withSfmlText.png.  It does both at the same time.


Notice the previous screenshot.png, some of the widgets work fine as well, the menu ->'File', (plus 'Load', 'Save', 'Exit' which you can't see on the screenshot), and also the title of the 'Child window'.  There may be something slightly different between those and the other widgets.

I also already reinstalled my graphics card today, although I think I already had the newest possible for my card, my computer window was recently reloaded.

I also tried increase the mipmap level on my card, after I read the 'Pictures drawn ugly' post.  It was at the highest level and I tried all the lower levels. No change.

I will see if I can make an image work under SFML, but that will probably be done tomorrow.
#6
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.