1use super::*;
2
3pub(crate) fn render_mode_name(idx: usize) -> &'static str {
13 match idx {
14 1 => MODE_SOFTWARE,
15 2 => MODE_HARDWARE,
16 3 => MODE_HYBRID,
17 _ => MODE_AUTO,
18 }
19}
20
21pub(crate) fn render_blur_radius(idx: usize) -> f32 {
31 match idx {
32 0 => 8.0,
33 2 => 24.0,
34 _ => 16.0,
35 }
36}
37
38pub(crate) fn render_gradient_angle(idx: usize) -> f32 {
48 match idx {
49 0 => 0.0,
50 2 => 90.0,
51 3 => 135.0,
52 _ => 45.0,
53 }
54}
55
56pub(crate) fn mount_render_vector_card(
67 mode_idx: Signal<usize>,
68 tokens: ThemeTokens,
69) -> (NodeId, NodeId) {
70 let palette: ThemePalette = tokens.get_palette();
71 let geometry: ThemeGeometry = tokens.get_geometry();
72 let mut canvas_id: NodeId = NodeId::default();
73 let pipeline_label = move || -> String {
74 let mode_name: &str = render_mode_name(mode_idx.get());
75 format!("Demo Preview Pipeline: {mode_name} (Widget-Scoped — Global App Unchanged)")
76 };
77 let paint_preview = move |bounds: Rect, display_list: &mut DisplayList| {
78 let live: ThemeTokens = live_tokens_untracked(tokens);
79 let lp: ThemePalette = live.get_palette();
80 let mode: usize = mode_idx.get_untracked();
81 let border_width: f32 = bounds.get_width().max(120.0);
82 let bh: f32 = bounds.get_height().max(100.0);
83 let grid_col: Color = lp.get_border().with_alpha(90);
84 let step_x: f32 = (border_width / 6.0).max(32.0);
85 let mut gx: f32 = bounds.get_x() + step_x;
86 while gx < bounds.right() - 8.0 {
87 display_list.push(DrawCommand::Line {
88 from: Point::new(gx, bounds.get_y() + 8.0),
89 to: Point::new(gx, bounds.bottom() - 8.0),
90 color: grid_col,
91 width: 1.0,
92 });
93 gx += step_x;
94 }
95 let rect_w: f32 = (border_width * 0.28).clamp(64.0, 210.0);
96 let rect_h: f32 = (bh - 52.0).max(60.0);
97 let primary_fill: Color = match mode {
98 1 => lp.get_secondary(),
99 2 => lp.get_primary(),
100 3 => lp.get_success(),
101 _ => lp.get_primary(),
102 };
103 display_list.push(DrawCommand::FillRoundedRect {
104 rect: Rect::new(bounds.get_x() + 18.0, bounds.get_y() + 34.0, rect_w, rect_h),
105 color: primary_fill,
106 radius: CornerRadius::all(14.0),
107 border: Border::new(1.5, lp.get_border()),
108 });
109 let circle_r: f32 = (border_width * 0.085).clamp(22.0, 48.0);
110 let circle_x: f32 = (bounds.get_x() + 18.0 + rect_w + circle_r + 24.0)
111 .min(bounds.right() - circle_r - 14.0);
112 let circle_y: f32 = bounds.get_y() + 34.0 + rect_h * 0.5;
113 display_list.push(DrawCommand::Circle {
114 center: Point::new(circle_x, circle_y),
115 radius: circle_r + 6.0,
116 color: lp.get_success().with_alpha(52),
117 });
118 display_list.push(DrawCommand::Circle {
119 center: Point::new(circle_x, circle_y),
120 radius: circle_r,
121 color: lp.get_success(),
122 });
123 let line_x0: f32 = (circle_x + circle_r + 18.0).min(bounds.right() - 24.0);
124 let line_x1: f32 = (bounds.right() - 18.0).max(line_x0);
125 display_list.push(DrawCommand::Line {
126 from: Point::new(line_x0, bounds.get_y() + 42.0),
127 to: Point::new(line_x1, bounds.bottom() - 22.0),
128 color: lp.get_warning(),
129 width: 3.5,
130 });
131 display_list.push(DrawCommand::Line {
132 from: Point::new(line_x0, bounds.bottom() - 22.0),
133 to: Point::new(line_x1, bounds.get_y() + 42.0),
134 color: lp.get_primary().with_alpha(180),
135 width: 2.0,
136 });
137 let mut hud_style: TextStyle = TextStyle::default();
138 hud_style
139 .set_font_size(11.5)
140 .set_weight(FontWeight::SemiBold)
141 .set_color(lp.get_foreground());
142 display_list.push(DrawCommand::TextRun {
143 rect: Rect::new(
144 bounds.get_x() + 16.0,
145 bounds.get_y() + 10.0,
146 (border_width - 32.0).max(1.0),
147 18.0,
148 ),
149 text: format!(
150 "SDF Vector Stage | Preview Mode: {} | Bounds: {:.0}x{:.0}",
151 render_mode_name(mode),
152 border_width,
153 bh
154 ),
155 style: hud_style,
156 });
157 };
158 let column_fifth_style: Style = style! {
159 Width(Length::Percent(100.0))
160 Gap(SPACE_SM)
161 };
162 let text_tertiary_style: Style = style! {
163 Width(Length::Percent(100.0))
164 FontSize(13.0)
165 FontWeight::SemiBold
166 TextColor(palette.get_primary())
167 };
168 let text_quaternary_style: Style = style! {
169 Width(Length::Percent(100.0))
170 FontSize(12.0)
171 FontWeight::Medium
172 TextColor(palette.get_muted_foreground())
173 };
174 let canvas_tertiary_style: Style = style! {
175 Width(Length::Percent(100.0))
176 Height(Length::Px(RENDER_VECTOR_CANVAS_HEIGHT))
177 Background(palette.get_muted())
178 Border::new(geometry.get_border_width(), palette.get_border())
179 Radius(geometry.get_radius_md())
180 };
181 let card: NodeId = view! {
182 EuvCard {
183 title: RENDER_CARD_TITLE.to_string()
184 tokens: tokens
185 subtitle: RENDER_CARD_SUB
186 column {
187 style: column_fifth_style
188 text {
189 style: text_tertiary_style
190 { pipeline_label }
191 }
192 text {
193 style: text_quaternary_style
194 { CANVAS_LABEL }
195 }
196 canvas {
197 node_ref: canvas_id
198 style: canvas_tertiary_style
199 painter: paint_preview
200 }
201 }
202 }
203 };
204 (card, canvas_id)
205}
206
207pub(crate) fn mount_render_blur_card(
218 blur_idx: Signal<usize>,
219 tokens: ThemeTokens,
220) -> (NodeId, NodeId) {
221 let palette: ThemePalette = tokens.get_palette();
222 let geometry: ThemeGeometry = tokens.get_geometry();
223 let mut glass_id: NodeId = NodeId::default();
224 let paint_backdrop = move |bounds: Rect, display_list: &mut DisplayList| {
225 let live: ThemeTokens = live_tokens_untracked(tokens);
226 let lp: ThemePalette = live.get_palette();
227 let border_width: f32 = bounds.get_width().max(80.0);
228 let bh: f32 = bounds.get_height().max(80.0);
229 display_list.push(DrawCommand::Circle {
230 center: Point::new(
231 bounds.get_x() + border_width * 0.24,
232 bounds.get_y() + bh * 0.48,
233 ),
234 radius: (bh * 0.34).max(20.0),
235 color: lp.get_primary(),
236 });
237 display_list.push(DrawCommand::Circle {
238 center: Point::new(
239 bounds.get_x() + border_width * 0.56,
240 bounds.get_y() + bh * 0.42,
241 ),
242 radius: (bh * 0.30).max(18.0),
243 color: lp.get_success(),
244 });
245 display_list.push(DrawCommand::Circle {
246 center: Point::new(
247 bounds.get_x() + border_width * 0.80,
248 bounds.get_y() + bh * 0.58,
249 ),
250 radius: (bh * 0.28).max(16.0),
251 color: lp.get_warning(),
252 });
253 };
254 let glass_style = move || -> Style {
255 let live: ThemeTokens = use_live_tokens(tokens);
256 let lp: ThemePalette = live.get_palette();
257 let lg: ThemeGeometry = live.get_geometry();
258 style! {
259 Width(Length::Percent(100.0))
260 FlexGrow(1.0)
261 FlexDirection::Column
262 JustifyContent::Center
263 Gap(SPACE_XS)
264 Padding(Edges::all(SPACE_MD))
265 Background(lp.get_card().with_alpha(196))
266 Border::new(lg.get_border_width(), lp.get_border())
267 Radius(lg.get_radius_md())
268 Overflow::Hidden
269 }
270 };
271 let glass_title_style = move || -> Style {
272 let live: ThemeTokens = use_live_tokens(tokens);
273 style! {
274 Width(Length::Percent(100.0))
275 FontSize(14.0)
276 FontWeight::Bold
277 TextColor(live.get_palette().get_card_foreground())
278 }
279 };
280 let glass_sub_style = move || -> Style {
281 let live: ThemeTokens = use_live_tokens(tokens);
282 style! {
283 Width(Length::Percent(100.0))
284 FontSize(12.0)
285 FontFamily::Monospace
286 TextColor(live.get_palette().get_card_foreground())
287 }
288 };
289 let blur_caption = move || -> String {
290 let radius: f32 = render_blur_radius(blur_idx.get());
291 format!("Dual-Kawase radius: {radius:.0}px | alpha=196/255")
292 };
293 let view_style: Style = style! {
294 Width(Length::Percent(100.0))
295 Height(Length::Px(RENDER_EFFECT_STAGE_HEIGHT))
296 Padding(Edges::all(SPACE_LG))
297 JustifyContent::Center
298 Background(palette.get_muted())
299 Border::new(geometry.get_border_width(), palette.get_border())
300 Radius(geometry.get_radius_md())
301 Overflow::Hidden
302 };
303 let canvas_secondary_style: Style = style! {
304 Position::Absolute
305 Inset(Some(0.0), Some(0.0), Some(0.0), Some(0.0))
306 Width(Length::Percent(100.0))
307 Height(Length::Percent(100.0))
308 };
309 let card: NodeId = view! {
310 EuvCard {
311 title: RENDER_BLUR_CARD_TITLE.to_string()
312 tokens: tokens
313 subtitle: RENDER_BLUR_CARD_SUB
314 view {
315 style: view_style
316 canvas {
317 style: canvas_secondary_style
318 painter: paint_backdrop
319 }
320 view {
321 node_ref: glass_id
322 bind_style: glass_style
323 text {
324 bind_style: glass_title_style
325 { RENDER_BLUR_GLASS_TITLE }
326 }
327 text {
328 bind_style: glass_sub_style
329 { blur_caption }
330 }
331 }
332 }
333 }
334 };
335 (card, glass_id)
336}
337
338pub(crate) fn mount_render_shadow_card(shadow_idx: Signal<usize>, tokens: ThemeTokens) -> NodeId {
349 let palette: ThemePalette = tokens.get_palette();
350 let geometry: ThemeGeometry = tokens.get_geometry();
351 let tile_style = move || -> Style {
352 let live: ThemeTokens = use_live_tokens(tokens);
353 let lp: ThemePalette = live.get_palette();
354 let lg: ThemeGeometry = live.get_geometry();
355 let sh: Shadow = match shadow_idx.get() {
356 0 => lg.get_shadow_sm(),
357 2 => lg.get_shadow_lg(),
358 _ => lg.get_shadow_md(),
359 };
360 style! {
361 FlexDirection::Column
362 Width(Length::Percent(100.0))
363 Padding(Edges::all(SPACE_MD))
364 Gap(SPACE_XS)
365 Background(lp.get_card())
366 Border::new(lg.get_border_width(), lp.get_border())
367 Radius(lg.get_radius_lg())
368 sh
369 Overflow::Hidden
370 }
371 };
372 let tile_title_style = move || -> Style {
373 let live: ThemeTokens = use_live_tokens(tokens);
374 style! {
375 Width(Length::Percent(100.0))
376 FontSize(14.0)
377 FontWeight::Bold
378 TextColor(live.get_palette().get_card_foreground())
379 }
380 };
381 let tile_meta_style = move || -> Style {
382 let live: ThemeTokens = use_live_tokens(tokens);
383 style! {
384 Width(Length::Percent(100.0))
385 FontSize(12.0)
386 FontFamily::Monospace
387 TextColor(live.get_palette().get_muted_foreground())
388 }
389 };
390 let shadow_meta = move || -> String {
391 let live: ThemeTokens = use_live_tokens(tokens);
392 let lg: ThemeGeometry = live.get_geometry();
393 let (tier, sh): (&str, Shadow) = match shadow_idx.get() {
394 0 => (RENDER_SHADOW_OPT_SM, lg.get_shadow_sm()),
395 2 => (RENDER_SHADOW_OPT_LG, lg.get_shadow_lg()),
396 _ => (RENDER_SHADOW_OPT_MD, lg.get_shadow_md()),
397 };
398 format!(
399 "{tier} | offset=({:.0},{:.0}) blur={:.0}px",
400 sh.get_offset_x(),
401 sh.get_offset_y(),
402 sh.get_blur_radius()
403 )
404 };
405 let column_quaternary_style: Style = style! {
406 Width(Length::Percent(100.0))
407 Height(Length::Px(RENDER_EFFECT_STAGE_HEIGHT))
408 Padding(Edges::all(SPACE_LG))
409 JustifyContent::Center
410 Background(palette.get_muted())
411 Border::new(geometry.get_border_width(), palette.get_border())
412 Radius(geometry.get_radius_md())
413 Overflow::Hidden
414 };
415 view! {
416 EuvCard {
417 title: RENDER_SHADOW_CARD_TITLE.to_string()
418 tokens: tokens
419 subtitle: RENDER_SHADOW_CARD_SUB
420 column {
421 style: column_quaternary_style
422 view {
423 bind_style: tile_style
424 text {
425 bind_style: tile_title_style
426 { RENDER_SHADOW_SAMPLE_TITLE }
427 }
428 text {
429 bind_style: tile_meta_style
430 { shadow_meta }
431 }
432 }
433 }
434 }
435 }
436}
437
438pub(crate) fn mount_render_gradient_card(angle_idx: Signal<usize>, tokens: ThemeTokens) -> NodeId {
449 let grad_box_style = move || -> Style {
450 let live: ThemeTokens = use_live_tokens(tokens);
451 let lp: ThemePalette = live.get_palette();
452 let lg: ThemeGeometry = live.get_geometry();
453 let angle: f32 = render_gradient_angle(angle_idx.get());
454 let grad: LinearGradient = LinearGradient::new(angle, lp.get_primary(), lp.get_success());
455 style! {
456 FlexDirection::Column
457 Width(Length::Percent(100.0))
458 Height(Length::Px(RENDER_EFFECT_STAGE_HEIGHT))
459 Padding(Edges::all(SPACE_MD))
460 JustifyContent::End
461 Gap(SPACE_XS)
462 Background(lp.get_primary())
463 grad
464 Border::new(lg.get_border_width(), lp.get_border())
465 Radius(lg.get_radius_md())
466 Overflow::Hidden
467 }
468 };
469 let grad_title_style = move || -> Style {
470 let live: ThemeTokens = use_live_tokens(tokens);
471 style! {
472 Width(Length::Percent(100.0))
473 FontSize(14.0)
474 FontWeight::Bold
475 TextColor(live.get_palette().get_primary_foreground())
476 }
477 };
478 let grad_meta_style = move || -> Style {
479 let live: ThemeTokens = use_live_tokens(tokens);
480 style! {
481 Width(Length::Percent(100.0))
482 FontSize(12.0)
483 FontFamily::Monospace
484 TextColor(live.get_palette().get_primary_foreground())
485 }
486 };
487 let grad_meta = move || -> String {
488 let angle: f32 = render_gradient_angle(angle_idx.get());
489 format!("LinearGradient({angle:.0} deg, primary -> success)")
490 };
491 view! {
492 EuvCard {
493 title: RENDER_GRADIENT_CARD_TITLE.to_string()
494 tokens: tokens
495 subtitle: RENDER_GRADIENT_CARD_SUB
496 view {
497 bind_style: grad_box_style
498 text {
499 bind_style: grad_title_style
500 { RENDER_GRADIENT_SAMPLE_TITLE }
501 }
502 text {
503 bind_style: grad_meta_style
504 { grad_meta }
505 }
506 }
507 }
508 }
509}
510
511pub(crate) fn mount_render_damage_card(
522 pulse_sig: Signal<u32>,
523 tokens: ThemeTokens,
524) -> (NodeId, NodeId) {
525 let palette: ThemePalette = tokens.get_palette();
526 let geometry: ThemeGeometry = tokens.get_geometry();
527 let mut damage_canvas_id: NodeId = NodeId::default();
528 let paint_damage = move |bounds: Rect, display_list: &mut DisplayList| {
529 let live: ThemeTokens = live_tokens_untracked(tokens);
530 let lp: ThemePalette = live.get_palette();
531 let pulse: u32 = pulse_sig.get_untracked();
532 let cols: usize = 4;
533 let rows: usize = 2;
534 let pad: f32 = 10.0;
535 let gap: f32 = 6.0;
536 let usable_w: f32 = (bounds.get_width() - pad * 2.0 - gap * ((cols - 1) as f32)).max(40.0);
537 let usable_h: f32 =
538 (bounds.get_height() - 28.0 - pad * 2.0 - gap * ((rows - 1) as f32)).max(24.0);
539 let cell_w: f32 = usable_w / (cols as f32);
540 let cell_h: f32 = usable_h / (rows as f32);
541 let active_idx: usize = (pulse as usize) % (cols * rows);
542 for row in 0..rows {
543 for col in 0..cols {
544 let idx: usize = row * cols + col;
545 let rx: f32 = bounds.get_x() + pad + (col as f32) * (cell_w + gap);
546 let ry: f32 = bounds.get_y() + 26.0 + pad + (row as f32) * (cell_h + gap);
547 let is_dirty: bool = idx == active_idx;
548 let fill: Color = if is_dirty {
549 lp.get_warning().with_alpha(96)
550 } else {
551 lp.get_card()
552 };
553 let stroke: Color = if is_dirty {
554 lp.get_warning()
555 } else {
556 lp.get_border()
557 };
558 display_list.push(DrawCommand::FillRoundedRect {
559 rect: Rect::new(rx, ry, cell_w, cell_h),
560 color: fill,
561 radius: CornerRadius::all(6.0),
562 border: Border::new(if is_dirty { 2.0 } else { 1.0 }, stroke),
563 });
564 }
565 }
566 let mut hud_style: TextStyle = TextStyle::default();
567 hud_style
568 .set_font_size(11.5)
569 .set_weight(FontWeight::SemiBold)
570 .set_color(lp.get_foreground());
571 display_list.push(DrawCommand::TextRun {
572 rect: Rect::new(
573 bounds.get_x() + 10.0,
574 bounds.get_y() + 8.0,
575 (bounds.get_width() - 20.0).max(1.0),
576 18.0,
577 ),
578 text: format!("DIRTY_PAINT Pulses: {pulse} | Active Tile: #{active_idx}"),
579 style: hud_style,
580 });
581 };
582 let canvas_style: Style = style! {
583 Width(Length::Percent(100.0))
584 Height(Length::Px(RENDER_EFFECT_STAGE_HEIGHT))
585 Background(palette.get_muted())
586 Border::new(geometry.get_border_width(), palette.get_border())
587 Radius(geometry.get_radius_md())
588 };
589 let card: NodeId = view! {
590 EuvCard {
591 title: RENDER_DAMAGE_CARD_TITLE.to_string()
592 tokens: tokens
593 subtitle: RENDER_DAMAGE_CARD_SUB
594 canvas {
595 node_ref: damage_canvas_id
596 style: canvas_style
597 painter: paint_damage
598 }
599 }
600 };
601 (card, damage_canvas_id)
602}
603
604pub(crate) fn mount_render_shader_cache_card(tokens: ThemeTokens) -> NodeId {
614 let initial_report: Option<ShaderPrecompileReport> = shader_precompile_status();
615 let report_sig: Signal<Option<ShaderPrecompileReport>> = Signal::new(initial_report);
616 let summary_text = move || -> String {
617 if let Some(report) = report_sig.get() {
618 report.summary_line()
619 } else if is_shader_precompile_in_flight() {
620 "Compiling GPU shader pipelines on background worker thread...".to_string()
621 } else {
622 RENDER_SHADER_STATUS_PENDING.to_string()
623 }
624 };
625 let archive_text = move || -> String {
626 if let Some(report) = report_sig.get() {
627 let archive_label: &str = if report.get_binary_archive_hit() {
628 "Disk Archive Hit"
629 } else if report.get_binary_archive_enabled() {
630 "Disk Archive Written"
631 } else {
632 "Process PSO Cache"
633 };
634 format!(
635 "Backend: {:?} · Hardware PSOs: {}/{} · Cache: {archive_label}",
636 report.get_backend(),
637 report.get_hardware_compiled_programs(),
638 report.get_total_programs(),
639 )
640 } else {
641 format!(
642 "Target Backend: {:?} · Registered Shaders: {} (UI, Blur, 3D PBR, Ocean)",
643 default_native_gpu_backend(),
644 ShaderProgramId::all().len(),
645 )
646 }
647 };
648 let entries_text = move || -> String {
649 if let Some(report) = report_sig.get() {
650 let mut lines: Vec<String> = Vec::with_capacity(report.get_entries().len());
651 for entry in report.get_entries().iter() {
652 let compile_ms: f64 = (entry.get_compile_time_us() as f64) / 1000.0;
653 let short_name: &str = match entry.get_program() {
654 ShaderProgramId::UiUber => "UI Uber",
655 ShaderProgramId::BackdropBlur => "BackdropBlur",
656 ShaderProgramId::Engine3dPbr => "3D PBR",
657 ShaderProgramId::FluidOceanOptical => "Fluid Ocean",
658 };
659 lines.push(format!(
660 "{short_name} [{}] · {} ({compile_ms:.2}ms)",
661 entry.get_language(),
662 entry.get_state().label(),
663 ));
664 }
665 lines.join("\n")
666 } else {
667 "UI Uber · Dual-Kawase Blur · 3D Engine PBR · Fluid Ocean Optical".to_string()
668 }
669 };
670 let on_precompile_now = move |_: &UiEvent| {
671 let report: ShaderPrecompileReport = precompile_shaders(default_native_gpu_backend());
672 let _: bool = report_sig.set(Some(report));
673 };
674 let on_warmup_async = move |_: &UiEvent| {
675 precompile_shaders_async(default_native_gpu_backend());
676 let status: Option<ShaderPrecompileReport> = shader_precompile_status();
677 if status.is_some() {
678 let _: bool = report_sig.set(status);
679 }
680 };
681 let primary_mono_style = move || -> Style {
682 let live: ThemeTokens = use_live_tokens(tokens);
683 style! {
684 Width(Length::Percent(100.0))
685 FontSize(12.5)
686 FontFamily::Monospace
687 FontWeight::SemiBold
688 TextColor(live.get_palette().get_primary())
689 }
690 };
691 let muted_mono_style = move || -> Style {
692 let live: ThemeTokens = use_live_tokens(tokens);
693 style! {
694 Width(Length::Percent(100.0))
695 FontSize(11.5)
696 FontFamily::Monospace
697 TextColor(live.get_palette().get_muted_foreground())
698 }
699 };
700 let card_col_style: Style = style! {
701 Width(Length::Percent(100.0))
702 Gap(SPACE_SM)
703 };
704 view! {
705 EuvCard {
706 title: RENDER_SHADER_CARD_TITLE.to_string()
707 tokens: tokens
708 subtitle: RENDER_SHADER_CARD_SUB
709 column {
710 style: card_col_style
711 text {
712 bind_style: primary_mono_style
713 { summary_text }
714 }
715 text {
716 bind_style: muted_mono_style
717 { archive_text }
718 }
719 text {
720 bind_style: muted_mono_style
721 { entries_text }
722 }
723 EuvActionRow {
724 EuvButton {
725 label: RENDER_BTN_PRECOMPILE_SHADERS.to_string()
726 tokens: tokens
727 small()
728 on_click: on_precompile_now
729 }
730 EuvButton {
731 label: RENDER_BTN_WARMUP_ASYNC.to_string()
732 tokens: tokens
733 outline()
734 small()
735 on_click: on_warmup_async
736 }
737 }
738 }
739 }
740 }
741}
742
743pub fn mount_render_page(state: &ShowcaseState, tokens: ThemeTokens) -> NodeId {
754 let palette: ThemePalette = tokens.get_palette();
755 let ctx: Context = current_context();
756 let mode_idx: Signal<usize> = state.get_render_mode_index();
757 let blur_idx: Signal<usize> = Signal::new(1);
758 let shadow_idx: Signal<usize> = Signal::new(1);
759 let angle_idx: Signal<usize> = Signal::new(1);
760 let damage_pulse: Signal<u32> = Signal::new(0);
761 let (vector_card, vector_canvas_id): (NodeId, NodeId) =
762 mount_render_vector_card(mode_idx, tokens);
763 let (blur_card, glass_id): (NodeId, NodeId) = mount_render_blur_card(blur_idx, tokens);
764 let shadow_card: NodeId = mount_render_shadow_card(shadow_idx, tokens);
765 let gradient_card: NodeId = mount_render_gradient_card(angle_idx, tokens);
766 let (damage_card, damage_canvas_id): (NodeId, NodeId) =
767 mount_render_damage_card(damage_pulse, tokens);
768 let effects_grid: NodeId =
769 mount_responsive_grid(vec![blur_card, shadow_card, gradient_card, damage_card], 2);
770 let pulse_scene: SceneHandle = ctx.get_scene().clone();
771 let on_pulse_dirty = move |_: &UiEvent| {
772 let _: bool = {
773 if let Some(mut updated_value) = damage_pulse.try_get_untracked() {
774 {
775 let item_count: &mut u32 = &mut updated_value;
776 *item_count = item_count.saturating_add(1);
777 }
778 damage_pulse.set(updated_value)
779 } else {
780 false
781 }
782 };
783 pulse_scene.mark_dirty(damage_canvas_id, DIRTY_PAINT);
784 };
785 let pulse_readout = move || -> String {
786 format!(
787 "Surgical DIRTY_PAINT count: {} (zero global layout rebuild)",
788 damage_pulse.get()
789 )
790 };
791 let pipeline_card: NodeId = view! {
792 EuvCard {
793 title: RENDER_PIPELINE_CARD_TITLE.to_string()
794 tokens: tokens
795 subtitle: RENDER_PIPELINE_CARD_SUB
796 EuvSegmented {
797 options: vec![
798 MODE_AUTO.to_string(),
799 MODE_SOFTWARE.to_string(),
800 MODE_HARDWARE.to_string(),
801 MODE_HYBRID.to_string(),
802 ]
803 selected: mode_idx
804 tokens: tokens
805 }
806 }
807 };
808 let column_tertiary_style: Style = style! {
809 Width(Length::Percent(100.0))
810 Gap(SPACE_SM)
811 };
812 let text_style: Style = style! {
813 Width(Length::Percent(100.0))
814 FontSize(12.0)
815 FontWeight::Medium
816 TextColor(palette.get_muted_foreground())
817 };
818 let text_secondary_style: Style = style! {
819 Width(Length::Percent(100.0))
820 FontSize(12.0)
821 FontFamily::Monospace
822 TextColor(palette.get_primary())
823 };
824 let controls_card: NodeId = view! {
825 EuvCard {
826 title: RENDER_CONTROLS_CARD_TITLE.to_string()
827 tokens: tokens
828 subtitle: RENDER_CONTROLS_CARD_SUB
829 column {
830 style: column_tertiary_style
831 text {
832 style: text_style
833 { RENDER_LABEL_BLUR_RADIUS }
834 }
835 EuvSegmented {
836 options: vec![
837 RENDER_BLUR_OPT_8.to_string(),
838 RENDER_BLUR_OPT_16.to_string(),
839 RENDER_BLUR_OPT_24.to_string(),
840 ]
841 selected: blur_idx
842 tokens: tokens
843 }
844 text {
845 style: text_style
846 { RENDER_LABEL_SHADOW_TIER }
847 }
848 EuvSegmented {
849 options: vec![
850 RENDER_SHADOW_OPT_SM.to_string(),
851 RENDER_SHADOW_OPT_MD.to_string(),
852 RENDER_SHADOW_OPT_LG.to_string(),
853 ]
854 selected: shadow_idx
855 tokens: tokens
856 }
857 text {
858 style: text_style
859 { RENDER_LABEL_GRADIENT_ANGLE }
860 }
861 EuvSegmented {
862 options: vec![
863 RENDER_ANGLE_0.to_string(),
864 RENDER_ANGLE_45.to_string(),
865 RENDER_ANGLE_90.to_string(),
866 RENDER_ANGLE_135.to_string(),
867 ]
868 selected: angle_idx
869 tokens: tokens
870 }
871 EuvActionRow {
872 EuvButton {
873 label: RENDER_BTN_PULSE_DIRTY.to_string()
874 tokens: tokens
875 small()
876 on_click: on_pulse_dirty
877 }
878 }
879 text {
880 style: text_secondary_style
881 { pulse_readout }
882 }
883 }
884 }
885 };
886 let shader_cache_card: NodeId = mount_render_shader_cache_card(tokens);
887 let column_secondary_style: Style = style! {
888 Width(Length::Percent(100.0))
889 Gap(SPACE_MD)
890 };
891 let rail: NodeId = view! {
892 column {
893 style: column_secondary_style
894 { pipeline_card }
895 { controls_card }
896 }
897 };
898 let column_style: Style = style! {
899 Width(Length::Percent(100.0))
900 Gap(SPACE_MD)
901 };
902 let main: NodeId = view! {
903 column {
904 style: column_style
905 { vector_card }
906 { shader_cache_card }
907 { effects_grid }
908 }
909 };
910 let studio: NodeId = mount_studio_layout(main, rail);
911 let page: NodeId = view! {
912 EuvPage {
913 title: RENDER_TITLE.to_string()
914 subtitle: RENDER_SUBTITLE.to_string()
915 tokens: tokens
916 { studio }
917 }
918 };
919 let scene_for_mode: SceneHandle = ctx.get_scene().clone();
920 let scene_for_blur: SceneHandle = ctx.get_scene().clone();
921 let (render_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
922 let _: Effect = Effect::new(move || {
923 let _: usize = mode_idx.get();
924 scene_for_mode.mark_dirty(vector_canvas_id, DIRTY_PAINT);
925 });
926 Effect::new(move || {
927 let radius: f32 = render_blur_radius(blur_idx.get());
928 scene_for_blur.with_write(
929 |tree: &mut SceneTree| {
930 tree.set_backdrop_blur(glass_id, radius);
931 tree.mark_dirty(glass_id, DIRTY_PAINT);
932 },
933 (),
934 );
935 })
936 });
937 ctx.get_scene().with_write(
938 |tree: &mut SceneTree| {
939 tree.attach_scope(page, render_scope);
940 },
941 (),
942 );
943 page
944}