From 5f1d1c58889811b7b2368e2dd957d4c48d3ca4d1 Mon Sep 17 00:00:00 2001 From: spx Date: Sun, 21 Jul 2013 19:46:13 +0900 Subject: [PATCH] Fixed hittest of Button meter due to lack of compatibility with new "Padding" option --- Library/MeterButton.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index 69db10b5..190f1297 100644 --- a/Library/MeterButton.cpp +++ b/Library/MeterButton.cpp @@ -229,11 +229,19 @@ bool MeterButton::HitTest2(int px, int py) // Check transparent pixels if (m_Image.IsLoaded()) { - Color color; - Status status = m_Image.GetImage()->GetPixel(px - x + m_W * m_State, py - y, &color); - if (status != Ok || color.GetA() != 0) + Rect meterRect = GetMeterRectPadding(); + int ix = meterRect.Width * m_State; + px = px - meterRect.X + ix; + py = py - meterRect.Y; + if (px >= ix && px < ix + meterRect.Width && + py >= 0 && py < meterRect.Height) { - return true; + Color color; + Status status = m_Image.GetImage()->GetPixel(px, py, &color); + if (status != Ok || color.GetA() != 0) + { + return true; + } } } else