Add an icon size setting (#3)
Launcher / test (push) Successful in 1m59s
Launcher / apk (push) Successful in 38s

This commit was merged in pull request #3.
This commit is contained in:
nandi committed 2026-11-24 22:43:04 +00:00
1 parent 3070db4fb4
commit 472a48f4bd
22 files changed
+901 -51

No files matched your search

+28 -15
View File
@@ -63,8 +63,8 @@ pub fn Slot::widget(
///|
/// Rows of app tiles nearest to a widget height in px, at least one.
pub fn widget_rows(px : Int32) -> Int32 {
let k = (px + row_gap + (cell_px + row_gap) / 2) / (cell_px + row_gap)
pub fn widget_rows(px : Int32, ch~ : Int32 = cell_px) -> Int32 {
let k = (px + row_gap + (ch + row_gap) / 2) / (ch + row_gap)
if k < 1 {
1
} else {
@@ -192,38 +192,51 @@ pub fn pack(
}
///|
/// A cell's box in px, given the column width: (x, y, w, h).
pub fn box(cell : Cell, col_w : Double) -> (Double, Double, Double, Double) {
/// A cell's box in px, given the column width and the row height `ch`: (x, y, w, h).
pub fn box(
cell : Cell,
col_w : Double,
ch~ : Int32 = cell_px,
) -> (Double, Double, Double, Double) {
let cg = col_gap.to_double()
let rg = row_gap.to_double()
(
cell.col.to_double() * (col_w + cg),
cell.row.to_double() * (cell_px.to_double() + rg),
cell.row.to_double() * (ch.to_double() + rg),
cell.w.to_double() * col_w + (cell.w - 1).to_double() * cg,
cell.h.to_double() * cell_px.to_double() + (cell.h - 1).to_double() * rg,
cell.h.to_double() * ch.to_double() + (cell.h - 1).to_double() * rg,
)
}
///|
/// The cell nearest to a point (px in the grid, from its top left): (col, row).
pub fn cell_at(x : Double, y : Double, col_w : Double) -> (Int32, Int32) {
pub fn cell_at(
x : Double,
y : Double,
col_w : Double,
ch~ : Int32 = cell_px,
) -> (Int32, Int32) {
let c = (x / (col_w + col_gap.to_double()) + 0.5).floor().to_int()
let r = (y / (cell_px + row_gap).to_double() + 0.5).floor().to_int()
let r = (y / (ch + row_gap).to_double() + 0.5).floor().to_int()
(@cmp.maximum(0, c), @cmp.maximum(0, r))
}
///|
/// The cell whose box contains a point, or `None` outside every cell (in the gaps).
pub fn cell_under(x : Double, y : Double, col_w : Double) -> (Int32, Int32)? {
pub fn cell_under(
x : Double,
y : Double,
col_w : Double,
ch~ : Int32 = cell_px,
) -> (Int32, Int32)? {
if x < 0.0 || y < 0.0 {
return None
}
let pw = col_w + col_gap.to_double()
let ph = (cell_px + row_gap).to_double()
let ph = (ch + row_gap).to_double()
let c = (x / pw).floor().to_int()
let r = (y / ph).floor().to_int()
if x - c.to_double() * pw > col_w ||
y - r.to_double() * ph > cell_px.to_double() {
if x - c.to_double() * pw > col_w || y - r.to_double() * ph > ch.to_double() {
None
} else {
Some((c, r))
@@ -345,9 +358,9 @@ pub fn column_width(grid_width : Double, cols : Int32) -> Double {
}
///|
/// How many rows of the grid fit in `height` px.
pub fn rows_fit(height : Double) -> Int32 {
let r = ((height + row_gap.to_double()) / (cell_px + row_gap).to_double())
/// How many rows of height `ch` fit in `height` px.
pub fn rows_fit(height : Double, ch~ : Int32 = cell_px) -> Int32 {
let r = ((height + row_gap.to_double()) / (ch + row_gap).to_double())
.floor()
.to_int()
@cmp.maximum(1, r)