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.
--HG-- branch : gsoc2012-gui-editorhg/feature/sse2
parent
203f12d2cd
commit
f9bcc43d8c
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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
|
Loading…
Reference in New Issue