mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Moved mask to Style and mask related drawing to ValueViewer.
Used the same mask also for TextStyles. To keep the text selectable (since the mask is now also used for containsPoint), the future sight cost masks needed to be updated. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1183 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+9
-6
@@ -118,6 +118,7 @@ IMPLEMENT_REFLECTION(Style) {
|
||||
REFLECT(bottom);
|
||||
REFLECT(angle);
|
||||
REFLECT(visible);
|
||||
REFLECT(mask);
|
||||
}
|
||||
|
||||
void init_object(const FieldP& field, StyleP& style) {
|
||||
@@ -135,15 +136,16 @@ inline bool is_setw(const Scriptable<double>& x) {
|
||||
}
|
||||
|
||||
int Style::update(Context& ctx) {
|
||||
bool changed =
|
||||
left .update(ctx)
|
||||
int changed =
|
||||
( left .update(ctx)
|
||||
| width .update(ctx)
|
||||
| right .update(ctx)
|
||||
| top .update(ctx)
|
||||
| height .update(ctx)
|
||||
| bottom .update(ctx)
|
||||
| angle .update(ctx)
|
||||
| visible.update(ctx);
|
||||
| angle .update(ctx) ) * CHANGE_SIZE
|
||||
| visible.update(ctx) * CHANGE_OTHER
|
||||
| mask .update(ctx) * CHANGE_MASK;
|
||||
// determine automatic_side and attachment of rotation point
|
||||
if (automatic_side == AUTO_UNKNOWN) {
|
||||
if (!is_set (right)) automatic_side = (AutomaticSide)(automatic_side | AUTO_RIGHT);
|
||||
@@ -154,7 +156,7 @@ int Style::update(Context& ctx) {
|
||||
else if (!is_setw(height)) automatic_side = (AutomaticSide)(automatic_side | AUTO_HEIGHT);
|
||||
else if (!is_set (top)) automatic_side = (AutomaticSide)(automatic_side | AUTO_TOP);
|
||||
else automatic_side = (AutomaticSide)(automatic_side | AUTO_TB);
|
||||
changed = true;
|
||||
changed |= CHANGE_SIZE;
|
||||
}
|
||||
if (!changed) return CHANGE_NONE;
|
||||
// update the automatic_side
|
||||
@@ -181,7 +183,7 @@ int Style::update(Context& ctx) {
|
||||
if (width < 0) width = -width;
|
||||
if (height < 0) height = -height;
|
||||
// done
|
||||
return CHANGE_OTHER;
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool Style::isVisible() const {
|
||||
@@ -214,6 +216,7 @@ void Style::checkContentDependencies(Context& ctx, const Dependency& dep) const
|
||||
right .initDependencies(ctx,dep);
|
||||
bottom .initDependencies(ctx,dep);
|
||||
visible.initDependencies(ctx,dep);
|
||||
mask .initDependencies(ctx,dep);
|
||||
}
|
||||
|
||||
void Style::markDependencyMember(const String& name, const Dependency& dep) const {
|
||||
|
||||
+14
-9
@@ -16,6 +16,7 @@
|
||||
#include <util/rotation.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
#include <script/dependency.hpp>
|
||||
#include <script/image.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Style);
|
||||
@@ -94,13 +95,16 @@ class Style : public IntrusivePtrVirtualBase {
|
||||
Style(const FieldP&);
|
||||
virtual ~Style();
|
||||
|
||||
const FieldP fieldP; ///< Field this style is for, should have the right type!
|
||||
int z_index; ///< Stacking of values of this field, higher = on top
|
||||
Scriptable<double> left, top; ///< Position of this field
|
||||
Scriptable<double> width, height; ///< Position of this field
|
||||
Scriptable<double> right, bottom; ///< Position of this field
|
||||
Scriptable<int> angle; ///< Rotation of the box
|
||||
Scriptable<bool> visible; ///< Is this field visible?
|
||||
const FieldP fieldP; ///< Field this style is for, should have the right type!
|
||||
|
||||
int z_index; ///< Stacking of values of this field, higher = on top
|
||||
Scriptable<double> left, top; ///< Position of this field
|
||||
Scriptable<double> width, height; ///< Position of this field
|
||||
Scriptable<double> right, bottom; ///< Position of this field
|
||||
Scriptable<int> angle; ///< Rotation of the box
|
||||
Scriptable<bool> visible; ///< Is this field visible?
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
|
||||
enum AutomaticSide {
|
||||
AUTO_UNKNOWN = 0x00,
|
||||
AUTO_LEFT = 0x01, AUTO_WIDTH = 0x02, AUTO_RIGHT = 0x04, AUTO_LR = 0x08,
|
||||
@@ -166,8 +170,9 @@ class Style : public IntrusivePtrVirtualBase {
|
||||
enum StyleChange
|
||||
{ CHANGE_NONE = 0x00 // nothing changed
|
||||
, CHANGE_OTHER = 0x01 // some other change (note: result of casting from bool)
|
||||
, CHANGE_DEFAULT = 0x02 // only the 'default' state is affected
|
||||
, CHANGE_MASK = 0x04 // a mask image changed, must be reloaded
|
||||
, CHANGE_SIZE = 0x02 // size/angle changed
|
||||
, CHANGE_DEFAULT = 0x04 // only the 'default' state is affected
|
||||
, CHANGE_MASK = 0x08 // a mask image changed, must be reloaded
|
||||
, CHANGE_ALREADY_PREPARED = 0x80 // hint that the change was the result of a content property change, viewers are already prepared
|
||||
};
|
||||
|
||||
|
||||
@@ -213,9 +213,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
|
||||
| mask .update(ctx) * CHANGE_MASK;
|
||||
int change = Style::update(ctx)
|
||||
| font .update(ctx) * CHANGE_OTHER;
|
||||
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;
|
||||
@@ -283,7 +282,6 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
REFLECT(popup_style);
|
||||
REFLECT(render_style);
|
||||
REFLECT(mask);
|
||||
REFLECT(combine);
|
||||
REFLECT(alignment);
|
||||
REFLECT(font);
|
||||
|
||||
@@ -146,7 +146,6 @@ class ChoiceStyle : public Style {
|
||||
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;
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
ImageCombine combine; ///< Combining mode for drawing the images
|
||||
Alignment alignment; ///< Alignment of images
|
||||
wxImageList* thumbnails; ///< Thumbnails for the choices
|
||||
|
||||
@@ -62,13 +62,11 @@ IMPLEMENT_REFLECTION(ColorStyle) {
|
||||
REFLECT(right_width);
|
||||
REFLECT(top_width);
|
||||
REFLECT(bottom_width);
|
||||
REFLECT(mask);
|
||||
REFLECT(combine);
|
||||
}
|
||||
|
||||
int ColorStyle::update(Context& ctx) {
|
||||
return Style::update(ctx)
|
||||
| mask.update(ctx) * CHANGE_MASK;
|
||||
return Style::update(ctx);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorValue
|
||||
|
||||
@@ -57,13 +57,12 @@ 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
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
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
|
||||
ImageCombine combine; ///< How to combine image with the background
|
||||
|
||||
virtual int update(Context&);
|
||||
};
|
||||
|
||||
@@ -23,13 +23,11 @@ IMPLEMENT_REFLECTION(ImageField) {
|
||||
|
||||
IMPLEMENT_REFLECTION(ImageStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
REFLECT(mask);
|
||||
REFLECT_N("default", default_image);
|
||||
}
|
||||
|
||||
int ImageStyle::update(Context& ctx) {
|
||||
return Style ::update(ctx)
|
||||
| mask .update(ctx) * CHANGE_MASK
|
||||
| default_image.update(ctx) * CHANGE_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ class ImageStyle : public Style {
|
||||
inline ImageStyle(const ImageFieldP& field) : Style(field) {}
|
||||
DECLARE_STYLE_TYPE(Image);
|
||||
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
ScriptableImage default_image; ///< Placeholder
|
||||
ScriptableImage default_image; ///< Placeholder
|
||||
|
||||
virtual int update(Context&);
|
||||
};
|
||||
|
||||
@@ -111,7 +111,6 @@ IMPLEMENT_REFLECTION(TextStyle) {
|
||||
REFLECT(line_height_hard_max);
|
||||
REFLECT(line_height_line_max);
|
||||
REFLECT(paragraph_height);
|
||||
REFLECT_N("mask", mask_filename);
|
||||
REFLECT(direction);
|
||||
reflect_content(tag, *this);
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ class TextStyle : public Style {
|
||||
double line_height_hard_max; ///< Maximum line height
|
||||
double line_height_line_max; ///< Maximum line height
|
||||
double paragraph_height; ///< Fixed height of paragraphs
|
||||
String mask_filename; ///< Filename of the mask
|
||||
AlphaMask mask; ///< Mask to fit the text to (may be null)
|
||||
Direction direction; ///< In what direction is text layed out?
|
||||
// information from text rendering
|
||||
double content_width, content_height; ///< Size of the rendered text
|
||||
|
||||
Reference in New Issue
Block a user