A little refactoring.

This commit is contained in:
dfighter1985 2014-09-27 20:15:46 +02:00
parent 75047b71b4
commit fada6e7dcc
4 changed files with 18 additions and 7 deletions

View file

@ -126,6 +126,7 @@ namespace NLGUI
void onRemoved(); void onRemoved();
void onWidgetDeleted( CInterfaceElement *e ); void onWidgetDeleted( CInterfaceElement *e );
void moveBy( sint32 x, sint32 y );
protected: protected:

View file

@ -510,6 +510,14 @@ namespace NLGUI
/// so other widgets in the group can check if it belongs to them /// so other widgets in the group can check if it belongs to them
virtual void onWidgetDeleted( CInterfaceElement *e ){} 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: protected:
bool editorSelected; bool editorSelected;

View file

@ -863,10 +863,6 @@ namespace NLGUI
if(getFrozen() && getFrozenHalfTone()) if(getFrozen() && getFrozenHalfTone())
_ViewText->setAlpha(_ViewText->getAlpha()>>2); _ViewText->setAlpha(_ViewText->getAlpha()>>2);
// When dragging the button, the text needs to move too
if( CInterfaceElement::editorMode )
_ViewText->updateCoords();
_ViewText->draw(); _ViewText->draw();
} }
} }
@ -1017,5 +1013,13 @@ namespace NLGUI
void CCtrlTextButton::onWidgetDeleted( CInterfaceElement *e ) void CCtrlTextButton::onWidgetDeleted( CInterfaceElement *e )
{ {
} }
void CCtrlTextButton::moveBy( sint32 x, sint32 y )
{
CInterfaceElement::moveBy( x, y );
if( _ViewText != NULL )
_ViewText->updateCoords();
}
} }

View file

@ -2633,9 +2633,7 @@ namespace NLGUI
sint32 dx = newX - oldX; sint32 dx = newX - oldX;
sint32 dy = newY - oldY; sint32 dy = newY - oldY;
draggedElement->setXReal( draggedElement->getXReal() + dx ); draggedElement->moveBy( dx, dy );
draggedElement->setYReal( draggedElement->getYReal() + dy );
draggedElement->invalidateCoords();
} }
} }