Added functions for refreshing the layer set occupied by a VIEW_ITEM.
This commit is contained in:
parent
96d162c907
commit
1de8eba49e
|
@ -633,7 +633,7 @@ void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) const
|
||||||
{
|
{
|
||||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||||
|
|
||||||
aItem->getLayers( layers, layers_count );
|
aItem->ViewGetLayers( layers, layers_count );
|
||||||
// Sorting is needed for drawing order dependent GALs (like Cairo)
|
// Sorting is needed for drawing order dependent GALs (like Cairo)
|
||||||
SortLayers( layers, layers_count );
|
SortLayers( layers, layers_count );
|
||||||
|
|
||||||
|
@ -813,19 +813,23 @@ void VIEW::clearGroupCache()
|
||||||
|
|
||||||
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
||||||
{
|
{
|
||||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
// updateLayers updates geometry too, so we do not have to update both of them at the same time
|
||||||
aItem->getLayers( layers, layers_count );
|
if( aUpdateFlags & VIEW_ITEM::LAYERS )
|
||||||
|
updateLayers( aItem );
|
||||||
if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
|
else if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
|
||||||
updateBbox( aItem );
|
updateBbox( aItem );
|
||||||
|
|
||||||
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||||
|
aItem->ViewGetLayers( layers, layers_count );
|
||||||
|
|
||||||
// Iterate through layers used by the item and recache it immediately
|
// Iterate through layers used by the item and recache it immediately
|
||||||
for( int i = 0; i < layers_count; i++ )
|
for( int i = 0; i < layers_count; i++ )
|
||||||
{
|
{
|
||||||
int layerId = layers[i];
|
int layerId = layers[i];
|
||||||
|
|
||||||
if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
|
if( aUpdateFlags & ( VIEW_ITEM::GEOMETRY | VIEW_ITEM::LAYERS ) )
|
||||||
{
|
{
|
||||||
|
// Redraw
|
||||||
if( IsCached( layerId ) )
|
if( IsCached( layerId ) )
|
||||||
updateItemGeometry( aItem, layerId );
|
updateItemGeometry( aItem, layerId );
|
||||||
}
|
}
|
||||||
|
@ -900,6 +904,31 @@ void VIEW::updateBbox( VIEW_ITEM* aItem )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void VIEW::updateLayers( VIEW_ITEM* aItem )
|
||||||
|
{
|
||||||
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||||
|
|
||||||
|
// Remove the item from previous layer set
|
||||||
|
aItem->getLayers( layers, layers_count );
|
||||||
|
for( int i = 0; i < layers_count; i++ )
|
||||||
|
{
|
||||||
|
VIEW_LAYER& l = m_layers[layers[i]];
|
||||||
|
l.items->Remove( aItem );
|
||||||
|
MarkTargetDirty( l.target );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the item to new layer set
|
||||||
|
aItem->ViewGetLayers( layers, layers_count );
|
||||||
|
aItem->saveLayers( layers, layers_count );
|
||||||
|
for( int i = 0; i < layers_count; i++ )
|
||||||
|
{
|
||||||
|
VIEW_LAYER& l = m_layers[layers[i]];
|
||||||
|
l.items->Insert( aItem );
|
||||||
|
MarkTargetDirty( l.target );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
|
bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
|
||||||
{
|
{
|
||||||
wxASSERT( (unsigned) aLayerId < m_layers.size() );
|
wxASSERT( (unsigned) aLayerId < m_layers.size() );
|
||||||
|
|
|
@ -73,7 +73,6 @@ void VIEW_ITEM::getLayers( int* aLayers, int& aCount ) const
|
||||||
{
|
{
|
||||||
if( m_layers[i] )
|
if( m_layers[i] )
|
||||||
*layersPtr++ = i;
|
*layersPtr++ = i;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aCount = m_layers.count();
|
aCount = m_layers.count();
|
||||||
|
|
|
@ -569,6 +569,9 @@ private:
|
||||||
/// Updates bounding box of an item
|
/// Updates bounding box of an item
|
||||||
void updateBbox( VIEW_ITEM* aItem );
|
void updateBbox( VIEW_ITEM* aItem );
|
||||||
|
|
||||||
|
/// Updates set of layers that an item occupies
|
||||||
|
void updateLayers( VIEW_ITEM* aItem );
|
||||||
|
|
||||||
/// Determines rendering order of layers. Used in display order sorting function.
|
/// Determines rendering order of layers. Used in display order sorting function.
|
||||||
static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j )
|
static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j )
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,6 +165,7 @@ public:
|
||||||
APPEARANCE = 0x01, /// Visibility flag has changed
|
APPEARANCE = 0x01, /// Visibility flag has changed
|
||||||
COLOR = 0x02, /// Color has changed
|
COLOR = 0x02, /// Color has changed
|
||||||
GEOMETRY = 0x04, /// Position or shape has changed
|
GEOMETRY = 0x04, /// Position or shape has changed
|
||||||
|
LAYERS = 0x08, /// Layers have changed
|
||||||
ALL = 0xff
|
ALL = 0xff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue