More GUI skeleton work. Added Shader Editor widget.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent e87e265c42
commit d46944f258

@ -19,6 +19,7 @@ SET(OVQT_PLUGIN_MATERIAL_EDITOR_HDR
material_property_editor.h
material_widget.h
render_passes.h
shader_editor.h
)
SET(OVQT_PLUGIN_MATERIAL_EDITOR_UIS
@ -27,6 +28,7 @@ SET(OVQT_PLUGIN_MATERIAL_EDITOR_UIS
material_property_editor.ui
material_widget.ui
render_passes.ui
shader_editor.ui
)
SET(QT_USE_QTGUI TRUE)

@ -16,6 +16,7 @@
#include "material_widget.h"
#include "render_passes.h"
#include "shader_editor.h"
namespace MaterialEditor
{
@ -25,6 +26,7 @@ namespace MaterialEditor
{
setupUi( this );
renderPassesWidget = new RenderPassesWidget();
shaderEditorWidget = new ShaderEditorWidget();
setupConnections();
}
@ -32,19 +34,31 @@ namespace MaterialEditor
{
delete renderPassesWidget;
renderPassesWidget = NULL;
delete shaderEditorWidget;
shaderEditorWidget = NULL;
}
void MaterialWidget::setupConnections()
{
connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) );
connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) );
connect( renderPassesWidget, SIGNAL( passAdded( const QString& ) ),
this, SLOT( onPassAdded( const QString& ) ) );
connect( renderPassesWidget, SIGNAL( passRemoved( const QString& ) ),
this, SLOT( onPassRemoved( const QString& ) ) );
connect( renderPassesWidget, SIGNAL( okClicked() ), this, SLOT( onPassOKClicked() ) );
connect( renderPassesWidget, SIGNAL( passRenamed( const QString&, const QString& ) ),
this, SLOT( onPassRenamed( const QString&, const QString& ) ) );
connect( renderPassesWidget, SIGNAL( passPushedUp( const QString& ) ),
this, SLOT( onPassPushedUp( const QString& ) ) );
connect( renderPassesWidget, SIGNAL( passPushedDown( const QString& ) ),
this, SLOT( onPassPushedDown( const QString& ) ) );
connect( shaderEditorWidget, SIGNAL( okClicked() ), this, SLOT( onShaderEditOKClicked() ) );
}
void MaterialWidget::onPassEditClicked()
@ -52,19 +66,68 @@ namespace MaterialEditor
renderPassesWidget->show();
}
void MaterialWidget::onPassOKClicked()
void MaterialWidget::onShaderEditClicked()
{
shaderEditorWidget->show();
}
void MaterialWidget::onPassAdded( const QString &pass )
{
passCB->addItem( pass );
}
void MaterialWidget::onPassRemoved( const QString &pass )
{
int i = passCB->findText( pass );
if( i == -1 )
return;
passCB->removeItem( i );
}
void MaterialWidget::onPassRenamed( const QString &from, const QString &to )
{
int i = passCB->findText( from );
if( i == -1 )
return;
passCB->setItemText( i, to );
}
void MaterialWidget::onPassPushedUp( const QString &pass )
{
int i = passCB->findText( pass );
if( i == -1 )
return;
if( i == 0 )
return;
QString temp = passCB->itemText( i - 1 );
passCB->setItemText( i - 1, pass );
passCB->setItemText( i, temp );
if( passCB->currentIndex() == i )
passCB->setCurrentIndex( i - 1 );
}
void MaterialWidget::onPassPushedDown( const QString &pass )
{
int i = passCB->findText( pass );
if( i == -1 )
return;
if( i == ( passCB->count() - 1 ) )
return;
QString temp = passCB->itemText( i + 1 );
passCB->setItemText( i + 1, pass );
passCB->setItemText( i, temp );
if( passCB->currentIndex() == i )
passCB->setCurrentIndex( i + 1 );
}
void MaterialWidget::onShaderEditOKClicked()
{
}

@ -23,6 +23,7 @@ namespace MaterialEditor
{
class RenderPassesWidget;
class ShaderEditorWidget;
class MaterialWidget : public QWidget, Ui::MaterialWidget
{
@ -34,13 +35,19 @@ namespace MaterialEditor
private:
void setupConnections();
RenderPassesWidget *renderPassesWidget;
ShaderEditorWidget *shaderEditorWidget;
private Q_SLOTS:
void onPassEditClicked();
void onPassOKClicked();
void onShaderEditClicked();
void onPassAdded( const QString &pass );
void onPassRemoved( const QString &pass );
void onPassRenamed( const QString &from, const QString &to );
void onPassPushedUp( const QString &pass );
void onPassPushedDown( const QString &pass );
void onShaderEditOKClicked();
};
}

@ -58,7 +58,6 @@ namespace MaterialEditor
void RenderPassesWidget::setupConnections()
{
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
@ -67,12 +66,6 @@ namespace MaterialEditor
}
void RenderPassesWidget::onOKClicked()
{
close();
Q_EMIT okClicked();
}
void RenderPassesWidget::onCancelClicked()
{
close();
}
@ -111,6 +104,7 @@ namespace MaterialEditor
}
listWidget->addItem( label );
Q_EMIT passAdded( label );
}
void RenderPassesWidget::onRemoveClicked()
@ -118,9 +112,13 @@ namespace MaterialEditor
int row = listWidget->currentRow();
if( row == -1 )
return;
QString pass;
QListWidgetItem *item = listWidget->takeItem( row );
pass = item->text();
delete item;
Q_EMIT passRemoved( pass );
}
void RenderPassesWidget::onEditClicked()

@ -34,6 +34,8 @@ namespace MaterialEditor
Q_SIGNALS:
void okClicked();
void passAdded( const QString &pass );
void passRemoved( const QString &pass );
void passRenamed( const QString &from, const QString &to );
void passPushedUp( const QString &pass );
void passPushedDown( const QString &pass );
@ -43,7 +45,6 @@ namespace MaterialEditor
private Q_SLOTS:
void onOKClicked();
void onCancelClicked();
void onAddClicked();
void onRemoveClicked();
void onEditClicked();

@ -125,19 +125,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

@ -0,0 +1,91 @@
// 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/>.
#include "shader_editor.h"
namespace MaterialEditor
{
ShaderEditorWidget::ShaderEditorWidget( QWidget *parent ) :
QWidget( parent )
{
setupUi( this );
setupConnections();
}
ShaderEditorWidget::~ShaderEditorWidget()
{
}
void ShaderEditorWidget::getName( QString &name )
{
name = nameEdit->text();
}
void ShaderEditorWidget::getDescription( QString &desc )
{
desc = descriptionEdit->toPlainText();
}
void ShaderEditorWidget::getVertexShader( QString &vs )
{
vs = vsEdit->toPlainText();
}
void ShaderEditorWidget::getFragmentShader( QString &fs )
{
fs = fsEdit->toPlainText();
}
void ShaderEditorWidget::setName( const QString &name )
{
nameEdit->setText( name );
}
void ShaderEditorWidget::setDescription( const QString &desc )
{
descriptionEdit->setPlainText( desc );
}
void ShaderEditorWidget::setVertexShader( const QString &vs )
{
vsEdit->setPlainText( vs );
}
void ShaderEditorWidget::setFragmentShader( const QString &fs )
{
fsEdit->setPlainText( fs );
}
void ShaderEditorWidget::setupConnections()
{
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ) ;
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
}
void ShaderEditorWidget::onOKClicked()
{
close();
Q_EMIT okClicked();
}
void ShaderEditorWidget::onCancelClicked()
{
close();
}
}

@ -0,0 +1,55 @@
// 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 SHADER_EDITOR_H
#define SHADER_EDITOR_H
#include "ui_shader_editor.h"
namespace MaterialEditor
{
class ShaderEditorWidget : public QWidget, public Ui::ShaderEditorWidget
{
Q_OBJECT
public:
ShaderEditorWidget( QWidget *parent = NULL );
~ShaderEditorWidget();
void getName( QString &name );
void getDescription( QString &desc );
void getVertexShader( QString &vs );
void getFragmentShader( QString &fs );
void setName( const QString &name );
void setDescription( const QString &desc );
void setVertexShader( const QString &vs );
void setFragmentShader( const QString &fs );
private Q_SLOTS:
void onOKClicked();
void onCancelClicked();
Q_SIGNALS:
void okClicked();
private:
void setupConnections();
};
}
#endif

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShaderEditorWidget</class>
<widget class="QWidget" name="ShaderEditorWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<height>729</height>
</rect>
</property>
<property name="windowTitle">
<string>Shader Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="nameLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="descrLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="descriptionEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="vsLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vertex Shader</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="vsEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="fsLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Fragment Shader</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="fsEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="okButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>468</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save