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.


Topics - texus

Pages: [1]
1
Themes / ===== Read before posting =====
« on: 04 June 2019, 12:50:02 »
In this forum section you can share themes that you created. For general help with themes, the help requests section would be a more suitable place.

When sharing a theme, please provide at least the following information:
  • A list of widgets supported by your theme
  • A screenshot showing some of the widgets with your theme

All themes shared here are freely usable and considered public domain unless explicitly stated otherwise!

2
General Discussion / New signal system
« on: 03 March 2019, 13:22:49 »
I'm currently thinking about changing the signal system.
Depending on how the new system would look like, it will only be added in TGUI 0.9 or it will already be added in 0.8 (but if it is added in 0.8 then the current system will be kept as well for backwards compatibility).

Currently I have been pushing a signal system that looks like this:
child->connect("closed", []{});

This is very flexible as the string could be read from a text file. The downside is that typos aren't caught at compile time.
Another issue is that the supported parameters of the function are only known at runtime (as they depend on the signal name), so the function signature can't be checked at compile-time either.

An improvement could be made by defining contant strings so that you would be able to write the following:
child->connect(tgui::ChildWindow::Closed, []{});

Because tgui::ChildWindow::Closed is a string, it is backwards compatible with the old system and using a string read from a text file is still possible. It also prevents typos.
The function signature is however still can't be checked at compile time and it adds extra code: the line is longer and the type of the widget has to be repeated on every connect call.

Currently a different method already exists, but it has been marked deprecated because I was pushing the signal systems with strings. Maybe I should stop deprecating it and start recommending something like this:
child->onClose.connect([]{});

It is shorter and has less repetition than having to use tgui::ChildWindow::Closed. It also allows the function signature to be checked on compile time.

It no longer allows passing a string read from a text file, but something could be done for that. If a system like this would be chosen then I will still keep some connect function that takes a string as parameter. The difference with the current implementation would be that the function signature would be limited: you would be able to pass a function without argument or taking a pointer to the widget and/or the name of the signal. The use unbound parameters (e.g. getting the text of a button as parameter) would only be possible via button->onPressed.connect(...), but not via button->connect("pressed", ...). This should however not be an issue, when loading these strings from a text file you are likely to bind a general callback function that doesn't take different parameters for different widgets (because if you know the widget type and signal upfront then you could just use the onXyz object).

TGUI currently has no public objects in its interface (other than these signals) so there is no naming convention for these signals yet. Maybe it would look slightly better if onClose would become Closed:
child->Closed.connect([]{});

Someone also suggested the following, although that might be more difficult to implement with inheritance:
child->connect.Closed([]{});

Which of these options would you like the use mostly in your code?

If you have comments or other ideas then feel free to post them in this topic.

3
Help requests / ===== Read before posting =====
« on: 26 June 2014, 18:21:00 »
This topic will provide some general rules to follow when posting, and small guides on how to solve some common mistakes.

Please read through this topic before posting.

Pages: [1]