Keep blocks still when switching layers

- The main block reserves the width and rows of its biggest layer, so the
  numpad and function row no longer shift between letters and symbols
- Smaller layers stretch into the room: stretch keys widen, rows grow
  taller (rows above the layer, like the function row, keep their height)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 22:35:00 +02:00
co-authored by Claude Opus 5.5
parent 75bbe2e566
commit ac0bfc2741
5 changed files with 66 additions and 14 deletions
+15
View File
@@ -82,6 +82,21 @@ private Q_SLOTS:
QCOMPARE(totalRows({tall, filling}), 4);
QCOMPARE(totalRows({filling}), 2);
}
void reservedRoomStretchesTheRowsAfterTheFixedOnes()
{
Block reserved{{{key()}, {key()}, {key()}}};
reserved.minUnits = 2;
reserved.minRows = 5;
reserved.fixedRows = 1;
const Block side{{{key()}}};
const auto rects = computeKeyRects({reserved, side}, {300, 100}, {.padding = 0, .gap = 0, .blockGap = 0});
QCOMPARE(totalRows({reserved, side}), 5);
QCOMPARE(rects[0], QRectF(50, 0, 100, 20)); // fixed row keeps the shared height, centered in 2 units
QCOMPARE(rects[1], QRectF(50, 20, 100, 40));
QCOMPARE(rects[2], QRectF(50, 60, 100, 40));
QCOMPARE(rects[3], QRectF(200, 80, 100, 20)); // the side block doesn't move
}
};
QTEST_GUILESS_MAIN(TestKeyGeometry)