MODIFIED: Update property browser when selecting in the central widget.

This commit is contained in:
dfighter1985 2013-02-23 06:55:19 +01:00
parent dcad62844b
commit 02dbaec3dd
12 changed files with 177 additions and 12 deletions

View 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;
};
}

View file

@ -47,6 +47,7 @@ namespace NLGUI
class CInterfaceOptions;
class CInterfaceAnim;
class CProcedure;
class IEditorSelectionWatcher;
/**
GUI Widget Manager
@ -485,6 +486,9 @@ namespace NLGUI
IParser* getParser() const{ return parser; }
void setCurrentEditorSelection( const std::string &name );
void notifySelectionWatchers();
void registerSelectionWatcher( IEditorSelectionWatcher *watcher );
void unregisterSelectionWatcher( IEditorSelectionWatcher *watcher );
private:
CWidgetManager();
@ -564,6 +568,8 @@ namespace NLGUI
std::vector< INewScreenSizeHandler* > newScreenSizeHandlers;
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
std::vector< IEditorSelectionWatcher* > selectionWatchers;
std::string currentEditorSelection;
};

View file

@ -31,6 +31,7 @@
#include "nel/gui/proc.h"
#include "nel/gui/interface_expr.h"
#include "nel/gui/reflect_register.h"
#include "nel/gui/editor_selection_watcher.h"
#include "nel/misc/events.h"
namespace NLGUI
@ -3181,9 +3182,44 @@ namespace NLGUI
}
e->setEditorSelected( true );
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()
{

View file

@ -60,6 +60,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
nelgui_widget.h
new_property_widget.h
new_widget_widget.h
editor_selection_watcher.h
)
SET(OVQT_PLUGIN_GUI_EDITOR_UIS

View file

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

View file

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

View file

@ -41,6 +41,7 @@
#include "project_file_serializer.h"
#include "project_window.h"
#include "nelgui_widget.h"
#include "editor_selection_watcher.h"
namespace GUIEditor
{
@ -91,11 +92,7 @@ namespace GUIEditor
viewPort->init();
connect( viewPort, SIGNAL( guiLoadComplete() ), hierarchyView, 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& ) ) );
connect( viewPort, SIGNAL( guiLoadComplete() ), this, SLOT( onGUILoaded() ) );
}
GUIEditorWindow::~GUIEditorWindow()
@ -262,6 +259,11 @@ namespace GUIEditor
if( reply != QMessageBox::Yes )
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();
projectWindow->clear();
hierarchyView->clearHierarchy();
@ -291,6 +293,16 @@ namespace GUIEditor
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()
{

View file

@ -58,6 +58,7 @@ public Q_SLOTS:
private Q_SLOTS:
void onProjectFilesChanged();
void onGUILoaded();
private:
void createMenus();

View file

@ -27,6 +27,7 @@
#include <set>
#include <string>
#include <QTimerEvent>
#include "editor_selection_watcher.h"
namespace GUIEditor
{
@ -37,6 +38,7 @@ namespace GUIEditor
{
timerID = 0;
guiLoaded = false;
watcher = NULL;
}
NelGUIWidget::~NelGUIWidget()
@ -70,6 +72,8 @@ namespace GUIEditor
NLGUI::CViewRenderer::getInstance()->init();
CWidgetManager::getInstance()->getParser()->setEditorMode( true );
watcher = new CEditorSelectionWatcher();
}
bool NelGUIWidget::parse( SProjectFiles &files )
@ -106,6 +110,8 @@ namespace GUIEditor
guiLoaded = true;
Q_EMIT guiLoadComplete();
CWidgetManager::getInstance()->registerSelectionWatcher( watcher );
return true;
}
@ -115,6 +121,7 @@ namespace GUIEditor
if( timerID != 0 )
killTimer( timerID );
timerID = 0;
CWidgetManager::getInstance()->unregisterSelectionWatcher( watcher );
CWidgetManager::getInstance()->reset();
CWidgetManager::getInstance()->getParser()->removeAll();
CViewRenderer::getInstance()->reset();

View file

@ -23,6 +23,8 @@
namespace GUIEditor
{
class CEditorSelectionWatcher;
/// Qt viewport for the Nel GUI library
class NelGUIWidget : public Nel3DWidget
{
@ -35,6 +37,7 @@ namespace GUIEditor
bool parse( SProjectFiles &files );
void draw();
void reset();
CEditorSelectionWatcher* getWatcher(){ return watcher; }
Q_SIGNALS:
void guiLoadComplete();
@ -49,6 +52,7 @@ Q_SIGNALS:
private:
int timerID;
bool guiLoaded;
CEditorSelectionWatcher *watcher;
};
}

View file

@ -130,6 +130,16 @@ namespace GUIEditor
if( masterGroup.empty() )
return;
buildHierarchy( masterGroup );
currentSelection.clear();
}
void WidgetHierarchy::onSelectionChanged( std::string &newSelection )
{
if( newSelection == currentSelection )
return;
// Update the tree
}
void WidgetHierarchy::onItemDblClicked( QTreeWidgetItem *item )
@ -138,9 +148,7 @@ namespace GUIEditor
return;
std::string n = item->text( 0 ).toUtf8().constData();
std::string selection = makeFullName( item, n );
CWidgetManager::getInstance()->setCurrentEditorSelection( selection );
Q_EMIT selectionChanged( selection );
currentSelection = makeFullName( item, n );
CWidgetManager::getInstance()->setCurrentEditorSelection( currentSelection );
}
}

View file

@ -45,6 +45,7 @@ namespace GUIEditor
public Q_SLOTS:
void onGUILoaded();
void onSelectionChanged( std::string &newSelection );
private Q_SLOTS:
void onItemDblClicked( QTreeWidgetItem *item );
@ -52,9 +53,6 @@ namespace GUIEditor
private:
std::string currentSelection;
std::string masterGroup;
Q_SIGNALS:
void selectionChanged( std::string &id );
};
}