mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Images are now cached as wxBitmap, not wxImage. This should improve performance.
Fixed some more corner cases of rotation+zoom. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@630 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -216,17 +216,17 @@ void ChoiceStyle::initImage() {
|
||||
script.addInstruction(I_RET);
|
||||
}
|
||||
|
||||
bool ChoiceStyle::update(Context& ctx) {
|
||||
int ChoiceStyle::update(Context& ctx) {
|
||||
// Don't update the choice images, leave that to invalidate()
|
||||
bool change = Style ::update(ctx)
|
||||
| font .update(ctx)
|
||||
| mask_filename.update(ctx);
|
||||
int change = Style ::update(ctx)
|
||||
| font .update(ctx) * CHANGE_OTHER
|
||||
| mask_filename.update(ctx) * CHANGE_MASK;
|
||||
if (!choice_images_initialized) {
|
||||
// we only want to do this once because it is rather slow, other updates are handled by dependencies
|
||||
choice_images_initialized = true;
|
||||
FOR_EACH(ci, choice_images) {
|
||||
if (ci.second.update(ctx)) {
|
||||
change = true;
|
||||
change |= CHANGE_OTHER;
|
||||
// TODO : remove this thumbnail
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ void ChoiceStyle::invalidate(Context& ctx) {
|
||||
thumbnails_status[i] = THUMB_CHANGED;
|
||||
}
|
||||
}
|
||||
if (change) tellListeners(false);
|
||||
if (change) tellListeners(CHANGE_OTHER);
|
||||
}
|
||||
|
||||
void ChoiceStyle::loadMask(Package& pkg) {
|
||||
|
||||
@@ -145,7 +145,7 @@ class ChoiceStyle : public Style {
|
||||
ChoicePopupStyle popup_style; ///< Style of popups/menus
|
||||
ChoiceRenderStyle render_style; ///< Style of rendering
|
||||
Font font; ///< Font for drawing text (when RENDER_TEXT)
|
||||
ScriptableImage image; ///< Image to draw (when RENDER_IMAGE)
|
||||
CachedScriptableImage image; ///< Image to draw (when RENDER_IMAGE)
|
||||
map<String,ScriptableImage> choice_images; ///< Images for the various choices (when RENDER_IMAGE)
|
||||
bool choice_images_initialized;
|
||||
Scriptable<String> mask_filename; ///< Filename of an additional mask over the images
|
||||
@@ -163,7 +163,7 @@ class ChoiceStyle : public Style {
|
||||
/// Initialize image from choice_images
|
||||
void initImage();
|
||||
|
||||
virtual bool update(Context&);
|
||||
virtual int update(Context&);
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
virtual void invalidate(Context&);
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ IMPLEMENT_REFLECTION(ColorStyle) {
|
||||
REFLECT_N("mask", mask_filename);
|
||||
}
|
||||
|
||||
bool ColorStyle::update(Context& ctx) {
|
||||
int ColorStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| mask_filename.update(ctx);
|
||||
| mask_filename.update(ctx) * CHANGE_MASK;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorValue
|
||||
|
||||
@@ -66,7 +66,7 @@ class ColorStyle : public Style {
|
||||
double bottom_width; ///< Width of the colored region on the bottom side
|
||||
Scriptable<String> mask_filename; ///< Filename of an additional mask over the images
|
||||
|
||||
virtual bool update(Context&);
|
||||
virtual int update(Context&);
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
@@ -25,14 +25,16 @@ IMPLEMENT_REFLECTION(ImageField) {
|
||||
|
||||
IMPLEMENT_REFLECTION(ImageStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
REFLECT(angle);
|
||||
REFLECT_N("mask", mask_filename);
|
||||
REFLECT_N("default", default_image);
|
||||
}
|
||||
|
||||
bool ImageStyle::update(Context& ctx) {
|
||||
int ImageStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| mask_filename.update(ctx)
|
||||
| default_image.update(ctx);
|
||||
| angle .update(ctx) * CHANGE_OTHER
|
||||
| mask_filename.update(ctx) * CHANGE_MASK
|
||||
| default_image.update(ctx) * CHANGE_DEFAULT;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ImageValue
|
||||
|
||||
@@ -38,10 +38,11 @@ class ImageStyle : public Style {
|
||||
inline ImageStyle(const ImageFieldP& field) : Style(field) {}
|
||||
DECLARE_STYLE_TYPE(Image);
|
||||
|
||||
Scriptable<int> angle; ///< Rotation of images
|
||||
Scriptable<String> mask_filename; ///< Filename for a mask image
|
||||
ScriptableImage default_image; ///< Placeholder
|
||||
|
||||
virtual bool update(Context&);
|
||||
virtual int update(Context&);
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
@@ -40,9 +40,9 @@ InfoStyle::InfoStyle(const InfoFieldP& field)
|
||||
, background_color(255,255,255)
|
||||
{}
|
||||
|
||||
bool InfoStyle::update(Context& ctx) {
|
||||
int InfoStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| font .update(ctx);
|
||||
| font .update(ctx) * CHANGE_OTHER;
|
||||
}
|
||||
void InfoStyle::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
Style ::initDependencies(ctx, dep);
|
||||
|
||||
@@ -51,7 +51,7 @@ class InfoStyle : public Style {
|
||||
double padding_top, padding_bottom;
|
||||
Color background_color;
|
||||
|
||||
virtual bool update(Context&);
|
||||
virtual int update(Context&);
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -68,12 +68,12 @@ double TextStyle::getStretch() const {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
bool TextStyle::update(Context& ctx) {
|
||||
int TextStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| font .update(ctx)
|
||||
| symbol_font.update(ctx)
|
||||
| alignment .update(ctx)
|
||||
| angle .update(ctx);
|
||||
| font .update(ctx) * CHANGE_OTHER
|
||||
| symbol_font.update(ctx) * CHANGE_OTHER
|
||||
| alignment .update(ctx) * CHANGE_OTHER
|
||||
| angle .update(ctx) * CHANGE_OTHER;
|
||||
}
|
||||
void TextStyle::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
Style ::initDependencies(ctx, dep);
|
||||
|
||||
@@ -75,7 +75,7 @@ class TextStyle : public Style {
|
||||
double content_width, content_height; ///< Size of the rendered text
|
||||
int content_lines; ///< Number of rendered lines
|
||||
|
||||
virtual bool update(Context&);
|
||||
virtual int update(Context&);
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
virtual void checkContentDependencies(Context&, const Dependency&) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user