mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
Fixed: containsPoint for color and image value viewers. They used the wrong Rotation.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1029 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -45,6 +45,7 @@ bool AlphaMask::isTransparent(int x, int y) const {
|
|||||||
return alpha[x + y * size.x] < 20;
|
return alpha[x + y * size.x] < 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Do the points form a (counter??)clockwise angle?
|
||||||
bool convex(const wxPoint& p, const wxPoint& q, const wxPoint& r) {
|
bool convex(const wxPoint& p, const wxPoint& q, const wxPoint& r) {
|
||||||
return p.y*q.x - p.x*q.y - p.y*r.x + q.y*r.x + p.x*r.y - q.x*r.y > 0;
|
return p.y*q.x - p.x*q.y - p.y*r.x + q.y*r.x + p.x*r.y - q.x*r.y > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void ColorValueViewer::draw(RotatedDC& dc) {
|
|||||||
Image img(alpha_mask->size.x, alpha_mask->size.y);
|
Image img(alpha_mask->size.x, alpha_mask->size.y);
|
||||||
fill_image(img, value().value());
|
fill_image(img, value().value());
|
||||||
alpha_mask->setAlpha(img);
|
alpha_mask->setAlpha(img);
|
||||||
dc.DrawImage(img, style().getPos());
|
dc.DrawImage(img, RealPoint(0,0));
|
||||||
} else {
|
} else {
|
||||||
// do we need clipping?
|
// do we need clipping?
|
||||||
bool clip = style().left_width < style().width && style().right_width < style().width &&
|
bool clip = style().left_width < style().width && style().right_width < style().width &&
|
||||||
@@ -74,16 +74,17 @@ bool ColorValueViewer::containsPoint(const RealPoint& p) const {
|
|||||||
// distance to each side
|
// distance to each side
|
||||||
double left = p.x, right = style().width - p.x - 1;
|
double left = p.x, right = style().width - p.x - 1;
|
||||||
double top = p.y, bottom = style().height - p.y - 1;
|
double top = p.y, bottom = style().height - p.y - 1;
|
||||||
if (left < 0 || right < 0 || top < 0 || bottom < 0 || // outside bounding box
|
if (left < 0 || right < 0 || top < 0 || bottom < 0) return false; // outside bounding box
|
||||||
(left >= style().left_width && right >= style().right_width && // outside horizontal border
|
|
||||||
top >= style().top_width && bottom >= style().bottom_width)) { // outside vertical border
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// check against mask
|
// check against mask
|
||||||
if (!style().mask_filename().empty()) {
|
if (!style().mask_filename().empty()) loadMask(getRotation());
|
||||||
loadMask(viewer.getRotation());
|
if (alpha_mask) {
|
||||||
return !alpha_mask || !alpha_mask->isTransparent((int)left, (int)top);
|
return !alpha_mask->isTransparent((int)left, (int)top);
|
||||||
} else {
|
} else {
|
||||||
|
// check against border
|
||||||
|
if (left >= style().left_width && right >= style().right_width && // outside horizontal border
|
||||||
|
top >= style().top_width && bottom >= style().bottom_width) { // outside vertical border
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,9 +98,8 @@ bool ImageValueViewer::containsPoint(const RealPoint& p) const {
|
|||||||
if (!ValueViewer::containsPoint(p)) return false;
|
if (!ValueViewer::containsPoint(p)) return false;
|
||||||
// check against mask
|
// check against mask
|
||||||
if (!style().mask_filename().empty()) {
|
if (!style().mask_filename().empty()) {
|
||||||
loadMask(viewer.getRotation());
|
loadMask(getRotation());
|
||||||
Rotation rot = viewer.getRotation();
|
return !alpha_mask || !alpha_mask->isTransparent((int)p.x, (int)p.y);
|
||||||
return !alpha_mask || !alpha_mask->isTransparent((int)rot.trX(p.x), (int)rot.trY(p.y));
|
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user