Added GUI for expression editor.

This commit is contained in:
dfighter1985 2014-09-12 19:19:51 +02:00
parent 60205f51e8
commit b300bb1ee7
6 changed files with 192 additions and 0 deletions

View file

@ -34,6 +34,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
texture_chooser.h texture_chooser.h
action_property_manager.h action_property_manager.h
texture_property_manager.h texture_property_manager.h
expression_editor.h
) )
SET(OVQT_PLUGIN_GUI_EDITOR_UIS SET(OVQT_PLUGIN_GUI_EDITOR_UIS
@ -51,6 +52,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS
add_widget_widget.ui add_widget_widget.ui
action_list.ui action_list.ui
texture_chooser.ui texture_chooser.ui
expression_editor.ui
) )
SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTGUI TRUE)

View file

@ -0,0 +1,88 @@
// Ryzom Core Studio - Georges Editor Plugin
//
// Copyright (C) 2014 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// 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 "expression_editor.h"
#include <QGraphicsScene>
#include <QGraphicsItem>
#include <QMenu>
#include <qevent.h>
ExpressionEditor::ExpressionEditor( QWidget *parent ) :
QWidget( parent )
{
m_ui.setupUi( this );
m_selection = NULL;
m_scene = new QGraphicsScene( this );
m_ui.view->setScene( m_scene );
m_scene->addSimpleText( "Hello" );
connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
}
ExpressionEditor::~ExpressionEditor()
{
m_scene = NULL;
}
void ExpressionEditor::contextMenuEvent( QContextMenuEvent *e )
{
QMenu menu;
QAction *a = NULL;
a = menu.addAction( "Add rect" );
connect( a, SIGNAL( triggered() ), this, SLOT( onAddRect() ) );
if( m_selection != NULL )
{
a = menu.addAction( "Remove" );
connect( a, SIGNAL( triggered() ), this, SLOT( onDeleteSelection() ) );
}
menu.exec( e->globalPos() );
}
void ExpressionEditor::onAddRect()
{
QGraphicsRectItem *item = new QGraphicsRectItem( 0, 0, 100, 100 );
item->setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable );
m_scene->addItem( item );
}
void ExpressionEditor::onDeleteSelection()
{
m_scene->removeItem( m_selection );
}
void ExpressionEditor::onSelectionChanged()
{
QList< QGraphicsItem* > l = m_scene->selectedItems();
if( l.isEmpty() )
{
m_selection = NULL;
return;
}
m_selection = l[ 0 ];
}

View file

@ -0,0 +1,51 @@
// Ryzom Core Studio - Georges Editor Plugin
//
// Copyright (C) 2014 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// 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 EXPRESSION_EDITOR
#define EXPRESSION_EDITOR
#include "ui_expression_editor.h"
class QGraphicsScene;
class QGraphicsItem;
class ExpressionEditor : public QWidget
{
Q_OBJECT
public:
ExpressionEditor( QWidget *parent = NULL );
~ExpressionEditor();
protected:
void contextMenuEvent( QContextMenuEvent *e );
private Q_SLOTS:
void onAddRect();
void onDeleteSelection();
void onSelectionChanged();
private:
Ui::ExpressionEditor m_ui;
QGraphicsScene *m_scene;
QGraphicsItem *m_selection;
};
#endif

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExpressionEditor</class>
<widget class="QWidget" name="ExpressionEditor">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<height>522</height>
</rect>
</property>
<property name="windowTitle">
<string>Expression Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGraphicsView" name="view">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -46,6 +46,8 @@
#include "add_widget_widget.h" #include "add_widget_widget.h"
#include "texture_chooser.h" #include "texture_chooser.h"
#include "expression_editor.h"
namespace GUIEditor namespace GUIEditor
{ {
QString _lastDir; QString _lastDir;
@ -72,6 +74,7 @@ namespace GUIEditor
widgetInfoTree = new CWidgetInfoTree; widgetInfoTree = new CWidgetInfoTree;
tc = new TextureChooser(); tc = new TextureChooser();
ee = new ExpressionEditor();
createMenus(); createMenus();
readSettings(); readSettings();
@ -120,6 +123,8 @@ namespace GUIEditor
delete tc; delete tc;
tc = NULL; tc = NULL;
delete ee;
ee = NULL;
delete messageProcessor; delete messageProcessor;
messageProcessor = NULL; messageProcessor = NULL;
@ -365,6 +370,11 @@ namespace GUIEditor
tc->exec(); tc->exec();
} }
void GUIEditorWindow::onEEClicked()
{
ee->show();
}
void GUIEditorWindow::createMenus() void GUIEditorWindow::createMenus()
{ {
Core::MenuManager *mm = Core::ICore::instance()->menuManager(); Core::MenuManager *mm = Core::ICore::instance()->menuManager();
@ -415,6 +425,10 @@ namespace GUIEditor
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) );
m->addAction( a ); m->addAction( a );
a = new QAction( "Expression Editor", this );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onEEClicked() ) );
m->addAction( a );
menu = m; menu = m;
} }
} }

View file

@ -29,6 +29,7 @@ class QtTreePropertyBrowser;
class QMenu; class QMenu;
class TextureChooser; class TextureChooser;
class ExpressionEditor;
namespace GUIEditor namespace GUIEditor
{ {
@ -68,6 +69,7 @@ private Q_SLOTS:
void onAddWidgetClicked(); void onAddWidgetClicked();
void onTreeChanged(); void onTreeChanged();
void onTCClicked(); void onTCClicked();
void onEEClicked();
protected: protected:
@ -103,6 +105,7 @@ private:
QMenu *menu; QMenu *menu;
TextureChooser *tc; TextureChooser *tc;
ExpressionEditor *ee;
}; };
} }