Public Access
The Launcher shows the Apps as a 4 x 3 grid of 32 x 32 icons, the selected one's name under it (issue #9). The icons are the website's own, doubled, and two drawn the same way for SSH and the Shell; they are PNGs in assets/icons, turned into arrays by scripts/make_icons.py, which CI checks. The selected tile is the website's: dark blue on cyan, with notched corners. - GridModel (lib/ui, host-tested) holds the selection and the scrolling. - App::badge(): a dot on the tile for unread IRC messages, a Track recording, a Capture running, an SSH session open. - Settings > Launcher: Grid or List. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#include "grid_model.h"
|
|
|
|
namespace roro {
|
|
|
|
void GridModel::setCount(int count) {
|
|
count_ = count < 0 ? 0 : count;
|
|
if (count_ == 0) {
|
|
selected_ = -1;
|
|
first_ = 0;
|
|
return;
|
|
}
|
|
select(selected_ < 0 ? 0 : selected_);
|
|
}
|
|
|
|
void GridModel::select(int index) {
|
|
if (count_ == 0) return;
|
|
selected_ = index < 0 ? 0 : index >= count_ ? count_ - 1 : index;
|
|
int row = selected_ / cols_;
|
|
if (row < first_) first_ = row;
|
|
if (row >= first_ + rows_) first_ = row - rows_ + 1;
|
|
int maxFirst = rows() > rows_ ? rows() - rows_ : 0;
|
|
if (first_ > maxFirst) first_ = maxFirst;
|
|
}
|
|
|
|
void GridModel::left() {
|
|
if (count_) select(selected_ == 0 ? count_ - 1 : selected_ - 1);
|
|
}
|
|
|
|
void GridModel::right() {
|
|
if (count_) select(selected_ == count_ - 1 ? 0 : selected_ + 1);
|
|
}
|
|
|
|
void GridModel::up() {
|
|
if (!count_) return;
|
|
int col = selected_ % cols_, row = selected_ / cols_;
|
|
row = row == 0 ? rows() - 1 : row - 1;
|
|
select(row * cols_ + col); // past the end of a short last row: the last item
|
|
}
|
|
|
|
void GridModel::down() {
|
|
if (!count_) return;
|
|
int col = selected_ % cols_, row = selected_ / cols_;
|
|
row = row == rows() - 1 ? 0 : row + 1;
|
|
select(row * cols_ + col);
|
|
}
|
|
|
|
} // namespace roro
|