The desk is as high as the screen shows of it

On a screen taller than 16:9 the career's desk offers its lower rows for widgets and
icons (up to 4:3). A stored layout may use the greatest height; objects a shorter
screen cannot show are moved back into sight. Property names read as nouns throughout
the bank.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 20:47:31 +01:00
1 parent e3edd2f9ed
commit b3e5ef4b4d
7 files changed
+82 -6

No files matched your search

+24 -4
View File
@@ -8,6 +8,11 @@
namespace bmh::modern_ui {
namespace {
constexpr int pitch = 248, gap = 24, cell = 224, left = 64, top = 224;
// The desk is 3840 wide and as high as the screen shows of it: 2160 on a 16:9 screen, more
// on a taller one. A stored layout may use the greatest height; what a screen cannot show
// is moved up by fit_desktop.
constexpr int tallest_desk = 2880;
int desk_height = 2160;
bool overlaps(const Json &a, const Json &b, int spacing) {
const int x = a.at("x"), y = a.at("y"), bx = b.at("x"), by = b.at("y");
return x < bx + b.at("w").get<int>() + spacing &&
@@ -23,7 +28,7 @@ bool find_space(Json &layout, const std::string &id, int near_x, int near_y,
const int step = grid ? pitch : 32;
double best = std::numeric_limits<double>::max();
int found_x = -1, found_y = -1;
for (int y = top; y + height <= 2160 - gap; y += step) {
for (int y = top; y + height <= desk_height - gap; y += step) {
for (int x = left; x + width <= 3840 - gap; x += step) {
Json candidate = object;
candidate["x"] = x;
@@ -181,7 +186,7 @@ bool valid_desktop(const Json &layout) {
return false;
const int x = o.at("x"), y = o.at("y"), w = o.at("w"), h = o.at("h");
return w > 0 && h > 0 && w <= 3840 && h <= 2160 - top && x >= 0 &&
y >= top && x <= 3840 - w && y <= 2160 - h &&
y >= top && x <= 3840 - w && y <= tallest_desk - h &&
(widget || (w == cell && h == cell && o.at("visible") == true));
};
for (const auto &d : widget_definitions()) {
@@ -202,6 +207,21 @@ bool valid_desktop(const Json &layout) {
return false;
}
}
void set_desktop_height(int height) { desk_height = std::clamp(height, 2160, tallest_desk); }
int desktop_height() { return desk_height; }
bool fit_desktop(Json &layout) {
if (!valid_desktop(layout)) return false;
auto next = layout;
bool moved = false;
for (auto &[id, o] : next["objects"].items()) {
if (!o.value("visible", false) || o.at("y").get<int>() + o.at("h").get<int>() <= desk_height) continue;
const int x = o.at("x"), y = desk_height - o.at("h").get<int>();
if (find_space(next, id, x, y, true)) moved = true;
else { o["y"] = std::max(top, y); moved = true; } // a full desk: at least within sight
}
if (moved && valid_desktop(next)) layout = std::move(next);
return moved;
}
bool migrate_desktop(Json &layout) {
try {
if (layout.at("objects").contains("app-almanac"))
@@ -227,7 +247,7 @@ bool place_desktop_object(Json &layout, const std::string &id, int x, int y,
return false;
if (!next.at("grid").get<bool>()) {
o["x"] = std::clamp(x, 0, 3840 - o.at("w").get<int>());
o["y"] = std::clamp(y, top, 2160 - o.at("h").get<int>());
o["y"] = std::clamp(y, top, desk_height - o.at("h").get<int>());
} else if (!find_space(next, id, x, y, nearest))
return false;
o["visible"] = true;
@@ -318,7 +338,7 @@ bool add_desktop_widget(Json &layout, const std::string &id, int columns,
if (next.at("grid") == true)
return false;
o["x"] = (3840 - o.at("w").get<int>()) / 2;
o["y"] = (2160 - o.at("h").get<int>()) / 2;
o["y"] = (desk_height - o.at("h").get<int>()) / 2;
}
o["visible"] = true;
if (!valid_desktop(next))