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
+10 -1
View File
@@ -1,5 +1,6 @@
#include "LayoutModel.h"
#include <algorithm>
#include <limits>
namespace {
@@ -183,8 +184,16 @@ QList<Block> LayoutModel::composeBlocks() const
if (section.placement == Section::Placement::Above && shown(section.id))
main.rows += section.rows;
}
if (layer && shown(MainSectionId))
if (layer && shown(MainSectionId)) {
// Room for the biggest layer, so switching layers keeps the other blocks still.
main.fixedRows = main.rows.size();
for (const Layer &other : m_layout.layers) {
main.minRows = std::max(main.minRows, main.fixedRows + other.rows.size());
for (const Row &row : other.rows)
main.minUnits = std::max(main.minUnits, rowUnits(row));
}
main.rows += layer->rows;
}
QList<Block> blocks;
if (!main.rows.isEmpty())