Properties panel: section headings in label text, form labels with colons beside fields of their own width, the Character section in its panel's layout, Opacity's icon after its field and Start Global Edit across the row, as production lays them out

This commit is contained in:
bflatastic
2026-11-24 10:49:42 +07:00
parent 767dc5cd2e
commit fed1961fa0
8 changed files with 53 additions and 48 deletions
+25 -17
View File
@@ -2,12 +2,12 @@
use craft::behavior::{ColumnWidth, IconId};
use craft::ui::buttons::{Button, IconButton};
use craft::ui::contract::{Props as _, Show as _, ShowContainer as _};
use craft::ui::layout_components::{Grid, Row};
use craft::ui::contract::{LabelScheme, Props as _, Show as _, ShowContainer as _};
use craft::ui::layout_components::{Grid, Row, Stack};
use craft::ui::patterns::panels::Inspector;
use craft::ui::runtime::commands::CommandRef;
use craft::ui::sections::Section;
use craft::ui::sections::{HeaderStrength, Section};
use egui::Ui;
use serde_json::json;
use vectorcraft_doc::{LiveShape, Node, NodeKind};
@@ -52,19 +52,27 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let guides = super::transform::selected_guides(app);
let header = heading(first.as_deref(), n_sel, editing_artboards, guides.is_some());
inspector.target(key).header(header).show(ui, |ui, _| {
if editing_artboards {
artboard_sections::artboard_sections(app, ui);
} else if first.is_none() {
match guides {
Some(guides) => transform_section::guide_sections(app, ui, guides),
None => document_sections::document_sections(app, ui),
// The reference panel's labels end in a colon beside fields that keep their own width.
Stack::new().fill_width().labels(LabelScheme::Form).show(ui, |ui, _| {
if editing_artboards {
artboard_sections::artboard_sections(app, ui);
} else if first.is_none() {
match guides {
Some(guides) => transform_section::guide_sections(app, ui, guides),
None => document_sections::document_sections(app, ui),
}
} else {
body(app, ui, first.as_deref(), n_sel, anchors);
}
} else {
body(app, ui, first.as_deref(), n_sel, anchors);
}
});
});
}
/// A section of the panel under its heading in label text, as the reference panel's section headings are.
fn section<'a>(title: &'static str) -> Section<'a> {
Section::fixed(title).strength(HeaderStrength::Normal)
}
/// The document's uid: production's field ids do not change with the selection, so neither does the key and the
/// scroll position stays.
fn target_key(app: &VectorcraftApp) -> Option<u64> {
@@ -89,7 +97,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
transform_section::corner_rows(app, ui);
// The Gradient tool: the gradient's type and, for a freeform one, how clicks add points (#921).
if app.session.tool_id() == "gradient" {
Section::fixed(tl!("Gradient")).show(ui, |ui, _| {
section(tl!("Gradient")).show(ui, |ui, _| {
super::gradient::type_row(app, ui);
super::gradient::draw_radios(app, ui);
});
@@ -112,7 +120,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
crate::dialogs::dimension::properties_section(app, ui);
}
appearance_section::appearance_section(app, ui);
Section::fixed(tl!("Align")).show(ui, |ui, _| {
section(tl!("Align")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
super::align::align_buttons(app, ui);
// The rest (Distribute Objects, Distribute Spacing, Align To) is the Align panel's.
@@ -120,7 +128,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
});
});
if n_sel > 1 {
Section::fixed(tl!("Pathfinder")).show(ui, |ui, _| {
section(tl!("Pathfinder")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
for (icon, tip, op) in [
("squares-unite", tl!("Unite"), "unite"),
@@ -135,10 +143,10 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
});
}
if anchors != crate::chrome::AnchorControls::None {
Section::fixed(tl!("Anchor Point")).show(ui, |ui, _| crate::chrome::anchor_buttons(app, ui, anchors));
section(tl!("Anchor Point")).show(ui, |ui, _| crate::chrome::anchor_buttons(app, ui, anchors));
}
let actions = quick_actions(app);
Section::fixed(tl!("Quick Actions")).show(ui, |ui, _| {
section(tl!("Quick Actions")).show(ui, |ui, _| {
if is_image {
crate::panels::image_trace::trace_button(app, ui);
}
@@ -5,13 +5,12 @@ use craft::behavior::IconId;
use craft::keymap::CommandRef;
use craft::ui::buttons::{Button, IconButton};
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _, Trigger, clicked};
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, clicked};
use craft::ui::display::{Elide, Shade, Text};
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::menu::Menu;
use craft::ui::popover::Popover;
use craft::ui::sections::Section;
use craft::ui::style::TypeRole;
use craft::ui::text::{NumberField, TextField};
use egui::{Response, Ui};
@@ -27,7 +26,7 @@ use crate::panels::{self, appearance, first_selected, stroke};
/// profile, Opacity and the effect controls.
pub(super) fn appearance_section(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(n) = first_selected(app) else { return };
Section::fixed(tl!("Appearance")).show(ui, |ui, _| {
super::section(tl!("Appearance")).show(ui, |ui, _| {
fill_stroke_rows(app, ui);
width_profile_row(app, ui);
opacity_row(app, ui, &n);
@@ -45,6 +44,7 @@ fn opacity_row(app: &mut VectorcraftApp, ui: &mut Ui, n: &Node) {
Row::new().show(ui, |ui, _| {
let shown = Some(n.opacity as f64 * 100.0);
let out = Field::new(tl!("Opacity"))
.sizing(Sizing::Content)
.show(ui, |ui, _| NumberField::new(tl!("Opacity"), Bind::given(shown)).range(0.0..=100.0).unit("%").fixed_decimals(0).show(ui))
.inner;
if let Some(out) = out {
@@ -135,8 +135,8 @@ pub(super) fn global_edit_row(app: &mut VectorcraftApp, ui: &mut Ui) {
// A copy, so the popover's flag does not borrow `app` while its body runs commands.
let mut open = app.ui.properties_panel.global_edit_open;
Row::new().show(ui, |ui, _| {
// The command's own state gives its title: Start or Stop Global Edit.
Button::command("select.globalEdit").show(ui);
// The command's own state gives its title: Start or Stop Global Edit. It takes the row up to the options.
Button::command("select.globalEdit").sizing(Sizing::FillWidth).show(ui);
let options = IconButton::new(IconId::new("chevron-down")).label(tl!("Global Edit Options")).enabled(!on).show(ui);
global_edit_popover(app, ui, &options.response, &mut open);
});
@@ -13,7 +13,6 @@ use craft::ui::layout_components::{Grid, Row};
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::pickers::Select;
use craft::ui::primitives::IconSpec;
use craft::ui::sections::Section;
use craft::ui::text::TextField;
use egui::Ui;
use serde_json::json;
@@ -36,13 +35,13 @@ pub(super) fn artboard_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
let i = artboards::selected(app, n);
let ab = app.session.active().and_then(|d| d.doc.artboards.get(i)).cloned();
if let Some(ab) = &ab {
Section::fixed(tl!("Transform")).show(ui, |ui, _| {
super::section(tl!("Transform")).show(ui, |ui, _| {
transform::artboard_fields(app, ui, i, ab.rect);
artboard_size_row(app, ui, i, ab.rect.width(), ab.rect.height());
artboards::art_options(app, ui);
});
}
Section::fixed(tl!("Artboards")).show(ui, |ui, _| {
super::section(tl!("Artboards")).show(ui, |ui, _| {
if let Some(ab) = &ab {
Field::new(tl!("Name:")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
@@ -72,7 +71,7 @@ pub(super) fn artboard_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
});
Section::fixed(tl!("Quick Actions")).show(ui, |ui, _| {
super::section(tl!("Quick Actions")).show(ui, |ui, _| {
Grid::new(&HALVES).show(ui, |ui, _| {
rearrange_button(ui, n);
Button::command(CommandRef::with_params("tool.select", json!({ "tool": "selection" })))
@@ -9,7 +9,6 @@ use craft::ui::form::Field;
use craft::ui::layout_components::{Grid, Row};
use craft::ui::pickers::Select;
use craft::ui::runtime::env::LengthUnits;
use craft::ui::sections::Section;
use craft::ui::text::NumberField;
use egui::Ui;
use serde_json::json;
@@ -26,7 +25,7 @@ use crate::panels::transform;
pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
let units = app.session.general_unit();
let artboards = app.session.active().map_or(0, |d| d.doc.artboards.len());
Section::fixed(tl!("Document")).show(ui, |ui, _| {
super::section(tl!("Document")).show(ui, |ui, _| {
Field::new(tl!("Units")).show(ui, |ui, _| {
let entries: Vec<Entry<Unit>> = Unit::ALL.iter().map(|u| Entry::new(*u, u.label())).collect();
let out = Select::new(tl!("Units"), Bind::given(units), &entries).show(ui);
@@ -45,8 +44,8 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
});
Section::fixed(tl!("Appearance")).show(ui, |ui, _| super::appearance_section::fill_stroke_rows(app, ui));
Section::fixed(tl!("Rulers & Grids")).show(ui, |ui, _| {
super::section(tl!("Appearance")).show(ui, |ui, _| super::appearance_section::fill_stroke_rows(app, ui));
super::section(tl!("Rulers & Grids")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
// The checked and enabled states and the tooltips come from the commands (Trim View turns the grid off).
for (command, icon) in [("view.rulers", "ruler"), ("view.grid", "grid-3x3"), ("view.transparencyGrid", "square-dashed")] {
@@ -54,14 +53,14 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
});
});
Section::fixed(tl!("Guides")).show(ui, |ui, _| {
super::section(tl!("Guides")).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
for (command, icon) in [("view.guides", "layout-grid"), ("view.smartGuides", "sparkles")] {
ToggleButton::command(CommandRef::new(command)).icon(IconId::new(icon)).icon_only().show(ui);
}
});
});
Section::fixed(tl!("Snap Options")).show(ui, |ui, _| {
super::section(tl!("Snap Options")).show(ui, |ui, _| {
let (point, grid) = (app.ui.view.snap_to_point, app.ui.view.snap_to_grid);
for (command, label, on) in [("view.snapToPoint", tl!("Snap to Point"), point), ("view.snapToGrid", tl!("Snap to Grid"), grid)] {
if Checkbox::new(Bind::given(on)).label(label).show(ui).value().is_some() {
@@ -69,7 +68,7 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
}
}
});
Section::fixed(tl!("Preferences")).show(ui, |ui, _| {
super::section(tl!("Preferences")).show(ui, |ui, _| {
Field::new(tl!("Keyboard Increment")).show(ui, |ui, _| {
// PLAN: assumed `canvas::rulers::general_lengths(app) -> LengthUnits` (cv.B5b)
let lengths: LengthUnits = crate::canvas::rulers::general_lengths(app);
@@ -89,7 +88,7 @@ pub(super) fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
transform::set_pref(app, "scaleStrokes", on);
}
});
Section::fixed(tl!("Quick Actions")).show(ui, |ui, _| {
super::section(tl!("Quick Actions")).show(ui, |ui, _| {
Grid::new(&HALVES).show(ui, |ui, _| {
for command in ["file.documentSetup", "edit.preferences"] {
Button::command(CommandRef::new(command)).sizing(Sizing::FillWidth).show(ui);
@@ -8,7 +8,6 @@
use craft::ui::buttons::Button;
use craft::ui::contract::{Props as _, Show as _, ShowContainer as _};
use craft::ui::layout_components::Row;
use craft::ui::sections::Section;
use egui::Ui;
use vectorcraft_doc::{Document, GraphKind, MAX_GRAPH_SERIES, NodeId};
@@ -79,7 +78,7 @@ fn series_of(doc: &Document, graph: NodeId, id: NodeId) -> Option<usize> {
/// The Graph section for the selection; nothing without a graph.
pub(crate) fn section(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(s) = shown(app) else { return };
Section::fixed(tl!("Graph")).show(ui, |ui, _| {
super::section(tl!("Graph")).show(ui, |ui, _| {
Row::new().wrap(true).show(ui, |ui, _| {
Button::command("graph.setType").label(tl!("Graph Type…")).show(ui);
Button::command("graph.setData").label(tl!("Graph Data…")).show(ui);
@@ -10,7 +10,6 @@ use craft::ui::form::Field;
use craft::ui::layout_components::Grid;
use craft::ui::pickers::{ReferencePoint, ReferencePointLook};
use craft::ui::runtime::env::UnitKind;
use craft::ui::sections::Section;
use craft::ui::style::TypeRole;
use craft::ui::text::{NumberField, NumberPick};
use egui::Ui;
@@ -28,7 +27,7 @@ pub(super) fn image_section(app: &mut VectorcraftApp, ui: &mut Ui) {
let Some(i) = crate::place::selected_image_info(app) else { return };
let (name, details) = crate::place::image_summary(i);
let (Some(id), linked) = (i["id"].as_u64(), i["linked"] == true) else { return };
Section::fixed(if linked { tl!("Linked File") } else { tl!("Embedded Image") }).show(ui, |ui, _| {
super::section(if linked { tl!("Linked File") } else { tl!("Embedded Image") }).show(ui, |ui, _| {
Text::new(name.clone()).elide(Elide::Middle).role(TypeRole::BodyStrong).show(ui);
Text::new(details.clone()).shade(Shade::Muted).show(ui);
Grid::new(&HALVES).show(ui, |ui, _| {
@@ -52,7 +51,7 @@ pub(super) fn image_section(app: &mut VectorcraftApp, ui: &mut Ui) {
/// The one selected Image Trace object: its preset (choosing another traces it again with that
/// one), view, a button to reveal the tracing controls, Expand and Release.
pub(super) fn trace_section(app: &mut VectorcraftApp, ui: &mut Ui, preset: &str, view: vectorcraft_doc::TraceView) {
Section::fixed(tl!("Image Trace")).show(ui, |ui, _| {
super::section(tl!("Image Trace")).show(ui, |ui, _| {
Field::new(tl!("Preset")).show(ui, |ui, _| crate::panels::image_trace::preset_dropdown(app, ui, preset));
crate::panels::image_trace::view_row(app, ui, view);
crate::panels::image_trace::split_row(app, ui);
@@ -118,7 +117,7 @@ pub(super) fn objects_on_path_section(app: &mut VectorcraftApp, ui: &mut Ui, oop
app.status(e);
}
};
Section::fixed(tl!("Objects on Path Options")).show(ui, |ui, _| {
super::section(tl!("Objects on Path Options")).show(ui, |ui, _| {
Field::new(tl!("Pivot")).show(ui, |ui, _| {
// Mixed while the groups' pivots differ: no square is chosen.
let shown = oop.pivot.map_or(Mixed::Mixed, |p| Mixed::Same(Anchor9::ALL.get(usize::from(p)).copied()));
@@ -12,7 +12,6 @@ use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::pickers::Select;
use craft::ui::popover::Popover;
use craft::ui::sections::Section;
use egui::Ui;
use serde_json::json;
use vectorcraft_doc::{LiveCorners, LiveShape, NodeKind};
@@ -31,7 +30,7 @@ pub fn transform_section(app: &mut VectorcraftApp, ui: &mut Ui) {
Text::new(tl!("No Selection")).shade(Shade::Muted).show(ui);
return;
}
Section::fixed(tl!("Transform")).show(ui, |ui, _| {
super::section(tl!("Transform")).show(ui, |ui, _| {
let mut groups = TransformGroups::NONE;
groups.reference = true;
groups.position = true;
@@ -107,5 +106,5 @@ pub(super) fn corner_rows(app: &mut VectorcraftApp, ui: &mut Ui) {
/// Ruler guides selected on their own: a Transform section with the X of the vertical ones and
/// the Y of the horizontal ones, which move them, as the Transform panel shows them (#1597).
pub(super) fn guide_sections(app: &mut VectorcraftApp, ui: &mut Ui, guides: (Option<f64>, Option<f64>)) {
Section::fixed(tl!("Transform")).show(ui, |ui, _| transform::guide_fields(app, ui, guides));
super::section(tl!("Transform")).show(ui, |ui, _| transform::guide_fields(app, ui, guides));
}
@@ -1,10 +1,9 @@
//! The Properties panel's Character and Paragraph sections for the selected text.
use craft::text::ui::character::CharacterRows;
use craft::ui::contract::{Show as _, ShowContainer as _};
use craft::ui::contract::{LabelScheme, Show as _, ShowContainer as _};
use craft::ui::display::{Shade, Text};
use craft::ui::layout_components::Row;
use craft::ui::sections::Section;
use craft::ui::layout_components::{Row, Stack};
use egui::Ui;
use vectorcraft_doc::NodeKind;
@@ -23,8 +22,11 @@ pub fn type_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
if character::text_style(app).is_none() {
return;
}
Section::fixed(tl!("Character")).show(ui, |ui, _| character::controls(app, ui, CharacterRows::PROPERTIES));
Section::fixed(tl!("Paragraph")).show(ui, |ui, _| {
// The Character panel's controls as that panel lays them out: the font pickers and the metrics fill the row.
super::section(tl!("Character")).show(ui, |ui, _| {
Stack::new().fill_width().labels(LabelScheme::Inspector).show(ui, |ui, _| character::controls(app, ui, CharacterRows::PROPERTIES));
});
super::section(tl!("Paragraph")).show(ui, |ui, _| {
// As in the Paragraph panel: the seven alignments and Hyphenate (#775), and area type's vertical alignment
// (#3759); the rest is there.
Row::new().show(ui, |ui, _| {