GithubHelp home page GithubHelp logo

texus / tgui Goto Github PK

View Code? Open in Web Editor NEW
755.0 33.0 86.0 40.27 MB

Cross-platform modern c++ GUI

Home Page: https://tgui.eu

License: zlib License

CMake 1.72% C++ 98.23% Makefile 0.02% Python 0.03%
tgui sfml cross-platform gui ui c-plus-plus gamedev

tgui's Introduction

TGUI - Texus' Graphical User Interface

TGUI is a cross-platform modern c++ GUI library.
Although originally a library for SFML, it now also has backends for SDL, GLFW and raylib.

For more information, take a look at the website.

TGUI 0.10 White theme TGUI 0.10 Black theme

Status

CI Github Actions Code coverage

OS support for each backend:

Windows Linux macOS Android iOS
SFML_GRAPHICS ✔️ ✔️ ✔️ ✔️ ✔️ ❓
SFML_OPENGL3 ✔️ ✔️ ✔️ N/A N/A
SDL_RENDERER ✔️ ✔️ ✔️ ✔️ ✔️ ❓
SDL_TTF_OPENGL3 ✔️ ✔️ ✔️ N/A N/A
SDL_TTF_GLES2 ✔️ N/A ✔️ ✔️ ❓
SDL_OPENGL3 ✔️ ✔️ ✔️ N/A N/A
SDL_GLES2 ✔️ N/A
GLFW_OPENGL3 ✔️ ✔️ ✔️ N/A N/A
GLFW_GLES2 ✔️ N/A N/A N/A
RAYLIB ✔️ ✔️ ✔️ N/A

Dependencies for each backend:

Window backend Font backend Rendering backend
SFML_GRAPHICS sfml-window (>= 2.5) sfml-graphics (>= 2.5) sfml-graphics (>= 2.5)
SFML_OPENGL3 sfml-window (>= 2.5) FreeType (>= 2.6) OpenGL (>= 3.3)
SDL_RENDERER SDL (>= 2.0.18) SDL_ttf (>= 2.0.14) SDL (>= 2.0.18)
SDL_TTF_OPENGL3 SDL (>= 2.0.6) SDL_ttf (>= 2.0.14) OpenGL (>= 3.3)
SDL_TTF_GLES2 SDL (>= 2.0.6) SDL_ttf (>= 2.0.14) OpenGL ES (>= 2.0)
SDL_OPENGL3 SDL (>= 2.0.6) FreeType (>= 2.6) OpenGL (>= 3.3)
SDL_GLES2 SDL (>= 2.0.6) FreeType (>= 2.6) OpenGL ES (>= 2.0)
GLFW_OPENGL3 GLFW (>= 3.2) FreeType (>= 2.6) OpenGL (>= 3.3)
GLFW_GLES2 GLFW (>= 3.2) FreeType (>= 2.6) OpenGL ES (>= 2.0)
RAYLIB raylib (>= 4.2) raylib (>= 4.2) raylib (>= 4.2)

Download

You can download the source code of the current development version from the git repository: Download ZIP

Precompiled libraries for some compilers are available for each release.

Learn

Contact

Name: Bruno Van de Velde

E-mail: [email protected]

Discord

Donate

Patreon

tgui's People

Contributors

1aam2am1 avatar bebu avatar casualyt31 avatar creepsky avatar goverlabs avatar gupascal avatar jayhawkzombie avatar kvaz1r avatar mickes27 avatar miv99 avatar posva avatar racebennnett avatar rgpaul avatar rubenwardy avatar ruckamongus avatar schweini07 avatar steffenploetz avatar tedlyngmo avatar texus avatar thalinsgenohan avatar theillusionistmirage avatar xandayn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tgui's Issues

Cutting off the half of the last line in chatbox

Hi,
I found bug in chatbox in tgui 0.7 in code below:

 // Display the last lines when there is no scrollbar
if (!m_scroll)
{
    if (positionY > getSize().y)
    {
        float diff = positionY - getSize().y;
        for (auto it = m_panel->getWidgets().begin(); it != m_panel->getWidgets().end(); ++it)
            (*it)->setPosition({(*it)->getPosition().x, (*it)->getPosition().y - diff});
    }
}

When in chatbox is no scrollbar, appears an error in the calculation of positionY and it cause cutting off half of the last line.

I try change getSize().y on m_panel->getSize().y and it help. After that change it looks good.

The problem of loading decimal numbers from saved widgets.

I found problem in functionality of loading/saving widgets in TGUI v0.7.
In my application I'm using polish locale. In Poland we are using ',' as separator in decimal numbers.
When I save widget in size: width = 10.5 and height = 11.5 then the output file contain:

Size: (10,5, 11,5);

The reading function doesn't handle it.

Proposition: Greater flexibility read and write functions.

Can you change in class WidgetLoader in function load the stringstream on istream?
Then widgets can be loaded directly from file and the current functionality will be untouched.

A similar change can be made in class WidgetSaver, instead of stringstream used ostream.

Put friend keyword first

I am currently trying to use Swig to bind TGUI to Lua. However, they make a statement that Swig does not recognize "non-conventional type declarations."[1] In SharedWidgetPtr.hpp, I have to change the friend keyword to be placed before the return type. If this is not done, I get that a syntax error is in your header file. I think swapping the location of the friend keyword is a really simple change. Thanks.

bool friend operator ==(const SharedWidgetPtr<T>& left, const U* right) // Error
friend bool operator ==(const SharedWidgetPtr<T>& left, const U* right) // OK

[1] http://www.swig.org/Doc3.0/SWIG.html#SWIG_nn8

[0.8-DEV]Label Color is missing ?

Hello,

I have try tgui 0.8-dev for make it my project (Multi-Game launcher) ...

Lot's of work is finish , i'm happy ... Now i create "light" interface

And i have see no option for change color of label, i can't downgrade to 0.7 at this point .

Can you add it please ?

Right alt problem

Hi,
I found small bug related with right alt. When using editbox, I noticed that whenever I press right alt + "a" the text in the control is cleared and put character "ą" (Polish diacritical mark). I made some investigation and found functionality ctrl + a which select text. Then I saw that insert right alt + a is recognized as ctrl + alt + a. It's looks weird but I found on internet information that it is normal. Functionality in editbox to select all text, checks only ctrl key and doesn't check other special keys. I think should be checked if other special keys aren't pressed.

More about this: http://blogs.msdn.com/b/oldnewthing/archive/2004/03/29/101121.aspx

TGUI 0.7

Regards,

Problem with text in tgui::ChatBox

I have problem with drawing text in tgui::ChatBox like on screenshot
bug

Here code where i create chat box:

m_chatPanel = tgui::Panel::Ptr((*gui));
m_chatPanel->setPosition(0, GraphicSystem::instance()->getWindowHeight() - 282);
m_chatPanel->setSize(260, 282);
m_chatPanel->setBackgroundColor(sf::Color(50,50,50));
{
    m_chatBox = tgui::ChatBox::Ptr((*m_chatPanel));
    m_chatBox->load("data/gui/objects/Black.conf");
    m_chatBox->setPosition(10, 10);
    m_chatBox->setSize(240, 222);
    m_chatBox->setTextSize(12);

    m_editBoxChat = tgui::EditBox::Ptr((*m_chatPanel));
    m_editBoxChat->load("data/gui/objects/Black.conf");
    m_editBoxChat->setPosition(10, 242);
    m_editBoxChat->setSize(240, 30);
    m_editBoxChat->setTextSize(12);
}

My config:
SFML revision SFML/SFML@44b98b4
TGUI revision 2189df4
Win7 64 pro sp1
mingw 4.7.4

Add a Time Widget

So I thought of adding in a Time Widget which is just a label that updates itself to the current system time.

I can open a pull request if your interested, or you can do it. I don't mind.

Thoughts?

Stack Overflow when on loading widgets from file

I get the same error as #54 when loading widgets from a file.
File where i receive this error:

Panel {
    Position: (150, 150);
    Size: (410, 110);

    Renderer {
        BackgroundColor: Transparent;
    }

    Picture.ObrazObiektu {
        Filename: "resource\\Brak_obrazka.png";
        Position: (5, 5);
        Size: ("&.h-10", "&.h-10");
    }
}

Custom Resource loader

There should be a way to handle resource loading completely out of the library. For example if you wanna load your resources out of a zip file or you wanna use physfs (http://icculus.org/physfs/) you need to be able to load every resource with custom code.

Add support for tables.

At the moment, the only way I can think of implementing tables is to have multiple list boxes side-by-side. Obviously this is not ideal, and would be much nicer if there were some built-in way to do this.

Clipping with Panel

It seems that Panel do not clip any more its children.
Adding window.resetGLState(); or

window.pushGLState();
gui.draw();
window.popGLState();

has no effect.
Here is a example code that shows the issue:

#include <TGUI/Gui.hpp>
#include <TGUI/Button.hpp>
#include <TGUI/Panel.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "TGUI");
    tgui::Gui gui(window);
    gui.setGlobalFont("DejaVuSans.ttf");
    auto panel = tgui::Panel::create({100, 100});
    gui.add(panel);
    auto button = tgui::Button::create();
    button->setText("TGUI");
    button->setSize(200, 200);
    panel->add(button);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
            gui.handleEvent(event);
        }
        window.clear();
        gui.draw();
        window.display();
    }
    return 0;
}

Widget.setSize segmentation fault

It appears that setSize causes a segmentation fault when using it like this (taken from example program):

picture->setSize(tgui::bindMax(800, windowWidth), tgui::bindMax(600, windowHeight));

I'm using TGUI version 0.7.4 and SFML 2.2.3 on Linux 64 bit.

connect/disconnect id mismatch

There is a mismatch between the id a function receives when it is connected and the one returned from the connect function.

Inside connect, function registered with: id
Value returned from connect: id+1.

This leads to an exception when disconnect is called with the returned id. I have this behavior, e.g., when connecting/disconnecting a function to the clicked signal of a button.

Problem with cmake install on linux

Then use install on linux i get this problems:

=======================================================
======================= Build =========================
=======================================================
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found SFML 2.1 in /home/taten/Dev/SFML_project/SFML_install/include
-- Looking for XOpenDisplay in /usr/lib/i386-linux-gnu/libX11.so;/usr/lib/i386-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/i386-linux-gnu/libX11.so;/usr/lib/i386-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/i386-linux-gnu/libX11.so
-- Found OpenGL: /usr/lib/i386-linux-gnu/libGL.so  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/taten/Dev/TGUI_project/TGUI_build
-- Found SFML 2.1 in /home/taten/Dev/SFML_project/SFML_install/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/taten/Dev/TGUI_project/TGUI_build
Scanning dependencies of target tgui
[  3%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/TGUI.cpp.o
[  6%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Callback.cpp.o
[  9%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Transformable.cpp.o
[ 12%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Widget.cpp.o
[ 15%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Label.cpp.o
[ 18%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Picture.cpp.o
[ 21%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Button.cpp.o
[ 25%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Checkbox.cpp.o
[ 28%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/RadioButton.cpp.o
[ 31%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/EditBox.cpp.o
[ 34%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Slider.cpp.o
[ 37%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Scrollbar.cpp.o
[ 40%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ListBox.cpp.o
[ 43%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/LoadingBar.cpp.o
[ 46%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ComboBox.cpp.o
[ 50%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/TextBox.cpp.o
[ 53%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/SpriteSheet.cpp.o
[ 56%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/AnimatedPicture.cpp.o
[ 59%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/SpinButton.cpp.o
[ 62%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Slider2d.cpp.o
[ 65%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Tab.cpp.o
[ 68%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ConfigFile.cpp.o
[ 71%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/TextureManager.cpp.o
[ 75%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Container.cpp.o
[ 78%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Panel.cpp.o
[ 81%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ChildWindow.cpp.o
[ 84%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Grid.cpp.o
[ 87%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Gui.cpp.o
[ 90%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ClickableWidget.cpp.o
[ 93%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/MenuBar.cpp.o
[ 96%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ChatBox.cpp.o
[100%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/MessageBox.cpp.o
Linking CXX shared library ../../lib/libtgui-d.so
[100%] Built target tgui
[100%] Built target tgui
Install the project...
-- Install configuration: "Debug"
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Transformable.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Label.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/SharedWidgetPtr.inl
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/ClickableWidget.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/LoadingBar.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/AnimatedPicture.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/TGUI.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/ChatBox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/RadioButton.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/SpinButton.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/SpriteSheet.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Container.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/ListBox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Picture.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/MenuBar.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/SharedWidgetPtr.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Tab.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Grid.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/ConfigFile.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/FormBuilder
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/FormBuilder/MenuBar.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/FormBuilder/Form.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/FormBuilder/WidgetData.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/FormBuilder/FormBuilder.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/MessageBox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Config.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Scrollbar.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/EditBox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Panel.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/TextureManager.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/ChildWindow.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/TextBox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Checkbox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Button.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Borders.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Slider2d.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/ComboBox.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Gui.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Callback.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Defines.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Slider.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/./include/TGUI/Widget.hpp
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/lib/libtgui-d.so.0.6
-- Installing: /home/taten/Dev/TGUI_project/TGUI_install/lib/libtgui-d.so
CMake Error at src/TGUI/cmake_install.cmake:73 (FILE):
  file cannot create directory: /usr/local/share/tgui-0.6/widgets.  Maybe
  need administrative privileges.
Call Stack (most recent call first):
  cmake_install.cmake:41 (INCLUDE)


make: *** [install] Ошибка 1

Problem config:
Lubuntu 13.04 x32
gcc 4.7.3
SFML revision SFML/SFML@369b7fa
TGUI revision e96d087

Proposition: Additional data in widget

Sometime I need associate widget with additional data. Now i must do it by std::map or std::vector. But more comfortable would be get data direct from widget. Could you add to the widget additional pointer to external data?
Below I join examples of function declarations.

void *getAdditionalData() const;
void setAdditionalData(void* data);

Checked and Unchecked triggers of Checkbox are emitted too early

See this code:

checkbox->bindCallbackEx(function, tgui::Checkbox::Checked | tgui::Checkbox::Unchecked);

void function(const tgui::Callback& callback)
{
    if (callback.checked != callback.widget->isChecked())
        cout<<"this message appears";
}

function was called before widget state was changed (callback.ckecked has the right value, not callback.widget->isChecked())

I don't fix this myself because I am not sure if there are other widgets and/or other triggers like this. Probably RadioButton...

sf::Text::findCharacterPos in EditBox

The findCharacterPos function returns a global position. The limitTextWidth function crashes on line 861 because that code assumed a local position.

Line 858 should become the following:
while (m_TextBeforeSelection.findCharacterPos(m_DisplayedText.getSize()).x - getPosition().x > width)

Although no other problems are visible, other uses of findCharacterPos should be reviewed. EditBox uses the function on various places, and not all seem to take the position into account. Now we are at it, look at the other widgets as well.

Wasn't findCharacterPos used because of a bug in getLocalBounds (about spaces at the beginning and end of the string)? If this bug has been fixed then the code can perhaps use getLocalBounds again?

Rewrite Tab class

There are a lot of things that the Tab class is missing, at least some of these should be added. The fixed tab width will definitely be added to v0.7 v0.8 while an tab with images is very likely to be added as well.

  • Fixed tab width
    The width of the tab currently depends on its contents. A consequence of this implementation was that the setSize function is empty and Tab cannot be scaled like other widgets. Adding a fixed tab width will solve this problem. The setSize function will set the total width and the tab height, the individual tab width becomes total width / nr of tabs. But setting a specific tab width might be wanted as well in which case the total width still has to be variable like it is now.
  • Hover state
    It might be a nice addition to also have a different color on hover like ListBox has for its items.
  • Minimum tab width
    Right now you can set a maximum tab width but not a minimum. The minimum is actually set to 2 * distance to side, but it should be more flexible and thus the user should be able to specify this value himself.

Edit: The following features are not be part of the rewrite. They could still be added in the future, but this issue will not remain open until then.

  • Images in tabs
    Every tab currently contains a Label, but it should be possible to store a Picture in it. Since both versions behave very similar but they are hard to combine, they should probably be split in two classes which inherit from a base tab class which does most of the work. The question then becomes if it is possible to have a Tab class that contains an image with text next to it.
  • Enlare selected tab
    It should be possible to enlarge the currently selected tab, especially when there is a fixed tab size. When no tabs are selected then then selecting a tab might increase the total width or decrease the individual tab widths, but in most cases one tab will already be selected and thus changing tab does not changes the total size. Making it larger vertically should also be possible but then the question becomes in which direction it should expand. Should changing the bottom or top of the individual tab impact the reported top or height of the widget? First thought is no, but when inside a HorizontalLayout it might be needed to fully display.
  • New tab
    An extra tab on the right could be optionally added to create a new tab. The user should have some way to set what the text of this tab is. Since he will probably want to do something when the tab opens it could perhaps be set in the callback that the user gets instead of having to add another setter.
  • Close button
    Adding an optional close button to each tab might be wanted in some cases.
  • Dragging
    The should be an option to allow reordering tabs by dragging them.

Autosized Label doesn't support multiline text.

That bug was introduced in your commit bd65356.
When you have a Label with a text like:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
turpis enim. Etiam sit amet sapien faucibus, euismod urna vel,
ultrices et quis turpis. Quisque varius consequat mauris lacinia
dapibus. Suspendisse et lorem sollicitudin, varius sit orci non,
volutpat mi.

only

Lorem ipsum
turpis enim.
ultrices et 
dapibus. Sus
volutpat mi.

will be displayed, because you use the last character to determine the width of the Label.

Issue in layout as a string

When I used layout as a string like this :

label_->setPosition({"&.w < w ? 0 : (&.w - w) / 2"}, { "&.h < h ? 0 : (&.h - h) / 2" });

the condition in this expression is incorrectly calculated. Instead of

&.w < w
&.h < h

is calculated:

&.w > w
&.h > h

Tgui::Gui has virtual methods but no virtual destructor

warning: deleting object of polymorphic class type 'tgui::Gui' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]

This occurs when using dynamic allocation via operator new and operator delete for tgui::Gui instances.

CMake with MinGW C++11 compile issues

I get errors such as "stoi is not a member of std" now when compiling using mingw32-make and CMake.

I checked CMAKE_CXX_FLAGS and it is
-Wall -Wextra -Wshadow -Wno-long-long -pedantic -std=c++0x

It seems to include the -std=c++0x flag that is necessary but the error I am getting is the error that would occur if the flag was not there.

Allow list box items to be listed in reverse order

I'm currently designing a console for my project using TGUI, and I've had to do a couple workarounds. I was curious if you think these implementations could be useful, if so I could attempt to add this to TGUI.

Here is an example of when adding an upside down list box could be useful
console

the console is actually an Edit box at the bottom for input, and a List box right above is echoing past commands for the user to see. The work around i've been doing at the moment is I've had to preallocate 13 items to fill the size of the listbox, and upon modification I need to pretend the last element is the first:

d_console_command_list = tgui::ListBox::Ptr(gui);
d_console_command_list->load("TGUI/widgets/black.conf");
d_console_command_list->setSize(400,180);
d_console_command_list->setPosition(0,0);
d_console_command_list->removeScrollbar();
d_console_command_list->setItemHeight(15);
for(int i = 0; i < COMMAND_COUNT+1; i++) {
    d_console_command_list->addItem(" ", i);
}

what might be useful for others is being able to instead set the listbox to add an item starting from the bottom instead, with an on/off function say listDirection(bool up=true);. Ugly name but you see what I'm proposing. that could cut that code down to

d_console_command_list = tgui::ListBox::Ptr(gui);
d_console_command_list->load("TGUI/widgets/black.conf");
d_console_command_list->setSize(400,180);
d_console_command_list->setPosition(0,0);
d_console_command_list->removeScrollbar();
d_console_command_list->setItemHeight(15);
d_console_command_list->listDirection(false); //list starting from bottom

not only that, but when echoing commands/output and handling when to cut off information all that would be required would when that the upper most element goes beyond a current threshold simply delete said item. It would be a much clear approach to my current way of doing this called translateUp

//move all commands up one to simulate a normal console
for(int i = 0; i < COMMAND_COUNT; i++) {
    std::string next = (d_console_command_list->getItem(i+1)).toAnsiString();
    d_console_command_list->changeItem(i,
        next);
}
//change the last element to what the user just entered
d_console_command_list->changeItem(
    COMMAND_COUNT, 
    d_console_edit_box->getText().getData()
);
d_console_edit_box->setText("> ");

Let me know what you think, and if you think this would be something TGUI might want to support.

An internal OpenGL call failed...

Start receiving this:

An internal OpenGL call failed in RenderTarget.cpp (399) : GL_INVALID_VALUE, a numeric argument is out of range

On oldest TGUI revision ab69785 all is good.

Problem config:
SFML revision SFML/SFML@718588f
TGUI revision e79a554
Win8 32 pro and Win7 64 pro
gcc 4.8.0

Some Button::ButtonCallbacks not working

tgui::Button::PressedSpaceKeyPressed & tgui::Button::ReturnKeyPressed never trigger, not even when hovered above the button with the mouse and manually focused (in case that would matter).

other callbacks (including tgui::Button::AllButtonCallbacks, I guess because they contain if a button gets the focus) work fine.

ComboBox in a Grid

When a ComboBox is opened:
-if there is a widget in the cell below, this widget will partially hide the ComboBox.
-if the ComboBox is at the bottom of the Grid, you won't be able to select an item when it is opened. (Focus is lost).

For the first point, I am not sure, but perhaps, everywhere, the focused widget should be drawn at the end (and handle events the first).
For the second point, the focused widget might always test if it contains the mouse or not, even if the mouse is not on the parent container.

Stack Overflow when using Layout

When execute this code:

tgui::Panel::Ptr m_panel = std::make_shared<tgui::Panel>();
tgui::Label::Ptr nazwa_ = std::make_shared<tgui::Label>();
m_panel->add(nazwa_, "NazwaObiektu");
nazwa_->setSize({ "{ ( &.w - &.h - 20 ) * 0.715 , ( &.h - 11 ) * 0.15 }" });
m_panel->setSize(410, 110);

I receive stack overflow.

Problem with Locale and Layout

In my application I use Polish Locale. We are using ',' as decimal separator.
When I write something like that:

label_->setSize({ "{ ( &.w - &.h - 20 ) * 0.715 , ( &.h - 11 ) * 0.15 }" });

Layout counting it wrongly. '0.715' is interpreted as '0', because function atof expected ',' instead of '.'
But when I set decimal separator as ',' then this expression will be wrongly interpreted.

Chatbox cutting off bottom portion of words

I'm not sure weather this is an actual bug or not, but I can't seem to find any sort of solution to this problem so I'm coming here. That being said:

It seems no matter what I do, my console seems to cut off the lower part of words. The text is too far down in the chatbox and despite using all the available commands I can't correctly position the text to avoid being cut off. Here's a screenshot of the cut-off:

cutoff

the window is 400_w_ 200_h_, and the console is composed of an EditBox at the bottom and a ChatBox that will list commands.

in my Initialize function I set the properties of both to:

d_console_edit_box = tgui::EditBox::Ptr(gui);
d_console_edit_box->load("TGUI/widgets/black.conf");
d_console_edit_box->setSize(400,20);
d_console_edit_box->setPosition(0,180);
d_console_edit_box->setTextSize(12);
d_console_edit_box->setMaximumCharacters(32);
d_console_edit_box->setText("> ");

d_console_command_list = tgui::ChatBox::Ptr(gui);
d_console_command_list->load("TGUI/widgets/black.conf");
d_console_command_list->setSize(400,180);
d_console_command_list->setPosition(0,0);
d_console_command_list->removeScrollbar();
d_console_command_list->setLinesStartFromBottom(true);
d_console_command_list->setLineLimit(COMMAND_COUNT+1);
d_console_command_list->setTextSize(12);
d_console_command_list->setTextColor(d_console_edit_box->getTextColor());

I'm setting the size of the text the same in both these boxes, yet my Edit box doesn't do any sort of cutting off as my Chat box is doing. Is this a bug?

Ambiguous "abs" function call

When I tried to compile TGUI, I got this error :

TGUI\src\Widgets\Knob.cpp:370:77: error: call of overloaded 'abs(float)' is ambiguous

allowedAngle = 360 - abs(m_endRotation - m_startRotation);

(There is 3 other occurrences of abs in this file)

I could fix it by using std::abs instead of abs.
I'm using mingw64 on Windows 7 g++ version 6.2.0

Question about Layout

String expression to counting dynamically size and position of widgets looks cool 👍
I wonder, how it will be behave this mechanism used in many widgets? Did you do performance tests?

Have you considered using lambda expressions? I know that could be impossibly to used it with the save/load functionality and could be probably a lot of other problems about which i don't know. What do you think about that?

Cannot compile on lubuntu 13.04 my project

Cannot compile my project on lubuntu 13.04 on latest commit: ae80e7d recive this error:

libtgui.so: undefined reference to `tgui::SharedWidgetPtr<tgui::Widget>::operator->() const'

Revert to commit 7c02748 and all compiles ok!
My gcc 4.7.3 x86

A theme manager is required to balance coding style and efficiency

I noticed that theme loading was moved to widget creation in 0.7-dev branch.
This is much better than that in 0.6, but still leave problems for coding:
If I wanna avoid multiple theme loads for widgets, I have to use copy methods like this:

auto button1 = Button::create(filename, section);
....
button2 = button1->copy();
....

If using a theme manager, we can write codes like this, which is more graceful:

auto themeMan = ThemeManager::create(filename);
...
auto button1 = Button::create(themeMan, section);
...
auto button2 = Button::create(themeMan, secion);
...

Also, a theme manager could handle widgets of different types more efficiently, for only parsing theme config file once.

Allow capture of control keys in editbox

It would be useful to be able to capture things like "UP" or "CTRL-K" in an EditBox. One use case I've found recently was when using the EditBox as command input and allowing a history. Being able to capture the arrow keys here would make it easier to navigate the history.

Stack Overflow

When I try to run this code, the stack overflow occurs:

    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");

    tgui::Panel::Ptr m_panel_1 = std::make_shared<tgui::Panel>();
    tgui::Panel::Ptr m_panel_4 = std::make_shared<tgui::Panel>();
    tgui::Label::Ptr nazwa_1 = std::make_shared<tgui::Label>();


    nazwa_1->setAutoSize(true);
    nazwa_1->setTextSize(14);
    nazwa_1->setTextColor({ 255,255,255 });
    m_panel_1->add(nazwa_1, "Nazwa");
    nazwa_1->setPosition({ "w > &.w ? 0 : (&.w - w) / 2" }, { "h > &.h ? 0 : (&.h - h) / 2" });
    m_panel_1->setBackgroundColor(sf::Color::Transparent);

    tgui::Panel::Ptr m_panel_2 = tgui::Panel::copy(m_panel_1);
    tgui::Panel::Ptr m_panel_3 = tgui::Panel::copy(m_panel_1);
    tgui::Label::Ptr nazwa_2 = m_panel_2->get<tgui::Label>("Nazwa");
    tgui::Label::Ptr nazwa_3 = m_panel_3->get<tgui::Label>("Nazwa");

    m_panel_4->add(m_panel_1, "1");
    m_panel_4->add(m_panel_2, "2");
    m_panel_4->add(m_panel_3, "3");

    tgui::Gui gui(window);
    gui.setFont("resource\\arial.ttf");

    nazwa_1->setText("Text");
    nazwa_2->setText("Text");
    nazwa_3->setText("Text");

    gui.add(m_panel_4, "4");

    nazwa_3->setText("Text");

TGUI-0.6.5 (and the latest revision) crashes with SFML 2.1

Hi,

I downloaded TGUI-0.6.5 and compiled/installed it on Linux (Ubuntu) with SFML 2.1. The examples compiled successfully too, however, they give segmentation fault. The following is the minimal example that fails (assuming sansation.ttf is in same directory):

#include <TGUI/TGUI.hpp>

int main() {
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    gui.setGlobalFont("sansation.ttf");

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

            gui.handleEvent(event);
        }

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

Running through gdb gives the following backtrace:

Program received signal SIGSEGV, Segmentation fault.
0xb7f71eff in tgui::Gui::draw(bool) () from /usr/local/lib/libtgui.so.0.6.5
(gdb) bt
#0  0xb7f71eff in tgui::Gui::draw(bool) () from /usr/local/lib/libtgui.so.0.6.5
#1  0x08049324 in main ()

I commented out gui.draw(); and it runs fine, so something is wrong with that. I cloned latest TGUI branch, but same results, although I didn't try it with latest SFML branch because I assumed it should work with stable SFML version, so maybe the current branch isn't compatible with SFML 2.1?

Proposition: The order of addition of the line in ChatBox.

I have proposition of new feature in ChatBox widget. Now ChatBox adds line always at the bottom of the list. I propose to add an attribute to class and/or a parameter to the add function which informs about the order of the insertion elements (new at the top or new at the bottom of the list).

Form Builder

I think a form builder would be highly beneficial for use with TGUI. While for some projects hardcoding is fine, TGUI is also just as viable a choice for projects with large UI's with its robust and modern C++ design, making for hardcoding to become and more painful.

A form builder for v0.7 should at minimum have support for the original features of v0.6 (excluding deprecated parts of the API).

Due to the fact that v0.7 adds some significant new concepts and features, the form builder should likely reflect this. For example, the more advanced scaling and layout features.

I'd like to for this to be a discussion about what features should be in a v0.7 form builder.

small bug in splitimage widgets

When you set a size for a splitted button that is below the combined widths of it's L,R,M images, the button still has a minimum width of L+R+M, but the hitbox for mouse callback gets set to the specified size.
At first I thought this was probably expected behaviour because you aren't meant to set a size below L+M+R, but this only happens when the vertical size is left at the original vertical size. If i also scale on the y-Axis the button scales correctly, even below L+M+R. Then it seems to use scaling algorithm for the parts.

New (?) compile errors with VS2013

I think they are all template-related. Do you already know about them?
I'm asking because it seems like you already have/had problems with VS2013 (ListBox.cpp Line 64/65).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.