1
0
Fork 0
forked from wry/wry

theme: add ThemeColor enum

This commit is contained in:
Julian Orth 2026-03-07 11:55:25 +01:00
parent c75b6ef66e
commit cf8b696f03
4 changed files with 82 additions and 41 deletions

View file

@ -93,7 +93,7 @@ use {
scale::Scale,
security_context_acceptor::SecurityContextAcceptors,
tagged_acceptor::TaggedAcceptors,
theme::{Color, Theme},
theme::{Color, Theme, ThemeColor},
time::Time,
tree::{
ContainerNode, ContainerSplit, Direction, DisplayNode, FindTreeUsecase, FloatNode,
@ -1696,6 +1696,39 @@ impl State {
logger.set_level(level);
}
}
fn colors_changed(&self) {
struct V;
impl NodeVisitorBase for V {
fn visit_container(&mut self, node: &Rc<ContainerNode>) {
node.on_colors_changed();
node.node_visit_children(self);
}
fn visit_output(&mut self, node: &Rc<OutputNode>) {
node.on_colors_changed();
node.node_visit_children(self);
}
fn visit_float(&mut self, node: &Rc<FloatNode>) {
node.on_colors_changed();
node.node_visit_children(self);
}
}
self.root.clone().node_visit(&mut V);
self.damage(self.root.extents.get());
self.icons.clear();
}
pub fn reset_colors(&self) {
self.theme.colors.reset();
self.colors_changed();
}
pub fn set_color(&self, colored: ThemeColor, v: Color) {
colored.field(&self.theme).set(v);
self.colors_changed();
}
}
#[derive(Debug, Error)]