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

+25 -2
View File
@@ -60,24 +60,35 @@ pub(all) enum Sheet {
/// The menu of a drawer app (row in the app list).
DrawerApp(Int32)
WidgetPicker
RecentsSetup
}
///|
#derive(Eq, Debug)
pub(all) enum Edge {
Left
Right
Top
Bottom
Corner
}
///|
/// A resize in progress: a handle was pressed on the widget whose box (px, viewport) was
/// at `left`, `top`.
/// A resize in progress: a handle was pressed on the widget whose viewport box and
/// grid edges were captured on down.
pub(all) struct ResizeDrag {
edge : Edge
slot : Int32
left : Double
top : Double
right : Double
bottom : Double
anchor_col : Int32
anchor_row : Int32
right_col : Int32
bottom_row : Int32
mut col : Int32
mut row : Int32
mut cols : Int32
mut rows : Int32
}
@@ -110,6 +121,9 @@ pub(all) struct Model {
mut query : String
mut wquery : String
mut drawer : Bool
/// The drawer is animating out before detaching.
mut drawer_closing : Bool
mut drawer_gen : Int32
/// The drawer is in "add apps" mode: taps toggle home slots.
mut picking : Bool
mut sheet : Sheet
@@ -165,6 +179,8 @@ pub fn Model::new() -> Model {
query: "",
wquery: "",
drawer: false,
drawer_closing: false,
drawer_gen: 0,
picking: false,
sheet: NoSheet,
gone: "",
@@ -221,6 +237,7 @@ pub(all) enum Msg {
grid_top~ : Double,
grid_w~ : Double,
bottom_pad~ : Double,
scroll_y~ : Double,
)
AppsLoaded(String?)
WidgetsLoaded(String?)
@@ -257,6 +274,7 @@ pub(all) enum Msg {
WClear
OpenDrawer
CloseDrawer
DrawerClosed(Int32)
OpenApp(Int32)
OpenFirst
OpenHome(Int32)
@@ -278,6 +296,9 @@ pub(all) enum Msg {
Settings
Wallpaper
Recents
RecentsUnavailable
OpenAccessibilitySettings
OpenSelfAppInfo
CheckUpdates
Lift(Int32)
Grab(Int32)
@@ -301,6 +322,8 @@ pub(all) enum Effect {
OpenSettings
PickWallpaper
OpenRecents
OpenAccessibilitySettings
OpenSelfAppInfo
Haptic
/// Fetch apps.json / widgets.json and answer `AppsLoaded` / `WidgetsLoaded`.
LoadApps
+22 -1
View File
@@ -60,7 +60,9 @@ pub(all) struct Carry {
#derive(Eq, @debug.Debug)
pub(all) enum Edge {
Left
Right
Top
Bottom
Corner
}
@@ -75,6 +77,8 @@ pub(all) enum Effect {
OpenSettings
PickWallpaper
OpenRecents
OpenAccessibilitySettings
OpenSelfAppInfo
Haptic
LoadApps
LoadWidgets
@@ -122,6 +126,8 @@ pub(all) struct Model {
mut query : String
mut wquery : String
mut drawer : Bool
mut drawer_closing : Bool
mut drawer_gen : Int32
mut picking : Bool
mut sheet : Sheet
mut gone : String
@@ -147,10 +153,12 @@ pub(all) struct Model {
mut gesture : @gesture.State
}
pub fn Model::app_row(Self, String) -> Int32
pub fn Model::drawer_open(Self) -> Bool
pub fn Model::first_match(Self) -> Int32
pub fn Model::first_widget_match(Self) -> Int32
pub fn Model::hidden(Self, Int32) -> Bool
pub fn Model::home_of(Self, Int32) -> Int32
pub fn Model::icon_keys(Self) -> Array[String]
pub fn Model::new() -> Self
pub fn Model::packed(Self) -> @grid.Packed
pub fn Model::slot_of_widget(Self, Int32) -> Int32
@@ -160,7 +168,7 @@ pub fn Model::widget_matches(Self, Int32) -> Bool
pub(all) enum Msg {
Restore(saved~ : String?, legacy~ : String?)
Started(now~ : Int64, last_check~ : Int64, declined~ : Int32, installed~ : Int32)
Measured(vw~ : Int32, vh~ : Int32, grid_left~ : Double, grid_top~ : Double, grid_w~ : Double, bottom_pad~ : Double)
Measured(vw~ : Int32, vh~ : Int32, grid_left~ : Double, grid_top~ : Double, grid_w~ : Double, bottom_pad~ : Double, scroll_y~ : Double)
AppsLoaded(String?)
WidgetsLoaded(String?)
LimitsKnown(Int32, String?)
@@ -182,6 +190,7 @@ pub(all) enum Msg {
WClear
OpenDrawer
CloseDrawer
DrawerClosed(Int32)
OpenApp(Int32)
OpenFirst
OpenHome(Int32)
@@ -202,6 +211,9 @@ pub(all) enum Msg {
Settings
Wallpaper
Recents
RecentsUnavailable
OpenAccessibilitySettings
OpenSelfAppInfo
CheckUpdates
Lift(Int32)
Grab(Int32)
@@ -217,6 +229,14 @@ pub(all) struct ResizeDrag {
slot : Int32
left : Double
top : Double
right : Double
bottom : Double
anchor_col : Int32
anchor_row : Int32
right_col : Int32
bottom_row : Int32
mut col : Int32
mut row : Int32
mut cols : Int32
mut rows : Int32
}
@@ -228,6 +248,7 @@ pub(all) enum Sheet {
Item(Int32)
DrawerApp(Int32)
WidgetPicker
RecentsSetup
}
pub(all) struct WidgetInfo {
+273 -5
View File
@@ -42,6 +42,7 @@ fn Sim::new() -> Sim {
grid_top=150.0,
grid_w=358.0,
bottom_pad=24.0,
scroll_y=0.0,
),
)
s.send(AppsLoaded(Some(apps_json)))
@@ -249,6 +250,21 @@ fn cell_center(col : Int32, row : Int32) -> (Double, Double) {
)
}
///|
/// Finish the pending drawer-close animation timer.
fn Sim::finish_drawer_close(self : Sim) -> Unit {
let mut gen : Int32? = None
for e in self.log {
if e is Delay(_, DrawerClosed(g)) {
gen = Some(g)
}
}
match gen {
Some(g) => self.send(DrawerClosed(g))
None => abort("no pending DrawerClosed timer")
}
}
///|
/// Add apps to the home screen through the long-press menu and the drawer's pick mode.
fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
@@ -258,6 +274,7 @@ fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
self.tap("tile", label=l, from=1) // the drawer's, not the home screen's under it
}
self.tap("btn", label="Done")
self.finish_drawer_close()
}
///|
@@ -294,7 +311,9 @@ test "add apps through the drawer's pick mode" {
s.tap("tile", label="Phone", from=1)
s.tap("tile", label="Gmail", from=1) // toggled off again
s.tap("btn", label="Done")
assert_true(!s.m.drawer)
assert_true(s.m.drawer && s.m.drawer_closing)
s.finish_drawer_close()
assert_true(!s.m.drawer && !s.m.drawer_closing)
assert_eq(s.home_names(), ["Chrome", "Phone"])
}
@@ -307,8 +326,10 @@ test "swipe down opens the drawer, swipe up closes it" {
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=false))
assert_true(s.m.drawer) // the list isn't at its end yet
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=true))
assert_true(!s.m.drawer)
assert_true(s.m.drawer && s.m.drawer_closing)
assert_true(s.has_effect(HideKeyboard))
s.finish_drawer_close()
assert_true(!s.m.drawer)
s.send(Touch(dx=3.0, dy=40.0, ms=200, home_top=true, list_end=false))
assert_true(!s.m.drawer) // too short
}
@@ -580,8 +601,10 @@ test "a widget: hold opens resize handles; drag the handles; Done" {
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
assert_eq(s.m.resizing, 0) // no item menu for a widget: handles
assert_eq(s.m.sheet, NoSheet)
assert_true(s.has_effect(QueryLimits(100))) // queried immediately on entering resize mode
let html = @vdom.to_html(s.tree[0])
assert_true(html.contains("resize-handle"))
assert_true(@vdom.to_html(s.tree[1]).contains("5 × 2"))
assert_true(
@vdom.to_html(s.tree[1]).contains(
"Drag to move, or drag the handles to resize",
@@ -592,10 +615,10 @@ test "a widget: hold opens resize handles; drag the handles; Done" {
.chain_where(fn(e) { e.attrs.contains(("data-edge", "b")) })
.unwrap()
s.press(hc, x=100.0, y=150.0 + 2.0 * 72.0 + 70.0)
assert_true(s.has_effect(QueryLimits(100)))
s.move_to(100.0, 150.0 + 3.0 * 72.0 + 40.0)
s.release()
assert_eq(s.m.home[0].rows, 4)
assert_true(@vdom.to_html(s.tree[1]).contains("5 × 4"))
assert_eq(s.m.resizing, 0) // handles stay
// the right handle to three columns (the widget starts the full row)
let rc = s
@@ -606,6 +629,7 @@ test "a widget: hold opens resize handles; drag the handles; Done" {
s.move_to(c3x + 36.0, 170.0)
s.release()
assert_eq(s.m.home[0].w, 3)
assert_true(@vdom.to_html(s.tree[1]).contains("3 × 4"))
// pressing the widget's body picks it up at once; letting go keeps the handles
let wc = s.chain("widget-slot")
s.press(wc, x=wx, y=wy)
@@ -636,10 +660,19 @@ test "resizing stays within the widget's limits" {
)
let (wx, wy) = cell_center(2, 0)
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
let html = @vdom.to_html(s.tree[0])
assert_true(
html.contains("data-edge=\"l\"") && html.contains("data-edge=\"r\""),
)
assert_true(
!html.contains("data-edge=\"t\"") &&
!html.contains("data-edge=\"b\"") &&
!html.contains("data-edge=\"rb\""),
)
let rc = s
.chain_where(fn(e) { e.attrs.contains(("data-edge", "rb")) })
.chain_where(fn(e) { e.attrs.contains(("data-edge", "r")) })
.unwrap()
s.press(rc, x=370.0, y=250.0)
s.press(rc, x=370.0, y=200.0)
s.move_to(60.0, 600.0) // far left and down
s.release()
assert_eq(s.m.home[0].w, 3) // 3 columns = 204px, the nearest to 200 within the limit
@@ -703,6 +736,8 @@ test "back and home close things from the top down" {
assert_eq(s.m.sheet, NoSheet)
assert_true(s.m.drawer)
s.send(Back)
assert_true(s.m.drawer && s.m.drawer_closing)
s.finish_drawer_close()
assert_true(!s.m.drawer)
s.send(OpenDrawer)
s.send(GoHome)
@@ -902,3 +937,236 @@ test "view snapshot: home with an app" {
),
)
}
///|
test "RecentsUnavailable opens setup sheet with settings and app info actions" {
let s = Sim::new()
s.send(RecentsUnavailable)
assert_eq(s.m.sheet, RecentsSetup)
let html = s.sheet_html()
assert_true(html.contains("Enable window list"))
assert_true(html.contains("Restricted setting"))
assert_true(html.contains("Allow restricted settings"))
s.tap("btn", label="Open Accessibility settings")
assert_true(s.has_effect(OpenAccessibilitySettings))
assert_eq(s.m.sheet, RecentsSetup)
s.tap("btn", label="Open App info")
assert_true(s.has_effect(OpenSelfAppInfo))
assert_eq(s.m.sheet, RecentsSetup)
s.tap("btn", label="Close")
assert_eq(s.m.sheet, NoSheet)
}
///|
test "drawer close animation lifecycle and reopening cancels stale close" {
let s = Sim::new()
s.send(OpenDrawer)
assert_true(s.m.drawer_open())
s.send(CloseDrawer)
assert_true(s.m.drawer && s.m.drawer_closing)
assert_true(!s.m.drawer_open())
assert_true(s.has_effect(HideKeyboard))
let stale_gen = s.m.drawer_gen
assert_true(s.has_effect(Delay(140, DrawerClosed(stale_gen))))
assert_true(@vdom.to_html(s.tree[1]).contains("drawer closing"))
// Reopening while closing cancels the pending close
s.send(OpenDrawer)
assert_true(s.m.drawer_open())
assert_true(!s.m.drawer_closing)
s.send(DrawerClosed(stale_gen))
assert_true(s.m.drawer_open())
// Launching an app closes immediately with no closing animation delay
s.tap("tile", label="Chrome", from=1)
assert_true(s.has_effect(Launch("c.chrome/.Main")))
assert_true(!s.m.drawer && !s.m.drawer_closing)
// First-match Enter and GoHome also close immediately
s.send(OpenDrawer)
let c = s.chain("input")
s.run(typed(s.m, s.table, c, "cal"))
s.run(key(s.m, s.table, c, Enter))
assert_true(!s.m.drawer && !s.m.drawer_closing)
}
///|
test "top-level view nodes have distinct non-zero keys" {
let s = Sim::new()
s.send(OpenDrawer)
s.send(AppMenu(0))
s.m.notice = "Added to home"
let keys : Array[Int32] = []
for n in view(s.m) {
if n is El(e) {
assert_true(e.key != 0)
assert_true(!keys.contains(e.key))
keys.push(e.key)
}
}
assert_eq(keys, [1, 2, 3, 4, 6])
}
///|
test "left/right/top/bottom resize anchors opposite edge and pins unpinned widget" {
let s = Sim::new()
s.add_apps(["Chrome", "Gmail", "Phone"])
s.send(PickWidget)
s.send(WidgetsLoaded(Some(widgets_json)))
s.send(ChooseWidget(0))
s.send(WidgetAdded(100))
s.send(
LimitsKnown(
100,
Some("{\"w\":130,\"minW\":64,\"minH\":64,\"h\":true,\"v\":true}"),
),
)
// Unpinned 2x2 widget starts at (3, 0) beside the 3 apps; resizing Right pins it at (3, 0)
// and widening past the right edge caps at 5 - 3 = 2 columns without shifting x or jumping rows
assert_eq((s.m.home[3].x, s.m.home[3].y, s.m.home[3].w), (-1, -1, 2))
let (wx, wy) = cell_center(3, 0)
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
let rc = s
.chain_where(fn(e) { e.attrs.contains(("data-edge", "r")) })
.unwrap()
s.press(rc, x=374.0, y=200.0)
s.move_to(520.0, 200.0)
s.release()
assert_eq((s.m.home[3].x, s.m.home[3].y, s.m.home[3].w), (3, 0, 2))
// Place widget at (2, 2) and test Left + Top handles keeping right/bottom anchored
s.m.home[3].x = 2
s.m.home[3].y = 2
s.m.home[3].w = 2
s.m.home[3].rows = 2
s.refresh()
let lc = s
.chain_where(fn(e) { e.attrs.contains(("data-edge", "l")) })
.unwrap()
let (c1x, c2y) = cell_center(1, 2)
s.press(lc, x=c1x + 40.0, y=c2y)
s.move_to(c1x - 32.0, c2y) // grow left by 1 col -> (1, 2), w=3 (right_col stays 4)
assert_eq((s.m.home[3].x, s.m.home[3].w), (1, 3))
s.move_to(-100.0, c2y) // clamp at col 0 -> (0, 2), w=4 (right_col stays 4)
assert_eq((s.m.home[3].x, s.m.home[3].w), (0, 4))
let (c2x, _) = cell_center(2, 2)
s.move_to(c2x + 40.0, c2y) // shrink back to 1 col -> (3, 2), w=1 (right_col stays 4)
s.release()
assert_eq((s.m.home[3].x, s.m.home[3].w), (3, 1))
let tc = s
.chain_where(fn(e) { e.attrs.contains(("data-edge", "t")) })
.unwrap()
let (c3x, c1y) = cell_center(3, 1)
s.press(tc, x=c3x, y=150.0 + 2.0 * 72.0)
s.move_to(c3x, c1y - 24.0) // grow up by 1 row -> row 1, rows=3 (bottom_row stays 4)
assert_eq((s.m.home[3].y, s.m.home[3].rows), (1, 3))
s.move_to(c3x, -50.0) // clamp at row 0 -> row 0, rows=4 (bottom_row stays 4)
assert_eq((s.m.home[3].y, s.m.home[3].rows), (0, 4))
let (_, c3y) = cell_center(3, 3)
s.move_to(c3x, c3y - 24.0) // shrink down to 1 row -> row 3, rows=1 (bottom_row stays 4)
s.release()
assert_eq((s.m.home[3].y, s.m.home[3].rows), (3, 1))
}
///|
test "holding a resize handle for 500ms does not lift widget or corrupt resize state" {
let s = Sim::new()
s.send(PickWidget)
s.send(WidgetsLoaded(Some(widgets_json)))
s.send(ChooseWidget(0))
s.send(WidgetAdded(100))
s.send(
LimitsKnown(
100,
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":true,\"v\":true}"),
),
)
let (wx, wy) = cell_center(2, 0)
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
let rc = s
.chain_where(fn(e) { e.attrs.contains(("data-edge", "r")) })
.unwrap()
s.press(rc, x=370.0, y=170.0)
s.hold()
assert_eq(s.m.resizing, 0)
assert_eq(s.m.lifted, -1)
assert_true(s.m.resize is Some(_))
let (c2x, _) = cell_center(1, 0)
s.move_to(c2x + 36.0, 170.0)
s.release()
assert_eq(s.m.home[0].w, 2)
assert_eq(s.m.resizing, 0)
assert_eq(s.m.lifted, -1)
assert_eq(s.m.sheet, NoSheet)
}
///|
test "scrolled Measured keeps nrows constant and resizes in viewport coordinates" {
let s = Sim::new()
s.send(PickWidget)
s.send(WidgetsLoaded(Some(widgets_json)))
s.send(ChooseWidget(0))
s.send(WidgetAdded(100))
s.send(
LimitsKnown(
100,
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":true,\"v\":true}"),
),
)
let unscrolled_rows = s.m.nrows
// Scrolled down 200px: grid_top in viewport moved from 150 to -50
s.send(
Measured(
vw=390,
vh=800,
grid_left=16.0,
grid_top=-50.0,
grid_w=358.0,
bottom_pad=24.0,
scroll_y=200.0,
),
)
assert_eq(s.m.nrows, unscrolled_rows)
let (wx, wy) = cell_center(2, 0)
s.long_press(s.chain("widget-slot"), x=wx, y=wy - 200.0)
let bc = s
.chain_where(fn(e) { e.attrs.contains(("data-edge", "b")) })
.unwrap()
s.press(bc, x=100.0, y=-50.0 + 2.0 * 72.0)
s.move_to(100.0, -50.0 + 3.0 * 72.0 - 8.0) // 3 rows in scrolled viewport coords
s.release()
assert_eq(s.m.home[0].rows, 3)
}
///|
test "only supported resize handles render per widget resizeMode" {
let s = Sim::new()
s.send(PickWidget)
s.send(WidgetsLoaded(Some(widgets_json)))
s.send(ChooseWidget(0))
s.send(WidgetAdded(100))
s.send(
LimitsKnown(
100,
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":false,\"v\":true}"),
),
)
let (wx, wy) = cell_center(2, 0)
s.long_press(s.chain("widget-slot"), x=wx, y=wy)
let v_only = @vdom.to_html(s.tree[0])
assert_true(
v_only.contains("data-edge=\"t\"") && v_only.contains("data-edge=\"b\""),
)
assert_true(
!v_only.contains("data-edge=\"l\"") &&
!v_only.contains("data-edge=\"r\"") &&
!v_only.contains("data-edge=\"rb\""),
)
s.send(
LimitsKnown(
100,
Some("{\"w\":0,\"minW\":64,\"minH\":64,\"h\":false,\"v\":false}"),
),
)
s.refresh()
let none_html = @vdom.to_html(s.tree[0])
assert_true(!none_html.contains("resize-handle"))
}
+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)
}
}
}
+102 -12
View File
@@ -22,12 +22,17 @@ fn cell_style(c : @grid.Cell) -> String {
}
///|
fn handle(edge : String, e : Edge) -> Node[Msg] {
fn handle(edge : String, e : Edge, active : Bool) -> Node[Msg] {
el(
"span",
classes=["resize-handle"],
classes=["resize-handle", cls_if("active", active)],
attrs=[("data-edge", edge), ("aria-hidden", "true")],
handlers={ ..Handlers::none(), down: Some(ResizeBegin(e)), tap: Some(Nop), },
handlers={
..Handlers::none(),
down: Some(ResizeBegin(e)),
tap: Some(Nop),
press: Some(Nop),
},
)
}
@@ -42,7 +47,7 @@ fn Model::view_slot(
let style = cell_style(cell)
match s.kind {
Widget => {
let live = !self.drawer &&
let live = !self.drawer_open() &&
self.sheet == NoSheet &&
(self.resizing < 0 || i == self.resizing)
let attrs = [("data-slot", i.to_string())]
@@ -53,9 +58,22 @@ fn Model::view_slot(
el("span", classes=["widget-label"], children=[text(s.str)]),
]
if i == self.resizing {
children.push(handle("r", Right))
children.push(handle("b", Bottom))
children.push(handle("rb", Corner))
let lim = self.limits.get(s.wid).unwrap_or(default_limits)
let active = match self.resize {
Some(r) if r.slot == i => Some(r.edge)
_ => None
}
if lim.h {
children.push(handle("l", Left, active == Some(Left)))
children.push(handle("r", Right, active == Some(Right)))
}
if lim.v {
children.push(handle("t", Top, active == Some(Top)))
children.push(handle("b", Bottom, active == Some(Bottom)))
}
if lim.h && lim.v {
children.push(handle("rb", Corner, active == Some(Corner)))
}
}
Some(
el(
@@ -165,6 +183,7 @@ fn Model::view_home(self : Model) -> Node[Msg] {
}
el(
"div",
key=1,
classes=["home"],
handlers={
..Handlers::none(),
@@ -255,7 +274,16 @@ fn Model::view_drawer(self : Model) -> Node[Msg] {
} else if tiles.length() == 0 {
children.push(el("p", classes=["empty"], children=[text("No apps match.")]))
}
el("div", classes=["drawer", cls_if("picking", self.picking)], children~)
el(
"div",
key=2,
classes=[
"drawer",
cls_if("picking", self.picking),
cls_if("closing", self.drawer_closing),
],
children~,
)
}
///|
@@ -379,11 +407,70 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
)
}
}
RecentsSetup => {
items.push(sheet_title("Enable window list"))
items.push(
el("p", classes=["sheet-copy"], children=[
text(
"Android only lets accessibility services open Recents, and blocks them on sideloaded apps until you allow restricted settings once (it stays allowed across updates). This service reads nothing on screen.",
),
]),
)
items.push(
el("ol", classes=["sheet-steps"], children=[
el("li", children=[
text("Tap "),
el("strong", children=[text("Open Accessibility settings")]),
text(" and tap "),
el("strong", children=[text("ultra Home window list")]),
text("."),
]),
el("li", children=[
text("If Android says "),
el("strong", children=[text("Restricted setting")]),
text(", return here, tap "),
el("strong", children=[text("Open App info")]),
text(", then tap "),
el("strong", children=[text("⋮")]),
text(" (or scroll to the bottom on Android 15+) → "),
el("strong", children=[text("Allow restricted settings")]),
text("."),
]),
el("li", children=[
text("Return to "),
el("strong", children=[text("Accessibility settings")]),
text(" and turn on "),
el("strong", children=[text("ultra Home window list")]),
text("."),
]),
]),
)
items.push(
el("div", classes=["sheet-actions"], children=[
el(
"button",
classes=["btn"],
handlers=tap(OpenAccessibilitySettings),
children=[text("Open Accessibility settings")],
),
el(
"button",
classes=["btn", "secondary"],
handlers=tap(OpenSelfAppInfo),
children=[text("Open App info")],
),
el("button", classes=["btn", "ghost"], handlers=tap(CloseSheet), children=[
text("Close"),
]),
]),
)
}
}
[
el("div", classes=["sheet-overlay"], handlers=tap(CloseSheet)),
el("div", key=3, classes=["sheet-overlay"], handlers=tap(CloseSheet)),
el(
"div",
key=4,
classes=["sheet"],
attrs=[("role", "dialog"), ("aria-modal", "true")],
handlers={ ..Handlers::none(), escape: Some(CloseSheet), },
@@ -394,7 +481,10 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
///|
fn Model::view_resize_bar(self : Model) -> Node[Msg] {
el("div", classes=["resize-bar"], attrs=[("role", "toolbar")], children=[
let s = self.home[self.resizing]
let size = "\{s.cols(self.cols)} × \{s.height()}"
el("div", key=5, classes=["resize-bar"], attrs=[("role", "toolbar")], children=[
el("span", classes=["resize-size"], children=[text(size)]),
el("span", classes=["resize-hint"], children=[
text("Drag to move, or drag the handles to resize"),
]),
@@ -419,12 +509,12 @@ pub fn view(m : Model) -> Array[Node[Msg]] {
}
if m.sheet != NoSheet {
out.append(m.view_sheet())
} else if m.resizing >= 0 && !m.drawer {
} else if m.resizing >= 0 && !m.drawer_open() {
out.push(m.view_resize_bar())
}
if m.notice != "" {
out.push(
el("div", classes=["notice"], attrs=[("role", "status")], children=[
el("div", key=6, classes=["notice"], attrs=[("role", "status")], children=[
text(m.notice),
]),
)