Beispiel #1
0
 internal InlineGridBuilder(ImGui gui, float elementWidth, float spacing, int elementsPerRow)
 {
     savedContext        = default;
     this.gui            = gui;
     this.spacing        = spacing;
     gui.allocator       = RectAllocator.LeftAlign;
     this.elementWidth   = MathF.Min(elementWidth, gui.width);
     this.elementsPerRow = elementsPerRow == 0 ? MathUtils.Floor((gui.width + spacing) / (elementWidth + spacing)) : elementsPerRow;
     currentRowIndex     = -1;
     if (elementWidth <= 0)
     {
         this.elementsPerRow = 1;
     }
 }
Beispiel #2
0
 public void Next()
 {
     if (currentRowIndex == elementsPerRow - 1)
     {
         savedContext.Dispose();
         savedContext    = default;
         currentRowIndex = -1;
     }
     currentRowIndex++;
     if (currentRowIndex == 0)
     {
         savedContext = gui.EnterRow(0f);
         gui.spacing  = 0f;
     }
     savedContext.SetManualRect(new Rect((elementWidth + spacing) * currentRowIndex, 0f, elementWidth, 0f), RectAllocator.Stretch);
 }