2020-06-01 10:42:28 +02:00
|
|
|
// IDEA: render to a cache buffer, then if not changed, copy the buf into the parent
|
2020-06-02 03:44:44 +02:00
|
|
|
type Surface = ();
|
2020-06-01 10:42:28 +02:00
|
|
|
pub trait Component {
|
|
|
|
/// Process input events, return true if handled.
|
2020-06-02 03:44:44 +02:00
|
|
|
fn process_event(&mut self, event: crossterm::event::Event, args: ()) -> bool;
|
2020-06-01 10:42:28 +02:00
|
|
|
/// Should redraw? Useful for saving redraw cycles if we know component didn't change.
|
2020-06-02 03:44:44 +02:00
|
|
|
fn should_update(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2020-06-01 10:42:28 +02:00
|
|
|
|
|
|
|
fn render(&mut self, surface: &mut Surface, args: ());
|
|
|
|
}
|
|
|
|
|
2020-06-02 03:44:44 +02:00
|
|
|
// HStack / VStack
|
2020-06-01 10:42:28 +02:00
|
|
|
// focus by component id: each View/Editor gets it's own incremental id at create
|
|
|
|
// Component: View(Arc<State>) -> multiple views can point to same state
|
|
|
|
// id 0 = prompt?
|
|
|
|
// when entering to prompt, it needs to direct Commands to last focus window
|
|
|
|
// -> prompt.trigger(focus_id), on_leave -> focus(focus_id)
|
|
|
|
// popups on another layer
|