mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 16:59:43 +01:00
VectorCraft's UI moves onto the shared craft UI framework in storytold/craft-libs (`next`; the framework side is storytold/craft-libs#2809), as PhotoCraft's did. The app keeps its engine, document model, file formats, commands and automation; its windows, panels, bars, dialogs and canvas are now built and driven by the framework: shell, docking and panels, hosted dialogs, keyboard, focus, IME and pointer routing, and theme tokens. About 264,000 lines of VectorCraft's own egui UI code are removed and about 154,000 added. craft-libs is pinned at bf62d509f (in `next`), the egui fork at f5025284. Tests that drove the old UI were rewritten against the port where only their premise changed, with their assertions kept. The UI tests still failing at merge, and their follow-ups, are listed in the pull request.
34 lines
1.8 KiB
Rust
34 lines
1.8 KiB
Rust
//! Three-Point Arc Tool Options (double-click the Three-Point Arc tool, or `tool.options`):
|
|
//! Third Point Sets Direction, the tool's `direction` option. With it on, the third point gives the
|
|
//! direction the arc leaves an end in; with it off, the arc passes through the third point. OK
|
|
//! sets it with `tool.setOption {tool: "threePointArc", values: {direction}}`; it lasts across
|
|
//! tool switches and is saved with the preferences. `]` also switches it while an arc is drawn.
|
|
|
|
use craft::ui::contract::Bind;
|
|
use craft::ui::patterns::form_dialogs::{HostedParamDialog, Param, ParamDialog, ParamKind, ParamResult};
|
|
use serde_json::{Value, json};
|
|
use vectorcraft_tools::three_point_arc::ID as TOOL;
|
|
|
|
use super::{form, host, tool_options};
|
|
use crate::VectorcraftApp;
|
|
|
|
/// The dialog kind of Three-Point Arc Tool Options.
|
|
pub const KIND: &str = "threePointArcOptions";
|
|
|
|
/// Open the tool's options with their current values.
|
|
pub fn open(app: &mut VectorcraftApp) -> Value {
|
|
let params = vec![Param::new("direction", tl!("Third Point Sets Direction"), ParamKind::bool(false))];
|
|
let options = app.session.tool_options_of(TOOL);
|
|
let fields = options.as_object().map(|m| form::fields_of(¶ms, m)).unwrap_or_default();
|
|
let (title, shown) = (tool_options::title(TOOL), params.clone());
|
|
let ok = move |app: &mut VectorcraftApp, result: &ParamResult| tool_options::set_options(app, TOOL, form::json_of(¶ms, &result.fields));
|
|
let opened = app.ui_ctx.clone().and_then(|ctx| {
|
|
let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |f| ParamDialog::new(KIND, title.clone(), shown.clone()).values(Bind::bound(f)));
|
|
host::open_held(app, dialog, ok)
|
|
});
|
|
if opened.is_none() {
|
|
app.status(tl!("No window to show the dialog in.").to_string());
|
|
}
|
|
json!({ "dialog": KIND })
|
|
}
|