A little refactoring.

This commit is contained in:
dfighter1985 2014-09-27 20:15:46 +02:00
parent 297d287f39
commit 89e86d2c7b
4 changed files with 18 additions and 7 deletions

View file

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

View file

@ -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;

View file

@ -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();
}
}

View file

@ -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 );
}
}