mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-26 16:56:19 +00:00
Move the text too with the text button.
This commit is contained in:
parent
3ca518dca2
commit
75047b71b4
3 changed files with 29 additions and 15 deletions
|
@ -202,7 +202,11 @@ namespace NLGUI
|
|||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
// Sets the parent element
|
||||
// See the comment at the field
|
||||
void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; }
|
||||
|
||||
protected:
|
||||
std::string _HardtextFormat;
|
||||
|
@ -379,6 +383,9 @@ namespace NLGUI
|
|||
/// Dynamic tooltips
|
||||
std::vector<CCtrlToolTip*> _Tooltips;
|
||||
|
||||
// Parent element is the element where this text belongs to
|
||||
// For example: text button
|
||||
CInterfaceElement *_ParentElm;
|
||||
|
||||
private:
|
||||
void setup ();
|
||||
|
|
|
@ -66,8 +66,6 @@ namespace NLGUI
|
|||
{
|
||||
if( _ViewText != NULL )
|
||||
{
|
||||
if( _Parent != NULL )
|
||||
_Parent->delView( _ViewText, true );
|
||||
delete _ViewText;
|
||||
_ViewText = NULL;
|
||||
}
|
||||
|
@ -569,6 +567,7 @@ namespace NLGUI
|
|||
((CViewTextID*)_ViewText)->parseTextIdOptions(cur);
|
||||
// Same RenderLayer as us.
|
||||
_ViewText->setRenderLayer(getRenderLayer());
|
||||
_ViewText->setParentElm(this);
|
||||
// Parse the hardText (if not text id)
|
||||
if(!_IsViewTextId)
|
||||
{
|
||||
|
@ -863,6 +862,12 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -873,6 +878,8 @@ namespace NLGUI
|
|||
// Should have been setuped with addCtrl
|
||||
nlassert(_Setuped);
|
||||
|
||||
_ViewText->updateCoords();
|
||||
|
||||
// Compute Size according to bitmap and Text.
|
||||
if (!(_SizeRef & 1))
|
||||
{
|
||||
|
@ -910,15 +917,13 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
// setup the viewText and add to parent
|
||||
_ViewText->setParent (getParent());
|
||||
_ViewText->setParentElm (this);
|
||||
_ViewText->setParentPos (this);
|
||||
_ViewText->setParentPosRef (_TextParentPosRef);
|
||||
_ViewText->setPosRef (_TextPosRef);
|
||||
_ViewText->setActive(_Active);
|
||||
_ViewText->setX(_TextX);
|
||||
_ViewText->setY(_TextY);
|
||||
|
||||
getParent()->addView(_ViewText);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -1007,17 +1012,10 @@ namespace NLGUI
|
|||
// ***************************************************************************
|
||||
void CCtrlTextButton::onRemoved()
|
||||
{
|
||||
if( _ViewText != NULL )
|
||||
{
|
||||
if( _Parent != NULL )
|
||||
_Parent->delView( _ViewText, true );
|
||||
}
|
||||
}
|
||||
|
||||
void CCtrlTextButton::onWidgetDeleted( CInterfaceElement *e )
|
||||
{
|
||||
if( e == _ViewText )
|
||||
_ViewText = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1814,9 +1814,18 @@ namespace NLGUI
|
|||
if (_AutoClamp)
|
||||
{
|
||||
CViewBase::updateCoords ();
|
||||
if (_Parent)
|
||||
|
||||
// If there's no parent, try the parent of the parent element.
|
||||
// Since we will be under the same group
|
||||
CInterfaceGroup *parent = _Parent;
|
||||
if( parent == NULL )
|
||||
{
|
||||
if( _ParentElm != NULL )
|
||||
parent = _ParentElm->getParent();
|
||||
}
|
||||
|
||||
if (parent)
|
||||
{
|
||||
CInterfaceGroup *parent = _Parent;
|
||||
// avoid resizing parents to compute the limiter
|
||||
while (parent && (parent->getResizeFromChildW() || parent->isGroupList() ))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue