better & more fine grained redraw system (should allow movement)
This commit is contained in:
@@ -2,15 +2,15 @@ use image::DynamicImage;
|
||||
|
||||
use crate::{
|
||||
layout::{
|
||||
ActiveSensors, Painter, SensorMap, StaticWidgetId, TextData, TextureHandle, Textures,
|
||||
UiRegion, Vec2, Widget, WidgetId, WidgetLike,
|
||||
ActiveSensors, PainterCtx, SensorMap, StaticWidgetId, TextData, TextureHandle, Textures,
|
||||
Vec2, Widget, WidgetId, WidgetInstance, WidgetLike,
|
||||
},
|
||||
render::Primitives,
|
||||
util::{HashMap, Id, IdTracker},
|
||||
};
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
ops::{Deref, DerefMut, Index, IndexMut, Range},
|
||||
ops::{Deref, DerefMut, Index, IndexMut},
|
||||
sync::mpsc::{Receiver, Sender, channel},
|
||||
};
|
||||
|
||||
@@ -118,22 +118,20 @@ impl Ui {
|
||||
|
||||
pub fn redraw_all(&mut self) {
|
||||
self.active.clear();
|
||||
self.primitives.clear();
|
||||
// free before bc nothing should exist
|
||||
self.free();
|
||||
let mut painter = Painter::new(
|
||||
let mut ctx = PainterCtx::new(
|
||||
&self.widgets,
|
||||
&mut self.primitives,
|
||||
&self.sensor_map,
|
||||
&mut self.active,
|
||||
&mut self.text,
|
||||
&mut self.textures,
|
||||
&mut self.text,
|
||||
self.size,
|
||||
);
|
||||
if let Some(base) = &self.base {
|
||||
painter.draw(base);
|
||||
ctx.draw(&base.id);
|
||||
}
|
||||
self.primitives.replace();
|
||||
}
|
||||
|
||||
pub fn update(&mut self) {
|
||||
@@ -146,17 +144,17 @@ impl Ui {
|
||||
}
|
||||
|
||||
fn redraw_updates(&mut self) {
|
||||
let mut painter = Painter::new(
|
||||
let mut ctx = PainterCtx::new(
|
||||
&self.widgets,
|
||||
&mut self.primitives,
|
||||
&self.sensor_map,
|
||||
&mut self.active,
|
||||
&mut self.text,
|
||||
&mut self.textures,
|
||||
&mut self.text,
|
||||
self.size,
|
||||
);
|
||||
for id in self.updates.drain(..) {
|
||||
painter.redraw(&id);
|
||||
ctx.redraw(&id);
|
||||
}
|
||||
self.free();
|
||||
}
|
||||
@@ -350,17 +348,10 @@ impl Default for Ui {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WidgetInstance {
|
||||
pub region: UiRegion,
|
||||
pub span: Range<usize>,
|
||||
pub children: Vec<Id>,
|
||||
pub parent: Option<Id>,
|
||||
pub textures: Vec<TextureHandle>,
|
||||
}
|
||||
pub type ActiveWidgets = HashMap<Id, WidgetInstance>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct Active {
|
||||
pub struct Active {
|
||||
pub sensors: ActiveSensors,
|
||||
pub widgets: ActiveWidgets,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user