armory3d / armory2d

2D Editor
zlib License
83 stars 24 forks source link

Add more tooltips #34

Closed MoritzBrueckner closed 4 years ago

MoritzBrueckner commented 4 years ago

This PR adds some more tooltips to the settings in Armory2d.


@luboslenco I'm planning to implement automated tooltips by passing a description value to UI elements. This would enable game devs to add tooltips to elements from within Armory2D. It works great with handles (by adding a "description" key to them), but not every element uses a handle. A solution would be to pass the description as an argument (with default value ""), but Haxe doesn't support passing arguments by name. Because of that, adding a description to an element by passing it as an argument would require passing all other arguments that have a default value before that (or the other way around if we put the description parameter further to the front of the functions parameters). My idea is to extend the handle's functionality so that it stores all arguments for the element's function (labels, alignment etc.). Every element would then only need a handle as an argument. Another positive side effect of this solution is that multiple elements at different places could share the same function and look. What do you think about that? Do you have another idea/any preferences? I don't want to rewrite a lot without asking you first :)

BlackGoku36 commented 4 years ago

Speaking of tooltips, i tried adding tooltips for canvas for game. There is one bug that prevent me from creating PR, when you trigger tooltip by hovering over UI(button for example) than move mouse away from button to untrigger tooltip, tool tip will come back everytime even when you aren't hovering over any element, to stop this bug, you will have to hover over element that doesn't have tooltip. Code change is simple, add if(sometext != "" && ui.isHovered) ui.tooltip(sometext);below UI element declaration like shown in zui's elements example.

luboslenco commented 4 years ago

Thanks!

Regarding the handles, it is a flaw in zui design. Ideally there would be no handles at all or just Ints. But for now adding description/tooltip key to Canvas.TElement and exposing that to armory2d should at least make it possible to define tooltips.