#include "top_window.hpp"
#include "os_factory.hpp"
#include "os_graphics.hpp"
+#include "var_manager.hpp"
+#include "anchor.hpp"
#include "../controls/ctrl_generic.hpp"
#include "../controls/ctrl_video.hpp"
+#include "../utils/var_bool.hpp"
GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
int minWidth, int maxWidth, int minHeight,
int maxHeight ):
- SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ),
- m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ),
+ SkinObject( pIntf ), m_pWindow( NULL ), m_rect( 0, 0, width, height ),
+ m_minWidth( minWidth ), m_maxWidth( maxWidth ),
m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ),
- m_visible( false )
+ m_visible( false ), m_pVarActive( NULL )
{
// Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Create the graphics buffer
m_pImage = pOsFactory->createOSGraphics( width, height );
+
+ // Create the "active layout" variable and register it in the manager
+ m_pVarActive = new VarBoolImpl( pIntf );
+ VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarActive ) );
}
{
delete m_pImage;
}
+ list<Anchor*>::const_iterator it;
+ for( it = m_anchorList.begin(); it != m_anchorList.end(); it++ )
+ {
+ delete *it;
+ }
}
pControl->draw( *m_pImage, rPosition.getLeft(), rPosition.getTop() );
// Add the control in the list.
- // This list must remain sorted by layer order
+ // This list must remain sorted by layer order
list<LayeredControl>::iterator it;
for( it = m_controlList.begin(); it != m_controlList.end(); it++ )
{
void GenericLayout::resize( int width, int height )
{
- // Check boundaries
- if( width < m_minWidth )
- {
- width = m_minWidth;
- }
- if( width > m_maxWidth )
- {
- width = m_maxWidth;
- }
- if( height < m_minHeight )
- {
- height = m_minHeight;
- }
- if( height > m_maxHeight )
- {
- height = m_maxHeight;
- }
-
- if( width == m_width && height == m_height )
- {
- return;
- }
-
// Update the window size
- m_width = width;
- m_height = height;
+ m_rect = SkinsRect( 0, 0 , width, height );
// Recreate a new image
if( m_pImage )
for( iter = m_controlList.begin(); iter != m_controlList.end(); iter++ )
{
iter->m_pControl->onResize();
- const Position *pPos = iter->m_pControl->getPosition();
- if( pPos && iter->m_pControl->isVisible() )
- {
- iter->m_pControl->draw( *m_pImage, pPos->getLeft(),
- pPos->getTop() );
- }
}
// Resize and refresh the associated window
if( pWindow )
{
// Resize the window
- pWindow->refresh( 0, 0, width, height );
pWindow->resize( width, height );
- pWindow->refresh( 0, 0, width, height );
+ refreshAll();
// Change the shape of the window and redraw it
pWindow->updateShape();
- pWindow->refresh( 0, 0, width, height );
+ refreshAll();
}
}
void GenericLayout::refreshAll()
{
- refreshRect( 0, 0, m_width, m_height );
+ refreshRect( 0, 0, m_rect.getWidth(), m_rect.getHeight() );
}
x = 0;
if( y < 0)
y = 0;
- if( x + width > m_width )
- width = m_width - x;
- if( y + height > m_height )
- height = m_height - y;
+ if( x + width > m_rect.getWidth() )
+ width = m_rect.getWidth() - x;
+ if( y + height > m_rect.getHeight() )
+ height = m_rect.getHeight() - y;
- // Refresh the window... but do not paint on a video control!
- if( !m_pVideoControl )
+ // Refresh the window... but do not paint on a visible video control!
+ if( !m_pVideoControl || !m_pVideoControl->isVisible() )
{
// No video control, we can safely repaint the rectangle
pWindow->refresh( x, y, width, height );