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 - wmbuRn

#1
Here is simple code


#include <TGUI/TGUI.hpp>

void loadWidgets( tgui::Gui& gui )
{

    tgui::ChildWindow::Ptr child(gui, "childWindow");
  //  child->load("../../widgets/Black.conf");
  //  child->setIcon("../icon.jpg");
    child->load("Black.conf");
    child->setSize(400, 400);
    child->setBackgroundColor(sf::Color(80, 80, 80));
    child->setPosition(200, 100);
    child->setTitle("Child window");
    child->hide();

    tgui::Button::Ptr showChildWindow(gui);
   // showChildWindow->load("../../widgets/Black.conf");
    showChildWindow->load("Black.conf");
    showChildWindow->setSize(120, 40);
    showChildWindow->setPosition(100, 100);
    showChildWindow->setText("Show child window");
    showChildWindow->bindCallback(tgui::Button::LeftMouseClicked);
    showChildWindow->setCallbackId(1);

}

int main()
{

    sf::RenderWindow app(sf::VideoMode(800, 600), "Child window test");
    tgui::Gui gui(app);

     // gui.setGlobalFont("../../fonts/DejaVuSans.ttf");
      gui.setGlobalFont("DejaVuSans.ttf");

    loadWidgets(gui);

    while (app.isOpen())
    {
        // Process events
        sf::Event event;
        while (app.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                app.close();

            // Pass the event to all the widgets
            gui.handleEvent(event);
        }

            tgui::Callback callback;
            while (gui.pollCallback(callback))
            {

                if (callback.id == 1)
                {
                    tgui::ChildWindow::Ptr Child = gui.get("childWindow");
                    Child->show();
                }

            }

        // Clear screen
        app.clear();

        // Draw the sprite
        gui.draw();

        // Update the window
        app.display();
    }


    return EXIT_SUCCESS;
}


What it does: Displays child window od given location. Problem is when clicking on  [X] on childwindow, it does close child window. But it doesnt hide it or anything, so i guess child window gets destroyed automaticly. After closing the child window, and clicking on same button to show child window i get core dumped. Which i guess its becouse child gets destroyed.

1. How to implement when clicking [X] button on child window, makes child window hide(), and not destroy()

2. I know i can add buttons to child window, and bindCallback to one button to serves as hide() for childwindow, but there still will be [X] displayed in child window titlebar when displaying child window, which i cant remove, and it is dangerous if somebody click on it.

#2
I can always get slider value by using code
slider->getValue()

But i dont get new values when i move slider left or right. How to constantly get new values when i move slider left or right ?

side question: which one should i use as slider for music volume? slider2d or slider?

Thanks in advance
#3
where is the source: C:/tgui-master/

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file:C:/TGUI-master/build/CMakeFiles/2.8.11.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file:C:/TGUI-master/build/CMakeFiles/2.8.11.2/CMakeCXXCompiler.cmake
Configuring incomplete, errors occurred!




where is the source: when i set from C:/tgui-master/ to : C:/TGUI-master/cmake/Modules

CMake Error: The source directory "C:/TGUI-master/cmake/Modules" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.


Is it my mistake of somebody elses? :)
#4
General Discussion / tgui 0.6 and sfml 2.1
28 July 2013, 16:42:57
Sfml 2.1 is released this morning, and i am wondering is it safe to use tgui 0.6 with sfml 2.1?

Thank you :)
#5
Help requests / checkbox and load from files
27 July 2013, 03:16:49
This is how i save isChecked()

bool saveUcenik1Trening(int Text)
{
std::ofstream saveFile;
saveFile.open("checkboxUcenik1.txt", std::ios::app);
    saveFile << Text;
    saveFile << " ";
saveFile.close();

return 0;
}


And it does save to file. This is how i load from "checkboxUcenik1.txt" file

std::ifstream loadFileUcenik1Trening("checkboxUcenik1.txt");
    int valueUcenik1[12];
    tgui::Checkbox::Ptr CheckBoxUcenik1[12];
if (loadFileUcenik1Trening.is_open())
{
    for (unsigned int i = 0; i < 12; ++i)
    {
     CheckBoxUcenik1[i] = Group1->get("Ucenik1Trening" + tgui::to_string(i));
     loadFileUcenik1Trening >> valueUcenik1[i];    // valueUcenik[i] 1 and 0 from file
     std::cout << valueUcenik1[i] << std::endl;  // terminal show valueUcenik have 1 and 0 loaded
     CheckBoxUcenik1[i]->check(valueUcenik1[i]);  // error here
     }
}
loadFileUcenik1Trening.close();
}
[/close]

error: no matching function for call to 'tgui::Checkbox::check(int&)' . Any idea how to fix this ?

Thank you in advance
wmbuRn
#6
Searched entire Class reference and i couldnt find anything about push.back. And i used it in my code [Thanks to Texus] and i want to read more about it. Since TextBox doesnt have push.back i need to find another way to take typed text from Text box so i can store it into .txt. This is how i done for Editboxes:


EditBoxNames[i] = Group1->get("Ime" + tgui::to_string(i));
Group1Names.push_back(EditBoxNames[i]->getText());
saveGroup1(Group1Names);  // function to save vector into .txt


saveGroup1(Group1Names) function:

void saveGroup1(std::vector<sf::String> strings)
{
std::ofstream snimiGrupu1;
int i = 0;
snimiGrupu1.open ("Group1.txt", std::ios::trunc);
        if (snimiGrupu1.is_open())
        {
            for (std::vector<sf::String>::iterator itr = strings.begin(); itr != strings.end(); ++itr)
            {
            snimiGrupu1 << "Name" + tgui::to_string(i+1) + ": ";
            snimiGrupu1 << itr->toAnsiString();
            snimiGrupu1 << "\n";
            i = i + 1;
            }
        }

        else
        {
        snimiGrupu1.close();
        }
snimiGrupu1.close();
}


But i cant use push.back on TextBox so i need article [wont torture anyone to writte me code] to read to find another solution. :)

with respect
wmbuRn
#7
I want to transfer values from Panel1 EditBox 1 to Panel2 Editbox1.

This is how i get Values from editbox [its Texus code]:

// this works, i used same thing to get values and to write them on .txt file
tgui::Panel::Ptr Group1 = gui.get("Group1");
EditBoxNames[i] = Group1->get("Ime" + tgui::to_string(i)); // get EditboxNames
Group1Names.push_back(EditBoxNames[i]->getText());        // getText from editboxes
// but i cant transfer those values into another panel

tgui::Panel::Ptr Group1Napomene = gui.get("Group1Napomene");  // get Group1Napomene
                                                                                                            // which is another panel

Ime1napomene->setText(Group1Names));

The problem is Ime1napomene have error: base operand of '->' has non-pointer type 'sf::String' . I just need help with code, becouse i never learned std::vectors, and now i am asking for help. Need to finnish this fast so i can start learning things i missed.

Thank you in advance
wmbuRn



#8
Help requests / arrays on 30 editBoxes
23 July 2013, 04:26:25
Basicly if i want to take value of a edit box i have to do this:

tgui::Panel::Ptr Group1 = gui.get("Group1");
tgui::EditBox::Ptr Ime1 = Group1->get("Ime1");
sf::String Name = Ime1->getText();

And it takes value of EditBox named "Ime1" and stores it to variable "Name". To do that for 30 editBoxes is a lot of code.. and i have 120 EditBoxes [in 1 group, having 18 groups in total is a lot lot lot lot of code] I can do that, dont have problem with that, but i am interested in using arrays. But arrays wont work. And i dont know why. I made test console application and arrays work there but in sfml and tgui they wont.
Here is  code:

sf::String Name[30];
sf::String Group1Ime[30];
for (unsigned int i = 1; i < 30; ++i) // 30 editboxes named Ime
{
Name[i] = "Group1->get(Ime[i])";
Group1Ime[i] = "Name[i]->getText()";
}

So nothing works, i changed code thousand times, and i get tons of different errors. And i know why this one doesnt work. Basicly i am doing this:

Group1Ime[i] = "Group1->get(Ime[i])->getText()";


I tried with std::vector

std::vector<tgui::EditBox::Ptr> Group1Names;
std::vector<tgui::EditBox::Ptr> EditBoxNames;
for (unsigned int i = 1; i < 30; ++i)
{
    tgui::Panel::Ptr Group1 = gui.get("Group1");
    EditBoxNames[i] = Group1->get("Ime" + "to_string(i)"); // error here becouse of "", even with Ime[i]
    Group1Names[i] = EditBoxNames[i]->getText();
}

No go. Nothing works. Any clues or hints ? :)
#9
Help requests / scrollbar tutorials?
15 July 2013, 03:46:29
Maybe i am becoming pain in the *** ? :) But there are no tutorials online that shows usage of scrollbar. Even code included in 0.6-dev [example "FulExample"] only displays scrollbar. Which i can do :). But lets say i want to display 10 pictures in a column. they are 80x80, so only about 4 or 5 fit on resolution 800x600. iI want to use scrollbar to scroll down to see other pictures. How to do that? Simple code :). Also after all these questions i asked, i will make tutorial code and if texus allow will be displayed on site or shipped with "examples" dir. So new users will have more tutorials nad wont ask questions like me :)

Thanks in advance
wmbuRn
#10
Little help on animated pictures please :)

I read class reference here: https://tgui.eu/dcmtn/v0.6/classtgui_1_1AnimatedPicture.html#details

Is somebody wiling to post simple code to load just one picture, ill do the rest ? picture/code is worth 1.000 words they said xD


void AnimatedPicture( tgui::Gui& gui )
{

// your code here please :)

}

I never understand classes definitions and usage on those links. Incase somebody think i will use c++/SFML/tGui without knowleadge of pointers, classes, functions, and arrays he is wrong :) ] :)

thank you in advance
wmbuRn
#11
Title says it all.

1. Is it possible to use sql libs, take something from databases and assign value/valuess to widet like combobox? If its possible i will learn myself how to do that :)

2. Lots of data/resources i needed for application is scatered in folder, i know i can arrange them into folders like
Data/Pictures
Data/Buttons etc etc etc
But is it possible to add libs like physfs ? And can tgui load from memory? I know sfml can loadFromStream, but is this possible with tGui?

thanks in advance
wmbuRn
#12
So i made login from tutorial, and more:

if (loginCallback.id == 1)
            {
                // Get the username and password
                tgui::EditBox::Ptr editBoxUsername = gui.get("Username");
                tgui::EditBox::Ptr editBoxPassword = gui.get("Password");

                sf::String username = editBoxUsername->getText();
                sf::String password = editBoxPassword->getText();

                a = Doit(a); // simple decrypter, since value for a and b is stored as variable
                b = Doit(b); // so a and b without Doit function have encrypted values
            if (username == a && password == b)
            {
            loginScreen.close();
            mainScreen.create(sf::VideoMode(800, 600), "A new Title");
            }

            if (username != a || password != b)
            {
            sf::sleep(sf::seconds(1));
            shaking = 1;
            }

So old window [loginScreen] get closed, and new window [mainScreen] get created. So i made new
(while (mainScreen.isOpen))
{
    // awesome stuff here like events and callback
}

But new window start taking 80% of cpu. Its not directly related to tGui, [it is indirectly]
And i added mainScreen.setFramerateLimit(30); everywhere but it is still using 70-80% of CPU. Untila i start clicking inside empty window than CPU usage goes to 1% for this app, until i stop clicking, then it goes back to 70-80% . :)
So.. any idea what am i doing wrong ? if needed I can upload entire project and post link here. :)
#13
Is it possible to set tooltip when you hover over button or any other widget?

Can i make my own buttons or i have to use default ones? And is it possible to change buttons to display pictures? I made some sfml application that displays 60x60 sprites [showing my team mate how the buttons should look], here is image of what i was thinking:  https://s23.postimg.org/fya019k97/this_buttons.png

So is it somehow possible to make those sprites a clickable objects? Or it is possible to make tgui buttons to look like that?

Thank you in advance
with respect
wmbuRn
#14
Help requests / Shaking window
09 July 2013, 19:18:37
I started same topic on SFML forum. But i think this topic should be written here since its tGui realted.

so:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(400, 300), "win");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed) window.close();
        }

        window.setPosition(sf::Vector2i(100 + rand() % 25, 100 + rand() % 25));

        window.clear(sf::Color::Black);
        window.display();
    }

    return 0;
}

that code is working, its pure SFML. It produces shaking the entire window.

Then implemented in SFML with tGui doesnt work:

while (screen.isOpen())
    {
        sf::Event event;
        while (screen.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                screen.close();

            // Pass the event to all the tgui stuff
            gui.handleEvent(event);
        }

        // The callback loop
        tgui::Callback callback;
        while (gui.pollCallback(callback))
        {
            // Make sure tha callback comes from the button
            if (callback.id == 1)
            {
                // Get the username and password
                tgui::EditBox::Ptr editBoxUsername = gui.get("Username");
                tgui::EditBox::Ptr editBoxPassword = gui.get("Password");

                sf::String username = editBoxUsername->getText();
                sf::String password = editBoxPassword->getText();

                if (username == "" && password == "")
                {
                  // clear the entire window and set new stuff to draw.
                }
            }
            if (callback.id == 2)
            {
             screen.setPosition(sf::Vector2i(100 + rand() % 25, 100 + rand() % 25));
            } // end if callback.id == 2 
        }

        screen.clear();

        // Draw all created tgui stuff
        gui.draw();

        screen.display();
    }

So basic idea is: when somebody click login with wrong username or password  i want window to shake left - right - left - right like in most linux program when you miss the pasword / username.
  if (callback.id == 2)  - Thats tGui button, its button [labeled: exit] but i will implement stuff there and when its working will move it to (callback.id == 1) which is actual login button. So my code  wont shake the window. It just move the screen one time. If needed i can provide entire code, or entire working directory.
#15
Installation help / gcc errors in linux
08 July 2013, 21:04:18
So i downloaded 0.6-dev from the site since 0.4.2 or 0.4.4 wont work at all :)
so i tried to compile Tgui-master [i used cmake first ofc [gui cmake]] and everythig went well with cmake(as it should), but when i typed "sudo make install" i got these errors:

Scanning dependencies of target tgui
[  2%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/TGUI.cpp.o
[  5%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Callback.cpp.o
[  8%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Transformable.cpp.o
[ 10%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Widgets.cpp.o
[ 13%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Label.cpp.o
/home/hidden/TGUI-master/src/TGUI/Label.cpp: In member function 'const sf::Font* tgui::Label::getTextFont() const':
/home/hidden/TGUI-master/src/TGUI/Label.cpp:152:31: error: cannot convert 'const sf::Font' to 'const sf::Font*' in return
/home/hidden/TGUI-master/src/TGUI/Label.cpp:153:5: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [src/TGUI/CMakeFiles/tgui.dir/Label.cpp.o] Error 1
make[1]: *** [src/TGUI/CMakeFiles/tgui.dir/all] Error 2
make: *** [all] Error 2


so, i will try 0.5 version and will report back. If anyone got a solution how to make this to work please reply. Thank you.
Btw nice gui lib!