-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom widgets #16
Comments
Providing the custom implementationsWe already allow custom widgets (e.g. all Event handlingAs noted above, this is already possible via implementation of the parameterised Size + drawingThe straightforward option would be to add To allow use of parameterised / external APIs, we should instead add draw/size functions to the Misc. functionsPossibly we should move functions like Since solutions require modifications to the |
Custom widgets are now possible using the "theme" helpers Exemplar: the |
Custom widget implementations need to define several details. It turns out this is not trivial, though the following provides good inspiration for a design.
Size
The widget should return a
SizeRules
as e.g.Theme::size_rules
. This requires some details, e.g. adraw
object (to generate text dimensions), the axis, and the DPI.Drawing
The question here is over which API should user-implemented widgets do their drawing? Some options:
kas::draw::Draw
: a fixed draw trait; does not allow themes to influence custom widgets; does not allow direct access to things likewgpu::Device
kas_wgpu::DrawWgpu
); allows lower-level drawing but still does not allow theme influence; additionally, use of generics will require some redesign of widget traitsTheme
APIProbably the best answer here is the most complex one: extend the
Theme
trait API and allow direct access to draw traits via generics, along with theme colours.Alternative (also for size): allow custom widget classes, and use a theme-extension to draw this. This option requires much of the above still: high-level draw operations in the
Theme
trait, theme colours, access to low-level draw devices.Event handling
This is covered already by the
event::Handler
trait (may require tweaking).Errata
Further details which should be customisable:
The text was updated successfully, but these errors were encountered: