From d7bd24b817a477196e96dcc64ac11714d317dfab Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 23:46:02 +0000 Subject: [PATCH] Resize widgets by dragging handles on their edges Holding a widget and letting go without moving now shows handles on its right edge, bottom edge and corner (plus a Remove / Done bar). Dragging them snaps the widget to whole grid columns and half rows, within the provider's min/max resize size and resize mode, which the shell reports through widgetLimits. Widgets keep their width in columns (0 = full row), saved with the rest of the home screen. The shell keeps the system's edge-swipe gestures off the handles and only calls updateAppWidgetSize when a widget's size actually changes (with the sizes list on Android 12+), not on every scroll. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01PuFQh1zV94TcKboMuS7t35 --- README.md | 2 +- .../java/dev/ultra/launcher/MainActivity.java | 75 +++++++++++++- tests/e2e.cjs | 23 ++++- web/app.py | 95 ++++++++++++++++-- web/app.wasm | Bin 12565 -> 14020 bytes web/index.html | 66 +++++++++++- web/style.css | 21 ++++ 7 files changed, 267 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f8fd60f..f523f1e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ultra launcher -An Android home screen written as an [ultra](https://github.com/nandi-conda/ultra) app (LPython compiled to WebAssembly, Elm-style). The home starts blank with a clock: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to move or remove it. Swipe down for the drawer with every app and a search (Enter opens the first match); long-press an app there to put it on the home screen, and swipe up to close it. The panel under the clock has a **Windows** button that opens Recents. The layout is saved in localStorage. +An Android home screen written as an [ultra](https://github.com/nandi-conda/ultra) app (LPython compiled to WebAssembly, Elm-style). The home starts blank with a clock: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to drag it somewhere else; let go without moving to get its menu, or, for a widget, handles on its edges that resize it to the grid. Swipe down for the drawer with every app and a search (Enter opens the first match); long-press an app there to put it on the home screen, and swipe up to close it. The panel under the clock has a **Windows** button that opens Recents. The layout is saved in localStorage. ## Install diff --git a/android/app/src/main/java/dev/ultra/launcher/MainActivity.java b/android/app/src/main/java/dev/ultra/launcher/MainActivity.java index 3b90a7f..1006bb0 100644 --- a/android/app/src/main/java/dev/ultra/launcher/MainActivity.java +++ b/android/app/src/main/java/dev/ultra/launcher/MainActivity.java @@ -16,6 +16,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Insets; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; @@ -28,6 +29,7 @@ import android.provider.Settings; import android.text.format.DateFormat; import android.util.Base64; import android.util.Log; +import android.util.SizeF; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import android.view.View; @@ -73,7 +75,8 @@ import java.util.concurrent.Executors; * wicon?p=PROV the provider's icon as a PNG * * and exposes window.Android (launch, appInfo, addWidget, removeWidget, placeWidgets, - * openSettings, pickWallpaper, openRecents, haptic, is24Hour) for the app's @jscall imports. + * widgetLimits, excludeGestures, openSettings, pickWallpaper, openRecents, haptic, is24Hour) + * for the app's @jscall imports and index.html. * * Widgets are real AppWidgetHostViews in a layer above the WebView. The page reports where * its live widget slots are (placeWidgets), and this class moves the views there. Package @@ -93,6 +96,7 @@ public class MainActivity extends Activity { private AppWidgetManager widgets; private AppWidgetHost widgetHost; private final Map widgetViews = new HashMap<>(); + private final Map widgetSizes = new HashMap<>(); // last size told to each widget private int pendingWidget = -1; private boolean ready; private int insetTop, insetBottom; // CSS px @@ -163,6 +167,7 @@ public class MainActivity extends Activity { return insets; }); widgetViews.clear(); + widgetSizes.clear(); widgetLayer = new FrameLayout(this); FrameLayout root = new FrameLayout(this); root.addView(web); @@ -473,9 +478,56 @@ public class MainActivity extends Activity { private void removeWidget(int id) { AppWidgetHostView v = widgetViews.remove(id); if (v != null) widgetLayer.removeView(v); + widgetSizes.remove(id); widgetHost.deleteAppWidgetId(id); } + /** + * How far a placed widget may be resized, in CSS px: {"minW", "minH", "maxW", "maxH" + * (0 = no limit), "h", "v" (whether it resizes horizontally / vertically)}. + */ + private String widgetLimits(int id) { + AppWidgetProviderInfo w = widgets.getAppWidgetInfo(id); + JSONObject o = new JSONObject(); + try { + if (w == null) return o.toString(); + float d = getResources().getDisplayMetrics().density; + // A minResize larger than the min size (or unset) means the min size applies. + int minW = w.minResizeWidth > 0 && w.minResizeWidth < w.minWidth ? w.minResizeWidth : w.minWidth; + int minH = w.minResizeHeight > 0 && w.minResizeHeight < w.minHeight ? w.minResizeHeight : w.minHeight; + int maxW = 0, maxH = 0; + if (Build.VERSION.SDK_INT >= 31) { + maxW = w.maxResizeWidth; + maxH = w.maxResizeHeight; + } + o.put("minW", Math.round(minW / d)).put("minH", Math.round(minH / d)) + .put("maxW", Math.round(maxW / d)).put("maxH", Math.round(maxH / d)) + .put("h", (w.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) + .put("v", (w.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0); + } catch (JSONException e) { + Log.w("ultra", "widget limits", e); + } + return o.toString(); + } + + /** Keep the system's edge gestures off these page rects ([[x, y, w, h], ...] in CSS px). */ + private void excludeGestures(String json) { + if (Build.VERSION.SDK_INT < 29) return; + float d = getResources().getDisplayMetrics().density; + List rects = new ArrayList<>(); + try { + JSONArray a = new JSONArray(json); + for (int i = 0; i < a.length(); i++) { + JSONArray r = a.getJSONArray(i); + int x = Math.round(r.getInt(0) * d), y = Math.round(r.getInt(1) * d); + rects.add(new Rect(x, y, x + Math.round(r.getInt(2) * d), y + Math.round(r.getInt(3) * d))); + } + } catch (JSONException e) { + return; + } + web.setSystemGestureExclusionRects(rects); + } + /** Lay widget views over the page's live slots: [[id, x, y, w, h], ...] in CSS px. */ private void placeWidgets(String json) { float d = getResources().getDisplayMetrics().density; @@ -511,7 +563,18 @@ public class MainActivity extends Activity { lp.topMargin = r[1]; v.setLayoutParams(lp); v.setVisibility(View.VISIBLE); - v.updateAppWidgetSize(new Bundle(), r[4], r[5], r[4], r[5]); + // Scrolling moves a widget without resizing it; only tell it about new sizes. + long size = ((long) r[4] << 32) | r[5]; + Long was = widgetSizes.put(id, size); + if (was == null || was != size) { + if (Build.VERSION.SDK_INT >= 31) { + List sizes = new ArrayList<>(); + sizes.add(new SizeF(r[4], r[5])); + v.updateAppWidgetSize(new Bundle(), sizes); + } else { + v.updateAppWidgetSize(new Bundle(), r[4], r[5], r[4], r[5]); + } + } } } @@ -678,6 +741,14 @@ public class MainActivity extends Activity { main.post(() -> MainActivity.this.placeWidgets(json)); } + @JavascriptInterface public String widgetLimits(int id) { + return MainActivity.this.widgetLimits(id); + } + + @JavascriptInterface public void excludeGestures(String json) { + main.post(() -> MainActivity.this.excludeGestures(json)); + } + @JavascriptInterface public void loadIcons(String keys) { MainActivity.this.loadIcons(keys); } diff --git a/tests/e2e.cjs b/tests/e2e.cjs index 24b00f3..09dce0c 100644 --- a/tests/e2e.cjs +++ b/tests/e2e.cjs @@ -94,8 +94,29 @@ const BASE = process.env.BASE || "http://localhost:8000"; assert.equal(await p.$$eval(".slots > li", (ls) => ls.length), 5); await p.click(".slots .tile:first-child"); await settle(); assert.equal(await p.textContent("#toast"), "Open com.example.gmail/.MainActivity"); + // hold a widget without moving: resize handles; drag them to snap it to the grid await longpress(".widget-slot"); - await p.click(".sheet-item >> text=Remove widget"); await settle(); + assert.ok(!(await p.$(".sheet")), "a widget gets handles, not the menu"); + assert.ok(await p.$(".widget-slot.resizing .resize-handle[data-edge=rb]")); + const size = () => p.$eval(".widget-slot", (w) => [Math.round(w.getBoundingClientRect().width), Math.round(w.getBoundingClientRect().height)]); + const [w0] = await size(); + const tile = await p.locator(".slots .tile").first().boundingBox(); + const hd = await p.locator(".resize-handle[data-edge=rb]").boundingBox(); + await p.mouse.move(hd.x + hd.width / 2, hd.y + hd.height / 2); + await p.mouse.down(); + const ws = await p.locator(".widget-slot").boundingBox(); + await p.mouse.move(ws.x + tile.width * 2.1, ws.y + 230, { steps: 8 }); await settle(); + await p.mouse.up(); await settle(); + const [w1, h1] = await size(); + assert.ok(w1 < w0 && Math.abs(w1 - (2 * tile.width + 8)) < 3, `two columns wide: ${w1} (tile ${tile.width})`); + assert.equal(h1, 250, "snapped to half rows"); + assert.ok(await p.$(".widget-slot.resizing"), "letting go of a handle keeps the handles"); + await p.click(".resize-bar >> text=Done"); await settle(); + assert.ok(!(await p.$(".resize-handle"))); + await p.reload(); await p.waitForSelector(".widget-slot"); + assert.deepEqual(await size(), [w1, h1], "the size is saved"); + await longpress(".widget-slot"); + await p.click(".resize-bar >> text=Remove"); await settle(); assert.ok(!(await p.$(".widget-slot"))); await p.evaluate(() => { window.ultraHome.reload(); }); await settle(); assert.equal(await p.$$eval(".slots > li", (ls) => ls.length), 4); diff --git a/web/app.py b/web/app.py index 74843a7..f0bca3e 100644 --- a/web/app.py +++ b/web/app.py @@ -10,7 +10,9 @@ from ui import btn_open, input_open, alert # An Android home screen. The home starts blank: you add apps and widgets to it # with a long press. Swiping down opens the drawer with every app and a search. # A long press on a home app or widget picks it up: drag it to move it, or let go -# without moving to get its menu (index.html does the dragging). +# without moving to get its menu (index.html does the dragging). Letting go of a +# widget that way shows resize handles on its right and bottom edges instead: +# dragging them snaps the widget to the grid, within the sizes it allows. # # The native shell (android/) serves this folder in a WebView, answers # apps.json and widgets.json, hosts the widgets as native views over the @@ -100,6 +102,8 @@ DROP: Const[i32] = 36 # arg: 1 if it was dragged, 0 if just held (opens WQUERY: Const[i32] = 37 # widget picker search WCLEAR: Const[i32] = 38 CHOOSE_FIRST_WIDGET: Const[i32] = 39 +RESIZE: Const[i32] = 40 # arg: columns * 4096 + height in px for the widget being resized +RESIZE_DONE: Const[i32] = 41 CAP: Const[i32] = 512 HOME_CAP: Const[i32] = 40 @@ -124,12 +128,14 @@ comps: i32[512] = empty(512, dtype=int32) icons: i32[512] = empty(512, dtype=int32) n: i32 = 0 # The home screen, in order. An app slot keeps its component name in hstr; -# a widget slot keeps the widget's label there, its host id in hwid and its -# height in CSS px in hh. hkey is a stable key for the DOM diff. +# a widget slot keeps the widget's label there, its host id in hwid, its +# height in CSS px in hh and its width in grid columns in hw (0: the whole row). +# hkey is a stable key for the DOM diff. hkind: i32[512] = empty(512, dtype=int32) hstr: i32[512] = empty(512, dtype=int32) hwid: i32[512] = empty(512, dtype=int32) hh: i32[512] = empty(512, dtype=int32) +hw: i32[512] = empty(512, dtype=int32) hkey: i32[512] = empty(512, dtype=int32) nh: i32 = 0 next_key: i32 = 1 @@ -157,6 +163,7 @@ picking: i32 = 0 # drawer is in "add apps" mode: taps toggle home slots sheet: i32 = 0 item: i32 = -1 # home slot the item sheet is about lifted: i32 = -1 # home slot picked up by a long press, being dragged +resizing: i32 = -1 # widget slot showing resize handles pending: i32 = 0 # JSON handle of a request in flight @@ -181,6 +188,7 @@ def init() -> None: hstr[nh] = h hwid[nh] = load_i32_at("ultra.home.wid", i, 0) hh[nh] = load_i32_at("ultra.home.h", i, 120) + hw[nh] = load_i32_at("ultra.home.w", i, 0) hkey[nh] = next_key next_key += 1 nh += 1 @@ -200,6 +208,7 @@ def save_home() -> None: s_save_at("ultra.home.str", i, hstr[i]) store_i32_at("ultra.home.wid", i, hwid[i]) store_i32_at("ultra.home.h", i, hh[i]) + store_i32_at("ultra.home.w", i, hw[i]) def say(msg: str) -> None: @@ -339,6 +348,7 @@ def push_slot(kind: i32, s: i32, wid: i32, h: i32) -> None: hstr[nh] = s hwid[nh] = wid hh[nh] = h + hw[nh] = 0 hkey[nh] = next_key next_key += 1 nh += 1 @@ -366,6 +376,7 @@ def remove_slot(at: i32) -> None: hstr[j] = hstr[j + 1] hwid[j] = hwid[j + 1] hh[j] = hh[j + 1] + hw[j] = hw[j + 1] hkey[j] = hkey[j + 1] nh -= 1 save_home() @@ -385,6 +396,9 @@ def swap_slots(a: i32, b: i32) -> None: t = hh[a] hh[a] = hh[b] hh[b] = t + t = hw[a] + hw[a] = hw[b] + hw[b] = t t = hkey[a] hkey[a] = hkey[b] hkey[b] = t @@ -411,17 +425,18 @@ def slot_of_widget(wid: i32) -> i32: def close_all() -> None: - global drawer, picking, sheet, item, lifted + global drawer, picking, sheet, item, lifted, resizing s_clear(query) drawer = 0 picking = 0 sheet = NONE item = -1 lifted = -1 + resizing = -1 # ---- Update def update(msg: i32, arg: i32) -> None: - global loading, drawer, picking, sheet, item, pending, wloading, chosen, lifted + global loading, drawer, picking, sheet, item, pending, wloading, chosen, lifted, resizing i: i32 if msg == LOADED: load_apps(arg) @@ -452,6 +467,7 @@ def update(msg: i32, arg: i32) -> None: launch(comps[i]) close_all() elif msg == OPEN_HOME: + resizing = -1 launch(hstr[arg]) elif msg == ADD_HOME: haptic() @@ -463,15 +479,18 @@ def update(msg: i32, arg: i32) -> None: elif nh < HOME_CAP: push_slot(APP, s_dup(comps[arg]), 0, 0) elif msg == MENU: + resizing = -1 haptic() sheet = SHEET_MENU elif msg == LIFT: if drawer == 0 and sheet == NONE: haptic() + resizing = -1 lifted = arg elif msg == WIDGET_MENU: i = slot_of_widget(arg) if i >= 0 and drawer == 0 and sheet == NONE: + resizing = -1 lifted = i elif msg == DRAG_TO: if lifted >= 0 and arg >= 0 and arg < nh and arg != lifted: @@ -479,9 +498,19 @@ def update(msg: i32, arg: i32) -> None: lifted = arg elif msg == DROP: if lifted >= 0 and arg == 0: - item = lifted - sheet = SHEET_ITEM + if hkind[lifted] == WIDGET: + resizing = lifted + else: + item = lifted + sheet = SHEET_ITEM lifted = -1 + elif msg == RESIZE: + if resizing >= 0: + hw[resizing] = arg // 4096 + hh[resizing] = arg % 4096 + save_home() + elif msg == RESIZE_DONE: + resizing = -1 elif msg == CLOSE_SHEET: sheet = NONE item = -1 @@ -510,6 +539,7 @@ def update(msg: i32, arg: i32) -> None: push_slot(WIDGET, s_dup(wlabels[chosen]), arg, wheights[chosen]) chosen = -1 elif msg == REMOVE: + resizing = -1 remove_slot(arg) sheet = NONE item = -1 @@ -544,6 +574,8 @@ def update(msg: i32, arg: i32) -> None: elif msg == BACK: if lifted >= 0: lifted = -1 + elif resizing >= 0: + resizing = -1 elif sheet != NONE: sheet = NONE item = -1 @@ -562,6 +594,34 @@ def view_icon(h: i32) -> None: end() +def view_handle(edge: str) -> None: + """A resize handle just outside the slot (the native widget covers the inside).""" + el("span") + cls("resize-handle") + attr("data-edge", edge) + attr("aria-hidden", "true") + end() + + +def view_resize_bar() -> None: + el("div") + cls("resize-bar") + attr("role", "toolbar") + el("span") + cls("resize-hint") + text("Drag the handles to resize") + end() + btn_open("ghost", REMOVE, resizing) + cls("sm") + text("Remove") + end() + btn_open("primary", RESIZE_DONE, 0) + cls("sm") + text("Done") + end() + end() + + def view_home_slot(i: i32) -> None: row: i32 if hkind[i] == WIDGET: @@ -569,20 +629,31 @@ def view_home_slot(i: i32) -> None: key(hkey[i]) cls("widget-slot") cls_if("lifted", i == lifted) + cls_if("resizing", i == resizing) attr_num("data-slot", i) - s_set(scratch, "height:") + if hw[i] > 0: + s_set(scratch, "grid-column:span ") + s_add_num(scratch, hw[i]) + s_add(scratch, ";height:") + else: + s_set(scratch, "height:") s_add_num(scratch, hh[i]) s_add(scratch, "px") attr_ref("style", scratch) # The native widget view is laid over slots marked live, so only mark - # them while nothing covers the home screen. - if drawer == 0 and sheet == NONE: + # them while nothing covers the home screen. While one is resized the + # others step aside, so nothing native covers its handles. + if drawer == 0 and sheet == NONE and (resizing < 0 or i == resizing): attr_num("data-wid", hwid[i]) on_longpress(LIFT, i) el("span") cls("widget-label") text_ref(hstr[i]) end() + if i == resizing: + view_handle("r") + view_handle("b") + view_handle("rb") end() return row = app_of(hstr[i]) @@ -626,6 +697,8 @@ def view_home() -> None: i: i32 div("home") on_longpress(MENU, 0) + if resizing >= 0: + on_click(RESIZE_DONE, 0) # a tap beside the widget finishes el("button") cls("pull") attr("aria-label", "All apps") @@ -826,6 +899,8 @@ def view() -> None: view_drawer() if sheet != NONE: view_sheet() + elif resizing >= 0 and drawer == 0: + view_resize_bar() if s_len(notice) > 0: el("div") cls("notice") diff --git a/web/app.wasm b/web/app.wasm index 45bdac8f10c278036ed7249c2c604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{7)64`D!oqY@sihnF@q(dOhKJ1#h_fubR#IxINW2bk*{;fD zX(){$)1@NJ;QI#0UB^BGPNUszfL+MAjoRd3qxc!MLnVfA0f({iJ%EWxEJEl_N;RZ3 zNhuXc!EwZ~zW~Kp@ewJFB6kKHgRv^ZK4$eH9er<*Nh>6V=8^u{_Sd$gH56T=x|~_aHv{Vq|mrKTQ2AbiGBc8E~0g zH$$$&FgjybzV?7gmBzu?vG0dE+y|JDk1sS%$d3Imq&y_0iqwu(NlIcOSof!Y1>5Fp z#eBb?#t@}I*(<Go>1alg8V`SNd)8J^bT)>YIJQ9L?##+ zfjP0S5S$97PW_tpF>4e}`z$D|$&icyZaaFSSS_T7DksY6VMH*#)R8H#OCQ9?a{cnP z9D|*KFMh~lR|@i>;^7@@4HEsB1?XqXeyR&yaj-|x0uE!jdjv~Ge6%S07S8&}rJ$N! z=>hx00(sM$bHyEiW838*C!QfVS}2Z;Hr@agmjLh@sAff60GOzL&VINUKrRKv_~bId zdgCN&9#U~bfK>^qvEX%rGA^cuy^`Q=P`kuVUjqzgCGmon-Q@TP9Da!gFj1Ufmd1e` zqC(0&Qt~BQ0w;8M4HPriCO~GNk&*l-zE(KDqd*0R(fRam01oF%eqO`59;-6!e;%N* z6}M8E6%P8yrQk68#}$J00@2Yth0w03vN(|iq=)NzX zJ*S6jl?f@sk$1>-1YE|`w_CV^$zry+EkUvXms!Vi0L318-y+x@$?*j^dS$dn0G9>( zlAqk~}& YoEvU896JrFIq+QqxU6Mv!PcApUnPSC9smFU diff --git a/web/index.html b/web/index.html index 4a797e5..2ee7a43 100644 --- a/web/index.html +++ b/web/index.html @@ -28,6 +28,7 @@ addWidget: () => setTimeout(() => window.ultraHome.widgetAdded(demoWidget++), 0), removeWidget: () => {}, placeWidgets: () => {}, + widgetLimits: () => JSON.stringify({ minW: 120, minH: 80, maxW: 0, maxH: 0, h: true, v: true }), openSettings: () => toast("Open system settings"), pickWallpaper: () => toast("Pick a wallpaper"), openRecents: () => toast("Show open windows"), @@ -53,7 +54,14 @@ }); const j = JSON.stringify(slots); if (j !== placed) { placed = j; host.placeWidgets(j); } + // Keep the system's edge swipes (back) off the resize handles. + const handles = JSON.stringify([...document.querySelectorAll(".resize-handle")].map((h) => { + const r = h.getBoundingClientRect(); + return [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]; + })); + if (handles !== excluded) { excluded = handles; host.excludeGestures?.(handles); } }; + let excluded = "[]"; // Icons: each gets its src from here. On a phone the // shell draws icons on its own thread and hands them back as data: URIs in batches @@ -113,7 +121,7 @@ // Messages the shell and the gestures below send (keep in sync with app.py). const TICK = 1, RELOAD = 2, HOME = 3, BACK = 4, SWIPE_DOWN = 5, SWIPE_UP = 6, - WIDGET_ADDED = 7, WIDGET_MENU = 8, DRAG_TO = 35, DROP = 36; + WIDGET_ADDED = 7, WIDGET_MENU = 8, DRAG_TO = 35, DROP = 36, RESIZE = 40; // Dragging a home slot. A long press lifts it (app.py marks it .lifted); moving the // finger then slides it to the slot under the finger, and letting go drops it there. @@ -155,6 +163,62 @@ addEventListener("touchmove", (e) => { if (drag && document.querySelector(".slots > .lifted") && e.cancelable) e.preventDefault(); }, { passive: false }); + + // Resizing a widget. Holding a widget and letting go without moving shows handles on + // its right edge, bottom edge and corner (app.py). Dragging one snaps the widget to + // whole grid columns and half rows, within the shell's limits for that widget + // (widgetLimits, CSS px: min/max size, 0 = no max, and whether it resizes h and v). + const CELL = 88; // a row of app tiles + let rs = null, swallowClick = false; + const span = (k, size, gap) => k * size + (k - 1) * gap; + const fit = (want, lo, hi, size, gap, min, max) => { + // the step nearest to want, kept within [min, max] px where it can be + let k = Math.round((want + gap) / (size + gap)); + while (k < hi && span(k, size, gap) < min - 8) k++; + while (k > lo && max > 0 && span(k, size, gap) > max + 8) k--; + return Math.max(lo, Math.min(hi, k)); + }; + addEventListener("pointerdown", (e) => { + const h = e.target.closest?.(".resize-handle"); + if (!h || !e.isPrimary) return; + e.stopPropagation(); e.preventDefault(); // not a long press on the slot under it + const li = h.closest("li"), slots = li.parentElement, cs = getComputedStyle(slots); + const cols = cs.gridTemplateColumns.split(" ").map(parseFloat); + const wid = +li.dataset.wid || 0; + let lim = {}; + try { lim = JSON.parse(host.widgetLimits?.(wid) || "{}"); } catch {} + const r = li.getBoundingClientRect(); + rs = { li, edge: h.dataset.edge, left: r.left, top: r.top, lim, n: cols.length, colW: cols[0], + gap: parseFloat(cs.columnGap) || 0, rgap: parseFloat(cs.rowGap) || 0, + cols: Math.round((r.width + (parseFloat(cs.columnGap) || 0)) / (cols[0] + (parseFloat(cs.columnGap) || 0))), + h: Math.round(r.height) }; + dragged = true; + h.setPointerCapture?.(e.pointerId); + }, true); + addEventListener("pointermove", (e) => { + if (!rs) return; + const { lim, n, colW, gap, rgap } = rs, half = (CELL + rgap) / 2; + let cols = rs.cols, h = rs.h; + if (rs.edge !== "b" && lim.h !== false) + cols = fit(e.clientX - rs.left, 1, n, colW, gap, lim.minW || 0, lim.maxW || 0); + if (rs.edge !== "r" && lim.v !== false) { + // half-row steps: 2 halves are one row of tiles, 4 are two rows with the gap between + const k = fit(e.clientY - rs.top + rgap, 2, 40, half, 0, (lim.minH || 0) + rgap, lim.maxH ? lim.maxH + rgap : 0); + h = Math.round(k * half - rgap); + } + if (cols === rs.cols && h === rs.h) return; + rs.cols = cols; rs.h = h; + host.haptic(); + app.dispatch(RESIZE, (cols >= n ? 0 : cols) * 4096 + h); + }, true); + const endResize = () => { if (rs) { rs = null; swallowClick = true; setTimeout(() => swallowClick = false, 0); } }; + addEventListener("pointerup", endResize, true); + addEventListener("pointercancel", endResize, true); + addEventListener("click", (e) => { // the click that ends a handle drag isn't a tap beside the widget + if (swallowClick || e.target.closest?.(".resize-handle")) { swallowClick = false; e.stopPropagation(); e.preventDefault(); } + }, true); + addEventListener("touchmove", (e) => { if (rs && e.cancelable) e.preventDefault(); }, { passive: false }); + window.ultraHome = { tick: () => { formats(); app.dispatch(TICK, 1); }, reload: () => app.dispatch(RELOAD, 0), diff --git a/web/style.css b/web/style.css index e058435..bc13db8 100644 --- a/web/style.css +++ b/web/style.css @@ -58,6 +58,27 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t border: 1px dashed rgb(255 255 255 / .3); } .widget-label { font-size: .875rem; opacity: .75; text-shadow: var(--shadow-text); } +/* A widget being resized: handles sit just outside its right and bottom edges, where the + native widget view doesn't cover them; the extra margin keeps the next row clear. */ +.widget-slot { position: relative; } +.widget-slot.resizing { margin-bottom: 1.75rem; outline: 2px solid rgb(255 255 255 / .85); + outline-offset: 3px; transition: none; } +.resize-handle { position: absolute; z-index: 2; touch-action: none; cursor: nwse-resize; } +.resize-handle::after { content: ""; position: absolute; border-radius: 999px; background: #fff; + box-shadow: 0 1px 6px rgb(0 0 0 / .45); } +.resize-handle[data-edge="r"] { top: 0; bottom: 0; right: -16px; width: 16px; cursor: ew-resize; } +.resize-handle[data-edge="r"]::after { top: 50%; left: 6px; width: 6px; height: 2.5rem; transform: translateY(-50%); } +.resize-handle[data-edge="b"] { left: 0; right: 0; bottom: -1.75rem; height: 1.75rem; cursor: ns-resize; } +.resize-handle[data-edge="b"]::after { left: 50%; top: 8px; width: 2.5rem; height: 6px; transform: translateX(-50%); } +.resize-handle[data-edge="rb"] { right: -16px; bottom: -1.75rem; width: 2.75rem; height: 1.75rem; } +.resize-handle[data-edge="rb"]::after { right: 4px; top: 6px; width: 14px; height: 14px; border-radius: 4px; } +.resize-bar { position: fixed; left: 50%; bottom: calc(var(--bottom) + 1rem); z-index: 15; transform: translateX(-50%); + display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem .4rem 1rem; border-radius: 999px; + background: rgb(0 0 0 / .8); color: #fff; font-size: .875rem; white-space: nowrap; + animation: ui-fade .15s; } +.resize-bar .btn.ghost { color: #fff; } +.resize-bar .btn.ghost:hover { background: rgb(255 255 255 / .12); color: #fff; } + /* A slot picked up by a long press, while it is dragged (index.html moves it). */ .slots > li { transition: transform .15s ease-out; } .slots > .lifted { z-index: 1; transform: scale(1.12); background: rgb(255 255 255 / .16);