small changes

This commit is contained in:
2025-12-16 18:38:06 -05:00
parent 71f3beaf94
commit ac9571b29f
10 changed files with 46 additions and 37 deletions

View File

@@ -18,7 +18,7 @@ mod num;
mod orientation;
mod primitive;
mod render;
mod state;
mod typed;
mod ui;
mod widget;

23
core/src/ui/active.rs Normal file
View File

@@ -0,0 +1,23 @@
use crate::{LayerId, Len, MaskIdx, PrimitiveHandle, TextureHandle, UiRegion, UiVec2, WidgetId};
/// important non rendering data for retained drawing
#[derive(Debug)]
pub struct ActiveData {
pub id: WidgetId,
pub region: UiRegion,
pub parent: Option<WidgetId>,
pub textures: Vec<TextureHandle>,
pub primitives: Vec<PrimitiveHandle>,
pub children: Vec<WidgetId>,
pub resize: ResizeRef,
pub mask: MaskIdx,
pub layer: LayerId,
}
/// stores information for children about the highest level parent that needed their size
/// so that they can redraw the parent if their size changes
#[derive(Clone, Copy, Debug, Default)]
pub struct ResizeRef {
pub x: Option<(WidgetId, (UiVec2, Len))>,
pub y: Option<(WidgetId, (UiVec2, Len))>,
}

View File

@@ -1,7 +1,7 @@
use crate::{
ActiveData, Len, Painter, SizeCtx, Ui, UiRegion, UiVec2, WidgetId,
render::MaskIdx,
ui::painter::ResizeRef,
ui::ResizeRef,
util::{HashMap, HashSet},
};
use std::ops::{Deref, DerefMut};

View File

@@ -10,11 +10,14 @@ use std::{
sync::mpsc::{Receiver, Sender, channel},
};
mod active;
mod draw_state;
mod painter;
mod size;
mod state;
pub use painter::{ActiveData, Painter};
pub use active::*;
pub use painter::Painter;
pub use size::*;
pub struct Ui<State> {

View File

@@ -1,5 +1,5 @@
use crate::{
Axis, Len, RenderedText, Size, SizeCtx, TextAttrs, TextBuffer, TextData, TextureHandle, Ui,
Axis, Len, RenderedText, Size, SizeCtx, TextAttrs, TextBuffer, TextData, TextureHandle,
UiRegion, UiVec2, WidgetHandle, WidgetId,
render::{Mask, MaskIdx, Primitive, PrimitiveHandle, PrimitiveInst},
ui::draw_state::DrawState,
@@ -21,28 +21,6 @@ pub struct Painter<'a, 'b, State> {
pub(super) id: WidgetId,
}
/// stores information for children about the highest level parent that needed their size
/// so that they can redraw the parent if their size changes
#[derive(Clone, Copy, Debug, Default)]
pub struct ResizeRef {
pub x: Option<(WidgetId, (UiVec2, Len))>,
pub y: Option<(WidgetId, (UiVec2, Len))>,
}
/// important non rendering data for retained drawing
#[derive(Debug)]
pub struct ActiveData {
pub id: WidgetId,
pub region: UiRegion,
pub parent: Option<WidgetId>,
pub textures: Vec<TextureHandle>,
pub primitives: Vec<PrimitiveHandle>,
pub children: Vec<WidgetId>,
pub resize: ResizeRef,
pub mask: MaskIdx,
pub layer: usize,
}
impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
fn primitive_at<P: Primitive>(&mut self, primitive: P, region: UiRegion) {
let h = self.state.layers.write(
@@ -168,6 +146,3 @@ impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
)
}
}
impl<State: 'static> Ui<State> {
}

3
core/src/ui/state.rs Normal file
View File

@@ -0,0 +1,3 @@
pub struct DynState {
}