refactor(op-editor-core): rename UiChrome → EditorUiState (drop the 'chrome' term)

This commit is contained in:
Kayshen-X 2026-05-16 17:51:39 +08:00
parent ec5ac70118
commit 88e155b324
6 changed files with 29 additions and 29 deletions

View file

@ -31,7 +31,7 @@ use crate::walkers::ReorderDirection;
/// Which boolean property [`EditorCommand::SetNodeFlag`] writes. The
/// canonical `PenNodeBase` carries `visible` + `locked`; `Collapsed` is
/// an editor-chrome-only flag with no schema field, so the applier
/// an editor-UI-only flag with no schema field, so the applier
/// rejects it (documented in the apply module).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NodeFlag {

View file

@ -249,7 +249,7 @@ impl EditorState {
}
/// `SetNodeFlag` — flip a boolean flag on a node. `Collapsed` has
/// no canonical-schema field (it is editor-chrome-only state), so
/// no canonical-schema field (it is editor-UI-only state), so
/// the applier rejects it; `Hidden` writes `visible`, `Locked`
/// writes `locked`.
pub(crate) fn cmd_set_node_flag(
@ -263,7 +263,7 @@ impl EditorState {
}
if matches!(flag, NodeFlag::Collapsed) {
// No `collapsed` field on `PenNodeBase` — collapse is a
// layer-panel chrome flag, not part of the `.op` document.
// layer-panel UI flag, not part of the `.op` document.
return false;
}
let Some(node) = find_node_mut(self.active_children_mut(), node_id) else {

View file

@ -1,6 +1,6 @@
//! Chrome / overlay UI state for `EditorState`.
//! Editor-UI overlay + panel state for `EditorState`.
//!
//! This module ports the ~30 widget-layer chrome fields that
//! This module ports the ~30 widget-layer UI fields that
//! `openpencil-shell-core::document::UiState` carries beyond the
//! editor-state subset already modelled by [`crate::ui_draft`]:
//!
@ -32,7 +32,7 @@ use crate::tool::Tool;
// it lives in `op-i18n` and re-exports cleanly into the state layer.
pub use op_i18n::Locale;
/// Light / dark chrome theme switch.
/// Light / dark UI theme switch.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ThemeMode {
Dark,
@ -179,7 +179,7 @@ pub enum ShapeChoice {
// What the LayerPanel right-click context menu is acting on — the
// canonical definition is `ui_draft::LayerContextTarget` (it backs
// the inline-rename draft too). Re-exported so chrome code that
// the inline-rename draft too). Re-exported so UI code that
// references a context target has one import path.
pub use crate::ui_draft::LayerContextTarget;
@ -207,9 +207,9 @@ pub enum VariableRowFocus {
String(usize),
}
/// Chrome / overlay UI state — the widget-layer toggles, hover
/// Editor-UI overlay + panel state — the widget-layer toggles, hover
/// targets, menu / modal open flags and panel metrics that the ~30
/// editor widgets paint from. Faithful superset of the chrome subset
/// editor widgets paint from. Faithful superset of the UI subset
/// of shell-core's `UiState`.
///
/// The *editor-state* subset of `UiState` (focused property field +
@ -217,14 +217,14 @@ pub enum VariableRowFocus {
/// caches, active page index) lives on [`crate::ui_draft::UiDraftState`]
/// and is not duplicated here.
#[derive(Debug, Clone)]
pub struct UiChrome {
pub struct EditorUiState {
// --- Sidebar + panel metrics -----------------------------------
pub sidebar_open: bool,
pub layer_panel_width: f32,
pub property_panel_width: f32,
// --- Theme + locale --------------------------------------------
/// Active chrome theme — TopBar Sun icon flips it.
/// Active UI theme — TopBar Sun icon flips it.
pub theme_mode: ThemeMode,
/// UI locale — TopBar Globe cycles.
pub locale: Locale,
@ -311,7 +311,7 @@ pub struct UiChrome {
pub last_canvas_click: Option<(NodeId, u64)>,
}
impl Default for UiChrome {
impl Default for EditorUiState {
fn default() -> Self {
Self {
sidebar_open: true,
@ -360,8 +360,8 @@ impl Default for UiChrome {
}
}
impl UiChrome {
/// A fresh chrome state — sidebar open, dark theme, no menus open.
impl EditorUiState {
/// A fresh UI state — sidebar open, dark theme, no menus open.
pub fn new() -> Self {
Self::default()
}
@ -372,8 +372,8 @@ mod tests {
use super::*;
#[test]
fn default_chrome_is_quiescent() {
let c = UiChrome::new();
fn default_editor_ui_is_quiescent() {
let c = EditorUiState::new();
assert!(c.sidebar_open);
assert_eq!(c.theme_mode, ThemeMode::Dark);
assert_eq!(c.locale, Locale::ZhCn);

View file

@ -31,7 +31,7 @@ pub mod rename;
pub mod selection;
pub mod state;
pub mod tool;
pub mod ui_chrome;
pub mod editor_ui_state;
pub mod ui_draft;
pub mod variables;
pub mod viewport;
@ -65,10 +65,10 @@ pub use render_backend::*;
pub use selection::SelectionState;
pub use state::EditorState;
pub use tool::Tool;
pub use ui_chrome::{
pub use editor_ui_state::{
BooleanOp, ExportFormat, FileAction, FileMenuChoice, FillType, FlexLayout,
LayerContextMenuState, Locale, PageRenameState, PropertyTab, RecentFile, ShapeChoice,
ThemeMode, UiChrome, VariableRowFocus,
ThemeMode, EditorUiState, VariableRowFocus,
};
pub use ui_draft::{
ColorPickerDrag, ColorPickerState, ColorTarget, LayerContextTarget, LayerRenameState,

View file

@ -44,7 +44,7 @@ use crate::components::ComponentLibrary;
use crate::history::History;
use crate::selection::SelectionState;
use crate::tool::Tool;
use crate::ui_chrome::UiChrome;
use crate::editor_ui_state::EditorUiState;
use crate::ui_draft::UiDraftState;
use crate::viewport::Viewport;
@ -72,11 +72,11 @@ pub struct EditorState {
/// Transient UI state — draft buffers, focus, active page index,
/// rebuilt-on-load variable/theme caches.
pub ui: UiDraftState,
/// Chrome / overlay UI state — the widget-layer toggles, hover
/// Editor-UI overlay + panel state — the widget-layer toggles, hover
/// targets, menu / modal open flags and panel metrics. With this
/// + `chat` + `components`, `EditorState` is a complete state
/// superset of shell-core's `Document` (Phase 6 Task 6.1a).
pub chrome: UiChrome,
pub editor_ui: EditorUiState,
/// AI chat sub-state — message transcript, input draft, panel
/// anchor, model catalog. Mirrors shell-core's `Document.chat`.
pub chat: ChatState,
@ -100,7 +100,7 @@ impl EditorState {
history: History::new(),
clipboard: Vec::new(),
ui: UiDraftState::new(),
chrome: UiChrome::new(),
editor_ui: EditorUiState::new(),
chat: ChatState::default(),
components: ComponentLibrary::default(),
}
@ -171,12 +171,12 @@ mod tests {
}
#[test]
fn new_state_carries_chrome_chat_and_components() {
fn new_state_carries_editor_ui_chat_and_components() {
let s = EditorState::new();
// Chrome defaults: sidebar open, dark theme, no menus open.
assert!(s.chrome.sidebar_open);
assert!(!s.chrome.file_menu_open);
assert!(!s.chrome.agent_settings_open);
// Editor-UI defaults: sidebar open, dark theme, no menus open.
assert!(s.editor_ui.sidebar_open);
assert!(!s.editor_ui.file_menu_open);
assert!(!s.editor_ui.agent_settings_open);
// Chat starts empty + idle.
assert!(s.chat.messages.is_empty());
assert!(s.chat.pending_send.is_none());

View file

@ -5,7 +5,7 @@
//! `openpencil-shell-core::document::UiState`. shell-core's `UiState`
//! also carries a large amount of *widget-layer* state (hover targets
//! typed as `crate::widgets::*`, export-dialog format enums, the
//! agent-settings modal struct, etc.). Those are chrome concerns that
//! agent-settings modal struct, etc.). Those are UI concerns that
//! belong to a later widget-layer crate, not the editor-state layer —
//! `op-editor-core` deliberately has no widget dependency. So this
//! struct ports the parts that are genuinely editor state: