Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::PropertyWidgetCEF Class Reference

Handler for setting, getting, onChange and PropertyObservable of a property from HTML. Handles "property.set", "property.get" commands sent from the Inviwo javascript API (see webbrowser/data/js/inviwoapi.js) and sets property values on the Inviwo-side. More...

#include <modules/webbrowser/properties/propertywidgetcef.h>

+ Inheritance diagram for inviwo::PropertyWidgetCEF:

Public Member Functions

const std::string & getOnChange () const
 
const std::string & getPropertyObserverCallback () const
 
virtual bool onQuery (CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, int64_t query_id, const CefString &request, bool persistent, CefRefPtr< CefMessageRouterBrowserSide::Handler::Callback > callback)
 
 PropertyWidgetCEF (Property *prop, const JSONPropertyConverter &converter, CefRefPtr< CefFrame > frame=nullptr, std::string_view onChange="")
 
void setFrame (CefRefPtr< CefFrame > frame)
 
void setOnChange (std::string_view onChange)
 
void setPropertyObserverCallback (std::string_view propertyObserverCallback)
 
virtual void updateFromProperty () override
 
- Public Member Functions inherited from inviwo::PropertyWidget
virtual PropertyEditorWidgetgetEditorWidget ()
 
virtual PropertygetProperty ()
 
virtual bool hasEditorWidget () const
 
PropertyWidgetoperator= (const PropertyWidget &)
 
PropertyWidgetoperator= (PropertyWidget &&)
 
 PropertyWidget (const PropertyWidget &)
 
 PropertyWidget (Property *property)
 
 PropertyWidget (PropertyWidget &&)
 
virtual ~PropertyWidget ()
 
- Public Member Functions inherited from inviwo::Observer
 Observer (const Observer &other)
 
 Observer (Observer &&other)
 
Observeroperator= (const Observer &other)
 
Observeroperator= (Observer &&other)
 
void removeObservation (ObservableInterface *observable)
 
void removeObservations ()
 
virtual ~Observer ()
 

Protected Member Functions

virtual void onSetDisplayName (Property *property, const std::string &displayName) override
 
virtual void onSetIdentifier (Property *property, const std::string &identifier) override
 
virtual void onSetReadOnly (Property *property, bool readonly) override
 
virtual void onSetSemantics (Property *property, const PropertySemantics &semantics) override
 
virtual void onSetVisible (Property *property, bool visible) override
 
- Protected Member Functions inherited from inviwo::Observer
void addObservation (ObservableInterface *observable)
 

Protected Attributes

const JSONPropertyConverterconverter_
 
CefRefPtr< CefFrame > frame_
 Execute on any PropertyObserver notifications.
 
std::string onChange_
 
std::string propertyObserverCallback_
 Callback to execute in javascript when property changes.
 
- Protected Attributes inherited from inviwo::PropertyWidget
Propertyproperty_ = nullptr
 
- Protected Attributes inherited from inviwo::Observer
std::unordered_set< ObservableInterface * > observables_
 

Friends

class CefDOMSearchId
 
class PropertyCefSynchronizer
 

Detailed Description

Handler for setting, getting, onChange and PropertyObservable of a property from HTML. Handles "property.set", "property.get" commands sent from the Inviwo javascript API (see webbrowser/data/js/inviwoapi.js) and sets property values on the Inviwo-side.

PropertyWidgetCEF must have a PropertyJSONConverter for its corresponding property. Thus, to add support for a new property it is only necessary to:

  1. Implement to_json and from_json
  2. Register converter using WebbrowserModule::registerPropertyJSONConverterAndWidget<PropertyWidgetCEF, MyNewProperty>()

Example code on HTML-side:

<script language="JavaScript">
// Initialize Inviwo API so that we can use it to synchronize properties
var inviwo = new InviwoAPI();
</script>
<input type="range" class="slider" id="PropertyIdentifier"
oninput="inviwo.setProperty('MyProcessor.MyProperty', {value: Number(this.value)})">
Note
Property serialization cannot be used to implement synchronization since it for example changes the property identifier if not set.

Member Function Documentation

◆ onSetDisplayName()

virtual void inviwo::PropertyWidgetCEF::onSetDisplayName ( Property * property,
const std::string & displayName )
overrideprotectedvirtual

Calls the currently set propertyObserverCallback function in javascript with the JSON encoded changed value as parameter. The propertyObserverCallback javascript function must be in global scope.

See also
setPropertyObserverCallback

Reimplemented from inviwo::PropertyObserver.

◆ onSetIdentifier()

virtual void inviwo::PropertyWidgetCEF::onSetIdentifier ( Property * property,
const std::string & identifier )
overrideprotectedvirtual

Calls the currently set propertyObserverCallback function in javascript with the JSON encoded changed value as parameter. The propertyObserverCallback javascript function must be in global scope.

See also
setPropertyObserverCallback

Reimplemented from inviwo::PropertyObserver.

◆ onSetReadOnly()

virtual void inviwo::PropertyWidgetCEF::onSetReadOnly ( Property * property,
bool readonly )
overrideprotectedvirtual

Calls the currently set propertyObserverCallback function in javascript with the JSON encoded changed value as parameter. The propertyObserverCallback javascript function must be in global scope.

See also
setPropertyObserverCallback

Reimplemented from inviwo::PropertyObserver.

◆ onSetSemantics()

virtual void inviwo::PropertyWidgetCEF::onSetSemantics ( Property * property,
const PropertySemantics & semantics )
overrideprotectedvirtual

Calls the currently set propertyObserverCallback function in javascript with the JSON encoded changed value as parameter. The propertyObserverCallback javascript function must be in global scope.

See also
setPropertyObserverCallback

Reimplemented from inviwo::PropertyObserver.

◆ onSetVisible()

virtual void inviwo::PropertyWidgetCEF::onSetVisible ( Property * property,
bool visible )
overrideprotectedvirtual

Calls the currently set propertyObserverCallback function in javascript with the JSON encoded changed value as parameter. The propertyObserverCallback javascript function must be in global scope.

See also
setPropertyObserverCallback

Reimplemented from inviwo::PropertyObserver.

◆ updateFromProperty()

virtual void inviwo::PropertyWidgetCEF::updateFromProperty ( )
overridevirtual

Calls the currently set onChange function in javascript with the JSON encoded property as parameter. The onChange javascript function must be in global scope.

See also
setOnChange

Implements inviwo::PropertyWidget.

Reimplemented in inviwo::MinMaxPropertyWidgetCEF< T >.


The documentation for this class was generated from the following file: