Page tree
Skip to end of metadata
Go to start of metadata

This is the base class for a user defined plugin

#include "PluginCore.h"

Overview

This is the base class for a user defined plugin.

If you generated a project with fbgen.py, you already have an implementation in projects/pluginName/pluginName.h and .cpp which you can easily extend.

Reference

createJSAPI()

virtual FB::JSAPIPtr createJSAPI() = 0

  • shall return a JSAPI* wrapped in a FB::JSAPIPtr() which represents the scriptable interface for the plugin
  • use JSAPIAuto for convenient creation of a scriptable object

Plugin window

FB::PluginWindow* GetWindow()

  • returns the current plugin window

void SetWindow(FB::PluginWindow* win)

  • Called by the browser to set the current plugin window to win

void ClearWindow()

  • Called by the browser to detach the current plugin window

SetHost()

void SetHost(FB::BrowserHost host)

  • Called by the browser to set the browser host for the plugin to host

IsWindowLess()

virtual bool IsWindowLess() = 0

  • shall return true if the plugin is window-less, false otherwise
  • implemented by classes that uses PluginCore

HandleEvent()

virtual bool HandleEvent(FB::PluginEvent* ev) = 0

  • receives events for the plugin
  • shall return true if the event was handled, false otherwise
  • see PluginEvent

Event maps

  • BEGIN_PLUGIN_EVENT_MAP()
  • END_PLUGIN_EVENT_MAP()
  • EVENTTYPE_CASE(eventType, handler, sourcetype)

To ease handling of events, a event mapping system is provided.
Event maps start with BEGIN_PLUGIN_EVENT_MAP() and end with END_PLUGIN_EVENT_MAP().

To specify which functions are to handle which events, use EVENTTYPE_CASE(eventType, handler):

class MyPlugin : public FB::PluginCore
{
public:
/\* ... \*/

virtual bool onMouseDown(FB::MouseDownEvent \*evt, FB::PluginWindow \*win);
virtual bool onMouseUp  (FB::MouseUpEvent   \*evt, FB::PluginWindow \*win);
virtual bool onMouseMove(FB::MouseMoveEvent \*evt, FB::PluginWindow \*win);

BEGIN_PLUGIN_EVENT_MAP()
EVENTTYPE_CASE(FB::MouseDownEvent, onMouseDown, FB::PluginWindow)
EVENTTYPE_CASE(FB::MouseUpEvent,   onMouseUp, FB::PluginWindow)
EVENTTYPE_CASE(FB::MouseMoveEvent, onMouseMove, FB::PluginWindow)
EVENTTYPE_CASE(FB::AttachedEvent, onWindowAttached, FB::PluginWindow)
EVENTTYPE_CASE(FB::DetachedEvent, onWindowDetached, FB::PluginWindow)
END_PLUGIN_EVENT_MAP()
};
  • No labels