mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -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:
@@ -10,6 +10,8 @@
|
||||
#include <render/value/viewer.hpp>
|
||||
#include <render/card/viewer.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(wxPoint);
|
||||
|
||||
// ----------------------------------------------------------------------------- : ValueViewer
|
||||
|
||||
ValueViewer::ValueViewer(DataViewer& parent, const StyleP& style)
|
||||
@@ -27,10 +29,7 @@ void ValueViewer::setValue(const ValueP& value) {
|
||||
}
|
||||
|
||||
bool ValueViewer::containsPoint(const RealPoint& p) const {
|
||||
return p.x >= 0
|
||||
&& p.y >= 0
|
||||
&& p.x < styleP->width
|
||||
&& p.y < styleP->height;
|
||||
return getMask().isOpaque(p, styleP->getSize());
|
||||
}
|
||||
RealRect ValueViewer::boundingBox() const {
|
||||
return styleP->getExternalRect().grow(1);
|
||||
@@ -54,10 +53,30 @@ bool ValueViewer::setFieldBorderPen(RotatedDC& dc) {
|
||||
void ValueViewer::drawFieldBorder(RotatedDC& dc) {
|
||||
if (setFieldBorderPen(dc)) {
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(dc.getInternalRect().grow(dc.trInvS(1)));
|
||||
const AlphaMask& alpha_mask = getMask(dc);
|
||||
if (alpha_mask.isLoaded()) {
|
||||
// from mask
|
||||
vector<wxPoint> points;
|
||||
alpha_mask.convexHull(points);
|
||||
if (points.size() < 3) return;
|
||||
FOR_EACH(p, points) p = dc.trPixelNoZoom(RealPoint(p.x,p.y));
|
||||
dc.getDC().DrawPolygon((int)points.size(), &points[0]);
|
||||
} else {
|
||||
// simple rectangle
|
||||
dc.DrawRectangle(dc.getInternalRect().grow(dc.trInvS(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const AlphaMask& ValueViewer::getMask(int w, int h) const {
|
||||
GeneratedImage::Options opts(w, h, &getStylePackage(), &getLocalPackage());
|
||||
return styleP->mask.get(opts);
|
||||
}
|
||||
const AlphaMask& ValueViewer::getMask(const Rotation& rot) const {
|
||||
return getMask((int)rot.trX(styleP->width), (int)rot.trY(styleP->height));
|
||||
}
|
||||
|
||||
|
||||
void ValueViewer::redraw() {
|
||||
viewer.redraw(*this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user