25#include <magic_enum.hpp>
37 aJson = { {
"type", magic_enum::enum_name( aItem.
m_Type ) } };
46 aJson[
"size"] = aItem.
m_Size;
60 nlohmann::json grpItems = nlohmann::json::array();
63 grpItems.push_back( it );
65 aJson[
"group_items"] = grpItems;
77 if( aJson.contains(
"type" ) )
79 auto type = magic_enum::enum_cast<TOOLBAR_ITEM_TYPE>( aJson[
"type"].get<std::string>(),
80 magic_enum::case_insensitive );
82 if( type.has_value() )
83 aItem.
m_Type = type.value();
93 if( aJson.contains(
"size" ) )
94 aItem.
m_Size = aJson[
"size"].get<
int>();
99 if( aJson.contains(
"name" ) )
105 if( aJson.contains(
"name" ) )
111 if( aJson.contains(
"group_name" ) )
112 aItem.
m_GroupName = aJson[
"group_name"].get<wxString>();
114 if( aJson.contains(
"group_items" ) )
116 for(
const nlohmann::json& it : aJson.at(
"group_items" ) )
126 aJson = nlohmann::json::array();
129 aJson.push_back( item );
140 if( aJson.is_array() )
142 for(
const nlohmann::json& item : aJson )
152 [&]() -> nlohmann::json
155 nlohmann::json js = nlohmann::json::array();
159 js.push_back( nlohmann::json( { {
"name", magic_enum::enum_name( loc ) },
160 {
"contents", tb } } ) );
165 [&](
const nlohmann::json& aObj )
170 if( !aObj.is_array() )
173 for(
const auto& entry : aObj )
175 if( entry.empty() || !entry.is_object() )
178 auto loc = magic_enum::enum_cast<TOOLBAR_LOC>( entry[
"name"].get<std::string>(),
179 magic_enum::case_insensitive );
181 if( loc.has_value() )
184 std::make_pair( loc.value(),
189 nlohmann::json::array() ) );
233 return m_parent.AppendAction( aActionName );
239 return m_parent.AppendAction( aAction );
251 return m_parent.AppendSpacer( aSize );
257 return m_parent.AppendGroup( aGroup );
263 return m_parent.AppendControl( aControlName );
269 return m_parent.AppendControl( aControl );
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
Like a normal param, but with custom getter and setter functions.
@ TOOLBARS
The toolbar directory (e.g. ~/.config/kicad/toolbars/)