mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
New class CachedScriptableMask: like CachedScriptableImage, only containing an AlphaMask instead of an Image/Bitmap.
Use CachedScriptableMask for all masks. TODO: This introduces some duplicate code in ValueViewers that could be fixed by moving mask to the Style base class. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1182 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -214,11 +214,8 @@ void ChoiceStyle::initImage() {
|
||||
int ChoiceStyle::update(Context& ctx) {
|
||||
// Don't update the choice images, leave that to invalidate()
|
||||
int change = Style ::update(ctx)
|
||||
| font .update(ctx) * CHANGE_OTHER;
|
||||
if (mask_filename.update(ctx)) {
|
||||
change |= CHANGE_MASK;
|
||||
mask = Image();
|
||||
}
|
||||
| font .update(ctx) * CHANGE_OTHER
|
||||
| mask .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;
|
||||
@@ -255,13 +252,6 @@ void ChoiceStyle::invalidate() {
|
||||
tellListeners(CHANGE_OTHER);
|
||||
}
|
||||
|
||||
void ChoiceStyle::loadMask(Package& pkg) {
|
||||
if (mask.Ok() || mask_filename().empty()) return;
|
||||
// load file
|
||||
InputStreamP image_file = pkg.openIn(mask_filename);
|
||||
mask.LoadFile(*image_file);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(ChoicePopupStyle) {
|
||||
VALUE_N("dropdown", POPUP_DROPDOWN);
|
||||
VALUE_N("menu", POPUP_MENU);
|
||||
@@ -293,7 +283,7 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
REFLECT(popup_style);
|
||||
REFLECT(render_style);
|
||||
REFLECT_N("mask",mask_filename);
|
||||
REFLECT(mask);
|
||||
REFLECT(combine);
|
||||
REFLECT(alignment);
|
||||
REFLECT(font);
|
||||
|
||||
@@ -143,20 +143,17 @@ 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)
|
||||
CachedScriptableImage 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
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
ImageCombine combine; ///< Combining mode for drawing the images
|
||||
Alignment alignment; ///< Alignment of images
|
||||
Image mask; ///< The actual mask image
|
||||
wxImageList* thumbnails; ///< Thumbnails for the choices
|
||||
vector<ThumbnailStatus> thumbnails_status; ///< Which thumbnails are up to date?
|
||||
vector<ThumbnailStatus> thumbnails_status; ///< Which thumbnails are up to date?
|
||||
// information from image rendering
|
||||
double content_width, content_height; ///< Size of the rendered image/text
|
||||
|
||||
/// Load the mask image, if it's not already done
|
||||
void loadMask(Package& pkg);
|
||||
/// Initialize image from choice_images
|
||||
void initImage();
|
||||
|
||||
|
||||
@@ -62,13 +62,13 @@ IMPLEMENT_REFLECTION(ColorStyle) {
|
||||
REFLECT(right_width);
|
||||
REFLECT(top_width);
|
||||
REFLECT(bottom_width);
|
||||
REFLECT_N("mask", mask_filename);
|
||||
REFLECT(mask);
|
||||
REFLECT(combine);
|
||||
}
|
||||
|
||||
int ColorStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| mask_filename.update(ctx) * CHANGE_MASK;
|
||||
return Style::update(ctx)
|
||||
| mask.update(ctx) * CHANGE_MASK;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorValue
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <util/defaultable.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
#include <script/image.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorField
|
||||
|
||||
@@ -56,13 +57,13 @@ class ColorStyle : public Style {
|
||||
ColorStyle(const ColorFieldP& field);
|
||||
DECLARE_STYLE_TYPE(Color);
|
||||
|
||||
double radius; ///< Radius of round corners
|
||||
double left_width; ///< Width of the colored region on the left side
|
||||
double right_width; ///< Width of the colored region on the right side
|
||||
double top_width; ///< Width of the colored region on the top side
|
||||
double bottom_width; ///< Width of the colored region on the bottom side
|
||||
Scriptable<String> mask_filename; ///< Filename of an additional mask over the images
|
||||
ImageCombine combine; ///< How to combine image with the background
|
||||
double radius; ///< Radius of round corners
|
||||
double left_width; ///< Width of the colored region on the left side
|
||||
double right_width; ///< Width of the colored region on the right side
|
||||
double top_width; ///< Width of the colored region on the top side
|
||||
double bottom_width; ///< Width of the colored region on the bottom side
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
ImageCombine combine; ///< How to combine image with the background
|
||||
|
||||
virtual int update(Context&);
|
||||
};
|
||||
|
||||
@@ -23,13 +23,13 @@ IMPLEMENT_REFLECTION(ImageField) {
|
||||
|
||||
IMPLEMENT_REFLECTION(ImageStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
REFLECT_N("mask", mask_filename);
|
||||
REFLECT(mask);
|
||||
REFLECT_N("default", default_image);
|
||||
}
|
||||
|
||||
int ImageStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| mask_filename.update(ctx) * CHANGE_MASK
|
||||
| mask .update(ctx) * CHANGE_MASK
|
||||
| default_image.update(ctx) * CHANGE_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ class ImageStyle : public Style {
|
||||
inline ImageStyle(const ImageFieldP& field) : Style(field) {}
|
||||
DECLARE_STYLE_TYPE(Image);
|
||||
|
||||
Scriptable<String> mask_filename; ///< Filename for a mask image
|
||||
ScriptableImage default_image; ///< Placeholder
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
ScriptableImage default_image; ///< Placeholder
|
||||
|
||||
virtual int update(Context&);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user