v0.36.9
This commit is contained in:
1 parent
88728bdd5a
commit
358a4518d9
4 files changed
+55
-8
No files matched your search
@@ -134,7 +134,8 @@ window.rustProxyOverviewRows = (() => {
|
||||
const columns = geometry.starts.length;
|
||||
const cardsModel = items.map(node => {
|
||||
const flow = place(node, geometry);
|
||||
return { node, stat: isStat(node), w: Math.min(columns, spanOf(flow)), design: spanOf(flow), h: rowsOf(node), r: 0, c: 0 };
|
||||
const w = Math.min(columns, spanOf(flow));
|
||||
return { node, stat: isStat(node), w, base: w, design: spanOf(flow), h: rowsOf(node), r: 0, c: 0 };
|
||||
});
|
||||
let occupancy = [];
|
||||
const free = (r, c, w, h) => {
|
||||
@@ -151,16 +152,32 @@ window.rustProxyOverviewRows = (() => {
|
||||
for (let x = c; x < c + w; x++) row[x] = value;
|
||||
}
|
||||
};
|
||||
const stripFree = (x, r, h) => {
|
||||
for (let y = r; y < r + h; y++) if (occupancy[y]?.[x]) return false;
|
||||
return true;
|
||||
};
|
||||
const pack = () => {
|
||||
occupancy = [];
|
||||
for (const card of cardsModel) {
|
||||
cardsModel.forEach((card, index) => {
|
||||
card.w = card.base;
|
||||
let placed = false;
|
||||
for (let r = 0; !placed; r++) {
|
||||
for (let c = 0; c + card.w <= columns; c++) {
|
||||
if (free(r, c, card.w, card.h)) { card.r = r; card.c = c; mark(r, c, card.w, card.h); placed = true; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
// A free strip beside the new card (over its whole height) that is
|
||||
// narrower than every card still to be placed could never be filled:
|
||||
// the card takes it now instead of leaving a hole.
|
||||
let narrowest = Infinity;
|
||||
for (let next = index + 1; next < cardsModel.length; next++) narrowest = Math.min(narrowest, cardsModel[next].base);
|
||||
let right = 0;
|
||||
while (card.c + card.w + right < columns && stripFree(card.c + card.w + right, card.r, card.h)) right++;
|
||||
if (right > 0 && right < narrowest) { mark(card.r, card.c + card.w, right, card.h); card.w += right; }
|
||||
let left = 0;
|
||||
while (card.c - left - 1 >= 0 && stripFree(card.c - left - 1, card.r, card.h)) left++;
|
||||
if (left > 0 && left < narrowest) { card.c -= left; card.w += left; mark(card.r, card.c, left, card.h); }
|
||||
});
|
||||
};
|
||||
// Stat tiles starting on the same row share the tallest height; re-pack until
|
||||
// stable (raising a row can move later cards).
|
||||
@@ -239,7 +256,10 @@ window.rustProxyOverviewRows = (() => {
|
||||
if (other !== card && other.c < card.c + card.w && other.c + other.w > card.c && other.r >= end) next = Math.min(next, other.r);
|
||||
}
|
||||
const extra = next - end;
|
||||
if (extra > 0 && extra <= Math.max(ROW_DIVISIONS * 2, card.h)) { mark(end, card.c, card.w, extra); card.h += extra; }
|
||||
// At the end of the grid a chart or panel always reaches the last row (its
|
||||
// chart grows) instead of leaving an empty area; stat tiles stay limited.
|
||||
const limit = next === bottom && !card.stat ? Infinity : Math.max(ROW_DIVISIONS * 2, card.h);
|
||||
if (extra > 0 && extra <= limit) { mark(end, card.c, card.w, extra); card.h += extra; }
|
||||
}
|
||||
for (const card of cardsModel) {
|
||||
card.node.style.setProperty("--overview-col", String(card.c + 1));
|
||||
|
||||
Reference in new issue
Block a user