Fix wallpaper transparency, Recents setup guide, drawer animation, and widget resizing (#2)
Launcher / test (push) Successful in 1m21s
Launcher / apk (push) Successful in 17s

This commit was merged in pull request #2.
This commit is contained in:
nandi committed 2026-11-23 05:36:23 +00:00
1 parent 2fa7bd745b
commit 3070db4fb4
15 files changed
+1011 -161

No files matched your search

+172 -56
View File
@@ -155,13 +155,48 @@ fn Model::drop_gone(self : Model, fx : Array[Effect]) -> Unit {
self.gone = ""
}
///|
/// Whether the drawer is open and not currently animating out.
pub fn Model::drawer_open(self : Model) -> Bool {
self.drawer && !self.drawer_closing
}
///|
/// App icon keys in priority order: home-screen apps first, then the rest of the app list.
pub fn Model::icon_keys(self : Model) -> Array[String] {
let out : Array[String] = []
let seen : Map[String, Bool] = Map([])
for s in self.home {
if s.kind == App {
let row = self.app_row(s.str)
if row >= 0 {
let k = self.apps[row].icon
if k != "" && !seen.contains(k) {
seen[k] = true
out.push(k)
}
}
}
}
for a in self.apps {
let k = a.icon
if k != "" && !seen.contains(k) {
seen[k] = true
out.push(k)
}
}
out
}
///|
fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
if self.drawer {
if self.drawer && !self.drawer_closing {
fx.push(HideKeyboard)
}
self.query = ""
self.drawer = false
self.drawer_closing = false
self.drawer_gen += 1
self.picking = false
self.sheet = NoSheet
self.lifted = -1
@@ -173,19 +208,23 @@ fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
///|
fn Model::open_drawer(self : Model, fx : Array[Effect]) -> Unit {
if self.sheet == NoSheet && !self.drawer {
if self.sheet == NoSheet && !self.drawer_open() {
self.drawer = true
self.drawer_closing = false
self.drawer_gen += 1
self.picking = false
self.query = ""
fx.push(FocusSearch)
}
}
///|
fn Model::close_drawer(self : Model, fx : Array[Effect]) -> Unit {
if self.drawer && self.sheet == NoSheet {
self.drawer = false
self.picking = false
self.query = ""
if self.drawer_open() && self.sheet == NoSheet {
self.drawer_closing = true
self.drawer_gen += 1
fx.push(HideKeyboard)
fx.push(Delay(140, DrawerClosed(self.drawer_gen)))
}
}
@@ -309,7 +348,7 @@ fn Model::drag_lifted(
/// The pointer is up. Letting go without moving opens the item's menu (a widget gets
/// resize handles instead); letting go of a dragged one just drops it, and whatever it
/// then covers moves on to free cells.
fn Model::drop_lifted(self : Model, moved : Bool) -> Unit {
fn Model::drop_lifted(self : Model, moved : Bool, fx : Array[Effect]) -> Unit {
self.carry = None
if self.lifted < 0 || self.lifted >= self.home.length() {
self.lifted = -1
@@ -322,7 +361,10 @@ fn Model::drop_lifted(self : Model, moved : Bool) -> Unit {
}
if !moved || self.regrab {
match s.kind {
Widget => self.resizing = self.lifted
Widget => {
self.resizing = self.lifted
fx.push(QueryLimits(s.wid))
}
App => self.sheet = Item(self.lifted)
}
}
@@ -337,23 +379,34 @@ fn Model::begin_resize(self : Model, edge : Edge, fx : Array[Effect]) -> Unit {
return
}
let s = self.home[i]
let (left, top) = match self.slot_box(self.packed(), i) {
Some(b) => (b.0, b.1)
None => (self.grid_left, self.grid_top)
}
guard self.packed().cells[i] is Some(cell) else { return }
s.x = cell.col
s.y = cell.row
let (bx, by, bw, bh) = @grid.box(cell, self.col_w)
let left = self.grid_left + bx
let top = self.grid_top + by
self.resize = Some({
edge,
slot: i,
left,
top,
cols: s.cols(self.cols),
rows: s.height(),
right: left + bw,
bottom: top + bh,
anchor_col: cell.col,
anchor_row: cell.row,
right_col: cell.col + cell.w,
bottom_row: cell.row + cell.h,
col: cell.col,
row: cell.row,
cols: cell.w,
rows: cell.h,
})
fx.push(QueryLimits(s.wid))
}
///|
/// Dragging a handle snaps the widget to whole columns and rows, within its limits.
/// Dragging a handle snaps the widget to whole columns and rows, within its limits
/// and without shifting its anchored edge.
fn Model::drag_resize(
self : Model,
r : ResizeDrag,
@@ -367,42 +420,86 @@ fn Model::drag_resize(
let s = self.home[r.slot]
let lim = self.limits.get(s.wid).unwrap_or(default_limits)
let n = self.cols
let mut col = r.col
let mut row = r.row
let mut cols = r.cols
let mut rows = r.rows
if r.edge != Bottom && lim.h {
cols = @grid.fit(
x - r.left,
1,
n,
self.col_w,
@grid.col_gap.to_double(),
lim.min_w,
lim.max_w,
)
let cg = @grid.col_gap.to_double()
let rg = @grid.row_gap.to_double()
if lim.h {
match r.edge {
Right | Corner => {
let hi = @cmp.maximum(1, n - r.anchor_col)
cols = @grid.fit(
x - r.left,
1,
hi,
self.col_w,
cg,
lim.min_w,
lim.max_w,
)
col = r.anchor_col
}
Left => {
let hi = @cmp.maximum(1, @cmp.minimum(n, r.right_col))
cols = @grid.fit(
r.right - x,
1,
hi,
self.col_w,
cg,
lim.min_w,
lim.max_w,
)
col = r.right_col - cols
}
Top | Bottom => ()
}
}
if r.edge != Right && lim.v {
rows = @grid.fit(
y - r.top,
1,
20,
@grid.cell_px.to_double(),
@grid.row_gap.to_double(),
lim.min_h,
lim.max_h,
)
if lim.v {
match r.edge {
Bottom | Corner => {
rows = @grid.fit(
y - r.top,
1,
20,
@grid.cell_px.to_double(),
rg,
lim.min_h,
lim.max_h,
)
row = r.anchor_row
}
Top => {
let hi = @cmp.maximum(1, @cmp.minimum(20, r.bottom_row))
rows = @grid.fit(
r.bottom - y,
1,
hi,
@grid.cell_px.to_double(),
rg,
lim.min_h,
lim.max_h,
)
row = r.bottom_row - rows
}
Left | Right => ()
}
}
if cols == r.cols && rows == r.rows {
if col == r.col && row == r.row && cols == r.cols && rows == r.rows {
return
}
r.col = col
r.row = row
r.cols = cols
r.rows = rows
fx.push(Haptic)
s.x = col
s.y = row
s.w = if cols >= n { 0 } else { cols }
s.rows = rows
if s.x >= 0 {
@grid.pin(self.home, r.slot, s.x, s.y, self.cols, self.nrows)
@grid.clear_cells(self.home, r.slot, self.cols)
}
@grid.clear_cells(self.home, r.slot, self.cols)
}
// ---- update -------------------------------------------------------------------
@@ -465,12 +562,14 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
fx.push(FetchRelease(@updater.release_api))
}
}
Measured(vw~, vh~, grid_left~, grid_top~, grid_w~, bottom_pad~) => {
Measured(vw~, vh~, grid_left~, grid_top~, grid_w~, bottom_pad~, scroll_y~) => {
m.cols = @grid.columns_for(vw)
m.grid_left = grid_left
m.grid_top = grid_top
m.col_w = @grid.column_width(grid_w, m.cols)
m.nrows = @grid.rows_fit(vh.to_double() - bottom_pad - grid_top)
m.nrows = @grid.rows_fit(
vh.to_double() - bottom_pad - (grid_top + scroll_y),
)
}
AppsLoaded(text) => {
m.loading = false
@@ -518,11 +617,8 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
m.resizing = -1
} else if m.sheet != NoSheet {
m.sheet = NoSheet
} else if m.drawer {
m.drawer = false
m.picking = false
m.query = ""
fx.push(HideKeyboard)
} else if m.drawer_open() {
m.close_drawer(fx)
}
WidgetAdded(id) =>
if m.chosen >= 0 &&
@@ -543,7 +639,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
}
WidgetMenu(wid) => {
let i = m.slot_of_widget(wid)
if i >= 0 && !m.drawer && m.sheet == NoSheet {
if i >= 0 && !m.drawer_open() && m.sheet == NoSheet {
m.resizing = -1
m.regrab = false
m.lifted = i
@@ -552,7 +648,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
}
WidgetGrab(wid) => {
let i = m.slot_of_widget(wid)
if i >= 0 && i == m.resizing && !m.drawer && m.sheet == NoSheet {
if i >= 0 && i == m.resizing && !m.drawer_open() && m.sheet == NoSheet {
m.resizing = -1
m.regrab = true
m.lifted = i
@@ -572,13 +668,13 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
}
NativeDrop(moved) => {
m.native_from = None
m.drop_lifted(moved)
m.drop_lifted(moved, fx)
}
Touch(dx~, dy~, ms~, home_top~, list_end~) =>
if !m.dragged && m.lifted < 0 && m.sheet == NoSheet {
match @gesture.classify_swipe(dx, dy, ms) {
Some(Down) => if !m.drawer && home_top { m.open_drawer(fx) }
Some(Up) => if m.drawer && list_end { m.close_drawer(fx) }
Some(Down) => if !m.drawer_open() && home_top { m.open_drawer(fx) }
Some(Up) => if m.drawer_open() && list_end { m.close_drawer(fx) }
None => ()
}
}
@@ -633,6 +729,13 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
WClear => m.wquery = ""
OpenDrawer => m.open_drawer(fx)
CloseDrawer => m.close_drawer(fx)
DrawerClosed(gen) =>
if gen == m.drawer_gen && m.drawer_closing {
m.drawer = false
m.drawer_closing = false
m.picking = false
m.query = ""
}
OpenApp(row) =>
if row >= 0 && row < m.apps.length() {
fx.push(Launch(m.apps[row].component))
@@ -663,7 +766,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
}
}
AppMenu(row) =>
if m.drawer && m.sheet == NoSheet {
if m.drawer_open() && m.sheet == NoSheet {
fx.push(Haptic)
m.sheet = DrawerApp(row)
}
@@ -685,7 +788,10 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
PickApps => {
m.sheet = NoSheet
m.drawer = true
m.drawer_closing = false
m.drawer_gen += 1
m.picking = true
m.query = ""
}
PickWidget => {
m.sheet = WidgetPicker
@@ -723,6 +829,12 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
m.sheet = NoSheet
}
Recents => fx.push(OpenRecents)
RecentsUnavailable => {
m.resizing = -1
m.sheet = RecentsSetup
}
OpenAccessibilitySettings => fx.push(OpenAccessibilitySettings)
OpenSelfAppInfo => fx.push(OpenSelfAppInfo)
CheckUpdates => {
m.sheet = NoSheet
if m.checking {
@@ -735,14 +847,18 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
}
}
Lift(i) =>
if !m.drawer && m.sheet == NoSheet && i != m.lifted && i < m.home.length() {
if !m.drawer_open() &&
m.sheet == NoSheet &&
m.resize is None &&
i != m.lifted &&
i < m.home.length() {
fx.push(Haptic)
m.resizing = -1
m.regrab = false
m.lifted = i
}
Grab(i) =>
if i >= 0 && i == m.resizing && !m.drawer && m.sheet == NoSheet {
if i >= 0 && i == m.resizing && !m.drawer_open() && m.sheet == NoSheet {
m.resizing = -1
m.regrab = true
m.lifted = i
@@ -760,7 +876,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
Released(moved~, held~) => {
ignore(held)
m.resize = None
m.drop_lifted(moved)
m.drop_lifted(moved, fx)
}
}
}