Commit a2fa93d5 authored by Erwan Tulou's avatar Erwan Tulou

skins2(Linux and Win): fix transparency issue at window level

When refreshing a window area, the window mask must first be stripped of this
 area, because the new refresh may not result in the same mask being applied.

This patch corrects the following issues :
- an animated bitmap with transparency varying from one subimage to the next
  is now guaranteed the previous subimage won't leave any trace.
- a control that becomes invisible now means transparency is restored
 if no other controls exist for the same area (instead of an undefined and visually unpleasant area)
parent f980341b
......@@ -205,6 +205,9 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
if( !m_visible )
return;
// update the transparency global mask
m_pImage->clear( x, y, width, height );
// Draw all the controls of the layout
list<LayeredControl>::const_iterator iter;
list<LayeredControl>::const_iterator iterVideo = m_controlList.end();
......
......@@ -40,7 +40,8 @@ public:
virtual ~OSGraphics() { }
/// Clear the graphics
virtual void clear() = 0;
virtual void clear( int xDest = 0, int yDest = 0,
int width = -1, int height = -1) = 0;
/// Draw another graphics on this one
virtual void drawGraphics( const OSGraphics &rGraphics, int xSrc = 0,
......
......@@ -59,11 +59,20 @@ Win32Graphics::~Win32Graphics()
}
void Win32Graphics::clear()
void Win32Graphics::clear( int xDest, int yDest, int width, int height )
{
if( width <= 0 || height <= 0 )
{
// Clear the transparency mask
DeleteObject( m_mask );
m_mask = CreateRectRgn( 0, 0, 0, 0 );
}
else
{
HRGN mask = CreateRectRgn( xDest, yDest,
xDest + width, yDest + height );
CombineRgn( m_mask, m_mask, mask, RGN_DIFF );
}
}
......
......@@ -39,7 +39,8 @@ public:
virtual ~Win32Graphics();
/// Clear the graphics
virtual void clear();
virtual void clear( int xDest = 0, int yDest = 0,
int width = -1, int height = -1 );
/// Render a bitmap on this graphics
virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
......
......@@ -73,11 +73,27 @@ X11Graphics::~X11Graphics()
}
void X11Graphics::clear()
void X11Graphics::clear( int xDest, int yDest, int width, int height )
{
// Clear the transparency mask
if( width <= 0 || height <= 0 )
{
// Clear the transparency mask completely
XDestroyRegion( m_mask );
m_mask = XCreateRegion();
}
else
{
// remove this area from the mask
XRectangle rect;
rect.x = xDest;
rect.y = yDest;
rect.width = width;
rect.height = height;
Region regMask = XCreateRegion();
XUnionRectWithRegion( &rect, regMask, regMask );
XSubtractRegion( m_mask, regMask, m_mask );
XDestroyRegion( regMask );
}
}
......
......@@ -44,7 +44,8 @@ public:
virtual ~X11Graphics();
/// Clear the graphics
virtual void clear();
virtual void clear( int xDest = 0, int yDest = 0,
int width = -1, int height = -1 );
/// Draw another graphics on this one
virtual void drawGraphics( const OSGraphics &rGraphics, int xSrc = 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment