diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp index 270856804..cf805e0fd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp @@ -54,6 +54,7 @@ namespace MaterialEditor createMenus(); createDockWidgets(); + setupConnections(); QTimer::singleShot( 1, this, SLOT( onStartup() ) ); } @@ -153,6 +154,7 @@ namespace MaterialEditor void MaterialEditorWindow::onStartup() { nl3dIface->loadShaders(); + shaderWidget->load(); } void MaterialEditorWindow::createMenus() @@ -197,5 +199,16 @@ namespace MaterialEditor dock->setWidget( materialSplitter ); addDockWidget( Qt::RightDockWidgetArea, dock ); } - + + void MaterialEditorWindow::setupConnections() + { + connect( shaderWidget, SIGNAL( shaderAdded( const QString& ) ), + materialSplitter, SLOT( onShaderAdded( const QString& ) ) ); + + connect( shaderWidget, SIGNAL( shaderRemoved( const QString& ) ), + materialSplitter, SLOT( onShaderRemoved( const QString& ) ) ); + + + } + } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h index fc7522154..91f7264e4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h @@ -47,6 +47,7 @@ private Q_SLOTS: private: void createMenus(); void createDockWidgets(); + void setupConnections(); CNel3DInterface *nl3dIface; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp index 5be742598..583fcea8d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp @@ -99,6 +99,16 @@ namespace MaterialEditor materialWidget->onPassRenamed( from, to ); } + void MaterialSplitter::onShaderAdded( const QString &name ) + { + materialWidget->onShaderAdded( name ); + } + + void MaterialSplitter::onShaderRemoved( const QString &name ) + { + materialWidget->onShaderRemoved( name ); + } + void MaterialSplitter::onPropsChanged() { QString pass; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h index 5e725eacf..a289a72d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h @@ -50,6 +50,10 @@ namespace MaterialEditor void onPassMovedDown( const char *name ); void onPassRenamed( const char *from, const char *to ); + public Q_SLOTS: + void onShaderAdded( const QString &name ); + void onShaderRemoved( const QString &name ); + private: CNel3DInterface *nl3dIface; MaterialWidget *materialWidget; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp index 8f2b13e4e..1ebcab5fb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp @@ -119,6 +119,20 @@ namespace MaterialEditor passCB->setItemText( i, to ); } + void MaterialWidget::onShaderAdded( const QString &name ) + { + shaderCB->addItem( name ); + } + + void MaterialWidget::onShaderRemoved( const QString &name ) + { + int i = shaderCB->findText( name ); + if( i < 0 ) + return; + + shaderCB->removeItem( i ); + } + void MaterialWidget::getCurrentPass( QString &pass ) { pass = passCB->currentText(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h index 5e54b2fdb..a4d75220b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h @@ -42,6 +42,9 @@ namespace MaterialEditor void onPassMovedDown( const char *name ); void onPassRenamed( const char *from, const char *to ); + void onShaderAdded( const QString &name ); + void onShaderRemoved( const QString &name ); + void setNel3DIface( CNel3DInterface *iface ){ nl3dIface = iface; } void getCurrentPass( QString &pass ); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp index 264b8cc83..a310b0a24 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp @@ -47,10 +47,15 @@ namespace MaterialEditor shaderList->clear(); + QString name; + std::vector< std::string >::const_iterator itr = v.begin(); while( itr != v.end() ) { - shaderList->addItem( itr->c_str() ); + name = itr->c_str(); + shaderList->addItem( name ); + Q_EMIT shaderAdded( name ); + ++itr; } } @@ -134,6 +139,8 @@ namespace MaterialEditor } shaderList->addItem( name ); + + Q_EMIT shaderAdded( name ); } void ShaderWidget::onRemoveClicked() @@ -154,7 +161,8 @@ namespace MaterialEditor if( selection == QMessageBox::Yes ) { QListWidgetItem *item = shaderList->takeItem( i ); - std::string n = item->text().toUtf8().data(); + QString name = item->text(); + std::string n = name.toUtf8().data(); delete item; nl3dIface->removeShader( n ); @@ -162,6 +170,8 @@ namespace MaterialEditor if( shaderList->count() == 0 ) description->setPlainText( "" ); + + Q_EMIT shaderRemoved( name ); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.h index cbfb3bcd5..9659d5a03 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.h @@ -36,6 +36,10 @@ namespace MaterialEditor void setNel3DInterface( CNel3DInterface *iface ){ nl3dIface = iface; } void load(); + Q_SIGNALS: + void shaderAdded( const QString &name ); + void shaderRemoved( const QString &name ); + private: void setupConnections(); bool nameExists( const QString &name );