css fixes
This commit is contained in:
parent
ec46e22782
commit
6b3a286caf
|
|
@ -5378,7 +5378,6 @@ impl eframe::App for EditorApp {
|
|||
// Main pane area (editor mode)
|
||||
let mut layout_action: Option<LayoutAction> = None;
|
||||
let mut clipboard_consumed = false;
|
||||
let mut css_debug_regions: Vec<panes::CssDebugRegion> = Vec::new();
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
let available_rect = ui.available_rect_before_wrap();
|
||||
|
||||
|
|
@ -5522,8 +5521,6 @@ impl eframe::App for EditorApp {
|
|||
commit_raster_floating_if_any: &mut self.commit_raster_floating_if_any,
|
||||
pending_node_group: &mut self.pending_node_group,
|
||||
pending_node_ungroup: &mut self.pending_node_ungroup,
|
||||
css_debug_regions: &mut css_debug_regions,
|
||||
css_debug_overlay: self.debug_overlay_visible,
|
||||
#[cfg(debug_assertions)]
|
||||
test_mode: &mut self.test_mode,
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
@ -6014,54 +6011,6 @@ impl eframe::App for EditorApp {
|
|||
);
|
||||
debug_overlay::render_debug_overlay(ctx, &stats);
|
||||
|
||||
// CSS Inspector: show CSS context for element under cursor
|
||||
if !css_debug_regions.is_empty() {
|
||||
if let Some(pointer_pos) = ctx.input(|i| i.pointer.hover_pos()) {
|
||||
// Find the smallest region containing the pointer
|
||||
let mut best: Option<&panes::CssDebugRegion> = None;
|
||||
for region in &css_debug_regions {
|
||||
if region.rect.contains(pointer_pos) {
|
||||
if best.map_or(true, |b| region.rect.area() < b.rect.area()) {
|
||||
best = Some(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(region) = best {
|
||||
let painter = ctx.layer_painter(egui::LayerId::new(
|
||||
egui::Order::Tooltip,
|
||||
egui::Id::new("css_inspector"),
|
||||
));
|
||||
// Highlight border
|
||||
painter.rect_stroke(
|
||||
region.rect,
|
||||
0.0,
|
||||
egui::Stroke::new(2.0, egui::Color32::from_rgb(0, 200, 255)),
|
||||
egui::StrokeKind::Outside,
|
||||
);
|
||||
// Tooltip with CSS context
|
||||
let context_str = region.context.join(" ");
|
||||
let resolved = self.theme.resolve_with_provenance(®ion.context.iter().map(|s| *s).collect::<Vec<_>>(), ctx);
|
||||
let mut tooltip_lines = vec![context_str];
|
||||
for (prop, sel) in &resolved.provenance {
|
||||
tooltip_lines.push(format!("{}: (from {})", prop, sel));
|
||||
}
|
||||
let tooltip_text = tooltip_lines.join("\n");
|
||||
|
||||
let tooltip_pos = pointer_pos + egui::vec2(16.0, 16.0);
|
||||
let galley = painter.layout_no_wrap(
|
||||
tooltip_text,
|
||||
egui::FontId::monospace(11.0),
|
||||
egui::Color32::from_rgb(200, 240, 255),
|
||||
);
|
||||
let tooltip_rect = egui::Rect::from_min_size(
|
||||
tooltip_pos,
|
||||
galley.size() + egui::vec2(12.0, 8.0),
|
||||
);
|
||||
painter.rect_filled(tooltip_rect, 4.0, egui::Color32::from_black_alpha(220));
|
||||
painter.galley(tooltip_pos + egui::vec2(6.0, 4.0), galley, egui::Color32::WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render custom cursor overlay (on top of everything including debug overlay)
|
||||
|
|
@ -6399,9 +6348,9 @@ fn render_pane(
|
|||
ui.painter().rect_filled(header_rect, 0.0, header_bg);
|
||||
|
||||
// Draw content background
|
||||
let bg_color = if let Some(pane_type) = pane_type {
|
||||
let pane_id = pane_type_css_id(pane_type);
|
||||
ctx.shared.theme.bg_color(&[pane_id, ".pane-content"], ui.ctx(), pane_color(pane_type))
|
||||
let pane_id = pane_type.map(pane_type_css_id);
|
||||
let bg_color = if let Some(pane_id) = pane_id {
|
||||
ctx.shared.theme.bg_color(&[pane_id, ".pane-content"], ui.ctx(), pane_color(pane_type.unwrap()))
|
||||
} else {
|
||||
egui::Color32::from_rgb(40, 40, 40)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -141,12 +141,6 @@ pub fn find_sampled_audio_track(document: &lightningbeam_core::document::Documen
|
|||
None
|
||||
}
|
||||
|
||||
/// CSS debug region for the CSS inspector overlay (F3)
|
||||
pub struct CssDebugRegion {
|
||||
pub rect: egui::Rect,
|
||||
pub context: Vec<&'static str>,
|
||||
}
|
||||
|
||||
/// Shared state that all panes can access
|
||||
pub struct SharedPaneState<'a> {
|
||||
pub tool_icon_cache: &'a mut crate::ToolIconCache,
|
||||
|
|
@ -291,10 +285,6 @@ pub struct SharedPaneState<'a> {
|
|||
pub pending_node_group: &'a mut bool,
|
||||
/// Set by MenuAction::Group (ungroup variant) when focus is Nodes — consumed by node graph pane
|
||||
pub pending_node_ungroup: &'a mut bool,
|
||||
/// CSS debug regions for the CSS inspector overlay (F3)
|
||||
pub css_debug_regions: &'a mut Vec<CssDebugRegion>,
|
||||
/// Whether the CSS debug overlay is active
|
||||
pub css_debug_overlay: bool,
|
||||
/// Test mode state for event recording (debug builds only)
|
||||
#[cfg(debug_assertions)]
|
||||
pub test_mode: &'a mut crate::test_mode::TestModeState,
|
||||
|
|
|
|||
|
|
@ -269,14 +269,6 @@ struct Rule {
|
|||
style: Style,
|
||||
}
|
||||
|
||||
/// Resolved style with provenance information (for CSS inspector)
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ResolvedStyle {
|
||||
pub style: Style,
|
||||
/// property_name -> selector that provided it
|
||||
pub provenance: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Theme {
|
||||
light_variables: HashMap<String, String>,
|
||||
|
|
@ -510,74 +502,6 @@ impl Theme {
|
|||
result
|
||||
}
|
||||
|
||||
/// Resolve with provenance info (for CSS inspector debug overlay)
|
||||
pub fn resolve_with_provenance(&self, context: &[&str], ctx: &egui::Context) -> ResolvedStyle {
|
||||
let is_dark = self.is_dark(ctx);
|
||||
let rules = if is_dark { &self.dark_rules } else { &self.light_rules };
|
||||
|
||||
let mut matching: Vec<&Rule> = rules
|
||||
.iter()
|
||||
.filter(|r| r.selector.matches(context))
|
||||
.collect();
|
||||
|
||||
matching.sort_by_key(|r| r.selector.specificity);
|
||||
|
||||
let mut result = Style::default();
|
||||
let mut provenance = HashMap::new();
|
||||
|
||||
for rule in &matching {
|
||||
let selector_str = rule.selector.parts.join(" ");
|
||||
let s = &rule.style;
|
||||
|
||||
if s.background.is_some() {
|
||||
result.background = s.background.clone();
|
||||
provenance.insert("background".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.border_color.is_some() {
|
||||
result.border_color = s.border_color;
|
||||
provenance.insert("border-color".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.border_width.is_some() {
|
||||
result.border_width = s.border_width;
|
||||
provenance.insert("border-width".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.border_radius.is_some() {
|
||||
result.border_radius = s.border_radius;
|
||||
provenance.insert("border-radius".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.text_color.is_some() {
|
||||
result.text_color = s.text_color;
|
||||
provenance.insert("color".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.width.is_some() {
|
||||
result.width = s.width;
|
||||
provenance.insert("width".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.height.is_some() {
|
||||
result.height = s.height;
|
||||
provenance.insert("height".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.padding.is_some() {
|
||||
result.padding = s.padding;
|
||||
provenance.insert("padding".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.margin.is_some() {
|
||||
result.margin = s.margin;
|
||||
provenance.insert("margin".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.font_size.is_some() {
|
||||
result.font_size = s.font_size;
|
||||
provenance.insert("font-size".to_string(), selector_str.clone());
|
||||
}
|
||||
if s.opacity.is_some() {
|
||||
result.opacity = s.opacity;
|
||||
provenance.insert("opacity".to_string(), selector_str.clone());
|
||||
}
|
||||
}
|
||||
|
||||
ResolvedStyle { style: result, provenance }
|
||||
}
|
||||
|
||||
/// Convenience: resolve and extract background color with fallback
|
||||
pub fn bg_color(&self, context: &[&str], ctx: &egui::Context, fallback: egui::Color32) -> egui::Color32 {
|
||||
self.resolve(context, ctx).background_color().unwrap_or(fallback)
|
||||
|
|
|
|||
Loading…
Reference in New Issue