MODIFIED: Update property browser when selecting in the central widget.
This commit is contained in:
parent
dcad62844b
commit
02dbaec3dd
12 changed files with 177 additions and 12 deletions
30
code/nel/include/nel/gui/editor_selection_watcher.h
Normal file
30
code/nel/include/nel/gui/editor_selection_watcher.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace NLGUI
|
||||||
|
{
|
||||||
|
/// Watches the currently selected GUI widget
|
||||||
|
class IEditorSelectionWatcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Notifies the watcher about the change
|
||||||
|
virtual void selectionChanged( std::string &newSelection ) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace NLGUI
|
||||||
class CInterfaceOptions;
|
class CInterfaceOptions;
|
||||||
class CInterfaceAnim;
|
class CInterfaceAnim;
|
||||||
class CProcedure;
|
class CProcedure;
|
||||||
|
class IEditorSelectionWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
GUI Widget Manager
|
GUI Widget Manager
|
||||||
|
@ -485,6 +486,9 @@ namespace NLGUI
|
||||||
IParser* getParser() const{ return parser; }
|
IParser* getParser() const{ return parser; }
|
||||||
|
|
||||||
void setCurrentEditorSelection( const std::string &name );
|
void setCurrentEditorSelection( const std::string &name );
|
||||||
|
void notifySelectionWatchers();
|
||||||
|
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
|
||||||
|
void unregisterSelectionWatcher( IEditorSelectionWatcher *watcher );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CWidgetManager();
|
CWidgetManager();
|
||||||
|
@ -564,6 +568,8 @@ namespace NLGUI
|
||||||
|
|
||||||
std::vector< INewScreenSizeHandler* > newScreenSizeHandlers;
|
std::vector< INewScreenSizeHandler* > newScreenSizeHandlers;
|
||||||
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
|
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
|
||||||
|
std::vector< IEditorSelectionWatcher* > selectionWatchers;
|
||||||
|
|
||||||
|
|
||||||
std::string currentEditorSelection;
|
std::string currentEditorSelection;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "nel/gui/proc.h"
|
#include "nel/gui/proc.h"
|
||||||
#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/misc/events.h"
|
#include "nel/misc/events.h"
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
|
@ -3181,9 +3182,44 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
e->setEditorSelected( true );
|
e->setEditorSelected( true );
|
||||||
currentEditorSelection = name;
|
currentEditorSelection = name;
|
||||||
|
notifySelectionWatchers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWidgetManager::notifySelectionWatchers()
|
||||||
|
{
|
||||||
|
std::vector< IEditorSelectionWatcher* >::iterator itr = selectionWatchers.begin();
|
||||||
|
while( itr != selectionWatchers.end() )
|
||||||
|
{
|
||||||
|
(*itr)->selectionChanged( currentEditorSelection );
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWidgetManager::registerSelectionWatcher( IEditorSelectionWatcher *watcher )
|
||||||
|
{
|
||||||
|
std::vector< IEditorSelectionWatcher* >::iterator itr =
|
||||||
|
std::find( selectionWatchers.begin(), selectionWatchers.end(), watcher );
|
||||||
|
|
||||||
|
// We already have this watcher
|
||||||
|
if( itr != selectionWatchers.end() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectionWatchers.push_back( watcher );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWidgetManager::unregisterSelectionWatcher( IEditorSelectionWatcher *watcher )
|
||||||
|
{
|
||||||
|
std::vector< IEditorSelectionWatcher* >::iterator itr =
|
||||||
|
std::find( selectionWatchers.begin(), selectionWatchers.end(), watcher );
|
||||||
|
|
||||||
|
// We don't have this watcher
|
||||||
|
if( itr == selectionWatchers.end() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectionWatchers.erase( itr );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CWidgetManager::CWidgetManager()
|
CWidgetManager::CWidgetManager()
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,6 +60,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
|
||||||
nelgui_widget.h
|
nelgui_widget.h
|
||||||
new_property_widget.h
|
new_property_widget.h
|
||||||
new_widget_widget.h
|
new_widget_widget.h
|
||||||
|
editor_selection_watcher.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include "editor_selection_watcher.h"
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
void CEditorSelectionWatcher::selectionChanged( std::string &newSelection )
|
||||||
|
{
|
||||||
|
Q_EMIT sgnSelectionChanged( newSelection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#include "nel/gui/editor_selection_watcher.h"
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
/// Watches the Editor selection, and emits a signal when it changes
|
||||||
|
class CEditorSelectionWatcher : public QObject, public NLGUI::IEditorSelectionWatcher
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CEditorSelectionWatcher() : QObject( NULL ){}
|
||||||
|
|
||||||
|
void selectionChanged( std::string &newSelection );
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void sgnSelectionChanged( std::string &id );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "project_file_serializer.h"
|
#include "project_file_serializer.h"
|
||||||
#include "project_window.h"
|
#include "project_window.h"
|
||||||
#include "nelgui_widget.h"
|
#include "nelgui_widget.h"
|
||||||
|
#include "editor_selection_watcher.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -91,11 +92,7 @@ namespace GUIEditor
|
||||||
|
|
||||||
viewPort->init();
|
viewPort->init();
|
||||||
|
|
||||||
connect( viewPort, SIGNAL( guiLoadComplete() ), hierarchyView, SLOT( onGUILoaded() ) );
|
connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) );
|
||||||
connect( viewPort, SIGNAL( guiLoadComplete() ), procList, SLOT( onGUILoaded() ) );
|
|
||||||
connect( viewPort, SIGNAL( guiLoadComplete() ), linkList, SLOT( onGUILoaded() ) );
|
|
||||||
connect( hierarchyView, SIGNAL( selectionChanged( std::string& ) ),
|
|
||||||
&browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIEditorWindow::~GUIEditorWindow()
|
GUIEditorWindow::~GUIEditorWindow()
|
||||||
|
@ -262,6 +259,11 @@ namespace GUIEditor
|
||||||
if( reply != QMessageBox::Yes )
|
if( reply != QMessageBox::Yes )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
CEditorSelectionWatcher *w = viewPort->getWatcher();
|
||||||
|
disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) );
|
||||||
|
disconnect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
|
||||||
|
|
||||||
projectFiles.clearAll();
|
projectFiles.clearAll();
|
||||||
projectWindow->clear();
|
projectWindow->clear();
|
||||||
hierarchyView->clearHierarchy();
|
hierarchyView->clearHierarchy();
|
||||||
|
@ -291,6 +293,16 @@ namespace GUIEditor
|
||||||
setCursor( Qt::ArrowCursor );
|
setCursor( Qt::ArrowCursor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIEditorWindow::onGUILoaded()
|
||||||
|
{
|
||||||
|
hierarchyView->onGUILoaded();
|
||||||
|
procList->onGUILoaded();
|
||||||
|
linkList->onGUILoaded();
|
||||||
|
|
||||||
|
CEditorSelectionWatcher *w = viewPort->getWatcher();
|
||||||
|
connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), hierarchyView, SLOT( onSelectionChanged( std::string& ) ) );
|
||||||
|
connect( w, SIGNAL( sgnSelectionChanged( std::string& ) ), &browserCtrl, SLOT( onSelectionChanged( std::string& ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
void GUIEditorWindow::createMenus()
|
void GUIEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onProjectFilesChanged();
|
void onProjectFilesChanged();
|
||||||
|
void onGUILoaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createMenus();
|
void createMenus();
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
#include "editor_selection_watcher.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -37,6 +38,7 @@ namespace GUIEditor
|
||||||
{
|
{
|
||||||
timerID = 0;
|
timerID = 0;
|
||||||
guiLoaded = false;
|
guiLoaded = false;
|
||||||
|
watcher = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
NelGUIWidget::~NelGUIWidget()
|
NelGUIWidget::~NelGUIWidget()
|
||||||
|
@ -70,6 +72,8 @@ namespace GUIEditor
|
||||||
NLGUI::CViewRenderer::getInstance()->init();
|
NLGUI::CViewRenderer::getInstance()->init();
|
||||||
|
|
||||||
CWidgetManager::getInstance()->getParser()->setEditorMode( true );
|
CWidgetManager::getInstance()->getParser()->setEditorMode( true );
|
||||||
|
|
||||||
|
watcher = new CEditorSelectionWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NelGUIWidget::parse( SProjectFiles &files )
|
bool NelGUIWidget::parse( SProjectFiles &files )
|
||||||
|
@ -106,6 +110,8 @@ namespace GUIEditor
|
||||||
guiLoaded = true;
|
guiLoaded = true;
|
||||||
Q_EMIT guiLoadComplete();
|
Q_EMIT guiLoadComplete();
|
||||||
|
|
||||||
|
CWidgetManager::getInstance()->registerSelectionWatcher( watcher );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +121,7 @@ namespace GUIEditor
|
||||||
if( timerID != 0 )
|
if( timerID != 0 )
|
||||||
killTimer( timerID );
|
killTimer( timerID );
|
||||||
timerID = 0;
|
timerID = 0;
|
||||||
|
CWidgetManager::getInstance()->unregisterSelectionWatcher( watcher );
|
||||||
CWidgetManager::getInstance()->reset();
|
CWidgetManager::getInstance()->reset();
|
||||||
CWidgetManager::getInstance()->getParser()->removeAll();
|
CWidgetManager::getInstance()->getParser()->removeAll();
|
||||||
CViewRenderer::getInstance()->reset();
|
CViewRenderer::getInstance()->reset();
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
class CEditorSelectionWatcher;
|
||||||
|
|
||||||
/// Qt viewport for the Nel GUI library
|
/// Qt viewport for the Nel GUI library
|
||||||
class NelGUIWidget : public Nel3DWidget
|
class NelGUIWidget : public Nel3DWidget
|
||||||
{
|
{
|
||||||
|
@ -35,6 +37,7 @@ namespace GUIEditor
|
||||||
bool parse( SProjectFiles &files );
|
bool parse( SProjectFiles &files );
|
||||||
void draw();
|
void draw();
|
||||||
void reset();
|
void reset();
|
||||||
|
CEditorSelectionWatcher* getWatcher(){ return watcher; }
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void guiLoadComplete();
|
void guiLoadComplete();
|
||||||
|
@ -49,6 +52,7 @@ Q_SIGNALS:
|
||||||
private:
|
private:
|
||||||
int timerID;
|
int timerID;
|
||||||
bool guiLoaded;
|
bool guiLoaded;
|
||||||
|
CEditorSelectionWatcher *watcher;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,16 @@ namespace GUIEditor
|
||||||
if( masterGroup.empty() )
|
if( masterGroup.empty() )
|
||||||
return;
|
return;
|
||||||
buildHierarchy( masterGroup );
|
buildHierarchy( masterGroup );
|
||||||
|
currentSelection.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidgetHierarchy::onSelectionChanged( std::string &newSelection )
|
||||||
|
{
|
||||||
|
if( newSelection == currentSelection )
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
// Update the tree
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item )
|
void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item )
|
||||||
|
@ -138,9 +148,7 @@ namespace GUIEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string n = item->text( 0 ).toUtf8().constData();
|
std::string n = item->text( 0 ).toUtf8().constData();
|
||||||
std::string selection = makeFullName( item, n );
|
currentSelection = makeFullName( item, n );
|
||||||
CWidgetManager::getInstance()->setCurrentEditorSelection( selection );
|
CWidgetManager::getInstance()->setCurrentEditorSelection( currentSelection );
|
||||||
|
|
||||||
Q_EMIT selectionChanged( selection );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace GUIEditor
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onGUILoaded();
|
void onGUILoaded();
|
||||||
|
void onSelectionChanged( std::string &newSelection );
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onItemDblClicked( QTreeWidgetItem *item );
|
void onItemDblClicked( QTreeWidgetItem *item );
|
||||||
|
@ -52,9 +53,6 @@ namespace GUIEditor
|
||||||
private:
|
private:
|
||||||
std::string currentSelection;
|
std::string currentSelection;
|
||||||
std::string masterGroup;
|
std::string masterGroup;
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void selectionChanged( std::string &id );
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue