Comments (4)
I don't think the performance is that important, the string isn't evaluated every frame, only when you actually change the size or position of a widget. Performance can always be improved in the future, initially the most important thing is that it works.
What exactly do you mean by using lambda expressions? Using them where? Could you give a small example?
from tgui.
Now to counting dynamically we must write something like that:
label->setPosition({ "{&.h+(&.w-&.h-20)*0.715+5,3+(&.h-10)*0.05}" });
The same code with lambda expression:
label->setPosition({ [label]()->float {
auto w = label->getParent()->getSize().x;
auto h = label->getParent()->getSize().y;
return h + (w - h - 20) * 0.715 + 5;
} },{ [label]()->float {
auto h = label->getParent()->getSize().y;
return 3 + (h - 10) * 0.05;
}});
When we used to this lambda expression we have more possibilities. In lambda expression we can use function which we want. And there is no need to use parser.
from tgui.
At first I thought this was a great idea, it wouldn't even be that hard to implement. But then I realized that it can't work: there is no way the label could know when to recalculate its position.
from tgui.
What a pity! I see, we would have to manually add the signals, but it cause obfuscated code and it is potential place to make a mistake.
from tgui.
Related Issues (20)
- Gamepad support? HOT 5
- Autocomplete support for EditBox HOT 2
- Can not input CJK words HOT 9
- Black background shown when changing window size HOT 4
- How to customize the window's title bar and frame HOT 2
- How to implement a polygon window HOT 2
- Hover style does not disappear when mouse moves out of the window HOT 6
- Add a 2d chart or rendering 3d data for TGUI? HOT 1
- Chinese support? HOT 5
- Focus Issues HOT 1
- [ANNOUNCE] The TGUI now distributed via MSYS2 on Windows HOT 1
- CMake fails to install pkg-config files HOT 2
- On macOS, Input Method Editors(IME) behavior seems incorrect. HOT 6
- How to use SDL2/3 backend with cmake `FetchContent` HOT 2
- [Question] How to compile my first example of TGUI ? HOT 13
- [Bug] Dead radio button text HOT 3
- [Bug] Tabs state after disabled tab click HOT 2
- FileDialog documentation needs clarification and maybe working examples HOT 4
- Is there a C binding? HOT 12
- Raylib backend? HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tgui.