Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Document properties: the page box field in its own function

moppeeerfd3d2f4e4922
diff --git a/crates/ui-egui/src/panels/properties/document.rs b/crates/ui-egui/src/panels/properties/document.rs
index f9ac002cb..d68d4531c 100644
--- a/crates/ui-egui/src/panels/properties/document.rs
+++ b/crates/ui-egui/src/panels/properties/document.rs
@@ -172,6 +172,15 @@ fn page_preset_menu(ui: &mut Ui, pw: f64, ph: f64) -> Option<(f64, f64)> {
preset
}
+/// As the status bar's page box: the page, or the parent shown ("A-Parent"); then the parents.
+fn page_box_field(app: &mut DesignApp, ui: &mut Ui, b: Rect) {
+ let Some(pb) = crate::canvas::page_box(app) else { return };
+ let picked = place(ui, sub(b, 0.0, 0.0, 93.0, FIELD_H), |ui| widgets::dropdown_list(ui, pb.current_name(), 93.0, &pb.names, Some(pb.current)));
+ if let Some(i) = picked {
+ crate::canvas::page_box_go(app, &pb, i);
+ }
+}
+
pub(super) fn document_sections(app: &mut DesignApp, ui: &mut Ui) {
let u = units(app);
let Some(st) = app.session.active() else { return };
@@ -287,14 +296,7 @@ pub(super) fn document_sections(app: &mut DesignApp, ui: &mut Ui) {
// Page.
section(ui, crate::i18n::tr(&app.ui.language, "Page"), true);
let b = block(ui, FIELD_H);
- // As the status bar's page box: the page, or the parent shown ("A-Parent"); then the parents.
- if let Some(pb) = crate::canvas::page_box(app) {
- let picked =
- place(ui, sub(b, 0.0, 0.0, 93.0, FIELD_H), |ui| widgets::dropdown_list(ui, pb.current_name(), 93.0, &pb.names, Some(pb.current)));
- if let Some(i) = picked {
- crate::canvas::page_box_go(app, &pb, i);
- }
- }
+ page_box_field(app, ui, b);
let (add, del) = place(ui, sub(b, 172.0, 0.0, 50.0, FIELD_H), |ui| {
ui.spacing_mut().item_spacing.x = 4.0;
let a = widgets::icon_toggle_sized(ui, "style-new", false, "Insert Page", vec2(22.0, 21.0)).clicked();