MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / GetFreeSpots

Method GetFreeSpots

Xaml/Controls/UniformGrid.cpp:318–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316 }
317
318 std::experimental::generator<std::tuple<int, int>> UniformGrid::GetFreeSpots(int firstColumn, bool topDown)
319 {
320 // Provides the next spot in the boolean array with a 'false' value.
321 if (topDown)
322 {
323 // Layout spots from Top-Bottom, Left-Right (right-left handled automatically by Grid with Flow-Direction).
324 // Effectively transpose the Grid Layout.
325 for (int c = 0; c < m_SpotsWidth; c++)
326 {
327 int start = (c == 0 && firstColumn > 0 && firstColumn < m_SpotsHeight) ? firstColumn : 0;
328 for (int r = start; r < m_SpotsHeight; r++)
329 {
330 if (!GetSpot(r, c))
331 {
332 co_yield { r, c };
333 }
334 }
335 }
336 }
337 else
338 {
339 // Layout spots as normal from Left-Right.
340 // (right-left handled automatically by Grid with Flow-Direction
341 // during its layout, internal model is always left-right).
342 for (int r = 0; r < m_SpotsHeight; r++)
343 {
344 int start = (r == 0 && firstColumn > 0 && firstColumn < m_SpotsWidth) ? firstColumn : 0;
345 for (int c = start; c < m_SpotsWidth; c++)
346 {
347 if (!GetSpot(r, c))
348 {
349 co_yield { r, c };
350 }
351 }
352 }
353 }
354 }
355}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected