Skip to content

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

Fill colour picker: the picker opener shared with the text panel, the swatches module's path, one Fill popup per chip

moppeeera9814cae3995
diff --git a/crates/ui-egui/src/panels/properties/object.rs b/crates/ui-egui/src/panels/properties/object.rs
index 50f8e498e..e9daa0f32 100644
--- a/crates/ui-egui/src/panels/properties/object.rs
+++ b/crates/ui-egui/src/panels/properties/object.rs
@@ -378,8 +378,8 @@ pub(super) fn appearance_section(app: &mut DesignApp, ui: &mut Ui, i: &SelInfo)
/// The Color Picker for a Fill or Stroke chip (a double-click on it, as in InDesign), with the
/// chip's colour: the objects', or with `text` the selected text's.
-fn open_color_picker(app: &mut DesignApp, doc: &designcraft_doc::Document, swatch: &str, stroke: bool, text: bool) {
- let mut fields = super::swatches::picker_fields(doc.resolve_color(swatch, 1.0), stroke);
+pub(super) fn open_color_picker(app: &mut DesignApp, doc: &designcraft_doc::Document, swatch: &str, stroke: bool, text: bool) {
+ let mut fields = crate::panels::swatches::picker_fields(doc.resolve_color(swatch, 1.0), stroke);
fields["text"] = json!(text);
app.ui.dialog = Some(crate::dialogs::Dialog::new("colorPicker", fields));
}
diff --git a/crates/ui-egui/src/panels/properties/text.rs b/crates/ui-egui/src/panels/properties/text.rs
index 05a2175a4..64c6d6890 100644
--- a/crates/ui-egui/src/panels/properties/text.rs
+++ b/crates/ui-egui/src/panels/properties/text.rs
@@ -1,4 +1,4 @@
-use super::object::swatch_menu;
+use super::object::{open_color_picker, swatch_menu};
use super::typography::{para_field_min, show_typography_panel};
use super::{
Align, DesignApp, FIELD_H, NumField, Rect, Sense, Stroke, StrokeKind, Tokens, Ui, Value, block, full_width, icon_toggle, icons, json, link_label,
@@ -128,7 +128,6 @@ pub(super) fn text_appearance_section(app: &mut DesignApp, ui: &mut Ui) {
ui.painter().text(chip.center(), egui::Align2::CENTER_CENTER, "T", crate::theme::semibold(12.0), tc);
}
let resp = ui.interact(chip, ui.scope_id().with(("tchip", k)), Sense::click()).on_hover_text(format!("{label}: {sw}"));
- swatch_menu(app, &resp, &doc, &sw, k != 0, false, true);
resp.widget_info(|| {
egui::WidgetInfo::labeled(egui::WidgetType::Button, true, if k == 0 { "Text fill swatch" } else { "Text stroke swatch" })
});