Commit 0860db16 authored by twanvl's avatar twanvl

use ->toImage() instead of image_from_script function.

parent f3aac625
...@@ -183,7 +183,7 @@ void DropDownChoiceListBase::generateThumbnailImages() { ...@@ -183,7 +183,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
try { try {
String name = canonical_name_form(field().choices->choiceName(i)); String name = canonical_name_form(field().choices->choiceName(i));
ctx.setVariable(_("input"), to_script(name)); ctx.setVariable(_("input"), to_script(name));
GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx)); GeneratedImageP img = style().image.getValidScriptP()->eval(ctx)->toImage();
style().choice_images.insert(make_pair(name, ScriptableImage(img))); style().choice_images.insert(make_pair(name, ScriptableImage(img)));
} catch (const Error& e) { } catch (const Error& e) {
handle_error(Error(e.what() + _("\n while generating choice images for drop down list"))); handle_error(Error(e.what() + _("\n while generating choice images for drop down list")));
......
...@@ -421,7 +421,7 @@ SCRIPT_FUNCTION(write_image_file) { ...@@ -421,7 +421,7 @@ SCRIPT_FUNCTION(write_image_file) {
if (card) { if (card) {
image = conform_image(export_bitmap(ei.set, card->getValue()).ConvertToImage(), options); image = conform_image(export_bitmap(ei.set, card->getValue()).ConvertToImage(), options);
} else { } else {
image = image_from_script(input)->generateConform(options); image = input->toImage()->generateConform(options);
} }
if (!image.Ok()) throw Error(_("Unable to generate image for file ") + file); if (!image.Ok()) throw Error(_("Unable to generate image for file ") + file);
// write // write
......
...@@ -25,10 +25,6 @@ void parse_enum(const String&, ImageCombine& out); ...@@ -25,10 +25,6 @@ void parse_enum(const String&, ImageCombine& out);
// ----------------------------------------------------------------------------- : Utility // ----------------------------------------------------------------------------- : Utility
template <> inline GeneratedImageP from_script<GeneratedImageP>(const ScriptValueP& value) {
return image_from_script(value);
}
SCRIPT_FUNCTION(to_image) { SCRIPT_FUNCTION(to_image) {
SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM_C(GeneratedImageP, input);
return input; return input;
...@@ -156,7 +152,7 @@ SCRIPT_FUNCTION(symbol_variation) { ...@@ -156,7 +152,7 @@ SCRIPT_FUNCTION(symbol_variation) {
} else if (valueO) { } else if (valueO) {
throw ScriptErrorConversion(valueO->typeName(), _TYPE_("symbol" )); throw ScriptErrorConversion(valueO->typeName(), _TYPE_("symbol" ));
} else { } else {
filename = from_script<String>(symbol); filename = symbol->toString();
} }
// known variation? // known variation?
SCRIPT_OPTIONAL_PARAM_(String, variation) SCRIPT_OPTIONAL_PARAM_(String, variation)
......
...@@ -15,13 +15,6 @@ ...@@ -15,13 +15,6 @@
#include <gfx/generated_image.hpp> #include <gfx/generated_image.hpp>
#include <data/field/image.hpp> #include <data/field/image.hpp>
// ----------------------------------------------------------------------------- : Utility
// convert any script value to a GeneratedImageP
GeneratedImageP image_from_script(const ScriptValueP& value) {
return value->toImage();
}
// ----------------------------------------------------------------------------- : ScriptableImage // ----------------------------------------------------------------------------- : ScriptableImage
Image ScriptableImage::generate(const GeneratedImage::Options& options) const { Image ScriptableImage::generate(const GeneratedImage::Options& options) const {
...@@ -50,7 +43,7 @@ ImageCombine ScriptableImage::combine() const { ...@@ -50,7 +43,7 @@ ImageCombine ScriptableImage::combine() const {
bool ScriptableImage::update(Context& ctx) { bool ScriptableImage::update(Context& ctx) {
if (!isScripted()) return false; if (!isScripted()) return false;
GeneratedImageP new_value = image_from_script(script.invoke(ctx)); GeneratedImageP new_value = script.invoke(ctx)->toImage();
if (!new_value || !value || *new_value != *value) { if (!new_value || !value || *new_value != *value) {
value = new_value; value = new_value;
return true; return true;
......
...@@ -71,9 +71,6 @@ class ScriptableImage { ...@@ -71,9 +71,6 @@ class ScriptableImage {
/// Missing for now /// Missing for now
inline ScriptValueP to_script(const ScriptableImage&) { return script_nil; } inline ScriptValueP to_script(const ScriptableImage&) { return script_nil; }
/// Convert a script value to a GeneratedImageP
GeneratedImageP image_from_script(const ScriptValueP& value);
// ----------------------------------------------------------------------------- : CachedScriptableImage // ----------------------------------------------------------------------------- : CachedScriptableImage
/// A version of ScriptableImage that does caching /// A version of ScriptableImage that does caching
......
...@@ -429,6 +429,7 @@ template <> inline bool from_script<bool> (const ScriptValueP& va ...@@ -429,6 +429,7 @@ template <> inline bool from_script<bool> (const ScriptValueP& va
template <> inline Color from_script<Color> (const ScriptValueP& value) { return value->toColor(); } template <> inline Color from_script<Color> (const ScriptValueP& value) { return value->toColor(); }
template <> inline AColor from_script<AColor> (const ScriptValueP& value) { return value->toColor(); } template <> inline AColor from_script<AColor> (const ScriptValueP& value) { return value->toColor(); }
template <> inline wxDateTime from_script<wxDateTime> (const ScriptValueP& value) { return value->toDateTime(); } template <> inline wxDateTime from_script<wxDateTime> (const ScriptValueP& value) { return value->toDateTime(); }
template <> inline GeneratedImageP from_script<GeneratedImageP>(const ScriptValueP& value) { return value->toImage(); }
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
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