Optional PC key blocks: function row, navigation, numeric keypad
- Template sections placed above or to the right of the typing keys; the user picks any mix in settings, typing keys included - keysym keys send XKB keysyms on press, optionally repeating - Geometry lays blocks side by side with one key unit; stretch keys are resolved at layout time so composed blocks line up - Toggling a block resizes the window so keys keep their size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,14 +6,26 @@
|
||||
#include <QSizeF>
|
||||
|
||||
struct KeyboardMetrics {
|
||||
qreal padding = 6; // around the whole keyboard
|
||||
qreal gap = 8; // between keys, horizontally and vertically
|
||||
qreal padding = 6; // around the whole keyboard
|
||||
qreal gap = 8; // between keys, horizontally and vertically
|
||||
qreal blockGap = 24; // between side-by-side blocks (main, navigation, numpad)
|
||||
};
|
||||
|
||||
// Lays out a layer's keys to fill `size`. Returns one rect per key, in row
|
||||
// order (spacers included). One key unit has the same width in every row, so
|
||||
// rows with equal unit totals line up; shorter rows are centered.
|
||||
QList<QRectF> computeKeyRects(const Layer &layer, QSizeF size, KeyboardMetrics metrics = {});
|
||||
// The keys on screen: blocks of rows, side by side.
|
||||
using Block = QList<Row>;
|
||||
|
||||
// Total width of a row in key units.
|
||||
// Lays out blocks to fill `size`. Returns one rect per key, block by block in
|
||||
// row order (spacers included). One key unit has the same width everywhere;
|
||||
// all rows share one height, and shorter blocks sit at the bottom. In each
|
||||
// block, stretch keys grow to make their row as wide as the widest one, and
|
||||
// remaining shorter rows are centered.
|
||||
QList<QRectF> computeKeyRects(const QList<Block> &blocks, QSizeF size, KeyboardMetrics metrics = {});
|
||||
inline QList<QRectF> computeKeyRects(const Layer &layer, QSizeF size, KeyboardMetrics metrics = {})
|
||||
{
|
||||
return computeKeyRects({layer.rows}, size, metrics);
|
||||
}
|
||||
|
||||
// Total width of a row in key units, before stretching.
|
||||
qreal rowUnits(const Row &row);
|
||||
// Width of all blocks in key units, ignoring gaps.
|
||||
qreal totalUnits(const QList<Block> &blocks);
|
||||
|
||||
Reference in New Issue
Block a user