ptr
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
mod image;
|
mod image;
|
||||||
mod mask;
|
mod mask;
|
||||||
mod position;
|
mod position;
|
||||||
|
mod ptr;
|
||||||
mod rect;
|
mod rect;
|
||||||
mod sense;
|
mod sense;
|
||||||
mod text;
|
mod text;
|
||||||
@@ -9,6 +10,7 @@ mod trait_fns;
|
|||||||
pub use image::*;
|
pub use image::*;
|
||||||
pub use mask::*;
|
pub use mask::*;
|
||||||
pub use position::*;
|
pub use position::*;
|
||||||
|
pub use ptr::*;
|
||||||
pub use rect::*;
|
pub use rect::*;
|
||||||
pub use sense::*;
|
pub use sense::*;
|
||||||
pub use text::*;
|
pub use text::*;
|
||||||
|
|||||||
22
src/core/ptr.rs
Normal file
22
src/core/ptr.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct WidgetPtr {
|
||||||
|
pub inner: Option<WidgetId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Widget for WidgetPtr {
|
||||||
|
fn draw(&mut self, painter: &mut Painter) {
|
||||||
|
if let Some(id) = &self.inner {
|
||||||
|
painter.widget(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn desired_size(&mut self, ctx: &mut SizeCtx) -> Size {
|
||||||
|
if let Some(id) = &self.inner {
|
||||||
|
ctx.size(id)
|
||||||
|
} else {
|
||||||
|
Size::ZERO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user