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:
twanvl
2008-08-30 23:49:12 +00:00
parent a183ecc9a6
commit a2af3211a4
28 changed files with 105 additions and 214 deletions
+1 -29
View File
@@ -74,31 +74,13 @@ void ImageValueViewer::draw(RotatedDC& dc) {
}
}
// border
drawFieldBorder(dc, alpha_mask);
drawFieldBorder(dc);
// draw image, if any
if (bitmap.Ok()) {
dc.DrawPreRotatedBitmap(bitmap, dc.getInternalRect());
}
}
void ImageValueViewer::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 ImageValueViewer::containsPoint(const RealPoint& p) const {
// check against mask
return getMask(0,0).isOpaque(p, style().getSize());
}
void ImageValueViewer::onValueChange() {
bitmap = Bitmap();
}
@@ -111,16 +93,6 @@ void ImageValueViewer::onStyleChange(int changes) {
ValueViewer::onStyleChange(changes);
}
const AlphaMask& ImageValueViewer::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);
}
// is an image very light?
bool very_light(const Image& image) {
int w = image.GetWidth(), h = image.GetHeight();