-
Notifications
You must be signed in to change notification settings - Fork 43
Embedding Tutorial
In this tutorial we will learn how to create a simple application which embeds VisualScriptEngine. Before reading this tutorial I highly recommend you to understand the Source Structure and Building the Engine pages.
Follow the steps on the Building the Engine page. You will need only the Core Modules, but if you are on windows, it is highly recommended to compile the windows related modules, too.
As the result of the previous step some binary library files are created. You have to link these to your application. Of course you have to add the Header folders of the modules to your applications include path.
You will need these modules:
- NodeEngine
- NodeUIEngine
- BuiltInNodes (optional, but recommended)
- WindowsAppSupport (optional, only if you are on windows, and don't want to do a lot of coding yourself)
You just have to implement some virtual functions and forward your input events to the engine. Ok, it isn't that simple, but this tutorial will guide you the through the required steps.
First of all you have to include the main entry point file for the engine.
#include "NodeEditor.hpp"
Now you have to implement some interfaces.
This interface is responsible for all drawing operations. You have to implement all of the draw methods for primitives. If you use windows, you can found some implementations in the WindowsAppSupport module.
Important note: The context should be offscreen, because the engine usually draws on this context outside of the paint event. You should blit the content of this context in your applications paint event when the engine notifies you that the drawing is ready.
This interface is responsible for the theme of the drawing. You can set colors, fonts, line weights and so on. There is a default implementation called NUIE::DefaultSkinParams
. You can use this if you don't want to customize the drawings.
This interface is responsible for platform-dependent event handler implementations. The engine can call these functions anytime during user interactions. For this tutorial it is completely OK if we provide the default implementation for all of the functions.
Later, you have to implement two types of handlers:
- OnContextMenu: The engine calls these function when a context menu should appear over the blank area, or over a node or slot.
- OnParameterSettings: The engine calls this function if a node parameter settings dialog should appear.
class MyEventHandlers : public NUIE::EventHandlers
{
public:
MyEventHandlers () :
NUIE::EventHandlers ()
{
}
virtual NUIE::CommandPtr OnContextMenu (
NUIE::NodeUIManager& uiManager,
NUIE::NodeUIEnvironment& uiEnvironment,
const NUIE::Point& position,
const NUIE::CommandStructure& commands) override
{
return nullptr;
}
virtual NUIE::CommandPtr OnContextMenu (
NUIE::NodeUIManager& uiManager,
NUIE::NodeUIEnvironment& env,
const NUIE::Point& position,
const NUIE::UINodePtr& uiNode,
const NUIE::CommandStructure& commands) override
{
return nullptr;
}
virtual NUIE::CommandPtr OnContextMenu (
NUIE::NodeUIManager& uiManager,
NUIE::NodeUIEnvironment& env,
const NUIE::Point& position,
const NE::OutputSlotPtr& outputSlot,
const NUIE::CommandStructure& commands) override
{
return nullptr;
}
virtual NUIE::CommandPtr OnContextMenu (
NUIE::NodeUIManager& uiManager,
NUIE::NodeUIEnvironment& env,
const NUIE::Point& position,
const NE::InputSlotPtr& inputSlot,
const NUIE::CommandStructure& commands) override
{
return nullptr;
}
virtual bool OnParameterSettings (NUIE::NodeParameterAccessorPtr) override
{
return false;
}
};
To be continued...