diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index cca39487..490e9337 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -234,6 +234,13 @@ void ChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const { ci.second.initDependencies(ctx, dep); } } +void ChoiceStyle::checkContentDependencies(Context& ctx, const Dependency& dep) const { + Style::checkContentDependencies(ctx, dep); + image.initDependencies(ctx, dep); + FOR_EACH_CONST(ci, choice_images) { + ci.second.initDependencies(ctx, dep); + } +} void ChoiceStyle::invalidate() { // TODO : this is also done in update(), once should be enough // Update choice images and thumbnails diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index 77df9de6..b8299b3f 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -162,6 +162,7 @@ class ChoiceStyle : public Style { virtual int update(Context&); virtual void initDependencies(Context&, const Dependency&) const; + virtual void checkContentDependencies(Context&, const Dependency&) const; virtual void invalidate(); }; diff --git a/src/render/value/choice.cpp b/src/render/value/choice.cpp index 3cb22b21..1664fc9f 100644 --- a/src/render/value/choice.cpp +++ b/src/render/value/choice.cpp @@ -59,6 +59,12 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style, if (style.render_style & RENDER_IMAGE) { // draw image CachedScriptableImage& img = style.image; + if (style.content_dependent) { + // re run script + Context& ctx = viewer.viewer.getContext(); + ctx.setVariable(SCRIPT_VAR_input, to_script(value)); + img.update(ctx); + } if (img.isReady()) { GeneratedImage::Options img_options; get_options(dc, viewer, style, img_options); diff --git a/src/render/value/multiple_choice.cpp b/src/render/value/multiple_choice.cpp index b7db7c21..1afad23c 100644 --- a/src/render/value/multiple_choice.cpp +++ b/src/render/value/multiple_choice.cpp @@ -82,3 +82,8 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const // next position pos = move_in_direction(style().direction, pos, size, style().spacing); } + +void MultipleChoiceValueViewer::onStyleChange(int changes) { + if (changes & CHANGE_MASK) style().image.clearCache(); + ValueViewer::onStyleChange(changes); +} diff --git a/src/render/value/multiple_choice.hpp b/src/render/value/multiple_choice.hpp index 3678363d..8efadf1c 100644 --- a/src/render/value/multiple_choice.hpp +++ b/src/render/value/multiple_choice.hpp @@ -22,6 +22,7 @@ class MultipleChoiceValueViewer : public ValueViewer { virtual bool prepare(RotatedDC& dc); virtual void draw(RotatedDC& dc); + virtual void onStyleChange(int); protected: double item_height; ///< Height of a single item, or 0 if non uniform private: