ADDED: #1471 Nel3D widget ( based on Dnk's similar widget ), NelGUI widget skeletons. NelGUI widget will be the widget which renders the GUI library's output and forward the input for it.

This commit is contained in:
dfighter1985 2012-07-19 04:39:30 +02:00
parent a840d7ad24
commit 19a087a0f7
9 changed files with 272 additions and 1 deletions

View file

@ -126,6 +126,9 @@ namespace NLGUI
/// Delete all textures and the like and reset the view renderer /// Delete all textures and the like and reset the view renderer
void reset(); void reset();
/// Release the resources of CViewRenderer, and delete the Singleton
static void release();
/// Retrieves the 3d driver we are using /// Retrieves the 3d driver we are using
static NL3D::UDriver* getDriver(); static NL3D::UDriver* getDriver();

View file

@ -184,6 +184,18 @@ namespace NLGUI
_Material.setTexture(3, NULL); _Material.setTexture(3, NULL);
_Material.setZBias(0); _Material.setZBias(0);
} }
void CViewRenderer::release()
{
if( instance != NULL )
{
instance->reset();
delete instance;
instance = NULL;
}
}
/* /*
* reset: reset the whole view renderer * reset: reset the whole view renderer
*/ */

View file

@ -20,6 +20,8 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
proc_editor.h proc_editor.h
property_browser_ctrl.h property_browser_ctrl.h
project_window.h project_window.h
nel3d_widget.h
nelgui_widget.h
) )
SET(OVQT_PLUGIN_GUI_EDITOR_UIS SET(OVQT_PLUGIN_GUI_EDITOR_UIS

View file

@ -37,6 +37,7 @@
#include "proc_editor.h" #include "proc_editor.h"
#include "project_file_parser.h" #include "project_file_parser.h"
#include "project_window.h" #include "project_window.h"
#include "nelgui_widget.h"
namespace GUIEditor namespace GUIEditor
{ {
@ -51,7 +52,10 @@ namespace GUIEditor
widgetProps = new CWidgetProperties; widgetProps = new CWidgetProperties;
linkEditor = new LinkEditor; linkEditor = new LinkEditor;
procEditor = new ProcEditor; procEditor = new ProcEditor;
projectWindow = new ProjectWindow(); projectWindow = new ProjectWindow;
viewPort = new NelGUIWidget;
setCentralWidget( viewPort );
createMenus(); createMenus();
readSettings(); readSettings();
@ -74,6 +78,8 @@ namespace GUIEditor
browserCtrl.setup(); browserCtrl.setup();
dock->setWidget( tb ); dock->setWidget( tb );
addDockWidget( Qt::RightDockWidgetArea, dock ); addDockWidget( Qt::RightDockWidgetArea, dock );
viewPort->init();
} }
GUIEditorWindow::~GUIEditorWindow() GUIEditorWindow::~GUIEditorWindow()
@ -91,6 +97,9 @@ namespace GUIEditor
delete projectWindow; delete projectWindow;
projectWindow = NULL; projectWindow = NULL;
delete viewPort;
viewPort = NULL;
} }
QUndoStack *GUIEditorWindow::undoStack() const QUndoStack *GUIEditorWindow::undoStack() const
@ -163,6 +172,10 @@ namespace GUIEditor
a = new QAction( "Project Window", this ); a = new QAction( "Project Window", this );
connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) ); connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) );
m->addAction( a ); m->addAction( a );
a = new QAction( "Clear Viewport", this );
connect( a, SIGNAL( triggered( bool ) ), viewPort, SLOT( clear() ) );
m->addAction( a );
} }
} }

View file

@ -31,6 +31,7 @@ namespace GUIEditor
class LinkEditor; class LinkEditor;
class ProcEditor; class ProcEditor;
class ProjectWindow; class ProjectWindow;
class NelGUIWidget;
class GUIEditorWindow: public QMainWindow class GUIEditorWindow: public QMainWindow
{ {
@ -63,6 +64,7 @@ private:
LinkEditor *linkEditor; LinkEditor *linkEditor;
ProcEditor *procEditor; ProcEditor *procEditor;
ProjectWindow *projectWindow; ProjectWindow *projectWindow;
NelGUIWidget *viewPort;
CPropBrowserCtrl browserCtrl; CPropBrowserCtrl browserCtrl;
QString currentProject; QString currentProject;

View file

@ -0,0 +1,94 @@
// Object Viewer Qt GUI 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 "nel3d_widget.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/text_context.h"
#include "nel/misc/rgba.h"
#include "nel/misc/path.h"
namespace GUIEditor
{
Nel3DWidget::Nel3DWidget( QWidget *parent ) :
QWidget( parent )
{
driver = NULL;
textContext = NULL;
}
Nel3DWidget::~Nel3DWidget()
{
if( driver != NULL )
{
if( textContext != NULL )
{
driver->deleteTextContext( textContext );
textContext = NULL;
}
driver->release();
delete driver;
driver = NULL;
}
}
void Nel3DWidget::init()
{
nlassert( driver == NULL );
driver = NL3D::UDriver::createDriver( 0, false, 0 );
driver->setMatrixMode2D11();
driver->setDisplay( winId(), NL3D::UDriver::CMode( width(), height(), 32, true ) );
}
void Nel3DWidget::createTextContext( std::string fontFile )
{
if( driver == NULL )
return;
std::string font;
try
{
font = NLMISC::CPath::lookup( fontFile );
}
catch( ... )
{
nlinfo( "Font %s cannot be found, cannot create textcontext!", fontFile.c_str() );
exit( EXIT_FAILURE );
}
if( textContext != NULL )
{
driver->deleteTextContext( textContext );
textContext = NULL;
}
textContext = driver->createTextContext( font );
}
void Nel3DWidget::clear()
{
if( driver == NULL )
return;
driver->clearBuffers( NLMISC::CRGBA::Black );
driver->swapBuffers();
}
}

View file

@ -0,0 +1,56 @@
// Object Viewer Qt GUI 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 NEL3D_WIDGET_H
#define NEL3D_WIDGET_H
#include <QWidget>
#include <string>
namespace NL3D
{
class UDriver;
class UTextContext;
}
namespace GUIEditor
{
/// Nel 3D interface to Qt
class Nel3DWidget : public QWidget
{
Q_OBJECT
public:
Nel3DWidget( QWidget *parent = NULL );
virtual ~Nel3DWidget();
virtual void init();
void createTextContext( std::string fontFile );
NL3D::UDriver* getDriver() const{ return driver; }
NL3D::UTextContext* getTextContext() const{ return textContext; }
public Q_SLOTS:
void clear();
private:
NL3D::UDriver *driver;
NL3D::UTextContext *textContext;
};
}
#endif

View file

@ -0,0 +1,52 @@
// Object Viewer Qt GUI 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 "nelgui_widget.h"
#include "nel/misc/path.h"
#include "nel/gui/view_renderer.h"
#include <set>
#include <string>
namespace GUIEditor
{
std::set< std::string > hwCursors;
NelGUIWidget::NelGUIWidget( QWidget *parent ) :
Nel3DWidget( parent )
{
}
NelGUIWidget::~NelGUIWidget()
{
NLGUI::CViewRenderer::release();
}
void NelGUIWidget::init()
{
NLMISC::CPath::addSearchPath( "fonts" );
Nel3DWidget::init();
createTextContext( "Ryzom.ttf" );
NLGUI::CViewRenderer::setDriver( getDriver() );
NLGUI::CViewRenderer::setTextContext( getTextContext() );
NLGUI::CViewRenderer::hwCursors = &hwCursors;
NLGUI::CViewRenderer::getInstance()->init();
}
}

View file

@ -0,0 +1,37 @@
// Object Viewer Qt GUI 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 NELGUI_WIDGET_H
#define NELGUI_WIDGET_H
#include "nel3d_widget.h"
namespace GUIEditor
{
/// Qt viewport for the Nel GUI library
class NelGUIWidget : public Nel3DWidget
{
Q_OBJECT
public:
NelGUIWidget( QWidget *parent = NULL );
~NelGUIWidget();
void init();
};
}
#endif