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

Pages: [1] 2
1
Installation help / Re: Compile-time error when using TGUI
« on: 15 December 2015, 22:09:31 »
Ok, thank you for your reply, I think I will include the main TGUI header.
I guess the documentation of the library have to indicate in one way or another which header to include to use the library. I don't think the best way to use Qt is to include <Qt/Qt.hpp> or something like this ^^
But I agree with you, for TGUI this is better in that way.

Edit: Now I know what means the sentence "This is an unstable release, API changes may break you code", there is alot of things that has changed recently in TGUI-0.7, some are easy to fix (replace all tgui::xx::create to std::make_shared<tgui::xx>) but others are more painful, like the old widget constructor with theme filename as parameters :)

2
Installation help / Re: Compile-time error when using TGUI
« on: 15 December 2015, 15:52:59 »
Is the usual way to use SFML/TGUI to include the main header (TGUI.hpp or SFML/Graphics.hpp) ?
I thought that including only needed headers gave better compilation performance, without other loss.

3
Installation help / Re: Compile-time error when using TGUI
« on: 15 December 2015, 15:31:03 »
This worked, thank you  :)

Should I delete /usr/share/include/tgui/* every time I install a new version of TGUI ?
This will be done quite often, if this is needed at each API public change.
Maybe that should be a good idea to make a target in the Makefile that do it by itself ?

Edit: Oh, right, I understood why this is the first time I had to delete files. That's because you have moved files, not because of an API public change. I'll remember that for the next time :)

4
Installation help / Compile-time error when using TGUI
« on: 15 December 2015, 10:00:25 »
Hi texus,

I downloaded the latest snapshots of TGUI and SFML on Github and I installed them by running the following commands:
Code: [Select]
mkdir build
cd build
cmake ..
make -j2
sudo make install
sudo ldconfig #Just to be sure
And then I wrote a very simple program, like this:
Code: [Select]
#include <TGUI/Label.hpp>
int main(){}
and I compiled it with
Code: [Select]
g++ -std=c++11 -ltgui -lsfml-graphics -lsfml-window -lsfml-system main.cppBut g++ does not think in that way, and say to me:
Code: [Select]
In file included from /usr/local/include/TGUI/Label.hpp:30:0,
                 from main.cpp:1:
/usr/local/include/TGUI/ClickableWidget.hpp:90:29: error: ‘virtual tgui::Widget::Ptr tgui::ClickableWidget::clone()’ marked ‘override’, but does not override
         virtual Widget::Ptr clone() override
                             ^
In file included from main.cpp:1:0:
/usr/local/include/TGUI/Label.hpp:99:22: error: ‘virtual void tgui::Label::setPosition(const tgui::Layout&)’ marked ‘override’, but does not override
         virtual void setPosition(const Layout& position) override;
                      ^
/usr/local/include/TGUI/Label.hpp:118:22: error: ‘virtual void tgui::Label::setSize(const tgui::Layout&)’ marked ‘override’, but does not override
         virtual void setSize(const Layout& size) override;
                      ^
/usr/local/include/TGUI/Label.hpp:329:22: error: ‘virtual void tgui::Label::initialize(tgui::Container*)’ marked ‘override’, but does not override
         virtual void initialize(Container *const container) override;
                      ^
/usr/local/include/TGUI/Label.hpp:354:22: error: ‘virtual void tgui::Label::update()’ marked ‘override’, but does not override
         virtual void update() override;
                      ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h:33:0,
                 from /usr/include/c++/5/bits/allocator.h:46,
                 from /usr/include/c++/5/string:41,
                 from /usr/local/include/TGUI/Exception.hpp:30,
                 from /usr/local/include/TGUI/Global.hpp:32,
                 from /usr/local/include/TGUI/Widget.hpp:30,
                 from /usr/local/include/TGUI/ClickableWidget.hpp:30,
                 from /usr/local/include/TGUI/Label.hpp:30,
                 from main.cpp:1:
/usr/include/c++/5/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = tgui::ClickableWidget; _Args = {tgui::ClickableWidget&}; _Tp = tgui::ClickableWidget]’:
/usr/include/c++/5/bits/alloc_traits.h:256:4:   required from ‘static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = tgui::ClickableWidget; _Args = {tgui::ClickableWidget&}; _Alloc = std::allocator<tgui::ClickableWidget>; std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]’
/usr/include/c++/5/bits/alloc_traits.h:402:16:   required from ‘static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = tgui::ClickableWidget; _Args = {tgui::ClickableWidget&}; _Alloc = std::allocator<tgui::ClickableWidget>; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]’
/usr/include/c++/5/bits/shared_ptr_base.h:522:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {tgui::ClickableWidget&}; _Tp = tgui::ClickableWidget; _Alloc = std::allocator<tgui::ClickableWidget>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr_base.h:617:4:   required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = tgui::ClickableWidget; _Alloc = std::allocator<tgui::ClickableWidget>; _Args = {tgui::ClickableWidget&}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr_base.h:1097:35:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<tgui::ClickableWidget>; _Args = {tgui::ClickableWidget&}; _Tp = tgui::ClickableWidget; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr.h:319:64:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<tgui::ClickableWidget>; _Args = {tgui::ClickableWidget&}; _Tp = tgui::ClickableWidget]’
/usr/include/c++/5/bits/shared_ptr.h:614:39:   required from ‘std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = tgui::ClickableWidget; _Alloc = std::allocator<tgui::ClickableWidget>; _Args = {tgui::ClickableWidget&}]’
/usr/include/c++/5/bits/shared_ptr.h:629:39:   required from ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = tgui::ClickableWidget; _Args = {tgui::ClickableWidget&}]’
/usr/local/include/TGUI/ClickableWidget.hpp:92:59:   required from here
/usr/include/c++/5/ext/new_allocator.h:120:4: error: invalid new-expression of abstract class type ‘tgui::ClickableWidget’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^
In file included from /usr/local/include/TGUI/Label.hpp:30:0,
                 from main.cpp:1:
/usr/local/include/TGUI/ClickableWidget.hpp:55:20: note:   because the following virtual functions are pure within ‘tgui::ClickableWidget’:
     class TGUI_API ClickableWidget : public Widget
                    ^
In file included from /usr/local/include/TGUI/ClickableWidget.hpp:30:0,
                 from /usr/local/include/TGUI/Label.hpp:30,
                 from main.cpp:1:
/usr/local/include/TGUI/Widget.hpp:564:29: note: virtual tgui::Widget::Ptr tgui::Widget::clone() const
         virtual Widget::Ptr clone() const = 0;
                             ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h:33:0,
                 from /usr/include/c++/5/bits/allocator.h:46,
                 from /usr/include/c++/5/string:41,
                 from /usr/local/include/TGUI/Exception.hpp:30,
                 from /usr/local/include/TGUI/Global.hpp:32,
                 from /usr/local/include/TGUI/Widget.hpp:30,
                 from /usr/local/include/TGUI/ClickableWidget.hpp:30,
                 from /usr/local/include/TGUI/Label.hpp:30,
                 from main.cpp:1:
/usr/include/c++/5/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = tgui::Label; _Args = {tgui::Label&}; _Tp = tgui::Label]’:
/usr/include/c++/5/bits/alloc_traits.h:256:4:   required from ‘static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = tgui::Label; _Args = {tgui::Label&}; _Alloc = std::allocator<tgui::Label>; std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]’
/usr/include/c++/5/bits/alloc_traits.h:402:16:   required from ‘static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = tgui::Label; _Args = {tgui::Label&}; _Alloc = std::allocator<tgui::Label>; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]’
/usr/include/c++/5/bits/shared_ptr_base.h:522:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {tgui::Label&}; _Tp = tgui::Label; _Alloc = std::allocator<tgui::Label>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr_base.h:617:4:   required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = tgui::Label; _Alloc = std::allocator<tgui::Label>; _Args = {tgui::Label&}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr_base.h:1097:35:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<tgui::Label>; _Args = {tgui::Label&}; _Tp = tgui::Label; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/5/bits/shared_ptr.h:319:64:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<tgui::Label>; _Args = {tgui::Label&}; _Tp = tgui::Label]’
/usr/include/c++/5/bits/shared_ptr.h:614:39:   required from ‘std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = tgui::Label; _Alloc = std::allocator<tgui::Label>; _Args = {tgui::Label&}]’
/usr/include/c++/5/bits/shared_ptr.h:629:39:   required from ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = tgui::Label; _Args = {tgui::Label&}]’
/usr/local/include/TGUI/Label.hpp:347:49:   required from here
/usr/include/c++/5/ext/new_allocator.h:120:4: error: invalid new-expression of abstract class type ‘tgui::Label’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^
In file included from main.cpp:1:0:
/usr/local/include/TGUI/Label.hpp:47:20: note:   because the following virtual functions are pure within ‘tgui::Label’:
     class TGUI_API Label : public ClickableWidget, public WidgetBorders, public WidgetPadding
                    ^
In file included from /usr/local/include/TGUI/ClickableWidget.hpp:30:0,
                 from /usr/local/include/TGUI/Label.hpp:30,
                 from main.cpp:1:
/usr/local/include/TGUI/Widget.hpp:564:29: note: virtual tgui::Widget::Ptr tgui::Widget::clone() const
         virtual Widget::Ptr clone() const =  0;
                             ^

As though all methods from base class were not know in children classes, so making overriding tests fail.
The version of g++ is 5.2.1, and I'm on Ubuntu 15.10.

Any idea of why is that happening ?

5
Feature requests / Re: Layout container
« on: 01 June 2015, 14:46:56 »
The interface you finally proposed is mostly the one I already made, I just learn how to fork/push and you'll can see what I've made.
I'll add
Code: [Select]
addSpace(float ratio, const sf::String widgetName = ""); I think it's a good idea.

Edit: Ok, I made a pull request.

6
Feature requests / Re: Layout container
« on: 01 June 2015, 13:41:27 »
Actually, there is 4 methods for addings things to the layout:
Code: [Select]
void insert(unsigned int position, const tgui::Widget::Ptr& widget, const sf::String& widgetName = "");
void add(const tgui::Widget::Ptr& widget, const sf::String& widgetName = "");
void insertSpace(unsigned int position, const sf::String& spaceName = "");
void addSpace(const sf::String& spaceName = "");
These four functions respectively insert a widget at the specified position in the layout, add a widget at the end of the layout, insert a space at the specified position and add a space at the end of the layout.
Spaces and widgets are handled the same way internally (spaces are hidden widgets).
So the three last are just convenience functions, and finally call insert.

And I didn't add a parameter for directly setting the ratio because sometimes the user would want to give an identifier and let the ratio to default, and sometimes he would wand to just set the ratio but let an empty identifier. So have these two parameters in the same function call with default value cannot satisfy these two cases at the same time.
But if you find anyway that it is better to add ratio to the parameters of add/insert methods, I will do so :)

7
Feature requests / Re: Layout container
« on: 31 May 2015, 22:08:30 »
I already implemented the ratio system for distribute differently the space between elements, and adding/inserting space between elements
The interface is like this:
Code: [Select]
layout->add(widget);
layout->add(widget2);
layout->insertSpace(1, "spaceID");
layout->setRatio("spaceID", 0.5f);

The ratio is not the size used by the widget in the layout, but the size that the widget will have relatively to others.
So in a layout 500 px, with 2 elements of a ratio equal to 2.f and another element with a ratio equal to 1.f, the two
first widgets will have 200px and the last one will have 100px.

8
Feature requests / Re: Layout container
« on: 31 May 2015, 00:50:23 »
Btw, perhaps it is just a typo and you already know this, but std::remove (which you use in BoxLayout::remove) doesn't remove anything.
No that wasn't a typo, I didn't read the doc enough to understand how std::remove works, I fixed that.

So I'll work a bit more on the features I said, and then maybe should I pull the TGUI github and make a pull request ?
I never used github on a real project before...

9
Feature requests / Layout container
« on: 30 May 2015, 19:40:09 »
Hey Texus, I wrote a class that allow user of TGUI to layout widget more easily than with bindWidth, bindHeight and so on.
It's juste like QBoxLayout in Qt, there is two class: HorizontalLayout and VerticalLayout. Both class have the same interface as Container, but automatically resize and position widgets, allowing this kind of code:
Code: [Select]
auto layout = tgui::VerticalLayout::create();
layout->setSize(bindWidth(gui), bindHeight(gui));
gui.add(layout);
//...
layout->add(button1);
layout->add(button2);
layout->add(button3);
And now the three buttons fill the whole window, juste like bindWidth(gui, 0.33f) but in a more intuitive way, and without the need to write floating literal.
It is also possible to insert widget, between two already added widgets.

If you're interested in theses classes, I can implement more features, like weight for each element, borders, fixed size widget and space elements.
This is not redundant with the Grid, because the grid actually only position elements, and theses layouts also resize them.

Edit: I know that the copy constructor/assignement operator sounds bad, because widgets are copied, removed and copied again, but that's the only way I seen to don't have to write a addWidget method like you did with Grid.
And maybe I written some methods the wrong way, like mouseOnWidget, I copy-pasted alot and I don't understand all mechanisms of TGUI. This is just a design proposal.

10
Help requests / Re: Get Grid working
« on: 29 May 2015, 15:03:15 »
Thanks for the tip on ChildWindow, I didn't dig deep enough to view that.

I think a different image for each tab is very common and more natural in a video game, you can see an exemple in the screenshot I posted above, but I seen this kind of tab in many other games. So I think a good thing would be to choose an image to add at left or right of the text in the tab, just like a Checkbox. But the image should  be stored in Tab rather than in TabRenderer, because it is specific data for each tab rather than a style data, so just like an extension of the text.

And for the Tooltip I think to the tooltip in the Qt librairy, wich allow to put full rich text/HTML in tooltip.
I think a good interface would be to have a Tooltip class that hold a Label by default, so with a owning semantic instead of inheriting, and allow the user to change the displayed widget. That will allow to create rich tooltip with many information (just like in many games when hovering an item in an inventory), or display a single line with different polices (this kind of tooltip is used inside QtCreator, but I'm not able to make a print screen of it, it disappear at the key pressure... ).

11
Help requests / Re: Get Grid working
« on: 29 May 2015, 14:16:05 »
Ok, this feature is the only one I need, all others feature you mentionned (scrollbar, lines, ...) can be done with others widgets relatively  easily.

In another unrelated topic (I found it more natural to continue discussion here instead of open another topic), would it be possible to customize a bit more widgets like Tab, Tooltip and ChildWindow ? Actually, these widgets use Labels for rendering (the ChildWindow use it for the close button). It would be nice to use custom widget instead of the default Label, or at least a picture, allowing to put nice images for tabs and close button on window, or complete tooltip full of informations.

12
Help requests / Re: Get Grid working
« on: 29 May 2015, 13:33:25 »
Ok, I can now show the labels, but how can I make the grid fit the whole size of the window ?
I wrote
Code: [Select]
grid->setSize(bindWidth(gui), bindHeight(gui)); but it seems to doesn't have any effect, the grid has the size of the labels in it, in place of fitting the whole window and centering labels in the cells. Maybe the grid is not intented to do that ?..

In fact, I would like to do an interface like this : https://i1.ytimg.com/vi/WA1sLQ55FII/maxresdefault.jpg
with the ability to select which columns are shown. So a grid would be nice for the big list, but I cannot make it fitting the whole width.

13
Help requests / Get Grid working
« on: 29 May 2015, 13:06:35 »
Hello,
The solution should be obvious, but I cannot get a Grid working properly:
Code: [Select]
#include <TGUI/Gui.hpp>
#include <TGUI/Label.hpp>
#include <TGUI/Grid.hpp>
#include <TGUI/Panel.hpp>

int main()
{
using tgui::bindWidth;
using tgui::bindHeight;
sf::RenderWindow window(sf::VideoMode(400, 300), "TGUI window");
tgui::Gui gui(window);
gui.setGlobalFont("DejaVuSans.ttf");

auto grid = tgui::Grid::create();
grid->setSize(bindWidth(gui), bindHeight(gui));
gui.add(grid);

std::vector<std::vector<sf::String>> itemListList = {{"Hello", "The", "World"}, {"TGUI", "is", "great!"}, {"Roses", "are", "red"}};
for(unsigned i{0}; i < itemListList.size(); ++i)
{
for(unsigned j{0}; j < itemListList[i].size(); ++j)
{
tgui::Label::Ptr label = tgui::Label::create();
label->setTextSize(10);
label->setText(itemListList[i][j]);
label->setTextColor(sf::Color::Black);
grid->addWidget(label, i, j);
}
}
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            gui.handleEvent(event);
        }
        window.clear(sf::Color::White);
        gui.draw();
        window.display();
    }
    return 0;
}

I simply get a white screen, without text at all.

I'm using last TGUI and SFML versions.

14
In the code I posted, the fix you offer is easy to implement, but I found this bug in a game I'm developping with a high abstraction level with many classes, so it is no this obvious to move functions calls on the Canvas outside the clear/display calls on the window.
So you also mentionned I can call window.resetGLStates() or window.activate() right before gui.draw(), is there any side effect of this method in place of moving the calls on Canvas?

(And I knew for the canvas code shortening, I just copy-pasted parts of you example codes)

Thanks :)

15
Help requests / [Bug] Clipping issue with Panel and canvas.
« on: 28 May 2015, 17:09:26 »
Hello,
I found a bug occurring in following situation:
-A widget is inside a Panel
-This widget overlap the bounds of the panel (so it should be clipped).
-A Canvas is also somewhere else.
In this case, the widget is not clipped at all at the bounds of the the Panel.
Have a look at this code:
Code: [Select]
#include <TGUI/Gui.hpp>
#include <TGUI/Panel.hpp>
#include <TGUI/Button.hpp>
#include <TGUI/Canvas.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(400, 300), "TGUI window");
    tgui::Gui gui(window);
    gui.setGlobalFont("DejaVuSans.ttf");

auto panel = tgui::Panel::create();
panel->setSize(tgui::bindWidth(gui.getContainer(), 0.5f), tgui::bindHeight(gui.getContainer(), 0.5f));
panel->setBackgroundColor(sf::Color::Transparent);
gui.add(panel);

    auto play = tgui::Button::create();
    play->setSize(tgui::bindWidth(gui.getContainer()), tgui::bindHeight(gui.getContainer()));
    play->setText("Play");
    panel->add(play);

    tgui::Canvas::Ptr canvas = tgui::Canvas::create({300, 300});
    gui.add(canvas);
    sf::Texture tex;
    tex.loadFromFile("Linux.jpg");
    sf::Sprite spr(tex);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            else if (event.type == sf::Event::Resized)
                gui.setView(sf::View{{0, 0, (float)event.size.width, (float)event.size.height}});
            gui.handleEvent(event);
        }
        window.clear();
        canvas->clear();
        canvas->draw(spr);
        canvas->display();
        gui.draw();
        window.display();
    }
    return EXIT_SUCCESS;
}
The button fills totally the window but the panel owning the button don't.

I'm using TGUI-0.7dev, SFML-2.3 (both latest snapshot) and gcc-4.9.

Pages: [1] 2