forked from 1b-agent/opencadstudio-upstream
Merge pull request #1722 from ramox81/codex/view-background
# 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
This commit is contained in:
commit
03445a540d
40 files changed
+1801
-46
No files matched your search
@@ -103,6 +103,7 @@ pub(super) const NAMES: &[&str] = &[
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
"external_change_cancel",
|
||||
"pdf_dialog_ok",
|
||||
"view_background",
|
||||
"pdf_layer_toggle",
|
||||
"pc_manager_toggle",
|
||||
"pc_manager",
|
||||
@@ -1786,6 +1787,53 @@ impl OpenCADStudio {
|
||||
})
|
||||
}
|
||||
"ribbon_dropdown" => Message::ToggleRibbonDropdown(string(req, "value")?.into()),
|
||||
// The -VIEW Background dialog, one field per call: "type=gradient",
|
||||
// "color|top|middle|bottom=r,g,b", "three=1", "rotation=30",
|
||||
// "image=<path>", "position=center|stretch|tile", "aspect=1",
|
||||
// "apply" or "cancel".
|
||||
"view_background" => {
|
||||
use crate::ui::window::pdf_dialogs::{BgKind, BgPosition, PdfDialogMsg as P};
|
||||
if self.active_modal != Some(crate::app::ModalKind::ViewBackground) {
|
||||
return Err(failure("no_dialog", "The Background dialog is not open"));
|
||||
}
|
||||
let spec = string(req, "value")?;
|
||||
let (key, value) = spec.split_once('=').unwrap_or((spec, ""));
|
||||
let bad = || failure("invalid_value", spec);
|
||||
let rgb = || -> Result<[u8; 3], Value> {
|
||||
let parts: Vec<u8> = value
|
||||
.split(',')
|
||||
.map(|part| part.trim().parse::<u8>())
|
||||
.collect::<Result<_, _>>()
|
||||
.map_err(|_| bad())?;
|
||||
<[u8; 3]>::try_from(parts).map_err(|_| bad())
|
||||
};
|
||||
match key {
|
||||
"cancel" => Message::CloseModal,
|
||||
"apply" => Message::PdfDialog(P::BgApply),
|
||||
"type" => Message::PdfDialog(P::BgKind(match value {
|
||||
"none" => BgKind::None,
|
||||
"solid" => BgKind::Solid,
|
||||
"gradient" => BgKind::Gradient,
|
||||
"image" => BgKind::Image,
|
||||
_ => return Err(bad()),
|
||||
})),
|
||||
"color" => Message::PdfDialog(P::BgColor(0, rgb()?)),
|
||||
"top" => Message::PdfDialog(P::BgColor(1, rgb()?)),
|
||||
"middle" => Message::PdfDialog(P::BgColor(2, rgb()?)),
|
||||
"bottom" => Message::PdfDialog(P::BgColor(3, rgb()?)),
|
||||
"three" => Message::PdfDialog(P::BgThree(value == "1")),
|
||||
"rotation" => Message::PdfDialog(P::BgRotation(value.to_string())),
|
||||
"image" => Message::PdfDialog(P::BgImage(value.to_string())),
|
||||
"position" => Message::PdfDialog(P::BgPosition(match value {
|
||||
"center" => BgPosition::Center,
|
||||
"stretch" => BgPosition::Stretch,
|
||||
"tile" => BgPosition::Tile,
|
||||
_ => return Err(bad()),
|
||||
})),
|
||||
"aspect" => Message::PdfDialog(P::BgAspect(value == "1")),
|
||||
_ => return Err(bad()),
|
||||
}
|
||||
}
|
||||
"pdf_dialog_ok" => {
|
||||
use crate::ui::window::pdf_dialogs::PdfDialogMsg;
|
||||
Message::PdfDialog(match self.active_modal {
|
||||
|
||||
Reference in new issue
Block a user