| 2357 | fn apply_inspector_value_row_text_layout<API: ScriptAPI + ?Sized>( |
| 2358 | ctx: &mut ScriptContext<'_, API>, |
| 2359 | idx: usize, |
| 2360 | row: &InspectorValueRow, |
| 2361 | changed: bool, |
| 2362 | ) { |
| 2363 | let (name_ratio, name_text_ratio) = if row.source == "section" { |
| 2364 | if row.depth == 0 { |
| 2365 | (0.96, 0.38) |
| 2366 | } else { |
| 2367 | (0.96, 0.36) |
| 2368 | } |
| 2369 | } else if row.kind == "EmptyArrayAdd" || row.kind == "EmptyObject" { |
| 2370 | (0.62, 0.62) |
| 2371 | } else if row.kind == "BitMask" { |
| 2372 | (0.13, 0.13) |
| 2373 | } else if row.kind.starts_with("Matrix(") { |
| 2374 | (0.23, 0.23) |
| 2375 | } else if row.kind == "Quat" || !row.components.is_empty() || row.kind == "Color" { |
| 2376 | (0.27, 0.32) |
| 2377 | } else { |
| 2378 | (0.42, 0.31) |
| 2379 | }; |
| 2380 | let name_label = format!("inspector_var_{idx}_name"); |
| 2381 | set_label_text_ratio(ctx, &name_label, name_text_ratio); |
| 2382 | set_label_size_ratio(ctx, &name_label, (name_ratio, 1.0)); |
| 2383 | if row.kind == "Quat" { |
| 2384 | set_ui_node_size( |
| 2385 | ctx, |
| 2386 | &format!("inspector_var_{idx}_components"), |
| 2387 | (0.68, 1.0), |
| 2388 | ); |
| 2389 | set_ui_node_size( |
| 2390 | ctx, |
| 2391 | &format!("inspector_var_{idx}_quat_mode"), |
| 2392 | (0.30, 0.32), |
| 2393 | ); |
| 2394 | } |
| 2395 | if row.source == "section" { |
| 2396 | // Categories stay centered like Godot; nested section headers hug |
| 2397 | // the left edge next to their disclosure marker. |
| 2398 | let marker = row.value.trim(); |
| 2399 | let text = if marker.is_empty() { |
| 2400 | row.name.clone() |
| 2401 | } else { |
| 2402 | format!("{marker} {}", row.name) |
| 2403 | }; |
| 2404 | set_label(ctx, &name_label, &text); |
| 2405 | set_label_h_align( |
| 2406 | ctx, |
| 2407 | &name_label, |
| 2408 | if row.depth == 0 { |
| 2409 | UiTextAlign::Center |
| 2410 | } else { |
| 2411 | UiTextAlign::Start |