fix(viewport): preserve tiled pane controls

This commit is contained in:
Hakan Seven committed 2026-07-29 17:21:57 +03:00
1 parent 8e2b67bfa5
commit cd1378e6b2
4 files changed
+40 -7

No files matched your search

+25 -3
View File
@@ -4,6 +4,24 @@ use super::*;
impl Scene {
// ── Layout management ─────────────────────────────────────────────────
pub(crate) fn model_pane_min_px(&self) -> f32 {
let measured = f32::from_bits(
self.model_pane_min_px
.load(std::sync::atomic::Ordering::Relaxed),
);
if measured.is_finite() && measured > 1.0 {
measured
} else {
MODEL_PANE_MIN_FALLBACK_PX
}
}
pub(crate) fn model_pane_min_reporter(
&self,
) -> std::sync::Arc<std::sync::atomic::AtomicU32> {
self.model_pane_min_px.clone()
}
/// Rename a paper-space layout. Updates the Layout object name in the document.
pub fn rename_layout(&mut self, old_name: &str, new_name: &str) {
for obj in self.document.objects.values_mut() {
@@ -361,7 +379,11 @@ impl Scene {
let half = TILE_DIVIDER_PX * 0.5;
self.model_panes
.layout()
.split_regions(TILE_DIVIDER_PX, 0.0, iced::Size::new(vw, vh))
.split_regions(
TILE_DIVIDER_PX,
self.model_pane_min_px(),
iced::Size::new(vw, vh),
)
.values()
.map(|(axis, region, ratio)| match axis {
Axis::Vertical => {
@@ -394,7 +416,7 @@ impl Scene {
}
let regions = self.model_panes.layout().pane_regions(
TILE_DIVIDER_PX,
0.0,
self.model_pane_min_px(),
iced::Size::new(vw, vh),
);
self.model_panes
@@ -421,7 +443,7 @@ impl Scene {
}
let regions = self.model_panes.layout().pane_regions(
TILE_DIVIDER_PX,
0.0,
self.model_pane_min_px(),
iced::Size::new(canvas_w, canvas_h),
);
let mut tiles = self.model_tiles.borrow_mut();
+8
View File
@@ -1110,6 +1110,9 @@ pub(crate) struct ModelTile {
/// the drawn viewports line up exactly with the pane_grid layout.
pub const TILE_DIVIDER_PX: f32 = 2.0;
/// Minimum used until the viewport render-mode bar reports its natural width.
pub const MODEL_PANE_MIN_FALLBACK_PX: f32 = 50.0;
/// Shift every vertex of a freshly tessellated `MeshLodSet` into the
/// scene's local f32 space by subtracting `world_offset`. ACIS / SAT
/// tessellation hands us WCS coordinates; the wire / hatch / face3d
@@ -1502,6 +1505,10 @@ pub struct Scene {
/// Plain field (not a `RefCell`) so the view can borrow it for the
/// `PaneGrid` widget's lifetime; mutated through `&mut Scene` in update.
pub(crate) model_panes: iced::widget::pane_grid::State<usize>,
/// Natural width of the Model viewport control bar. `DensitySwap` updates
/// it during layout; every pane-grid geometry calculation reads it on the
/// next frame so a pane cannot become narrower than its controls.
model_pane_min_px: std::sync::Arc<std::sync::atomic::AtomicU32>,
pub selection: Rc<RefCell<SelectionState>>,
/// The CAD document — single source of truth for all entities.
pub document: CadDocument,
@@ -1903,6 +1910,7 @@ impl Scene {
last_sdf_text: RefCell::new(HashMap::default()),
// One pane mapped to tile 0 — matches the single default tile above.
model_panes: iced::widget::pane_grid::State::new(0).0,
model_pane_min_px: std::sync::Arc::new(std::sync::atomic::AtomicU32::new(0)),
selection: Rc::new(RefCell::new(SelectionState::default())),
document: CadDocument::new(),
object_data_cache: crate::entities::object_data::ObjectDataCache::default(),