use std::fmt::Debug;
use super::{ComponentRegistryMap, EventPropagation, GlobalData, HasFocus};
use crate::{CommonResult, FlexBox, FlexBoxId, InputEvent, RenderPipeline, Surface,
SurfaceBounds};
pub trait Component<S, AS>
where
S: Debug + Default + Clone + Sync + Send,
AS: Debug + Default + Clone + Sync + Send,
{
fn reset(&mut self);
fn get_id(&self) -> FlexBoxId;
fn render(
&mut self,
global_data: &mut GlobalData<S, AS>,
current_box: FlexBox,
surface_bounds: SurfaceBounds,
has_focus: &mut HasFocus,
) -> CommonResult<RenderPipeline>;
fn handle_event(
&mut self,
global_data: &mut GlobalData<S, AS>,
input_event: InputEvent,
has_focus: &mut HasFocus,
) -> CommonResult<EventPropagation>;
}
pub trait SurfaceRender<S, AS>
where
S: Debug + Default + Clone + Sync + Send,
AS: Debug + Default + Clone + Sync + Send,
{
fn render_in_surface(
&mut self,
surface: &mut Surface,
global_data: &mut GlobalData<S, AS>,
component_registry_map: &mut ComponentRegistryMap<S, AS>,
has_focus: &mut HasFocus,
) -> CommonResult<()>;
}