25#include <magic_enum.hpp>
26#include <nlohmann/json.hpp>
36 aJson = { {
"type", magic_enum::enum_name( aItem.
m_Type ) } };
45 aJson[
"size"] = aItem.
m_Size;
59 nlohmann::json grpItems = nlohmann::json::array();
62 grpItems.push_back( it );
64 aJson[
"group_items"] = grpItems;
76 if( aJson.contains(
"type" ) )
78 auto type = magic_enum::enum_cast<TOOLBAR_ITEM_TYPE>( aJson[
"type"].get<std::string>(),
79 magic_enum::case_insensitive );
81 if( type.has_value() )
82 aItem.
m_Type = type.value();
92 if( aJson.contains(
"size" ) )
93 aItem.
m_Size = aJson[
"size"].get<
int>();
98 if( aJson.contains(
"name" ) )
104 if( aJson.contains(
"name" ) )
110 if( aJson.contains(
"group_name" ) )
111 aItem.
m_GroupName = aJson[
"group_name"].get<wxString>();
113 if( aJson.contains(
"group_items" ) )
115 for(
const nlohmann::json& it : aJson.at(
"group_items" ) )
125 aJson = nlohmann::json::array();
128 aJson.push_back( item );
139 if( aJson.is_array() )
141 for(
const nlohmann::json& item : aJson )
151 [&]() -> nlohmann::json
154 nlohmann::json js = nlohmann::json::array();
158 js.push_back( nlohmann::json( { {
"name", magic_enum::enum_name( loc ) },
159 {
"contents", tb } } ) );
164 [&](
const nlohmann::json& aObj )
169 if( !aObj.is_array() )
172 for(
const auto& entry : aObj )
174 if( entry.empty() || !entry.is_object() )
177 auto loc = magic_enum::enum_cast<TOOLBAR_LOC>( entry[
"name"].get<std::string>(),
178 magic_enum::case_insensitive );
180 if( loc.has_value() )
183 std::make_pair( loc.value(),
188 nlohmann::json::array() ) );
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
Like a normal param, but with custom getter and setter functions.
@ TOOLBARS
The toolbar directory (e.g. ~/.config/kicad/toolbars/)