Open a Diary day's photos from a Show gallery row, with one caret

The day's photos under the entry now sit behind a dropdown row, as Habits'
inactive habits do: Show gallery with a chevron opens the sideways strip,
and the row then reads Hide gallery. It starts closed whenever a day opens.
Tapping a photo still puts it in the entry at the caret, as one undoable
edit; Enter on the focused row opens and closes it. The strings are in all
twelve languages, and the subset fonts carry their new characters.

Kryon is pinned at 88cc4594, whose TextArea paints the caret on the value
the frame paints. While typing at the end of a line, the frame that took a
key painted the caret at the next line's start, a second caret flickering
under the typed line.

The Diary UI test opens the gallery through the widget tree, finds it
closed when a day opens and again after leaving and returning, taps and
undoes a photo, and checks that typing above an empty line never draws ink
below the typed line.
This commit is contained in:
waozi committed 2026-10-17 19:32:24 -03:00
1 parent 141b08de1d
commit dc950730a0
24 files changed
+302 -90

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
- More apps lists your node's apps without an app update.
- Settings › About › Show beta apps lists apps in testing.
- Photos (beta): your photos by day on all devices, encrypted and kept once.
- Diary is Markdown with photos inline, kept in your photo library; each day shows its photos below.
- Diary is Markdown with photos inline, kept in your photo library; each day has a photo gallery.
### Changed
- Photos go to every node with photo upload on.
+1 -1
View File
@@ -5,7 +5,7 @@
### Changed
- An entry is Markdown. Headings, **bold**, *italic*, links, lists and quotes show styled, and their marks appear on the line you are editing.
- Photos sit inside the entry, where you add them, with text before or after them on their line. Each one is saved to your photo library, the one Photos shows, under the day it was taken, and the entry links to it there. Delete a photo's Markdown to take it out of the entry.
- Each day's photos scroll sideways under its entry. Tap one to put it in the entry at the cursor.
- Show gallery under each day's entry opens that day's photos, which scroll sideways. Tap one to put it in the entry at the cursor.
- Photos from older entries appear inside the entry, after its text.
## [1.1.12] - 2026-10-17
+50 -6
View File
@@ -32,6 +32,8 @@ using TextAlign;
using TextWrap;
using ButtonTone;
using ButtonEmphasis;
using IconPlacement;
using ContentAlignment;
host_api :: #system_library "host_api";
ReadDiaryUiHost :: () -> DiaryUiFrame #foreign host_api;
WriteDiaryUiHost :: (frame: DiaryUiFrame) #foreign host_api;
@@ -54,6 +56,9 @@ DIARY_PHOTO_ICON :: "S1.6rr:M3 5H21V19H3ZM3 16L8 11L13 16L16 13L21 18M17.5 8.5C1
DIARY_UNDO_ICON :: "S1.8rr:M9 14L4 9L9 4M4 9H14C17.31 9 20 11.69 20 15C20 18.31 17.31 21 14 21H11"
DIARY_REDO_ICON :: "S1.8rr:M15 14L20 9L15 4M20 9H10C6.69 9 4 11.69 4 15C4 18.31 6.69 21 10 21H13"
DIARY_SPELLING_ICON :: "S2rr:M3 14L7.5 3L12 14M4.8 10H10.2M12 17L15.5 20.5L21.5 13"
// The gallery row's chevron points down while the photos are hidden.
DIARY_SHOW_ICON :: "S1.8rr:M6 9L12 15L18 9"
DIARY_HIDE_ICON :: "S1.8rr:M6 15L12 9L18 15"
DiaryObserve :: () -> DiaryUiFrame {
return ReadDiaryUiHost()
@@ -134,11 +139,13 @@ DiaryEditorStyle :: (area: *TextAreaProps, text: string, editing: bool) {
area.blocks = editor_blocks[:editor_preview.photo_count]
}
// Under the entry, every photo of the day in one row that scrolls sideways:
// the media library's photos of that day, newest first, then the entry's
// other photos in its order. A tap puts a photo's embed at the caret.
// Under the entry, a Show gallery row opens every photo of the day in one
// row that scrolls sideways: the media library's photos of that day, newest
// first, then the entry's other photos in its order. A tap puts a photo's
// embed at the caret. The gallery starts closed whenever a day opens.
DIARY_DAY_PHOTOS :: 64
DIARY_TILE :: 88
DIARY_GALLERY_ROW :: 44
DiaryDayPhoto :: struct {
// What an embed of the photo links to.
@@ -190,12 +197,25 @@ DiaryDayPhotos :: (text: string) {
}
}
// The room the photos take under the entry, or 0 on a day without photos.
// The open gallery remembers its day, so another day opens with it closed.
DiaryDayKey :: () -> s32 {
return state.year * 10000 + state.month * 100 + state.day
}
DiaryGalleryOpen :: () -> bool {
return frame.photos_open_day != 0 && frame.photos_open_day == DiaryDayKey()
}
// The room the gallery takes under the entry, or 0 on a day without photos.
DiaryDayPhotosHeight :: () -> s32 {
if day_photo_count == 0 {
return 0
}
return Scale(DIARY_TILE) + Scale(12)
height := Scale(12) + Scale(DIARY_GALLERY_ROW)
if DiaryGalleryOpen() {
height += Scale(8) + Scale(DIARY_TILE)
}
return height
}
// Puts a photo's embed on its own line at the caret: one edit, saved at once.
@@ -210,6 +230,29 @@ DiaryInsertPhoto :: (destination: string, name: string) {
frame.save_at = frame.now
}
// The gallery row, a dropdown as Habits' inactive habits are, and under it
// the open gallery.
DiaryDayGallery :: (left: float32, top: float32, width: float32, editable: bool) {
open := DiaryGalleryOpen()
row := cast(float32)Scale(DIARY_GALLERY_ROW)
label := DiaryLocaleHost("diary_show_gallery")
if open {
label = DiaryLocaleHost("diary_hide_gallery")
}
if Button(frame.session, ButtonProps.{.id = 29017, .bounds = Rectangle.{left, top, width, row},
.label = label, .icon_shape = ifx open then DIARY_HIDE_ICON else DIARY_SHOW_ICON,
.icon_placement = cast(IconPlacement)IconPlacementTrailing,
.content_alignment = cast(ContentAlignment)ContentAlignmentStart,
.tone = cast(ButtonTone)ButtonToneNeutral,
.emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost}) != 0 {
frame.photos_open_day = ifx open then 0 else DiaryDayKey()
frame.photos_scroll = 0
}
if open {
DiaryDayPhotoStrip(left, top + row + cast(float32)Scale(8), width, editable)
}
}
DiaryDayPhotoStrip :: (left: float32, top: float32, width: float32, editable: bool) {
tile := cast(float32)Scale(DIARY_TILE)
gap := cast(float32)Scale(8)
@@ -319,6 +362,7 @@ DiaryAction :: ( id: s32, label: string, bounds: Rectangle, enabled: bool = true
pending = true
frame.scroll = 0
frame.photos_scroll = 0
frame.photos_open_day = 0
}
}
@@ -498,7 +542,7 @@ DiaryView :: (message: DiaryMessage, observed: DiaryUiFrame, today: Date) -> Dia
.text = DiaryLocaleHost(status), .font = frame.font})
}
if photos_room > 0 {
DiaryDayPhotoStrip(left, area.bounds.y + area.bounds.height +
DiaryDayGallery(left, area.bounds.y + area.bounds.height +
cast(float32)(notice_room + Scale(12)), width, editable && !frame.spelling_busy)
}
End(frame.session)
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,7 +4,7 @@ Added
- More apps lists your node's apps without an app update.
- Settings › About › Show beta apps lists apps in testing.
- Photos (beta): your photos by day on all devices, encrypted and kept once.
- Diary is Markdown with photos inline, kept in your photo library; each day shows its photos below.
- Diary is Markdown with photos inline, kept in your photo library; each day has a photo gallery.
Changed
---
- Photos go to every node with photo upload on.
+8
View File
@@ -3369,6 +3369,14 @@ Nahrávání fotek pro tento uzel se nepodařilo změnit.
[diary_photo_unavailable]
Tato fotka není v tomto zařízení. Zůstává v zařízení nebo uzlu, který fotky uchovává.
---
[diary_show_gallery]
Zobrazit galerii
---
[diary_hide_gallery]
Skrýt galerii
---
[device_link_title]
Připojit zařízení
---
+8
View File
@@ -3363,6 +3363,14 @@ Der Foto-Upload für diesen Knoten konnte nicht geändert werden.
[diary_photo_unavailable]
Dieses Foto ist nicht auf diesem Gerät. Es bleibt auf dem Gerät oder Knoten, der Fotos speichert.
---
[diary_show_gallery]
Galerie anzeigen
---
[diary_hide_gallery]
Galerie ausblenden
---
[device_link_title]
Gerät verbinden
---
+8
View File
@@ -3387,6 +3387,14 @@ Could not change photo upload for this node.
[diary_photo_unavailable]
This photo is not on this device. It stays on the device or node that keeps photos.
---
[diary_show_gallery]
Show gallery
---
[diary_hide_gallery]
Hide gallery
---
[device_link_title]
Connect a device
---
+8
View File
@@ -3363,6 +3363,14 @@ No se pudo cambiar la subida de fotos para este nodo.
[diary_photo_unavailable]
Esta foto no está en este dispositivo. Se guarda en el dispositivo o nodo que conserva las fotos.
---
[diary_show_gallery]
Mostrar galería
---
[diary_hide_gallery]
Ocultar galería
---
[device_link_title]
Conectar un dispositivo
---
+8
View File
@@ -3351,6 +3351,14 @@ Impossible de modifier l’envoi de photos pour ce nœud.
[diary_photo_unavailable]
Cette photo n’est pas sur cet appareil. Elle reste sur l’appareil ou le nœud qui garde les photos.
---
[diary_show_gallery]
Afficher la galerie
---
[diary_hide_gallery]
Masquer la galerie
---
[device_link_title]
Connecter un appareil
---
+8
View File
@@ -3352,6 +3352,14 @@ Tidak dapat mengubah unggahan foto untuk simpul ini.
[diary_photo_unavailable]
Foto ini tidak ada di perangkat ini. Foto tetap di perangkat atau simpul yang menyimpan foto.
---
[diary_show_gallery]
Tampilkan galeri
---
[diary_hide_gallery]
Sembunyikan galeri
---
[device_link_title]
Hubungkan perangkat
---
+8
View File
@@ -3352,6 +3352,14 @@ Impossibile modificare il caricamento delle foto per questo nodo.
[diary_photo_unavailable]
Questa foto non è su questo dispositivo. Resta sul dispositivo o sul nodo che conserva le foto.
---
[diary_show_gallery]
Mostra galleria
---
[diary_hide_gallery]
Nascondi galleria
---
[device_link_title]
Collega un dispositivo
---
+8
View File
@@ -3348,6 +3348,14 @@ Lumiに相談
[diary_photo_unavailable]
この写真はこのデバイスにありません。写真を保存しているデバイスまたはノードに残っています。
---
[diary_show_gallery]
ギャラリーを表示
---
[diary_hide_gallery]
ギャラリーを隠す
---
[device_link_title]
デバイスを接続
---
+8
View File
@@ -3358,6 +3358,14 @@ Lumi에게 요청
[diary_photo_unavailable]
이 사진은 이 기기에 없습니다. 사진을 보관하는 기기나 노드에 남아 있습니다.
---
[diary_show_gallery]
갤러리 보기
---
[diary_hide_gallery]
갤러리 숨기기
---
[device_link_title]
기기 연결
---
+8
View File
@@ -3361,6 +3361,14 @@ Não foi possível alterar o envio de fotos para este nó.
[diary_photo_unavailable]
Esta foto não está neste dispositivo. Ela fica no dispositivo ou nó que guarda as fotos.
---
[diary_show_gallery]
Mostrar galeria
---
[diary_hide_gallery]
Ocultar galeria
---
[device_link_title]
Conectar um dispositivo
---
+8
View File
@@ -3357,6 +3357,14 @@ Lumi остаётся без сети, пока вы не примете её у
[diary_photo_unavailable]
Этого фото нет на этом устройстве. Оно хранится на устройстве или узле, где сохраняются фото.
---
[diary_show_gallery]
Показать галерею
---
[diary_hide_gallery]
Скрыть галерею
---
[device_link_title]
Подключить устройство
---
+8
View File
@@ -3363,6 +3363,14 @@ Daochi 节点
[diary_photo_unavailable]
这张照片不在此设备上。它保存在存放照片的设备或节点上。
---
[diary_show_gallery]
显示图库
---
[diary_hide_gallery]
隐藏图库
---
[device_link_title]
连接设备
---
+72 -58
View File
@@ -29,7 +29,7 @@
using HostValueKind;
WidgetDiaryUiFrameCodec :: struct {
fields: [28]HostField
fields: [29]HostField
session: WidgetSessionCodec
input: WidgetTextAreaInputCodec
}
@@ -39,7 +39,7 @@ WidgetEncodeDiaryUiFrame :: (data: DiaryUiFrame, codec: *WidgetDiaryUiFrameCodec
value.kind = cast(s32)HostRecord
value.type_name = HostTextData("DiaryUiFrame")
value.fields = *codec.fields[0]
value.field_count = 28
value.field_count = 29
codec.fields[0].name = HostTextData("session")
codec.fields[0].value = WidgetEncodeSession(data.session, *codec.session)
codec.fields[1].name = HostTextData("width")
@@ -68,34 +68,36 @@ WidgetEncodeDiaryUiFrame :: (data: DiaryUiFrame, codec: *WidgetDiaryUiFrameCodec
codec.fields[12].value = HostScalar("s32", cast(s64)data.page_scroll)
codec.fields[13].name = HostTextData("photos_scroll")
codec.fields[13].value = HostScalar("s32", cast(s64)data.photos_scroll)
codec.fields[14].name = HostTextData("save_at")
codec.fields[14].value = HostValue.{.kind = cast(s32)HostReal, .type_name = HostTextData("float64"), .real = cast(float64)data.save_at}
codec.fields[15].name = HostTextData("photo_error")
codec.fields[15].value = HostScalar("bool", ifx data.photo_error then 1 else 0)
codec.fields[16].name = HostTextData("photo_requested")
codec.fields[16].value = HostScalar("bool", ifx data.photo_requested then 1 else 0)
codec.fields[17].name = HostTextData("link_color")
codec.fields[17].value = HostScalar("u32", cast(s64)data.link_color)
codec.fields[18].name = HostTextData("muted_color")
codec.fields[18].value = HostScalar("u32", cast(s64)data.muted_color)
codec.fields[19].name = HostTextData("clipboard_write")
codec.fields[19].value = HostScalar("bool", ifx data.clipboard_write then 1 else 0)
codec.fields[20].name = HostTextData("clipboard_text")
codec.fields[20].value = HostValue.{.kind = cast(s32)HostString, .type_name = HostTextData("string"), .data = HostTextData(data.clipboard_text), .length = cast(usize)data.clipboard_text.count}
codec.fields[21].name = HostTextData("can_undo")
codec.fields[21].value = HostScalar("bool", ifx data.can_undo then 1 else 0)
codec.fields[22].name = HostTextData("can_redo")
codec.fields[22].value = HostScalar("bool", ifx data.can_redo then 1 else 0)
codec.fields[23].name = HostTextData("undo_requested")
codec.fields[23].value = HostScalar("bool", ifx data.undo_requested then 1 else 0)
codec.fields[24].name = HostTextData("redo_requested")
codec.fields[24].value = HostScalar("bool", ifx data.redo_requested then 1 else 0)
codec.fields[25].name = HostTextData("spelling_requested")
codec.fields[25].value = HostScalar("bool", ifx data.spelling_requested then 1 else 0)
codec.fields[26].name = HostTextData("spelling_busy")
codec.fields[26].value = HostScalar("bool", ifx data.spelling_busy then 1 else 0)
codec.fields[27].name = HostTextData("spelling_notice")
codec.fields[27].value = HostValue.{.kind = cast(s32)HostString, .type_name = HostTextData("string"), .data = HostTextData(data.spelling_notice), .length = cast(usize)data.spelling_notice.count}
codec.fields[14].name = HostTextData("photos_open_day")
codec.fields[14].value = HostScalar("s32", cast(s64)data.photos_open_day)
codec.fields[15].name = HostTextData("save_at")
codec.fields[15].value = HostValue.{.kind = cast(s32)HostReal, .type_name = HostTextData("float64"), .real = cast(float64)data.save_at}
codec.fields[16].name = HostTextData("photo_error")
codec.fields[16].value = HostScalar("bool", ifx data.photo_error then 1 else 0)
codec.fields[17].name = HostTextData("photo_requested")
codec.fields[17].value = HostScalar("bool", ifx data.photo_requested then 1 else 0)
codec.fields[18].name = HostTextData("link_color")
codec.fields[18].value = HostScalar("u32", cast(s64)data.link_color)
codec.fields[19].name = HostTextData("muted_color")
codec.fields[19].value = HostScalar("u32", cast(s64)data.muted_color)
codec.fields[20].name = HostTextData("clipboard_write")
codec.fields[20].value = HostScalar("bool", ifx data.clipboard_write then 1 else 0)
codec.fields[21].name = HostTextData("clipboard_text")
codec.fields[21].value = HostValue.{.kind = cast(s32)HostString, .type_name = HostTextData("string"), .data = HostTextData(data.clipboard_text), .length = cast(usize)data.clipboard_text.count}
codec.fields[22].name = HostTextData("can_undo")
codec.fields[22].value = HostScalar("bool", ifx data.can_undo then 1 else 0)
codec.fields[23].name = HostTextData("can_redo")
codec.fields[23].value = HostScalar("bool", ifx data.can_redo then 1 else 0)
codec.fields[24].name = HostTextData("undo_requested")
codec.fields[24].value = HostScalar("bool", ifx data.undo_requested then 1 else 0)
codec.fields[25].name = HostTextData("redo_requested")
codec.fields[25].value = HostScalar("bool", ifx data.redo_requested then 1 else 0)
codec.fields[26].name = HostTextData("spelling_requested")
codec.fields[26].value = HostScalar("bool", ifx data.spelling_requested then 1 else 0)
codec.fields[27].name = HostTextData("spelling_busy")
codec.fields[27].value = HostScalar("bool", ifx data.spelling_busy then 1 else 0)
codec.fields[28].name = HostTextData("spelling_notice")
codec.fields[28].value = HostValue.{.kind = cast(s32)HostString, .type_name = HostTextData("string"), .data = HostTextData(data.spelling_notice), .length = cast(usize)data.spelling_notice.count}
return value
}
@@ -186,85 +188,91 @@ WidgetDecodeDiaryUiFrame :: (value: HostValue, codec: *WidgetDiaryUiFrameCodec)
}
}
{
field_at := HostFieldAt(value, 14, "save_at")
field_at := HostFieldAt(value, 14, "photos_open_day")
if field_at >= 0 {
data.photos_open_day = cast(s32)value.fields[field_at].value.integer
}
}
{
field_at := HostFieldAt(value, 15, "save_at")
if field_at >= 0 {
data.save_at = cast(float64)value.fields[field_at].value.real
}
}
{
field_at := HostFieldAt(value, 15, "photo_error")
field_at := HostFieldAt(value, 16, "photo_error")
if field_at >= 0 {
data.photo_error = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 16, "photo_requested")
field_at := HostFieldAt(value, 17, "photo_requested")
if field_at >= 0 {
data.photo_requested = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 17, "link_color")
field_at := HostFieldAt(value, 18, "link_color")
if field_at >= 0 {
data.link_color = cast(u32)value.fields[field_at].value.bits
}
}
{
field_at := HostFieldAt(value, 18, "muted_color")
field_at := HostFieldAt(value, 19, "muted_color")
if field_at >= 0 {
data.muted_color = cast(u32)value.fields[field_at].value.bits
}
}
{
field_at := HostFieldAt(value, 19, "clipboard_write")
field_at := HostFieldAt(value, 20, "clipboard_write")
if field_at >= 0 {
data.clipboard_write = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 20, "clipboard_text")
field_at := HostFieldAt(value, 21, "clipboard_text")
if field_at >= 0 {
data.clipboard_text = TextFromBytes(BytesFromPointer(value.fields[field_at].value.data, cast(u64)value.fields[field_at].value.length))
}
}
{
field_at := HostFieldAt(value, 21, "can_undo")
field_at := HostFieldAt(value, 22, "can_undo")
if field_at >= 0 {
data.can_undo = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 22, "can_redo")
field_at := HostFieldAt(value, 23, "can_redo")
if field_at >= 0 {
data.can_redo = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 23, "undo_requested")
field_at := HostFieldAt(value, 24, "undo_requested")
if field_at >= 0 {
data.undo_requested = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 24, "redo_requested")
field_at := HostFieldAt(value, 25, "redo_requested")
if field_at >= 0 {
data.redo_requested = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 25, "spelling_requested")
field_at := HostFieldAt(value, 26, "spelling_requested")
if field_at >= 0 {
data.spelling_requested = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 26, "spelling_busy")
field_at := HostFieldAt(value, 27, "spelling_busy")
if field_at >= 0 {
data.spelling_busy = value.fields[field_at].value.integer != 0
}
}
{
field_at := HostFieldAt(value, 27, "spelling_notice")
field_at := HostFieldAt(value, 28, "spelling_notice")
if field_at >= 0 {
data.spelling_notice = TextFromBytes(BytesFromPointer(value.fields[field_at].value.data, cast(u64)value.fields[field_at].value.length))
}
@@ -361,85 +369,91 @@ WidgetValidDiaryUiFrame :: (value: HostValue) -> bool {
}
}
{
field_at := HostFieldAt(value, 14, "save_at")
field_at := HostFieldAt(value, 14, "photos_open_day")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "s32", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 15, "save_at")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "float64", cast(s32)HostReal) { return false }
}
}
{
field_at := HostFieldAt(value, 15, "photo_error")
field_at := HostFieldAt(value, 16, "photo_error")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 16, "photo_requested")
field_at := HostFieldAt(value, 17, "photo_requested")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 17, "link_color")
field_at := HostFieldAt(value, 18, "link_color")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "u32", cast(s32)HostUnsigned) { return false }
}
}
{
field_at := HostFieldAt(value, 18, "muted_color")
field_at := HostFieldAt(value, 19, "muted_color")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "u32", cast(s32)HostUnsigned) { return false }
}
}
{
field_at := HostFieldAt(value, 19, "clipboard_write")
field_at := HostFieldAt(value, 20, "clipboard_write")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 20, "clipboard_text")
field_at := HostFieldAt(value, 21, "clipboard_text")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "string", cast(s32)HostString) { return false }
}
}
{
field_at := HostFieldAt(value, 21, "can_undo")
field_at := HostFieldAt(value, 22, "can_undo")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 22, "can_redo")
field_at := HostFieldAt(value, 23, "can_redo")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 23, "undo_requested")
field_at := HostFieldAt(value, 24, "undo_requested")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 24, "redo_requested")
field_at := HostFieldAt(value, 25, "redo_requested")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 25, "spelling_requested")
field_at := HostFieldAt(value, 26, "spelling_requested")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 26, "spelling_busy")
field_at := HostFieldAt(value, 27, "spelling_busy")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "bool", cast(s32)HostInteger) { return false }
}
}
{
field_at := HostFieldAt(value, 27, "spelling_notice")
field_at := HostFieldAt(value, 28, "spelling_notice")
if field_at >= 0 {
if !HostScalarValid(value.fields[field_at].value, "string", cast(s32)HostString) { return false }
}
+3 -1
View File
@@ -16,8 +16,10 @@ DiaryUiFrame :: struct {
scroll: s32
calendar_scroll: s32
page_scroll: s32
// How far the day's photos under the entry are scrolled sideways.
// How far the day's photos under the entry are scrolled sideways, and
// the day whose gallery is open (year * 10000 + month * 100 + day), or 0.
photos_scroll: s32
photos_open_day: s32
save_at: float64
photo_error: bool
photo_requested: bool
+1
View File
@@ -269,6 +269,7 @@ DiaryUiCall :: (context: *void, module: *u8, function: *u8,
diary_ui.calendar_scroll = observed.calendar_scroll
diary_ui.page_scroll = observed.page_scroll
diary_ui.photos_scroll = observed.photos_scroll
diary_ui.photos_open_day = observed.photos_open_day
diary_ui.save_at = observed.save_at
diary_photo_requested = observed.photo_requested
diary_undo_requested = observed.undo_requested
+65 -10
View File
@@ -12,6 +12,8 @@ import time
from PIL import Image
from ui_driver import UiDriver
ROOT = Path(__file__).resolve().parent.parent
OUTPUT = ROOT / "build/cells-diary-test"
OUTPUT.mkdir(parents=True, exist_ok=True)
@@ -20,6 +22,8 @@ ENV = os.environ.copy()
ENV.update(APP_NO_TRAY="1", YUE_DESKTOP_RECOVERY="0")
ENV.pop("INBE_DIARY_IMPORT", None)
ENV.pop("HARMONY_DATA_ROOT", None)
# Widgets are found and keys typed through Kryon's test driver.
driver = UiDriver(OUTPUT / "driver")
def command(*args):
@@ -58,22 +62,39 @@ def purple_pixels(path):
abs(color[2] - 176) < 24)
def ink_bottom(path, box):
"""The lowest row in box that differs from the box's background."""
left, top, right, bottom = box
with Image.open(path) as image:
rgb = image.convert("RGB")
pixels = rgb.load()
background = pixels[right - 2, bottom - 2]
lowest = -1
for y in range(top, bottom):
for x in range(left, right):
if sum(abs(a - b) for a, b in zip(pixels[x, y], background)) > 90:
lowest = y
break
return lowest
def wait_for_text(entry, matches, message):
deadline = time.monotonic() + 10
while not matches(json.loads(entry.read_text())["text"]):
assert time.monotonic() < deadline, message
assert time.monotonic() < deadline, f"{message}: {json.loads(entry.read_text())['text']!r}"
time.sleep(0.1)
@contextlib.contextmanager
def application(profile, label, import_source=None, size=(900, 720)):
with (OUTPUT / f"{label}.log").open("w") as log:
environment = ENV | {"APP_DATA_ROOT": str(profile)}
environment = ENV | {"APP_DATA_ROOT": str(profile)} | driver.environment()
if import_source is not None:
environment["INBE_DIARY_IMPORT"] = str(import_source)
app = subprocess.Popen([sys.argv[1], "--bundle", str(ROOT / "build/cells/diary.zib")],
cwd=ROOT, env=environment,
stdout=log, stderr=subprocess.STDOUT)
driver.attach(app)
try:
deadline = time.monotonic() + 20
while time.monotonic() < deadline:
@@ -168,11 +189,29 @@ with tempfile.TemporaryDirectory(prefix="inbe-diary-ui-") as temporary:
"The photo was not drawn while its line was edited"
# Away from that line its Markdown hides and the photo stays under
# the text.
command("xdotool", "key", "--clearmodifiers", "ctrl+End")
driver.key("down")
time.sleep(0.5)
capture(window, "text-beside-photo")
assert len(purple_pixels(OUTPUT / "text-beside-photo.png")) > 20000, \
"The photo was not drawn under the text typed after it"
# While typing at the end of a line with an empty line under it, one
# caret shows, on the typed line: the frame that takes a key never
# draws a second one at the start of the line below.
driver.key("enter")
driver.key("up")
area = driver.find(role="text_area")[0]
assert area["value"][area["cursor"] - 1:area["cursor"] + 1] == "\n\n", "The caret is not on the empty line"
box = (area["x"] + 6, area["y"] + 6, area["x"] + area["width"] - 6, area["y"] + area["height"] - 6)
typed_rows = []
for index, letter in enumerate("Typed"):
driver.type(letter)
capture(window, f"typing-{index}")
typed_rows.append(ink_bottom(OUTPUT / f"typing-{index}.png", box))
wait_for_text(entry, lambda text: text.endswith(") right after\nTyped\n"), "Typing under the photo was not saved")
time.sleep(0.5)
capture(window, "typed")
settled = ink_bottom(OUTPUT / "typed.png", box)
assert max(typed_rows) <= settled + 2, f"A second caret showed under the typed line: {typed_rows} > {settled}"
saved = json.loads(entry.read_text())
tap(window, 288, 86) # Calendar.
capture(window, "calendar")
@@ -245,13 +284,15 @@ with tempfile.TemporaryDirectory(prefix="inbe-diary-ui-") as temporary:
time.sleep(0.5)
capture(window, f"sage-{dark}-inline")
red = red_pixels(OUTPUT / f"sage-{dark}-inline.png")
# The photo inside the entry is far larger than its tile below.
assert len(red) > 20000, "Photo not drawn inside the entry at phone scale"
bottom = max(y for x, y in red)
tile = [(x, y) for x, y in red if y > bottom - 60]
assert 1000 < len(tile) < 20000, "The day's photos are not shown under the entry"
assert phone_entry.read_text() == stored, "Viewing the day rewrote its entry"
tap(window, sum(x for x, y in tile) // len(tile), sum(y for x, y in tile) // len(tile))
# The day's gallery opens from its row, closed when the day opens.
driver.wait(label="Show gallery")
assert not driver.find(label="A photo", role="image"), "The gallery was open when the day opened"
driver.press(label="Show gallery")
driver.wait(label="Hide gallery")
driver.wait(label="A photo", role="image")
driver.press(label="A photo")
deadline = time.monotonic() + 5
while json.loads(phone_entry.read_text())["text"].count("](diary:photo-local.bin)") != 2:
assert time.monotonic() < deadline, "A tapped photo was not embedded in the entry"
@@ -259,9 +300,23 @@ with tempfile.TemporaryDirectory(prefix="inbe-diary-ui-") as temporary:
saved_photo = json.loads(phone_entry.read_text())
assert saved_photo["text"].startswith(original["text"] + "\n\n![A photo](diary:photo-local.bin)")
assert [row["file"] for row in saved_photo["photos"]] == files
# Undo takes the tapped photo out again; redo puts it back.
driver.press(label="Undo")
wait_for_text(phone_entry, lambda text: text.count("](diary:photo-local.bin)") == 1, "Undo kept the tapped photo")
driver.press(label="Redo")
wait_for_text(phone_entry, lambda text: text == saved_photo["text"], "Redo did not restore the tapped photo")
# Another day opens with its gallery closed, and so does this one
# when it opens again.
driver.press(label="Hide gallery")
driver.wait(label="Show gallery")
driver.press(label="Show gallery")
driver.press(label="‹")
driver.press(label="›")
driver.wait(label="Show gallery")
assert not driver.find(label="A photo", role="image"), "The gallery stayed open on another day"
with application(phone, f"sage-{dark}-restart", size=(390, 844)):
assert json.loads(phone_entry.read_text()) == saved_photo
assert (phone_entry.parent / "photo-local.bin").read_bytes() == photo_bytes
print("Standalone Diary: native editing, delayed save, time insertion, undo, redo, spelling without an account, a picked photo in the photo library and inside the entry, text typed right after the photo, calendar, restart and day navigation passed")
print("Standalone Diary: native editing, delayed save, time insertion, undo, redo, spelling without an account, a picked photo in the photo library and inside the entry, text typed right after the photo, one caret while typing, calendar, restart and day navigation passed")
print("Harmony import: text and photo bytes copied, originals preserved, symlinks skipped and existing entries retained")
print("Diary photos: older photo lists inside the entry, a missing file, no writes on viewing, a tapped day photo embedded, and restart at phone width in light/dark sage passed")
print("Diary photos: older photo lists inside the entry, a missing file, no writes on viewing, the gallery dropdown closed on every day it opens, a tapped photo embedded and undone, and restart at phone width in light/dark sage passed")
+12 -12
View File
@@ -53,9 +53,17 @@
"source": true,
"url": "https://github.com/raysan5/raylib.git"
},
{
"commit": "88cc4594167aeae416095a26972f5be221c08368",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "p85aa0152d609fff1",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "41538659afbbda300915ef009b55c18f6de159b8",
"dependencies": {"kryon": "pda0e4f7cad5a1c2a"},
"dependencies": {"kryon": "p85aa0152d609fff1"},
"id": "p9504fb8e5fabefc6",
"name": "Kss",
"ref": "master",
@@ -71,7 +79,7 @@
},
{
"commit": "2ee29338c9b93fb4f4a56a49c7be09e9d2c2418f",
"dependencies": {"kryon": "pda0e4f7cad5a1c2a"},
"dependencies": {"kryon": "p85aa0152d609fff1"},
"id": "pa5dd7b8b83307b18",
"name": "plot",
"ref": "master",
@@ -79,7 +87,7 @@
},
{
"commit": "7aa01465ac3f988e0404f3c6dc244bf4b009f253",
"dependencies": {"kryon": "pda0e4f7cad5a1c2a"},
"dependencies": {"kryon": "p85aa0152d609fff1"},
"id": "paa08e1730a25bda0",
"name": "Game2D",
"ref": "master",
@@ -94,14 +102,6 @@
"source": true,
"url": "https://github.com/curl/curl.git"
},
{
"commit": "2b8304299e5e69a8939e6de12476ac28dba24443",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "pda0e4f7cad5a1c2a",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "51fa84aedaa6ae4f6734e0fcca9bfc35a184d297",
"dependencies": {},
@@ -121,7 +121,7 @@
}
],
"root": {
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "p96e1f539ccb91af5", "game2d": "paa08e1730a25bda0", "kryon": "pda0e4f7cad5a1c2a", "kss": "p9504fb8e5fabefc6", "liboqs": "pfb3df7cb222b1bdc", "mingcute": "p56788fa3dab3e73a", "monocypher": "p2ff634c7b007140d", "oqs": "p55635fc8976895a9", "plot": "pa5dd7b8b83307b18", "qrcode": "pf0ce9cea355c9228", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "p96e1f539ccb91af5", "game2d": "paa08e1730a25bda0", "kryon": "p85aa0152d609fff1", "kss": "p9504fb8e5fabefc6", "liboqs": "pfb3df7cb222b1bdc", "mingcute": "p56788fa3dab3e73a", "monocypher": "p2ff634c7b007140d", "oqs": "p55635fc8976895a9", "plot": "pa5dd7b8b83307b18", "qrcode": "pf0ce9cea355c9228", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
"name": "Inbe"
},
"toolchain": {