forked from 1b-agent/opencadstudio-upstream
Merge pull request #1810 from ramox81/codex/insert-import-panel
Insert ribbon: Import panel # Conflicts: # locales/ar-SA/opencadstudio.ftl # locales/bg-BG/opencadstudio.ftl # locales/cs-CZ/opencadstudio.ftl # locales/de-DE/opencadstudio.ftl # locales/el-GR/opencadstudio.ftl # locales/en-US/opencadstudio.ftl # locales/es-ES/opencadstudio.ftl # locales/fi-FI/opencadstudio.ftl # locales/fr-FR/opencadstudio.ftl # locales/hi-IN/opencadstudio.ftl # locales/hu-HU/opencadstudio.ftl # locales/it-IT/opencadstudio.ftl # locales/ja-JP/opencadstudio.ftl # locales/ko-KR/opencadstudio.ftl # locales/lo-LA/opencadstudio.ftl # locales/nl-NL/opencadstudio.ftl # locales/pl-PL/opencadstudio.ftl # locales/pt-BR/opencadstudio.ftl # locales/ru-RU/opencadstudio.ftl # locales/tr-TR/opencadstudio.ftl # locales/zh-CN/opencadstudio.ftl # locales/zh-TW/opencadstudio.ftl # src/modules/insert/mod.rs # src/ui/ribbon/draw_panel.rs
This commit is contained in:
commit
443d3ec13d
33 files changed
+285
-42
No files matched your search
+34
-14
@@ -173,6 +173,14 @@ const BLOCK_DEFINITION_TOOLS: &[Tool] = &[
|
||||
),
|
||||
];
|
||||
|
||||
/// Insert > Import slide-out, its tools named beside their icons.
|
||||
const IMPORT_TOOLS: &[Tool] = &[icon_tool(
|
||||
"LANDXMLIMPORT",
|
||||
"Land XML",
|
||||
include_bytes!("../../../assets/icons/landxml.svg"),
|
||||
)];
|
||||
const IMPORT_PANEL_ID: &str = "import_extension";
|
||||
|
||||
const PANELS: &[Panel] = &[
|
||||
Panel {
|
||||
id: PANEL_ID,
|
||||
@@ -209,6 +217,13 @@ const PANELS: &[Panel] = &[
|
||||
title: "Block Definition",
|
||||
tools: BLOCK_DEFINITION_TOOLS,
|
||||
},
|
||||
Panel {
|
||||
id: IMPORT_PANEL_ID,
|
||||
anchor: None,
|
||||
title_id: "import_extension_title",
|
||||
title: "Import",
|
||||
tools: IMPORT_TOOLS,
|
||||
},
|
||||
];
|
||||
|
||||
/// Command, label and icon of every tool in the expanded Draw and Modify
|
||||
@@ -417,19 +432,14 @@ fn tool_button(tool: &Tool, active: bool, panel_id: &'static str) -> Element<'st
|
||||
}
|
||||
}
|
||||
|
||||
/// The Reference slide-out: Edit Reference, and xref fading on/off with its
|
||||
/// amount (XDWGFADECTL; the switch keeps the amount as a negative value).
|
||||
fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Element<'a, Message> {
|
||||
let width: f32 = 260.0_f32.min((win.0 - 8.0).max(120.0));
|
||||
let (_, x, anchor_top) = ribbon.dd_anchor(panel.id, width, win.0);
|
||||
let left = x.clamp(0.0, (win.0 - width).max(0.0));
|
||||
let top = anchor_top.min((win.1 - 80.0).max(0.0));
|
||||
let tool = &panel.tools[0];
|
||||
let edit = button(
|
||||
/// A slide-out tool as one row: its icon, then its name.
|
||||
fn labeled_row(panel_id: &'static str, tool: &Tool) -> Element<'static, Message> {
|
||||
let command = tool.command;
|
||||
let row = button(
|
||||
row![
|
||||
make_icon(IconKind::Svg(tool.icon), 16.0),
|
||||
keytips::label_anchor(
|
||||
|| keytips::label_id(&keytips::item_anchor(panel.id, tool.command)),
|
||||
move || keytips::label_id(&keytips::item_anchor(panel_id, command)),
|
||||
text(t!(tool.label)).size(11),
|
||||
),
|
||||
]
|
||||
@@ -437,13 +447,23 @@ fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Elem
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.on_press(Message::DropdownSelectItem {
|
||||
dropdown_id: panel.id,
|
||||
cmd: tool.command,
|
||||
dropdown_id: panel_id,
|
||||
cmd: command,
|
||||
})
|
||||
.style(popup_row_style)
|
||||
.width(Fill)
|
||||
.padding([3, 6]);
|
||||
let edit = keytips::anchor_with(|| keytips::item_anchor(panel.id, tool.command), edit);
|
||||
keytips::anchor_with(move || keytips::item_anchor(panel_id, command), row)
|
||||
}
|
||||
|
||||
/// The Reference slide-out: Edit Reference, and xref fading on/off with its
|
||||
/// amount (XDWGFADECTL; the switch keeps the amount as a negative value).
|
||||
fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Element<'a, Message> {
|
||||
let width: f32 = 260.0_f32.min((win.0 - 8.0).max(120.0));
|
||||
let (_, x, anchor_top) = ribbon.dd_anchor(panel.id, width, win.0);
|
||||
let left = x.clamp(0.0, (win.0 - width).max(0.0));
|
||||
let top = anchor_top.min((win.1 - 80.0).max(0.0));
|
||||
let edit = labeled_row(panel.id, &panel.tools[0]);
|
||||
let fade = ribbon.xref_fade;
|
||||
let on = fade > 0;
|
||||
let switch = button(make_icon(
|
||||
@@ -541,7 +561,7 @@ pub(super) fn overlay<'a>(ribbon: &Ribbon, id: &str, win: (f32, f32)) -> Element
|
||||
if panel.id == REFERENCE_PANEL_ID {
|
||||
return reference_overlay(ribbon, panel, win);
|
||||
}
|
||||
if panel.id == BLOCK_DEFINITION_PANEL_ID {
|
||||
if panel.id == BLOCK_DEFINITION_PANEL_ID || panel.id == IMPORT_PANEL_ID {
|
||||
return labeled_overlay(ribbon, panel, win);
|
||||
}
|
||||
let tools = panel.tools;
|
||||
|
||||
@@ -405,6 +405,13 @@ const CODES: &[(&str, &str, &str)] = &[
|
||||
("insert", "UOSNAP_DROPDOWN", "SN"),
|
||||
("reference_extension", "REFEDIT", "ER"),
|
||||
("reference_extension", XREF_FADE, "XF"),
|
||||
("insert", "IMPORT_FILE", "IF"),
|
||||
("IMPORT_FILE", "PDFIMPORT;FILE", "PI"),
|
||||
("IMPORT_FILE", "DGNIMPORT", "DI"),
|
||||
("IMPORT_FILE", "IMPORT", "OI"),
|
||||
("insert", "PDFSHXTEXT", "PS"),
|
||||
("insert", "PDFSHXTEXT_SETTINGS", "PT"),
|
||||
("insert", "TXT2MTXT", "TM"),
|
||||
// Annotate.
|
||||
("annotate", "Text", "TE"),
|
||||
("annotate", "ANNOTATE_TEXT", "MT"),
|
||||
|
||||
+17
-1
@@ -50,6 +50,11 @@ pub(crate) fn tooltip_style(theme: &Theme) -> container::Style {
|
||||
widgets::tip_style(theme)
|
||||
}
|
||||
|
||||
/// A line over the items of a split button whose face names the chosen item.
|
||||
fn dropdown_header(id: &str) -> Option<&'static str> {
|
||||
(id == "IMPORT_FILE").then_some("Import File — the face runs the last one chosen")
|
||||
}
|
||||
|
||||
// ── Ribbon state ───────────────────────────────────────────────────────────
|
||||
|
||||
pub struct Ribbon {
|
||||
@@ -1069,11 +1074,22 @@ impl Ribbon {
|
||||
.iter()
|
||||
.map(|(_, label, _)| t!(*label).to_string())
|
||||
.collect();
|
||||
let header = dropdown_header(dd_id).map(|header| t!(header).into_owned());
|
||||
let mut rows = rows;
|
||||
if let Some(header) = &header {
|
||||
rows.insert(
|
||||
0,
|
||||
container(text(header.clone()).size(10).style(muted_text_style))
|
||||
.padding([4, 10])
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
let panel_w = crate::ui::style::common::dropdown_popup_width(
|
||||
labels.iter().map(|s| s.as_str()),
|
||||
11.0,
|
||||
68.0,
|
||||
190.0,
|
||||
// A header wraps rather than widening the menu.
|
||||
if header.is_some() { 240.0 } else { 190.0 },
|
||||
);
|
||||
|
||||
let panel = container(column(rows))
|
||||
|
||||
@@ -501,6 +501,8 @@ fn tool_description(id: &str) -> Option<&'static str> {
|
||||
/// A tool's tooltip: its name, its description when one is known, and the
|
||||
/// command it runs.
|
||||
fn tool_tip_text(label: &str, id: &str) -> String {
|
||||
// A macro (`PDFIMPORT;FILE`) shows the command it starts.
|
||||
let id = id.split(';').next().unwrap_or(id);
|
||||
match tool_description(id) {
|
||||
Some(description) => format!("{label}\n{}\n{} {id}", t!(description), t!("Command:")),
|
||||
None => format!("{label}\n{} {id}", t!("Command:")),
|
||||
@@ -827,6 +829,10 @@ pub(super) fn render_large_dropdown<'a>(
|
||||
})
|
||||
.or_else(|| items.first().map(|(_, lbl, _)| *lbl))
|
||||
.unwrap_or(id);
|
||||
// An empty label: the face keeps its own icon and names the chosen item.
|
||||
let names_item = explicit_label == Some("");
|
||||
let cur_icon = if names_item { icon } else { cur_icon };
|
||||
let explicit_label = explicit_label.filter(|label| !label.is_empty());
|
||||
let label = t!(explicit_label.unwrap_or(cur_label)).into_owned();
|
||||
let tip_text = tool_tip_text(&t!(cur_label), last);
|
||||
let arr_tip = format!("{} {}", label, t!("options"));
|
||||
|
||||
Reference in new issue
Block a user