Changing passes should now show up on the material widget too!

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent 02e61b1e1b
commit 067676c049

@ -172,7 +172,10 @@ namespace MaterialEditor
{
QDockWidget *dock = new QDockWidget( tr( "Material" ), this );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
dock->setWidget( new MaterialWidget() );
MaterialWidget *mw = new MaterialWidget();
passesWidget->setMaterialObserver( mw );
dock->setWidget( mw );
addDockWidget( Qt::RightDockWidgetArea, dock );
}

@ -0,0 +1,40 @@
// Object Viewer Qt Material Editor plugin <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 MATERIAL_OBSERVER_H
#define MATERIAL_OBSERVER_H
namespace MaterialEditor
{
/// Observes material changes
class CMaterialObserver
{
public:
CMaterialObserver(){}
virtual ~CMaterialObserver(){}
virtual void onPassAdded( const char *name ) = 0;
virtual void onPassRemoved( const char *name ) = 0;
virtual void onPassMovedUp( const char *name ) = 0;
virtual void onPassMovedDown( const char *name ) = 0;
virtual void onPassRenamed( const char *from, const char *to ) = 0;
};
}
#endif

@ -38,6 +38,56 @@ namespace MaterialEditor
matPropWidget = NULL;
}
void MaterialWidget::onPassAdded( const char *name )
{
passCB->addItem( name );
}
void MaterialWidget::onPassRemoved( const char *name )
{
int i = passCB->findText( name );
if( i == -1 )
return;
passCB->removeItem( i );
}
void MaterialWidget::onPassMovedUp( const char *name )
{
int i = passCB->findText( name );
if( i == -1 )
return;
if( i == 0 )
return;
QString t = passCB->itemText( i - 1 );
passCB->setItemText( i - 1, name );
passCB->setItemText( i, t );
passCB->setCurrentIndex( i - 1 );
}
void MaterialWidget::onPassMovedDown( const char *name )
{
int i = passCB->findText( name );
if( i == -1 )
return;
if( i == ( passCB->count() - 1 ) )
return;
QString t = passCB->itemText( i + 1 );
passCB->setItemText( i + 1, name );
passCB->setItemText( i, t );
passCB->setCurrentIndex( i + 1 );
}
void MaterialWidget::onPassRenamed( const char *from, const char *to )
{
int i = passCB->findText( from );
if( i == -1 )
return;
passCB->setItemText( i, to );
}
void MaterialWidget::setupConnections()
{
connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) );

@ -18,19 +18,26 @@
#define MATERIAL_WIDGET_H
#include "ui_material_widget.h"
#include "material_observer.h"
namespace MaterialEditor
{
class ShaderEditorWidget;
class MatPropWidget;
class MaterialWidget : public QWidget, Ui::MaterialWidget
class MaterialWidget : public QWidget, public Ui::MaterialWidget, public CMaterialObserver
{
Q_OBJECT
public:
MaterialWidget( QWidget *parent = NULL );
~MaterialWidget();
void onPassAdded( const char *name );
void onPassRemoved( const char *name );
void onPassMovedUp( const char *name );
void onPassMovedDown( const char *name );
void onPassRenamed( const char *from, const char *to );
private:
void setupConnections();
ShaderEditorWidget *shaderEditorWidget;

@ -16,6 +16,7 @@
#include "render_passes.h"
#include "nel3d_interface.h"
#include "material_observer.h"
#include <QInputDialog>
#include <QMessageBox>
@ -27,6 +28,7 @@ namespace MaterialEditor
setupUi( this );
setupConnections();
nl3dIface = NULL;
observer = NULL;
}
RenderPassesWidget::~RenderPassesWidget()
@ -109,6 +111,9 @@ namespace MaterialEditor
CNelMaterialProxy material = nl3dIface->getMaterial();
material.addPass( label.toUtf8().data() );
if( observer != NULL )
observer->onPassAdded( label.toUtf8().data() );
}
void RenderPassesWidget::onRemoveClicked()
@ -124,6 +129,9 @@ namespace MaterialEditor
CNelMaterialProxy material = nl3dIface->getMaterial();
material.removePass( pass.toUtf8().data() );
if( observer != NULL )
observer->onPassRemoved( pass.toUtf8().data() );
}
void RenderPassesWidget::onEditClicked()
@ -149,6 +157,9 @@ namespace MaterialEditor
CNelMaterialProxy material = nl3dIface->getMaterial();
material.renamePass( from.toUtf8().data(), to.toUtf8().data() );
if( observer != NULL )
observer->onPassRenamed( from.toUtf8().data(), to.toUtf8().data() );
}
void RenderPassesWidget::onUpClicked()
@ -169,6 +180,9 @@ namespace MaterialEditor
CNelMaterialProxy material = nl3dIface->getMaterial();
material.movePassUp( s.toUtf8().data() );
if( observer != NULL )
observer->onPassMovedUp( s.toUtf8().data() );
}
void RenderPassesWidget::onDownClicked()
@ -189,6 +203,9 @@ namespace MaterialEditor
CNelMaterialProxy material = nl3dIface->getMaterial();
material.movePassDown( s.toUtf8().data() );
if( observer != NULL )
observer->onPassMovedDown( s.toUtf8().data() );
}
}

@ -23,6 +23,7 @@
namespace MaterialEditor
{
class CNel3DInterface;
class CMaterialObserver;
class RenderPassesWidget : public QWidget, public Ui::RenderPassesWidget
{
@ -35,10 +36,13 @@ namespace MaterialEditor
void clear();
void setNel3dIface( CNel3DInterface *iface ){ nl3dIface = iface; }
void setMaterialObserver( CMaterialObserver *obs ){ observer = obs; }
private:
void setupConnections();
CNel3DInterface *nl3dIface;
CMaterialObserver *observer;
private Q_SLOTS:
void onOKClicked();

Loading…
Cancel
Save