xentara-workbench-plugin v1.0.1
The Xentara Workbench Plugin Framework
Loading...
Searching...
No Matches
xentara::workbench::bindings::ImportButton Class Referencefinal

A button for generating child elements by importing an external file. More...

#include <xentara/workbench/bindings/ImportButton.hpp>

+ Inheritance diagram for xentara::workbench::bindings::ImportButton:

Classes

struct  Options
 Options for the binding. More...
 

Public Types

template<typename Object >
using ReadFile = auto(Object::*)(const std::filesystem::path &path) -> utils::eh::expected< std::string, ui::String >
 The type for the function that read the file.
 

Public Member Functions

template<typename Object >
 ImportButton (const PropertyHandle &property, Object &object, ReadFile< Object > readFile, Options options)
 Constructor.
 

Detailed Description

A button for generating child elements by importing an external file.

Member Typedef Documentation

◆ ReadFile

template<typename Object >
using xentara::workbench::bindings::ImportButton::ReadFile = auto (Object::*)(const std::filesystem::path &path) -> utils::eh::expected<std::string, ui::String>

The type for the function that read the file.

This function is called when the import button is clicker to read the file. It must return a JSON string containing an array with the newly imported elements. The JSON format for the elements is the same as the format for Xentara model files.

The elements in the returned JSON string do not need to contain any UUIDs. Any UUIDs will be overwritten.

Constructor & Destructor Documentation

◆ ImportButton()

template<typename Object >
xentara::workbench::bindings::ImportButton::ImportButton ( const PropertyHandle property,
Object &  object,
ReadFile< Object >  readFile,
Options  options 
)

Constructor.

Parameters
propertyA handle to the bound property. This property need not contain a value, it is only used to track changes in visibility.
objectThe object on which the callback should be called
readFileThe callback function that reads the imported file
optionsThe binding options