2026-04-08 22:56:51 +03:00
|
|
|
//! Text Style Font Browser window — fills the entire OS window.
|
|
|
|
|
|
|
|
|
|
use crate::app::Message;
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
use crate::app::StyleKind;
|
2026-06-03 17:43:12 +03:00
|
|
|
use iced::widget::{button, checkbox, column, container, row, scrollable, text, text_input, Space};
|
2026-04-08 22:56:51 +03:00
|
|
|
use iced::{Background, Border, Color, Element, Fill, Theme};
|
|
|
|
|
|
2026-06-03 17:43:12 +03:00
|
|
|
/// View-model for the Text Style editor window.
|
|
|
|
|
pub struct TextStyleView<'a> {
|
|
|
|
|
pub styles: Vec<String>,
|
|
|
|
|
pub selected: &'a str,
|
|
|
|
|
pub font_buf: &'a str,
|
|
|
|
|
pub width_buf: &'a str,
|
|
|
|
|
pub oblique_buf: &'a str,
|
|
|
|
|
pub height_buf: &'a str,
|
|
|
|
|
pub bigfont_buf: &'a str,
|
|
|
|
|
pub ttf_buf: &'a str,
|
|
|
|
|
pub backward: bool,
|
|
|
|
|
pub upside_down: bool,
|
|
|
|
|
pub annotative: bool,
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
/// Name of the style being renamed inline (double-clicked), if any.
|
|
|
|
|
pub rename_active: Option<&'a str>,
|
|
|
|
|
/// Edit buffer for the inline rename text input.
|
|
|
|
|
pub rename_buf: &'a str,
|
2026-06-03 17:43:12 +03:00
|
|
|
}
|
|
|
|
|
|
2026-05-12 10:36:15 +03:00
|
|
|
const BORDER: Color = Color {
|
|
|
|
|
r: 0.35,
|
|
|
|
|
g: 0.35,
|
|
|
|
|
b: 0.35,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
|
|
|
|
const TEXT: Color = Color {
|
|
|
|
|
r: 0.88,
|
|
|
|
|
g: 0.88,
|
|
|
|
|
b: 0.88,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
|
|
|
|
const DIM: Color = Color {
|
|
|
|
|
r: 0.55,
|
|
|
|
|
g: 0.55,
|
|
|
|
|
b: 0.55,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
|
|
|
|
const ACCENT: Color = Color {
|
|
|
|
|
r: 0.25,
|
|
|
|
|
g: 0.50,
|
|
|
|
|
b: 0.85,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
|
|
|
|
const ACTIVE: Color = Color {
|
|
|
|
|
r: 0.20,
|
|
|
|
|
g: 0.40,
|
|
|
|
|
b: 0.70,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
|
|
|
|
const FIELD: Color = Color {
|
|
|
|
|
r: 0.10,
|
|
|
|
|
g: 0.10,
|
|
|
|
|
b: 0.10,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
|
|
|
|
const LIST: Color = Color {
|
|
|
|
|
r: 0.12,
|
|
|
|
|
g: 0.12,
|
|
|
|
|
b: 0.12,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
};
|
2026-04-08 22:56:51 +03:00
|
|
|
|
|
|
|
|
const BUILTIN_FONTS: &[&str] = &[
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
"Standard", "ISO", "Simplex", "RomanS", "RomanD", "RomanC", "RomanT", "ItalicC", "ItalicT",
|
|
|
|
|
"ScriptS", "ScriptC", "GothGBT", "GothGRT", "GothITT", "Cursive", "GreekC", "Symbol", "ISO",
|
|
|
|
|
"ISO3098", "Unicode",
|
2026-04-08 22:56:51 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
fn list_item(active: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
|
|
|
|
move |_: &Theme, st| button::Style {
|
|
|
|
|
background: Some(Background::Color(match (active, st) {
|
2026-05-12 10:36:15 +03:00
|
|
|
(true, _) => ACTIVE,
|
|
|
|
|
(false, button::Status::Hovered | button::Status::Pressed) => Color {
|
|
|
|
|
r: 0.26,
|
|
|
|
|
g: 0.26,
|
|
|
|
|
b: 0.26,
|
|
|
|
|
a: 1.0,
|
|
|
|
|
},
|
2026-04-08 22:56:51 +03:00
|
|
|
_ => Color::TRANSPARENT,
|
|
|
|
|
})),
|
|
|
|
|
text_color: TEXT,
|
|
|
|
|
..Default::default()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn field_style(_: &Theme, _: text_input::Status) -> text_input::Style {
|
|
|
|
|
text_input::Style {
|
|
|
|
|
background: Background::Color(FIELD),
|
2026-05-12 10:36:15 +03:00
|
|
|
border: Border {
|
|
|
|
|
color: BORDER,
|
|
|
|
|
width: 1.0,
|
|
|
|
|
radius: 3.0.into(),
|
|
|
|
|
},
|
|
|
|
|
icon: TEXT,
|
|
|
|
|
placeholder: DIM,
|
|
|
|
|
value: TEXT,
|
|
|
|
|
selection: ACCENT,
|
2026-04-08 22:56:51 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn vsep<'a>() -> Element<'a, Message> {
|
|
|
|
|
container(Space::new().width(1).height(Fill))
|
2026-05-12 10:36:15 +03:00
|
|
|
.width(1)
|
|
|
|
|
.height(Fill)
|
2026-04-08 22:56:51 +03:00
|
|
|
.style(|_: &Theme| container::Style {
|
|
|
|
|
background: Some(Background::Color(BORDER)),
|
|
|
|
|
..Default::default()
|
|
|
|
|
})
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-03 17:43:12 +03:00
|
|
|
pub fn view_window<'a>(v: TextStyleView<'a>) -> Element<'a, Message> {
|
|
|
|
|
let TextStyleView {
|
|
|
|
|
styles,
|
|
|
|
|
selected,
|
|
|
|
|
font_buf,
|
|
|
|
|
width_buf,
|
|
|
|
|
oblique_buf,
|
|
|
|
|
height_buf,
|
|
|
|
|
bigfont_buf,
|
|
|
|
|
ttf_buf,
|
|
|
|
|
backward,
|
|
|
|
|
upside_down,
|
|
|
|
|
annotative,
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
rename_active,
|
|
|
|
|
rename_buf,
|
2026-06-03 17:43:12 +03:00
|
|
|
} = v;
|
2026-04-08 22:56:51 +03:00
|
|
|
// ── Middle: Font browser ──────────────────────────────────────────────
|
2026-05-12 10:36:15 +03:00
|
|
|
let font_items: Vec<Element<'_, Message>> = BUILTIN_FONTS
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|&f| {
|
|
|
|
|
let is_sel = font_buf == f;
|
|
|
|
|
button(text(f).size(10))
|
|
|
|
|
.on_press(Message::TextStyleFontPick(f.to_string()))
|
|
|
|
|
.style(list_item(is_sel))
|
|
|
|
|
.padding([3, 8])
|
|
|
|
|
.width(Fill)
|
|
|
|
|
.into()
|
|
|
|
|
})
|
|
|
|
|
.collect();
|
2026-04-08 22:56:51 +03:00
|
|
|
|
|
|
|
|
let font_panel = container(
|
|
|
|
|
column![
|
|
|
|
|
text("Font File").size(10).color(DIM),
|
|
|
|
|
container(scrollable(column(font_items).spacing(1)).height(Fill))
|
|
|
|
|
.style(|_: &Theme| container::Style {
|
|
|
|
|
background: Some(Background::Color(LIST)),
|
2026-05-12 10:36:15 +03:00
|
|
|
border: Border {
|
|
|
|
|
color: BORDER,
|
|
|
|
|
width: 1.0,
|
|
|
|
|
radius: 3.0.into()
|
|
|
|
|
},
|
2026-04-08 22:56:51 +03:00
|
|
|
..Default::default()
|
|
|
|
|
})
|
|
|
|
|
.width(Fill)
|
|
|
|
|
.height(Fill)
|
|
|
|
|
.padding(2),
|
|
|
|
|
text_input("font file…", font_buf)
|
2026-05-12 10:36:15 +03:00
|
|
|
.on_input(|v| Message::TextStyleEdit {
|
|
|
|
|
field: "font",
|
|
|
|
|
value: v
|
|
|
|
|
})
|
2026-04-08 22:56:51 +03:00
|
|
|
.style(field_style)
|
|
|
|
|
.size(11)
|
|
|
|
|
.width(Fill),
|
|
|
|
|
]
|
|
|
|
|
.spacing(6)
|
2026-05-12 10:36:15 +03:00
|
|
|
.height(Fill),
|
2026-04-08 22:56:51 +03:00
|
|
|
)
|
|
|
|
|
.width(190)
|
|
|
|
|
.height(Fill)
|
|
|
|
|
.padding([12, 8]);
|
|
|
|
|
|
2026-06-03 17:43:12 +03:00
|
|
|
// Labeled numeric/text field row → TextStyleEdit { field, value }.
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
fn frow<'a>(
|
|
|
|
|
label: &'a str,
|
|
|
|
|
ph: &'a str,
|
|
|
|
|
buf: &'a str,
|
|
|
|
|
field: &'static str,
|
|
|
|
|
) -> Element<'a, Message> {
|
2026-06-03 17:43:12 +03:00
|
|
|
row![
|
|
|
|
|
text(label).size(11).color(DIM).width(120),
|
|
|
|
|
text_input(ph, buf)
|
|
|
|
|
.on_input(move |v| Message::TextStyleEdit { field, value: v })
|
|
|
|
|
.style(field_style)
|
|
|
|
|
.size(11)
|
|
|
|
|
.width(140),
|
|
|
|
|
]
|
|
|
|
|
.spacing(6)
|
|
|
|
|
.align_y(iced::Center)
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 22:56:51 +03:00
|
|
|
// ── Right: Properties ─────────────────────────────────────────────────
|
|
|
|
|
let props_panel = container(
|
|
|
|
|
column![
|
|
|
|
|
text("Properties").size(11).color(ACCENT),
|
2026-06-03 17:43:12 +03:00
|
|
|
frow("Big Font:", "big-font file…", bigfont_buf, "bigfont"),
|
|
|
|
|
frow("TrueType Font:", "e.g. Arial", ttf_buf, "ttf"),
|
|
|
|
|
frow("Fixed Height:", "0 = variable", height_buf, "height"),
|
|
|
|
|
frow("Width Factor:", "1.0", width_buf, "width"),
|
|
|
|
|
frow("Oblique (°):", "0.0", oblique_buf, "oblique"),
|
2026-04-08 22:56:51 +03:00
|
|
|
row![
|
2026-06-03 17:43:12 +03:00
|
|
|
checkbox(backward)
|
|
|
|
|
.label("Backward")
|
|
|
|
|
.on_toggle(|_| Message::TextStyleToggle("backward"))
|
|
|
|
|
.size(15)
|
|
|
|
|
.text_size(11),
|
|
|
|
|
checkbox(upside_down)
|
|
|
|
|
.label("Upside down")
|
|
|
|
|
.on_toggle(|_| Message::TextStyleToggle("upside_down"))
|
|
|
|
|
.size(15)
|
|
|
|
|
.text_size(11),
|
2026-05-12 10:36:15 +03:00
|
|
|
]
|
2026-06-03 17:43:12 +03:00
|
|
|
.spacing(16),
|
|
|
|
|
checkbox(annotative)
|
|
|
|
|
.label("Annotative")
|
|
|
|
|
.on_toggle(|_| Message::TextStyleToggle("annotative"))
|
|
|
|
|
.size(15)
|
|
|
|
|
.text_size(11),
|
2026-04-08 22:56:51 +03:00
|
|
|
Space::new().height(8),
|
|
|
|
|
text("Preview").size(10).color(DIM),
|
2026-05-12 10:36:15 +03:00
|
|
|
container(text("AaBbCc 0123").size(20))
|
|
|
|
|
.style(|_: &Theme| container::Style {
|
|
|
|
|
background: Some(Background::Color(FIELD)),
|
|
|
|
|
border: Border {
|
|
|
|
|
color: BORDER,
|
|
|
|
|
width: 1.0,
|
|
|
|
|
radius: 4.0.into()
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
|
})
|
|
|
|
|
.padding(12)
|
|
|
|
|
.width(Fill),
|
2026-04-08 22:56:51 +03:00
|
|
|
]
|
|
|
|
|
.spacing(10)
|
2026-05-12 10:36:15 +03:00
|
|
|
.height(Fill),
|
2026-04-08 22:56:51 +03:00
|
|
|
)
|
|
|
|
|
.width(Fill)
|
|
|
|
|
.height(Fill)
|
2026-05-12 10:36:15 +03:00
|
|
|
.padding(iced::Padding {
|
|
|
|
|
top: 12.0,
|
|
|
|
|
right: 12.0,
|
|
|
|
|
bottom: 12.0,
|
|
|
|
|
left: 8.0,
|
|
|
|
|
});
|
2026-04-08 22:56:51 +03:00
|
|
|
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
let editor = row![font_panel, vsep(), props_panel].height(Fill);
|
2026-04-08 22:56:51 +03:00
|
|
|
|
feat(styles): unify the five style managers behind a shared frame
The text/dimension/table/multileader/multiline managers were hand-copied,
so their list CRUD kept drifting and breaking: Dimension's New created
nothing (#73), new text styles never reached the ribbon dropdown (#74),
and several were added with a NULL handle (dropped on DWG save, #67).
Collapse the duplicated parts into three shared pieces and leave only the
per-manager property editor bespoke:
- app/style_ops.rs: one StyleKind-dispatched CRUD layer (new / copy /
delete / rename) handling handle allocation, ribbon sync, Table re-key
and name-reference rewrites in a single place.
- ui/style_manager.rs: the window scaffold — uniform toolbar (New / Copy /
Delete on the left, Set Current + Apply on the right), style list and
chrome. Each manager now only builds its editor.
- ui/style_list.rs: the list row — single click selects, double click
starts an inline rename.
New capabilities, now consistent across all five:
- Copy duplicates the selected style.
- Double-click a name to rename it inline.
- Right side is always Set Current + Apply (added Table set-current;
MLine apply is a documented placeholder until its editor is editable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:34 +03:00
|
|
|
crate::ui::style_manager::view(crate::ui::style_manager::Scaffold {
|
|
|
|
|
kind: StyleKind::Text,
|
|
|
|
|
styles: &styles,
|
|
|
|
|
selected,
|
|
|
|
|
current: None,
|
|
|
|
|
rename_active,
|
|
|
|
|
rename_buf,
|
|
|
|
|
on_new: Message::TextStyleDialogNew,
|
|
|
|
|
on_copy: Message::TextStyleDialogCopy,
|
|
|
|
|
on_delete: Message::TextStyleDialogDelete,
|
|
|
|
|
on_select: Message::TextStyleDialogSelect,
|
|
|
|
|
on_set_current: Message::TextStyleDialogSetCurrent,
|
|
|
|
|
on_apply: Message::TextStyleApply,
|
|
|
|
|
editor: editor.into(),
|
|
|
|
|
})
|
2026-04-08 22:56:51 +03:00
|
|
|
}
|