From 0055e2dd91d95c562c9620fddf01908f719895b8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 27 Sep 2014 20:15:46 +0200 Subject: [PATCH] A little refactoring. --HG-- branch : dfighter-tools --- code/nel/include/nel/gui/ctrl_text_button.h | 1 + code/nel/include/nel/gui/interface_element.h | 8 ++++++++ code/nel/src/gui/ctrl_text_button.cpp | 12 ++++++++---- code/nel/src/gui/widget_manager.cpp | 4 +--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index 183b6a65e..d2b49ffa9 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -126,6 +126,7 @@ namespace NLGUI void onRemoved(); void onWidgetDeleted( CInterfaceElement *e ); + void moveBy( sint32 x, sint32 y ); protected: diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index db7a499c8..048ec4b6e 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -510,6 +510,14 @@ namespace NLGUI /// so other widgets in the group can check if it belongs to them virtual void onWidgetDeleted( CInterfaceElement *e ){} + /// Move the element by x in the X direction and y in the Y direction + // Uses real coordinates + virtual void moveBy( sint32 x, sint32 y ) + { + _XReal += x; + _YReal += y; + } + protected: bool editorSelected; diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index b14fb27ca..03db2b797 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -863,10 +863,6 @@ namespace NLGUI if(getFrozen() && getFrozenHalfTone()) _ViewText->setAlpha(_ViewText->getAlpha()>>2); - // When dragging the button, the text needs to move too - if( CInterfaceElement::editorMode ) - _ViewText->updateCoords(); - _ViewText->draw(); } } @@ -1017,5 +1013,13 @@ namespace NLGUI void CCtrlTextButton::onWidgetDeleted( CInterfaceElement *e ) { } + + void CCtrlTextButton::moveBy( sint32 x, sint32 y ) + { + CInterfaceElement::moveBy( x, y ); + + if( _ViewText != NULL ) + _ViewText->updateCoords(); + } } diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 54b180ef1..5b51fcb6b 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -2633,9 +2633,7 @@ namespace NLGUI sint32 dx = newX - oldX; sint32 dy = newY - oldY; - draggedElement->setXReal( draggedElement->getXReal() + dx ); - draggedElement->setYReal( draggedElement->getYReal() + dy ); - draggedElement->invalidateCoords(); + draggedElement->moveBy( dx, dy ); } }