From c476de0fa2127a8729c823a4a9f345d6433a1f30 Mon Sep 17 00:00:00 2001 From: twanvl Date: Wed, 23 Jul 2008 12:39:07 +0000 Subject: [PATCH] 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 --- src/gfx/mask_image.cpp | 1 + src/render/value/color.cpp | 19 ++++++++++--------- src/render/value/image.cpp | 5 ++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/gfx/mask_image.cpp b/src/gfx/mask_image.cpp index 4f6a1d8e..52d34fe5 100644 --- a/src/gfx/mask_image.cpp +++ b/src/gfx/mask_image.cpp @@ -45,6 +45,7 @@ bool AlphaMask::isTransparent(int x, int y) const { 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) { 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; } diff --git a/src/render/value/color.cpp b/src/render/value/color.cpp index ee02675b..daa3bfb5 100644 --- a/src/render/value/color.cpp +++ b/src/render/value/color.cpp @@ -48,7 +48,7 @@ void ColorValueViewer::draw(RotatedDC& dc) { Image img(alpha_mask->size.x, alpha_mask->size.y); fill_image(img, value().value()); alpha_mask->setAlpha(img); - dc.DrawImage(img, style().getPos()); + dc.DrawImage(img, RealPoint(0,0)); } else { // do we need clipping? 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 double left = p.x, right = style().width - p.x - 1; double top = p.y, bottom = style().height - p.y - 1; - if (left < 0 || right < 0 || top < 0 || bottom < 0 || // 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; - } + if (left < 0 || right < 0 || top < 0 || bottom < 0) return false; // outside bounding box // check against mask - if (!style().mask_filename().empty()) { - loadMask(viewer.getRotation()); - return !alpha_mask || !alpha_mask->isTransparent((int)left, (int)top); + if (!style().mask_filename().empty()) loadMask(getRotation()); + if (alpha_mask) { + return !alpha_mask->isTransparent((int)left, (int)top); } 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; } } diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index a5c1f0ba..c12eb028 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -98,9 +98,8 @@ bool ImageValueViewer::containsPoint(const RealPoint& p) const { if (!ValueViewer::containsPoint(p)) return false; // check against mask if (!style().mask_filename().empty()) { - loadMask(viewer.getRotation()); - Rotation rot = viewer.getRotation(); - return !alpha_mask || !alpha_mask->isTransparent((int)rot.trX(p.x), (int)rot.trY(p.y)); + loadMask(getRotation()); + return !alpha_mask || !alpha_mask->isTransparent((int)p.x, (int)p.y); } else { return true; }