ConfigPanel.hpp

Interfaces with config objects to provide UI configuration.

class ConfigPanel : public Div
#include <ConfigPanel.hpp>

Use the ConfigPanel class to easily add a dynamic configuration panel to your web app. Users can interact with the config panel by updating values.

The ConfigPanel is constructed using sub-components. Groups of settings are placed in Cards, and individual settings are represented by ValueControls.

Public Types

using on_change_fun_t = internal::ConfigPanelInfo::on_change_fun_t

Public Functions

inline ConfigPanel(Config &config, bool open = true, const std::string &div_name = "")
Parameters:
  • config – config object used to construct this panel

  • open – Should card for displaying this config default to being open?

  • div_name – Name to use for html div id for this panel

inline void SetOnChangeFun(const on_change_fun_t &fun)

Sets on-update callback for a ConfigPanel.

Parameters:

fun – callback function handle

inline void SetRange(const std::string &setting, const std::string &min, const std::string &max = "DEFAULT", const std::string &step = "DEFAULT")

Sets the range of a slider for a numeric setting.

Parameters:
  • setting – the numeric config value which will have its range slider updated

  • min – minimum value of the slider for this config value (use “DEFAULT” to leave unchanged)

  • max – maximum value of the slider for this config value (use “DEFAULT” to leave unchanged)

  • step – step size of the slider for this config value (use “DEFAULT” to leave unchanged)

inline void ExcludeConfig(const std::string &setting)

Excludes a setting or group of settings, recommend using ExcludeSetting or ExcludeGroup instead

Deprecated:

renamed to ExcludeSetting

Parameters:

setting – The name of a single setting that should not be displayed in the config panel

inline void ExcludeSetting(const std::string &setting)

Excludes a specific setting from the config panel

Parameters:

setting – name of the setting that should not be displayed in the config panel

inline void ExcludeGroup(const std::string &setting_group)

Excludes an entire group of settings from the config panel

Parameters:

setting_group – name of the group that should not be displayed in the config panel

inline void Setup(Config &config, bool open = true, const std::string &id_prefix = "")

Arranges config panel based configuration pass to constructor

Deprecated:

No longer necessary for config panel to function. This function was a work around to fix a bug.

Parameters:
  • config – the config object used to create this panel

  • open – should the card for the panel start open?

  • id_prefix – string appended to id for each setting (unused)

inline Div &GetConfigPanelDiv()

Deprecated:

Can directly stream this component

Returns:

Div containing the entire config panel

Private Types

using INFO_TYPE = internal::ConfigPanelInfo

Type of shared pointer shared among instances of ConfigPanel representing the same conceptual DOM element.

Private Functions

inline INFO_TYPE *Info()

Get shared info pointer, cast to ConfigPanel-specific type.

Returns:

cast pointer

inline const INFO_TYPE *Info() const

Get shared info pointer, cast to const ConfigPanel-specific type.

Returns:

cast pointer

inline on_change_fun_t &GetOnChangeFun()

Get current on-update callback.

Returns:

current callback function handle

Private Static Attributes

static std::set<std::string> numeric_types = {"int", "double", "float", "uint32_t", "uint64_t", "size_t"}