Scene Lab
An open source project by
FPL.
|
Public Member Functions | |
FlatbufferEditor (const FlatbufferEditorConfig *config, const reflection::Schema &schema, const reflection::Object &table_def, const void *flatbuffer_data) | |
Construct a FlatbufferEditor for a given schema and table definition, and optionally initialize it with flatbuffer data (or nullptr). More... | |
void | SetFlatbufferData (const void *flatbuffer_data) |
Override the current Flatbuffer data with this new one. More... | |
bool | HasFlatbufferData () const |
Does this FlatbufferEditor have any Flatbuffer data? More... | |
void | Update () |
Update the internal state. More... | |
void | Draw () |
Draw the Flatbuffer edit fields. Call this INSIDE a gui::Run context. | |
bool | GetFlatbufferCopy (std::vector< uint8_t > *flatbuffer_output) |
Copy the modified Flatbuffer into a vector. More... | |
bool | GetFlatbufferCopy (std::string *flatbuffer_output) |
Copy the modified Flatbuffer into a string (requires an extra copy). More... | |
std::unique_ptr< uint8_t > | GetFlatbufferCopy () |
Copy the modified Flatbuffer into a generic buffer and get a pointer. More... | |
bool | flatbuffer_modified () const |
Has the Flatbuffer data been modified? If so, you probably want to reload whatever is using it. More... | |
void | ClearFlatbufferModifiedFlag () |
Once you have reloaded the Flatbuffer into whatever you are using it for, call this to reset the "modified" flag and the list of modified fields. More... | |
const void * | flatbuffer () |
Get a pointer to the Flatbuffer we are working with, in case you want to manually copy it out. More... | |
bool | config_read_only () const |
Check if we are in Read-only mode: If true, draw the Flatbuffer using FlatUI's Label fields instead of Edit fields, just showing the values and not allowing them to be edited. More... | |
void | set_config_read_only (bool b) |
Set Read-only mode. See config_read_only() for more information. | |
bool | config_auto_commit () const |
Get the Auto-commit mode: If true, then whenever the user edits the Flatbuffer fields, automatically update the Flatbuffer contents after the user finishes editing (presses Enter or clicks on another field). More... | |
void | set_config_auto_commit (bool b) |
Set the Auto-commit mode. See config_auto_commit(). | |
bool | config_allow_resize () const |
Allow resizing of the Flatbuffer. More... | |
void | set_config_allow_resize (bool b) |
Set the "Allow resizing" config value. More... | |
bool | config_allow_adding_fields () const |
Allow adding fields to the Flatbuffer. More... | |
void | set_config_allow_adding_fields (bool b) |
Set the "Allow adding fields" config value. More... | |
float | ui_size () const |
Get the size of all the UI elements passed to FlatUI. More... | |
void | set_ui_size (float s) |
Set the UI size. See ui_size(). | |
float | ui_spacing () const |
Get the spacing of all the UI elements passed to FlatUI. More... | |
void | set_ui_spacing (float s) |
Set the UI spacing. See ui_spacing(). | |
float | blank_field_width () const |
When an editable text field is blank, we force the width of the gui Edit field to this value so that it can still be clicked on. More... | |
void | set_blank_field_width (float w) |
Set the blank field width. See blank_filed_width(). | |
bool | show_types () const |
Show the type of each subtable / struct in the Flatbuffer table? | |
void | set_show_types (bool b) |
See show_types(). | |
bool | expand_all () const |
Expand all subtables in the Flatbuffer table? | |
void | set_expand_all (bool b) |
See expand_all(). | |
bool | keyboard_in_use () const |
Is the keyboard in use? A field is being edited? You probably want to check this to make sure you don't consume those keypresses yourself. More... | |
void | set_root_id (const std::string &id) |
Set a unique root ID for all edit fields, required by FlatUI. More... | |
const std::string & | root_id () const |
See set_root_id(). | |
scene_lab::FlatbufferEditor::FlatbufferEditor | ( | const FlatbufferEditorConfig * | config, |
const reflection::Schema & | schema, | ||
const reflection::Object & | table_def, | ||
const void * | flatbuffer_data | ||
) |
Construct a FlatbufferEditor for a given schema and table definition, and optionally initialize it with flatbuffer data (or nullptr).
When you create a FlatbufferEditor, we will use reflection to copy the flatbuffer into our own internal buffer. If you want to change the Flatbuffer externally, call SetNewFlatbuffer() and pass in the new contents. If you don't have the data you want to edit yet, you can pass in nullptr, which means HasFlatbufferData() will be false and can use SetFlatbufferData later on. (And if you don't have a FlatbufferEditorConfig, just pass in nullptr and we will use default UI settings.)
|
inline |
When an editable text field is blank, we force the width of the gui Edit field to this value so that it can still be clicked on.
void scene_lab::FlatbufferEditor::ClearFlatbufferModifiedFlag | ( | ) |
Once you have reloaded the Flatbuffer into whatever you are using it for, call this to reset the "modified" flag and the list of modified fields.
|
inline |
Allow adding fields to the Flatbuffer.
If this is true, you can and add sub-tables, strings, vectors, etc. to tables and vectors. Otherwise, you are only allowed to change the size of existing fields. The default for this comes from FlatbufferEditorConfig.
Note: This will always require resizing the Flatbuffer, so you will need to set config_allow_resize() to true as well.
WARNING: This functionality in Flatbuffers is EXPERIMENTAL and is not yet completely implemented here. Turn it on at your own risk.
|
inline |
Allow resizing of the Flatbuffer.
If this is true, you can edit anything inside the Flatbuffer, including vector sizes, strings, and union types. Otherwise, you are only allowed to edit scalar values. The default for this comes from FlatbufferEditorConfig.
|
inline |
Get the Auto-commit mode: If true, then whenever the user edits the Flatbuffer fields, automatically update the Flatbuffer contents after the user finishes editing (presses Enter or clicks on another field).
If false, show an "Apply" button next to all edited fields which will update the Flatbuffer when clicked.
|
inline |
Check if we are in Read-only mode: If true, draw the Flatbuffer using FlatUI's Label fields instead of Edit fields, just showing the values and not allowing them to be edited.
Defaults to false.
|
inline |
Get a pointer to the Flatbuffer we are working with, in case you want to manually copy it out.
|
inline |
Has the Flatbuffer data been modified? If so, you probably want to reload whatever is using it.
bool scene_lab::FlatbufferEditor::GetFlatbufferCopy | ( | std::vector< uint8_t > * | flatbuffer_output | ) |
Copy the modified Flatbuffer into a vector.
Returns true if successful or false if the Flatbuffer editor has no Flatbuffer to copy.
bool scene_lab::FlatbufferEditor::GetFlatbufferCopy | ( | std::string * | flatbuffer_output | ) |
Copy the modified Flatbuffer into a string (requires an extra copy).
Returns true if successful or false if there is no Flatbuffer.
std::unique_ptr<uint8_t> scene_lab::FlatbufferEditor::GetFlatbufferCopy | ( | ) |
Copy the modified Flatbuffer into a generic buffer and get a pointer.
Requires an extra copy.
|
inline |
Does this FlatbufferEditor have any Flatbuffer data?
If you passed in nullptr when setting the Flatbuffer data, this will be false. Otherwise it will be true, and that means there is a Flatbuffer that we are in the process of drawing / editing.
|
inline |
Is the keyboard in use? A field is being edited? You probably want to check this to make sure you don't consume those keypresses yourself.
|
inline |
Set the "Allow adding fields" config value.
See config_allow_adding_fields() for more information.
|
inline |
Set the "Allow resizing" config value.
See config_allow_resize() for more information.
|
inline |
Set a unique root ID for all edit fields, required by FlatUI.
If you don't set this, it will use a unique value based on our pointer address.
|
inline |
Override the current Flatbuffer data with this new one.
Uses reflection to copy into our own internal buffers. Will discard whatever is already in our copy of the Flatbuffer and in the edit fields.
|
inline |
Get the size of all the UI elements passed to FlatUI.
Defaults are set in the FlatbufferEditorConfig.
|
inline |
Get the spacing of all the UI elements passed to FlatUI.
Defaults are set in the FlatbufferEditorConfig.
void scene_lab::FlatbufferEditor::Update | ( | ) |
Update the internal state.
Call each frame, OUTSIDE a gui::Run context, before or after drawing.