From 24cab0eabd49778368f61194dcccfec7074a73fc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Aug 2013 16:51:38 +0200 Subject: [PATCH] View: various fixes, added VIEW::IsDirty() --- common/view/view.cpp | 41 ++++++++++++++++++++++----------- common/view/view_item.cpp | 9 ++++++++ include/view/view.h | 4 +++- include/view/view_controls.h | 8 ++++++- include/view/wx_view_controls.h | 4 ++++ 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index 16953ee1b6..14a765f014 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -498,14 +498,16 @@ struct VIEW::drawItem { group = gal->BeginGroup(); aItem->setGroup( currentLayer->id, group ); - view->m_painter->Draw( aItem, currentLayer->id ); + if(!view->m_painter->Draw( aItem, currentLayer->id )) + aItem->ViewDraw(currentLayer->id, gal, BOX2I()); gal->EndGroup(); } } else { // Immediate mode - view->m_painter->Draw( aItem, currentLayer->id ); + if(!view->m_painter->Draw( aItem, currentLayer->id )) + aItem->ViewDraw(currentLayer->id, gal, BOX2I()); } } @@ -526,11 +528,20 @@ void VIEW::redrawRect( const BOX2I& aRect ) m_gal->SetTarget( l->target ); m_gal->SetLayerDepth( l->renderingOrder ); l->items->Query( aRect, drawFunc ); - l->isDirty = false; } + l->isDirty = false; } } +bool VIEW::IsDirty() +{ + BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers ) + { + if(l->isDirty) + return true; + } + return false; +} struct VIEW::unlinkItem { @@ -622,18 +633,22 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) for( int i = 0; i < layer_count; i++ ) { - VIEW_LAYER* l = &m_layers[layer_indices[i]]; - - l->dirtyExtents = - l->isDirty ? aItem->ViewBBox() : l->dirtyExtents.Merge( aItem->ViewBBox() ); - - if( aUpdateFlags & VIEW_ITEM::GEOMETRY ) + if(m_layers.find(layer_indices[i]) != m_layers.end()) { - l->items->Remove( aItem ); - l->items->Insert( aItem ); /* reinsert */ + VIEW_LAYER* l = &m_layers[layer_indices[i]]; - aItem->deleteGroups(); - } + l->dirtyExtents = + l->isDirty ? aItem->ViewBBox() : l->dirtyExtents.Merge( aItem->ViewBBox() ); + + l->isDirty = true; + + if( aUpdateFlags & VIEW_ITEM::GEOMETRY ) + { + l->items->Remove( aItem ); + l->items->Insert( aItem ); /* reinsert */ + aItem->deleteGroups(); + } + } } if( aItem->storesGroups() ) diff --git a/common/view/view_item.cpp b/common/view/view_item.cpp index 460c7f3d77..12651ed7c3 100644 --- a/common/view/view_item.cpp +++ b/common/view/view_item.cpp @@ -57,6 +57,9 @@ void VIEW_ITEM::ViewGetRequiredLayers( int aLayers[], int& aCount ) const void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) { + if(!m_view) + return; + m_view->invalidateItem( this, aUpdateFlags ); if( aForceImmediateRedraw ) @@ -140,3 +143,9 @@ bool VIEW_ITEM::storesGroups() const { return ( m_groupsSize > 0 ); } + +void VIEW_ITEM::ViewSetHighlighted( bool aIsHighlighted ) +{ + m_highlighted = aIsHighlighted; + ViewUpdate(APPEARANCE | GEOMETRY); +} diff --git a/include/view/view.h b/include/view/view.h index 9e8561187d..27e9a48358 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -270,7 +270,7 @@ public: } /** - * Function SetLayerOrder() + * Function SetLayerOrder() * Sets rendering order of a particular layer. * @param aLayer: the layer * @param aRenderingOrder: arbitrary number denoting the rendering order. @@ -360,6 +360,8 @@ public: */ bool IsDynamic() const { return m_dynamic; } + bool IsDirty(); + static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown private: diff --git a/include/view/view_controls.h b/include/view/view_controls.h index 695530d73e..9e399d3282 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -55,6 +55,7 @@ public: JUMP = 2 }; + VIEW_CONTROLS( VIEW* aView ) : m_view( aView ) {}; virtual ~VIEW_CONTROLS() {}; @@ -74,7 +75,7 @@ public: virtual void SetGrabMouse( bool aEnabled ) {}; /** - * Function SetGrabMouse + * Function SetAutoPan * Turns on/off auto panning (this feature is used when there is a tool active (eg. drawing a * track) and user moves mouse to the VIEW edge - then the view can be translated or not). * @param aEnabled tells if the autopanning should be active. @@ -108,6 +109,11 @@ public: */ virtual void AnimatedZoom( const BOX2I& aExtents ) {}; + virtual void WarpCursor (const VECTOR2D& aPosition ) {}; + + virtual void ShowCursor (bool aEnabled ) {}; + + protected: /// Pointer to controlled VIEW. VIEW* m_view; diff --git a/include/view/wx_view_controls.h b/include/view/wx_view_controls.h index df7b2f7bb7..8e7400df67 100644 --- a/include/view/wx_view_controls.h +++ b/include/view/wx_view_controls.h @@ -37,6 +37,7 @@ #include class EDA_DRAW_PANEL_GAL; +class TOOL_DISPATCHER; namespace KiGfx { @@ -56,6 +57,8 @@ public: void onButton( wxMouseEvent& event ); void onEnter( wxMouseEvent& event ); + void SetEventDispatcher( TOOL_DISPATCHER *aEventDispatcher ); + private: /// Options for WX_VIEW_CONTROLS @@ -80,6 +83,7 @@ private: /// Used for determining time intervals between events. wxLongLong m_timeStamp; + TOOL_DISPATCHER* m_eventDispatcher; }; } // namespace KiGfx