use crate::ui::{
event::{UiEvent, UiEventOutcome},
workspace::{UiView, ViewContext},
};
#[derive(Debug, Clone)]
pub struct Canvas {
pub id: String,
pub visible: bool,
}
impl Canvas {
pub fn new() -> Self {
Self {
id: String::new(),
visible: true,
}
}
pub fn with_id(mut self, id: impl Into<String>) -> Self {
self.id = id.into();
self
}
pub fn with_visible(mut self, visible: bool) -> Self {
self.visible = visible;
self
}
pub fn set_visible(&mut self, visible: bool) {
self.visible = visible;
}
pub fn is_visible(&self) -> bool {
self.visible
}
pub fn show(&mut self) {
self.visible = true;
}
pub fn hide(&mut self) {
self.visible = false;
}
}
impl Default for Canvas {
fn default() -> Self {
Self::new()
}
}
impl UiView for Canvas {
fn build(&mut self, _ctx: &mut ViewContext) {
}
fn handle_event(&mut self, _evt: &UiEvent) -> UiEventOutcome {
UiEventOutcome::none()
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn view_id(&self) -> &str {
&self.id
}
}