Add retained paints and shared text selection

This commit is contained in:
iris committed 2026-09-10 18:35:24 -04:00
1 parent 1e6d3b1edd
commit a33fbca966
42 files changed
+2424 -470

No files matched your search

+4 -4
View File
@@ -27,11 +27,11 @@ fn row_image(i: usize) -> image::DynamicImage {
fn build_row<Rsc: UiRsc + 'static>(rsc: &mut Rsc, i: usize) -> StrongWidget {
let tint = if i.is_multiple_of(2) {
Color::rgb(120, 130, 170)
Srgba8::rgb(120, 130, 170)
} else {
Color::rgb(70, 80, 140)
Srgba8::rgb(70, 80, 140)
};
let text_color = Color::BLACK;
let text_color = PaintId::BLACK;
if i.is_multiple_of(IMAGE_EVERY) {
let text = wtext(row_text(i))
.wrap(true)
@@ -77,7 +77,7 @@ impl DefaultAppState for State {
let root = list
.scrollable()
.masked()
.background(rect(Color::WHITE))
.background(rect(PaintId::WHITE))
.add_strong(rsc);
ui_state.set_root(root.any());
+1 -1
View File
@@ -15,7 +15,7 @@ impl DefaultAppState for State {
rsc: &mut DefaultRsc<Self>,
_: Proxy<Self::Event>,
) -> Self {
rect(Color::RED).set_root(rsc, &mut ui_state);
rect(PaintId::RED).set_root(rsc, &mut ui_state);
Self { ui_state }
}
}
+4 -4
View File
@@ -16,15 +16,15 @@ impl DefaultAppState for State {
rsc: &mut DefaultRsc<Self>,
_: Proxy<Self::Event>,
) -> Self {
let rect = rect(Color::RED).add(rsc);
let rect = rect(PaintId::RED).add(rsc);
rect.task_on(CursorSense::click(), async move |mut ctx| {
tokio::time::sleep(Duration::from_secs(1)).await;
ctx.update(move |_, rsc| {
let rect = rect(rsc);
if rect.color == Color::RED {
rect.color = Color::BLUE;
if rect.is_paint(&PaintId::RED) {
rect.set_paint(PaintId::BLUE);
} else {
rect.color = Color::RED;
rect.set_paint(PaintId::RED);
}
});
})
+3 -3
View File
@@ -20,7 +20,7 @@ struct Test {
impl Test {
pub fn new(rsc: &mut Rsc) -> Self {
let root = rect(Color::RED).add(rsc);
let root = rect(PaintId::RED).add(rsc);
let cur = rsc.create_state(root, false);
Self { root, cur }
}
@@ -28,9 +28,9 @@ impl Test {
let cur = &mut rsc[self.cur];
*cur = !*cur;
if *cur {
rsc[self.root].color = Color::BLUE;
rsc[self.root].set_paint(PaintId::BLUE);
} else {
rsc[self.root].color = Color::RED;
rsc[self.root].set_paint(PaintId::RED);
}
}
}