euv_ui/component/data_display/
impl.rs1use super::*;
2
3#[component]
5impl EuvTag {
7 fn render(&self) -> NodeId {
17 let ctx: Context = current_context();
18 let tokens: ThemeTokens = live_tokens_untracked(self.get_tokens());
19 let theme_palette: ThemePalette = tokens.get_palette();
20 let geometry: ThemeGeometry = tokens.get_geometry();
21 let (accent, _): (Color, Color) = self.get_tone().colors(theme_palette);
22 let muted_surface: SurfaceColors = theme_palette.surface(SurfaceRole::Muted);
23 let border_col: Color = if self.get_tone() == EuvTone::Neutral {
24 theme_palette.get_border()
25 } else {
26 accent
27 };
28 let Self { label, .. } = self;
29 let mut row_st: Style = Style::default();
30 row_st
31 .get_mut_layout()
32 .set_flex_direction(FlexDirection::Row)
33 .set_align_self(AlignSelf::Start)
34 .set_height(Length::Px(24.0))
35 .set_justify_content(JustifyContent::Center)
36 .set_align_items(AlignItems::Center)
37 .set_padding(Edges::symmetric(0.0, SPACE_SM))
38 .set_overflow(Overflow::Hidden);
39 row_st
40 .get_mut_paint()
41 .set_background(Some(muted_surface.get_bg()))
42 .set_border(Border::new(
43 geometry.get_border_width().max(0.0),
44 border_col,
45 ))
46 .set_radius(CornerRadius::all(RADIUS_PILL));
47 let mut txt_st: Style = Style::default();
48 txt_st
49 .get_mut_text()
50 .set_font_size(12.0)
51 .set_weight(FontWeight::Medium)
52 .set_color(muted_surface.get_fg())
53 .set_align(TextAlign::Center)
54 .set_overflow(TextOverflow::Ellipsis);
55 ctx.get_scene().with_write(
56 |tree: &mut SceneTree| {
57 let root: NodeId = tree.create_view(row_st);
58 let txt_id: NodeId = tree.create_text(label.clone(), txt_st);
59 tree.append_child(root, txt_id);
60 root
61 },
62 NodeId::default(),
63 )
64 }
65}
66
67#[component]
69impl EuvAvatar {
71 fn render(&self) -> NodeId {
81 let ctx: Context = current_context();
82 let theme_palette: ThemePalette = live_tokens_untracked(self.get_tokens()).get_palette();
83 let primary_surface: SurfaceColors = theme_palette.surface(SurfaceRole::Primary);
84 let sz: f32 = self.get_size();
85 let Self { initials, .. } = self;
86 let mut row_st: Style = Style::default();
87 row_st
88 .get_mut_layout()
89 .set_flex_direction(FlexDirection::Row)
90 .set_width(Length::Px(sz))
91 .set_height(Length::Px(sz))
92 .set_justify_content(JustifyContent::Center)
93 .set_align_items(AlignItems::Center)
94 .set_overflow(Overflow::Hidden);
95 row_st
96 .get_mut_paint()
97 .set_background(Some(primary_surface.get_bg()))
98 .set_radius(CornerRadius::all(RADIUS_PILL));
99 let mut txt_st: Style = Style::default();
100 txt_st
101 .get_mut_text()
102 .set_font_size((sz * 0.42).max(10.0))
103 .set_weight(FontWeight::Bold)
104 .set_color(primary_surface.get_fg())
105 .set_align(TextAlign::Center);
106 ctx.get_scene().with_write(
107 |tree: &mut SceneTree| {
108 let root: NodeId = tree.create_view(row_st);
109 let txt_id: NodeId = tree.create_text(initials.clone(), txt_st);
110 tree.append_child(root, txt_id);
111 root
112 },
113 NodeId::default(),
114 )
115 }
116}
117
118impl EuvIcon {
120 #[must_use]
132 pub fn vector(icon: EuvIconName, size: f32, color: Color) -> Self {
133 Self {
134 symbol: String::new(),
135 size,
136 style: Some(style! {
137 TextColor(color)
138 }),
139 icon: Some(icon),
140 }
141 }
142}
143
144#[component]
146impl EuvIcon {
148 fn render(&self) -> NodeId {
158 let ctx: Context = current_context();
159 let sz: f32 = self.get_size();
160 let mount_tokens: ThemeTokens = live_tokens_untracked(ThemeTokens::default());
161 let user_style: Option<Style> = self.get_style();
162 let color: Color = user_style
163 .map(|computed_style: Style| computed_style.get_text().get_color())
164 .unwrap_or_else(|| mount_tokens.get_palette().get_foreground());
165 if let Some(icon_name) = self.get_icon() {
166 let paint_icon = move |bounds: Rect, display_list: &mut DisplayList| {
167 let live_tok: ThemeTokens = live_tokens_untracked(mount_tokens);
168 let resolved_color: Color = remap_theme_color(color, mount_tokens, live_tok);
169 draw_euv_icon(icon_name, bounds, display_list, resolved_color);
170 };
171 let canvas_st: Style = style! {
172 Width(Length::Px(sz))
173 Height(Length::Px(sz))
174 }
175 .with_overrides(user_style);
176 return view! {
177 canvas {
178 style: canvas_st
179 painter: paint_icon
180 }
181 };
182 }
183 let Self { symbol, .. } = self;
184 let mut row_st: Style = Style::default();
185 row_st
186 .get_mut_layout()
187 .set_flex_direction(FlexDirection::Row)
188 .set_width(Length::Px(sz))
189 .set_height(Length::Px(sz))
190 .set_justify_content(JustifyContent::Center)
191 .set_align_items(AlignItems::Center);
192 row_st = row_st.with_overrides(user_style);
193 let mut txt_st: Style = Style::default();
194 txt_st
195 .get_mut_text()
196 .set_font_size(sz * 0.78)
197 .set_weight(FontWeight::SemiBold)
198 .set_color(color);
199 ctx.get_scene().with_write(
200 |tree: &mut SceneTree| {
201 let root: NodeId = tree.create_view(row_st);
202 let txt_id: NodeId = tree.create_text(symbol.clone(), txt_st);
203 tree.append_child(root, txt_id);
204 root
205 },
206 NodeId::default(),
207 )
208 }
209}
210
211#[component]
213impl EuvKbd {
215 fn render(&self) -> NodeId {
225 let ctx: Context = current_context();
226 let tokens: ThemeTokens = live_tokens_untracked(self.get_tokens());
227 let theme_palette: ThemePalette = tokens.get_palette();
228 let geometry: ThemeGeometry = tokens.get_geometry();
229 let muted_surface: SurfaceColors = theme_palette.surface(SurfaceRole::Muted);
230 let Self { key, .. } = self;
231 let mut row_st: Style = Style::default();
232 row_st
233 .get_mut_layout()
234 .set_flex_direction(FlexDirection::Row)
235 .set_align_self(AlignSelf::Start)
236 .set_justify_content(JustifyContent::Center)
237 .set_align_items(AlignItems::Center)
238 .set_padding(Edges::symmetric(2.0, 6.0))
239 .set_overflow(Overflow::Hidden);
240 row_st
241 .get_mut_paint()
242 .set_background(Some(muted_surface.get_bg()))
243 .set_border(Border::new(
244 geometry.get_border_width().max(0.0),
245 theme_palette.get_border(),
246 ))
247 .set_radius(CornerRadius::all(geometry.get_radius_sm().max(0.0)));
248 let mut txt_st: Style = Style::default();
249 txt_st
250 .get_mut_text()
251 .set_family(FontFamily::Monospace)
252 .set_font_size(11.0)
253 .set_color(muted_surface.get_fg())
254 .set_align(TextAlign::Center)
255 .set_overflow(TextOverflow::Clip);
256 ctx.get_scene().with_write(
257 |tree: &mut SceneTree| {
258 let root: NodeId = tree.create_view(row_st);
259 let txt_id: NodeId = tree.create_text(key.clone(), txt_st);
260 tree.append_child(root, txt_id);
261 root
262 },
263 NodeId::default(),
264 )
265 }
266}
267
268#[component]
270impl EuvTypography {
272 fn render(&self) -> NodeId {
282 let tokens: ThemeTokens = live_tokens_untracked(self.get_tokens());
283 let theme_palette: ThemePalette = tokens.get_palette();
284 let geometry: ThemeGeometry = tokens.get_geometry();
285 let variant: EuvTypographyVariant = self.get_variant();
286 let Self { text, .. } = self;
287 let mut style: Style = Style::default();
288 let node_text_style: &mut TextStyle = style.get_mut_text();
289 match variant {
290 EuvTypographyVariant::H1 => {
291 node_text_style
292 .set_font_size(geometry.get_font_title())
293 .set_weight(FontWeight::Bold)
294 .set_color(theme_palette.get_foreground());
295 }
296 EuvTypographyVariant::H2 => {
297 node_text_style
298 .set_font_size(geometry.get_font_heading())
299 .set_weight(FontWeight::Bold)
300 .set_color(theme_palette.get_foreground());
301 }
302 EuvTypographyVariant::H3 => {
303 node_text_style
304 .set_font_size(15.0)
305 .set_weight(FontWeight::SemiBold)
306 .set_color(theme_palette.get_foreground());
307 }
308 EuvTypographyVariant::Body => {
309 node_text_style
310 .set_font_size(geometry.get_font_body())
311 .set_color(theme_palette.get_foreground());
312 }
313 EuvTypographyVariant::Caption => {
314 node_text_style
315 .set_font_size(12.0)
316 .set_color(theme_palette.get_muted_foreground());
317 }
318 }
319 view! {
320 text {
321 style: style
322 { text.as_str() }
323 }
324 }
325 }
326}
327
328#[component]
330impl EuvEmpty {
332 fn render(&self) -> NodeId {
342 let tokens: ThemeTokens = live_tokens_untracked(self.get_tokens());
343 let theme_palette: ThemePalette = tokens.get_palette();
344 let geometry: ThemeGeometry = tokens.get_geometry();
345 let Self {
346 title, description, ..
347 } = self;
348 let column_fifth_style: Style = style! {
349 Width(Length::Percent(100.0))
350 AlignItems::Center
351 Padding(Edges::all(SPACE_2XL))
352 Gap(SPACE_SM)
353 Border::new(geometry.get_border_width(), theme_palette.get_border())
354 Radius(geometry.get_radius_lg())
355 Overflow::Hidden
356 };
357 let text_seventh_style: Style = style! {
358 FontSize(20.0)
359 TextColor(theme_palette.get_muted_foreground())
360 };
361 let text_eighth_style: Style = style! {
362 Width(Length::Percent(100.0))
363 FontSize(15.0)
364 FontWeight::SemiBold
365 TextColor(theme_palette.get_foreground())
366 TextAlign::Center
367 };
368 let text_ninth_style: Style = style! {
369 Width(Length::Percent(100.0))
370 FontSize(13.0)
371 TextColor(theme_palette.get_muted_foreground())
372 TextAlign::Center
373 };
374 view! {
375 column {
376 style: column_fifth_style
377 text {
378 style: text_seventh_style
379 { EMPTY_ICON_GLYPH }
380 }
381 text {
382 style: text_eighth_style
383 { title.as_str() }
384 }
385 text {
386 style: text_ninth_style
387 { description.as_str() }
388 }
389 }
390 }
391 }
392}
393
394#[component]
396impl EuvSkeleton {
398 fn render(&self) -> NodeId {
408 let live_tok: ThemeTokens = live_tokens_untracked(self.get_tokens());
409 let theme_palette: ThemePalette = live_tok.get_palette();
410 let geometry: ThemeGeometry = live_tok.get_geometry();
411 let box_st: Style = style! {
412 Width(Length::Percent(100.0))
413 MaxWidth(Length::Percent(100.0))
414 Height(Length::Px(16.0))
415 Background(theme_palette.get_secondary())
416 Radius(geometry.get_radius_sm())
417 }
418 .with_overrides(self.get_style());
419 view! {
420 view {
421 style: box_st
422 }
423 }
424 }
425}
426
427#[component]
429impl EuvSpinner {
431 fn render(&self) -> NodeId {
441 let base_tokens: ThemeTokens = self.get_tokens();
442 let sz: f32 = self.get_size();
443 let paint_spinner = move |bounds: Rect, display_list: &mut DisplayList| {
444 let primary: Color = live_tokens_untracked(base_tokens)
445 .get_palette()
446 .get_primary();
447 let cx: f32 = bounds.get_x() + bounds.get_width() * 0.5;
448 let cy: f32 = bounds.get_y() + bounds.get_height() * 0.5;
449 let outer_r: f32 = (bounds.get_width().min(bounds.get_height()) * 0.42).max(4.0);
450 let inner_r: f32 = outer_r * 0.56;
451 let stroke_w: f32 = (outer_r * 0.24).clamp(1.6, 3.2);
452 for &(cos_a, sin_a, alpha) in SPINNER_SPOKES.iter() {
453 display_list.push(DrawCommand::Line {
454 from: Point::new(cx + cos_a * inner_r, cy + sin_a * inner_r),
455 to: Point::new(cx + cos_a * outer_r, cy + sin_a * outer_r),
456 color: primary.multiply_alpha(alpha),
457 width: stroke_w,
458 });
459 }
460 };
461 let canvas_style: Style = style! {
462 Width(Length::Px(sz))
463 Height(Length::Px(sz))
464 Radius(RADIUS_PILL)
465 };
466 view! {
467 canvas {
468 style: canvas_style
469 painter: paint_spinner
470 }
471 }
472 }
473}
474
475#[component]
477impl EuvTimeline {
479 fn render(&self) -> NodeId {
489 let theme_palette: ThemePalette = live_tokens_untracked(self.get_tokens()).get_palette();
490 let Self { items, .. } = self;
491 let column_tertiary_style: Style = style! {
492 Width(Length::Percent(100.0))
493 Gap(SPACE_MD)
494 };
495 let view_secondary_style: Style = style! {
496 Width(Length::Px(10.0))
497 Height(Length::Px(10.0))
498 FlexShrink(0.0)
499 Background(theme_palette.get_primary())
500 Radius(RADIUS_PILL)
501 };
502 let column_quaternary_style: Style = style! {
503 FlexGrow(1.0)
504 FlexShrink(1.0)
505 MinWidth(Length::Px(0.0))
506 Gap(2.0)
507 };
508 let text_quaternary_style: Style = style! {
509 Width(Length::Percent(100.0))
510 FontSize(14.0)
511 FontWeight::SemiBold
512 TextColor(theme_palette.get_foreground())
513 };
514 let text_fifth_style: Style = style! {
515 Width(Length::Percent(100.0))
516 FontSize(11.0)
517 TextColor(theme_palette.get_muted_foreground())
518 };
519 let text_sixth_style: Style = style! {
520 Width(Length::Percent(100.0))
521 FontSize(13.0)
522 TextColor(theme_palette.get_muted_foreground())
523 };
524 view! {
525 column {
526 style: column_tertiary_style
527 for item in items.iter() {
528 row {
529 style: column_tertiary_style
530 view {
531 style: view_secondary_style
532 }
533 column {
534 style: column_quaternary_style
535 text {
536 style: text_quaternary_style
537 { item.get_title().as_str() }
538 }
539 text {
540 style: text_fifth_style
541 { item.get_timestamp().as_str() }
542 }
543 text {
544 style: text_sixth_style
545 { item.get_detail().as_str() }
546 }
547 }
548 }
549 }
550 }
551 }
552 }
553}
554
555#[component]
557impl EuvList {
559 fn render(&self) -> NodeId {
569 let tokens: ThemeTokens = live_tokens_untracked(self.get_tokens());
570 let theme_palette: ThemePalette = tokens.get_palette();
571 let geometry: ThemeGeometry = tokens.get_geometry();
572 let Self { items, .. } = self;
573 let column_secondary_style: Style = style! {
574 Width(Length::Percent(100.0))
575 Background(theme_palette.get_card())
576 Border::new(geometry.get_border_width(), theme_palette.get_border())
577 Radius(geometry.get_radius_md())
578 Overflow::Hidden
579 };
580 let view_style: Style = style! {
581 Width(Length::Percent(100.0))
582 Height(Length::Px(geometry.get_border_width().max(1.0)))
583 Background(theme_palette.get_border())
584 };
585 let row_secondary_style: Style = style! {
586 Width(Length::Percent(100.0))
587 Padding(Edges::symmetric(SPACE_SM, SPACE_MD))
588 Overflow::Hidden
589 };
590 let text_tertiary_style: Style = style! {
591 Width(Length::Percent(100.0))
592 FontSize(13.0)
593 TextColor(theme_palette.get_foreground())
594 };
595 view! {
596 column {
597 style: column_secondary_style
598 for (idx, item) in items.iter().enumerate() {
599 if idx > 0 {
600 view {
601 style: view_style
602 }
603 }
604 row {
605 style: row_secondary_style
606 text {
607 style: text_tertiary_style
608 { item.as_str() }
609 }
610 }
611 }
612 }
613 }
614 }
615}
616
617impl EuvTree {
619 #[must_use]
630 pub fn row_colors(palette: ThemePalette, is_selected: bool) -> (Color, Color) {
631 if is_selected {
632 let surface: SurfaceColors = palette.surface(SurfaceRole::Accent);
633 (surface.get_bg(), surface.get_fg())
634 } else {
635 let card_surface: SurfaceColors = palette.surface(SurfaceRole::Card);
636 (COLOR_TRANSPARENT, card_surface.get_fg())
637 }
638 }
639
640 #[must_use]
651 pub fn selected(mut self, selected: Signal<Option<String>>) -> Self {
652 self.set_selected(Some(selected));
653 self
654 }
655
656 fn build_branch(
671 nodes: &[EuvTreeNode],
672 depth: usize,
673 theme: (ThemePalette, ThemeGeometry),
674 selected: Option<Signal<Option<String>>>,
675 init_selected: Option<&str>,
676 bound_rows: &mut Vec<(NodeId, NodeId, String)>,
677 ) -> Vec<NodeId> {
678 let (palette, geom): (ThemePalette, ThemeGeometry) = theme;
679 let row_radius: f32 = concentric_radius(geom.get_radius_lg(), CONTROL_INSET);
680 let mut out: Vec<NodeId> = Vec::with_capacity(nodes.len() * 2);
681 for node in nodes.iter() {
682 let has_children: bool = !node.get_children().is_empty();
683 let expanded: Signal<bool> = Signal::new(true);
684 let indent: f32 = (depth as f32) * 16.0;
685 let label_str: &str = node.get_label().as_str();
686 let lbl_click: String = node.get_label().clone();
687 let is_init_sel: bool = init_selected == Some(label_str);
688 let (init_bg, init_fg): (Color, Color) = Self::row_colors(palette, is_init_sel);
689 let on_row_click = move |_: &UiEvent| {
690 if has_children {
691 let _: bool = expanded.set(!expanded.get_untracked());
692 }
693 if let Some(sel_sig) = selected {
694 let _: bool = sel_sig.set_if_changed(Some(lbl_click.clone()));
695 }
696 };
697 let label_node: NodeId = if has_children {
698 let lbl_for_txt: String = node.get_label().clone();
699 let branch_label = move || -> String {
700 let pfx: &str = if expanded.get() {
701 TREE_EXPAND_PREFIX
702 } else {
703 TREE_COLLAPSED_PREFIX
704 };
705 format!("{pfx}{lbl_for_txt}")
706 };
707 let text_secondary_style: Style = style! {
708 FlexGrow(1.0)
709 FlexShrink(1.0)
710 MinWidth(Length::Px(0.0))
711 FontSize(13.0)
712 FontWeight::Medium
713 TextColor(init_fg)
714 };
715 view! {
716 text {
717 style: text_secondary_style
718 { branch_label }
719 }
720 }
721 } else {
722 let leaf_label: String = format!("{TREE_LEAF_PREFIX}{label_str}");
723 let text_style: Style = style! {
724 FlexGrow(1.0)
725 FlexShrink(1.0)
726 MinWidth(Length::Px(0.0))
727 FontSize(13.0)
728 TextColor(init_fg)
729 };
730 view! {
731 text {
732 style: text_style
733 { leaf_label }
734 }
735 }
736 };
737 let row_style: Style = style! {
738 Width(Length::Percent(100.0))
739 MinHeight(Length::Px(geom.get_control_sm()))
740 AlignItems::Center
741 Padding(Edges::new(SPACE_XS, SPACE_SM, SPACE_XS, SPACE_SM + indent))
742 Radius(row_radius)
743 Background(init_bg)
744 Overflow::Hidden
745 CursorIcon::Pointer
746 };
747 let row: NodeId = view! {
748 row {
749 style: row_style
750 on_click: on_row_click
751 { label_node }
752 }
753 };
754 if selected.is_some() {
755 bound_rows.push((row, label_node, node.get_label().clone()));
756 }
757 out.push(row);
758 if has_children {
759 let child_nodes: Vec<NodeId> = Self::build_branch(
760 node.get_children(),
761 depth + 1,
762 theme,
763 selected,
764 init_selected,
765 bound_rows,
766 );
767 let mut branch_base: Style = Style::default();
768 branch_base
769 .get_mut_layout()
770 .set_flex_direction(FlexDirection::Column)
771 .set_width(Length::Percent(100.0))
772 .set_row_gap(CONTROL_INSET)
773 .set_column_gap(CONTROL_INSET);
774 let branch_style = move || -> Style {
775 let mut computed_style: Style = branch_base;
776 computed_style
777 .get_mut_layout()
778 .set_display(if expanded.get() {
779 Display::Flex
780 } else {
781 Display::None
782 });
783 computed_style
784 };
785 let branch_box: NodeId = view! {
786 column {
787 bind_style: branch_style
788 ..child_nodes
789 }
790 };
791 out.push(branch_box);
792 }
793 }
794 out
795 }
796}
797
798#[component]
800impl EuvTree {
802 fn render(&self) -> NodeId {
815 let base_tokens: ThemeTokens = self.get_tokens();
816 let init_tok: ThemeTokens = live_tokens_untracked(base_tokens);
817 let theme_palette: ThemePalette = init_tok.get_palette();
818 let geometry: ThemeGeometry = init_tok.get_geometry();
819 let Self {
820 roots, selected, ..
821 } = self;
822 let init_selected: Option<String> =
823 selected.and_then(|sig: Signal<Option<String>>| sig.get_untracked());
824 let mut bound_rows: Vec<(NodeId, NodeId, String)> = Vec::new();
825 let branch_nodes: Vec<NodeId> = Self::build_branch(
826 roots,
827 0,
828 (theme_palette, geometry),
829 *selected,
830 init_selected.as_deref(),
831 &mut bound_rows,
832 );
833 let column_style: Style = style! {
834 Width(Length::Percent(100.0))
835 Padding(Edges::all(CONTROL_INSET))
836 Gap(CONTROL_INSET)
837 Background(theme_palette.get_card())
838 Border::new(geometry.get_border_width(), theme_palette.get_border())
839 Radius(geometry.get_radius_lg())
840 Overflow::Hidden
841 };
842 let root: NodeId = view! {
843 column {
844 style: column_style
845 ..branch_nodes
846 }
847 };
848 if let Some(sel_sig) = *selected
849 && !bound_rows.is_empty()
850 {
851 let ctx: Context = current_context();
852 let scene: SceneHandle = ctx.get_scene().clone();
853 let owned_nodes: Vec<NodeId> = bound_rows
854 .iter()
855 .flat_map(|&(row_id, lbl_id, _): &(NodeId, NodeId, String)| [row_id, lbl_id])
856 .collect();
857 let init_key: ThemeKey = init_tok.key();
858 let (tree_scope, _): (Scope, ()) = Scope::run(|_: Scope| {
859 let sel: Rc<Selector<Option<String>>> =
860 Rc::new(Selector::new(move || sel_sig.get()));
861 let sel_cleanup: Rc<Selector<Option<String>>> = Rc::clone(&sel);
862 on_cleanup(move || {
863 sel_cleanup.dispose();
864 });
865 for (row_node, label_node, lbl_cmp) in bound_rows.into_iter() {
866 let sel_row: Rc<Selector<Option<String>>> = Rc::clone(&sel);
867 let scene_row: SceneHandle = scene.clone();
868 let init_is_sel: bool = init_selected.as_deref() == Some(lbl_cmp.as_str());
869 let prev_state: Cell<(bool, ThemeKey)> = Cell::new((init_is_sel, init_key));
870 let _: Effect = Effect::new(move || {
871 let is_sel: bool = sel_row.is_selected(Some(lbl_cmp.clone()));
872 let live_tok: ThemeTokens = use_live_tokens(base_tokens);
873 let (prev_sel, prev_key): (bool, ThemeKey) =
874 prev_state.replace((is_sel, live_tok.key()));
875 if prev_sel == is_sel && prev_key == live_tok.key() {
876 return;
877 }
878 let (bg, fg): (Color, Color) =
879 Self::row_colors(live_tok.get_palette(), is_sel);
880 scene_row.with_write(
881 |tree: &mut SceneTree| {
882 if let Some(node) = tree.get_node_mut(row_node) {
883 node.get_mut_style()
884 .get_mut_paint()
885 .set_background(Some(bg));
886 tree.mark_dirty(row_node, DIRTY_PAINT);
887 }
888 if let Some(node) = tree.get_node_mut(label_node) {
889 node.get_mut_style().get_mut_text().set_color(fg);
890 tree.mark_dirty(label_node, DIRTY_PAINT);
891 }
892 },
893 (),
894 );
895 });
896 }
897 });
898 ctx.get_scene().with_write(
899 |tree: &mut SceneTree| {
900 mark_theme_owned(tree, owned_nodes.as_slice());
901 tree.attach_scope(root, tree_scope);
902 },
903 (),
904 );
905 }
906 root
907 }
908}