Merged develop.
This commit is contained in:
commit
3fbe51185f
7 changed files with 200 additions and 83 deletions
|
@ -57,6 +57,7 @@ namespace NLGUI
|
||||||
CInterfaceElement* findFromShortId(const std::string &id);
|
CInterfaceElement* findFromShortId(const std::string &id);
|
||||||
|
|
||||||
/// Dynamic creation
|
/// Dynamic creation
|
||||||
|
virtual void addElement (CInterfaceElement *child, sint eltOrder = -1 );
|
||||||
virtual void addView (CViewBase *child , sint eltOrder = -1);
|
virtual void addView (CViewBase *child , sint eltOrder = -1);
|
||||||
virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1);
|
virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1);
|
||||||
virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1);
|
virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1);
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Affero General Public License as
|
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Affero General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
#ifndef WIDGET_ADD_WATCHER
|
|
||||||
#define WIDGET_ADD_WATCHER
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace NLGUI
|
|
||||||
{
|
|
||||||
class IWidgetAdditionWatcher
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void widgetAdded( const std::string &name ) = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -75,6 +75,16 @@ namespace NLGUI
|
||||||
virtual void process() = 0;
|
virtual void process() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Interface for event handlers that can be called when widgets are added or moved
|
||||||
|
class IWidgetWatcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IWidgetWatcher(){}
|
||||||
|
virtual ~IWidgetWatcher(){}
|
||||||
|
virtual void onWidgetAdded( const std::string &name ) = 0;
|
||||||
|
virtual void onWidgetMoved( const std::string &oldid, const std::string &newid ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/// Frame render times
|
/// Frame render times
|
||||||
struct SInterfaceTimes
|
struct SInterfaceTimes
|
||||||
{
|
{
|
||||||
|
@ -498,10 +508,12 @@ namespace NLGUI
|
||||||
void notifySelectionWatchers();
|
void notifySelectionWatchers();
|
||||||
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
|
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
|
||||||
void unregisterSelectionWatcher( IEditorSelectionWatcher *watcher );
|
void unregisterSelectionWatcher( IEditorSelectionWatcher *watcher );
|
||||||
|
|
||||||
void notifyAdditionWatchers( const std::string &widgetName );
|
|
||||||
void registerAdditionWatcher( IWidgetAdditionWatcher *watcher );
|
void onWidgetAdded( const std::string &id );
|
||||||
void unregisterAdditionWatcher( IWidgetAdditionWatcher *watcher );
|
void onWidgetMoved( const std::string &oldid, const std::string &newid );
|
||||||
|
void registerWidgetWatcher( IWidgetWatcher *watcher );
|
||||||
|
void unregisterWidgetWatcher( IWidgetWatcher *watcher );
|
||||||
|
|
||||||
CInterfaceElement* addWidgetToGroup( std::string &group, std::string &widgetClass, std::string &widgetName );
|
CInterfaceElement* addWidgetToGroup( std::string &group, std::string &widgetClass, std::string &widgetName );
|
||||||
|
|
||||||
|
@ -532,7 +544,7 @@ namespace NLGUI
|
||||||
|
|
||||||
NLMISC::CRefPtr< CViewBase > _CapturedView;
|
NLMISC::CRefPtr< CViewBase > _CapturedView;
|
||||||
|
|
||||||
NLMISC::CRefPtr< CInterfaceElement > draggedElement;
|
NLMISC::CRefPtr< CInterfaceElement > draggedElement; // the element that we're currently dragging
|
||||||
|
|
||||||
bool startDragging();
|
bool startDragging();
|
||||||
void stopDragging();
|
void stopDragging();
|
||||||
|
@ -594,7 +606,7 @@ namespace NLGUI
|
||||||
std::vector< INewScreenSizeHandler* > newScreenSizeHandlers;
|
std::vector< INewScreenSizeHandler* > newScreenSizeHandlers;
|
||||||
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
|
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
|
||||||
std::vector< IEditorSelectionWatcher* > selectionWatchers;
|
std::vector< IEditorSelectionWatcher* > selectionWatchers;
|
||||||
std::vector< IWidgetAdditionWatcher* > additionWatchers;
|
std::vector< IWidgetWatcher* > widgetWatchers;
|
||||||
|
|
||||||
|
|
||||||
std::string currentEditorSelection;
|
std::string currentEditorSelection;
|
||||||
|
|
|
@ -911,6 +911,31 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CInterfaceGroup::addElement (CInterfaceElement *child, sint eltOrder /*= -1*/)
|
||||||
|
{
|
||||||
|
if (!child)
|
||||||
|
{
|
||||||
|
nlwarning("<CInterfaceGroup::addView> : tried to add a NULL view");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( child->isGroup() )
|
||||||
|
{
|
||||||
|
addGroup( static_cast< CInterfaceGroup* >( child ), eltOrder );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( child->isCtrl() )
|
||||||
|
{
|
||||||
|
addCtrl( static_cast< CCtrlBase* >( child ), eltOrder );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( child->isView() )
|
||||||
|
{
|
||||||
|
addView( static_cast< CViewBase* >( child ), eltOrder );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CInterfaceGroup::addView (CViewBase *child, sint eltOrder /*= -1*/)
|
void CInterfaceGroup::addView (CViewBase *child, sint eltOrder /*= -1*/)
|
||||||
{
|
{
|
||||||
|
@ -1312,6 +1337,11 @@ namespace NLGUI
|
||||||
for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++)
|
for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++)
|
||||||
{
|
{
|
||||||
CViewBase *pVB = *ite;
|
CViewBase *pVB = *ite;
|
||||||
|
if( pVB->getName() == "=MARKED=" )
|
||||||
|
{
|
||||||
|
nlinfo( "=MARKED=" );
|
||||||
|
}
|
||||||
|
|
||||||
if (pVB->getActive())
|
if (pVB->getActive())
|
||||||
pVB->draw();
|
pVB->draw();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "nel/gui/interface_expr.h"
|
#include "nel/gui/interface_expr.h"
|
||||||
#include "nel/gui/reflect_register.h"
|
#include "nel/gui/reflect_register.h"
|
||||||
#include "nel/gui/editor_selection_watcher.h"
|
#include "nel/gui/editor_selection_watcher.h"
|
||||||
#include "nel/gui/widget_addition_watcher.h"
|
|
||||||
#include "nel/misc/events.h"
|
#include "nel/misc/events.h"
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
|
@ -1036,7 +1035,7 @@ namespace NLGUI
|
||||||
setCapturePointerLeft(NULL);
|
setCapturePointerLeft(NULL);
|
||||||
setCapturePointerRight(NULL);
|
setCapturePointerRight(NULL);
|
||||||
_CapturedView = NULL;
|
_CapturedView = NULL;
|
||||||
|
|
||||||
resetColorProps();
|
resetColorProps();
|
||||||
resetAlphaRolloverSpeedProps();
|
resetAlphaRolloverSpeedProps();
|
||||||
resetGlobalAlphasProps();
|
resetGlobalAlphasProps();
|
||||||
|
@ -2401,6 +2400,7 @@ namespace NLGUI
|
||||||
// This may happen when alt-tab has been used => the sheet is dragged but the left button is up
|
// This may happen when alt-tab has been used => the sheet is dragged but the left button is up
|
||||||
if (!CCtrlDraggable::getDraggedSheet())
|
if (!CCtrlDraggable::getDraggedSheet())
|
||||||
{
|
{
|
||||||
|
|
||||||
// Take the top most control.
|
// Take the top most control.
|
||||||
uint nMaxDepth = 0;
|
uint nMaxDepth = 0;
|
||||||
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
|
const std::vector< CCtrlBase* >& _CtrlsUnderPointer = getCtrlsUnderPointer();
|
||||||
|
@ -2630,8 +2630,11 @@ namespace NLGUI
|
||||||
else
|
else
|
||||||
if( draggedElement != NULL )
|
if( draggedElement != NULL )
|
||||||
{
|
{
|
||||||
draggedElement->setXReal( newX );
|
sint32 dx = newX - oldX;
|
||||||
draggedElement->setYReal( newY );
|
sint32 dy = newY - oldY;
|
||||||
|
|
||||||
|
draggedElement->setXReal( draggedElement->getXReal() + dx );
|
||||||
|
draggedElement->setYReal( draggedElement->getYReal() + dy );
|
||||||
draggedElement->invalidateCoords();
|
draggedElement->invalidateCoords();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2659,13 +2662,33 @@ namespace NLGUI
|
||||||
|
|
||||||
e->setParent( NULL );
|
e->setParent( NULL );
|
||||||
draggedElement = e;
|
draggedElement = e;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWidgetManager::stopDragging()
|
void CWidgetManager::stopDragging()
|
||||||
{
|
{
|
||||||
draggedElement = NULL;
|
if( draggedElement != NULL )
|
||||||
|
{
|
||||||
|
CInterfaceGroup *g = getGroupUnder( draggedElement->getXReal(), draggedElement->getYReal() );
|
||||||
|
CInterfaceElement *e = draggedElement;
|
||||||
|
CInterfaceGroup *tw = getTopWindow();
|
||||||
|
|
||||||
|
if( g == NULL )
|
||||||
|
g = tw;
|
||||||
|
|
||||||
|
std::string oldid = e->getId();
|
||||||
|
|
||||||
|
e->setParent( g );
|
||||||
|
e->setIdRecurse( e->getShortId() );
|
||||||
|
e->setParentPos( g );
|
||||||
|
e->setParentSize( g );
|
||||||
|
g->addElement( e );
|
||||||
|
|
||||||
|
draggedElement = NULL;
|
||||||
|
|
||||||
|
onWidgetMoved( oldid, e->getId() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -3352,36 +3375,46 @@ namespace NLGUI
|
||||||
selectionWatchers.erase( itr );
|
selectionWatchers.erase( itr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWidgetManager::notifyAdditionWatchers( const std::string &widgetName )
|
void CWidgetManager::onWidgetAdded( const std::string &id )
|
||||||
{
|
{
|
||||||
std::vector< IWidgetAdditionWatcher* >::const_iterator itr = additionWatchers.begin();
|
std::vector< IWidgetWatcher* >::const_iterator itr = widgetWatchers.begin();
|
||||||
while( itr != additionWatchers.end() )
|
while( itr != widgetWatchers.end() )
|
||||||
{
|
{
|
||||||
(*itr)->widgetAdded( widgetName );
|
(*itr)->onWidgetAdded( id );
|
||||||
++itr;
|
++itr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWidgetManager::registerAdditionWatcher( IWidgetAdditionWatcher *watcher )
|
void CWidgetManager::onWidgetMoved( const std::string &oldid, const std::string &newid )
|
||||||
{
|
{
|
||||||
std::vector< IWidgetAdditionWatcher* >::const_iterator itr
|
std::vector< IWidgetWatcher* >::const_iterator itr = widgetWatchers.begin();
|
||||||
= std::find( additionWatchers.begin(), additionWatchers.end(), watcher );
|
while( itr != widgetWatchers.end() )
|
||||||
// already exists
|
{
|
||||||
if( itr != additionWatchers.end() )
|
(*itr)->onWidgetMoved( oldid, newid );
|
||||||
return;
|
++itr;
|
||||||
|
}
|
||||||
additionWatchers.push_back( watcher );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWidgetManager::unregisterAdditionWatcher( IWidgetAdditionWatcher *watcher )
|
void CWidgetManager::registerWidgetWatcher( IWidgetWatcher *watcher )
|
||||||
{
|
{
|
||||||
std::vector< IWidgetAdditionWatcher* >::iterator itr
|
std::vector< IWidgetWatcher* >::const_iterator itr
|
||||||
= std::find( additionWatchers.begin(), additionWatchers.end(), watcher );
|
= std::find( widgetWatchers.begin(), widgetWatchers.end(), watcher );
|
||||||
// doesn't exist
|
// already exists
|
||||||
if( itr == additionWatchers.end() )
|
if( itr != widgetWatchers.end() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
additionWatchers.erase( itr );
|
widgetWatchers.push_back( watcher );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWidgetManager::unregisterWidgetWatcher( IWidgetWatcher *watcher )
|
||||||
|
{
|
||||||
|
std::vector< IWidgetWatcher* >::iterator itr
|
||||||
|
= std::find( widgetWatchers.begin(), widgetWatchers.end(), watcher );
|
||||||
|
// doesn't exist
|
||||||
|
if( itr == widgetWatchers.end() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
widgetWatchers.erase( itr );
|
||||||
}
|
}
|
||||||
|
|
||||||
CInterfaceElement* CWidgetManager::addWidgetToGroup( std::string &group, std::string &widgetClass, std::string &widgetName )
|
CInterfaceElement* CWidgetManager::addWidgetToGroup( std::string &group, std::string &widgetClass, std::string &widgetName )
|
||||||
|
@ -3414,7 +3447,7 @@ namespace NLGUI
|
||||||
else
|
else
|
||||||
g->addView( v );
|
g->addView( v );
|
||||||
|
|
||||||
notifyAdditionWatchers( v->getId() );
|
onWidgetAdded( v->getId() );
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "widget_hierarchy.h"
|
#include "widget_hierarchy.h"
|
||||||
#include "nel/gui/interface_group.h"
|
#include "nel/gui/interface_group.h"
|
||||||
#include "nel/gui/widget_manager.h"
|
#include "nel/gui/widget_manager.h"
|
||||||
#include "nel/gui/widget_addition_watcher.h"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -76,18 +75,24 @@ namespace
|
||||||
GUIEditor::WidgetHierarchy *h;
|
GUIEditor::WidgetHierarchy *h;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CWidgetAdditionWatcher : public IWidgetAdditionWatcher
|
class CWidgetWatcher : public CWidgetManager::IWidgetWatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CWidgetAdditionWatcher(){ h = NULL; }
|
CWidgetWatcher(){ h = NULL; }
|
||||||
~CWidgetAdditionWatcher(){}
|
~CWidgetWatcher(){}
|
||||||
|
|
||||||
void widgetAdded( const std::string &name )
|
void onWidgetAdded( const std::string &name )
|
||||||
{
|
{
|
||||||
if( h != NULL )
|
if( h != NULL )
|
||||||
h->onWidgetAdded( name );
|
h->onWidgetAdded( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onWidgetMoved( const std::string &oldid, const std::string &newid )
|
||||||
|
{
|
||||||
|
if( h != NULL )
|
||||||
|
h->onWidgetMoved( oldid, newid );
|
||||||
|
}
|
||||||
|
|
||||||
void setWidgetHierarchy( GUIEditor::WidgetHierarchy *h ){ this->h = h; }
|
void setWidgetHierarchy( GUIEditor::WidgetHierarchy *h ){ this->h = h; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -95,7 +100,7 @@ namespace
|
||||||
};
|
};
|
||||||
|
|
||||||
CWidgetDeletionWatcher deletionWatcher;
|
CWidgetDeletionWatcher deletionWatcher;
|
||||||
CWidgetAdditionWatcher additionWatcher;
|
CWidgetWatcher widgetwatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
|
@ -107,7 +112,7 @@ namespace GUIEditor
|
||||||
connect( widgetHT, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ),
|
connect( widgetHT, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ),
|
||||||
this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) );
|
this, SLOT( onItemDblClicked( QTreeWidgetItem* ) ) );
|
||||||
deletionWatcher.setWidgetHierarchy( this );
|
deletionWatcher.setWidgetHierarchy( this );
|
||||||
additionWatcher.setWidgetHierarchy( this );
|
widgetwatcher.setWidgetHierarchy( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetHierarchy::~WidgetHierarchy()
|
WidgetHierarchy::~WidgetHierarchy()
|
||||||
|
@ -117,7 +122,7 @@ namespace GUIEditor
|
||||||
void WidgetHierarchy::clearHierarchy()
|
void WidgetHierarchy::clearHierarchy()
|
||||||
{
|
{
|
||||||
CInterfaceElement::unregisterDeletionWatcher( &deletionWatcher );
|
CInterfaceElement::unregisterDeletionWatcher( &deletionWatcher );
|
||||||
CWidgetManager::getInstance()->unregisterAdditionWatcher( &additionWatcher );
|
CWidgetManager::getInstance()->unregisterWidgetWatcher( &widgetwatcher );
|
||||||
widgetHT->clear();
|
widgetHT->clear();
|
||||||
widgetHierarchyMap.clear();
|
widgetHierarchyMap.clear();
|
||||||
}
|
}
|
||||||
|
@ -126,7 +131,7 @@ namespace GUIEditor
|
||||||
{
|
{
|
||||||
clearHierarchy();
|
clearHierarchy();
|
||||||
CInterfaceElement::registerDeletionWatcher( &deletionWatcher );
|
CInterfaceElement::registerDeletionWatcher( &deletionWatcher );
|
||||||
CWidgetManager::getInstance()->registerAdditionWatcher( &additionWatcher );
|
CWidgetManager::getInstance()->registerWidgetWatcher( &widgetwatcher );
|
||||||
|
|
||||||
CInterfaceGroup *mg = CWidgetManager::getInstance()->getMasterGroupFromId( masterGroup );
|
CInterfaceGroup *mg = CWidgetManager::getInstance()->getMasterGroupFromId( masterGroup );
|
||||||
if( mg != NULL )
|
if( mg != NULL )
|
||||||
|
@ -177,6 +182,27 @@ namespace GUIEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* WidgetHierarchy::findItem( const std::string &id )
|
||||||
|
{
|
||||||
|
std::map< std::string, QTreeWidgetItem* >::iterator itr
|
||||||
|
= widgetHierarchyMap.find( id );
|
||||||
|
if( itr == widgetHierarchyMap.end() )
|
||||||
|
return NULL;
|
||||||
|
else
|
||||||
|
return itr->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* WidgetHierarchy::findParent( const std::string &id )
|
||||||
|
{
|
||||||
|
// Get the parent's name
|
||||||
|
std::string::size_type p = id.find_last_of( ':' );
|
||||||
|
if( p == std::string::npos )
|
||||||
|
return NULL;
|
||||||
|
std::string parentId = id.substr( 0, p );
|
||||||
|
|
||||||
|
return findItem( parentId );
|
||||||
|
}
|
||||||
|
|
||||||
void WidgetHierarchy::onWidgetDeleted( const std::string &id )
|
void WidgetHierarchy::onWidgetDeleted( const std::string &id )
|
||||||
{
|
{
|
||||||
std::map< std::string, QTreeWidgetItem* >::iterator itr
|
std::map< std::string, QTreeWidgetItem* >::iterator itr
|
||||||
|
@ -231,6 +257,54 @@ namespace GUIEditor
|
||||||
widgetHierarchyMap[ id ] = item;
|
widgetHierarchyMap[ id ] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WidgetHierarchy::onWidgetMoved( const std::string &oldid, const std::string &newid )
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *newParent = NULL;
|
||||||
|
QTreeWidgetItem *item = NULL;
|
||||||
|
QString id;
|
||||||
|
|
||||||
|
newParent = findParent( newid );
|
||||||
|
item = findItem( oldid );
|
||||||
|
|
||||||
|
if( ( newParent == NULL ) || ( item == NULL ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Remove old item
|
||||||
|
QTreeWidgetItem *p = item->parent();
|
||||||
|
if( p != NULL )
|
||||||
|
p->setExpanded( false );
|
||||||
|
id = item->data( 0, Qt::DisplayRole ).toString();
|
||||||
|
delete item;
|
||||||
|
item = NULL;
|
||||||
|
|
||||||
|
// Remove reference to old item
|
||||||
|
widgetHierarchyMap.erase( oldid );
|
||||||
|
|
||||||
|
// Add new item
|
||||||
|
item = new QTreeWidgetItem();
|
||||||
|
item->setData( 0, Qt::DisplayRole, id );
|
||||||
|
item->setSelected( true );
|
||||||
|
newParent->addChild( item );
|
||||||
|
|
||||||
|
|
||||||
|
selectItem( item );
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidgetHierarchy::selectItem( QTreeWidgetItem *item )
|
||||||
|
{
|
||||||
|
widgetHT->collapseAll();
|
||||||
|
|
||||||
|
QTreeWidgetItem *currItem = item;
|
||||||
|
while( currItem != NULL )
|
||||||
|
{
|
||||||
|
currItem->setExpanded( true );
|
||||||
|
currItem = currItem->parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
widgetHT->setCurrentItem( item );
|
||||||
|
item->setSelected( true );
|
||||||
|
}
|
||||||
|
|
||||||
void WidgetHierarchy::getCurrentGroup( QString &g )
|
void WidgetHierarchy::getCurrentGroup( QString &g )
|
||||||
{
|
{
|
||||||
std::string s = CWidgetManager::getInstance()->getCurrentEditorSelection();
|
std::string s = CWidgetManager::getInstance()->getCurrentEditorSelection();
|
||||||
|
@ -288,18 +362,11 @@ namespace GUIEditor
|
||||||
if( widgetHT->currentItem() != NULL )
|
if( widgetHT->currentItem() != NULL )
|
||||||
widgetHT->currentItem()->setSelected( false );
|
widgetHT->currentItem()->setSelected( false );
|
||||||
|
|
||||||
// expand the tree items, so that we can see the selected item
|
widgetHT->collapseAll();
|
||||||
QTreeWidgetItem *item = itr->second;
|
|
||||||
QTreeWidgetItem *currItem = item;
|
|
||||||
while( currItem != NULL )
|
|
||||||
{
|
|
||||||
currItem->setExpanded( true );
|
|
||||||
currItem = currItem->parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// select the current item
|
// select the current item
|
||||||
item->setSelected( true );
|
QTreeWidgetItem *item = itr->second;
|
||||||
widgetHT->setCurrentItem( item );
|
selectItem( item );
|
||||||
currentSelection = newSelection;
|
currentSelection = newSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,6 +374,8 @@ namespace GUIEditor
|
||||||
{
|
{
|
||||||
if( item->parent() == NULL )
|
if( item->parent() == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
selectItem( item );
|
||||||
|
|
||||||
std::string n = item->text( 0 ).toUtf8().constData();
|
std::string n = item->text( 0 ).toUtf8().constData();
|
||||||
currentSelection = makeFullName( item, n );
|
currentSelection = makeFullName( item, n );
|
||||||
|
|
|
@ -44,11 +44,15 @@ namespace GUIEditor
|
||||||
|
|
||||||
void onWidgetDeleted( const std::string &id );
|
void onWidgetDeleted( const std::string &id );
|
||||||
void onWidgetAdded( const std::string &id );
|
void onWidgetAdded( const std::string &id );
|
||||||
|
void onWidgetMoved( const std::string &oldid, const std::string &newid );
|
||||||
|
|
||||||
void getCurrentGroup( QString &g );
|
void getCurrentGroup( QString &g );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
|
void buildHierarchy( QTreeWidgetItem *parent, NLGUI::CInterfaceGroup *group );
|
||||||
|
QTreeWidgetItem* findItem( const std::string &id );
|
||||||
|
QTreeWidgetItem* findParent( const std::string &id );
|
||||||
|
void selectItem( QTreeWidgetItem *item );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onGUILoaded();
|
void onGUILoaded();
|
||||||
|
|
Loading…
Reference in a new issue