Add semi-transparent background to metadata overlay text - #104
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughMetadata overlay text now uses a shared styled-text helper with a half-transparent black background. Field labels, values, empty-state messaging, and overlay actions use the helper, while action rendering switches to galley painting. A unit test verifies the background styling. ChangesMetadata Overlay Styling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/metadata.rs (1)
235-265: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHover and disabled text colors will not be applied.
RichText::append_toresolves the text color usingui.style().visuals.text_color()and bakes it into theLayoutJob. Because the glyphs in the resultingGalleypossess a concrete color, the fallbackcolorpassed toui.painter().galley(...)will be ignored. Consequently, the hover and disabled visual states will not render.To fix this, clone the initial
LayoutJobto calculate dimensions, then mutate the text section's format color before requesting the final galley.🐛 Proposed fix to apply the correct interaction color
fn metadata_overlay_action(ui: &mut egui::Ui, text: &str, enabled: bool) -> egui::Response { let font_id = egui::TextStyle::Body.resolve(ui.style()); let mut layout_job = egui::text::LayoutJob::default(); Self::metadata_overlay_text(text).font(font_id).append_to( &mut layout_job, ui.style(), egui::FontSelection::Default, egui::Align::BOTTOM, ); - let galley = ui.painter().layout_job(layout_job); + let galley = ui.painter().layout_job(layout_job.clone()); let sense = if enabled { egui::Sense::click() } else { egui::Sense::hover() }; let (rect, response) = ui.allocate_exact_size(galley.size(), sense); let response = if enabled { response.on_hover_cursor(egui::CursorIcon::PointingHand) } else { response }; let color = if enabled && response.hovered() { egui::Color32::WHITE } else if enabled { ui.visuals().weak_text_color() } else { ui.visuals().weak_text_color().gamma_multiply(0.65) }; + layout_job.sections[0].format.color = color; + let galley = ui.painter().layout_job(layout_job); ui.painter().galley(rect.left_top(), galley, color); response }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/metadata.rs` around lines 235 - 265, Update metadata_overlay_action so the layout job used for size allocation is cloned, then set the text section’s format color on the final job to the computed interaction color before creating the galley. Ensure the hover, enabled, and disabled colors selected by the existing color logic are embedded in the galley rather than relying on the painter’s fallback color.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/app/metadata.rs`:
- Around line 235-265: Update metadata_overlay_action so the layout job used for
size allocation is cloned, then set the text section’s format color on the final
job to the computed interaction color before creating the galley. Ensure the
hover, enabled, and disabled colors selected by the existing color logic are
embedded in the galley rather than relying on the painter’s fallback color.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e70e3caf-c206-4f40-bbda-19937df5664e
📒 Files selected for processing (1)
src/app/metadata.rs
Summary by CodeRabbit