From 8cca7674bdbae1cda0be09ceee7bb94468652a1e Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sun, 4 Jan 2026 00:29:00 +0100 Subject: [PATCH] add store_in_metadata image style property --- src/data/field.hpp | 38 ++++++++--------- src/data/field/image.cpp | 3 +- src/data/field/image.hpp | 41 +++++++++++------- src/data/format/file_to_text.h | 76 ++++++++++++++++++++++++++++++++++ src/data/format/image.cpp | 40 ++++++++++++------ src/data/settings.cpp | 4 +- src/gui/control/card_list.cpp | 19 ++++++++- src/gui/image_slice_window.cpp | 2 +- src/script/functions/json.cpp | 5 ++- src/util/io/package.hpp | 28 +++++++++++-- src/util/uid.hpp | 2 +- 11 files changed, 202 insertions(+), 56 deletions(-) create mode 100644 src/data/format/file_to_text.h diff --git a/src/data/field.hpp b/src/data/field.hpp index bb3de113..3ede7d99 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -103,15 +103,15 @@ public: Style(const FieldP&); virtual ~Style(); - const FieldP fieldP; ///< Field this style is for, should have the right type! + const FieldP fieldP; ///< Field this style is for, should have the right type! - int z_index; ///< Stacking of values of this field, higher = on top - int tab_index; ///< Tab index in editor - Scriptable left, top; ///< Position of this field - Scriptable width, height; ///< Position of this field - Scriptable right, bottom; ///< Position of this field - Scriptable angle; ///< Rotation of the box - Scriptable visible; ///< Is this field visible? + int z_index; ///< Stacking of values of this field, higher = on top + int tab_index; ///< Tab index in editor + Scriptable left, top; ///< Position of this field + Scriptable right, bottom; ///< Position of this field + Scriptable width, height; ///< Size of this field + Scriptable angle; ///< Rotation of the box + Scriptable visible; ///< Is this field visible? CachedScriptableMask mask; ///< Mask image enum AutomaticSide { @@ -123,10 +123,10 @@ public: } automatic_side : 8; ///< Which of (left, width, right) and (top, height, bottom) is determined automatically? bool content_dependent; ///< Does this style depend on content properties? - inline RealPoint getPos() const { return RealPoint(left, top); } - inline RealSize getSize() const { return RealSize(width, height); } - inline RealRect getExternalRect() const { return RealRect(left, top, width, height); } - inline String getExternalRectString(double scale, Radians angle, double bleed, int img_width, int img_height, int img_offset) { ///< update the style before calling this + inline RealPoint getPos() const { return RealPoint(left, top); } + inline RealSize getSize() const { return RealSize(width, height); } + inline RealRect getExternalRect() const { return RealRect(left, top, width, height); } + inline std::string getExternalRectString(double scale, Radians angle, double bleed, int img_width, int img_height, int img_offset) { ///< update the style before calling this double x = left * scale, y = top * scale; double w = width * scale, h = height * scale; RealRect rect(x, y, w, h); @@ -142,14 +142,14 @@ public: rect = RealRect(img_width - y - h, x, h, w); degrees = 270; } else { - return _(""); + return ""; } - return _("---") + wxString::Format(wxT("%i"), (int)std::ceil( rect.x + bleed + img_offset)) + - _("-") + wxString::Format(wxT("%i"), (int)std::ceil( rect.y + bleed)) + - _("-") + wxString::Format(wxT("%i"), (int)std::floor(rect.width)) + - _("-") + wxString::Format(wxT("%i"), (int)std::floor(rect.height)) + - _("-") + wxString::Format(wxT("%i"), degrees) + - _("---"); + return "" + std::to_string((int)std::ceil (rect.x + bleed + img_offset)) + + "-" + std::to_string((int)std::ceil (rect.y + bleed)) + + "-" + std::to_string((int)std::floor(rect.width)) + + "-" + std::to_string((int)std::floor(rect.height)) + + "-" + std::to_string(degrees) + + ""; } /// Does this style have a non-zero size (or is it scripted)? diff --git a/src/data/field/image.cpp b/src/data/field/image.cpp index b2f08127..84a0b121 100644 --- a/src/data/field/image.cpp +++ b/src/data/field/image.cpp @@ -18,17 +18,18 @@ IMPLEMENT_REFLECTION(ImageField) { REFLECT_BASE(Field); } - // ----------------------------------------------------------------------------- : ImageStyle IMPLEMENT_REFLECTION(ImageStyle) { REFLECT_BASE(Style); REFLECT_N("default", default_image); + REFLECT(store_in_metadata); } int ImageStyle::update(Context& ctx) { int changes = Style::update(ctx); changes |= default_image.update(ctx) * CHANGE_DEFAULT; + changes |= store_in_metadata.update(ctx) * CHANGE_OTHER; return changes; } diff --git a/src/data/field/image.hpp b/src/data/field/image.hpp index 686f6a18..0c95d82a 100644 --- a/src/data/field/image.hpp +++ b/src/data/field/image.hpp @@ -10,6 +10,7 @@ #include #include +#include #include