HeapsIO / heaps

Heaps : Haxe Game Framework
http://heaps.io
MIT License
3.2k stars 338 forks source link

[RFC] h2d.ui package #746

Open Yanrishatum opened 4 years ago

Yanrishatum commented 4 years ago

Sparked from same conversation that started talk about Heaps and community. Currently there are 2 specific elements in h2d that look out of place - h2d.Slider and h2d.Dropdown. On top of that, samples use their own implementation of basic components that aren't part of h2d. That approach always felt to me as kind of half-assed. I want to propose refactoring those elements into separate h2d.ui package and expanding library of basic UI components. Those components are often used for debug interfaces, hence they don't require super-customizability of how they are rendered. But I think expanding amount of available UIs out of the box would make life easier for developers as they can throw together dev interfaces far faster and focus on adding actual function rather than reinventing the wheel with making UI components. I would like to reiterate main point: This aims heavily to ease up making UI at early development stages just to get things working, before artists and other people tune in and make stuff look fancy.

Proposed changes

Move following classes from h2d to h2d.ui: Slider and Dropdown. Debatable if those should be moved or not: Flow, TextInput and Console.

Backward compatibility

As to not introduce breaking changes, same approach as with h2d.Sprite will be used: Instead of classes there would be typedefs:

@:deprecated("Moved to h2d.ui.T")
typedef T = h2d.ui.T

Expanding bundled UIs

Each component is debatable, obviously. Some can be excluded or some added. Those I consider as a must-have additions:

Those are "nice to have":

ncannasse commented 4 years ago

Regarding new package : I agree it's a good idea.

Regarding moving existing components:

One problem with these extra components is styling. If you want to customize the look'n'feel (not only colors, but also fonts, margin, etc.) you end up with something that is only partly customizable and at some point you often need to make your own custom implementation : a good example for that are html components.

That's why we only did the "behavior" components so far (the ones that have a complex behavior but with very low "display" code).

One way to handle styling and to have some kind of unified API would be to have all of them extend Flow. This also permits Domkit styling, which is a big plus (actually even requirement).