KiCad PCB EDA Suite
Loading...
Searching...
No Matches
aui_settings.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Rivos
5 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Wayne Stambaugh <[email protected]>
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
24#include <nlohmann/json.hpp>
25
26#include <wx/gdicmn.h>
27#include <wx/aui/framemanager.h>
28
29
30void to_json( nlohmann::json& aJson, const wxPoint& aPoint )
31{
32 aJson = nlohmann::json
33 {
34 { "x", aPoint.x },
35 { "y", aPoint.y }
36 };
37}
38
39
40void from_json( const nlohmann::json& aJson, wxPoint& aPoint )
41{
42 aPoint.x = aJson.at( "x" ).get<int>();
43 aPoint.y = aJson.at( "y" ).get<int>();
44}
45
46
47bool operator<( const wxPoint& aLhs, const wxPoint& aRhs )
48{
49 int xDelta = aLhs.x - aRhs.x;
50
51 if( xDelta < 0 )
52 return true;
53
54 if( ( xDelta == 0 ) && (aLhs.y < aRhs.y ) )
55 return true;
56
57 return false;
58}
59
60
61void to_json( nlohmann::json& aJson, const wxSize& aSize )
62{
63 aJson = nlohmann::json
64 {
65 { "width", aSize.x },
66 { "height", aSize.y }
67 };
68}
69
70
71void from_json( const nlohmann::json& aJson, wxSize& aSize )
72{
73 aSize.SetWidth( aJson.at( "width" ).get<int>() );
74 aSize.SetHeight( aJson.at( "height" ).get<int>() );
75}
76
77
78bool operator<( const wxSize& aLhs, const wxSize& aRhs )
79{
80 int xDelta = aLhs.x - aRhs.x;
81
82 if( xDelta < 0 )
83 return true;
84
85 if( ( xDelta == 0 ) && (aLhs.y < aRhs.y ) )
86 return true;
87
88 return false;
89}
90
91
92void to_json( nlohmann::json& aJson, const wxRect& aRect )
93{
94 aJson = nlohmann::json
95 {
96 { "position", aRect.GetPosition() },
97 { "size", aRect.GetSize() }
98 };
99}
100
101
102void from_json( const nlohmann::json& aJson, wxRect& aRect )
103{
104 aRect.SetPosition( aJson.at( "position" ).get<wxPoint>() );
105 aRect.SetSize( aJson.at( "size" ).get<wxSize>() );
106}
107
108
109bool operator<( const wxRect& aLhs, const wxRect& aRhs )
110{
111 if( aLhs.GetSize() < aRhs.GetSize() )
112 return true;
113
114 if( aLhs.GetPosition() < aRhs.GetPosition() )
115 return true;
116
117 return false;
118}
119
120
121void to_json( nlohmann::json& aJson, const wxAuiPaneInfo& aPaneInfo )
122{
123 aJson = nlohmann::json
124 {
125 { "name", aPaneInfo.name },
126 { "caption", aPaneInfo.caption },
127 { "state", aPaneInfo.state },
128 { "dock_direction", aPaneInfo.dock_direction },
129 { "dock_layer", aPaneInfo.dock_layer },
130 { "dock_row", aPaneInfo.dock_row },
131 { "dock_pos", aPaneInfo.dock_pos },
132 { "dock_proportion", aPaneInfo.dock_proportion },
133 { "best_size", aPaneInfo.best_size },
134 { "min_size", aPaneInfo.min_size },
135 { "max_size", aPaneInfo.max_size },
136 { "floating_pos", aPaneInfo.floating_pos },
137 { "floating_size", aPaneInfo.floating_size },
138 { "rect", aPaneInfo.rect }
139 };
140}
141
142
143void from_json( const nlohmann::json& aJson, wxAuiPaneInfo& aPaneInfo )
144{
145 aPaneInfo.name = aJson.at( "name" ).get<wxString>();
146 aPaneInfo.caption = aJson.at( "caption" ).get<wxString>();
147 aPaneInfo.state = aJson.at( "state" ).get<int>();
148 aPaneInfo.dock_direction = aJson.at( "dock_direction" ).get<unsigned int>();
149 aPaneInfo.dock_layer = aJson.at( "dock_layer" ).get<int>();
150 aPaneInfo.dock_row = aJson.at( "dock_row" ).get<int>();
151 aPaneInfo.dock_pos = aJson.at( "dock_pos" ).get<int>();
152 aPaneInfo.dock_proportion = aJson.at( "dock_proportion" ).get<int>();
153 aPaneInfo.best_size = aJson.at( "best_size" ).get<wxSize>();
154 aPaneInfo.min_size = aJson.at( "min_size" ).get<wxSize>();
155 aPaneInfo.max_size = aJson.at( "max_size" ).get<wxSize>();
156 aPaneInfo.floating_pos = aJson.at( "floating_pos" ).get<wxPoint>();
157 aPaneInfo.floating_size = aJson.at( "floating_size" ).get<wxSize>();
158 aPaneInfo.rect = aJson.at( "rect" ).get<wxRect>();
159}
160
161
162bool operator<( const wxAuiPaneInfo& aLhs, const wxAuiPaneInfo& aRhs )
163{
164 if( aLhs.name < aRhs.name )
165 return true;
166
167 if( aLhs.caption < aRhs.caption )
168 return true;
169
170 if( aLhs.state < aRhs.state )
171 return true;
172
173 if( aLhs.dock_direction < aRhs.dock_direction )
174 return true;
175
176 if( aLhs.dock_layer < aRhs.dock_layer )
177 return true;
178
179 if( aLhs.dock_row < aRhs.dock_row )
180 return true;
181
182 if( aLhs.dock_pos < aRhs.dock_pos )
183 return true;
184
185 if( aLhs.dock_proportion < aRhs.dock_proportion )
186 return true;
187
188 if( aLhs.best_size < aRhs.best_size )
189 return true;
190
191 if( aLhs.min_size < aRhs.min_size )
192 return true;
193
194 if( aLhs.max_size < aRhs.max_size )
195 return true;
196
197 if( aLhs.floating_pos < aRhs.floating_pos )
198 return true;
199
200 if( aLhs.floating_size < aRhs.floating_size )
201 return true;
202
203 if( aLhs.rect < aRhs.rect )
204 return true;
205
206 return false;
207}
208
209
210bool operator==( const wxAuiPaneInfo& aLhs, const wxAuiPaneInfo& aRhs )
211{
212 if( aLhs.name != aRhs.name )
213 return false;
214
215 if( aLhs.caption != aRhs.caption )
216 return false;
217
218 if( aLhs.state != aRhs.state )
219 return false;
220
221 if( aLhs.dock_direction != aRhs.dock_direction )
222 return false;
223
224 if( aLhs.dock_layer != aRhs.dock_layer )
225 return false;
226
227 if( aLhs.dock_row != aRhs.dock_row )
228 return false;
229
230 if( aLhs.dock_pos != aRhs.dock_pos )
231 return false;
232
233 if( aLhs.dock_proportion != aRhs.dock_proportion )
234 return false;
235
236 if( aLhs.best_size != aRhs.best_size )
237 return false;
238
239 if( aLhs.min_size != aRhs.min_size )
240 return false;
241
242 if( aLhs.max_size != aRhs.max_size )
243 return false;
244
245 if( aLhs.floating_pos != aRhs.floating_pos )
246 return false;
247
248 if( aLhs.floating_size != aRhs.floating_size )
249 return false;
250
251 if( aLhs.rect != aRhs.rect )
252 return false;
253
254 return true;
255}
void from_json(const nlohmann::json &aJson, wxPoint &aPoint)
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
void to_json(nlohmann::json &aJson, const wxPoint &aPoint)
bool operator<(const wxPoint &aLhs, const wxPoint &aRhs)