diff --git a/code/nel/include/nel/gui/editor_selection_watcher.h b/code/nel/include/nel/gui/editor_selection_watcher.h
index 415f4f9db..7e262bdf1 100644
--- a/code/nel/include/nel/gui/editor_selection_watcher.h
+++ b/code/nel/include/nel/gui/editor_selection_watcher.h
@@ -15,6 +15,7 @@
// along with this program. If not, see .
#include
+#include
namespace NLGUI
{
@@ -24,7 +25,7 @@ namespace NLGUI
public:
/// Notifies the watcher about the change
- virtual void selectionChanged( std::string &newSelection ) = 0;
+ virtual void selectionChanged() = 0;
};
}
diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h
index 917a0e9ba..243847ad7 100644
--- a/code/nel/include/nel/gui/widget_manager.h
+++ b/code/nel/include/nel/gui/widget_manager.h
@@ -503,8 +503,15 @@ namespace NLGUI
IParser* getParser() const{ return parser; }
- std::string& getCurrentEditorSelection(){ return currentEditorSelection; }
- void setCurrentEditorSelection( const std::string &name );
+ /// Retrieves the Id of the currently selected widgets
+ void getEditorSelection( std::vector< std::string > &selection );
+
+ /// Adds the widget with the specified Id to the selected widgets
+ void selectWidget( const std::string &name );
+
+ /// Clears the selection
+ void clearEditorSelection();
+
void notifySelectionWatchers();
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
void unregisterSelectionWatcher( IEditorSelectionWatcher *watcher );
@@ -519,6 +526,7 @@ namespace NLGUI
void setGroupSelection( bool b ){ groupSelection = b; }
bool unGroupSelection();
+ void setMultiSelection( bool b ){ multiSelection = b; }
private:
CWidgetManager();
@@ -611,9 +619,9 @@ namespace NLGUI
std::vector< IEditorSelectionWatcher* > selectionWatchers;
std::vector< IWidgetWatcher* > widgetWatchers;
-
- std::string currentEditorSelection;
+ std::vector< std::string > editorSelection;
bool groupSelection;
+ bool multiSelection;
};
}
diff --git a/code/nel/src/gui/view_base.cpp b/code/nel/src/gui/view_base.cpp
index 05d958d3e..2b09061a9 100644
--- a/code/nel/src/gui/view_base.cpp
+++ b/code/nel/src/gui/view_base.cpp
@@ -57,7 +57,7 @@ namespace NLGUI
{
if( editorMode )
{
- CWidgetManager::getInstance()->setCurrentEditorSelection( getId() );
+ CWidgetManager::getInstance()->selectWidget( getId() );
return true;
}
}
diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp
index c26a23231..6ee1588c3 100644
--- a/code/nel/src/gui/widget_manager.cpp
+++ b/code/nel/src/gui/widget_manager.cpp
@@ -2077,9 +2077,9 @@ namespace NLGUI
if( CInterfaceElement::getEditorMode() )
{
- if( !currentEditorSelection.empty() )
+ for( int i = 0; i < editorSelection.size(); i++ )
{
- CInterfaceElement *e = getElementFromId( currentEditorSelection );
+ CInterfaceElement *e = getElementFromId( editorSelection[ i ] );
if( e != NULL )
e->drawHighlight();
}
@@ -2478,7 +2478,7 @@ namespace NLGUI
else
{
if( CInterfaceElement::getEditorMode() )
- setCurrentEditorSelection( "" );
+ clearEditorSelection();
}
}
@@ -3349,25 +3349,53 @@ namespace NLGUI
}
}
+ void CWidgetManager::getEditorSelection( std::vector< std::string > &selection )
+ {
+ selection.clear();
+ for( int i = 0; i < editorSelection.size(); i++ )
+ selection.push_back( editorSelection[ i ] );
+ }
- void CWidgetManager::setCurrentEditorSelection( const std::string &name )
+ void CWidgetManager::selectWidget( const std::string &name )
{
+ std::vector< std::string >::iterator itr
+ = std::find( editorSelection.begin(), editorSelection.end(), name );
+
CInterfaceElement *e = getElementFromId( name );
- if( e != NULL )
+
+ if( itr != editorSelection.end() )
{
- if( !currentEditorSelection.empty() )
+ // If multiselection is on unselect if already selected
+ if( multiSelection )
{
- CInterfaceElement *prev = getElementFromId( currentEditorSelection );
- if( prev != NULL )
- prev->setEditorSelected( false );
+ editorSelection.erase( itr );
+ if( e != NULL )
+ e->setEditorSelected( false );
}
- e->setEditorSelected( true );
}
else
- if( !name.empty() )
- return;
-
- currentEditorSelection = name;
+ {
+ // Select if not yet selected
+ if( e != NULL )
+ {
+ // If multiselection is off, we can only have 1 widget selected
+ if( !multiSelection )
+ {
+ editorSelection.clear();
+ }
+
+ e->setEditorSelected( true );
+ editorSelection.push_back( name );
+ }
+
+ }
+
+ notifySelectionWatchers();
+ }
+
+ void CWidgetManager::clearEditorSelection()
+ {
+ editorSelection.clear();
notifySelectionWatchers();
}
@@ -3376,7 +3404,7 @@ namespace NLGUI
std::vector< IEditorSelectionWatcher* >::iterator itr = selectionWatchers.begin();
while( itr != selectionWatchers.end() )
{
- (*itr)->selectionChanged( currentEditorSelection );
+ (*itr)->selectionChanged();
++itr;
}
}
@@ -3484,11 +3512,11 @@ namespace NLGUI
bool CWidgetManager::unGroupSelection()
{
- if( currentEditorSelection.empty() )
+ if( editorSelection.size() != 1 )
return false;
// Does the element exist?
- CInterfaceElement *e = getElementFromId( currentEditorSelection );
+ CInterfaceElement *e = getElementFromId( editorSelection[ 0 ] );
if( e == NULL )
return false;
@@ -3509,7 +3537,7 @@ namespace NLGUI
p->delElement( g );
- setCurrentEditorSelection( "" );
+ clearEditorSelection();
p->updateCoords();
@@ -3554,8 +3582,8 @@ namespace NLGUI
setScreenWH( 0, 0 );
- currentEditorSelection = "";
groupSelection = false;
+ multiSelection = false;
}
CWidgetManager::~CWidgetManager()
@@ -3569,6 +3597,8 @@ namespace NLGUI
curContextHelp = NULL;
CStringShared::deleteStringMapper();
+
+ editorSelection.clear();
}
}
diff --git a/code/studio/src/plugins/gui_editor/editor_message_processor.cpp b/code/studio/src/plugins/gui_editor/editor_message_processor.cpp
index 4c48a4fa4..a818cf174 100644
--- a/code/studio/src/plugins/gui_editor/editor_message_processor.cpp
+++ b/code/studio/src/plugins/gui_editor/editor_message_processor.cpp
@@ -25,35 +25,40 @@ namespace GUIEditor
{
void CEditorMessageProcessor::onDelete()
{
- std::string selection = CWidgetManager::getInstance()->getCurrentEditorSelection();
+ std::vector< std::string > selection;
+
+ CWidgetManager::getInstance()->getEditorSelection( selection );
if( selection.empty() )
return;
QMessageBox::StandardButton r =
QMessageBox::question( NULL,
tr( "Deleting widget" ),
- tr( "Are you sure you want to delete %1?" ).arg( selection.c_str() ),
+ tr( "Are you sure you want to delete these?" ),
QMessageBox::Yes | QMessageBox::No );
if( r != QMessageBox::Yes )
return;
- CInterfaceElement *e =
- CWidgetManager::getInstance()->getElementFromId( selection );
- if( e == NULL )
- return;
+ for( int i = 0; i < selection.size(); i++ )
+ {
+ CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( selection[ i ] );
+ if( e == NULL )
+ continue;
- CInterfaceElement *p = e->getParent();
- if( p == NULL )
- return;
-
- CInterfaceGroup *g = dynamic_cast< CInterfaceGroup* >( p );
- if( g == NULL )
- return;
+ CInterfaceElement *p = e->getParent();
+ if( p == NULL )
+ continue;
+
+ CInterfaceGroup *g = dynamic_cast< CInterfaceGroup* >( p );
+ if( g == NULL )
+ continue;
+
+ g->delElement( e );
- if( g->delElement( e ) )
- {
- CWidgetManager::getInstance()->setCurrentEditorSelection( "" );
}
+
+
+ CWidgetManager::getInstance()->clearEditorSelection();
}
void CEditorMessageProcessor::onAdd( const QString &parentGroup, const QString &widgetType, const QString &name )
@@ -147,5 +152,10 @@ namespace GUIEditor
tr( "Couldn't ungroup widgets." ) );
}
}
+
+ void CEditorMessageProcessor::onSetMultiSelection( bool b )
+ {
+ CWidgetManager::getInstance()->setMultiSelection( b );
+ }
}
diff --git a/code/studio/src/plugins/gui_editor/editor_message_processor.h b/code/studio/src/plugins/gui_editor/editor_message_processor.h
index 9e6d3cf89..c3483e2ef 100644
--- a/code/studio/src/plugins/gui_editor/editor_message_processor.h
+++ b/code/studio/src/plugins/gui_editor/editor_message_processor.h
@@ -40,6 +40,7 @@ namespace GUIEditor
void onAdd( const QString &parentGroup, const QString &widgetType, const QString &name );
void onSetGroupSelection( bool b );
void onUngroup();
+ void onSetMultiSelection( bool b );
private:
CWidgetInfoTree *tree;
diff --git a/code/studio/src/plugins/gui_editor/editor_selection_watcher.cpp b/code/studio/src/plugins/gui_editor/editor_selection_watcher.cpp
index ee3a079ad..7647c8abb 100644
--- a/code/studio/src/plugins/gui_editor/editor_selection_watcher.cpp
+++ b/code/studio/src/plugins/gui_editor/editor_selection_watcher.cpp
@@ -18,9 +18,9 @@
namespace GUIEditor
{
- void CEditorSelectionWatcher::selectionChanged( std::string &newSelection )
+ void CEditorSelectionWatcher::selectionChanged()
{
- Q_EMIT sgnSelectionChanged( newSelection );
+ Q_EMIT sgnSelectionChanged();
}
}
diff --git a/code/studio/src/plugins/gui_editor/editor_selection_watcher.h b/code/studio/src/plugins/gui_editor/editor_selection_watcher.h
index 61218c0cd..2eab68310 100644
--- a/code/studio/src/plugins/gui_editor/editor_selection_watcher.h
+++ b/code/studio/src/plugins/gui_editor/editor_selection_watcher.h
@@ -27,10 +27,10 @@ namespace GUIEditor
public:
CEditorSelectionWatcher() : QObject( NULL ){}
- void selectionChanged( std::string &newSelection );
+ void selectionChanged();
Q_SIGNALS:
- void sgnSelectionChanged( std::string &id );
+ void sgnSelectionChanged();
};
}
diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp
index 01433bf9e..6cc072ce8 100644
--- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp
+++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp
@@ -283,8 +283,8 @@ namespace GUIEditor
CEditorSelectionWatcher *w = GUICtrl->getWatcher();
- disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) );
- disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
+ disconnect( w, SIGNAL( sgnSelectionChanged() ), hierarchyView, SLOT( onSelectionChanged() ) );
+ disconnect( w, SIGNAL( sgnSelectionChanged() ), &browserCtrl, SLOT( onSelectionChanged() ) );
projectFiles.clearAll();
projectWindow->clear();
@@ -322,8 +322,8 @@ namespace GUIEditor
linkList->onGUILoaded();
CEditorSelectionWatcher *w = GUICtrl->getWatcher();
- connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) );
- connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
+ connect( w, SIGNAL( sgnSelectionChanged() ), hierarchyView, SLOT( onSelectionChanged() ) );
+ connect( w, SIGNAL( sgnSelectionChanged() ), &browserCtrl, SLOT( onSelectionChanged() ) );
}
void GUIEditorWindow::onAddWidgetClicked()
@@ -413,6 +413,12 @@ namespace GUIEditor
connect( a, SIGNAL( triggered( bool ) ), messageProcessor, SLOT( onSetGroupSelection( bool ) ) );
m->addAction( a );
+ a = new QAction( "Multiselect", this );
+ a->setCheckable( true );
+ a->setChecked( false );
+ connect( a, SIGNAL( triggered( bool ) ), messageProcessor, SLOT( onSetMultiSelection( bool ) ) );
+ m->addAction( a );
+
menu = m;
}
}
diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp
index c005f80e5..84302bcf0 100644
--- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp
+++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.cpp
@@ -436,7 +436,7 @@ namespace GUIEditor
browser->clear();
}
- void CPropBrowserCtrl::onSelectionChanged( std::string &id )
+ void CPropBrowserCtrl::onSelectionChanged()
{
if( browser == NULL )
return;
@@ -444,14 +444,20 @@ namespace GUIEditor
disablePropertyWatchers();
browser->clear();
- CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id );
+ std::vector< std::string > selection;
+ CWidgetManager::getInstance()->getEditorSelection( selection );
+
+ if( selection.size() != 1 )
+ return;
+
+ CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( selection[ 0 ] );
if( e == NULL )
{
enablePropertyWatchers();
return;
}
- currentElement = id;
+ currentElement = selection[ 0 ];
std::string n = e->getClassName();
diff --git a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h
index abf80d7de..3d72d92ba 100644
--- a/code/studio/src/plugins/gui_editor/property_browser_ctrl.h
+++ b/code/studio/src/plugins/gui_editor/property_browser_ctrl.h
@@ -59,7 +59,7 @@ namespace GUIEditor
void clear();
public Q_SLOTS:
- void onSelectionChanged( std::string &id );
+ void onSelectionChanged();
private Q_SLOTS:
void onPropertyChanged( QtProperty *prop, const QVariant &v );
diff --git a/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp b/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp
index 1439fea9e..343d8efd8 100644
--- a/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp
+++ b/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp
@@ -304,14 +304,15 @@ namespace GUIEditor
void WidgetHierarchy::getCurrentGroup( QString &g )
{
- std::string s = CWidgetManager::getInstance()->getCurrentEditorSelection();
- if( s.empty() )
+ std::vector< std::string > selection;
+ CWidgetManager::getInstance()->getEditorSelection( selection );
+ if( selection.size() != 1 )
{
g = "";
return;
}
- NLGUI::CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( s );
+ NLGUI::CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( selection[ 0 ] );
if( e == NULL )
{
g = "";
@@ -342,8 +343,16 @@ namespace GUIEditor
currentSelection.clear();
}
- void WidgetHierarchy::onSelectionChanged( std::string &newSelection )
+ void WidgetHierarchy::onSelectionChanged()
{
+ std::vector< std::string > selection;
+ CWidgetManager::getInstance()->getEditorSelection( selection );
+
+ if( selection.size() != 1 )
+ return;
+
+ std::string newSelection = selection[ 0 ];
+
if( newSelection == currentSelection )
return;
@@ -376,6 +385,6 @@ namespace GUIEditor
std::string n = item->text( 0 ).toUtf8().constData();
currentSelection = makeFullName( item, n );
- CWidgetManager::getInstance()->setCurrentEditorSelection( currentSelection );
+ CWidgetManager::getInstance()->selectWidget( currentSelection );
}
}
diff --git a/code/studio/src/plugins/gui_editor/widget_hierarchy.h b/code/studio/src/plugins/gui_editor/widget_hierarchy.h
index 27218715d..cdfc9a741 100644
--- a/code/studio/src/plugins/gui_editor/widget_hierarchy.h
+++ b/code/studio/src/plugins/gui_editor/widget_hierarchy.h
@@ -56,7 +56,7 @@ namespace GUIEditor
public Q_SLOTS:
void onGUILoaded();
- void onSelectionChanged( std::string &newSelection );
+ void onSelectionChanged();
private Q_SLOTS:
void onItemDblClicked( QTreeWidgetItem *item );