SVN commit 523411 by zachmann: o Started to add tools. This is still very very basic. What we still need: - A way to change the tool when e.g. we release the mouse at the end of a move or resize, so that we are in the default tool again. - A good way for repainting. - A good interface for the tools. At the moment it is still very basic. - And all that have I forgot ... I think we can learn from krita's KisTools. CCMAIL: koffice-devel@kde.org M +25 -10 KoObjectManager.cpp M +5 -0 KoObjectManager.h M +1 -40 KoSelection.cpp M +0 -2 KoSelection.h A KoTool.h [License: no copyright] A KoToolMove.cpp [License: no copyright] A KoToolMove.h [License: no copyright] M +2 -2 lib.pro --- trunk/playground/office/flake/lib/KoObjectManager.cpp #523410:523411 @@ -31,6 +31,8 @@ KoObjectManager::KoObjectManager( QLinkedList &objects ) : m_objects( objects ) , m_selection( new KoSelection() ) +, m_tool( 0 ) +, m_moveTool( m_selection ) { } @@ -55,12 +57,8 @@ KoGraphicBase * object( getObjectAt( event->m_point ) ); if ( object ) { - if ( object == m_selection ) + if ( object != m_selection ) { - m_selection->mousePressEvent( event ); - } - else - { if ( event->m_event.modifiers() & Qt::ControlModifier ) { if ( object->selected() ) @@ -71,7 +69,7 @@ else { m_selection->select( object ); - m_selection->mousePressEvent( event ); + //m_selection->mousePressEvent( event ); } } else if ( !object->selected() ) @@ -79,18 +77,29 @@ m_selection->deselectAll(); m_selection->select( object ); - m_selection->mousePressEvent( event ); + //m_selection->mousePressEvent( event ); } else { - m_selection->mousePressEvent( event ); + //m_selection->mousePressEvent( event ); } } + if ( m_selection->count() > 0 ) + { + m_tool = &m_moveTool; + } } else { m_selection->deselectAll(); + m_tool = 0; } + + if ( m_tool ) + { + m_tool->mousePressEvent( event ); + } + //TODO return true; } @@ -99,9 +108,9 @@ bool KoObjectManager::mouseMoveEvent( KoGfxEvent *event ) { bool retval = false; - if ( m_selection->count() > 0 ) + if ( m_tool ) { - retval = m_selection->mouseMoveEvent( event ); + retval = m_tool->mouseMoveEvent( event ); } return retval; } @@ -109,6 +118,12 @@ bool KoObjectManager::mouseReleaseEvent( KoGfxEvent *event ) { + + if ( m_tool ) + { + m_tool->mouseReleaseEvent( event ); + m_tool = 0; + } //TODO return true; } --- trunk/playground/office/flake/lib/KoObjectManager.h #523410:523411 @@ -23,6 +23,8 @@ #include +#include "KoToolMove.h" + class KoEnvContext; class KoGfxEvent; class KoGraphicBase; @@ -36,6 +38,7 @@ { public: KoObjectManager( QLinkedList &objects ); + virtual ~KoObjectManager() {} void setObjects( QLinkedList &objects ); @@ -50,6 +53,8 @@ private: QLinkedList & m_objects; KoSelection * m_selection; + KoTool * m_tool; + KoToolMove m_moveTool; }; #endif /* KOOBJECTMANAGER_H */ --- trunk/playground/office/flake/lib/KoSelection.cpp #523410:523411 @@ -39,7 +39,7 @@ painter.save(); QRectF bb( boundingBox() ); - QPen pen (Qt::red ); + QPen pen( Qt::red ); painter.setPen( pen ); painter.drawRect( bb ); @@ -94,57 +94,18 @@ bool KoSelection::mousePressEvent( KoGfxEvent *event ) { bool retval = true; - qDebug() << "KoSelection::mousePressEvent:" << this << " " << event->m_point; - if ( count() > 0 ) - { - m_movePos = event->m_point; - } - else if ( count() == 1 ) - { - retval = m_selectedObjects.first()->mousePressEvent( event ); - } - else - { - retval = false; - } - return retval; } bool KoSelection::mouseMoveEvent( KoGfxEvent *event ) { bool retval = true; - qDebug() << "KoSelection::mouseMoveEvent:" << this << " " << event->m_point; - if ( count() > 0 ) - { - QPointF diff( event->m_point - m_movePos ); - - foreach ( KoGraphicBase * base, m_selectedObjects ) - { - base->setPos( base->pos() + diff ); - } - m_movePos = event->m_point; - } - else - { - retval = false; - } - return retval; } bool KoSelection::mouseReleaseEvent( KoGfxEvent *event ) { bool retval = true; - qDebug() << "KoSelection::mouseReleaseEvent:" << this << " " << event->m_point; - if ( count() > 0 ) - { - } - else - { - retval = false; - } - return retval; } --- trunk/playground/office/flake/lib/KoSelection.h #523410:523411 @@ -48,8 +48,6 @@ private: QList m_selectedObjects; - - QPointF m_movePos; }; #endif --- trunk/playground/office/flake/lib/lib.pro #523410:523411 @@ -8,5 +8,5 @@ INCLUDEPATH += . # Input -HEADERS += KoEnvContext.h KoGraphicBase.h KoSelection.h KoGfxStyle.h KoObjectManager.h -SOURCES += KoGraphicBase.cpp KoPathGfxObj.cpp KoSelection.cpp KoGfxStyle.cpp KoObjectManager.cpp +HEADERS += KoEnvContext.h KoGraphicBase.h KoSelection.h KoGfxStyle.h KoObjectManager.h KoTool.h KoToolMove.h +SOURCES += KoGraphicBase.cpp KoPathGfxObj.cpp KoSelection.cpp KoGfxStyle.cpp KoObjectManager.cpp KoToolMove.cpp _______________________________________________ koffice-devel mailing list koffice-devel@kde.org https://mail.kde.org/mailman/listinfo/koffice-devel