--- gui/buttons/guiBitmapButtonCtrl.cpp	Thu Jan 15 03:14:12 1970
+++ gui/buttons/guiBitmapButtonCtrl.cpp	Thu Jan 15 03:14:12 1970
@@ -282,6 +282,7 @@
             static String s_d = "_d";
             static String s_h = "_h";
             static String s_i = "_i";
+            static String s_m = "_m";
 
             String baseName = mBitmapName;
             if( mUseModifiers )
@@ -305,6 +306,9 @@
                mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXDefaultPersistentProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
                if( !mTextures[ i ].mTextureInactive )
                   mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
+
+               mTextures[ i ].mTextureMask = GFXTexHandle( baseName + s_m, &GFXDefaultPersistentProfile, avar("%s() - mTextureMask (line %d)", __FUNCTION__, __LINE__));
+
             }
 
             if( i == 0 && mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull() )
@@ -327,6 +331,7 @@
          mTextures[ i ].mTextureHilight = NULL;
          mTextures[ i ].mTextureDepressed = NULL;
          mTextures[ i ].mTextureInactive = NULL;
+         mTextures[ i ].mTextureMask = NULL;
       }
    }
    
@@ -466,6 +471,79 @@
       }
    }
 }
+
+//-----------------------------------------------------------------------------
+
+bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
+{
+	GFXTexHandle		*texture	= NULL;
+	GBitmap				*bmp		= NULL;
+	U32					index		= ModifierNone;
+
+
+	/// abort when coordinates aren't even within control rectangle boundaries
+	if(!Parent::pointInControl(parentCoordPoint))
+		return false;
+
+	if(mUseModifiers)
+		index = getCurrentModifier();
+
+	// abort shaped mask hit test if no shape mask image loaded
+	texture = &mTextures[ index ].mTextureMask;
+	if(!texture || !*texture)
+		return true;
+
+	// get shaped mask bitmap, if available, else abort out
+	bmp = texture->getBitmap();
+	if(!bmp)
+		return true; // TODO: shouldn't we report a warning of somekind? --TRON
+
+	/// determine if point in control is hitting shaped mask
+	const RectI		&bounds		= getBounds();
+	S32				xt			= parentCoordPoint.x - bounds.point.x;
+	S32				yt			= parentCoordPoint.y - bounds.point.y;
+	ColorI			rColor(0x00, 0x00, 0x00);
+	ColorI			rMask( 0xFF, 0xFF, 0xFF);
+
+	// correct the test coordinates depending on drawing mode
+	switch (mBitmapMode)
+	{
+		case BitmapStretched:
+		{
+			F32		rw, rh;
+			S32		px			= getExtent().x;
+			S32		py			= getExtent().y;
+
+			// prevent divide by zero
+			if(!px) px = 1;
+			if(!py) py = 1;
+
+			// calculate stretched bitmap ratio
+			rw = (F32)texture->getWidth()  / px;
+			rh = (F32)texture->getHeight() / py;
+
+			// correct the coordinates by ratio
+			xt = (S32)(xt * rw);
+			yt = (S32)(yt * rh);
+			break;
+		}
+
+		case BitmapCentered:
+		{
+			xt -= getExtent().x / 2 - texture->getWidth() / 2;
+			yt -= getExtent().y / 2 - texture->getHeight() / 2;
+			break;
+		}
+	}
+
+	// get pixel color from shaped mask with provided coordinates
+	bmp->getColor(xt, yt, rColor);
+	rColor.alpha = 0xFF;
+
+	// when colors match then the point did hit shaped mask area, else it didn't
+	return (rColor == rMask);
+}
+
 
 //=============================================================================
 //    GuiBitmapButtonTextCtrl.
--- gui/buttons/guiBitmapButtonCtrl.h	Thu Jan 15 03:14:12 1970
+++ gui/buttons/guiBitmapButtonCtrl.h	Thu Jan 15 03:14:12 1970
@@ -22,6 +22,7 @@
 /// append '_h' for highlighted
 /// append '_d' for depressed
 /// append '_i' for inactive
+/// append '_m' for shaped mask
 ///
 /// If a bitmap cannot be found it will use the default bitmap to render.
 ///
@@ -77,6 +78,9 @@
          
          /// Texture for inactive state.
          GFXTexHandle mTextureInactive;
+
+         /// Texture for shaped hitmask.
+         GFXTexHandle mTextureMask;
       };
 
       /// Make control extents equal to bitmap size.
@@ -141,6 +145,11 @@
       virtual void onSleep();
       virtual void onAction();
       virtual void inspectPostApply();
+
+      /// This function will return true if the provided coordinates (wrt parent object) are
+      /// within the bounds of this control
+      /// @param   parentCoordPoint   Coordinates to test
+      virtual bool pointInControl(const Point2I& parentCoordPoint);
 
       virtual void onRender(Point2I offset, const RectI &updateRect);
 
