small changes
This commit is contained in:
@@ -18,7 +18,7 @@ mod num;
|
|||||||
mod orientation;
|
mod orientation;
|
||||||
mod primitive;
|
mod primitive;
|
||||||
mod render;
|
mod render;
|
||||||
mod state;
|
mod typed;
|
||||||
mod ui;
|
mod ui;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
|
|||||||
23
core/src/ui/active.rs
Normal file
23
core/src/ui/active.rs
Normal 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))>,
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
ActiveData, Len, Painter, SizeCtx, Ui, UiRegion, UiVec2, WidgetId,
|
ActiveData, Len, Painter, SizeCtx, Ui, UiRegion, UiVec2, WidgetId,
|
||||||
render::MaskIdx,
|
render::MaskIdx,
|
||||||
ui::painter::ResizeRef,
|
ui::ResizeRef,
|
||||||
util::{HashMap, HashSet},
|
util::{HashMap, HashSet},
|
||||||
};
|
};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ use std::{
|
|||||||
sync::mpsc::{Receiver, Sender, channel},
|
sync::mpsc::{Receiver, Sender, channel},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mod active;
|
||||||
mod draw_state;
|
mod draw_state;
|
||||||
mod painter;
|
mod painter;
|
||||||
mod size;
|
mod size;
|
||||||
|
mod state;
|
||||||
|
|
||||||
pub use painter::{ActiveData, Painter};
|
pub use active::*;
|
||||||
|
pub use painter::Painter;
|
||||||
pub use size::*;
|
pub use size::*;
|
||||||
|
|
||||||
pub struct Ui<State> {
|
pub struct Ui<State> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
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,
|
UiRegion, UiVec2, WidgetHandle, WidgetId,
|
||||||
render::{Mask, MaskIdx, Primitive, PrimitiveHandle, PrimitiveInst},
|
render::{Mask, MaskIdx, Primitive, PrimitiveHandle, PrimitiveInst},
|
||||||
ui::draw_state::DrawState,
|
ui::draw_state::DrawState,
|
||||||
@@ -21,28 +21,6 @@ pub struct Painter<'a, 'b, State> {
|
|||||||
pub(super) id: WidgetId,
|
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> {
|
impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
|
||||||
fn primitive_at<P: Primitive>(&mut self, primitive: P, region: UiRegion) {
|
fn primitive_at<P: Primitive>(&mut self, primitive: P, region: UiRegion) {
|
||||||
let h = self.state.layers.write(
|
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
3
core/src/ui/state.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pub struct DynState {
|
||||||
|
|
||||||
|
}
|
||||||
17
readme.md
17
readme.md
@@ -1,22 +1,25 @@
|
|||||||
# iris
|
# iris
|
||||||
|
|
||||||
my take on a rust ui library (also my first ui library)
|
My experimental attempt at a rust ui library (also my first ui library).
|
||||||
|
|
||||||
it's called iris because it's the structure around what you actually want to display and colorful
|
It's currently designed around using retained data structures (widgets), rather than diffing generated trees from data like xilem or iced. This is an experiment and I'm not sure if it's a good idea or not.
|
||||||
|
|
||||||
there's a `main.rs` that runs a testing window, so can just `cargo run` to see it working
|
There's a `main.rs` that runs a testing window, so you can just `cargo run` to see it working.
|
||||||
|
|
||||||
goals, in general order:
|
Goals, in general order:
|
||||||
1. does what I want it to (text, images, video, animations)
|
1. does what I want it to (text, images, video, animations)
|
||||||
2. very easy to use ignoring ergonomic ref counting
|
2. very easy to use ignoring ergonomic ref counting
|
||||||
3. reasonably fast / efficient (a lot faster than electron, save battery life)
|
3. reasonably fast / efficient (a lot faster than electron, save battery life)
|
||||||
|
|
||||||
not targeting web rn cause wanna use actual nice gpu features & entire point of this is to make desktop apps
|
## dev details
|
||||||
|
|
||||||
|
not targeting web rn cause wanna use actual nice gpu features & entire point of this is to make desktop apps / not need a web browser
|
||||||
|
|
||||||
general ideas trynna use rn / experiment with:
|
general ideas trynna use rn / experiment with:
|
||||||
- retained mode
|
- retained mode
|
||||||
- specifically designed around wgpu
|
- specifically designed around wgpu so there's no translation
|
||||||
- postfix functions for most things to prevent unreadable indentation (going very well)
|
- postfix functions for most things to prevent unreadable indentation (going very well)
|
||||||
|
- events can be done directly where you draw the widgets
|
||||||
- almost no macros in user code & actual LSP typechecking (variadic generics if you can hear me please save us)
|
- almost no macros in user code & actual LSP typechecking (variadic generics if you can hear me please save us)
|
||||||
- relative anchor + absolute offset coord system (+ "rest" / leftover during widget layout)
|
- relative anchor + absolute offset coord system (+ "rest" / leftover during widget layout)
|
||||||
- single threaded ui & pass context around to make non async usage straightforward (pretty unsure about this)
|
- single threaded ui & pass context around to make non async usage straightforward (pretty unsure about this)
|
||||||
@@ -24,3 +27,5 @@ general ideas trynna use rn / experiment with:
|
|||||||
|
|
||||||
under heavy initial development so not gonna try to explain status, maybe check TODO for that;
|
under heavy initial development so not gonna try to explain status, maybe check TODO for that;
|
||||||
sizable chance it gets a rewrite once I know everything I need and what seems to work best
|
sizable chance it gets a rewrite once I know everything I need and what seems to work best
|
||||||
|
|
||||||
|
it's called iris because it's the structure around what you actually want to display and colorful
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
pub mod default;
|
pub mod default;
|
||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod state;
|
pub mod typed;
|
||||||
pub mod widget;
|
pub mod widget;
|
||||||
|
|
||||||
pub use iris_core;
|
pub use iris_core;
|
||||||
@@ -37,5 +37,5 @@ pub mod prelude {
|
|||||||
pub use widget::*;
|
pub use widget::*;
|
||||||
|
|
||||||
pub use iris_core::util::Vec2;
|
pub use iris_core::util::Vec2;
|
||||||
pub use state::*;
|
pub use typed::*;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user