mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Cleanup: rename ValueViewer::viewer -> parent; store CardP in ValueAction
This commit is contained in:
@@ -36,7 +36,7 @@ bool prepare_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& styl
|
||||
if (style.render_style & RENDER_IMAGE) {
|
||||
style.initImage();
|
||||
CachedScriptableImage& img = style.image;
|
||||
Context& ctx = viewer.viewer.getContext();
|
||||
Context& ctx = viewer.getContext();
|
||||
ctx.setVariable(SCRIPT_VAR_input, to_script(value));
|
||||
// generate to determine the size
|
||||
if (img.update(ctx) && img.isReady()) {
|
||||
@@ -67,7 +67,7 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style,
|
||||
CachedScriptableImage& img = style.image;
|
||||
if (style.content_dependent) {
|
||||
// re run script
|
||||
Context& ctx = viewer.viewer.getContext();
|
||||
Context& ctx = viewer.getContext();
|
||||
ctx.setVariable(SCRIPT_VAR_input, to_script(value));
|
||||
img.update(ctx);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
IMPLEMENT_VALUE_VIEWER(Image);
|
||||
|
||||
void ImageValueViewer::draw(RotatedDC& dc) {
|
||||
DrawWhat what = viewer.drawWhat(this);
|
||||
DrawWhat what = drawWhat();
|
||||
// reset?
|
||||
int w = max(0,(int)dc.trX(style().width)), h = max(0,(int)dc.trY(style().height));
|
||||
Radians a = dc.getAngle();
|
||||
|
||||
@@ -16,16 +16,16 @@ IMPLEMENT_VALUE_VIEWER(Text);
|
||||
|
||||
bool TextValueViewer::prepare(RotatedDC& dc) {
|
||||
getMask(dc); // ensure alpha/contour mask is loaded
|
||||
return v.prepare(dc, value().value(), style(), viewer.getContext());
|
||||
return v.prepare(dc, value().value(), style(), getContext());
|
||||
}
|
||||
|
||||
void TextValueViewer::draw(RotatedDC& dc) {
|
||||
drawFieldBorder(dc);
|
||||
if (!v.prepared()) {
|
||||
v.prepare(dc, value().value(), style(), viewer.getContext());
|
||||
v.prepare(dc, value().value(), style(), getContext());
|
||||
dc.setStretch(getStretch());
|
||||
}
|
||||
DrawWhat what = viewer.drawWhat(this);
|
||||
DrawWhat what = drawWhat();
|
||||
v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE));
|
||||
setFieldBorderPen(dc);
|
||||
v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE));
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
// ----------------------------------------------------------------------------- : ValueViewer
|
||||
|
||||
ValueViewer::ValueViewer(DataViewer& parent, const StyleP& style)
|
||||
: StyleListener(style), viewer(parent)
|
||||
: StyleListener(style), parent(parent)
|
||||
{}
|
||||
|
||||
Package& ValueViewer::getStylePackage() const { return viewer.getStylePackage(); }
|
||||
Package& ValueViewer::getLocalPackage() const { return viewer.getLocalPackage(); }
|
||||
Package& ValueViewer::getStylePackage() const { return parent.getStylePackage(); }
|
||||
Package& ValueViewer::getLocalPackage() const { return parent.getLocalPackage(); }
|
||||
|
||||
void ValueViewer::setValue(const ValueP& value) {
|
||||
assert(value->fieldP == styleP->fieldP); // matching field
|
||||
@@ -53,7 +53,7 @@ Rotation ValueViewer::getRotation() const {
|
||||
|
||||
bool ValueViewer::setFieldBorderPen(RotatedDC& dc) {
|
||||
if (!getField()->editable) return false;
|
||||
DrawWhat what = viewer.drawWhat(this);
|
||||
DrawWhat what = drawWhat();
|
||||
if (!(what & DRAW_BORDERS)) return false;
|
||||
if (what & DRAW_ACTIVE) {
|
||||
dc.SetPen(wxPen(Color(0, 128, 255), 1, wxPENSTYLE_SOLID));
|
||||
@@ -91,20 +91,26 @@ const AlphaMask& ValueViewer::getMask(const Rotation& rot) const {
|
||||
return getMask((int)rot.trX(styleP->width), (int)rot.trY(styleP->height));
|
||||
}
|
||||
|
||||
Context& ValueViewer::getContext() const {
|
||||
return parent.getContext();
|
||||
}
|
||||
|
||||
void ValueViewer::redraw() {
|
||||
viewer.redraw(*this);
|
||||
parent.redraw(*this);
|
||||
}
|
||||
|
||||
bool ValueViewer::nativeLook() const {
|
||||
return viewer.nativeLook();
|
||||
return parent.nativeLook();
|
||||
}
|
||||
DrawWhat ValueViewer::drawWhat() const {
|
||||
return parent.drawWhat(this);
|
||||
}
|
||||
bool ValueViewer::isCurrent() const {
|
||||
return viewer.viewerIsCurrent(this);
|
||||
return parent.viewerIsCurrent(this);
|
||||
}
|
||||
|
||||
void ValueViewer::onStyleChange(int changes) {
|
||||
if (!(changes & CHANGE_ALREADY_PREPARED)) {
|
||||
viewer.redraw(*this);
|
||||
parent.redraw(*this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/rotation.hpp>
|
||||
#include <util/real_point.hpp>
|
||||
#include <data/draw_what.hpp>
|
||||
#include <data/field.hpp>
|
||||
|
||||
class Set;
|
||||
@@ -69,10 +70,11 @@ public:
|
||||
|
||||
/// Convert this viewer to an editor, if possible
|
||||
virtual ValueEditor* getEditor() { return nullptr; }
|
||||
|
||||
DataViewer& viewer; ///< Our parent object
|
||||
|
||||
public:
|
||||
DataViewer& parent; ///< Our parent object
|
||||
protected:
|
||||
ValueP valueP; ///< The value we are currently viewing
|
||||
ValueP valueP; ///< The value we are currently viewing
|
||||
|
||||
/// Set the pen for drawing the border, returns true if a border needs to be drawn
|
||||
bool setFieldBorderPen(RotatedDC& dc);
|
||||
@@ -85,10 +87,15 @@ protected:
|
||||
/// Load the AlphaMask for this field, scaled but not rotated
|
||||
const AlphaMask& getMask(int w = 0, int h = 0) const;
|
||||
const AlphaMask& getMask(const Rotation& rot) const;
|
||||
|
||||
|
||||
public:
|
||||
// Context to use for script functions
|
||||
Context& getContext() const;
|
||||
|
||||
/// Should this viewer render using a platform native look?
|
||||
bool nativeLook() const;
|
||||
/// What elements to draw
|
||||
DrawWhat drawWhat() const;
|
||||
/// Is this the currently selected viewer?
|
||||
/** Usually only the editor allows selection of viewers */
|
||||
bool isCurrent() const;
|
||||
|
||||
Reference in New Issue
Block a user