palm-client: tap and hold a channel on Home for Mute/Unmute, Channel Scope, Leave

RowList gets an optional hold callback: the pen still (3 px) on a row for half
a second unhighlights it, and lifting calls the callback (DMs fall back to a
tap). The channel actions take a slot, with the menu versions wrapping them.
This commit is contained in:
rich committed 2026-11-03 11:11:30 -05:00
1 parent 7b2f10343c
commit aa09b1800d
14 files changed
+266 -18

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

+1
View File
@@ -97,6 +97,7 @@ BEGIN
SCROLLBAR ID HomeScroll AT (153 16 7 128) VALUE 0 MIN 0 MAX 0 PAGESIZE 1
BUTTON "Contacts" ID HomeContactsButton AT (1 147 AUTO AUTO)
BUTTON "Node" ID HomeNodeButton AT (PREVRIGHT+5 PREVTOP AUTO AUTO)
LIST "" ID HomeActionList AT (28 16 80 AUTO) NONUSABLE VISIBLEITEMS 3
END
/* One conversation: transcript, compose field, send */
+11 -6
View File
@@ -147,22 +147,27 @@ Boolean ChannelFormHandleEvent(EventType *event)
void ChannelLeaveCurrent(void)
{
VmChannel c;
Char name[VM_NAME_SIZE + 1], msg[48];
Err err;
if (FrmGetActiveFormID() != ConvoForm || gAppConv.type != VM_CONV_CHANNEL) {
Error("Open the channel you want to leave first.");
return;
}
ChannelLeave(gAppConv.channel);
}
void ChannelLeave(UInt8 slot)
{
VmChannel c;
Char name[VM_NAME_SIZE + 1], msg[48];
Err err;
if (!SessionIsConnected()) {
Error("Connect to the radio first.");
return;
}
StrCopy(name, ChannelsFindSlot(gAppConv.channel, &c) ? c.name : "this channel");
StrCopy(name, ChannelsFindSlot(slot, &c) ? c.name : "this channel");
if (FrmCustomAlert(LeaveChannelAlert, name, "", "") != 0)
return;
err = ChannelsRemove(gAppConv.channel, SessionDevice()->maxChannels);
err = ChannelsRemove(slot, SessionDevice()->maxChannels);
if (err != errNone) {
AppErrorText(err, msg);
Error(msg);
+2
View File
@@ -7,5 +7,7 @@
Boolean ChannelFormHandleEvent(EventType *event) VM_SECT2;
/* Options > Leave Channel: asks, then empties the open channel's slot. */
void ChannelLeaveCurrent(void) VM_SECT2;
/* The same for any channel (Home's tap-and-hold); goes back to Home. */
void ChannelLeave(UInt8 slot) VM_SECT2;
#endif
+51 -1
View File
@@ -1,7 +1,8 @@
/*
* Home: the conversation list, MeshTerm's chat picker. Channels in slot
* order, then direct conversations (most recent first). Each row: marker,
* name, unread badge or failed mark, age, preview. Tap to open.
* name, unread badge or failed mark, age, preview. Tap to open; tap and hold
* a channel for its actions (mute, scope, leave).
*/
#include <PalmOS.h>
#include "resources.h"
@@ -12,6 +13,9 @@
#include "ui/text.h"
#include "ui/rowlist.h"
#include "home_form.h"
#include "mutes.h"
#include "scopes.h"
#include "channel_form.h"
/* In the second code segment: see sections.h for the rules. */
static void DrawRow(UInt16 row, const RectangleType *b, void *ctx) VM_SECT2;
@@ -20,6 +24,7 @@ static void DrawTitleStatus(void) VM_SECT2;
static void ShowStatus(const Char *text) VM_SECT2;
static void TitleRight(const Char *text) VM_SECT2;
static void Rebuild(Boolean draw) VM_SECT2;
static Boolean Hold(UInt16 row, const RectangleType *b, void *ctx) VM_SECT2;
#define HOME_MAX_ROWS 64
#define NAME_X 8
@@ -65,6 +70,50 @@ static void DrawRow(UInt16 row, const RectangleType *b, void *ctx)
FntSetFont(old);
}
#define HOLD_ITEMS 3
#define HOLD_LIST_X 28
#define HOLD_LIST_H (HOLD_ITEMS * 11 + 2) /* stdFont rows and the frame */
/* Tap and hold on a channel: a popup of its actions beside the row. DMs open as a tap. */
static Boolean Hold(UInt16 row, const RectangleType *b, void *ctx)
{
const VmConvRow *r = &gRows[row];
FormType *form = FrmGetActiveForm();
ListType *list;
Char *items[HOLD_ITEMS];
Coord y;
UInt8 slot;
if (r->kind != VM_ROW_CONV || r->conv.type != VM_CONV_CHANNEL)
return false;
slot = r->conv.channel;
items[0] = r->muted ? "Unmute" : "Mute";
items[1] = "Channel Scope...";
items[2] = "Leave Channel";
/* below the row, or above it near the bottom of the list */
y = b->topLeft.y + b->extent.y;
if (y + HOLD_LIST_H > b->topLeft.y + RowListVisibleRows(&gList) * gList.rowH)
y = b->topLeft.y - HOLD_LIST_H;
list = FrmGetObjectPtr(form, FrmGetObjectIndex(form, HomeActionList));
LstSetListChoices(list, items, HOLD_ITEMS);
LstSetHeight(list, HOLD_ITEMS);
LstSetPosition(list, HOLD_LIST_X, y);
LstSetSelection(list, noListSelection);
switch (LstPopupList(list)) {
case 0:
ChannelMuteToggle(slot);
Rebuild(true);
break;
case 1:
ChannelScopeChoose(slot);
break;
case 2:
ChannelLeave(slot);
break;
}
return true;
}
static Boolean Selectable(UInt16 row, void *ctx)
{
return gRows[row].kind == VM_ROW_CONV;
@@ -132,6 +181,7 @@ Boolean HomeFormHandleEvent(EventType *event)
if (!gRows)
return false;
RowListInit(&gList, HomeGadget, HomeScroll, VM_ROW_H, DrawRow, Selectable, NULL);
gList.hold = Hold;
Rebuild(false);
FrmDrawForm(FrmGetActiveForm());
RowListDraw(&gList);
+10 -4
View File
@@ -58,16 +58,22 @@ Boolean ChannelSlotMuted(UInt8 slot)
}
void ChannelMuteToggleCurrent(void)
{
if (FrmGetActiveFormID() != ConvoForm || gAppConv.type != VM_CONV_CHANNEL) {
FrmCustomAlert(MuteAlert, "Open the channel you want to mute first.", "", "");
return;
}
ChannelMuteToggle(gAppConv.channel);
}
void ChannelMuteToggle(UInt8 slot)
{
VmChannel c;
Char msg[VM_NAME_SIZE + 48];
Int16 i;
if (FrmGetActiveFormID() != ConvoForm || gAppConv.type != VM_CONV_CHANNEL ||
!ChannelsFindSlot(gAppConv.channel, &c)) {
FrmCustomAlert(MuteAlert, "Open the channel you want to mute first.", "", "");
if (!ChannelsFindSlot(slot, &c))
return;
}
i = FindMute(&c);
if (i >= 0) {
MemMove(gMutes.ids[i], gMutes.ids[i + 1], (gMutes.count - i - 1) * VM_MUTE_ID_SIZE);
+2
View File
@@ -17,5 +17,7 @@ Boolean ChannelSlotMuted(UInt8 slot) VM_SECT3;
/* Options > Mute Channel: toggles the channel on screen and says which way it went. */
void ChannelMuteToggleCurrent(void) VM_SECT3;
/* The same for any channel (Home's tap-and-hold). */
void ChannelMuteToggle(UInt8 slot) VM_SECT3;
#endif
+1
View File
@@ -98,6 +98,7 @@
#define HomeScroll 1502
#define HomeContactsButton 1503
#define HomeNodeButton 1504
#define HomeActionList 1505 /* tap-and-hold popup (home_form.c) */
#define ConvoForm 1600
#define ConvoGadget 1601
+10 -4
View File
@@ -93,6 +93,15 @@ UInt8 ScopesForChannel(UInt8 slot, UInt8 key[VM_SCOPE_KEY_SIZE])
/* ---- Channel Scope dialog ---- */
void ChannelScopeChooseCurrent(void)
{
if (FrmGetActiveFormID() != ConvoForm || gAppConv.type != VM_CONV_CHANNEL) {
Error("Open the channel first.");
return;
}
ChannelScopeChoose(gAppConv.channel);
}
void ChannelScopeChoose(UInt8 slot)
{
VmChannel c;
FormType *form, *prev;
@@ -101,11 +110,8 @@ void ChannelScopeChooseCurrent(void)
UInt16 n, k;
ChanScope *cs;
if (FrmGetActiveFormID() != ConvoForm || gAppConv.type != VM_CONV_CHANNEL ||
!ChannelsFindSlot(gAppConv.channel, &c)) {
Error("Open the channel first.");
if (!ChannelsFindSlot(slot, &c))
return;
}
i = FindChannel(&c);
StrCopy(gItems[0], "Radio default");
StrCopy(gItems[1], "No scope");
+2
View File
@@ -23,6 +23,8 @@ UInt8 ScopesForChannel(UInt8 slot, UInt8 key[VM_SCOPE_KEY_SIZE]) VM_SECT4;
/* Options > Channel Scope: picks a scope for the channel on screen. */
void ChannelScopeChooseCurrent(void) VM_SECT4;
/* The same for any channel (Home's tap-and-hold). */
void ChannelScopeChoose(UInt8 slot) VM_SECT4;
/* Options > Flood Scopes: the list, and the radio's default. Done goes back to returnForm. */
void ScopesFormOpen(UInt16 returnForm) VM_SECT4;
+22 -2
View File
@@ -1,6 +1,9 @@
#include <PalmOS.h>
#include "rowlist.h"
#define RL_HOLD_TICKS (SysTicksPerSecond() / 2) /* pen still this long: a hold */
#define RL_HOLD_SLOP 3 /* pixels the pen may wander */
/* In the second code segment: see sections.h for the rules. */
static void GetBounds(const RowList *list, RectangleType *r) VM_SECT2;
static UInt16 MaxTop(const RowList *list) VM_SECT2;
@@ -31,6 +34,7 @@ void RowListInit(RowList *list, UInt16 gadgetId, UInt16 scrollId, Coord rowH,
list->top = 0;
list->draw = draw;
list->selectable = selectable;
list->hold = NULL;
list->ctx = ctx;
}
@@ -96,8 +100,9 @@ Boolean RowListHandleEvent(RowList *list, EventType *event, Int16 *tapped)
{
RectangleType area, rowR;
UInt16 row, visible;
Boolean penDown, inRow;
Boolean penDown, inRow, held = false;
Coord x, y;
UInt32 start;
switch (event->eType) {
case sclRepeatEvent:
@@ -131,14 +136,29 @@ Boolean RowListHandleEvent(RowList *list, EventType *event, Int16 *tapped)
area.extent.x, list->rowH);
WinInvertRectangle(&rowR, 0);
inRow = true;
start = TimGetTicks();
do {
EvtGetPen(&x, &y, &penDown);
if (held)
continue; /* waiting for the pen to lift */
if (list->hold && penDown &&
(x - event->screenX > RL_HOLD_SLOP || event->screenX - x > RL_HOLD_SLOP ||
y - event->screenY > RL_HOLD_SLOP || event->screenY - y > RL_HOLD_SLOP))
start = 0; /* moved: no longer a hold */
if (list->hold && start && inRow && TimGetTicks() - start >= RL_HOLD_TICKS) {
held = true;
WinInvertRectangle(&rowR, 0); /* unhighlight: the cue to lift */
continue;
}
if (RctPtInRectangle(x, y, &rowR) != inRow) {
inRow = !inRow;
WinInvertRectangle(&rowR, 0);
}
} while (penDown);
if (inRow) {
if (held) {
if (!list->hold(row, &rowR, list->ctx))
*tapped = (Int16)row;
} else if (inRow) {
WinInvertRectangle(&rowR, 0);
*tapped = (Int16)row;
}
+6 -1
View File
@@ -12,6 +12,8 @@
typedef void (*RowDrawFn)(UInt16 row, const RectangleType *bounds, void *ctx);
typedef Boolean (*RowSelectableFn)(UInt16 row, void *ctx);
/* A tap-and-hold on a selectable row (bounds: where it is). Returns false to treat it as a tap. */
typedef Boolean (*RowHoldFn)(UInt16 row, const RectangleType *bounds, void *ctx);
typedef struct {
UInt16 gadgetId;
@@ -21,6 +23,7 @@ typedef struct {
UInt16 top; /* first visible row */
RowDrawFn draw;
RowSelectableFn selectable; /* NULL = every row can be tapped */
RowHoldFn hold; /* NULL = holding is a tap; set after RowListInit */
void *ctx;
} RowList;
@@ -37,7 +40,9 @@ void RowListDraw(RowList *list) VM_SECT2;
/*
* Handles pen taps in the list, scroll-bar moves and the page buttons. Returns
* true if it used the event; a tap on a selectable row also sets *tapped to the
* row (and returns true), otherwise *tapped is left alone.
* row (and returns true), otherwise *tapped is left alone. With a hold
* callback, keeping the pen still on a row for RL_HOLD_TICKS unhighlights it
* (the cue to lift), and lifting the pen calls the callback.
*/
Boolean RowListHandleEvent(RowList *list, EventType *event, Int16 *tapped) VM_SECT2;
+148
View File
@@ -0,0 +1,148 @@
#!/usr/bin/env python3
"""Pixel art for the VisorMesh launcher icons.
Drawn at the device size -- 22x22 for the launcher's large icon, 15x9 for the
list view -- on the Visor Neo's 16 gray levels, one grid cell per screen pixel.
Nothing here is scaled down from the 512px artwork: at 22px a downscale turns
into gray mush, which is what tools/make_icon.sh --art exists to avoid.
python3 tools/gen_icon_art.py # write resources/icon/src/*.png
python3 tools/gen_icon_art.py --show # print the pixel grids
tools/make_icon.sh --art resources/icon/src/large22.png \
resources/icon/src/small15x9.png
Levels are 0..15 (n*17 = the 8-bit gray). Keep anything reversed out at 14 (238)
or below: white 255 is the app's transparency key (ICONFAMILY ... TRANSPARENT
255 255 255), so a 255 pixel punches a hole through the icon instead of drawing.
"""
import subprocess
import sys
from typing import Optional
OUT = "resources/icon/src"
TRANSPARENT: Optional[int] = None
Pixel = Optional[int]
Grid = list[list[Pixel]]
def level(n: int) -> int:
return n * 17 # 0..15 -> 8-bit gray
# ---- the art -------------------------------------------------------------
# Crown outline: per-column top row of the hair. Four chunky spikes ~5px apart
# with 4px notches -- any thinner and the teeth stop reading at 22px.
TOP22 = [6, 4, 2, 3, 4, 6, 4, 1, 3, 5, 6, 4, 2, 3, 5, 6, 4, 2, 4, 5, 6, 6]
TOP15 = [2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]
M = ["ff...ff", "fff.fff", "ff.f.ff", "ff.f.ff",
"ff...ff", "ff...ff", "ff...ff"]
C = [".ffff.", "ff..ff", "ff....", "ff....",
"ff....", "ff..ff", ".ffff."]
def grid(w, h) -> Grid:
return [[TRANSPARENT] * w for _ in range(h)]
def put(g: Grid, x: int, y: int, v: Pixel) -> None:
if 0 <= y < len(g) and 0 <= x < len(g[0]):
g[y][x] = v
def large() -> Grid:
"""22x22: hair crown, visor band, dark square, reversed MC."""
g = grid(22, 22)
# dark square (behind everything), corners knocked off to round them
for y in range(9, 22):
for x in range(2, 20):
put(g, x, y, 1)
for corner in ((2, 9), (19, 9), (2, 21), (19, 21)):
put(g, *corner, TRANSPARENT)
# hair: light fill, level 6 only where the crown meets the background
for x in range(22):
for y in range(TOP22[x], 8):
put(g, x, y, 12)
for x in range(22):
for y in range(TOP22[x], 8):
if g[y][x] != 12:
continue
above = g[y - 1][x] if y > 0 else TRANSPARENT
left = g[y][x - 1] if x > 0 else TRANSPARENT
right = g[y][x + 1] if x < 21 else TRANSPARENT
if TRANSPARENT in (above, left, right):
g[y][x] = 6
# band: highlight / face / shadow, rounded ends; sits in front of both
for x in range(22):
if x in (0, 21):
put(g, x, 9, 3)
else:
put(g, x, 8, 7)
put(g, x, 9, 5)
put(g, x, 10, 3)
# MC on 2px stems: the thinnest weight that survives 1:1
for i, row in enumerate(M):
for j, ch in enumerate(row):
if ch == "f":
put(g, 4 + j, 13 + i, 14)
for i, row in enumerate(C):
for j, ch in enumerate(row):
if ch == "f":
put(g, 12 + j, 13 + i, 14)
return g
def small() -> Grid:
"""15x9: silhouette only -- no lettering survives at this size."""
g = grid(15, 9)
for y in range(4, 9):
for x in range(1, 14):
put(g, x, y, 1)
for corner in ((1, 4), (13, 4), (1, 8), (13, 8)):
put(g, *corner, TRANSPARENT)
for x in range(15):
for y in range(TOP15[x], 3):
put(g, x, y, 12 if y > TOP15[x] else 6)
for x in range(15):
put(g, x, 3, 5)
return g
# ---- plumbing ------------------------------------------------------------
def write_pgm(g, path):
rows = "\n".join(" ".join("255" if v is TRANSPARENT else str(level(v))
for v in row) for row in g)
open(path, "w").write(f"P2\n{len(g[0])} {len(g)}\n255\n{rows}\n")
def write_png(g, path):
"""White pixels become transparent, so the padding is see-through, not a box."""
pgm = path + ".pgm"
write_pgm(g, pgm)
subprocess.run(["magick", pgm, "-transparent", "white", "-depth", "4", path],
check=True)
subprocess.run(["rm", "-f", pgm], check=True)
def show(g):
sym = "0123456789abcdef"
for row in g:
print("".join("." if v is TRANSPARENT else sym[v] for v in row))
if __name__ == "__main__":
if "--show" in sys.argv:
show(large())
print()
show(small())
else:
write_png(large(), f"{OUT}/large22.png")
write_png(small(), f"{OUT}/small15x9.png")
print(f"wrote {OUT}/large22.png ({len(large()[0])}x{len(large())}), "
f"{OUT}/small15x9.png ({len(small()[0])}x{len(small())})")