Commit 4c0d53cb authored by twanvl's avatar twanvl

Content dependent scripted images of (multiple) choice values are now updated correctly

parent 4adf0c46
...@@ -234,6 +234,13 @@ void ChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const { ...@@ -234,6 +234,13 @@ void ChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const {
ci.second.initDependencies(ctx, dep); 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() { void ChoiceStyle::invalidate() {
// TODO : this is also done in update(), once should be enough // TODO : this is also done in update(), once should be enough
// Update choice images and thumbnails // Update choice images and thumbnails
......
...@@ -162,6 +162,7 @@ class ChoiceStyle : public Style { ...@@ -162,6 +162,7 @@ class ChoiceStyle : public Style {
virtual int update(Context&); virtual int update(Context&);
virtual void initDependencies(Context&, const Dependency&) const; virtual void initDependencies(Context&, const Dependency&) const;
virtual void checkContentDependencies(Context&, const Dependency&) const;
virtual void invalidate(); virtual void invalidate();
}; };
......
...@@ -59,6 +59,12 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style, ...@@ -59,6 +59,12 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style,
if (style.render_style & RENDER_IMAGE) { if (style.render_style & RENDER_IMAGE) {
// draw image // draw image
CachedScriptableImage& img = style.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()) { if (img.isReady()) {
GeneratedImage::Options img_options; GeneratedImage::Options img_options;
get_options(dc, viewer, style, img_options); get_options(dc, viewer, style, img_options);
......
...@@ -82,3 +82,8 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const ...@@ -82,3 +82,8 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
// next position // next position
pos = move_in_direction(style().direction, pos, size, style().spacing); 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);
}
...@@ -22,6 +22,7 @@ class MultipleChoiceValueViewer : public ValueViewer { ...@@ -22,6 +22,7 @@ class MultipleChoiceValueViewer : public ValueViewer {
virtual bool prepare(RotatedDC& dc); virtual bool prepare(RotatedDC& dc);
virtual void draw(RotatedDC& dc); virtual void draw(RotatedDC& dc);
virtual void onStyleChange(int);
protected: protected:
double item_height; ///< Height of a single item, or 0 if non uniform double item_height; ///< Height of a single item, or 0 if non uniform
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment