|
30 | 30 | #include <yoga/enums/Wrap.h> |
31 | 31 | #include <yoga/numeric/FloatOptional.h> |
32 | 32 | #include <yoga/style/GridLine.h> |
| 33 | +#include <yoga/style/GridStyle.h> |
33 | 34 | #include <yoga/style/GridTrack.h> |
34 | 35 | #include <yoga/style/StyleLength.h> |
35 | 36 | #include <yoga/style/StyleSizeLength.h> |
@@ -209,84 +210,84 @@ class YG_EXPORT Style { |
209 | 210 |
|
210 | 211 | // Grid Container Properties |
211 | 212 | const GridTrackList& gridTemplateColumns() const { |
212 | | - return gridTemplateColumns_; |
| 213 | + return grid_.get().templateColumns; |
213 | 214 | } |
214 | 215 | void setGridTemplateColumns(GridTrackList value) { |
215 | | - gridTemplateColumns_ = std::move(value); |
| 216 | + grid_.ensure().templateColumns = std::move(value); |
216 | 217 | } |
217 | 218 | void resizeGridTemplateColumns(size_t count) { |
218 | | - gridTemplateColumns_.resize(count); |
| 219 | + grid_.ensure().templateColumns.resize(count); |
219 | 220 | } |
220 | 221 | void setGridTemplateColumnAt(size_t index, GridTrackSize value) { |
221 | | - gridTemplateColumns_[index] = value; |
| 222 | + grid_.ensure().templateColumns[index] = value; |
222 | 223 | } |
223 | 224 |
|
224 | 225 | const GridTrackList& gridTemplateRows() const { |
225 | | - return gridTemplateRows_; |
| 226 | + return grid_.get().templateRows; |
226 | 227 | } |
227 | 228 | void setGridTemplateRows(GridTrackList value) { |
228 | | - gridTemplateRows_ = std::move(value); |
| 229 | + grid_.ensure().templateRows = std::move(value); |
229 | 230 | } |
230 | 231 | void resizeGridTemplateRows(size_t count) { |
231 | | - gridTemplateRows_.resize(count); |
| 232 | + grid_.ensure().templateRows.resize(count); |
232 | 233 | } |
233 | 234 | void setGridTemplateRowAt(size_t index, GridTrackSize value) { |
234 | | - gridTemplateRows_[index] = value; |
| 235 | + grid_.ensure().templateRows[index] = value; |
235 | 236 | } |
236 | 237 |
|
237 | 238 | const GridTrackList& gridAutoColumns() const { |
238 | | - return gridAutoColumns_; |
| 239 | + return grid_.get().autoColumns; |
239 | 240 | } |
240 | 241 | void setGridAutoColumns(GridTrackList value) { |
241 | | - gridAutoColumns_ = std::move(value); |
| 242 | + grid_.ensure().autoColumns = std::move(value); |
242 | 243 | } |
243 | 244 | void resizeGridAutoColumns(size_t count) { |
244 | | - gridAutoColumns_.resize(count); |
| 245 | + grid_.ensure().autoColumns.resize(count); |
245 | 246 | } |
246 | 247 | void setGridAutoColumnAt(size_t index, GridTrackSize value) { |
247 | | - gridAutoColumns_[index] = value; |
| 248 | + grid_.ensure().autoColumns[index] = value; |
248 | 249 | } |
249 | 250 |
|
250 | 251 | const GridTrackList& gridAutoRows() const { |
251 | | - return gridAutoRows_; |
| 252 | + return grid_.get().autoRows; |
252 | 253 | } |
253 | 254 | void setGridAutoRows(GridTrackList value) { |
254 | | - gridAutoRows_ = std::move(value); |
| 255 | + grid_.ensure().autoRows = std::move(value); |
255 | 256 | } |
256 | 257 | void resizeGridAutoRows(size_t count) { |
257 | | - gridAutoRows_.resize(count); |
| 258 | + grid_.ensure().autoRows.resize(count); |
258 | 259 | } |
259 | 260 | void setGridAutoRowAt(size_t index, GridTrackSize value) { |
260 | | - gridAutoRows_[index] = value; |
| 261 | + grid_.ensure().autoRows[index] = value; |
261 | 262 | } |
262 | 263 |
|
263 | 264 | // Grid Item Properties |
264 | 265 | const GridLine& gridColumnStart() const { |
265 | | - return gridColumnStart_; |
| 266 | + return grid_.get().columnStart; |
266 | 267 | } |
267 | 268 | void setGridColumnStart(GridLine value) { |
268 | | - gridColumnStart_ = value; |
| 269 | + grid_.ensure().columnStart = value; |
269 | 270 | } |
270 | 271 |
|
271 | 272 | const GridLine& gridColumnEnd() const { |
272 | | - return gridColumnEnd_; |
| 273 | + return grid_.get().columnEnd; |
273 | 274 | } |
274 | 275 | void setGridColumnEnd(GridLine value) { |
275 | | - gridColumnEnd_ = value; |
| 276 | + grid_.ensure().columnEnd = value; |
276 | 277 | } |
277 | 278 |
|
278 | 279 | const GridLine& gridRowStart() const { |
279 | | - return gridRowStart_; |
| 280 | + return grid_.get().rowStart; |
280 | 281 | } |
281 | 282 | void setGridRowStart(GridLine value) { |
282 | | - gridRowStart_ = value; |
| 283 | + grid_.ensure().rowStart = value; |
283 | 284 | } |
284 | 285 |
|
285 | 286 | const GridLine& gridRowEnd() const { |
286 | | - return gridRowEnd_; |
| 287 | + return grid_.get().rowEnd; |
287 | 288 | } |
288 | 289 | void setGridRowEnd(GridLine value) { |
289 | | - gridRowEnd_ = value; |
| 290 | + grid_.ensure().rowEnd = value; |
290 | 291 | } |
291 | 292 |
|
292 | 293 | FloatOptional resolvedMinDimension( |
@@ -667,14 +668,7 @@ class YG_EXPORT Style { |
667 | 668 | sizeLengthsEqual( |
668 | 669 | maxDimensions_, pool_, other.maxDimensions_, other.pool_) && |
669 | 670 | numbersEqual(aspectRatio_, pool_, other.aspectRatio_, other.pool_) && |
670 | | - gridTemplateColumns_ == other.gridTemplateColumns_ && |
671 | | - gridTemplateRows_ == other.gridTemplateRows_ && |
672 | | - gridAutoColumns_ == other.gridAutoColumns_ && |
673 | | - gridAutoRows_ == other.gridAutoRows_ && |
674 | | - gridColumnStart_ == other.gridColumnStart_ && |
675 | | - gridColumnEnd_ == other.gridColumnEnd_ && |
676 | | - gridRowStart_ == other.gridRowStart_ && |
677 | | - gridRowEnd_ == other.gridRowEnd_; |
| 671 | + grid_ == other.grid_; |
678 | 672 | } |
679 | 673 |
|
680 | 674 | private: |
@@ -929,15 +923,8 @@ class YG_EXPORT Style { |
929 | 923 | Dimensions maxDimensions_{}; |
930 | 924 | StyleValueHandle aspectRatio_{}; |
931 | 925 |
|
932 | | - // Grid properties |
933 | | - GridTrackList gridTemplateColumns_{}; |
934 | | - GridTrackList gridTemplateRows_{}; |
935 | | - GridTrackList gridAutoColumns_{}; |
936 | | - GridTrackList gridAutoRows_{}; |
937 | | - GridLine gridColumnStart_{}; |
938 | | - GridLine gridColumnEnd_{}; |
939 | | - GridLine gridRowStart_{}; |
940 | | - GridLine gridRowEnd_{}; |
| 926 | + // Grid properties, allocated only when one of them is set |
| 927 | + GridStyleStorage grid_{}; |
941 | 928 |
|
942 | 929 | StyleValuePool pool_; |
943 | 930 | }; |
|
0 commit comments