mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-11 20:04:46 +00:00
Added GUI for expression editor.
This commit is contained in:
parent
32a085fb33
commit
b0553f8918
6 changed files with 192 additions and 0 deletions
|
@ -34,6 +34,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
|
|||
texture_chooser.h
|
||||
action_property_manager.h
|
||||
texture_property_manager.h
|
||||
expression_editor.h
|
||||
)
|
||||
|
||||
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
||||
|
@ -51,6 +52,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
|||
add_widget_widget.ui
|
||||
action_list.ui
|
||||
texture_chooser.ui
|
||||
expression_editor.ui
|
||||
)
|
||||
|
||||
SET(QT_USE_QTGUI TRUE)
|
||||
|
|
88
code/studio/src/plugins/gui_editor/expression_editor.cpp
Normal file
88
code/studio/src/plugins/gui_editor/expression_editor.cpp
Normal 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 ];
|
||||
}
|
||||
|
||||
|
||||
|
51
code/studio/src/plugins/gui_editor/expression_editor.h
Normal file
51
code/studio/src/plugins/gui_editor/expression_editor.h
Normal 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
|
||||
|
34
code/studio/src/plugins/gui_editor/expression_editor.ui
Normal file
34
code/studio/src/plugins/gui_editor/expression_editor.ui
Normal 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>
|
|
@ -46,6 +46,8 @@
|
|||
#include "add_widget_widget.h"
|
||||
#include "texture_chooser.h"
|
||||
|
||||
#include "expression_editor.h"
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
QString _lastDir;
|
||||
|
@ -72,6 +74,7 @@ namespace GUIEditor
|
|||
widgetInfoTree = new CWidgetInfoTree;
|
||||
|
||||
tc = new TextureChooser();
|
||||
ee = new ExpressionEditor();
|
||||
|
||||
createMenus();
|
||||
readSettings();
|
||||
|
@ -120,6 +123,8 @@ namespace GUIEditor
|
|||
|
||||
delete tc;
|
||||
tc = NULL;
|
||||
delete ee;
|
||||
ee = NULL;
|
||||
|
||||
delete messageProcessor;
|
||||
messageProcessor = NULL;
|
||||
|
@ -365,6 +370,11 @@ namespace GUIEditor
|
|||
tc->exec();
|
||||
}
|
||||
|
||||
void GUIEditorWindow::onEEClicked()
|
||||
{
|
||||
ee->show();
|
||||
}
|
||||
|
||||
void GUIEditorWindow::createMenus()
|
||||
{
|
||||
Core::MenuManager *mm = Core::ICore::instance()->menuManager();
|
||||
|
@ -415,6 +425,10 @@ namespace GUIEditor
|
|||
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onTCClicked() ) );
|
||||
m->addAction( a );
|
||||
|
||||
a = new QAction( "Expression Editor", this );
|
||||
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onEEClicked() ) );
|
||||
m->addAction( a );
|
||||
|
||||
menu = m;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ class QtTreePropertyBrowser;
|
|||
class QMenu;
|
||||
|
||||
class TextureChooser;
|
||||
class ExpressionEditor;
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
|
@ -68,6 +69,7 @@ private Q_SLOTS:
|
|||
void onAddWidgetClicked();
|
||||
void onTreeChanged();
|
||||
void onTCClicked();
|
||||
void onEEClicked();
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -103,6 +105,7 @@ private:
|
|||
QMenu *menu;
|
||||
|
||||
TextureChooser *tc;
|
||||
ExpressionEditor *ee;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue