Skip to content

What information should be exposed to widgets? #15

Description

@airblast-dev

When creating and rendering a widget a set of information and capabilities must be available such as:

  • Writing cells
  • Display width, height
  • The area to render the widget in

If you want to support animations and collapsing cells you also need:

  • The time delta (animations)
  • Collapsed borders so blocks can be merged together (collapsing cells)

While these are the most common ones a widget implementer needs, there some more niche ones as well:

  • Mouse position
  • Cursor position

These are a bit problematic as it would allow users to implement bad widgets where it keeps moving the cursor around and remove control from the widget user. I think that implementations that rely on some state like the cursor position should be handled outside of the widget. So in practice this means the provided argument should not allow the cursor to be moved around.

My main question is: What information should be exposed to a widget as a minimum?


When I say Widget I am referring to a trait and its draw function with the set of information mentioned above as an argument.

Using a trait here allows the users to use dynamic dispatch (Box<dyn Thing>) to implement something like a bunch of swap-able panes of different widgets determined at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions