fix(ribbon): Properties panel compact/collapse, undo-redo anchoring, restore panel dividers

- The Properties panel's Match button now shrinks to a small icon when the
  panel is compacted (render_large gained a `compact` flag), so the panel
  actually gets narrower and joins the from-the-right degradation instead
  of jumping straight to collapsed.
- A collapsed Properties panel now shows its Match button as the
  representative face: item_id recognises PropertiesGroup and
  collapse_button renders its match_prop as a large tool.
- The undo/redo history controls are wrapped in PosReport, so their
  dropdowns anchor directly below the button (and flip at the edge) like
  every other dropdown, instead of falling back to the corner.
- Panel dividers are back: CollapsePanels draws a 1px line between adjacent
  panels, skipped only between two collapsed panels.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-07-05 19:23:48 +03:00
commit 6a5402ccae
3 changed files with 102 additions and 36 deletions

View file

@ -9,8 +9,11 @@ use std::cell::RefCell;
use iced::advanced::layout::{self, Layout};
use iced::advanced::widget::{self, Widget};
use iced::advanced::{mouse, overlay, renderer, Clipboard, Shell};
use iced::{Element, Event, Length, Point, Rectangle, Renderer, Size, Theme, Vector};
use iced::advanced::{mouse, overlay, renderer, Clipboard, Renderer as _, Shell};
use iced::{
Background, Border, Color, Element, Event, Length, Point, Rectangle, Renderer, Shadow, Size,
Theme, Vector,
};
use crate::app::Message;
@ -35,17 +38,20 @@ pub struct CollapsePanels<'a> {
open: Option<String>,
/// Row height (a full ribbon tool-area height).
row_h: f32,
/// Colour of the 1px divider drawn between panels.
divider: Color,
/// Chosen degradation level per panel; set during layout.
levels: RefCell<Vec<u8>>,
}
impl<'a> CollapsePanels<'a> {
pub fn new(panels: Vec<Panel<'a>>, open: Option<String>, row_h: f32) -> Self {
pub fn new(panels: Vec<Panel<'a>>, open: Option<String>, row_h: f32, divider: Color) -> Self {
let n = panels.len();
Self {
panels,
open,
row_h,
divider,
levels: RefCell::new(vec![FULL; n]),
}
}
@ -276,6 +282,31 @@ impl<'a> Widget<Message, Theme, Renderer> for CollapsePanels<'a> {
viewport,
);
}
// 1px divider between adjacent panels, except between two collapsed
// panels (whose buttons read better with no line between them).
let bounds: Vec<Rectangle> = layout.children().map(|l| l.bounds()).collect();
let wb = layout.bounds();
for i in 0..self.panels.len().saturating_sub(1) {
if levels[i] == COLLAPSED && levels[i + 1] == COLLAPSED {
continue;
}
let x = bounds[i + 1].x;
renderer.fill_quad(
renderer::Quad {
bounds: Rectangle {
x,
y: wb.y,
width: 1.0,
height: wb.height,
},
border: Border::default(),
shadow: Shadow::default(),
snap: true,
},
Background::Color(self.divider),
);
}
}
fn overlay<'b>(