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:
@@ -235,6 +235,20 @@ private Q_SLOTS:
|
||||
QCOMPARE(model.rowCount(), mainKeys); // never nothing
|
||||
}
|
||||
|
||||
void switchingLayersKeepsTheOtherBlocksStill()
|
||||
{
|
||||
model.setLayout(TestLayouts::build("us", KeyboardMode::Full)); // letters have more rows than symbols
|
||||
model.setVisibleSections({u"function"_s, MainSectionId, u"numpad"_s});
|
||||
model.setSize({1000, 300});
|
||||
const auto lastKeyRect = [this] { return model.keyRect(model.rowCount() - 1); }; // numpad "="
|
||||
const auto firstKeyRect = [this] { return model.keyRect(0); }; // esc
|
||||
const QRectF numpad = lastKeyRect();
|
||||
const QRectF esc = firstKeyRect();
|
||||
model.setLayer(u"numbers"_s);
|
||||
QCOMPARE(lastKeyRect(), numpad);
|
||||
QCOMPARE(firstKeyRect(), esc);
|
||||
}
|
||||
|
||||
KeyDef keysymKey(quint32 keysym)
|
||||
{
|
||||
KeyDef key = makeKey(KeyType::Keysym);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user