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:
@@ -22,46 +22,16 @@ bool ChoiceValueViewer::prepare(RotatedDC& dc) {
|
||||
return prepare_choice_viewer(dc, *this, style(), value().value());
|
||||
}
|
||||
void ChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
int w = max(0,(int)dc.trX(style().width)), h = max(0,(int)dc.trY(style().height));
|
||||
const AlphaMask& alpha_mask = getMask(w,h);
|
||||
drawFieldBorder(dc, alpha_mask);
|
||||
drawFieldBorder(dc);
|
||||
if (style().render_style & RENDER_HIDDEN) return;
|
||||
draw_choice_viewer(dc, *this, style(), value().value());
|
||||
}
|
||||
|
||||
void ChoiceValueViewer::drawFieldBorder(RotatedDC& dc, const AlphaMask& alpha_mask) {
|
||||
if (!alpha_mask.isLoaded()) {
|
||||
ValueViewer::drawFieldBorder(dc);
|
||||
} else if (setFieldBorderPen(dc)) {
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
bool ChoiceValueViewer::containsPoint(const RealPoint& p) const {
|
||||
// check against mask
|
||||
return getMask(0,0).isOpaque(p, style().getSize());
|
||||
}
|
||||
|
||||
void ChoiceValueViewer::onStyleChange(int changes) {
|
||||
if (changes & CHANGE_MASK) style().image.clearCache();
|
||||
ValueViewer::onStyleChange(changes);
|
||||
}
|
||||
|
||||
const AlphaMask& ChoiceValueViewer::getMask(int w, int h) const {
|
||||
GeneratedImage::Options opts;
|
||||
opts.package = &viewer.getStylePackage();
|
||||
opts.local_package = &viewer.getLocalPackage();
|
||||
opts.angle = 0;
|
||||
opts.width = w;
|
||||
opts.height = h;
|
||||
return style().mask.get(opts);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Generic draw/prepare
|
||||
|
||||
bool prepare_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style, const String& value) {
|
||||
|
||||
Reference in New Issue
Block a user