diff --git a/include/sst/jucegui/layouts/LabeledGrid.h b/include/sst/jucegui/layouts/LabeledGrid.h index ac7a315..a17297e 100644 --- a/include/sst/jucegui/layouts/LabeledGrid.h +++ b/include/sst/jucegui/layouts/LabeledGrid.h @@ -37,6 +37,8 @@ template struct LabeledGrid juce::Component ∁ }; + LabeledGrid() { std::fill(colSpan.begin(), colSpan.end(), 1); } + int32_t cellWidth{-1}, cellHeight{-1}; void setControlCellSize(int cw, int ch) { @@ -45,9 +47,12 @@ template struct LabeledGrid } float colGapSize{14}; - std::vector colGapsAfter; - void addColGapAfter(int col) { colGapsAfter.push_back(col); } - void setColGapSize(float c) { colGapsAfter = c; } + std::array colGapsAfter{}; + void addColGapAfter(int col) { addColGapAfter(col, colGapSize); } + void addColGapAfter(int col, float cgs) { colGapsAfter[col] = cgs; } + + std::array colSpan; + void setColspanAt(int col, int span) { colSpan[col] = span; } float labelHeight{18}; void setLabelHeight(float lh) { labelHeight = lh; } @@ -113,10 +118,12 @@ template struct LabeledGrid for (const auto &g : gridComps) { auto xtran = g->x * ctW; + int idx{0}; for (const auto &c : colGapsAfter) { - if (g->x > c) - xtran += colGapSize; + if (g->x > idx) + xtran += c; + idx++; } auto cbx = box0.translated(xtran + g->xPush, g->y * (ctH + labelHeight) + g->yPush); @@ -124,18 +131,24 @@ template struct LabeledGrid { cbx = cbx.withHeight(cbx.getHeight() + labelHeight); } + cbx = cbx.withWidth(cbx.getWidth() * colSpan[g->x]); + g->comp.setBounds(cbx.reduced(g->reduction)); } for (const auto &g : gridLabels) { auto xtran = g->x * ctW; + int idx{0}; for (const auto &c : colGapsAfter) { - if (g->x > c) - xtran += colGapSize; + if (g->x > idx) + xtran += c; + idx++; } auto cbx = boxLab0.translated(xtran, g->y * (ctH + labelHeight)); + cbx = cbx.withWidth(cbx.getWidth() * colSpan[g->x]); + g->comp.setBounds(cbx); } } diff --git a/src/sst/jucegui/components/MultiSwitch.cpp b/src/sst/jucegui/components/MultiSwitch.cpp index d9d5497..08656c7 100644 --- a/src/sst/jucegui/components/MultiSwitch.cpp +++ b/src/sst/jucegui/components/MultiSwitch.cpp @@ -143,7 +143,7 @@ void MultiSwitch::setValueFromMouse(const juce::MouseEvent &e) } else { - float nItems = data->getMax() - data->getMin(); + float nItems = data->getMax() - data->getMin() + 1; float h = std::min(getWidth() / nItems, elementSize * 1.f); val = (int)(e.x / h); }