forked from 1b-agent/opencadstudio-upstream
feat(locale): localize full interface
This commit is contained in:
1 parent
b90b3e3ecf
commit
3e6693b93f
205 files changed
+32369
-3810
No files matched your search
@@ -10,6 +10,7 @@ use crate::app::Message;
|
||||
use crate::ui::style::style_manager::{hdivider, muted_text_style, tb_button};
|
||||
use iced::widget::{column, container, mouse_area, row, scrollable, text, Space};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
|
||||
/// `scales` is `(name, "paper:drawing" ratio, is_member)`. Every label is cloned
|
||||
/// into the widget tree, so the returned element borrows nothing from the args.
|
||||
@@ -20,9 +21,9 @@ pub fn view_window(
|
||||
) -> Element<'static, Message> {
|
||||
let toolbar = container(
|
||||
row![
|
||||
text(format!("Object: {object_label}")).size(11),
|
||||
text(t!("Object: %{object_label}", object_label = object_label)).size(11),
|
||||
Space::new().width(sizing.width),
|
||||
tb_button("Close", Message::CloseModal, true),
|
||||
tb_button(t!("Close"), Message::CloseModal, true),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
@@ -75,7 +76,7 @@ pub fn view_window(
|
||||
|
||||
let body = container(
|
||||
column![
|
||||
text("Click a scale to add or remove the object's representation for it.")
|
||||
text(t!("Click a scale to add or remove the object's representation for it."))
|
||||
.size(10)
|
||||
.style(muted_text_style),
|
||||
list,
|
||||
|
||||
+130
-111
@@ -5,6 +5,21 @@ use iced::widget::{
|
||||
button, checkbox, column, container, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
struct DimEnumChoice {
|
||||
code: String,
|
||||
label: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for DimEnumChoice {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(&self.label)
|
||||
}
|
||||
}
|
||||
|
||||
/// All DimStyle field values needed by the view.
|
||||
pub struct DimStyleValues<'a> {
|
||||
@@ -173,34 +188,34 @@ pub fn view_window<'a>(
|
||||
) -> Element<'a, Message> {
|
||||
// ── Tab bar ───────────────────────────────────────────────────────────
|
||||
let tabs = row![
|
||||
button(text("Lines").size(11))
|
||||
button(text(t!("Lines")).size(11))
|
||||
.on_press(Message::DimStyleDialogTab(0))
|
||||
.style(tab_btn_style(tab == 0))
|
||||
.padding([4, 10]),
|
||||
button(text("Arrows").size(11))
|
||||
button(text(t!("Arrows")).size(11))
|
||||
.on_press(Message::DimStyleDialogTab(1))
|
||||
.style(tab_btn_style(tab == 1))
|
||||
.padding([4, 10]),
|
||||
button(text("Text").size(11))
|
||||
button(text(t!("Text")).size(11))
|
||||
.on_press(Message::DimStyleDialogTab(2))
|
||||
.style(tab_btn_style(tab == 2))
|
||||
.padding([4, 10]),
|
||||
button(text("Scale/Units").size(11))
|
||||
button(text(t!("Scale/Units")).size(11))
|
||||
.on_press(Message::DimStyleDialogTab(3))
|
||||
.style(tab_btn_style(tab == 3))
|
||||
.padding([4, 10]),
|
||||
button(text("Tolerances").size(11))
|
||||
button(text(t!("Tolerances")).size(11))
|
||||
.on_press(Message::DimStyleDialogTab(4))
|
||||
.style(tab_btn_style(tab == 4))
|
||||
.padding([4, 10]),
|
||||
button(text("Alternate").size(11))
|
||||
button(text(t!("Alternate")).size(11))
|
||||
.on_press(Message::DimStyleDialogTab(5))
|
||||
.style(tab_btn_style(tab == 5))
|
||||
.padding([4, 10]),
|
||||
]
|
||||
.spacing(2);
|
||||
|
||||
let lbl = |s: &'static str| text(s).size(11).style(muted_style).width(180);
|
||||
let lbl = |s: Cow<'static, str>| text(s).size(11).style(muted_style).width(180);
|
||||
|
||||
let mk_field = |fld: DsField, val: &'a str| -> Element<'a, Message> {
|
||||
text_input("", val)
|
||||
@@ -211,7 +226,7 @@ pub fn view_window<'a>(
|
||||
.into()
|
||||
};
|
||||
|
||||
let chk = |label: &'static str, val: bool, fld: DsField| -> Element<'a, Message> {
|
||||
let chk = |label: Cow<'static, str>, val: bool, fld: DsField| -> Element<'a, Message> {
|
||||
checkbox(val)
|
||||
.label(label)
|
||||
.on_toggle(move |_| Message::DsToggle(fld.clone()))
|
||||
@@ -222,27 +237,31 @@ pub fn view_window<'a>(
|
||||
|
||||
// Enum dropdown: maps the stored integer code to a named option and back,
|
||||
// so the user picks "Above" rather than typing "1".
|
||||
let enum_field = move |label: &'static str,
|
||||
let enum_field = move |label: Cow<'static, str>,
|
||||
fld: DsField,
|
||||
val: &'a str,
|
||||
opts: &'static [(&'static str, &'static str)]|
|
||||
-> Element<'a, Message> {
|
||||
let labels: Vec<String> = opts.iter().map(|(_, l)| (*l).to_string()).collect();
|
||||
let cur = opts
|
||||
let options: Vec<DimEnumChoice> = opts
|
||||
.iter()
|
||||
.find(|(c, _)| *c == val.trim())
|
||||
.map(|(_, l)| (*l).to_string())
|
||||
.unwrap_or_else(|| val.to_string());
|
||||
.map(|(code, label)| DimEnumChoice {
|
||||
code: (*code).to_string(),
|
||||
label: crate::i18n::translate(label).into_owned(),
|
||||
})
|
||||
.collect();
|
||||
let cur = options
|
||||
.iter()
|
||||
.find(|choice| choice.code == val.trim())
|
||||
.cloned()
|
||||
.unwrap_or_else(|| DimEnumChoice {
|
||||
code: val.to_string(),
|
||||
label: val.to_string(),
|
||||
});
|
||||
row![
|
||||
lbl(label),
|
||||
iced::widget::pick_list(Some(cur), labels, |value| value.to_string())
|
||||
.on_select(move |chosen| {
|
||||
let code = opts
|
||||
.iter()
|
||||
.find(|(_, l)| *l == chosen.as_str())
|
||||
.map(|(c, _)| (*c).to_string())
|
||||
.unwrap_or(chosen);
|
||||
Message::DsEdit(fld.clone(), code)
|
||||
iced::widget::pick_list(Some(cur), options, |value| value.to_string())
|
||||
.on_select(move |chosen: DimEnumChoice| {
|
||||
Message::DsEdit(fld.clone(), chosen.code)
|
||||
})
|
||||
.text_size(11)
|
||||
.width(150),
|
||||
@@ -275,7 +294,7 @@ pub fn view_window<'a>(
|
||||
// Shared colour selector (main dropdown + "more" palette), reusing the
|
||||
// existing DsEdit path (the chosen colour is sent as an ACI string).
|
||||
let color_open = vals.color_open.clone();
|
||||
let color_row = move |label: &'static str, fld: DsField, _val: &'a str| -> Element<'a, Message> {
|
||||
let color_row = move |label: Cow<'static, str>, fld: DsField, _val: &'a str| -> Element<'a, Message> {
|
||||
let cur = crate::ui::color_select::aci_string_to_color(_val);
|
||||
let open = color_open.as_ref() == Some(&fld);
|
||||
let f_sel = fld.clone();
|
||||
@@ -301,7 +320,7 @@ pub fn view_window<'a>(
|
||||
|
||||
// Block / linetype Handle dropdown: pick a block-record (arrowheads) or a
|
||||
// linetype by name from the available records.
|
||||
let hrow = move |label: &'static str,
|
||||
let hrow = move |label: Cow<'static, str>,
|
||||
options: Vec<String>,
|
||||
selected: String,
|
||||
field: &'static str|
|
||||
@@ -320,81 +339,81 @@ pub fn view_window<'a>(
|
||||
|
||||
let tab_content: Element<'_, Message> = match tab {
|
||||
0 => column![
|
||||
text("Dimension Line").size(11).style(primary_style),
|
||||
text(t!("Dimension Line")).size(11).style(primary_style),
|
||||
row![
|
||||
lbl("Extension (DIMDLE)"),
|
||||
lbl(t!("Extension (DIMDLE)")),
|
||||
mk_field(DsField::Dimdle, vals.dimdle)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Spacing (DIMDLI)"),
|
||||
lbl(t!("Spacing (DIMDLI)")),
|
||||
mk_field(DsField::Dimdli, vals.dimdli)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Text gap (DIMGAP)"),
|
||||
lbl(t!("Text gap (DIMGAP)")),
|
||||
mk_field(DsField::Dimgap, vals.dimgap)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
chk("Suppress 1st line (DIMSD1)", vals.dimsd1, DsField::Dimsd1),
|
||||
chk("Suppress 2nd line (DIMSD2)", vals.dimsd2, DsField::Dimsd2),
|
||||
text("Extension Line").size(11).style(primary_style),
|
||||
chk(t!("Suppress 1st line (DIMSD1)"), vals.dimsd1, DsField::Dimsd1),
|
||||
chk(t!("Suppress 2nd line (DIMSD2)"), vals.dimsd2, DsField::Dimsd2),
|
||||
text(t!("Extension Line")).size(11).style(primary_style),
|
||||
row![
|
||||
lbl("Extension (DIMEXE)"),
|
||||
lbl(t!("Extension (DIMEXE)")),
|
||||
mk_field(DsField::Dimexe, vals.dimexe)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Offset (DIMEXO)"),
|
||||
lbl(t!("Offset (DIMEXO)")),
|
||||
mk_field(DsField::Dimexo, vals.dimexo)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
chk("Suppress 1st line (DIMSE1)", vals.dimse1, DsField::Dimse1),
|
||||
chk("Suppress 2nd line (DIMSE2)", vals.dimse2, DsField::Dimse2),
|
||||
color_row("Dim line color ACI (DIMCLRD)", DsField::Dimclrd, vals.dimclrd),
|
||||
chk(t!("Suppress 1st line (DIMSE1)"), vals.dimse1, DsField::Dimse1),
|
||||
chk(t!("Suppress 2nd line (DIMSE2)"), vals.dimse2, DsField::Dimse2),
|
||||
color_row(t!("Dim line color ACI (DIMCLRD)"), DsField::Dimclrd, vals.dimclrd),
|
||||
row![
|
||||
lbl("Dim line weight (DIMLWD)"),
|
||||
lbl(t!("Dim line weight (DIMLWD)")),
|
||||
mk_field(DsField::Dimlwd, vals.dimlwd)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
color_row("Ext line color ACI (DIMCLRE)", DsField::Dimclre, vals.dimclre),
|
||||
color_row(t!("Ext line color ACI (DIMCLRE)"), DsField::Dimclre, vals.dimclre),
|
||||
row![
|
||||
lbl("Ext line weight (DIMLWE)"),
|
||||
lbl(t!("Ext line weight (DIMLWE)")),
|
||||
mk_field(DsField::Dimlwe, vals.dimlwe)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
chk(
|
||||
"Fixed-length ext lines (DIMFXLON)",
|
||||
t!("Fixed-length ext lines (DIMFXLON)"),
|
||||
vals.dimfxlon,
|
||||
DsField::Dimfxlon
|
||||
),
|
||||
row![
|
||||
lbl("Fixed length (DIMFXL)"),
|
||||
lbl(t!("Fixed length (DIMFXL)")),
|
||||
mk_field(DsField::Dimfxl, vals.dimfxl)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
hrow(
|
||||
"Dim line linetype (DIMLTYPE)",
|
||||
t!("Dim line linetype (DIMLTYPE)"),
|
||||
vals.lt_opts.clone(),
|
||||
vals.dimltex_name.clone(),
|
||||
"dimltex_handle"
|
||||
),
|
||||
hrow(
|
||||
"Ext line 1 linetype (DIMLTEX1)",
|
||||
t!("Ext line 1 linetype (DIMLTEX1)"),
|
||||
vals.lt_opts.clone(),
|
||||
vals.dimltex1_name.clone(),
|
||||
"dimltex1_handle"
|
||||
),
|
||||
hrow(
|
||||
"Ext line 2 linetype (DIMLTEX2)",
|
||||
t!("Ext line 2 linetype (DIMLTEX2)"),
|
||||
vals.lt_opts.clone(),
|
||||
vals.dimltex2_name.clone(),
|
||||
"dimltex2_handle"
|
||||
@@ -403,62 +422,62 @@ pub fn view_window<'a>(
|
||||
.spacing(7)
|
||||
.into(),
|
||||
1 => column![
|
||||
text("Arrows").size(11).style(primary_style),
|
||||
text(t!("Arrows")).size(11).style(primary_style),
|
||||
hrow(
|
||||
"Arrowhead (DIMBLK)",
|
||||
t!("Arrowhead (DIMBLK)"),
|
||||
vals.block_opts.clone(),
|
||||
vals.dimblk_name.clone(),
|
||||
"dimblk"
|
||||
),
|
||||
hrow(
|
||||
"1st arrowhead (DIMBLK1)",
|
||||
t!("1st arrowhead (DIMBLK1)"),
|
||||
vals.block_opts.clone(),
|
||||
vals.dimblk1_name.clone(),
|
||||
"dimblk1"
|
||||
),
|
||||
hrow(
|
||||
"2nd arrowhead (DIMBLK2)",
|
||||
t!("2nd arrowhead (DIMBLK2)"),
|
||||
vals.block_opts.clone(),
|
||||
vals.dimblk2_name.clone(),
|
||||
"dimblk2"
|
||||
),
|
||||
hrow(
|
||||
"Leader arrowhead (DIMLDRBLK)",
|
||||
t!("Leader arrowhead (DIMLDRBLK)"),
|
||||
vals.block_opts.clone(),
|
||||
vals.dimldrblk_name.clone(),
|
||||
"dimldrblk"
|
||||
),
|
||||
row![
|
||||
lbl("Arrow size (DIMASZ)"),
|
||||
lbl(t!("Arrow size (DIMASZ)")),
|
||||
mk_field(DsField::Dimasz, vals.dimasz)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Center mark (DIMCEN)"),
|
||||
lbl(t!("Center mark (DIMCEN)")),
|
||||
mk_field(DsField::Dimcen, vals.dimcen)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Tick size (DIMTSZ)"),
|
||||
lbl(t!("Tick size (DIMTSZ)")),
|
||||
mk_field(DsField::Dimtsz, vals.dimtsz)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
chk(
|
||||
"Separate arrow blocks (DIMSAH)",
|
||||
t!("Separate arrow blocks (DIMSAH)"),
|
||||
vals.dimsah,
|
||||
DsField::Dimsah
|
||||
),
|
||||
enum_field(
|
||||
"Arc length symbol (DIMARCSYM)",
|
||||
t!("Arc length symbol (DIMARCSYM)"),
|
||||
DsField::Dimarcsym,
|
||||
vals.dimarcsym,
|
||||
&[("0", "Before text"), ("1", "Above text"), ("2", "None")],
|
||||
),
|
||||
row![
|
||||
lbl("Jog angle ° (DIMJOGANG)"),
|
||||
lbl(t!("Jog angle ° (DIMJOGANG)")),
|
||||
mk_field(DsField::Dimjogang, vals.dimjogang)
|
||||
]
|
||||
.spacing(8)
|
||||
@@ -467,21 +486,21 @@ pub fn view_window<'a>(
|
||||
.spacing(7)
|
||||
.into(),
|
||||
2 => column![
|
||||
text("Text").size(11).style(primary_style),
|
||||
text(t!("Text")).size(11).style(primary_style),
|
||||
row![
|
||||
lbl("Height (DIMTXT)"),
|
||||
lbl(t!("Height (DIMTXT)")),
|
||||
mk_field(DsField::Dimtxt, vals.dimtxt)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Style (DIMTXSTY)"),
|
||||
lbl(t!("Style (DIMTXSTY)")),
|
||||
mk_field(DsField::Dimtxsty, vals.dimtxsty)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field(
|
||||
"Vertical pos (DIMTAD)",
|
||||
t!("Vertical pos (DIMTAD)"),
|
||||
DsField::Dimtad,
|
||||
vals.dimtad,
|
||||
&[
|
||||
@@ -492,11 +511,11 @@ pub fn view_window<'a>(
|
||||
("4", "Below"),
|
||||
],
|
||||
),
|
||||
chk("Horizontal inside (DIMTIH)", vals.dimtih, DsField::Dimtih),
|
||||
chk("Horizontal outside (DIMTOH)", vals.dimtoh, DsField::Dimtoh),
|
||||
color_row("Text color ACI (DIMCLRT)", DsField::Dimclrt, vals.dimclrt),
|
||||
chk(t!("Horizontal inside (DIMTIH)"), vals.dimtih, DsField::Dimtih),
|
||||
chk(t!("Horizontal outside (DIMTOH)"), vals.dimtoh, DsField::Dimtoh),
|
||||
color_row(t!("Text color ACI (DIMCLRT)"), DsField::Dimclrt, vals.dimclrt),
|
||||
enum_field(
|
||||
"Horizontal just (DIMJUST)",
|
||||
t!("Horizontal just (DIMJUST)"),
|
||||
DsField::Dimjust,
|
||||
vals.dimjust,
|
||||
&[
|
||||
@@ -508,13 +527,13 @@ pub fn view_window<'a>(
|
||||
],
|
||||
),
|
||||
row![
|
||||
lbl("Vertical pos (DIMTVP)"),
|
||||
lbl(t!("Vertical pos (DIMTVP)")),
|
||||
mk_field(DsField::Dimtvp, vals.dimtvp)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field(
|
||||
"Text fill mode (DIMTFILL)",
|
||||
t!("Text fill mode (DIMTFILL)"),
|
||||
DsField::Dimtfill,
|
||||
vals.dimtfill,
|
||||
&[
|
||||
@@ -523,9 +542,9 @@ pub fn view_window<'a>(
|
||||
("2", "Color"),
|
||||
],
|
||||
),
|
||||
color_row("Fill color ACI (DIMTFILLCLR)", DsField::Dimtfillclr, vals.dimtfillclr),
|
||||
color_row(t!("Fill color ACI (DIMTFILLCLR)"), DsField::Dimtfillclr, vals.dimtfillclr),
|
||||
chk(
|
||||
"Left-to-right (DIMTXTDIRECTION)",
|
||||
t!("Left-to-right (DIMTXTDIRECTION)"),
|
||||
vals.dimtxtdirection,
|
||||
DsField::Dimtxtdirection
|
||||
),
|
||||
@@ -533,10 +552,10 @@ pub fn view_window<'a>(
|
||||
.spacing(7)
|
||||
.into(),
|
||||
3 => column![
|
||||
text("Scale").size(11).style(primary_style),
|
||||
chk("Annotative", vals.annotative, DsField::Annotative),
|
||||
text(t!("Scale")).size(11).style(primary_style),
|
||||
chk(t!("Annotative"), vals.annotative, DsField::Annotative),
|
||||
row![
|
||||
lbl("Overall scale (DIMSCALE)"),
|
||||
lbl(t!("Overall scale (DIMSCALE)")),
|
||||
if vals.annotative {
|
||||
text_input("", "0")
|
||||
.style(field_style)
|
||||
@@ -550,40 +569,40 @@ pub fn view_window<'a>(
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Linear factor (DIMLFAC)"),
|
||||
lbl(t!("Linear factor (DIMLFAC)")),
|
||||
mk_field(DsField::Dimlfac, vals.dimlfac)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
text("Units").size(11).style(primary_style),
|
||||
enum_field("Format (DIMLUNIT)", DsField::Dimlunit, vals.dimlunit, OPT_LUNIT),
|
||||
text(t!("Units")).size(11).style(primary_style),
|
||||
enum_field(t!("Format (DIMLUNIT)"), DsField::Dimlunit, vals.dimlunit, OPT_LUNIT),
|
||||
row![
|
||||
lbl("Decimals (DIMDEC)"),
|
||||
lbl(t!("Decimals (DIMDEC)")),
|
||||
mk_field(DsField::Dimdec, vals.dimdec)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Suffix (DIMPOST)"),
|
||||
lbl(t!("Suffix (DIMPOST)")),
|
||||
mk_field(DsField::Dimpost, vals.dimpost)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Decimal sep ASCII (DIMDSEP)"),
|
||||
lbl(t!("Decimal sep ASCII (DIMDSEP)")),
|
||||
mk_field(DsField::Dimdsep, vals.dimdsep)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Round off (DIMRND)"),
|
||||
lbl(t!("Round off (DIMRND)")),
|
||||
mk_field(DsField::Dimrnd, vals.dimrnd)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field("Zero suppress (DIMZIN)", DsField::Dimzin, vals.dimzin, OPT_ZIN),
|
||||
enum_field(t!("Zero suppress (DIMZIN)"), DsField::Dimzin, vals.dimzin, OPT_ZIN),
|
||||
enum_field(
|
||||
"Fraction format (DIMFRAC)",
|
||||
t!("Fraction format (DIMFRAC)"),
|
||||
DsField::Dimfrac,
|
||||
vals.dimfrac,
|
||||
&[
|
||||
@@ -593,7 +612,7 @@ pub fn view_window<'a>(
|
||||
],
|
||||
),
|
||||
enum_field(
|
||||
"Angular unit (DIMAUNIT)",
|
||||
t!("Angular unit (DIMAUNIT)"),
|
||||
DsField::Dimaunit,
|
||||
vals.dimaunit,
|
||||
&[
|
||||
@@ -604,19 +623,19 @@ pub fn view_window<'a>(
|
||||
],
|
||||
),
|
||||
row![
|
||||
lbl("Angular decimals (DIMADEC)"),
|
||||
lbl(t!("Angular decimals (DIMADEC)")),
|
||||
mk_field(DsField::Dimadec, vals.dimadec)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Unit format (DIMUNIT)"),
|
||||
lbl(t!("Unit format (DIMUNIT)")),
|
||||
mk_field(DsField::Dimunit, vals.dimunit)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field(
|
||||
"Angular zero supp (DIMAZIN)",
|
||||
t!("Angular zero supp (DIMAZIN)"),
|
||||
DsField::Dimazin,
|
||||
vals.dimazin,
|
||||
&[
|
||||
@@ -626,9 +645,9 @@ pub fn view_window<'a>(
|
||||
("3", "Leading & trailing"),
|
||||
],
|
||||
),
|
||||
text("Fit").size(11).style(primary_style),
|
||||
text(t!("Fit")).size(11).style(primary_style),
|
||||
enum_field(
|
||||
"Fit (DIMATFIT)",
|
||||
t!("Fit (DIMATFIT)"),
|
||||
DsField::Dimatfit,
|
||||
vals.dimatfit,
|
||||
&[
|
||||
@@ -639,7 +658,7 @@ pub fn view_window<'a>(
|
||||
],
|
||||
),
|
||||
enum_field(
|
||||
"Text movement (DIMTMOVE)",
|
||||
t!("Text movement (DIMTMOVE)"),
|
||||
DsField::Dimtmove,
|
||||
vals.dimtmove,
|
||||
&[
|
||||
@@ -649,20 +668,20 @@ pub fn view_window<'a>(
|
||||
],
|
||||
),
|
||||
row![
|
||||
lbl("Fit (legacy DIMFIT)"),
|
||||
lbl(t!("Fit (legacy DIMFIT)")),
|
||||
mk_field(DsField::Dimfit, vals.dimfit)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
chk("Force text inside (DIMTIX)", vals.dimtix, DsField::Dimtix),
|
||||
chk(t!("Force text inside (DIMTIX)"), vals.dimtix, DsField::Dimtix),
|
||||
chk(
|
||||
"Suppress outside arrows (DIMSOXD)",
|
||||
t!("Suppress outside arrows (DIMSOXD)"),
|
||||
vals.dimsoxd,
|
||||
DsField::Dimsoxd
|
||||
),
|
||||
chk("Place text manually (DIMUPT)", vals.dimupt, DsField::Dimupt),
|
||||
chk(t!("Place text manually (DIMUPT)"), vals.dimupt, DsField::Dimupt),
|
||||
chk(
|
||||
"Dim line between ext (DIMTOFL)",
|
||||
t!("Dim line between ext (DIMTOFL)"),
|
||||
vals.dimtofl,
|
||||
DsField::Dimtofl
|
||||
),
|
||||
@@ -670,46 +689,46 @@ pub fn view_window<'a>(
|
||||
.spacing(7)
|
||||
.into(),
|
||||
5 => column![
|
||||
text("Alternate Units").size(11).style(primary_style),
|
||||
text(t!("Alternate Units")).size(11).style(primary_style),
|
||||
chk(
|
||||
"Enable alternate units (DIMALT)",
|
||||
t!("Enable alternate units (DIMALT)"),
|
||||
vals.dimalt,
|
||||
DsField::Dimalt
|
||||
),
|
||||
row![
|
||||
lbl("Multiplier (DIMALTF)"),
|
||||
lbl(t!("Multiplier (DIMALTF)")),
|
||||
mk_field(DsField::Dimaltf, vals.dimaltf)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Decimals (DIMALTD)"),
|
||||
lbl(t!("Decimals (DIMALTD)")),
|
||||
mk_field(DsField::Dimaltd, vals.dimaltd)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field("Unit format (DIMALTU)", DsField::Dimaltu, vals.dimaltu, OPT_LUNIT),
|
||||
enum_field(t!("Unit format (DIMALTU)"), DsField::Dimaltu, vals.dimaltu, OPT_LUNIT),
|
||||
row![
|
||||
lbl("Tol decimals (DIMALTTD)"),
|
||||
lbl(t!("Tol decimals (DIMALTTD)")),
|
||||
mk_field(DsField::Dimalttd, vals.dimalttd)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Round off (DIMALTRND)"),
|
||||
lbl(t!("Round off (DIMALTRND)")),
|
||||
mk_field(DsField::Dimaltrnd, vals.dimaltrnd)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Suffix (DIMAPOST)"),
|
||||
lbl(t!("Suffix (DIMAPOST)")),
|
||||
mk_field(DsField::Dimapost, vals.dimapost)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field("Zero suppress (DIMALTZ)", DsField::Dimaltz, vals.dimaltz, OPT_ZIN),
|
||||
enum_field(t!("Zero suppress (DIMALTZ)"), DsField::Dimaltz, vals.dimaltz, OPT_ZIN),
|
||||
enum_field(
|
||||
"Tol zero supp (DIMALTTZ)",
|
||||
t!("Tol zero supp (DIMALTTZ)"),
|
||||
DsField::Dimalttz,
|
||||
vals.dimalttz,
|
||||
OPT_ZIN,
|
||||
@@ -718,40 +737,40 @@ pub fn view_window<'a>(
|
||||
.spacing(7)
|
||||
.into(),
|
||||
_ => column![
|
||||
text("Tolerances").size(11).style(primary_style),
|
||||
chk("Generate tolerances (DIMTOL)", vals.dimtol, DsField::Dimtol),
|
||||
chk("Limits generation (DIMLIM)", vals.dimlim, DsField::Dimlim),
|
||||
text(t!("Tolerances")).size(11).style(primary_style),
|
||||
chk(t!("Generate tolerances (DIMTOL)"), vals.dimtol, DsField::Dimtol),
|
||||
chk(t!("Limits generation (DIMLIM)"), vals.dimlim, DsField::Dimlim),
|
||||
row![
|
||||
lbl("Plus tolerance (DIMTP)"),
|
||||
lbl(t!("Plus tolerance (DIMTP)")),
|
||||
mk_field(DsField::Dimtp, vals.dimtp)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Minus tolerance (DIMTM)"),
|
||||
lbl(t!("Minus tolerance (DIMTM)")),
|
||||
mk_field(DsField::Dimtm, vals.dimtm)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Tol. decimals (DIMTDEC)"),
|
||||
lbl(t!("Tol. decimals (DIMTDEC)")),
|
||||
mk_field(DsField::Dimtdec, vals.dimtdec)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
lbl("Tol. scale (DIMTFAC)"),
|
||||
lbl(t!("Tol. scale (DIMTFAC)")),
|
||||
mk_field(DsField::Dimtfac, vals.dimtfac)
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
enum_field(
|
||||
"Tol. vert just (DIMTOLJ)",
|
||||
t!("Tol. vert just (DIMTOLJ)"),
|
||||
DsField::Dimtolj,
|
||||
vals.dimtolj,
|
||||
&[("0", "Bottom"), ("1", "Middle"), ("2", "Top")],
|
||||
),
|
||||
enum_field("Tol. zero supp (DIMTZIN)", DsField::Dimtzin, vals.dimtzin, OPT_ZIN),
|
||||
enum_field(t!("Tol. zero supp (DIMTZIN)"), DsField::Dimtzin, vals.dimtzin, OPT_ZIN),
|
||||
]
|
||||
.spacing(7)
|
||||
.into(),
|
||||
@@ -763,7 +782,7 @@ pub fn view_window<'a>(
|
||||
// content container instead of the panel padding.
|
||||
let right_panel = container(
|
||||
column![
|
||||
text(format!("Editing: {selected}")).size(11).style(muted_style),
|
||||
text(t!("Editing: %{selected}", selected = selected)).size(11).style(muted_style),
|
||||
tabs,
|
||||
hdivider(sizing.width),
|
||||
scrollable(container(tab_content).padding([12, 12]).width(sizing.width))
|
||||
|
||||
@@ -5,6 +5,18 @@ use iced::widget::{
|
||||
button, checkbox, column, container, row, scrollable, text, text_input,
|
||||
};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
struct EnumChoice(String);
|
||||
|
||||
impl fmt::Display for EnumChoice {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str(crate::i18n::translate(&self.0).as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
fn btn_s(accent: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme: &Theme, st| {
|
||||
@@ -83,12 +95,12 @@ pub struct MLeaderStyleView<'a> {
|
||||
pub color_open: Option<&'static str>,
|
||||
}
|
||||
|
||||
fn section<'a>(label: &'static str) -> Element<'a, Message> {
|
||||
fn section<'a>(label: Cow<'static, str>) -> Element<'a, Message> {
|
||||
text(label).size(11).style(primary_style).into()
|
||||
}
|
||||
|
||||
fn num_row<'a>(
|
||||
label: &'static str,
|
||||
label: Cow<'static, str>,
|
||||
placeholder: &'static str,
|
||||
value: &'a str,
|
||||
field: &'static str,
|
||||
@@ -105,7 +117,10 @@ fn num_row<'a>(
|
||||
.into()
|
||||
}
|
||||
|
||||
fn readonly_num_row<'a>(label: &'static str, value: &'a str) -> Element<'a, Message> {
|
||||
fn readonly_num_row<'a>(
|
||||
label: Cow<'static, str>,
|
||||
value: Cow<'static, str>,
|
||||
) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(150),
|
||||
text(value).size(11).style(muted_style),
|
||||
@@ -118,7 +133,7 @@ fn readonly_num_row<'a>(label: &'static str, value: &'a str) -> Element<'a, Mess
|
||||
/// Shared colour selector row. Reuses MLeaderStyleEdit by sending the chosen
|
||||
/// colour as an ACI string; `open` shows the expanded palette.
|
||||
fn color_row<'a>(
|
||||
label: &'static str,
|
||||
label: Cow<'static, str>,
|
||||
value: &'a str,
|
||||
field: &'static str,
|
||||
open: bool,
|
||||
@@ -148,15 +163,15 @@ fn color_row<'a>(
|
||||
}
|
||||
|
||||
fn enum_row<'a>(
|
||||
label: &'static str,
|
||||
options: Vec<String>,
|
||||
label: Cow<'static, str>,
|
||||
options: Vec<EnumChoice>,
|
||||
selected: String,
|
||||
field: &'static str,
|
||||
) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(150),
|
||||
iced::widget::pick_list(Some(selected), options, |value| value.to_string())
|
||||
.on_select(move |value| Message::MLeaderStyleSetEnum { field, value })
|
||||
iced::widget::pick_list(Some(EnumChoice(selected)), options, |value| value.to_string())
|
||||
.on_select(move |choice| Message::MLeaderStyleSetEnum { field, value: choice.0 })
|
||||
.text_size(11)
|
||||
.width(190),
|
||||
]
|
||||
@@ -168,7 +183,7 @@ fn enum_row<'a>(
|
||||
fn lineweight_row<'a>(selected: acadrust::types::LineWeight) -> Element<'a, Message> {
|
||||
let selected = crate::ui::properties::LwItem(selected);
|
||||
row![
|
||||
text("Line weight:").size(11).style(muted_style).width(150),
|
||||
text(t!("Line weight:")).size(11).style(muted_style).width(150),
|
||||
iced::widget::pick_list(
|
||||
Some(selected),
|
||||
crate::ui::properties::lw_options(),
|
||||
@@ -198,14 +213,14 @@ const ATTACH_OPTS: [&str; 11] = [
|
||||
"CenterOfTextOverline",
|
||||
];
|
||||
|
||||
fn opts(list: &[&str]) -> Vec<String> {
|
||||
list.iter().map(|s| s.to_string()).collect()
|
||||
fn opts(list: &[&str]) -> Vec<EnumChoice> {
|
||||
list.iter().map(|value| EnumChoice((*value).to_string())).collect()
|
||||
}
|
||||
|
||||
/// Dropdown for an Option<Handle> field (linetype / arrowhead / text style /
|
||||
/// block content). Options are record names; "None" clears the handle.
|
||||
fn handle_row<'a>(
|
||||
label: &'static str,
|
||||
label: Cow<'static, str>,
|
||||
options: Vec<String>,
|
||||
selected: String,
|
||||
field: &'static str,
|
||||
@@ -222,7 +237,7 @@ fn handle_row<'a>(
|
||||
.into()
|
||||
}
|
||||
|
||||
fn chk<'a>(label: &'static str, val: bool, field: &'static str) -> Element<'a, Message> {
|
||||
fn chk<'a>(label: Cow<'static, str>, val: bool, field: &'static str) -> Element<'a, Message> {
|
||||
checkbox(val)
|
||||
.label(label)
|
||||
.on_toggle(move |_| Message::MLeaderStyleToggle(field))
|
||||
@@ -240,174 +255,174 @@ pub fn view_window<'a>(
|
||||
scrollable(
|
||||
column![
|
||||
row![
|
||||
text("Name:").size(11).style(muted_style).width(150),
|
||||
text(t!("Name:")).size(11).style(muted_style).width(150),
|
||||
text(s.name.clone()).size(11),
|
||||
]
|
||||
.spacing(8),
|
||||
num_row("Description:", "", v.description, "description"),
|
||||
num_row(t!("Description:"), "", v.description, "description"),
|
||||
// Leader Format
|
||||
section("Leader Format"),
|
||||
section(t!("Leader Format")),
|
||||
enum_row(
|
||||
"Path type:",
|
||||
t!("Path type:"),
|
||||
opts(&["Invisible", "StraightLineSegments", "Spline"]),
|
||||
format!("{:?}", s.path_type),
|
||||
"path_type"
|
||||
),
|
||||
color_row("Line color (ACI):", v.line_color, "line_color", v.color_open == Some("line_color")),
|
||||
color_row(t!("Line color (ACI):"), v.line_color, "line_color", v.color_open == Some("line_color")),
|
||||
lineweight_row(s.line_weight),
|
||||
handle_row(
|
||||
"Line type:",
|
||||
t!("Line type:"),
|
||||
v.lt_opts.clone(),
|
||||
v.line_type_name.clone(),
|
||||
"line_type_handle"
|
||||
),
|
||||
handle_row(
|
||||
"Arrowhead block:",
|
||||
t!("Arrowhead block:"),
|
||||
v.block_opts.clone(),
|
||||
v.arrowhead_name.clone(),
|
||||
"arrowhead_handle"
|
||||
),
|
||||
num_row(
|
||||
"Arrowhead size:",
|
||||
t!("Arrowhead size:"),
|
||||
"0.18",
|
||||
v.arrowhead_size,
|
||||
"arrowhead_size"
|
||||
),
|
||||
num_row("Break gap size:", "0.125", v.break_gap, "break_gap"),
|
||||
num_row(t!("Break gap size:"), "0.125", v.break_gap, "break_gap"),
|
||||
// Leader Structure
|
||||
section("Leader Structure"),
|
||||
chk("Enable landing", s.enable_landing, "enable_landing"),
|
||||
chk("Enable dogleg", s.enable_dogleg, "enable_dogleg"),
|
||||
section(t!("Leader Structure")),
|
||||
chk(t!("Enable landing"), s.enable_landing, "enable_landing"),
|
||||
chk(t!("Enable dogleg"), s.enable_dogleg, "enable_dogleg"),
|
||||
num_row(
|
||||
"Landing distance:",
|
||||
t!("Landing distance:"),
|
||||
"8.0",
|
||||
v.landing_distance,
|
||||
"landing_distance"
|
||||
),
|
||||
num_row("Landing gap:", "0.09", v.landing_gap, "landing_gap"),
|
||||
num_row("Max leader points:", "2", v.max_points, "max_points"),
|
||||
num_row(t!("Landing gap:"), "0.09", v.landing_gap, "landing_gap"),
|
||||
num_row(t!("Max leader points:"), "2", v.max_points, "max_points"),
|
||||
num_row(
|
||||
"First seg. angle:",
|
||||
t!("First seg. angle:"),
|
||||
"0",
|
||||
v.first_seg_angle,
|
||||
"first_seg_angle"
|
||||
),
|
||||
num_row(
|
||||
"Second seg. angle:",
|
||||
t!("Second seg. angle:"),
|
||||
"0",
|
||||
v.second_seg_angle,
|
||||
"second_seg_angle"
|
||||
),
|
||||
if s.is_annotative {
|
||||
readonly_num_row("Scale factor:", "By annotation scale")
|
||||
readonly_num_row(t!("Scale factor:"), t!("By annotation scale"))
|
||||
} else {
|
||||
num_row("Scale factor:", "1.0", v.scale_factor, "scale_factor")
|
||||
num_row(t!("Scale factor:"), "1.0", v.scale_factor, "scale_factor")
|
||||
},
|
||||
num_row("Align space:", "4.0", v.align_space, "align_space"),
|
||||
num_row(t!("Align space:"), "4.0", v.align_space, "align_space"),
|
||||
enum_row(
|
||||
"Leader draw order:",
|
||||
t!("Leader draw order:"),
|
||||
opts(&["LeaderHeadFirst", "LeaderTailFirst"]),
|
||||
format!("{:?}", s.leader_draw_order),
|
||||
"leader_draw_order"
|
||||
),
|
||||
enum_row(
|
||||
"Multileader draw order:",
|
||||
t!("Multileader draw order:"),
|
||||
opts(&["ContentFirst", "LeaderFirst"]),
|
||||
format!("{:?}", s.multileader_draw_order),
|
||||
"multileader_draw_order"
|
||||
),
|
||||
chk("Annotative", s.is_annotative, "annotative"),
|
||||
chk(t!("Annotative"), s.is_annotative, "annotative"),
|
||||
// Content
|
||||
section("Content"),
|
||||
section(t!("Content")),
|
||||
enum_row(
|
||||
"Content type:",
|
||||
t!("Content type:"),
|
||||
opts(&["None", "Block", "MText", "Tolerance"]),
|
||||
format!("{:?}", s.content_type),
|
||||
"content_type"
|
||||
),
|
||||
num_row("Default text:", "", v.default_text, "default_text"),
|
||||
num_row(t!("Default text:"), "", v.default_text, "default_text"),
|
||||
handle_row(
|
||||
"Text style:",
|
||||
t!("Text style:"),
|
||||
v.textstyle_opts.clone(),
|
||||
v.text_style_name.clone(),
|
||||
"text_style_handle"
|
||||
),
|
||||
num_row("Text height:", "0.18", v.text_height, "text_height"),
|
||||
color_row("Text color (ACI):", v.text_color, "text_color", v.color_open == Some("text_color")),
|
||||
num_row(t!("Text height:"), "0.18", v.text_height, "text_height"),
|
||||
color_row(t!("Text color (ACI):"), v.text_color, "text_color", v.color_open == Some("text_color")),
|
||||
enum_row(
|
||||
"Text angle:",
|
||||
t!("Text angle:"),
|
||||
opts(&["ParallelToLastLeaderLine", "Horizontal", "Optimized"]),
|
||||
format!("{:?}", s.text_angle_type),
|
||||
"text_angle_type"
|
||||
),
|
||||
enum_row(
|
||||
"Text alignment:",
|
||||
t!("Text alignment:"),
|
||||
opts(&["Left", "Center", "Right"]),
|
||||
format!("{:?}", s.text_alignment),
|
||||
"text_alignment"
|
||||
),
|
||||
enum_row(
|
||||
"Left attachment:",
|
||||
t!("Left attachment:"),
|
||||
opts(&ATTACH_OPTS),
|
||||
format!("{:?}", s.text_left_attachment),
|
||||
"text_left_attachment"
|
||||
),
|
||||
enum_row(
|
||||
"Right attachment:",
|
||||
t!("Right attachment:"),
|
||||
opts(&ATTACH_OPTS),
|
||||
format!("{:?}", s.text_right_attachment),
|
||||
"text_right_attachment"
|
||||
),
|
||||
enum_row(
|
||||
"Top attachment:",
|
||||
t!("Top attachment:"),
|
||||
opts(&ATTACH_OPTS),
|
||||
format!("{:?}", s.text_top_attachment),
|
||||
"text_top_attachment"
|
||||
),
|
||||
enum_row(
|
||||
"Bottom attachment:",
|
||||
t!("Bottom attachment:"),
|
||||
opts(&ATTACH_OPTS),
|
||||
format!("{:?}", s.text_bottom_attachment),
|
||||
"text_bottom_attachment"
|
||||
),
|
||||
enum_row(
|
||||
"Attachment direction:",
|
||||
t!("Attachment direction:"),
|
||||
opts(&["Horizontal", "Vertical"]),
|
||||
format!("{:?}", s.text_attachment_direction),
|
||||
"text_attachment_direction"
|
||||
),
|
||||
chk("Text frame", s.text_frame, "text_frame"),
|
||||
chk("Text always left", s.text_always_left, "text_always_left"),
|
||||
chk(t!("Text frame"), s.text_frame, "text_frame"),
|
||||
chk(t!("Text always left"), s.text_always_left, "text_always_left"),
|
||||
// Block Content
|
||||
section("Block Content"),
|
||||
section(t!("Block Content")),
|
||||
handle_row(
|
||||
"Block:",
|
||||
t!("Block:"),
|
||||
v.block_opts.clone(),
|
||||
v.block_content_name.clone(),
|
||||
"block_content_handle"
|
||||
),
|
||||
color_row("Block color (ACI):", v.block_color, "block_color", v.color_open == Some("block_color")),
|
||||
color_row(t!("Block color (ACI):"), v.block_color, "block_color", v.color_open == Some("block_color")),
|
||||
enum_row(
|
||||
"Block connection:",
|
||||
t!("Block connection:"),
|
||||
opts(&["BlockExtents", "BasePoint"]),
|
||||
format!("{:?}", s.block_content_connection),
|
||||
"block_content_connection"
|
||||
),
|
||||
num_row("Block rotation:", "0", v.block_rotation, "block_rotation"),
|
||||
num_row("Block scale X:", "1.0", v.block_scale_x, "block_scale_x"),
|
||||
num_row("Block scale Y:", "1.0", v.block_scale_y, "block_scale_y"),
|
||||
num_row("Block scale Z:", "1.0", v.block_scale_z, "block_scale_z"),
|
||||
num_row(t!("Block rotation:"), "0", v.block_rotation, "block_rotation"),
|
||||
num_row(t!("Block scale X:"), "1.0", v.block_scale_x, "block_scale_x"),
|
||||
num_row(t!("Block scale Y:"), "1.0", v.block_scale_y, "block_scale_y"),
|
||||
num_row(t!("Block scale Z:"), "1.0", v.block_scale_z, "block_scale_z"),
|
||||
chk(
|
||||
"Enable block scale",
|
||||
t!("Enable block scale"),
|
||||
s.enable_block_scale,
|
||||
"enable_block_scale"
|
||||
),
|
||||
chk(
|
||||
"Enable block rotation",
|
||||
t!("Enable block rotation"),
|
||||
s.enable_block_rotation,
|
||||
"enable_block_rotation"
|
||||
),
|
||||
button(text("Apply").size(11))
|
||||
button(text(t!("Apply")).size(11))
|
||||
.on_press(Message::MLeaderStyleApply)
|
||||
.style(btn_s(true))
|
||||
.padding([4, 14]),
|
||||
@@ -419,7 +434,7 @@ pub fn view_window<'a>(
|
||||
.height(sizing.height)
|
||||
.into()
|
||||
} else {
|
||||
container(text("Select a style to view details.").size(11).style(muted_style))
|
||||
container(text(t!("Select a style to view details.")).size(11).style(muted_style))
|
||||
.padding([12, 12])
|
||||
.into()
|
||||
};
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
use crate::app::Message;
|
||||
use iced::widget::{column, container, row, scrollable, text};
|
||||
use iced::{Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
fn muted_style(theme: &Theme) -> iced::widget::text::Style {
|
||||
iced::widget::text::Style {
|
||||
@@ -20,7 +22,7 @@ pub fn view_window<'a>(
|
||||
sizing: crate::ui::modal::ModalSizing,
|
||||
) -> Element<'a, Message> {
|
||||
// ── Right: Details panel ──────────────────────────────────────────────
|
||||
let info_row = |label: &'static str, val: String| -> Element<'_, Message> {
|
||||
let info_row = |label: Cow<'static, str>, val: String| -> Element<'_, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(120),
|
||||
text(val).size(11),
|
||||
@@ -61,9 +63,9 @@ pub fn view_window<'a>(
|
||||
.collect();
|
||||
|
||||
let mut col_items: Vec<Element<'_, Message>> = vec![
|
||||
info_row("Name:", s.name.clone()),
|
||||
info_row("Elements:", s.elements.len().to_string()),
|
||||
text(" Off Color Ltype")
|
||||
info_row(t!("Name:"), s.name.clone()),
|
||||
info_row(t!("Elements:"), s.elements.len().to_string()),
|
||||
text(t!(" Off Color Ltype"))
|
||||
.size(10)
|
||||
.style(muted_style)
|
||||
.into(),
|
||||
@@ -73,7 +75,7 @@ pub fn view_window<'a>(
|
||||
.height(sizing.height)
|
||||
.into()
|
||||
} else {
|
||||
container(text("Select a style to view details.").size(11).style(muted_style))
|
||||
container(text(t!("Select a style to view details.")).size(11).style(muted_style))
|
||||
.padding([12, 12])
|
||||
.into()
|
||||
};
|
||||
|
||||
+22
-20
@@ -3,6 +3,8 @@
|
||||
use crate::app::Message;
|
||||
use iced::widget::{button, column, container, row, scrollable, text, text_input, Space};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
fn btn_s(accent: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme: &Theme, st| {
|
||||
@@ -89,21 +91,21 @@ pub fn view_window<'a>(
|
||||
sizing: crate::ui::modal::ModalSizing,
|
||||
) -> Element<'a, Message> {
|
||||
let table_name = table
|
||||
.map(|t| t.name.as_str())
|
||||
.unwrap_or("(no table loaded)");
|
||||
.map(|t| t.name.clone())
|
||||
.unwrap_or_else(|| t!("(no table loaded)").into_owned());
|
||||
|
||||
// ── Toolbar ───────────────────────────────────────────────────────────
|
||||
let toolbar = container(
|
||||
row![
|
||||
button(text("Load CTB/STB").size(11))
|
||||
button(text(t!("Load CTB/STB")).size(11))
|
||||
.on_press(Message::PlotStyleLoad)
|
||||
.style(btn_s(false))
|
||||
.padding([4, 10]),
|
||||
button(text("Save As…").size(11))
|
||||
button(text(t!("Save As…")).size(11))
|
||||
.on_press(Message::PlotStylePanelSave)
|
||||
.style(btn_s(false))
|
||||
.padding([4, 10]),
|
||||
button(text("Clear Table").size(11))
|
||||
button(text(t!("Clear Table")).size(11))
|
||||
.on_press(Message::PlotStyleClear)
|
||||
.style(btn_s(false))
|
||||
.padding([4, 10]),
|
||||
@@ -149,7 +151,7 @@ pub fn view_window<'a>(
|
||||
let label = if has_override {
|
||||
format!("{aci:>3} {color_str:<9} {lw_str}")
|
||||
} else {
|
||||
format!("{aci:>3} (default)")
|
||||
format!("{aci:>3} {}", t!("(default)"))
|
||||
};
|
||||
button(text(label).size(10).font(iced::Font::MONOSPACE))
|
||||
.on_press(Message::PlotStylePanelSelectAci(aci))
|
||||
@@ -178,7 +180,7 @@ pub fn view_window<'a>(
|
||||
|
||||
let aci_list = container(
|
||||
column![
|
||||
text("ACI Color Index").size(10).style(muted_style),
|
||||
text(t!("ACI Color Index")).size(10).style(muted_style),
|
||||
container(scrollable(column(aci_items).spacing(1)).height(sizing.height))
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
@@ -212,11 +214,11 @@ pub fn view_window<'a>(
|
||||
let entry = table.and_then(|t| t.aci_entries.get(selected_aci as usize));
|
||||
let cur_color = entry
|
||||
.and_then(|e| e.color.map(|[r, g, b]| format!("#{r:02X}{g:02X}{b:02X}")))
|
||||
.unwrap_or_else(|| "(none)".into());
|
||||
.unwrap_or_else(|| t!("(none)").into());
|
||||
let cur_lw = entry
|
||||
.map(|e| {
|
||||
if e.lineweight == 255 {
|
||||
"object".into()
|
||||
t!("object").into()
|
||||
} else {
|
||||
crate::io::plot_style::LW_TABLE
|
||||
.get(e.lineweight as usize)
|
||||
@@ -229,41 +231,41 @@ pub fn view_window<'a>(
|
||||
.map(|e| format!("{}%", e.screening))
|
||||
.unwrap_or_else(|| "—".into());
|
||||
|
||||
let lbl = |s: &'static str| text(s).size(11).style(muted_style);
|
||||
let lbl = |s: Cow<'static, str>| text(s).size(11).style(muted_style);
|
||||
|
||||
let edit_panel = container(
|
||||
column![
|
||||
row![
|
||||
text("ACI:").size(11).style(muted_style).width(100),
|
||||
text(t!("ACI:")).size(11).style(muted_style).width(100),
|
||||
text(format!("{selected_aci}")).size(11),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
lbl("Color override (#RRGGBB):"),
|
||||
text_input("#RRGGBB or blank", color_buf)
|
||||
lbl(t!("Color override (#RRGGBB):")),
|
||||
text_input(t!("#RRGGBB or blank").as_ref(), color_buf)
|
||||
.on_input(Message::PlotStylePanelColorBuf)
|
||||
.style(field_style)
|
||||
.size(11)
|
||||
.padding([4, 8]),
|
||||
lbl("Lineweight index (0-24, 255=obj):"),
|
||||
lbl(t!("Lineweight index (0-24, 255=obj):")),
|
||||
text_input("255", lw_buf)
|
||||
.on_input(Message::PlotStylePanelLwBuf)
|
||||
.style(field_style)
|
||||
.size(11)
|
||||
.padding([4, 8]),
|
||||
lbl("Screening (0-100):"),
|
||||
lbl(t!("Screening (0-100):")),
|
||||
text_input("100", screen_buf)
|
||||
.on_input(Message::PlotStylePanelScreenBuf)
|
||||
.style(field_style)
|
||||
.size(11)
|
||||
.padding([4, 8]),
|
||||
Space::new().height(8),
|
||||
text("Current values:").size(10).style(muted_style),
|
||||
text(format!(" Color: {cur_color}")).size(10),
|
||||
text(format!(" Lineweight: {cur_lw}")).size(10),
|
||||
text(format!(" Screening: {cur_scr}")).size(10),
|
||||
text(t!("Current values:")).size(10).style(muted_style),
|
||||
text(t!(" Color: %{cur_color}", cur_color = cur_color)).size(10),
|
||||
text(t!(" Lineweight: %{cur_lw}", cur_lw = cur_lw)).size(10),
|
||||
text(t!(" Screening: %{cur_scr}", cur_scr = cur_scr)).size(10),
|
||||
Space::new().height(sizing.height),
|
||||
button(text("Apply to ACI").size(11))
|
||||
button(text(t!("Apply to ACI")).size(11))
|
||||
.on_press(Message::PlotStylePanelApply)
|
||||
.style(btn_s(true))
|
||||
.padding([5, 10]),
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
use crate::app::Message;
|
||||
use iced::widget::{button, canvas, column, container, radio, row, text, text_input, Space};
|
||||
use iced::{mouse, Background, Border, Element, Length, Point, Rectangle, Size, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
const CELL_PX: f32 = 44.0;
|
||||
|
||||
@@ -151,7 +153,7 @@ pub fn view_window<'a>(
|
||||
}
|
||||
|
||||
let size_row = row![
|
||||
text("Point Size:").size(13),
|
||||
text(t!("Point Size:")).size(13),
|
||||
Space::new().width(10),
|
||||
text_input("0", size_buf)
|
||||
.on_input(Message::PointStyleSizeInput)
|
||||
@@ -160,13 +162,13 @@ pub fn view_window<'a>(
|
||||
.size(13)
|
||||
.width(110),
|
||||
Space::new().width(6),
|
||||
text(if relative { "%" } else { "units" }).size(12).style(muted_style),
|
||||
text(if relative { Cow::Borrowed("%") } else { t!("units") }).size(12).style(muted_style),
|
||||
]
|
||||
.align_y(iced::Center);
|
||||
|
||||
let radios = column![
|
||||
radio(
|
||||
"Set Size Relative to Screen",
|
||||
t!("Set Size Relative to Screen"),
|
||||
true,
|
||||
Some(relative),
|
||||
Message::PointStyleSizeRelative,
|
||||
@@ -174,7 +176,7 @@ pub fn view_window<'a>(
|
||||
.size(15)
|
||||
.text_size(13),
|
||||
radio(
|
||||
"Set Size in Absolute Units",
|
||||
t!("Set Size in Absolute Units"),
|
||||
false,
|
||||
Some(relative),
|
||||
Message::PointStyleSizeRelative,
|
||||
@@ -184,14 +186,14 @@ pub fn view_window<'a>(
|
||||
]
|
||||
.spacing(6);
|
||||
|
||||
let ok = button(text("OK").size(13))
|
||||
let ok = button(text(t!("OK")).size(13))
|
||||
.padding([5, 22])
|
||||
.on_press(Message::PointStyleOk)
|
||||
.style(button::primary);
|
||||
|
||||
container(
|
||||
column![
|
||||
text("Point Style").size(18),
|
||||
text(t!("Point Style")).size(18),
|
||||
Space::new().height(6),
|
||||
grid,
|
||||
Space::new().height(12),
|
||||
|
||||
@@ -13,6 +13,8 @@ use iced::widget::{
|
||||
column, container, mouse_area, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// Inline-rename text-input id, so the rename-start handler can focus it.
|
||||
pub fn rename_input_id() -> iced::widget::Id {
|
||||
@@ -54,12 +56,12 @@ pub fn view_window<'a, 'b>(
|
||||
// ── Toolbar: New / Delete | Set Current / Apply ───────────────────────
|
||||
let toolbar = container(
|
||||
row![
|
||||
tb_button("New", Message::ScaleManagerNew, false),
|
||||
tb_button("Copy", Message::ScaleManagerCopy, false),
|
||||
tb_button("Delete", Message::ScaleManagerDelete, false),
|
||||
tb_button(t!("New"), Message::ScaleManagerNew, false),
|
||||
tb_button(t!("Copy"), Message::ScaleManagerCopy, false),
|
||||
tb_button(t!("Delete"), Message::ScaleManagerDelete, false),
|
||||
Space::new().width(sizing.width),
|
||||
tb_button("Set Current", Message::ScaleManagerSetCurrent, false),
|
||||
tb_button("Apply", Message::ScaleManagerApply, true),
|
||||
tb_button(t!("Set Current"), Message::ScaleManagerSetCurrent, false),
|
||||
tb_button(t!("Apply"), Message::ScaleManagerApply, true),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
@@ -119,7 +121,7 @@ pub fn view_window<'a, 'b>(
|
||||
|
||||
let list_panel = container(
|
||||
column![
|
||||
text("Scales").size(10).style(muted_text_style),
|
||||
text(t!("Scales")).size(10).style(muted_text_style),
|
||||
container(scrollable(column(rows).spacing(1)).height(sizing.height))
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
@@ -151,10 +153,10 @@ pub fn view_window<'a, 'b>(
|
||||
|
||||
// ── Right: editor (name + paper:drawing) ──────────────────────────────
|
||||
let field =
|
||||
|label: &'static str, ph: &'static str, value: &str, on: fn(String) -> Message| {
|
||||
|label: Cow<'static, str>, ph: Cow<'static, str>, value: &str, on: fn(String) -> Message| {
|
||||
row![
|
||||
text(label).size(11).style(muted_text_style).width(96),
|
||||
text_input(ph, value)
|
||||
text_input(ph.as_ref(), value)
|
||||
.on_input(on)
|
||||
.style(field_style)
|
||||
.size(12)
|
||||
@@ -167,11 +169,11 @@ pub fn view_window<'a, 'b>(
|
||||
|
||||
let editor = container(
|
||||
column![
|
||||
text("Scale").size(10).style(muted_text_style),
|
||||
field("Paper units", "1", paper_buf, Message::ScaleManagerPaperBuf),
|
||||
field("Drawing units", "50", drawing_buf, Message::ScaleManagerDrawingBuf),
|
||||
text(Cow::Borrowed("Scale")).size(10).style(muted_text_style),
|
||||
field(t!("Paper units"), Cow::Borrowed("1"), paper_buf, Message::ScaleManagerPaperBuf),
|
||||
field(t!("Drawing units"), Cow::Borrowed("50"), drawing_buf, Message::ScaleManagerDrawingBuf),
|
||||
Space::new().height(6),
|
||||
text("Double-click a scale to rename it; edit its paper : drawing ratio here. New / Copy add a scale. Changes are kept only if you click Apply before closing.")
|
||||
text(t!("Double-click a scale to rename it; edit its paper : drawing ratio here. New / Copy add a scale. Changes are kept only if you click Apply before closing."))
|
||||
.size(10)
|
||||
.style(muted_text_style),
|
||||
]
|
||||
|
||||
@@ -11,6 +11,8 @@ use crate::app::{Message, StyleKind};
|
||||
use iced::widget::button::{Status, Style};
|
||||
use iced::widget::{button, column, container, row, scrollable, text, Space};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// Everything the shared frame needs. The per-manager `editor` element is the
|
||||
/// only bespoke part.
|
||||
@@ -51,12 +53,12 @@ pub fn view<'a, 'b>(s: Scaffold<'a, 'b>) -> Element<'a, Message> {
|
||||
let height = s.sizing.height;
|
||||
// ── Toolbar: New / Copy / Delete | … | Set Current / Apply ────────────
|
||||
let bar = row![
|
||||
tb_button("New", s.on_new, false),
|
||||
tb_button("Copy", s.on_copy, false),
|
||||
tb_button("Delete", s.on_delete, false),
|
||||
tb_button(t!("New"), s.on_new, false),
|
||||
tb_button(t!("Copy"), s.on_copy, false),
|
||||
tb_button(t!("Delete"), s.on_delete, false),
|
||||
Space::new().width(width),
|
||||
tb_button("Set Current", s.on_set_current, false),
|
||||
tb_button("Apply", s.on_apply, true),
|
||||
tb_button(t!("Set Current"), s.on_set_current, false),
|
||||
tb_button(t!("Apply"), s.on_apply, true),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center);
|
||||
@@ -91,7 +93,7 @@ pub fn view<'a, 'b>(s: Scaffold<'a, 'b>) -> Element<'a, Message> {
|
||||
|
||||
let list_panel = container(
|
||||
column![
|
||||
text("Styles").size(10).style(muted_text_style),
|
||||
text(t!("Styles")).size(10).style(muted_text_style),
|
||||
container(scrollable(column(rows).spacing(1)).height(height))
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
@@ -137,9 +139,13 @@ pub fn view<'a, 'b>(s: Scaffold<'a, 'b>) -> Element<'a, Message> {
|
||||
|
||||
// ── Shared chrome ──────────────────────────────────────────────────────────
|
||||
|
||||
pub(crate) fn tb_button<'a>(label: &'a str, msg: Message, accent: bool) -> Element<'a, Message> {
|
||||
pub(crate) fn tb_button(
|
||||
label: impl Into<Cow<'static, str>>,
|
||||
msg: Message,
|
||||
accent: bool,
|
||||
) -> Element<'static, Message> {
|
||||
let pad = if accent { [4, 14] } else { [4, 10] };
|
||||
button(text(label).size(11))
|
||||
button(text(label.into()).size(11))
|
||||
.on_press(msg)
|
||||
.style(btn_s(accent))
|
||||
.padding(pad)
|
||||
|
||||
+60
-50
@@ -5,6 +5,22 @@ use iced::widget::{
|
||||
button, checkbox, column, container, row, scrollable, text, text_input, Column,
|
||||
};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
struct EnumChoice(String);
|
||||
|
||||
impl fmt::Display for EnumChoice {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str(crate::i18n::translate(&self.0).as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
fn enum_choices(values: &[&str]) -> Vec<EnumChoice> {
|
||||
values.iter().map(|value| EnumChoice((*value).to_string())).collect()
|
||||
}
|
||||
|
||||
fn btn_s(accent: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme: &Theme, st| {
|
||||
@@ -66,7 +82,7 @@ pub fn view_window<'a>(
|
||||
sizing: crate::ui::modal::ModalSizing,
|
||||
) -> Element<'a, Message> {
|
||||
// ── Right: Details panel ──────────────────────────────────────────────
|
||||
let info_row = |label: &'static str, val: String| -> Element<'_, Message> {
|
||||
let info_row = |label: Cow<'static, str>, val: String| -> Element<'_, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(160),
|
||||
text(val).size(11),
|
||||
@@ -76,12 +92,12 @@ pub fn view_window<'a>(
|
||||
.into()
|
||||
};
|
||||
|
||||
let cell_editor = |row_label: &'static str,
|
||||
let cell_editor = |row_label: Cow<'static, str>,
|
||||
row: u8,
|
||||
rs: &acadrust::objects::RowCellStyle|
|
||||
-> Element<'a, Message> {
|
||||
let r = row as usize;
|
||||
let cell_in = |label: &'static str,
|
||||
let cell_in = |label: Cow<'static, str>,
|
||||
placeholder: &'static str,
|
||||
value: &'a str,
|
||||
field: &'static str|
|
||||
@@ -103,7 +119,7 @@ pub fn view_window<'a>(
|
||||
};
|
||||
// Shared colour selector — sends the chosen colour through the same
|
||||
// cell edit as an ACI string.
|
||||
let cell_color = |label: &'static str, value: &'a str, field: &'static str| -> Element<'a, Message> {
|
||||
let cell_color = |label: Cow<'static, str>, value: &'a str, field: &'static str| -> Element<'a, Message> {
|
||||
let cur = crate::ui::color_select::aci_string_to_color(value);
|
||||
let open = color_open == Some((row, field));
|
||||
let selector = crate::ui::color_select::color_selector(
|
||||
@@ -133,20 +149,20 @@ pub fn view_window<'a>(
|
||||
.spacing(3)
|
||||
.push(text(row_label).size(11).style(primary_style))
|
||||
.push(cell_in(
|
||||
" Text style:",
|
||||
t!(" Text style:"),
|
||||
"Standard",
|
||||
&cell_textstyle[r],
|
||||
"textstyle",
|
||||
))
|
||||
.push(cell_in(" Text height:", "0.18", &cell_height[r], "height"))
|
||||
.push(cell_color(" Text color:", &cell_textcolor[r], "textcolor"))
|
||||
.push(cell_color(" Fill color:", &cell_fillcolor[r], "fillcolor"))
|
||||
.push(cell_in(t!(" Text height:"), "0.18", &cell_height[r], "height"))
|
||||
.push(cell_color(t!(" Text color:"), &cell_textcolor[r], "textcolor"))
|
||||
.push(cell_color(t!(" Fill color:"), &cell_fillcolor[r], "fillcolor"))
|
||||
.push(
|
||||
row![
|
||||
text(" Alignment:").size(11).style(muted_style).width(150),
|
||||
text(t!(" Alignment:")).size(11).style(muted_style).width(150),
|
||||
iced::widget::pick_list(
|
||||
Some(format!("{:?}", rs.alignment)),
|
||||
[
|
||||
Some(EnumChoice(format!("{:?}", rs.alignment))),
|
||||
enum_choices(&[
|
||||
"TopLeft",
|
||||
"TopCenter",
|
||||
"TopRight",
|
||||
@@ -156,13 +172,13 @@ pub fn view_window<'a>(
|
||||
"BottomLeft",
|
||||
"BottomCenter",
|
||||
"BottomRight",
|
||||
]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
]),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |value| Message::TableStyleCellSetAlign { row, value })
|
||||
.on_select(move |choice| Message::TableStyleCellSetAlign {
|
||||
row,
|
||||
value: choice.0,
|
||||
})
|
||||
.text_size(11)
|
||||
.width(140),
|
||||
]
|
||||
@@ -171,16 +187,16 @@ pub fn view_window<'a>(
|
||||
)
|
||||
.push(
|
||||
checkbox(rs.fill_enabled)
|
||||
.label(" Background fill enabled")
|
||||
.label(t!(" Background fill enabled"))
|
||||
.on_toggle(move |_| Message::TableStyleCellToggleFill(row))
|
||||
.size(14)
|
||||
.text_size(11),
|
||||
)
|
||||
.push(cell_in(" Data type:", "0", &cell_datatype[r], "datatype"))
|
||||
.push(cell_in(" Unit type:", "0", &cell_unittype[r], "unittype"))
|
||||
.push(cell_in(" Format string:", "", &cell_format[r], "format"))
|
||||
.push(cell_in(t!(" Data type:"), "0", &cell_datatype[r], "datatype"))
|
||||
.push(cell_in(t!(" Unit type:"), "0", &cell_unittype[r], "unittype"))
|
||||
.push(cell_in(t!(" Format string:"), "", &cell_format[r], "format"))
|
||||
.push(
|
||||
text(" Borders (type / weight / color / spacing / hidden)")
|
||||
text(t!(" Borders (type / weight / color / spacing / hidden)"))
|
||||
.size(10)
|
||||
.style(muted_style),
|
||||
);
|
||||
@@ -199,21 +215,18 @@ pub fn view_window<'a>(
|
||||
row![
|
||||
text(format!(" {bname}")).size(11).style(muted_style).width(28),
|
||||
iced::widget::pick_list(
|
||||
Some(format!("{:?}", bd.border_type)),
|
||||
["Single", "Double"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
Some(EnumChoice(format!("{:?}", bd.border_type))),
|
||||
enum_choices(&["Single", "Double"]),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |value| Message::TableStyleBorderSetType {
|
||||
.on_select(move |choice| Message::TableStyleBorderSetType {
|
||||
cell: row,
|
||||
border: bu,
|
||||
value
|
||||
value: choice.0,
|
||||
})
|
||||
.text_size(10)
|
||||
.width(74),
|
||||
text_input("wt", &border_lw[r][b])
|
||||
text_input("", &border_lw[r][b])
|
||||
.on_input(move |v| Message::TableStyleBorderEdit {
|
||||
cell: row,
|
||||
border: bu,
|
||||
@@ -222,7 +235,7 @@ pub fn view_window<'a>(
|
||||
})
|
||||
.size(10)
|
||||
.width(46),
|
||||
text_input("clr", &border_color[r][b])
|
||||
text_input("", &border_color[r][b])
|
||||
.on_input(move |v| Message::TableStyleBorderEdit {
|
||||
cell: row,
|
||||
border: bu,
|
||||
@@ -231,7 +244,7 @@ pub fn view_window<'a>(
|
||||
})
|
||||
.size(10)
|
||||
.width(46),
|
||||
text_input("gap", &border_spacing[r][b])
|
||||
text_input("", &border_spacing[r][b])
|
||||
.on_input(move |v| Message::TableStyleBorderEdit {
|
||||
cell: row,
|
||||
border: bu,
|
||||
@@ -253,7 +266,7 @@ pub fn view_window<'a>(
|
||||
}
|
||||
|
||||
col.push(
|
||||
button(text("Apply cell").size(11))
|
||||
button(text(t!("Apply cell")).size(11))
|
||||
.on_press(Message::TableStyleCellApply(row))
|
||||
.style(btn_s(true))
|
||||
.padding([4, 12]),
|
||||
@@ -264,9 +277,9 @@ pub fn view_window<'a>(
|
||||
let details: Element<'_, Message> = if let Some(s) = selected_style {
|
||||
scrollable(
|
||||
column![
|
||||
info_row("Name:", s.name.clone()),
|
||||
info_row(t!("Name:"), s.name.clone()),
|
||||
row![
|
||||
text("Description:").size(11).style(muted_style).width(160),
|
||||
text(t!("Description:")).size(11).style(muted_style).width(160),
|
||||
text_input("", description_buf)
|
||||
.on_input(|v| Message::TableStyleEdit {
|
||||
field: "description",
|
||||
@@ -278,23 +291,20 @@ pub fn view_window<'a>(
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
text("Flow direction:").size(11).style(muted_style).width(160),
|
||||
text(t!("Flow direction:")).size(11).style(muted_style).width(160),
|
||||
iced::widget::pick_list(
|
||||
Some(format!("{:?}", s.flow_direction)),
|
||||
["Down", "Up"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
Some(EnumChoice(format!("{:?}", s.flow_direction))),
|
||||
enum_choices(&["Down", "Up"]),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(Message::TableStyleSetFlow)
|
||||
.on_select(|choice| Message::TableStyleSetFlow(choice.0))
|
||||
.text_size(11)
|
||||
.width(100),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
text("H Margin:").size(11).style(muted_style).width(160),
|
||||
text(t!("H Margin:")).size(11).style(muted_style).width(160),
|
||||
text_input("1.5", hmargin_buf)
|
||||
.on_input(|v| Message::TableStyleEdit {
|
||||
field: "hmargin",
|
||||
@@ -306,7 +316,7 @@ pub fn view_window<'a>(
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
text("V Margin:").size(11).style(muted_style).width(160),
|
||||
text(t!("V Margin:")).size(11).style(muted_style).width(160),
|
||||
text_input("1.5", vmargin_buf)
|
||||
.on_input(|v| Message::TableStyleEdit {
|
||||
field: "vmargin",
|
||||
@@ -318,22 +328,22 @@ pub fn view_window<'a>(
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
checkbox(s.title_suppressed)
|
||||
.label("Title row suppressed")
|
||||
.label(t!("Title row suppressed"))
|
||||
.on_toggle(|_| Message::TableStyleToggle("title_sup"))
|
||||
.size(14)
|
||||
.text_size(11),
|
||||
checkbox(s.header_suppressed)
|
||||
.label("Header row suppressed")
|
||||
.label(t!("Header row suppressed"))
|
||||
.on_toggle(|_| Message::TableStyleToggle("header_sup"))
|
||||
.size(14)
|
||||
.text_size(11),
|
||||
button(text("Apply margins").size(11))
|
||||
button(text(t!("Apply margins")).size(11))
|
||||
.on_press(Message::TableStyleApply)
|
||||
.style(btn_s(true))
|
||||
.padding([4, 12]),
|
||||
cell_editor("Data Row:", 0, &s.data_row_style),
|
||||
cell_editor("Header Row:", 1, &s.header_row_style),
|
||||
cell_editor("Title Row:", 2, &s.title_row_style),
|
||||
cell_editor(t!("Data Row:"), 0, &s.data_row_style),
|
||||
cell_editor(t!("Header Row:"), 1, &s.header_row_style),
|
||||
cell_editor(t!("Title Row:"), 2, &s.title_row_style),
|
||||
]
|
||||
.spacing(6)
|
||||
.padding([12, 12]),
|
||||
@@ -342,7 +352,7 @@ pub fn view_window<'a>(
|
||||
.height(sizing.height)
|
||||
.into()
|
||||
} else {
|
||||
container(text("Select a style to view details.").size(11).style(muted_style))
|
||||
container(text(t!("Select a style to view details.")).size(11).style(muted_style))
|
||||
.padding([12, 12])
|
||||
.into()
|
||||
};
|
||||
|
||||
+22
-20
@@ -6,6 +6,8 @@ use iced::widget::{
|
||||
button, canvas, checkbox, column, container, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
use iced::{mouse, Background, Border, Element, Length, Point, Rectangle, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// View-model for the Text Style editor window.
|
||||
pub struct TextStyleView<'a> {
|
||||
@@ -217,7 +219,7 @@ pub fn view_window<'a>(
|
||||
|
||||
let font_panel = container(
|
||||
column![
|
||||
text("Font File").size(10).style(muted_style),
|
||||
text(t!("Font File")).size(10).style(muted_style),
|
||||
container(scrollable(column(font_items).spacing(1)).height(sizing.height))
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
@@ -234,7 +236,7 @@ pub fn view_window<'a>(
|
||||
.width(sizing.width)
|
||||
.height(sizing.height)
|
||||
.padding(2),
|
||||
text_input("font file…", font_buf)
|
||||
text_input(t!("font file…").as_ref(), font_buf)
|
||||
.on_input(|v| Message::TextStyleEdit {
|
||||
field: "font",
|
||||
value: v
|
||||
@@ -252,14 +254,14 @@ pub fn view_window<'a>(
|
||||
|
||||
// Labeled numeric/text field row → TextStyleEdit { field, value }.
|
||||
fn frow<'a>(
|
||||
label: &'a str,
|
||||
ph: &'a str,
|
||||
label: impl Into<Cow<'static, str>>,
|
||||
ph: impl Into<Cow<'static, str>>,
|
||||
buf: &'a str,
|
||||
field: &'static str,
|
||||
) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(120),
|
||||
text_input(ph, buf)
|
||||
text(label.into()).size(11).style(muted_style).width(120),
|
||||
text_input(ph.into().as_ref(), buf)
|
||||
.on_input(move |v| Message::TextStyleEdit { field, value: v })
|
||||
.style(field_style)
|
||||
.size(11)
|
||||
@@ -295,41 +297,41 @@ pub fn view_window<'a>(
|
||||
// ── Right: Properties ─────────────────────────────────────────────────
|
||||
let props_panel = container(
|
||||
column![
|
||||
text("Properties").size(11).style(primary_style),
|
||||
frow("Big Font:", "big-font file…", bigfont_buf, "bigfont"),
|
||||
frow("TrueType Font:", "e.g. Arial", ttf_buf, "ttf"),
|
||||
text(t!("Properties")).size(11).style(primary_style),
|
||||
frow(t!("Big Font:"), t!("big-font file…"), bigfont_buf, "bigfont"),
|
||||
frow(t!("TrueType Font:"), t!("e.g. Arial"), ttf_buf, "ttf"),
|
||||
frow(
|
||||
if annotative {
|
||||
"Paper Text Height:"
|
||||
t!("Paper Text Height:")
|
||||
} else {
|
||||
"Fixed Height:"
|
||||
t!("Fixed Height:")
|
||||
},
|
||||
"0 = variable",
|
||||
t!("0 = variable"),
|
||||
height_buf,
|
||||
"height",
|
||||
),
|
||||
frow("Width Factor:", "1.0", width_buf, "width"),
|
||||
frow("Oblique (°):", "0.0", oblique_buf, "oblique"),
|
||||
frow(t!("Width Factor:"), "1.0", width_buf, "width"),
|
||||
frow(t!("Oblique (°):"), "0.0", oblique_buf, "oblique"),
|
||||
row![
|
||||
checkbox(backward)
|
||||
.label("Backward")
|
||||
.label(t!("Backward"))
|
||||
.on_toggle(|_| Message::TextStyleToggle("backward"))
|
||||
.size(15)
|
||||
.text_size(11),
|
||||
checkbox(upside_down)
|
||||
.label("Upside down")
|
||||
.label(t!("Upside down"))
|
||||
.on_toggle(|_| Message::TextStyleToggle("upside_down"))
|
||||
.size(15)
|
||||
.text_size(11),
|
||||
]
|
||||
.spacing(16),
|
||||
checkbox(annotative)
|
||||
.label("Annotative")
|
||||
.label(t!("Annotative"))
|
||||
.on_toggle(|_| Message::TextStyleToggle("annotative"))
|
||||
.size(15)
|
||||
.text_size(11),
|
||||
Space::new().height(8),
|
||||
text("Preview").size(10).style(muted_style),
|
||||
text(t!("Preview")).size(10).style(muted_style),
|
||||
container(preview)
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
@@ -377,7 +379,7 @@ pub fn view_window<'a>(
|
||||
|
||||
let ttf_panel = container(
|
||||
column![
|
||||
text("TrueType (system)").size(10).style(muted_style),
|
||||
text(t!("TrueType (system)")).size(10).style(muted_style),
|
||||
container(scrollable(column(ttf_items).spacing(1)).height(sizing.height))
|
||||
.style(|theme: &Theme| {
|
||||
let palette = theme.palette();
|
||||
@@ -394,7 +396,7 @@ pub fn view_window<'a>(
|
||||
.width(sizing.width)
|
||||
.height(sizing.height)
|
||||
.padding(2),
|
||||
text_input("TrueType font…", ttf_buf)
|
||||
text_input(t!("TrueType font…").as_ref(), ttf_buf)
|
||||
.on_input(|v| Message::TextStyleEdit {
|
||||
field: "ttf",
|
||||
value: v
|
||||
|
||||
Reference in new issue
Block a user