refactor(shell): single canonical MIN_RAIL_WIDTH in shell-core
Codex Step 3 R1 BLOCK: `MIN_RAIL_WIDTH: f32 = 80.0` was defined twice — once in `crates/openpencil-shell-web/src/widget_host.rs` and once in `crates/openpencil-shell-native/src/widget_host.rs`. Each had a comment claiming "mirrors the other"; nothing enforced agreement. A future drift on one side would silently break cross-platform layout parity. Move to a single canonical `pub const MIN_RAIL_WIDTH: f32 = 80.0` in `crates/openpencil-shell-core/src/widgets/mod.rs`. Both hosts import it via the existing `widgets::*` use list. Verification: - `cargo build -p openpencil-shell-native --example inspector_window` — green - `cargo build -p openpencil-shell-web --target wasm32-unknown-unknown --features skia --release` — green - `cargo test -p openpencil-shell-core --lib` — 39 tests passing - grep confirms one definition + two imports + 4 use sites
This commit is contained in:
parent
3192d237f4
commit
8523f7fbcf
|
|
@ -17,6 +17,15 @@
|
|||
|
||||
use crate::{Point2D, Rect, RenderBackend};
|
||||
|
||||
/// Minimum width (in CSS / physical px) below which the editor-UI
|
||||
/// host paints the Toolbar only and skips the LayerPanel /
|
||||
/// CanvasViewport / PropertyPanel rails. Single canonical
|
||||
/// definition consumed by both `openpencil-shell-web::WidgetHost`
|
||||
/// and `openpencil-shell-native::WidgetHostNative` so they stay in
|
||||
/// lock-step (codex Step 3 R1 BLOCK fix — was duplicated as
|
||||
/// `const MIN_RAIL_WIDTH` in each host).
|
||||
pub const MIN_RAIL_WIDTH: f32 = 80.0;
|
||||
|
||||
// Phase B primitives.
|
||||
pub mod dropdown;
|
||||
pub mod prop_row;
|
||||
|
|
|
|||
|
|
@ -52,16 +52,10 @@
|
|||
use crate::backend::NativeBackend;
|
||||
use openpencil_shell_core::document::Document;
|
||||
use openpencil_shell_core::widgets::{
|
||||
CanvasViewport, LayerPanel, LayoutCx, PaintCx, PropertyPanel, Toolbar, Widget,
|
||||
CanvasViewport, LayerPanel, LayoutCx, PaintCx, PropertyPanel, Toolbar, Widget, MIN_RAIL_WIDTH,
|
||||
};
|
||||
use openpencil_shell_core::{Color, Point2D, Rect, RenderBackend, TextLayout};
|
||||
|
||||
/// Below this viewport width (in physical px) we paint the Toolbar
|
||||
/// only and skip both rails. Mirrors shell-web's `MIN_RAIL_WIDTH`
|
||||
/// constant so cross-platform behaviour at narrow viewports stays
|
||||
/// in sync. Codex Step 2 R1 CONCERN-3.
|
||||
const MIN_RAIL_WIDTH: f32 = 80.0;
|
||||
|
||||
/// Frame-scoped `RenderBackend` adapter over `NativeBackend` +
|
||||
/// `&Canvas`. Lifetime-bound to the `SharedSkiaContext::with_frame`
|
||||
/// closure body so widget code never sees the canvas borrow directly.
|
||||
|
|
|
|||
|
|
@ -24,17 +24,10 @@
|
|||
use crate::backend::WebBackend;
|
||||
use openpencil_shell_core::document::Document;
|
||||
use openpencil_shell_core::widgets::{
|
||||
CanvasViewport, LayerPanel, LayoutCx, PaintCx, PropertyPanel, Toolbar, Widget,
|
||||
CanvasViewport, LayerPanel, LayoutCx, PaintCx, PropertyPanel, Toolbar, Widget, MIN_RAIL_WIDTH,
|
||||
};
|
||||
use openpencil_shell_core::{Point2D, Rect, RenderBackend};
|
||||
|
||||
/// Below this viewport width (in CSS px) we paint the Toolbar
|
||||
/// only and skip both rails — there's not enough horizontal
|
||||
/// space for a usable LayerPanel + PropertyPanel split. Codex
|
||||
/// Step 2 R1 CONCERN-3: clamp `rail_w` to non-negative AND skip
|
||||
/// when too small to be useful.
|
||||
const MIN_RAIL_WIDTH: f32 = 80.0;
|
||||
|
||||
/// The Step 3 editor-UI host. Owns the document model + toolbar
|
||||
/// tool selection; per-frame builds LayerPanel / PropertyPanel /
|
||||
/// CanvasViewport from the document. Aux Dropdown / TextInput
|
||||
|
|
|
|||
Loading…
Reference in a new issue