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

#1
Folowing code works great:

#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();
    child->bindCallback(tgui::ChildWindow::Closed);
    child->setCallbackId(2);



    tgui::Button::Ptr showChildWindow(gui);
    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()
{
    // Create the main window
    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);

// Start the game loop
    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();

                }

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

            }



        // Clear screen
        app.clear();

        // Draw the sprite
        gui.draw();

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


    return EXIT_SUCCESS;
}


Just added

child->bindCallback(tgui::ChildWindow::Closed);
child->setCallbackId(2);

To child window

And

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

Inside  while (gui.pollCallback(callback)) where all callbacks are checked.

I posted this "solution" in case somebody gets same problems as i did. If not nedded, feel free to delete entire topic (:
#2
No delete button on topic. Forget this topic, i didnt see

enum tgui::ChildWindow::ChildWindowCallbacks

Defines specific triggers to ChildWindow.
Enumerator
LeftMousePressed    

The left mouse button was pressed (child window was thus brough to front)
Closed    

Child window was closed.
Moved    

Child window was moved.
AllChildWindowCallbacks    

All triggers defined in ChildWindow and its base classes.

in documentation. Sorry
#3
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.

#4
Help requests / Re: String/letters label
17 March 2014, 19:01:31
Downloading guthub version, will report back after i install and test. thank you

EDIT: It works perfectly with current github version of SFML. Thank you
#5
Help requests / Re: String/letters label
17 March 2014, 18:40:13
we are working on same project, labels are cut on my linux. Here is code for labels:


    tgui::Label::Ptr labelPlayerSettings(*settingsScreen);
    labelPlayerSettings->setText("Music Player:");
    labelPlayerSettings->setTextColor(sf::Color::White);
    labelPlayerSettings->setPosition(430, 20);
    labelPlayerSettings->setTextSize(20);

    tgui::Label::Ptr labelRandomSongs(*settingsScreen);
    labelRandomSongs->setText("Play random songs");
    labelRandomSongs->setTextColor(sf::Color::White);
    labelRandomSongs->setPosition(460, 60);
    labelRandomSongs->setTextSize(10);


And other code from picture below. Labels are cut on bottom.
using Linux: Elementary OS Luna.
TGUI: 0.6.2 just downloaded tham and installed
SFML: 2.1

picture: https://s18.postimg.org/8jts76j4p/cut_Label.png

EIDT: If needed i can make new project with just labels
#6
It works. I will check the docs. Thank you very much
#7
getValue() returns current value when program loads. When i move the thumb of the slider i dont get new values. I will code only for slider in 1-2 mins

Here is minimal code:

#include <TGUI/TGUI.hpp>

int main()
{
    // Create the main window
    sf::RenderWindow app(sf::VideoMode(400, 400), "slider test");
    tgui::Gui gui(app);

    tgui::Slider::Ptr slider(gui);
    slider->load("Black.conf");
    slider->setVerticalScroll(false);
    slider->setPosition(10, 10);
    slider->setSize(300, 25);
    slider->setMinimum(0);
    slider->setMaximum(100);

    std::cout << "Value is: " << slider->getValue() << std::endl;



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

            gui.handleEvent(event);
        }

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

        // Clear screen
        app.clear();

        // Draw the sprite
        gui.draw();

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

    return EXIT_SUCCESS;
}
#8
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
#9
It wasnt my pc, i was connected [teamviewer] to my gf computer trying to solve why things wont cmake on her pc. First she installen mingw in "C:/Program Files/Code Blocks/Mingw" while mingws site said to use path without spaces so ideal path will be "C:/mingw" . Didnt solved it yet, no internet in entire town where i live. Am online throught PC and tethering from my android phone :) will report back when internet comes back :)
#10
Let me check env paths again and will report back :)
#11
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? :)
#12
I couldnt find diference between sfml 2.0 and 2.1. So i didnt know is sfml 2.1 is a bugfix release or api was changed. Yup since there is no sfml 2.1 on launchpad [yet?] i will have to build sfml and tgui from source. Am waiting for github to start working again to get tgui-0.6.

Thank you for your answer
wmbuRn
#13
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 :)
#14
Yeah i know i can change value like that, but i have about 3.300 checkboxes :) Anyway thanks for help. :)
#15
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