added underdeveloped but working image support (no freeing or samplers)

This commit is contained in:
2025-08-22 23:07:31 -04:00
parent bde929b05a
commit 7dbdcbba42
26 changed files with 1256 additions and 155 deletions

View File

@@ -1,6 +1,6 @@
use crate::{
ActiveSensors, SensorMap, UiRegion, WidgetId, Widgets,
primitive::{Primitive, Primitives},
ActiveSensors, SensorMap, TextureHandle, UiRegion, WidgetId, Widgets,
render::{Primitive, Primitives},
};
pub struct Painter<'a, Ctx: 'static> {
@@ -32,7 +32,9 @@ impl<'a, Ctx> Painter<'a, Ctx> {
self.primitives.write(data, self.region);
}
pub fn draw<W>(&mut self, id: &WidgetId<W>)
/// Draws a widget but does NOT maintain the region.
/// Useful if you only have a single widget to draw.
pub fn draw_inner<W>(&mut self, id: &WidgetId<W>)
where
Ctx: 'static,
{
@@ -42,16 +44,34 @@ impl<'a, Ctx> Painter<'a, Ctx> {
self.nodes.get_dyn(id).draw(self);
}
pub fn draw_within(&mut self, node: &WidgetId, region: UiRegion)
/// Draws a widget and maintains the original region.
/// Useful if you need to draw multiple overlapping child widgets.
pub fn draw<W>(&mut self, id: &WidgetId<W>)
where
Ctx: 'static,
{
let old = self.region;
self.draw_inner(id);
self.region = old;
}
/// Draws a widget within an inner region and maintains the original region.
/// Useful if you need to draw multiple child widgets in select areas within the original
/// region.
pub fn draw_within(&mut self, id: &WidgetId, region: UiRegion)
where
Ctx: 'static,
{
let old = self.region;
self.region.select(&region);
self.draw(node);
self.draw_inner(id);
self.region = old;
}
pub fn draw_texture(&mut self, handle: &TextureHandle) {
self.write(handle.inner);
}
pub fn finish(self) -> Primitives {
self.primitives
}