diff --git a/code/studio/src/plugins/gui_editor/CMakeLists.txt b/code/studio/src/plugins/gui_editor/CMakeLists.txt index 4b50ec8d1..77ca5a335 100644 --- a/code/studio/src/plugins/gui_editor/CMakeLists.txt +++ b/code/studio/src/plugins/gui_editor/CMakeLists.txt @@ -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) diff --git a/code/studio/src/plugins/gui_editor/expression_editor.cpp b/code/studio/src/plugins/gui_editor/expression_editor.cpp new file mode 100644 index 000000000..81ea74941 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_editor.cpp @@ -0,0 +1,88 @@ +// Ryzom Core Studio - Georges Editor Plugin +// +// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#include "expression_editor.h" +#include +#include +#include +#include + +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 ]; +} + + + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.h b/code/studio/src/plugins/gui_editor/expression_editor.h new file mode 100644 index 000000000..31fb64d73 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_editor.h @@ -0,0 +1,51 @@ +// Ryzom Core Studio - Georges Editor Plugin +// +// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#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 + diff --git a/code/studio/src/plugins/gui_editor/expression_editor.ui b/code/studio/src/plugins/gui_editor/expression_editor.ui new file mode 100644 index 000000000..80480ad39 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/expression_editor.ui @@ -0,0 +1,34 @@ + + + ExpressionEditor + + + Qt::ApplicationModal + + + + 0 + 0 + 724 + 522 + + + + Expression Editor + + + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOn + + + + + + + + diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp index 3f4e318db..f6adacc8a 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.cpp @@ -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; } } diff --git a/code/studio/src/plugins/gui_editor/gui_editor_window.h b/code/studio/src/plugins/gui_editor/gui_editor_window.h index d18a24813..d0dbe628e 100644 --- a/code/studio/src/plugins/gui_editor/gui_editor_window.h +++ b/code/studio/src/plugins/gui_editor/gui_editor_window.h @@ -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; }; }