Reach the window, input, clock and log through host modules
Breeze's platform code no longer calls raylib by name. The window, frame loop, input, clock, log, window state, icons, audio, radio decoding, text input, assets and storage file access go through Breeze host modules (host_clock, host_input, host_window, host_window_state, host_frame, app_trace, icon_png) with a raylib branch for today's builds and a branch for Kryon's SDL2 and Cairo desktop host, selected at compile time by DESKTOP_HOST. The shipped builds still use raylib; the Linux build moves once Kryon has the remaining desktop pieces. The plans map what Windows, the web and Android still need. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
017d3565d3
commit
307e3c05ac
62 files changed
+1956
-992
No files matched your search
@@ -1,3 +1,4 @@
|
||||
#import, file "../../src/platform/host_clock.zi";
|
||||
#import, file "../../src/apps/practice_ui_types.zi";
|
||||
#import, file "../../src/apps/practice_types.zi";
|
||||
#import, file "../../src/practices/practice_movement_host.zi";
|
||||
@@ -41,7 +42,6 @@ Layout :: #import "kryon/layout";
|
||||
#import "kryon/tree"
|
||||
|
||||
c :: #system_library "c";
|
||||
GetFrameTime :: () -> float32 #foreign c;
|
||||
practice_background_start :: (app: *InnerBreeze, id: s32) #foreign c;
|
||||
practice_active_background_stop :: (app: *InnerBreeze) #foreign c;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c;
|
||||
@@ -344,7 +344,7 @@ AstralDraw :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
|
||||
app.session_paused = ifx app.session_paused != 0 then 0 else 1
|
||||
}
|
||||
if app.backgrounded == 0 {
|
||||
total := cast(float64)GetFrameTime() * 1000.0 + astral_frame_carry
|
||||
total := cast(float64)HostFrameSeconds() * 1000.0 + astral_frame_carry
|
||||
milliseconds := cast(s32)total
|
||||
astral_frame_carry = total - cast(float64)milliseconds
|
||||
AstralAdvanceElapsed(app, milliseconds)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Practice component probes live with the Practices screen implementation.
|
||||
WindowRuntime :: #import "kryon/window_runtime";
|
||||
#import, file "../../src/platform/host_window.zi";
|
||||
#import, file "../../src/platform/host_frame.zi";
|
||||
#import, file "../../src/platform/app_host.zi";
|
||||
#import, file "../../src/app/app_types.zi";
|
||||
#import, file "../../src/app/exercise_types.zi";
|
||||
@@ -16,11 +17,16 @@ Layout :: #import "kryon/layout";
|
||||
#import "tree_draw"
|
||||
#import "geometry"
|
||||
#import "drawing_props"
|
||||
#import "raylib_trace"
|
||||
#import, file "../../src/platform/app_trace.zi";
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
using CanvasHost :: #import "canvas_host";
|
||||
} else {
|
||||
#import "kryon/Raylib"
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Cairo :: #import "Cairo";
|
||||
} else {
|
||||
WindowRuntime :: #import "kryon/window_runtime";
|
||||
#import "kryon/Raylib"
|
||||
}
|
||||
}
|
||||
using ExerciseType;
|
||||
using AppMainTab;
|
||||
@@ -28,6 +34,9 @@ using NavigationPlacement;
|
||||
LOG_INFO :: 3
|
||||
|
||||
practice_probe_frame_count: s32;
|
||||
practice_probe_app: *InnerBreeze;
|
||||
practice_probe_mode: s32;
|
||||
practice_probe_size: WindowSize;
|
||||
|
||||
PracticeProbeMode :: (argc: s32, argv: **u8) -> s32 {
|
||||
if argc < 2 {
|
||||
@@ -49,10 +58,57 @@ PracticeProbeMode :: (argc: s32, argv: **u8) -> s32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// One probe frame's widgets: the component the mode names.
|
||||
PracticeProbeDraw :: (app: *InnerBreeze, mode: s32, size: WindowSize, first_probe_frame: bool) {
|
||||
FrameTextReset(*app.ui.frame_text)
|
||||
bounds := Rectangle.{0.0, 0.0,
|
||||
cast(float32)size.width, cast(float32)size.height}
|
||||
if cast(s32)BeginFrame(app.ui.session, Layout.KeyHash("practice/probe"),
|
||||
bounds) == 0 {
|
||||
if mode == 4 {
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: before navigation bar")
|
||||
}
|
||||
unused app_draw_bottom_nav(app)
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: after navigation bar")
|
||||
}
|
||||
} else if mode == 1 {
|
||||
practice_draw_card_banner(
|
||||
"assets/practices/meditation/banner-dark.png",
|
||||
Rectangle.{0.0, 0.0,
|
||||
cast(float32)size.width, 360.0})
|
||||
} else if mode == 2 {
|
||||
unused practice_screen_draw_home_hero(app)
|
||||
} else {
|
||||
practice_screen_draw_home(app)
|
||||
}
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: before EndFrame")
|
||||
}
|
||||
unused EndFrame(app.ui.session)
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: after EndFrame")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
// The desktop host polls, rasterizes and presents around this.
|
||||
#program_export
|
||||
practice_probe_frame :: (argument: *void) {
|
||||
unused argument
|
||||
first_probe_frame := practice_probe_frame_count == 0
|
||||
practice_probe_frame_count += 1
|
||||
PracticeProbeDraw(practice_probe_app, practice_probe_mode, practice_probe_size,
|
||||
first_probe_frame)
|
||||
}
|
||||
}
|
||||
|
||||
RunPracticeProbe :: (app: *InnerBreeze, mode: s32, size: WindowSize) -> s32 {
|
||||
app.ui.session = SessionOpen()
|
||||
if !SessionValid(app.ui.session) {
|
||||
WindowRuntime.CloseNativeWindow()
|
||||
HostCloseWindow()
|
||||
return 1
|
||||
}
|
||||
app.ui.view_width = size.width
|
||||
@@ -68,48 +124,33 @@ RunPracticeProbe :: (app: *InnerBreeze, mode: s32, size: WindowSize) -> s32 {
|
||||
app_reset_bottom_nav_routes(app)
|
||||
}
|
||||
SetCurrentApp(app)
|
||||
while !WindowRuntime.WindowClosing() {
|
||||
first_probe_frame := practice_probe_frame_count == 0
|
||||
practice_probe_frame_count += 1
|
||||
FrameTextReset(*app.ui.frame_text)
|
||||
WindowRuntime.BeginWindowFrame()
|
||||
WindowRuntime.ClearWindowFrame(Color.{30, 40, 50, 255})
|
||||
bounds := Rectangle.{0.0, 0.0,
|
||||
cast(float32)size.width, cast(float32)size.height}
|
||||
if cast(s32)BeginFrame(app.ui.session, Layout.KeyHash("practice/probe"),
|
||||
bounds) == 0 {
|
||||
if mode == 4 {
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: before navigation bar")
|
||||
}
|
||||
unused app_draw_bottom_nav(app)
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: after navigation bar")
|
||||
}
|
||||
} else if mode == 1 {
|
||||
practice_draw_card_banner(
|
||||
"assets/practices/meditation/banner-dark.png",
|
||||
Rectangle.{0.0, 0.0,
|
||||
cast(float32)size.width, 360.0})
|
||||
} else if mode == 2 {
|
||||
unused practice_screen_draw_home_hero(app)
|
||||
} else {
|
||||
practice_screen_draw_home(app)
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
practice_probe_app = app
|
||||
practice_probe_mode = mode
|
||||
practice_probe_size = size
|
||||
while !HostWindowClosing() && !HostTakeCloseRequest() {
|
||||
first_probe_frame := practice_probe_frame_count == 0
|
||||
if !HostRunFrame(practice_probe_frame, null) {
|
||||
break
|
||||
}
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: before EndFrame")
|
||||
}
|
||||
unused EndFrame(app.ui.session)
|
||||
if first_probe_frame {
|
||||
TraceLog(LOG_INFO, "APP PROBE: after EndFrame")
|
||||
if mode == 4 && first_probe_frame && Cairo.CaptureRequested() {
|
||||
unused Cairo.CaptureConfigured()
|
||||
}
|
||||
}
|
||||
WindowRuntime.EndWindowFrame()
|
||||
if mode == 4 && first_probe_frame && CaptureRequested() {
|
||||
unused CaptureConfigured()
|
||||
} else {
|
||||
while !WindowRuntime.WindowClosing() {
|
||||
first_probe_frame := practice_probe_frame_count == 0
|
||||
practice_probe_frame_count += 1
|
||||
WindowRuntime.BeginWindowFrame()
|
||||
WindowRuntime.ClearWindowFrame(Color.{30, 40, 50, 255})
|
||||
PracticeProbeDraw(app, mode, size, first_probe_frame)
|
||||
WindowRuntime.EndWindowFrame()
|
||||
if mode == 4 && first_probe_frame && CaptureRequested() {
|
||||
unused CaptureConfigured()
|
||||
}
|
||||
}
|
||||
}
|
||||
SetCurrentApp(null)
|
||||
WindowRuntime.CloseNativeWindow()
|
||||
HostCloseWindow()
|
||||
return 0
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../../src/platform/host_clock.zi";
|
||||
#import, file "../../src/apps/practice_ui_types.zi";
|
||||
#import, file "../../src/apps/practice_types.zi";
|
||||
#import, file "../../src/practices/practice_movement_host.zi";
|
||||
@@ -48,7 +49,6 @@ Text :: #import "kryon/text";
|
||||
#import "kryon/tree"
|
||||
|
||||
c :: #system_library "c";
|
||||
GetFrameTime :: () -> float32 #foreign c;
|
||||
practice_background_start :: (app: *InnerBreeze, id: s32) #foreign c;
|
||||
practice_active_background_stop :: (app: *InnerBreeze) #foreign c;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c;
|
||||
@@ -333,7 +333,7 @@ WorkoutDraw :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
|
||||
app.session_paused = ifx app.session_paused != 0 then 0 else 1
|
||||
}
|
||||
if app.backgrounded == 0 {
|
||||
total := cast(float64)GetFrameTime() * 1000.0 + workout_frame_carry
|
||||
total := cast(float64)HostFrameSeconds() * 1000.0 + workout_frame_carry
|
||||
milliseconds := cast(s32)total
|
||||
workout_frame_carry = total - cast(float64)milliseconds
|
||||
WorkoutAdvanceElapsed(app, milliseconds)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Sample the host's real audible playback state; connection time is excluded.
|
||||
#import, file "../../src/platform/host_clock.zi";
|
||||
#import "std/c_string"
|
||||
#import "std/text_buffer"
|
||||
#import "std/vec"
|
||||
@@ -8,7 +9,6 @@
|
||||
#import, file "../../src/apps/package_files.zi";
|
||||
|
||||
c :: #system_library "c";
|
||||
AchievementRadioTime :: () -> float64 #foreign c "GetTime";
|
||||
AchievementRadioOwnerFn :: #type (owner: s32) -> bool;
|
||||
achievement_radio_owner: AchievementRadioOwnerFn;
|
||||
achievement_radio_account: [65]u8;
|
||||
@@ -67,5 +67,5 @@ AchievementRadioSample :: (owner: s32, station: string, playing: bool, volume: s
|
||||
|
||||
AchievementRadioTick :: (owner: s32, station: string, playing: bool, volume: s32, verified: bool) {
|
||||
AchievementRadioSample(owner, station, playing, volume, verified,
|
||||
AchievementRadioTime(), now_seconds(), AchievementToday())
|
||||
HostSeconds(), now_seconds(), AchievementToday())
|
||||
}
|
||||
@@ -185,16 +185,76 @@ Android and web keep today's raylib or canvas modules under the same names.
|
||||
Unchanged: Android's `GetAndroidApp` and window-state calls, and the web
|
||||
canvas host (`src/platform/web_window.zi`).
|
||||
|
||||
## Breeze's host modules
|
||||
|
||||
The Linux desktop build defines `DESKTOP_HOST` (compile time; no run-time
|
||||
flag). Breeze reaches its host through these modules, each with a raylib
|
||||
branch for the other platforms and a desktop branch:
|
||||
|
||||
- `src/platform/app_trace.zi`: the log (stderr or `inbe.log`, recent errors).
|
||||
- `src/platform/host_clock.zi`: `HostSeconds`, `HostFrameSeconds`, `HostWait`.
|
||||
- `src/platform/host_input.zi`: keys, repeats, pointer, right button, wheel
|
||||
X/Y, pointer movement, modifiers, cursor.
|
||||
- `src/platform/host_window.zi`: open, size, retained pixels, PNG capture,
|
||||
render scale, close request, hidden/minimized, close. Light: no runtime.
|
||||
- `src/platform/host_window_state.zi`: focus, title, tray hide/show,
|
||||
minimize, restore, monitor size.
|
||||
- `src/platform/host_frame.zi`: the frame loop and picture invalidation; the
|
||||
only module that imports `kryon/raylib_runtime` or `kryon/canvas_host`.
|
||||
- `src/platform/icon_png.zi`: RGBA to PNG (Ziran's encoder, every native
|
||||
host) and, on the desktop host, pictures decoded to RGBA by the raster.
|
||||
- Desktop branches in `audio_runtime.zi` (Kryon's mixer, SDL sink, Opus,
|
||||
WAV, MP3, Vorbis), `radio_native.zi` (dr_mp3 push decoding from the audio
|
||||
package, mixer PCM stream), `raylib_text_input.zi` (desktop keyboard, the
|
||||
window's text per frame, clipboard) and `asset_files.zi` (`cairo_assets`).
|
||||
|
||||
## Per-platform checklist
|
||||
|
||||
Linux desktop:
|
||||
- [x] Every raylib call site above ported; the desktop graph generates and
|
||||
compiles. A private link (build/desktop-host/breeze, 96.3 MiB) has no
|
||||
raylib markers and no GLES; it links SDL2, Pango, Cairo, fontconfig,
|
||||
FreeType, GLib/GIO and X11.
|
||||
- [ ] Kryon K5–K8 (with the parent coordinator): Cairo picture-cache
|
||||
invalidation; `DisposeFrameTexture` and route-fade frames;
|
||||
`ImagePreviewDecode`/`ImagePreviewRelease`; `notification_desktop`'s
|
||||
raylib `IsWindowFocused`. Until then the private link needs a throwaway
|
||||
stub file outside the repository.
|
||||
- [ ] Switch the shared Makefile's native build to `DESKTOP_HOST`
|
||||
(desktop libraries from pkg-config, the audio package's MP3 and Vorbis
|
||||
archives) once the link needs no stubs.
|
||||
- [ ] Run the scenario on a private Xvfb; then the after benchmark,
|
||||
alternating with the saved raylib build so both see the same load.
|
||||
- [ ] Delete the Linux path's raylib build rules (`RAYLIB_A` for native,
|
||||
`KRYON_BACKEND_RAYLIB`, `AVIF_RAYLIB`, raylib `SUPPORT_*` flags).
|
||||
- [ ] Rename `raylib_text_input.zi` and move the key constants out of
|
||||
`raylib_host.zi` once no platform uses raylib.
|
||||
- Known desktop gaps: no route fade (K6); updated pictures need a restart
|
||||
(K5); window focus for notifications (K8).
|
||||
|
||||
Windows, web, Android: every remaining raylib use and Kryon's replacement
|
||||
is mapped in `plans/2026-11-16-breeze-raylib-other-platforms.md`. Kryon gaps
|
||||
sent to the parent coordinator on 2026-11-16:
|
||||
- [ ] Web W1: the browser MediaAudio provider out of `media_audio_raylib`.
|
||||
- [ ] Web W2: Canvas-named clip and trace calls for `raylib_clip` and
|
||||
`raylib_trace`.
|
||||
- [ ] Android A1: app ticks while paused or windowless (practices, audio,
|
||||
timers, PiP) in `android_run`.
|
||||
- [ ] Android A2: a mixer sink (AAudio or OpenSL ES), or SDL2 on Android.
|
||||
- [ ] Android A3: picture registration for embedded, disk and practice
|
||||
bytes, with orientation and invalidation.
|
||||
- [ ] Android A4: a non-raylib `window_runtime` branch.
|
||||
- [ ] Windows X1: platform-selected timer, image, video and accessibility
|
||||
modules for the desktop host, and Windows SDL2/Cairo/Pango/FreeType builds.
|
||||
- [ ] Windows X2: a raylib-free picture-to-PNG path (`ImageExport`,
|
||||
`window_icon`).
|
||||
|
||||
## Steps
|
||||
|
||||
1. Get a Breeze build to benchmark. The checkout does not build right now
|
||||
while its pins move to Kryon's namespaced widget API; the Breeze pin
|
||||
sessions (breeze-entity-kryon-master, breeze-one-format-pins) own that
|
||||
repair. Benchmark the first state that builds.
|
||||
2. Measure and record the before table; commit and push the plan, the
|
||||
harness and the numbers.
|
||||
3. Port the Linux desktop layer file by file as K1–K4 land, following the
|
||||
map above; delete the raylib code the Linux path no longer uses. Windows,
|
||||
web and Android builds must still pass.
|
||||
4. Run the same benchmark after the port and add the after table and the
|
||||
1. Kryon K5–K8, routed by the parent coordinator, pushed, then pinned here.
|
||||
2. Remove the live-Kryon `ziran.local.toml` someone added on 2026-11-16 15:57
|
||||
(its owner, via the coordinator) so builds use the pinned Kryon again.
|
||||
3. Finish the Linux checklist above, then the after benchmark and the
|
||||
comparison here.
|
||||
4. Windows, web and Android, platform by platform, each with its raylib code
|
||||
deleted as it moves.
|
||||
@@ -0,0 +1,156 @@
|
||||
# Breeze raylib audit: Windows, web and Android — 2026-11-16
|
||||
|
||||
Read-only source audit; this document is the only write. No builds, source generation, app/device tests, commits or dependency changes. Linux's in-progress `DESKTOP_HOST` port is outside this audit. Line numbers describe the shared checkout as read today and can move as that port proceeds.
|
||||
|
||||
Evidence base: Breeze `ziran.toml:12` pins Kryon `b45cc52456775dac23062979888ee04c5537b078`; `build/packages/kryon` resolves to `/home/wao/.cache/ziran/sources/p9f8ecaca6100c8aa`. Below, **K/** means that pinned package root; all other paths are Breeze-relative. Entries group declarations by file but enumerate individual foreign target names. A foreign declaration identifies the source dependency, not proof that a linker retains an unused function. No direct `#foreign c "<raylib API name>"` was found in the scoped Breeze `.zi` files; the calls below use `raylib` or another alias naming raylib. Kryon's Canvas host supplies many of those C symbol names itself on web.
|
||||
|
||||
Scope flag for parent: `Makefile:172,173,599` also names `CLICK_RAYLIB_BUILD_DIR`, `CLICK_RAYLIB_A`, and Click raylib wrappers. Click is outside the requested Windows/web/Android audit; resolve that shipping target before deleting Kryon's backend.
|
||||
|
||||
| Local wrapper imports shared by Windows, web and Android | Remaining module |
|
||||
| --- | --- |
|
||||
| `src/platform/app_host.zi:100`; `src/app/app_launcher.zi:47`; `src/app/entity_host.zi:55`; `src/screens/settings/settings_appearance.zi:13`; `src/screens/settings/settings_sync_account_impl.zi:12`; `src/screens/profile_social.zi:28`; `src/screens/profile_dew.zi:26`; `src/screens/telegram_account.zi:21`; `src/screens/node_app_screen.zi:27`; `src/screens/habits/habit_session_screen.zi:29`; `src/screens/habits/shop.zi:26`; `src/screens/habits/edit.zi:44`; `src/screens/habits/habit_entries.zi:21`; `src/screens/diary_screen.zi:40`; `src/screens/profile_screen.zi:44`; `src/screens/elist_screen.zi:19`; `src/screens/lumi_settings.zi:31`; `src/screens/lumi_screen.zi:55` | Local `raylib_text_input.zi`; its six direct foreign calls are enumerated in each platform section. These imports add no separate foreign API. |
|
||||
|
||||
## Windows
|
||||
|
||||
Windows still builds real raylib: `mk/windows.mk:88` defines `PLATFORM_DESKTOP`, `_WIN32`, `AVIF_RAYLIB`, `DESKTOP_TRAY_ENABLED`, without `DESKTOP_HOST`. The new Linux branches therefore do not remove the Windows dependency.
|
||||
|
||||
| Breeze file:line | Remaining call or module | Windows effect |
|
||||
| --- | --- | --- |
|
||||
| `src/platform/raylib_host.zi:10,11,45,46,47,81` | `kryon/Raylib`, `window_visible`; `InitWindow`, `CloseWindow`, `ExportImage`; `RaylibUseIconTextures()` | Main native window, screenshots, icon textures. Imported by `src/main.zi:10`, `src/breaks/app_breaks.zi:6`, `src/platform/startup_tools.zi:4`, `src/platform/app_host.zi:34`, `src/app/dpi_state.zi:5`, `src/screens/break_overlay.zi:7`. |
|
||||
| `src/platform/host_clock.zi:12,13,14` | `GetTime`, `GetFrameTime`, `WaitTime` | Animation/practice/frame clocks and waits. |
|
||||
| `src/platform/host_input.zi:15,16,17,18,19,20,21,22,23,24,25,26` | `IsKeyPressed`, `IsKeyDown`, `IsKeyPressedRepeat`, `GetKeyPressed`, `GetMousePosition`, `IsMouseButtonPressed`, `IsMouseButtonDown`, `IsMouseButtonReleased`, `GetMouseWheelMoveV`, `GetMouseDelta`, `SetMouseCursor`, `IsKeyReleased` | Main input, wheel, modifiers and cursor. |
|
||||
| `src/platform/host_window.zi:16,17,37,45,92,113,121,129,137` | `kryon/window_runtime`, `window_close`; `WindowWidth`, `WindowHeight`, `WindowCloseTake`, `WindowClosing`, `WindowHidden`, `WindowMinimized`, `CloseNativeWindow` | `window_runtime`'s non-web implementation calls raylib; close interception itself is Win32. |
|
||||
| `src/platform/host_window_state.zi:11,30,31,32,33,34,35,36,37,38` | `IsWindowFocused`, `SetWindowTitle`, `SetWindowState`, `ClearWindowState`, `RestoreWindow`, `MinimizeWindow`, `SetWindowFocused`, `GetCurrentMonitor`, `GetMonitorWidth`, `GetMonitorHeight` | Focus, title, tray visibility, restore/minimize, monitor placement. |
|
||||
| `src/platform/host_frame.zi:15,50,62,74` | `kryon/raylib_runtime`; `RunRaylibAppFrame`, `InvalidateRaylibAssets`, `InvalidateRaylibAssetsUnder` | Frame/render driver and downloaded picture invalidation. |
|
||||
| `src/platform/app_host.zi:2,38,44,45,46,47,48,51,52,98` | `kryon/window_runtime`, `kryon/Raylib`; `SetConfigFlags`, `SetExitKey`, `GetRenderWidth`, `GetRenderHeight`, `SetTargetFPS`, `LoadImageFromScreen`, `UnloadImage`; `raylib_secondary_window` | Setup, render sizing, pacing and screenshot capture. |
|
||||
| `src/platform/main_platform.zi:18,19,26,28,29,30` | `window_close`, `kryon/window_icon`; `TraceLog`, `IsWindowReady`, `GetWindowHandle`, `ChangeDirectory` | Win32 icon/resource setup and close watching use raylib's HWND (`:139,346`); other declarations remain even where platform branches do not use them. |
|
||||
| `src/platform/app_trace.zi:26,28,89,97,129,138,149`; `src/platform/trace_log.zi:15` | `raylib_trace`; `SetTraceLogLevel`; `TraceLog`, `RaylibTraceToConsole`, `RaylibTraceToFile`, `RaylibTraceRecentErrors`, `RaylibTraceClose`; variadic `TraceLog` | File/console diagnostics and startup-error capture. `K/src/backend/raylib_trace.zi:37,38,39` calls `SetTraceLogCallback`, `SetTraceLogLevel`, `TraceLog`. |
|
||||
| `src/platform/raylib_text_input.zi:87,88,89,90,91,92` | `GetCharPressed`, `IsKeyPressed`, `IsKeyPressedRepeat`, `IsKeyDown`, `GetClipboardText`, `SetClipboardText` | Typed text, editor keys and clipboard. |
|
||||
| `src/platform/asset_files.zi:34,35,36,43,98` | `SetLoadFileDataCallback`, `MemAlloc`, `MemFree`, `GetFileLength`; callback installation | Embedded/disk bytes for raylib font/image/audio loaders. |
|
||||
| `src/platform/audio_runtime.zi:297,299,301,302,303,304,305,306,307,308,309,310,311,312` | `LoadWave`, `LoadWaveFromMemory`, `WaveFormat`, `UnloadWave`, `LoadSoundFromWave`, `LoadSound`, `IsSoundValid`, `UnloadSound`, `PlaySound`, `StopSound`, `PauseSound`, `IsSoundPlaying`, `SetSoundVolume`, `SetSoundPitch` | Decoding and cue/sample playback. |
|
||||
| `src/platform/audio_runtime.zi:313,315,316,317,318,319,320,321,322,323,324` | `LoadMusicStream`, `LoadMusicStreamFromMemory`, `IsMusicValid`, `UnloadMusicStream`, `PlayMusicStream`, `StopMusicStream`, `PauseMusicStream`, `ResumeMusicStream`, `IsMusicStreamPlaying`, `UpdateMusicStream`, `SetMusicVolume` | Background music and streamed recordings. |
|
||||
| `src/platform/audio_runtime.zi:325,326,327,329,330` | `InitAudioDevice`, `IsAudioDeviceReady`, `CloseAudioDevice`, `AttachAudioMixedProcessor`, `DetachAudioMixedProcessor` | Device lifecycle and audio meter tap. |
|
||||
| `src/platform/voice_audio.zi:10,58` → `K/src/backend/media_audio_raylib.zi:12,13,33`; `K/src/backend/media_audio_opus.zi:8` | `media_audio_raylib`, `MediaAudioUseRaylib`; transitive `media_audio_opus` → `audio_sink_raylib` | Spoken practices/Lumi; native Opus PCM sink still uses raylib. |
|
||||
| `src/platform/radio_native.zi:27,28,29,30,31,32,33,92,94` | `LoadAudioStream`, `UnloadAudioStream`, `PlayAudioStream`, `IsAudioStreamProcessed`, `UpdateAudioStream`, `SetAudioStreamVolume`, `SetAudioStreamBufferSizeDefault`, `drmp3dec_init`, `drmp3dec_decode_frame` | Live radio PCM and raylib's embedded MP3 push decoder. Outer guard excludes Android/web but includes Windows. |
|
||||
| `src/app/dpi_state.zi:8,10,11,79` | `kryon/Raylib`; `IsWindowReady`, `GetWindowScaleDPI`; `RaylibSetZoom` | Display scale and raster/icon zoom. |
|
||||
| `src/app/application_frame.zi:71,89,90,91,92` | `kryon/raylib_runtime`; `BeginMode2D`, `EndMode2D`, `BeginScissorMode`, `EndScissorMode` | Camera/scissor rendering and retained frame machinery. |
|
||||
| `src/platform/practice_window_host.zi:14`; `src/breaks/app_breaks.zi:52`; `src/platform/app_host.zi:98` | `raylib_secondary_window` | Legacy import remains. Actual SDL/raylib renderer is gated by `K/src/backend/raylib_secondary_window.zi:149,273`; Windows generation does not define `NATIVE_WINDOW_HAVE_SDL`, so secondary windows are unavailable stubs. |
|
||||
| `src/platform/desktop_tray.zi:31,326` → `K/src/backend/image_export.zi:3,7,15,20` | `kryon/ImageExport`, `EncodedImageExport` → `raylib_image_decode`, `ExportImage` | Decodes embedded WebP and writes tray PNG. |
|
||||
| `K/src/backend/raylib_runtime.zi:37`; `K/src/backend/window_icon.zi:4,6,7`; `K/src/backend/raylib_image_decode.zi:26,27,28,29,30,31` | Transitive `raylib_image_decode`: `LoadImageFromMemory`, `UnloadImage`, `ImageRotateCW`, `ImageRotateCCW`, `ImageFlipHorizontal`, `ImageFlipVertical`; icon `ImageFormat`, `SetWindowIcon` | Picture decode/orientation and native icon. |
|
||||
| `K/src/backend/raylib_runtime.zi:34` → `raylib_clip.zi:3,31,44,45,47,48,49,51` | `raylib_clip`: `rlGetMatrixModelview`, `glIsEnabled`, `glGetIntegerv`, `BeginScissorMode`, `EndScissorMode`, `rlEnableScissorTest`, `rlScissor` | Shared clipping module uses raylib/GL calls on native targets. Cairo replacement must not retain this native branch. |
|
||||
| `src/screens/habits_screen.zi:17`; `src/app/application_update.zi:72`; `src/app/lumi_guide.zi:26` | Bare `#system_library "raylib"` aliases | Residual names, with no associated foreign call in those files. |
|
||||
| Scoped Breeze sources; `K/ziran.toml:118` | `bundle_raylib` | No Breeze import found. Kryon still exports it; `K/src/backend/bundle_raylib.zi:7,16` imports `media_audio_raylib`/`raylib_runtime`. Export availability alone does not establish Breeze use. |
|
||||
|
||||
| Build file:line | Remaining dependency/rule |
|
||||
| --- | --- |
|
||||
| `Makefile:195,217,218,226,469` | `RAYLIB_DIR`, `WIN64_RAYLIB_BUILD_DIR`, `WIN64_RAYLIB_A`, `RAYLIB_SOURCES`, shared `-I$(RAYLIB_DIR)`. |
|
||||
| `Makefile:452,498,500–507,509,598,732` | `WINDOWS_GEN_GAME_C := …/Raylib.c`; `RAY_RAYLIB_CONFIG` and audio-period configuration feed `APP_RAYLIB_CONFIG`, which enables raudio/JPG/Ogg/MP3/TTF; archive depends on Makefile; `KRYON_WINDOWS_SRCS += $(KRYON_RAYLIB_WRAPPERS_C)` (legacy variable reference); `vendor-prebuilds-windows` requires `WIN64_RAYLIB_A`. |
|
||||
| `mk/windows.mk:5,6,12,14,15,16,18,21` | `WINDOWS_RAYLIB_RULE` copies package sources and builds static raylib with MinGW, `PLATFORM_DESKTOP_RGFW`, OpenGL 1.1, audio/models and `APP_RAYLIB_CONFIG`; instantiated for `WIN64_RAYLIB_A`. |
|
||||
| `mk/windows.mk:88,93,153,166`; `Makefile:519` | Generator selects non-`DESKTOP_HOST` graph and `AVIF_RAYLIB`; generated `Raylib.c` target remains; executable depends on and links `WIN64_RAYLIB_A`. System libraries include `gdi32`, `winmm`, `opengl32`, `user32`; these are not a Kryon GDI renderer. |
|
||||
| `K/ziran.toml:3,11,94,95,96,118,400,402,404` | Declares raylib; exports `Raylib`/`raylib_runtime`, `ImageExport`, `bundle_raylib`, renderer-raylib artifact. Default link list/renderer-desktop artifact are Linux-oriented; their presence is not Windows readiness. |
|
||||
|
||||
| Kryon already offers at the pin | Exact remaining gap and why Breeze needs it |
|
||||
| --- | --- |
|
||||
| SDL2 primitives in `K/src/backend/desktop_window.zi:61,84,94,104,120` (`Open`, `Clear`, `Present`, `NextEvent`, `Close`); software presenters `pixmap_sdl.zi`, `pixmap_sdl3.zi`; Cairo raster. | Real non-raylib building blocks, but no Windows GDI/Win32 drawing/frame host was found in the backend inventory. `tray_windows`, `window_close` and Win32 file picker are utilities, not a renderer. `desktop_window` only clears/presents an empty window; it cannot replace Breeze's full UI host alone. |
|
||||
| `K/src/backend/desktop_runtime.zi:468,527,555,566,659,773,1045,1080,1120,1181,1196,1204,1210,1226,1243`: `OpenDesktopTitled`, `DesktopViewport`, `DesktopSetTitle`, `DesktopSetIcon`, `CloseDesktop`, `PollDesktop`, `DesktopInputQueue`, `BeginDesktopFrame`, `EndDesktopFrame`, `PauseDesktop`, visibility/focus/close APIs. `desktop_keyboard`; `desktop_window_state.zi:48,55,63,71,78,85,86,87,90,93,97` covers minimize/maximize/restore/raise/on-top/monitor/DPI. | SDL calls are portable building blocks, but this is not a completed Windows SDL2+Cairo target: `desktop_runtime.zi:16,27` imports `std/timer_linux`/`video_linux`; `Timer.MonotonicMilliseconds` is used at `:484,1023,1112`. `cairo_raster.zi:46,47` uses libdl `dlsym`; its image path calls `Decode.OpenStill/OpenImage/CopyPixels` at `:836,847,851`, backed by `image_decode_linux.zi:5,8,9` loading Linux libraries. `video_linux.zi:8,12,13` uses `dlopen`/`dlsym` for `VideoOpenHost` (`:130`) and associated playback hooks. Need supported Windows loading/decoding/timing or platform-selected implementations before enabling `DESKTOP_HOST`. |
|
||||
| `K/src/backend/frames_desktop.zi:19` / `desktop_loop`; Cairo/Pango/FreeType typefaces in `cairo_typefaces.zi:18,19,20`. | Stock desktop frame host imports Linux accessibility (`desktop_loop.zi:7`; `frames_desktop.zi:8`) and Linux timer/files (`desktop_loop.zi:17,18`). `K/ziran.toml:3` links X11/pthread/GIO/Pango/Cairo. Need a Windows build/link artifact for the chosen renderer/font/image stack; Breeze's current MinGW rule supplies no SDL2/Cairo/Pango/FreeType. Source portability is untested here. |
|
||||
| `K/src/backend/desktop_secondary_window.zi` supplies `OpenSecondaryWindow`, frame/input/paint/close and `GetSecondaryWindowSize`; SDL2 surfaces/Cairo. | Non-raylib route for practice/reminder windows after main host portability work; shares Cairo/runtime gaps. Old Windows RGFW route currently supplies stubs. |
|
||||
| `K/src/backend/audio_mixer.zi:294,325,371,379,397` (`AudioUseTap`, `AudioLoad`, `AudioLoadFile`, `AudioOpenStream`, `AudioStreamWritable`); `audio_sink_sdl.zi:54,75,78`; `media_audio_desktop.zi:126`; Opus/WAV/MP3/Vorbis decoders. | Select these for Windows and build/link SDL2 plus codec archives. `media_audio_opus.zi:8` must stop selecting `audio_sink_raylib` on this route. Preserve cue pitch, streamed music, meter tap and radio push decoding; Breeze's desktop branch already shows required mixer use. No Windows runtime validation was performed. |
|
||||
| `K/src/backend/ziran_image_decode.zi:7,8,9,10,12,17` supplies allocation/byte/signature helpers; `webp_image`, `avif_image`; Cairo `RasterWritePNG`; SDL `DesktopSetIcon`. | `ziran_image_decode` is not a complete decoder/exporter by itself. `ImageExport`/`window_icon` still expose raylib image structs/calls. Need a raylib-free encoded-image→RGBA→PNG path and portable image loading for embedded icon, tray PNG, practice/user pictures and screenshots. Linux port's `icon_png.zi` is app-side evidence, not a new pinned Kryon API. |
|
||||
| SDL2 clipboard/input, `desktop_keyboard`, existing Win32 `window_close`. | `window_runtime.zi:8–30` has Canvas/raylib branches, no SDL2+Cairo/Win32 branch. Route Breeze's host window/clock/input/text/DPI functions to the new host; preserve HWND access or use host-native icon/close APIs. `app_trace` non-desktop branch still needs raylib callbacks; replace with an ordinary file/console logger retaining startup-error capture. |
|
||||
|
||||
## Web
|
||||
|
||||
The web artifact is already raylib-library-free in the inspected build rules. `mk/web.mk:8,9,43,47,80,84` selects `PLATFORM_WEB`/Emscripten and Kryon Canvas2D. Names below are foreign symbol declarations or legacy modules; many are implemented by Kryon's `.zi` page/Canvas host and do not require libraylib.
|
||||
|
||||
| Breeze file:line | Remaining raylib name/module | Actual web implementation or qualification |
|
||||
| --- | --- | --- |
|
||||
| `src/platform/raylib_host.zi:45,46,47` | `InitWindow`, `CloseWindow`, `ExportImage`; local `RaylibImage` at `:33` | `K/src/backend/canvas_window.zi:52,68`; `canvas_texture.zi:275`. `kryon/Raylib`/`window_visible` imports at `:10,11` are excluded; Canvas imports at `:14–17` replace them. Native screenshot capture is excluded. |
|
||||
| `src/platform/host_clock.zi:12,13,14` | `GetTime`, `GetFrameTime`, `WaitTime` | `K/src/backend/canvas_window.zi:212,217,315`, backed by page clock/sleep. |
|
||||
| `src/platform/host_input.zi:15,16,17,18,19,20,21,22,23,24,25,26` | `IsKeyPressed`, `IsKeyDown`, `IsKeyPressedRepeat`, `GetKeyPressed`, `GetMousePosition`, `IsMouseButtonPressed`, `IsMouseButtonDown`, `IsMouseButtonReleased`, `GetMouseWheelMoveV`, `GetMouseDelta`, `SetMouseCursor`, `IsKeyReleased` | `K/src/backend/canvas_input.zi:47,57,52,83,106,67,72,77,121,111,62`; cursor in `canvas_window.zi:256`. |
|
||||
| `src/platform/host_window.zi:16,17`; `src/platform/app_host.zi:2`; `src/platform/main_platform.zi:18,19` | `window_runtime`, `window_close`, `window_icon` | `window_runtime.zi:7–9` selects Canvas. `window_icon.zi:3` excludes raylib on web; `window_close.zi:5,6,109` returns false without desktop watchers. These names do not imply a web raylib renderer. |
|
||||
| `src/platform/host_window_state.zi:11,30,31,32,33,34,35,36,37,38` | `IsWindowFocused`, `SetWindowTitle`, `SetWindowState`, `ClearWindowState`, `RestoreWindow`, `MinimizeWindow`, `SetWindowFocused`, `GetCurrentMonitor`, `GetMonitorWidth`, `GetMonitorHeight` | `K/src/backend/canvas_window.zi:95,261,119,125,151,145,266,282,292,297`. Some desktop operations are browser state/no-op equivalents. |
|
||||
| `src/platform/app_host.zi:44,45,46,47,48` | `SetConfigFlags`, `SetExitKey`, `GetRenderWidth`, `GetRenderHeight`, `SetTargetFPS` | `K/src/backend/canvas_window.zi:114,310,236,243,156`. `LoadImageFromScreen`/`UnloadImage` at `:51,52` excluded. |
|
||||
| `src/platform/main_platform.zi:26,28,29,30` | `TraceLog`, `IsWindowReady`, `GetWindowHandle`, `ChangeDirectory` | `canvas_os.zi:561` supplies C `TraceLog`; `canvas_window.zi:90,278` and `canvas_os.zi:297` supply other names. Some declarations unused by web setup. |
|
||||
| `src/platform/app_trace.zi:26,28,89,97,129,138,149`; `src/platform/trace_log.zi:15` | `raylib_trace`, `SetTraceLogLevel`, variadic `TraceLog`; `RaylibTraceToConsole/ToFile/RecentErrors/Close` | `raylib_trace.zi:37–39` still declares callback/level/log imports. Web C exports: `canvas_os.zi:531,561,582`. Rename/reselect before deleting the raylib-named module upstream. |
|
||||
| `src/platform/raylib_text_input.zi:87,88,89,90,91,92` | `GetCharPressed`, `IsKeyPressed`, `IsKeyPressedRepeat`, `IsKeyDown`, `GetClipboardText`, `SetClipboardText` | Canvas input `:91,47,52,57`; `canvas_os.zi:102,107` clipboard. |
|
||||
| `src/platform/asset_files.zi:34,35,36,43,98` | `SetLoadFileDataCallback`, `MemAlloc`, `MemFree`, `GetFileLength` | `K/src/backend/canvas_os.zi:184,572,577,312`; still registers Breeze embedded-file callback. |
|
||||
| `src/platform/audio_runtime.zi:297,299,301,302,303,304,305,306,307,308,309,310,311,312` | `LoadWave`, `LoadWaveFromMemory`, `WaveFormat`, `UnloadWave`, `LoadSoundFromWave`, `LoadSound`, `IsSoundValid`, `UnloadSound`, `PlaySound`, `StopSound`, `PauseSound`, `IsSoundPlaying`, `SetSoundVolume`, `SetSoundPitch` | `K/src/backend/canvas_audio.zi` supplies public C names using Canvas audio structs/engine. |
|
||||
| `src/platform/audio_runtime.zi:313,315,316,317,318,319,320,321,322,323,324` | `LoadMusicStream`, `LoadMusicStreamFromMemory`, `IsMusicValid`, `UnloadMusicStream`, `PlayMusicStream`, `StopMusicStream`, `PauseMusicStream`, `ResumeMusicStream`, `IsMusicStreamPlaying`, `UpdateMusicStream`, `SetMusicVolume` | `canvas_audio.zi` → `canvas_audio_engine`/`canvas_audio_host`. |
|
||||
| `src/platform/audio_runtime.zi:325,326,327,329,330` | `InitAudioDevice`, `IsAudioDeviceReady`, `CloseAudioDevice`, `AttachAudioMixedProcessor`, `DetachAudioMixedProcessor` | Browser implementation; mixed processor functions at `canvas_audio.zi:731,742`. |
|
||||
| `src/platform/voice_audio.zi:10,58` | `media_audio_raylib`, `MediaAudioUseRaylib` | `K/src/backend/media_audio_raylib.zi:22–25,60–64` selects browser engine/host/device state. Native `media_audio_opus`/`audio_sink_raylib` import excluded at `:12`. Actual provider is raylib-free but shares its module name. |
|
||||
| `src/app/application_frame.zi:89,90,91,92` | `BeginMode2D`, `EndMode2D`, `BeginScissorMode`, `EndScissorMode` | `canvas_draw.zi:78,83,68,73` → page paint. `raylib_runtime` import at `:71` excluded. |
|
||||
| `K/src/backend/canvas_raster.zi:18` → `raylib_clip.zi:3,31,35–41` | `raylib_clip`, foreign `rlGetMatrixModelview`; web clipping uses `PageClipPush/Pop` | `canvas_draw.zi:143` exports the modelview C symbol from page transforms. Native GL/scissor foreign declarations at `raylib_clip.zi:44–51` are excluded on web. Rehome this shared clip code before deleting raylib-named backend files. |
|
||||
| `src/platform/web_window.zi:10,13,14,15,16` | `raylib` alias; `GetScreenWidth`, `GetScreenHeight`, `IsMouseButtonDown`, `SetWindowSize` | Web-only orientation/resize uses Canvas window/input C exports. `UpdateDPI` at `:17` is Breeze's export, not raylib. |
|
||||
| `src/platform/app_host.zi:98`; `src/platform/practice_window_host.zi:14`; `src/breaks/app_breaks.zi:52` | `raylib_secondary_window` | Imported legacy module; `SECONDARY_SDL` false on web (`K/src/backend/raylib_secondary_window.zi:149`), so native windows return unavailable/defaults. |
|
||||
| `src/platform/desktop_tray.zi:31,326` → `K/src/backend/image_export.zi:3,7` | `ImageExport`, transitive `raylib_image_decode`, `ExportImage` | Desktop tray path remains in shared source. Canvas supplies image C names where reached. `window_icon` raylib decoding and runtime raylib decoding imports are excluded on web. |
|
||||
| `src/screens/habits_screen.zi:17`; `src/app/application_update.zi:72`; `src/app/lumi_guide.zi:26` | Bare raylib library aliases | Residual names without foreign calls there. |
|
||||
| `src/platform/host_frame.zi:13,44,59,69`; `src/app/application_frame.zi:68`; `src/app/dpi_state.zi:73,74` | Already selected replacements: `canvas_host`, direct frame callback, `InvalidateCanvasAssets`, `InvalidateCanvasAssetsUnder`, `SetPaintPixelScale` | `RaylibSetZoom`, native DPI imports, `RunRaylibAppFrame`, `ResetRaylibGraphics` excluded. `radio_native`'s raylib block excluded at `:7`. No `bundle_raylib` import found. |
|
||||
|
||||
| Build file:line | Actual web rule / residual naming |
|
||||
| --- | --- |
|
||||
| `mk/web.mk:6–9` | Generate with `PLATFORM_WEB`, `__EMSCRIPTEN__`, explicitly include `canvas_raster.zi`, `canvas_audio.zi`, `page_route.zi`. No raylib generation define. |
|
||||
| `mk/web.mk:39–51,76–88` | Both web targets use `KRYON_BACKEND_CANVAS=1`, link generated C, SQLite, bundle runtime, liboqs and JS hosts; neither lists `RAYLIB_A`/`-lraylib`. |
|
||||
| `Makefile:448,469,472,507,606–609,616` | Legacy `WEB_GEN_GAME_C := …/Raylib.c`; shared include set retains raylib headers. `APP_RAYLIB_CONFIG` is shared native config, not a web library build. JS hosts are Breeze/Telegram and Ziran `web/ziran_web.js`; `KRYON_CANVAS_SRCS` filters legacy raylib wrappers. |
|
||||
| `mk/web.mk:13`; `K/ziran.toml:11,94,95,118` | Generated `Raylib.c` prerequisite reference and package raylib dependency/exports remain although web linker selects no libraylib. Clean these for full upstream removal. |
|
||||
|
||||
| Kryon already offers at the pin | Exact remaining gap and why Breeze needs it |
|
||||
| --- | --- |
|
||||
| `K/src/backend/canvas_host.zi:7–24` connects Canvas window/drawing/input/texture/events, frame driver and page host; `frames_web.zi:16,38` has `DrawCanvasFrame`/`Run`. Canvas raster/text/texture already supply browser rendering. | No missing renderer demonstrated. Replace foreign-library raylib naming with Canvas/module calls while retaining Breeze's frame ownership. `raylib_clip` still has a raylib foreign declaration, fulfilled by Canvas on web; rehome its modelview/clip surface before deleting raylib-named files. |
|
||||
| `K/src/backend/page_core`; `page_window.zi:23` `Show`; page events/input/paint/texture/font/files/route on Ziran's `web` bridge. | `page_window.Show` intentionally opens only an empty canvas (`:1–4`); Breeze needs full Canvas frames/text/input/audio. Page host is not an Android/Windows fallback. |
|
||||
| Canvas audio engine/host already supplies cues/streamed music; `media_audio_raylib` has a browser provider branch. | Rehome/export browser provider under a non-raylib module/function. Deleting `media_audio_raylib` now deletes the provider `VoiceAudioStart` selects. Preserve `MediaAudio` Load/Play/Pause/Resume/Gain/Status/Unload and browser suspended/unavailable state. API separation, not a demonstrated new browser-audio capability gap. |
|
||||
| `canvas_os.zi:531,561,582` provides trace callback/log/level/OS helpers; Canvas picture exports exist. | Remove `raylib_trace`, `ImageExport`/`raylib_image_decode` and secondary-window imports from selected graph via a host-neutral logger/browser image API or by excluding unreachable desktop utilities. No missing browser renderer capability found. Static audit does not establish that every vestigial native helper can execute on web. |
|
||||
| Web rules already link no raylib archive. | Remove generated `Raylib.c`/header/wrapper assumptions and package raylib dependency after native migrations. Parent implementation must verify browser behavior and exports; no web build/smoke test run here. |
|
||||
|
||||
## Android
|
||||
|
||||
Android still uses raylib for renderer/audio. CMake defines both `KRYON_ANDROID_HOST` and `KRYON_RAYLIB_HOST`: the former enables Android helpers; it does not select Kryon's standalone software renderer while the latter remains.
|
||||
|
||||
| Breeze file:line | Remaining call or module | Android effect |
|
||||
| --- | --- | --- |
|
||||
| `src/platform/raylib_host.zi:10,11,45,46,47,54–72,81` | `kryon/Raylib`, `window_visible`; `InitWindow`, `CloseWindow`, `ExportImage`, `RaylibUseIconTextures`; waits for native surface | Opens raylib EGL/GL window; native dimensions can come from `AndroidSurface`. Same common import consumers as Windows (`src/main.zi:10`, etc.). |
|
||||
| `src/platform/host_clock.zi:12,13,14` | `GetTime`, `GetFrameTime`, `WaitTime` | Frame/practice clocks and waits. |
|
||||
| `src/platform/host_input.zi:15,16,17,18,19,20,21,22,23,24,25,26` | `IsKeyPressed`, `IsKeyDown`, `IsKeyPressedRepeat`, `GetKeyPressed`, `GetMousePosition`, `IsMouseButtonPressed`, `IsMouseButtonDown`, `IsMouseButtonReleased`, `GetMouseWheelMoveV`, `GetMouseDelta`, `SetMouseCursor`, `IsKeyReleased` | Shared declarations; Android also intercepts native touch. |
|
||||
| `src/platform/host_window.zi:16,17,37,45,92,113,121,129,137`; `src/app/application_frame.zi:82` | `window_runtime`, `window_close`; size/close/hidden/minimized/`CloseNativeWindow`; `SyncWindowSurface` in frame path | Native surface helpers coexist with raylib GL framebuffer sync (`K/src/backend/window_runtime.zi:15–22,70`). This is not standalone software host. |
|
||||
| `src/platform/host_window_state.zi:11,30,31,32,33,34,35,36,37,38` | `IsWindowFocused`, `SetWindowTitle`, `SetWindowState`, `ClearWindowState`, `RestoreWindow`, `MinimizeWindow`, `SetWindowFocused`, `GetCurrentMonitor`, `GetMonitorWidth`, `GetMonitorHeight` | Shared declarations including desktop operations; Android needs lifecycle/focus/background distinctions. |
|
||||
| `src/platform/host_frame.zi:15,50,62,74`; `src/app/application_frame.zi:71,123` | `raylib_runtime`; `RunRaylibAppFrame`, `InvalidateRaylibAssets`, `InvalidateRaylibAssetsUnder`, `ResetRaylibGraphics(context_lost)` | Render loop, image/texture cache, EGL-context recovery. |
|
||||
| `src/platform/app_host.zi:2,38,44,45,46,47,48,51,52,145,146,345,347` | `window_runtime`, `kryon/Raylib`; `SetConfigFlags`, `SetExitKey`, `GetRenderWidth`, `GetRenderHeight`, `SetTargetFPS`, `LoadImageFromScreen`, `UnloadImage`; `SetWindowState`, `ClearWindowState` | Shared setup/capture declarations; PiP toggles `FLAG_WINDOW_ALWAYS_RUN` to keep native events alive. Exit-key configuration excluded at `:281`. |
|
||||
| `src/platform/main_platform.zi:18,19,26,28,29,30,83` | `window_close`, `window_icon`; `TraceLog`, `IsWindowReady`, `GetWindowHandle`, `ChangeDirectory`; debug `GetTime` | File-root setup uses `ChangeDirectory` (`:305`); setup uses `IsWindowReady` (`:315`); geometry time is debug-only. Icon raylib implementation excluded by `K/src/backend/window_icon.zi:3`. |
|
||||
| `src/platform/app_trace.zi:26,28,89,97,129,138,149`; `src/platform/trace_log.zi:15` | `raylib_trace`, `SetTraceLogLevel`, `TraceLog`, `RaylibTraceToConsole/ToFile/RecentErrors/Close` | Callback routes diagnostics to Android logcat/file paths. |
|
||||
| `src/platform/raylib_text_input.zi:87,88,89,90,91,92` | `GetCharPressed`, `IsKeyPressed`, `IsKeyPressedRepeat`, `IsKeyDown`, `GetClipboardText`, `SetClipboardText` | Selected editor/clipboard API; Android IME helpers also exist. |
|
||||
| `src/platform/asset_files.zi:34,35,36,43,98` | `SetLoadFileDataCallback`, `MemAlloc`, `MemFree`, `GetFileLength` | Embedded/disk assets via raylib allocator/loader hook. |
|
||||
| `src/platform/audio_runtime.zi:297,299,301,302,303,304,305,306,307,308,309,310,311,312` | `LoadWave`, `LoadWaveFromMemory`, `WaveFormat`, `UnloadWave`, `LoadSoundFromWave`, `LoadSound`, `IsSoundValid`, `UnloadSound`, `PlaySound`, `StopSound`, `PauseSound`, `IsSoundPlaying`, `SetSoundVolume`, `SetSoundPitch` | Cue/sample decode/playback. |
|
||||
| `src/platform/audio_runtime.zi:313,315,316,317,318,319,320,321,322,323,324` | `LoadMusicStream`, `LoadMusicStreamFromMemory`, `IsMusicValid`, `UnloadMusicStream`, `PlayMusicStream`, `StopMusicStream`, `PauseMusicStream`, `ResumeMusicStream`, `IsMusicStreamPlaying`, `UpdateMusicStream`, `SetMusicVolume` | Background/practice music and recordings. |
|
||||
| `src/platform/audio_runtime.zi:325,326,327,329,330` | `InitAudioDevice`, `IsAudioDeviceReady`, `CloseAudioDevice`, `AttachAudioMixedProcessor`, `DetachAudioMixedProcessor` | Audio device and meter tap. |
|
||||
| `src/platform/voice_audio.zi:10,58` → `K/src/backend/media_audio_raylib.zi:12,13,33`; `K/src/backend/media_audio_opus.zi:8` | `media_audio_raylib`, `MediaAudioUseRaylib`, transitive `media_audio_opus` → `audio_sink_raylib` | Narration uses raylib stream sink including audio-package Opus. |
|
||||
| `src/app/dpi_state.zi:8,10,11,79` | `kryon/Raylib`, `IsWindowReady`, `GetWindowScaleDPI`, `RaylibSetZoom` | Native declarations retained; desktop-only runtime condition normally prevents scale query on Android. Raster zoom still selected. |
|
||||
| `src/app/application_frame.zi:89,90,91,92` | `BeginMode2D`, `EndMode2D`, `BeginScissorMode`, `EndScissorMode` | Logical-coordinate camera/scissor rendering. |
|
||||
| `src/platform/android/android_startup.zi:7`; `src/platform/android/android_touch_host.zi:9`; `src/platform/android/android_package_assets.zi:9` | Three direct `GetAndroidApp` imports | Startup wait/looper commands; raylib input callback chaining; APK/package asset-manager access. Must use host's own app pointer. |
|
||||
| `K/src/backend/android_jni.zi:219,221,224` | `KRYON_RAYLIB_HOST` → `GetAndroidApp` within `JniGetAndroidApp` | Transitive dependency for Android helpers. Clearing define selects retained app pointer; new NativeActivity entry must initialize pointer/thread context. |
|
||||
| `src/platform/app_host.zi:98`; `src/platform/practice_window_host.zi:14`; `src/breaks/app_breaks.zi:52` | `raylib_secondary_window` | Actual secondary SDL/raylib code excluded on Android (`K/src/backend/raylib_secondary_window.zi:149`); detached practice uses Android PiP. |
|
||||
| `src/platform/desktop_tray.zi:31,326`; `K/src/backend/raylib_runtime.zi:37`; `K/src/backend/image_export.zi:3,7` | `ImageExport`, transitive `raylib_image_decode`, `ExportImage` | Shared tray import/native decode still selects raylib structs/calls. `raylib_image_decode.zi:26–31`: `LoadImageFromMemory`, `UnloadImage`, rotations/flips. `window_visible` returns true on Android (`:5,24`), not another graphics dependency. |
|
||||
| `K/src/backend/raylib_runtime.zi:34` → `raylib_clip.zi:3,31,44,45,47,48,49,51` | `raylib_clip`: `rlGetMatrixModelview`, `glIsEnabled`, `glGetIntegerv`, `BeginScissorMode`, `EndScissorMode`, `rlEnableScissorTest`, `rlScissor` | Native clipping depends on raylib/GL; select Pixmap/native host clipping when replacing the renderer. |
|
||||
| `src/screens/habits_screen.zi:17`; `src/app/application_update.zi:72`; `src/app/lumi_guide.zi:26` | Bare raylib aliases | Residual names without foreign calls there. |
|
||||
| `src/platform/radio_native.zi:7`; scoped Breeze sources; `K/ziran.toml:118` | Radio raylib stream/MP3 block excluded; no Breeze `bundle_raylib` import | Export availability is not app selection. |
|
||||
|
||||
| Build file:line | Remaining dependency/rule |
|
||||
| --- | --- |
|
||||
| `mk/android.mk:41,42,46,47,75,80` | Delegates APK/bundle to Gradle; no direct raylib rule/define here. Renderer choice is CMake below. |
|
||||
| `droid/app/src/main/cpp/CMakeLists.txt:22,109,110,111` | `RAYLIB_DIR`; generation/check definitions include `ANDROID_BUILD KRYON_ANDROID_HOST KRYON_RAYLIB_HOST AVIF_RAYLIB`. |
|
||||
| `droid/app/src/main/cpp/CMakeLists.txt:174–178,282,285–290` | Generator receives defines; `kryon_android_codecs` supplies glue/codecs; Breeze creates `breeze_raylib` from `rcore.c`, `rshapes.c`, `rtextures.c`, `rtext.c`, `raudio.c`. |
|
||||
| `droid/app/src/main/cpp/CMakeLists.txt:291–310` | `PLATFORM_ANDROID`, GLES2, custom frame control, TTF/JPG/PNG/Ogg/audio flags, `__wrap_fopen=KryonRaylibFopen`. |
|
||||
| `droid/app/src/main/cpp/CMakeLists.txt:311–319,377–380,384` | Raylib includes/options; links codecs, Opus, EGL, GLESv2, OpenSLES. Generated `main.c` is freestanding because raylib calls it; app `main` links `breeze_raylib`. Entry ownership must change with library list. |
|
||||
| `Makefile:195,469,507`; `K/ziran.toml:11,72,98,106,400,402` | Shared raylib path/header/config; package dependency/artifact; separately exports `host/android`, `AndroidSurface`, `android_run`. |
|
||||
|
||||
| Kryon already offers at the pin | Exact remaining gap and why Breeze needs it |
|
||||
| --- | --- |
|
||||
| `K/src/backend/app_host_android.zi:1` imports `android_run`; `android_run.zi:1–4` selects `android_bundle_run` for ZX. Native `android_run.zi:95,168,253`: `DrawAndroidFrame`, exported `android_main`, `AndroidRunMain`. Presents Pixmap damage with ANativeWindow lock/post (`:77–92,143–155`). | Real raylib-free renderer exists. Integrate Breeze initialization/state/frame callback instead of raylib's entry calling Breeze main. `DrawAndroidFrame` calls standard `Frame(session,bounds)` at `:138` and owns Begin/EndFrame/input; Breeze already owns these. Need reusable host lifecycle/frame surface or deliberate entry conversion; importing both creates competing entry/loop/frame ownership. |
|
||||
| `K/src/backend/android_native.zi:96,223,255,273,298,314,339,371`: `AndroidNativeApp`, `AndroidNativeOnCommand`, `AndroidNativeStart`, `AndroidNativePoll`, pixels/lock/present/unlock; ready/paused/destroy state. `android_jni.zi:224` non-raylib app pointer. | Replace three Breeze `GetAndroidApp` imports and callback chaining. Preserve startup-window wait, asset manager, JNI registration/thread lifetime. Remove `KRYON_RAYLIB_HOST` with new entry initialization. |
|
||||
| `android_surface.zi:210,278,287,317,343,353,383`: sizing, pending/current surface, viewport/insets/clear. `android_touch.zi:106,186,193,215,243,268,276,288`: native input/zoom/frame/focus. `android_device`, `android_text_editor`, `android_clipboard`, `android_process`. | No missing basic touch/IME/insets capability demonstrated. Route Breeze input/text/DPI to these. `window_runtime.zi:11–30` still chooses raylib on all non-web platforms, including rlgl framebuffer sync. Need non-raylib Android window/frame implementation or stop importing it. Software scale/clip/cache invalidation must replace `RaylibSetZoom`, `ResetRaylibGraphics` and EGL tracking. |
|
||||
| `android_run.zi:192–247` owns scheduling; drops retained paint on invalidation. `pixmap_frame`/`pixmap` supply software output. | Exact lifecycle gap: `android_run.zi:201–207` skips app frames whenever paused/windowless. Breeze needs practices/audio/background timers/PiP according to existing mobile policy (`src/platform/app_host.zi:327–348` keeps raylib processing through PiP entry). Need app/background tick policy and focus/window state independent of rendering; stock paused behavior cannot replace it unchanged. |
|
||||
| `audio_mixer`/decoders are raylib-free; `audio_sink_sdl` is the existing non-raylib native PCM sink. `android_bundle_media.zi:42–45` uses JNI MediaPlayer, imported by `android_bundle_run.zi:6`. | No Android-native mixer sink/provider in backend inventory: no `audio_sink_android` or AAudio/OpenSLES equivalent. Need device open/ready/close and PCM pull (`AudioRender`), locking/tap semantics for cues/streams/meter. Alternatively deliberately package SDL2 and use `AudioSinkOpen/Ready/Close`; current Android CMake links no SDL2. Bundle MediaPlayer is not a `MediaAudioUseProvider` mixer sink and does not replace Breeze pitch/tap API. Native `media_audio_opus.zi:8` still selects `audio_sink_raylib`. |
|
||||
| `android_bundle_images.zi:126,166,221,232,244,290`: PNG/JNI BitmapFactory decode, oriented image/cache register/load/release/unregister; WebP/AVIF/Pixmap imports. `android_bundle_run.zi:4–20` has files/resources/images/media. | Decoder exists but registration/cache API is bundle-specific. Breeze needs embedded/disk/practice asset bytes, JPEG orientation and downloaded-image invalidation through ordinary host picture/font loaders. Rehome/reuse decoder through that API; `ziran_image_decode` alone is allocation/byte helpers. Replace `ImageExport` or exclude unreachable tray path. |
|
||||
| Android log writer `android_run.zi:38,39,41`; JNI/process/clipboard/notification/picker helpers. | `app_trace` still selects raylib callback ABI; `main_platform` uses raylib directory/readiness functions. Use ordinary Android logging/libc/process/native readiness while preserving diagnostics. No new notification/picker gap found. |
|
||||
| Page/Canvas is browser host; `frames_desktop` is SDL2+Cairo; `frames_web` is Canvas. | Page host is not Android drop-in. Select `host/android`/NativeActivity+Pixmap or deliberately package SDL2, preserving Breeze app/frame/background contract. No Breeze `bundle_raylib` import to migrate. |
|
||||
|
||||
Read-only verification commands used: `rg -n 'raylib|Raylib|ImageExport|window_runtime|window_icon|window_close|window_visible' src/platform src/app src/screens src/breaks src/main.zi -g '*.zi'`; `rg -n 'bundle_raylib|raylib_image_decode|audio_sink_raylib' src -g '*.zi'` (no direct matches); bounded numbered reads of all five requested build files and named pinned backend modules. Document validation: `test -s plans/2026-11-16-breeze-raylib-other-platforms.md && rg -n '^## (Windows|Web|Android)$' plans/2026-11-16-breeze-raylib-other-platforms.md` — exit 0, all three sections present. No build/test suite run because task explicitly forbids builds/implementation. Platform compilation/runtime parity remains unverified; this records static source/build evidence only.
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "text_buffer"
|
||||
#import "wire"
|
||||
#import "authorization"
|
||||
@@ -28,7 +29,6 @@ c :: #system_library "c";
|
||||
} else {
|
||||
ActivityNow :: (out: *s64) -> s64 #foreign c "time";
|
||||
}
|
||||
ActivityFrameTime :: () -> float64 #foreign c "GetTime";
|
||||
ActivityScheduleSync :: (app: *InnerBreeze) -> s32 #foreign c "app_auto_sync";
|
||||
|
||||
ActivityState :: struct {
|
||||
@@ -76,7 +76,7 @@ ActivityAvailable :: () -> bool {
|
||||
}
|
||||
revision := storage_data_revision()
|
||||
generation := StoredDelegateGeneration()
|
||||
clock := ActivityFrameTime()
|
||||
clock := HostSeconds()
|
||||
if revision == activity_availability_revision && generation == activity_availability_delegate_generation &&
|
||||
clock >= activity_availability_checked && clock - activity_availability_checked < 0.25 {
|
||||
// Delegate expiry and identity checks remain live even when the
|
||||
@@ -217,7 +217,7 @@ ActivityPump :: (app: *InnerBreeze) {
|
||||
if app == null {
|
||||
return
|
||||
}
|
||||
clock := ActivityFrameTime()
|
||||
clock := HostSeconds()
|
||||
if clock >= account_activity.last_poll && clock - account_activity.last_poll < 0.25 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "achievement_locale.zi";
|
||||
#import, file "assets.zi";
|
||||
// Account-scoped, bounded source reconciliation and quiet presentation.
|
||||
@@ -35,7 +36,6 @@
|
||||
#import, file "../../apps/radio/radio_achievements.zi";
|
||||
|
||||
c :: #system_library "c";
|
||||
AchievementFrameTime :: () -> float64 #foreign c "GetTime";
|
||||
achievement_scan_revision: s64 = -1;
|
||||
achievement_scan_phase: s32;
|
||||
achievement_scan_offset: s32;
|
||||
@@ -220,7 +220,7 @@ AchievementDrawAlerts :: (app: *InnerBreeze) {
|
||||
else { BuilderPrint(*label, "%", LocaleText("achievement_unlocked")) }
|
||||
text := BuilderFinish(label)
|
||||
AchievementToastShow(*achievement_toast, text, LocaleText(TextUntilNul(entry.title_key[:])),
|
||||
AchievementIconShape(entry), AchievementFrameTime())
|
||||
AchievementIconShape(entry), HostSeconds())
|
||||
PackageFree(text)
|
||||
}
|
||||
if app.backgrounded != 0 {
|
||||
@@ -237,7 +237,7 @@ AchievementDrawAlerts :: (app: *InnerBreeze) {
|
||||
unused AchievementToastDraw(app.ui.session, *achievement_toast, AchievementToastProps.{
|
||||
.key = cast(u64)0x61636869657665,
|
||||
.viewport = Rectangle.{0.0, 0.0, cast(float32)app.ui.view_width, cast(float32)app.ui.view_height},
|
||||
.top = cast(float32)AppTitleBarHeight(), .scale = MetricsScale(), .now = AchievementFrameTime(),
|
||||
.top = cast(float32)AppTitleBarHeight(), .scale = MetricsScale(), .now = HostSeconds(),
|
||||
.seconds = AppNotificationToastSeconds, .plain = true,
|
||||
.fill = StyleTokenColor("surface"), .border = DarkenColor(StyleTokenColor("canvas"), 18),
|
||||
.accent = StyleTokenColor("accent")})
|
||||
|
||||
@@ -55,7 +55,6 @@ ListIcon :: #import "mingcute/mingcute_regular_list_check";
|
||||
EditIcon :: #import "mingcute/mingcute_regular_edit";
|
||||
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
|
||||
using AppNavRoute;
|
||||
using ButtonEmphasis;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_window_state.zi";
|
||||
#import, file "app_types.zi";
|
||||
#import, file "app_nav_state.zi";
|
||||
#import, file "app_launcher_state.zi";
|
||||
@@ -14,10 +15,6 @@
|
||||
#import, file "text_buffers.zi";
|
||||
#import, file "route_types.zi";
|
||||
#import, file "../platform/launcher_entry.zi";
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
raylib :: #system_library "raylib";
|
||||
LauncherWindowTitle :: (title: *u8) #foreign raylib "SetWindowTitle";
|
||||
}
|
||||
|
||||
launcher_pin_status: s32 = -1;
|
||||
launcher_pending_name: [25]u8;
|
||||
@@ -134,10 +131,7 @@ app_launcher_pump_request :: (app: *InnerBreeze) {
|
||||
bit := app_nav_route_bit(route)
|
||||
app.host_feature = ifx bit != 0 then bit else route
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
title: [256]u8
|
||||
if CopyCString(app_nav_route_label(route), title[:]) {
|
||||
LauncherWindowTitle(*title[0])
|
||||
}
|
||||
HostSetWindowTitle(app_nav_route_label(route))
|
||||
}
|
||||
launcher_pending_name[0] = 0
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "async_client"
|
||||
#import "auth"
|
||||
#import "text_buffer"
|
||||
@@ -34,7 +35,6 @@ SyncWorkerFree :: (ptr: *void) #foreign c "free";
|
||||
FormatLocaleText :: (out: *u8, out_size: s64, key: string) {
|
||||
SyncCopyText(out, out_size, LocaleText(key))
|
||||
}
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
#import, file "modal_rules.zi";
|
||||
#import, file "../core/types.zi";
|
||||
#import, file "app_types.zi";
|
||||
@@ -196,7 +196,7 @@ app_sync_record_result :: (result: s32) {
|
||||
g_sync.storage_recovery_attempted = false
|
||||
}
|
||||
if retry_is_temporary(result) && AppSyncNodeFailover() {
|
||||
g_sync.dirty_sync_at = GetTime() + 1.0
|
||||
g_sync.dirty_sync_at = HostSeconds() + 1.0
|
||||
}
|
||||
decision := sync_retry_decision(result,
|
||||
SettingsReadInt("sync_retry_attempt", 0))
|
||||
@@ -206,7 +206,7 @@ app_sync_record_result :: (result: s32) {
|
||||
}
|
||||
SettingsStoreInt("sync_retry_attempt", decision.attempt)
|
||||
if decision.delay > 0 {
|
||||
g_sync.retry_at = GetTime() + cast(float64)decision.delay
|
||||
g_sync.retry_at = HostSeconds() + cast(float64)decision.delay
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ app_social_record_result :: (result: s32) {
|
||||
}
|
||||
g_sync.social_retry_attempt = decision.attempt
|
||||
if decision.delay > 0 {
|
||||
g_sync.social_retry_at = GetTime() + cast(float64)decision.delay
|
||||
g_sync.social_retry_at = HostSeconds() + cast(float64)decision.delay
|
||||
g_sync.social_refresh_pending = 1
|
||||
}
|
||||
}
|
||||
@@ -753,7 +753,7 @@ app_ensure_sync_events :: (url: string) {
|
||||
}
|
||||
}
|
||||
#if WEB {
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
if AppTextFromCString(*g_sync_events_url[0], 512) != url {
|
||||
CloseRemoteEvents(*g_remote_events)
|
||||
g_sync_events_url[0] = cast(u8)0
|
||||
@@ -778,7 +778,7 @@ app_ensure_sync_events :: (url: string) {
|
||||
}
|
||||
}
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
if AppTextFromCString(*g_sync_events_url[0], 512) != url ||
|
||||
now >= g_sync_events_retry_at {
|
||||
unused AppCopyText(url, g_sync_events_url[:])
|
||||
@@ -851,9 +851,9 @@ app_apply_pending_social_refresh :: (app: *InnerBreeze) {
|
||||
action: [16]u8
|
||||
action_value: [96]u8
|
||||
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
|
||||
if GetTime() < g_sync.social_retry_at {
|
||||
if HostSeconds() < g_sync.social_retry_at {
|
||||
return
|
||||
}
|
||||
if g_sync.social_refresh_pending == 0 || app_background_sync_safe(app) == 0 || app_sync_user_idle(app, now) == 0 {
|
||||
@@ -1181,7 +1181,7 @@ app_auto_sync :: (app: *InnerBreeze) -> s32 {
|
||||
app_sync_url(*url[0], size_of(type_of(url))) == 0 {
|
||||
return 0
|
||||
}
|
||||
now = GetTime()
|
||||
now = HostSeconds()
|
||||
g_sync.last_input_at = now
|
||||
// New local work must get an attempt even while old charged content
|
||||
// waits for space. Repeated refusals without new work still stop.
|
||||
@@ -1297,7 +1297,7 @@ app_sync_pump :: (app: *InnerBreeze) {
|
||||
if SyncOnFrameThread() && app_practice_holds_frame_work(app) {
|
||||
return
|
||||
}
|
||||
now = GetTime()
|
||||
now = HostSeconds()
|
||||
app_sync_record_input(app, now)
|
||||
app_collect_finished_sync()
|
||||
app_collect_finished_social_refresh(app)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Drawing each frame: the current screen and its chrome, the Android
|
||||
// picture-in-picture window, and reloading graphics after a lost context.
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "../storage/dew.zi";
|
||||
#import, file "../storage/dew_rewards.zi";
|
||||
#import, file "../platform/dew_payment.zi";
|
||||
@@ -62,27 +63,34 @@ Layout :: #import "kryon/layout";
|
||||
#import, file "application_update.zi";
|
||||
|
||||
c :: #system_library "c";
|
||||
raylib_log :: #system_library "raylib";
|
||||
native_keep_display_awake :: (awake: bool) #foreign c;
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
#import "kryon/canvas_host"
|
||||
} else {
|
||||
#import "kryon/raylib_runtime"
|
||||
#if !#defined(DESKTOP_HOST) {
|
||||
#import "kryon/raylib_runtime"
|
||||
}
|
||||
}
|
||||
#import, file "../platform/host_window.zi";
|
||||
#import, file "../platform/host_frame.zi";
|
||||
|
||||
using NavigationPlacement;
|
||||
using ModalType;
|
||||
using ExerciseType;
|
||||
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
WindowRuntime :: #import "kryon/window_runtime";
|
||||
}
|
||||
PackageNow :: () -> s64 #foreign c "now_seconds";
|
||||
BeginMode2D :: (camera: Camera) #foreign raylib_log "BeginMode2D";
|
||||
EndMode2D :: () #foreign raylib_log "EndMode2D";
|
||||
BeginScissorMode :: (x: s32, y: s32, width: s32, height: s32) #foreign raylib_log "BeginScissorMode";
|
||||
EndScissorMode :: () #foreign raylib_log "EndScissorMode";
|
||||
// Raylib draws the frame through a camera and a scissor; Kryon's desktop
|
||||
// host scales its raster instead (HostSetRenderScale).
|
||||
#if !#defined(DESKTOP_HOST) {
|
||||
raylib_log :: #system_library "raylib";
|
||||
BeginMode2D :: (camera: Camera) #foreign raylib_log "BeginMode2D";
|
||||
EndMode2D :: () #foreign raylib_log "EndMode2D";
|
||||
BeginScissorMode :: (x: s32, y: s32, width: s32, height: s32) #foreign raylib_log "BeginScissorMode";
|
||||
EndScissorMode :: () #foreign raylib_log "EndScissorMode";
|
||||
}
|
||||
|
||||
LOG_INFO :: 3
|
||||
LOG_WARNING :: 4
|
||||
@@ -136,14 +144,14 @@ app_capture_route_transition :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
surface: FrameSurface
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) && !#defined(DESKTOP_HOST) {
|
||||
if app.ui.retained_target_active {
|
||||
surface = FrameSurfaceCopy(FrameSurface.{RetainedPreviousFrameTexture()})
|
||||
}
|
||||
}
|
||||
// Input can change the route while updateapp builds the destination.
|
||||
// Capture the last presented frame before app_finish_frame paints it.
|
||||
app_route_transition_capture(app, surface.texture, GetTime(), true)
|
||||
app_route_transition_capture(app, surface.texture, HostSeconds(), true)
|
||||
}
|
||||
|
||||
app_finish_frame :: (app: *InnerBreeze) {
|
||||
@@ -178,7 +186,7 @@ app_finish_frame :: (app: *InnerBreeze) {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
if status == 0 {
|
||||
AndroidAccessibilityFrame(app.ui.session, app.camera,
|
||||
WindowRuntime.WindowWidth(), WindowRuntime.WindowHeight(), GetTime())
|
||||
WindowRuntime.WindowWidth(), WindowRuntime.WindowHeight(), HostSeconds())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,7 +236,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
generation := picture_state >> 4
|
||||
if generation != app.session_window.system_generation {
|
||||
app.session_window.system_generation = generation
|
||||
app.session_window.system_last_tick = GetTime()
|
||||
app.session_window.system_last_tick = HostSeconds()
|
||||
}
|
||||
// Opening the floating window back into the app shows its practice,
|
||||
// not the page that was open behind the practice's in-app window.
|
||||
@@ -243,7 +251,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
app_draw_android_picture_window(app, viewport)
|
||||
return
|
||||
}
|
||||
app.session_window.system_last_tick = GetTime()
|
||||
app.session_window.system_last_tick = HostSeconds()
|
||||
}
|
||||
full_width = cast(s32)viewport.width
|
||||
full_height = cast(s32)viewport.height
|
||||
@@ -296,7 +304,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
content_w = 1
|
||||
}
|
||||
{
|
||||
now: float64 = GetTime()
|
||||
now: float64 = HostSeconds()
|
||||
changed := full_width != app_update_draw_last_full_w ||
|
||||
full_height != app_update_draw_last_full_h ||
|
||||
content_x != app_update_draw_last_content_x ||
|
||||
@@ -340,7 +348,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
return
|
||||
}
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
if AndroidAccessibilityInput(app.ui.session, GetTime()) {
|
||||
if AndroidAccessibilityInput(app.ui.session, HostSeconds()) {
|
||||
app.ui.pointer_active = true
|
||||
}
|
||||
}
|
||||
@@ -365,12 +373,16 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
app_capture_route_transition(app)
|
||||
app_breaks_draw_toast(app,
|
||||
Rectangle.{0.0, 0.0, cast(float32)view_width, cast(float32)view_height})
|
||||
app_route_transition_draw(app, logical_frame, GetTime())
|
||||
app_route_transition_draw(app, logical_frame, HostSeconds())
|
||||
app_finish_frame(app)
|
||||
} else {
|
||||
BeginScissorMode(cast(s32)viewport.x, cast(s32)viewport.y,
|
||||
full_width, full_height)
|
||||
BeginMode2D(app.camera)
|
||||
// Kryon's desktop host draws at the render scale UpdateDPI sets, and
|
||||
// its window is the viewport, so nothing needs a camera or clipping.
|
||||
#if !#defined(DESKTOP_HOST) {
|
||||
BeginScissorMode(cast(s32)viewport.x, cast(s32)viewport.y,
|
||||
full_width, full_height)
|
||||
BeginMode2D(app.camera)
|
||||
}
|
||||
Box.Draw(app.ui.session, content_canvas)
|
||||
profile_update_start = app_profile_now()
|
||||
updateapp(app)
|
||||
@@ -378,10 +390,12 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
app_capture_route_transition(app)
|
||||
app_breaks_draw_toast(app,
|
||||
Rectangle.{0.0, 0.0, cast(float32)view_width, cast(float32)view_height})
|
||||
app_route_transition_draw(app, logical_frame, GetTime())
|
||||
app_route_transition_draw(app, logical_frame, HostSeconds())
|
||||
app_finish_frame(app)
|
||||
EndMode2D()
|
||||
EndScissorMode()
|
||||
#if !#defined(DESKTOP_HOST) {
|
||||
EndMode2D()
|
||||
EndScissorMode()
|
||||
}
|
||||
}
|
||||
// A game played full screen keeps the display on; see main_platform.
|
||||
on_app := app.breathing.screen == ScreenNodeApp
|
||||
@@ -403,7 +417,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
if DewAvailable() {
|
||||
// The balance stays current on the Profile overview.
|
||||
dew_visible := app.breathing.screen == ScreenProfile && app.profile_tab == PROFILE_TAB_OVERVIEW
|
||||
DewTick(dew_visible, GetTime())
|
||||
DewTick(dew_visible, HostSeconds())
|
||||
DewRewardsTick()
|
||||
if DewTakeSyncRequest() {
|
||||
unused app_request_sync(app)
|
||||
@@ -465,18 +479,10 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
// practice pack opened.
|
||||
changes := AssetTakeChanges()
|
||||
if changes.all {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
InvalidateCanvasAssets()
|
||||
} else {
|
||||
InvalidateRaylibAssets()
|
||||
}
|
||||
HostInvalidatePictures()
|
||||
} else {
|
||||
for folder: changes.folders {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
InvalidateCanvasAssetsUnder(folder)
|
||||
} else {
|
||||
InvalidateRaylibAssetsUnder(folder)
|
||||
}
|
||||
HostInvalidatePicturesUnder(folder)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -498,11 +504,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
app.breathing.screen != ScreenHabitEdit && app.breathing.screen != ScreenHabitSessionEdit &&
|
||||
app_diary_save() {
|
||||
if AppsReloadFeatures(app.enabled_apps) {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
InvalidateCanvasAssets()
|
||||
} else {
|
||||
InvalidateRaylibAssets()
|
||||
}
|
||||
HostInvalidatePictures()
|
||||
app.package_revision = PackageRevision()
|
||||
app_diary_reset()
|
||||
app_update_app_navigation(app)
|
||||
@@ -515,7 +517,7 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
// with a stable 200-unit layout while the OS moves and resizes it.
|
||||
app_draw_android_picture_window :: (app: *InnerBreeze, viewport: Rectangle) {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
elapsed := now - app.session_window.system_last_tick
|
||||
app.session_window.system_last_tick = now
|
||||
// The in-app card must not replay the whole PiP interval on return.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#import, file "../platform/host_input.zi";
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "achievement_runtime.zi";
|
||||
#import, file "entity_management.zi";
|
||||
#import, file "background_audio.zi";
|
||||
@@ -80,9 +82,6 @@ using ExerciseType;
|
||||
using ButtonTone;
|
||||
using ButtonEmphasis;
|
||||
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
IsKeyPressed :: (key: s32) -> bool #foreign raylib_log "IsKeyPressed";
|
||||
IsKeyDown :: (key: s32) -> bool #foreign raylib_log "IsKeyDown";
|
||||
|
||||
updateapp :: (app: *InnerBreeze) {
|
||||
InbeManagementPump(app)
|
||||
@@ -198,13 +197,13 @@ updateapp :: (app: *InnerBreeze) {
|
||||
app_draw_return_bar(app)
|
||||
// Kryon gives the top overlay first refusal of Escape, before page
|
||||
// navigation or the idle-home quit shortcut can see that same press.
|
||||
escape_requested := IsKeyPressed(APP_KEY_ESCAPE) && !TreeEscapeCaptured(app.ui.session)
|
||||
back_requested := IsKeyPressed(APP_KEY_BACK) ||
|
||||
escape_requested := HostKeyPressed(APP_KEY_ESCAPE) && !TreeEscapeCaptured(app.ui.session)
|
||||
back_requested := HostKeyPressed(APP_KEY_BACK) ||
|
||||
((app.launcher_open || app.breathing.screen == ScreenNodeApp || (app.modal.active != 0 &&
|
||||
(app.modal.type == cast(ModalType)ModalStoragePlans ||
|
||||
app.modal.type == cast(ModalType)ModalDewTopUp))) && escape_requested)
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
if IsKeyPressed(KEY_BACKSPACE) && ((app.breathing.screen == ScreenStart && app.practice_tab != PRACTICE_TAB_PLAY) || app.breathing.screen == ScreenSession || app.breathing.screen == ScreenMeditation || app.breathing.screen == ScreenSunSalutation || app.breathing.screen == ScreenPatterns || app.breathing.screen == ScreenTaiChi || app.breathing.screen == ScreenAstralProjection || app.breathing.screen == ScreenWorkout) {
|
||||
if HostKeyPressed(KEY_BACKSPACE) && ((app.breathing.screen == ScreenStart && app.practice_tab != PRACTICE_TAB_PLAY) || app.breathing.screen == ScreenSession || app.breathing.screen == ScreenMeditation || app.breathing.screen == ScreenSunSalutation || app.breathing.screen == ScreenPatterns || app.breathing.screen == ScreenTaiChi || app.breathing.screen == ScreenAstralProjection || app.breathing.screen == ScreenWorkout) {
|
||||
back_requested = true
|
||||
}
|
||||
}
|
||||
@@ -234,7 +233,7 @@ updateapp :: (app: *InnerBreeze) {
|
||||
}
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
// Ctrl+Q quits from any screen; Esc quits only from idle home.
|
||||
if IsKeyPressed(KEY_Q) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)) {
|
||||
if HostKeyPressed(KEY_Q) && (HostKeyDown(KEY_LEFT_CONTROL) || HostKeyDown(KEY_RIGHT_CONTROL)) {
|
||||
app_request_desktop_quit(app)
|
||||
} else if !back_requested && escape_requested &&
|
||||
app.breathing.screen == ScreenStart &&
|
||||
@@ -432,7 +431,7 @@ app_network_pump :: (app: *InnerBreeze) {
|
||||
}
|
||||
ActivityPump(app)
|
||||
app_sync_pump(app)
|
||||
ListsNetworkTick(app, GetTime(), app.breathing.screen == ScreenEList ||
|
||||
ListsNetworkTick(app, HostSeconds(), app.breathing.screen == ScreenEList ||
|
||||
app.breathing.screen == ScreenNodeApp)
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
android_network_pump_end()
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// Logging and the shared peak sample for the app's audio meter.
|
||||
#import, file "../platform/app_trace.zi";
|
||||
#import "byte_text_linux"
|
||||
#import "c_string"
|
||||
|
||||
raylib :: #system_library "raylib";
|
||||
HostAudioTrace :: (level: s32, format: *u8,
|
||||
args: ..any) #foreign raylib "TraceLog";
|
||||
|
||||
AUDIO_ATOMIC_METER :: #defined(PLATFORM_DESKTOP) || #defined(ANDROID_BUILD)
|
||||
#if AUDIO_ATOMIC_METER {
|
||||
atomic :: #system_library "atomic";
|
||||
@@ -21,49 +18,17 @@ AUDIO_ATOMIC_METER :: #defined(PLATFORM_DESKTOP) || #defined(ANDROID_BUILD)
|
||||
|
||||
audio_meter_peak_milli: s32;
|
||||
|
||||
AudioTraceBytes :: (message: string) -> *u8 {
|
||||
if message.count == 0 {
|
||||
return null
|
||||
}
|
||||
descriptor: *TextDescriptor = cast(*TextDescriptor)(*message)
|
||||
return descriptor.data
|
||||
}
|
||||
|
||||
AudioTraceLength :: (message: string) -> s32 {
|
||||
if message.count > 2147483647 {
|
||||
return 2147483647
|
||||
}
|
||||
return cast(s32)message.count
|
||||
}
|
||||
|
||||
#program_export
|
||||
app_audio_trace :: (level: s32, message: string) {
|
||||
format: [8]u8
|
||||
empty: [1]u8 = .[0]
|
||||
if !CopyCString("%.*s", format[:]) {
|
||||
return
|
||||
}
|
||||
data := AudioTraceBytes(message)
|
||||
if data == null {
|
||||
data = *empty[0]
|
||||
}
|
||||
HostAudioTrace(level, *format[0], AudioTraceLength(message), data)
|
||||
TraceLog(level, message)
|
||||
}
|
||||
|
||||
#program_export
|
||||
app_audio_trace_frames :: (level: s32, message: string,
|
||||
frames: s32) {
|
||||
format: [24]u8
|
||||
empty: [1]u8 = .[0]
|
||||
if !CopyCString("%.*s (%d frames)", format[:]) {
|
||||
return
|
||||
}
|
||||
data := AudioTraceBytes(message)
|
||||
if data == null {
|
||||
data = *empty[0]
|
||||
}
|
||||
HostAudioTrace(level, *format[0], AudioTraceLength(message),
|
||||
data, frames)
|
||||
line: Vec(u8)
|
||||
BuilderPrint(*line, "% (% frames)", message, frames)
|
||||
TraceLog(level, BuilderFinish(line))
|
||||
}
|
||||
|
||||
#program_export
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// One QR code connection at a time, advanced by the frame loop. The device
|
||||
// showing the code polls Daochi's link mailbox for the other device; the
|
||||
// scanning device answers. See src/storage/device_link.zi for the protocol.
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "keys"
|
||||
#import "json_scan"
|
||||
#import "text"
|
||||
@@ -20,7 +21,6 @@
|
||||
#import, file "../platform/app_trace.zi";
|
||||
|
||||
c :: #system_library "c";
|
||||
DeviceLinkClock :: () -> float64 #foreign c "GetTime";
|
||||
DeviceLinkGetenv :: (name: *u8) -> *u8 #foreign c "getenv";
|
||||
DeviceLinkRemove :: (path: *u8) -> s32 #foreign c "remove";
|
||||
|
||||
@@ -139,8 +139,8 @@ DeviceLinkShow :: () -> bool {
|
||||
}
|
||||
for byte, index: text { device_link.code[index] = byte }
|
||||
device_link.stage = cast(DeviceLinkStage)DeviceLinkShowing
|
||||
device_link.expires_at = DeviceLinkClock() + DEVICE_LINK_LIFETIME
|
||||
device_link.next_poll = DeviceLinkClock()
|
||||
device_link.expires_at = HostSeconds() + DEVICE_LINK_LIFETIME
|
||||
device_link.next_poll = HostSeconds()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ DeviceLinkScan :: (text: string) -> bool {
|
||||
DeviceLinkFail("device_link_failed")
|
||||
return false
|
||||
}
|
||||
device_link.expires_at = DeviceLinkClock() + DEVICE_LINK_LIFETIME
|
||||
device_link.expires_at = HostSeconds() + DEVICE_LINK_LIFETIME
|
||||
if code.sends {
|
||||
// The other device holds the account: send our key and show the
|
||||
// digits it must match before it sends anything.
|
||||
@@ -376,7 +376,7 @@ DeviceLinkPump :: () {
|
||||
if !waiting {
|
||||
return
|
||||
}
|
||||
now := DeviceLinkClock()
|
||||
now := HostSeconds()
|
||||
if now > device_link.expires_at {
|
||||
DeviceLinkFail("device_link_expired")
|
||||
return
|
||||
|
||||
+10
-5
@@ -3,12 +3,13 @@
|
||||
#import "geometry"
|
||||
#import, file "../platform/environment.zi";
|
||||
#import, file "../platform/raylib_host.zi";
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
#import, file "../platform/host_window.zi";
|
||||
#if #defined(PLATFORM_WEB) == false && !#defined(DESKTOP_HOST) {
|
||||
#import "kryon/Raylib"
|
||||
raylib :: #system_library "raylib";
|
||||
IsWindowReady :: () -> bool #foreign raylib;
|
||||
GetWindowScaleDPI :: () -> Vector2 #foreign raylib;
|
||||
}
|
||||
raylib :: #system_library "raylib";
|
||||
IsWindowReady :: () -> bool #foreign raylib;
|
||||
GetWindowScaleDPI :: () -> Vector2 #foreign raylib;
|
||||
|
||||
using DPIPlatform;
|
||||
|
||||
@@ -72,7 +73,11 @@ UpdateDPI :: (view_width: s32, view_height: s32) {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
SetPaintPixelScale(dpi_state.render_scale)
|
||||
} else {
|
||||
RaylibSetZoom(dpi_state.render_scale)
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
HostSetRenderScale(dpi_state.render_scale)
|
||||
} else {
|
||||
RaylibSetZoom(dpi_state.render_scale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#import "typeface_source"
|
||||
// Kryon's desktop host loads the faces with Pango and fontconfig.
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
#import "cairo_typefaces"
|
||||
}
|
||||
#import, file "app_types.zi";
|
||||
#import, file "font_assets.zi";
|
||||
#import, file "assets.zi";
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// while it types into the bubble, and hovers with gently beating wings until
|
||||
// the step changes. One guide shows at a time, so her state lives here
|
||||
// between frames; GuideOverlay draws her and the bubble.
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "drawing_props"
|
||||
#import "geometry"
|
||||
#import "guide"
|
||||
@@ -23,7 +24,6 @@
|
||||
Grapheme :: #import "std/grapheme";
|
||||
|
||||
raylib :: #system_library "raylib";
|
||||
GetTime :: () -> float64 #foreign raylib;
|
||||
|
||||
// Lumi's flight cycle: eight frames facing right, then the same eight facing
|
||||
// left, each 192 by 157 pixels on a 200 by 165 grid four frames wide.
|
||||
@@ -133,7 +133,7 @@ LumiGuideSameVoice :: (key: string) -> bool {
|
||||
}
|
||||
|
||||
LumiGuideNow :: () -> float64 {
|
||||
return GetTime()
|
||||
return HostSeconds()
|
||||
}
|
||||
|
||||
// Milliseconds since the step began, or the pinned moment of a screenshot.
|
||||
|
||||
@@ -8,6 +8,7 @@ Scroll :: #import "kryon/scroll";
|
||||
Slider :: #import "kryon/slider";
|
||||
Text :: #import "kryon/text";
|
||||
Toast :: #import "kryon/toast";
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "kryon/control_props"
|
||||
#import, file "modal_rules.zi";
|
||||
#import, file "../storage/state.zi";
|
||||
@@ -56,8 +57,6 @@ media_compression_due: float64;
|
||||
media_compression_scroll: s32;
|
||||
media_compression_toast: Toast.ToastState;
|
||||
media_compression_text: FrameTextStore;
|
||||
media_compression_clock_library :: #system_library "c";
|
||||
MediaCompressionClock :: () -> float64 #foreign media_compression_clock_library "GetTime";
|
||||
|
||||
MediaCompressionScreen :: (app: *InnerBreeze) -> bool {
|
||||
return ImagePreview.ImageAVIFEncodingAvailable() &&
|
||||
@@ -76,7 +75,7 @@ MediaCompressionDropPreview :: (app: *InnerBreeze) {
|
||||
MediaCompressionInvalidate :: (app: *InnerBreeze) {
|
||||
media_compression_generation += 1
|
||||
MediaCompressionDropPreview(app)
|
||||
media_compression_due = MediaCompressionClock() + 0.25
|
||||
media_compression_due = HostSeconds() + 0.25
|
||||
}
|
||||
|
||||
MediaCompressionRefresh :: () {
|
||||
@@ -173,14 +172,14 @@ MediaCompressionPump :: (app: *InnerBreeze) {
|
||||
if opened && media_compression_work == null && media_compression_hash.count > 0 &&
|
||||
media_compression_notice != "media_compression_failed" {
|
||||
AppRequestSmoothFrames(2)
|
||||
if MediaCompressionClock() < media_compression_due {
|
||||
if HostSeconds() < media_compression_due {
|
||||
return
|
||||
}
|
||||
source := MediaCompressionSource(media_compression_hash)
|
||||
if source.count == 0 {
|
||||
if MediaCompressionSourcePending(media_compression_hash) {
|
||||
media_compression_notice = "app_loading_pictures"
|
||||
media_compression_due = MediaCompressionClock() + 1.0
|
||||
media_compression_due = HostSeconds() + 1.0
|
||||
} else {
|
||||
media_compression_notice = "media_compression_failed"
|
||||
}
|
||||
@@ -214,7 +213,7 @@ MediaCompressionOfferDraw :: (app: *InnerBreeze) {
|
||||
.viewport = Rectangle.{0.0, 0.0, cast(float32)app.ui.view_width,
|
||||
cast(float32)app.ui.view_height}, .state = media_compression_toast,
|
||||
.message = message, .action_label = LocaleText("media_compression_review"),
|
||||
.seconds = 12.0, .now_seconds = MediaCompressionClock(), .scale = MetricsScale()})
|
||||
.seconds = 12.0, .now_seconds = HostSeconds(), .scale = MetricsScale()})
|
||||
media_compression_toast = result.state
|
||||
if result.visible {
|
||||
AppRequestSmoothFrames(2)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
// Embedded in a supervising host, such as Harmony's Sessions window, Inbe
|
||||
// draws in that host's theme by default; started on its own it keeps its own
|
||||
// theme. Kryon's host palette reader checks that the host started Inbe and
|
||||
@@ -32,7 +33,6 @@ parent_theme_next_poll: float64;
|
||||
SystemHost :: #import "kryon/SystemThemeHostLinux";
|
||||
parent_theme_c :: #system_library "c";
|
||||
ParentThemeEnvironment :: (name: *u8) -> *u8 #foreign parent_theme_c "getenv";
|
||||
ParentThemeNow :: () -> float64 #foreign parent_theme_c "GetTime";
|
||||
|
||||
// The host names the window it embeds Inbe in; a standalone start has none.
|
||||
ParentThemeHosted :: () -> bool {
|
||||
@@ -93,7 +93,7 @@ ParentThemeSame :: (left: ParentTheme, right: ParentTheme) -> bool {
|
||||
// The host's current theme, read again at most every quarter second.
|
||||
ParentThemeCurrent :: () -> ParentTheme {
|
||||
#if PARENT_THEME_HOST {
|
||||
now := ParentThemeNow()
|
||||
now := HostSeconds()
|
||||
if parent_theme_checked && now < parent_theme_next_poll {
|
||||
return parent_theme
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "entity/dew_model"
|
||||
#import "entity/dew_play"
|
||||
#import, file "../habits/habit_icons.zi";
|
||||
@@ -81,7 +82,6 @@ using AppMainTab;
|
||||
using AppNavRoute;
|
||||
using ExerciseType;
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
using HabitSyncMode;
|
||||
using SyncResult;
|
||||
using SyncAccountLocalDataChoice;
|
||||
@@ -119,18 +119,15 @@ ScreenshotOwned :: (product: string) -> bool {
|
||||
return true
|
||||
}
|
||||
|
||||
screenshot_clock :: #system_library "raylib";
|
||||
ScreenshotClockNow :: () -> float64 #foreign screenshot_clock "GetTime";
|
||||
ScreenshotClockWait :: (seconds: float64) #foreign screenshot_clock "WaitTime";
|
||||
|
||||
// Cached practice content opens asynchronously. Screenshot fixtures must
|
||||
// finish that read before they select a course or start a session.
|
||||
ScreenshotPracticeReady :: (app: *InnerBreeze, practice: s32) {
|
||||
deadline := ScreenshotClockNow() + 10.0
|
||||
deadline := HostSeconds() + 10.0
|
||||
PracticeDownloadsPump(practice, app.voice_narration_enabled != 0,
|
||||
app.guide_narration_enabled != 0, true)
|
||||
while !PracticeContentReady(practice) && ScreenshotClockNow() < deadline {
|
||||
ScreenshotClockWait(0.01)
|
||||
while !PracticeContentReady(practice) && HostSeconds() < deadline {
|
||||
HostWait(0.01)
|
||||
PracticeDownloadsPump(practice, app.voice_narration_enabled != 0,
|
||||
app.guide_narration_enabled != 0, true)
|
||||
}
|
||||
@@ -1118,7 +1115,7 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
ProfileTopUpOpen(app)
|
||||
if scene_text == "dew_play_wait" {
|
||||
unused AppCopyText("{\"ready\":false,\"products\":[],\"purchases\":[]}", dew_play.state[:])
|
||||
profile_play_prices_deadline = GetTime() + 0.5
|
||||
profile_play_prices_deadline = HostSeconds() + 0.5
|
||||
} else {
|
||||
unused AppCopyText("{\"ready\":true,\"products\":[{\"id\":\"dew_10\",\"price\":\"$0.72\",\"micros\":720000,\"currency\":\"USD\"},{\"id\":\"dew_100\",\"price\":\"$6.90\",\"micros\":6900000,\"currency\":\"USD\"},{\"id\":\"dew_500\",\"price\":\"$33.00\",\"micros\":33000000,\"currency\":\"USD\"},{\"id\":\"dew_1000\",\"price\":\"$63.00\",\"micros\":63000000,\"currency\":\"USD\"},{\"id\":\"dew_5000\",\"price\":\"$300.00\",\"micros\":300000000,\"currency\":\"USD\"}],\"purchases\":[]}", dew_play.state[:])
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// A running practice keeps going in a small window while another app is
|
||||
// open, and the navigation slides out of the way while a practice runs.
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "app_types.zi";
|
||||
#import, file "../core/types.zi";
|
||||
#import, file "session_screen.zi";
|
||||
@@ -13,7 +14,6 @@
|
||||
#import "geometry"
|
||||
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
|
||||
using AppMainTab;
|
||||
using AppNavRoute;
|
||||
@@ -29,7 +29,7 @@ app_session_window_open :: (app: *InnerBreeze) -> bool {
|
||||
return false
|
||||
}
|
||||
app.session_window.screen = app.breathing.screen
|
||||
app.session_window.last_tick = GetTime()
|
||||
app.session_window.last_tick = HostSeconds()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ app_session_nav_update :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
window := *app.session_window
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
step := cast(float32)(now - window.nav_frame_time)
|
||||
window.nav_frame_time = now
|
||||
if step < 0.0 || step > 0.1 {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// The running practice in its small window: advancing it while another
|
||||
// app is open, and the window that returns to it or ends it.
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "app_types.zi";
|
||||
#import, file "../core/types.zi";
|
||||
#import, file "session_screen.zi";
|
||||
@@ -32,7 +33,6 @@ Text :: #import "kryon/text";
|
||||
#import "widget_kind"
|
||||
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
|
||||
using ButtonEmphasis;
|
||||
using ButtonTone;
|
||||
@@ -172,7 +172,7 @@ app_session_window_tick :: (app: *InnerBreeze) {
|
||||
if app == null || app.session_window.screen == ScreenStart {
|
||||
return
|
||||
}
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
elapsed := now - app.session_window.last_tick
|
||||
app.session_window.last_tick = now
|
||||
// A finished practice shows its results; a practice shown again by any
|
||||
@@ -345,7 +345,7 @@ session_window_breathe_button :: (app: *InnerBreeze, bounds: Rectangle) -> bool
|
||||
// A tap on the window while the practice is set to double tap to breathe:
|
||||
// the second tap in quick succession breathes.
|
||||
session_window_breathe_tap :: (app: *InnerBreeze, practice: *PracticeDefinition) {
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
last := app.breath_tap_last_time
|
||||
if last > 0.0 && now - last <= SESSION_WINDOW_DOUBLE_TAP_SECONDS {
|
||||
app.breath_tap_last_time = 0.0
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Inbe supplies account storage and platform services to the shared Apps
|
||||
// runtime. The shared package alone owns nested VM lifecycle and navigation.
|
||||
#import, file "../platform/host_window_state.zi";
|
||||
#import, file "../platform/app_trace.zi";
|
||||
#import "apps/host"
|
||||
#import "apps/preparation"
|
||||
@@ -55,8 +56,6 @@ Legacy :: #import "apps/node_types";
|
||||
#import, file "../app/current_app.zi";
|
||||
#import, file "../app/app_types.zi";
|
||||
#import, file "../core/types.zi";
|
||||
notification_raylib :: #system_library "raylib";
|
||||
NodeNotificationWindowFocused :: () -> bool #foreign notification_raylib "IsWindowFocused";
|
||||
|
||||
using HostValueKind;
|
||||
|
||||
@@ -207,7 +206,7 @@ NodeTreeNotificationFocused :: (context: *void, node: *AppNode) -> bool {
|
||||
app.modal.active != 0 || app.launcher_open {
|
||||
return false
|
||||
}
|
||||
return NodeNotificationWindowFocused()
|
||||
return HostWindowFocused()
|
||||
}
|
||||
|
||||
NodeTreeAllows :: (context: *void, node: *AppNode, name: string) -> bool {
|
||||
|
||||
+20
-34
@@ -1,17 +1,8 @@
|
||||
c :: #system_library "c";
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "../platform/raylib_host.zi";
|
||||
raylib :: #system_library "raylib";
|
||||
GetTime :: () -> float64 #foreign raylib;
|
||||
GetMouseWheelMove :: () -> float32 #foreign raylib;
|
||||
GetMouseDelta :: () -> Vector2 #foreign raylib;
|
||||
IsKeyPressed :: (key: s32) -> bool #foreign raylib;
|
||||
IsWindowFocused :: () -> bool #foreign raylib;
|
||||
ClearWindowState :: (flags: u32) #foreign raylib;
|
||||
RestoreWindow :: () #foreign raylib;
|
||||
SetWindowFocused :: () #foreign raylib;
|
||||
GetCurrentMonitor :: () -> s32 #foreign raylib;
|
||||
GetMonitorWidth :: (monitor: s32) -> s32 #foreign raylib;
|
||||
GetMonitorHeight :: (monitor: s32) -> s32 #foreign raylib;
|
||||
#import, file "../platform/host_input.zi";
|
||||
#import, file "../platform/host_window_state.zi";
|
||||
#import, file "../habits/habit_types.zi";
|
||||
WEB :: #defined(PLATFORM_WEB)
|
||||
#import, file "../core/types.zi";
|
||||
@@ -52,7 +43,11 @@ Toast :: #import "kryon/toast";
|
||||
#import, file "../app/locale.zi";
|
||||
#import, file "../app/app_route_state.zi";
|
||||
#import, file "../app/app_modal_state.zi";
|
||||
#import "raylib_secondary_window"
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
#import "desktop_secondary_window"
|
||||
} else {
|
||||
#import "raylib_secondary_window"
|
||||
}
|
||||
#import "idle_time"
|
||||
#import "text_measure"
|
||||
#import "text_align"
|
||||
@@ -108,7 +103,7 @@ app_breaks_draw_toast :: (app: *InnerBreeze, viewport: Rectangle) {
|
||||
props.state = break_toast_state
|
||||
props.message = break_toast_request
|
||||
props.seconds = AppNotificationToastSeconds
|
||||
props.now_seconds = GetTime()
|
||||
props.now_seconds = HostSeconds()
|
||||
props.scale = GetDPIScale()
|
||||
break_toast_state = Toast.Draw(app.ui.session, props).state
|
||||
break_toast_request = ""
|
||||
@@ -213,22 +208,17 @@ break_persist_daily_state :: (app: *InnerBreeze) {
|
||||
}
|
||||
|
||||
break_fallback_pointer_seen :: () -> bool {
|
||||
wheel := cast(s32)(GetMouseWheelMove() * 1000.0f)
|
||||
wheel := cast(s32)(HostWheel().y * 1000.0f)
|
||||
if wheel != 0 {
|
||||
return true
|
||||
}
|
||||
dx: float32 = GetMouseDelta().x
|
||||
dy: float32 = GetMouseDelta().y
|
||||
if dx != 0.0f || dy != 0.0f {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return HostPointerMoved()
|
||||
}
|
||||
|
||||
break_fallback_key_seen :: () -> bool {
|
||||
k: s32 = KEY_SPACE
|
||||
while k <= KEY_KB_MENU {
|
||||
if IsKeyPressed(k) {
|
||||
if HostKeyPressed(k) {
|
||||
return true
|
||||
}
|
||||
k += 1
|
||||
@@ -246,7 +236,7 @@ break_sample_activity :: (app: *InnerBreeze, idle_ms_out: *s32) -> s32 {
|
||||
input.idle_ms = idle_ms
|
||||
input.frame = app.breathing.frame
|
||||
if idle_ms < 0 {
|
||||
input.focused = IsWindowFocused()
|
||||
input.focused = HostWindowFocused()
|
||||
if input.focused {
|
||||
input.key_pressed = break_fallback_key_seen()
|
||||
input.pointer_active = break_fallback_pointer_seen()
|
||||
@@ -290,9 +280,7 @@ break_engine_open_window :: (app: *InnerBreeze, t: s32) {
|
||||
// The app-owned secondary window remains available on Wayland, where
|
||||
// a global keyboard grab is not available.
|
||||
if IsWaylandSession() {
|
||||
ClearWindowState(cast(u32)128)
|
||||
RestoreWindow()
|
||||
SetWindowFocused()
|
||||
HostRestoreAndFocusWindow()
|
||||
}
|
||||
}
|
||||
app.break_window_taken = 1
|
||||
@@ -331,9 +319,9 @@ app_breaks_window_update :: (app: *InnerBreeze) {
|
||||
if scale <= 0 || scale > 8 {
|
||||
scale = 1
|
||||
}
|
||||
monitor := GetCurrentMonitor()
|
||||
win_w := GetMonitorWidth(monitor) * 60 / 100
|
||||
win_h := GetMonitorHeight(monitor) * 66 / 100
|
||||
monitor_width, monitor_height := HostMonitorSize()
|
||||
win_w := monitor_width * 60 / 100
|
||||
win_h := monitor_height * 66 / 100
|
||||
// The Windows RGFW/OpenGL 1.1 compatibility context can reject large
|
||||
// framebuffer objects (notably on VMs and high-DPI displays). Keep the
|
||||
// auxiliary render target inside the broadly supported 1024px range.
|
||||
@@ -528,7 +516,7 @@ app_breaks_update :: (app: *InnerBreeze) {
|
||||
#if DESKTOP {
|
||||
idle_ms: s32 = 0
|
||||
active := break_sample_activity(app, *idle_ms)
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
elapsed: float32 = 0.0f
|
||||
ticks: s32 = 0
|
||||
|
||||
@@ -783,9 +771,7 @@ app_breaks_open_habits :: (app: *InnerBreeze, t: s32) {
|
||||
app.habits.scroll = 0
|
||||
app.habits.focus_selected_tab = 1
|
||||
#if DESKTOP {
|
||||
ClearWindowState(cast(u32)128)
|
||||
RestoreWindow()
|
||||
SetWindowFocused()
|
||||
HostRestoreAndFocusWindow()
|
||||
}
|
||||
app_switch_screen(app, ScreenHabits)
|
||||
}
|
||||
@@ -886,7 +872,7 @@ app_breaks_hud_update :: (app: *InnerBreeze) {
|
||||
|
||||
// The HUD content changes on timer ticks, drags, and clicks. Present
|
||||
// at about 2 Hz to avoid unnecessary texture readback and window blits.
|
||||
now := GetTime()
|
||||
now := HostSeconds()
|
||||
if app.break_hud_last_present <= 0 || now - app.break_hud_last_present >= 0.45 {
|
||||
app.break_hud_last_present = now
|
||||
if BeginSecondaryWindow(break_hud) {
|
||||
|
||||
+13
-6
@@ -1,4 +1,3 @@
|
||||
WindowRuntime :: #import "kryon/window_runtime";
|
||||
#import "kryon/application_entry"
|
||||
#import, file "apps/shared_state.zi";
|
||||
#import, file "apps/module_host.zi";
|
||||
@@ -9,6 +8,7 @@ WindowRuntime :: #import "kryon/window_runtime";
|
||||
#import, file "app/application_close.zi";
|
||||
#import, file "app/current_app.zi";
|
||||
#import, file "platform/raylib_host.zi";
|
||||
#import, file "platform/host_window.zi";
|
||||
#import, file "platform/app_trace.zi";
|
||||
#import "android_jni"
|
||||
// The desktop notification host; Android and the browser have their own.
|
||||
@@ -37,7 +37,7 @@ destroy_app_window :: () {
|
||||
}
|
||||
app_destroy(cast(*void)*app)
|
||||
SetCurrentApp(null)
|
||||
WindowRuntime.CloseNativeWindow()
|
||||
HostCloseWindow()
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ run_screenshot_if_requested :: () -> s32 {
|
||||
TraceLog(LOG_INFO, "APP: quit requested by shutdown signal")
|
||||
quit = 1
|
||||
}
|
||||
if (WindowRuntime.WindowHidden() || WindowRuntime.WindowMinimized()) && desktop_tray_ready() == 0 &&
|
||||
if (HostWindowHidden() || HostWindowMinimized()) && desktop_tray_ready() == 0 &&
|
||||
!app.session_window.detached {
|
||||
TraceLog(LOG_INFO, "APP: tray indicator unavailable; stopping background execution")
|
||||
quit = 1
|
||||
@@ -135,13 +135,13 @@ run_screenshot_if_requested :: () -> s32 {
|
||||
|
||||
while ShutdownRequested() == 0 && !quit {
|
||||
#if #defined(PLATFORM_DESKTOP) {
|
||||
if (WindowRuntime.WindowHidden() || WindowRuntime.WindowMinimized()) && !app.session_window.detached {
|
||||
if (HostWindowHidden() || HostWindowMinimized()) && !app.session_window.detached {
|
||||
TraceLog(LOG_INFO, "APP: no tray indicator; stopping background execution")
|
||||
break
|
||||
}
|
||||
}
|
||||
DrawFrame(*app)
|
||||
if WindowRuntime.WindowClosing() || TakeWindowCloseRequest() != 0 ||
|
||||
if HostWindowClosing() || TakeWindowCloseRequest() != 0 ||
|
||||
ShutdownRequested() != 0 || app.request_quit != 0 {
|
||||
quit = true
|
||||
}
|
||||
@@ -162,7 +162,14 @@ run_application :: (argc: s32, argv: **u8) -> s32 {
|
||||
window_size = InitialWindowSize()
|
||||
ConfigureWindow()
|
||||
|
||||
InitWindow(window_size.width, window_size.height, WindowTitle())
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
if !HostOpenWindow(window_size.width, window_size.height, WindowTitle()) {
|
||||
TraceLog(5, "APP: the desktop window could not open")
|
||||
return 1
|
||||
}
|
||||
} else {
|
||||
InitWindow(window_size.width, window_size.height, WindowTitle())
|
||||
}
|
||||
if FinishWindowSetup() == 0 {
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ LOG_ERROR :: 5
|
||||
#import, file "app_trace.zi";
|
||||
#import, file "host_input.zi";
|
||||
#import, file "host_window.zi";
|
||||
#import, file "host_frame.zi";
|
||||
app_getenv_bytes :: (name: *u8) -> *u8 #foreign c;
|
||||
#import, file "../app/app_types.zi";
|
||||
#import, file "../screens/elist_types.zi";
|
||||
@@ -702,15 +703,16 @@ CaptureScreenshot :: (app: *InnerBreeze) -> s32 {
|
||||
}
|
||||
|
||||
output := AppTextFromCString(*request.output[0], 512)
|
||||
saved := false
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
saved := HostSaveFramePng(output)
|
||||
saved = HostSaveFramePng(output)
|
||||
} else {
|
||||
capture: RaylibImage = LoadImageFromScreen()
|
||||
if capture.data == null {
|
||||
TraceLog(LOG_ERROR, "APP: screenshot readback failed")
|
||||
return -1
|
||||
}
|
||||
saved := ExportImage(capture, output)
|
||||
saved = ExportImage(capture, output)
|
||||
UnloadImage(capture)
|
||||
}
|
||||
return ifx (saved) then (1) else (-1)
|
||||
|
||||
+85
-59
@@ -1,74 +1,100 @@
|
||||
#import, file "../app/assets.zi";
|
||||
|
||||
asset_file_host :: #system_library "c";
|
||||
asset_file_raylib :: #system_library "raylib";
|
||||
// Embedded assets for the host's picture and font loaders. Kryon's desktop
|
||||
// raster reads an embedded asset's bytes from memory and any other path from
|
||||
// disk; raylib reads both through one load callback.
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Assets :: #import "cairo_assets";
|
||||
#import "c_string"
|
||||
#import "byte_text_linux"
|
||||
|
||||
AssetFileCallback :: #type (*u8, *s32) -> *u8 #c_call;
|
||||
InstallAssetFileCallback :: (callback: AssetFileCallback) #foreign asset_file_raylib "SetLoadFileDataCallback";
|
||||
AssetFileAllocate :: (size: u32) -> *u8 #foreign asset_file_raylib "MemAlloc";
|
||||
AssetFileFree :: (bytes: *u8) #foreign asset_file_raylib "MemFree";
|
||||
AssetFileCopy :: (output: *u8, source: *u8,
|
||||
count: usize) -> *u8 #foreign asset_file_host "memcpy";
|
||||
AssetFileOpen :: (path: *u8, mode: *u8) -> *void #foreign asset_file_host "fopen";
|
||||
AssetFileRead :: (output: *u8, size: usize, count: usize,
|
||||
file: *void) -> usize #foreign asset_file_host "fread";
|
||||
AssetFileClose :: (file: *void) -> s32 #foreign asset_file_host "fclose";
|
||||
AssetFileLength :: (path: *u8) -> s32 #foreign asset_file_raylib "GetFileLength";
|
||||
// The bytes of an asset embedded in the executable; empty for other
|
||||
// paths, which the raster then reads from disk.
|
||||
ReadEmbeddedAsset :: (path: string) -> string {
|
||||
name: [4096]u8
|
||||
if !CopyCString(path, name[:]) {
|
||||
return ""
|
||||
}
|
||||
embedded := asset_lookup(*name[0])
|
||||
if !embedded.found || embedded.data == null || embedded.size == 0 {
|
||||
return ""
|
||||
}
|
||||
return TextFromBytes(BytesFromPointer(embedded.data, cast(u64)embedded.size))
|
||||
}
|
||||
|
||||
// raylib owns and frees the returned allocation. Embedded bytes remain
|
||||
// immutable, so each successful read returns a separate owned copy.
|
||||
#scope_export
|
||||
ReadAssetFile :: (path: *u8, size: *s32) -> *u8 {
|
||||
if size == null {
|
||||
return null
|
||||
InstallAssetFiles :: () {
|
||||
reader: Assets.RasterAssetRead = ReadEmbeddedAsset
|
||||
Assets.RasterUseAssets(reader)
|
||||
}
|
||||
size.* = 0
|
||||
if path == null || path[0] == 0 {
|
||||
return null
|
||||
}
|
||||
embedded := asset_lookup(path)
|
||||
if embedded.found {
|
||||
if embedded.data == null || embedded.size == 0 ||
|
||||
embedded.size > cast(usize)2147483647 {
|
||||
} else {
|
||||
asset_file_host :: #system_library "c";
|
||||
asset_file_raylib :: #system_library "raylib";
|
||||
|
||||
AssetFileCallback :: #type (*u8, *s32) -> *u8 #c_call;
|
||||
InstallAssetFileCallback :: (callback: AssetFileCallback) #foreign asset_file_raylib "SetLoadFileDataCallback";
|
||||
AssetFileAllocate :: (size: u32) -> *u8 #foreign asset_file_raylib "MemAlloc";
|
||||
AssetFileFree :: (bytes: *u8) #foreign asset_file_raylib "MemFree";
|
||||
AssetFileCopy :: (output: *u8, source: *u8,
|
||||
count: usize) -> *u8 #foreign asset_file_host "memcpy";
|
||||
AssetFileOpen :: (path: *u8, mode: *u8) -> *void #foreign asset_file_host "fopen";
|
||||
AssetFileRead :: (output: *u8, size: usize, count: usize,
|
||||
file: *void) -> usize #foreign asset_file_host "fread";
|
||||
AssetFileClose :: (file: *void) -> s32 #foreign asset_file_host "fclose";
|
||||
AssetFileLength :: (path: *u8) -> s32 #foreign asset_file_raylib "GetFileLength";
|
||||
|
||||
// raylib owns and frees the returned allocation. Embedded bytes remain
|
||||
// immutable, so each successful read returns a separate owned copy.
|
||||
ReadAssetFile :: (path: *u8, size: *s32) -> *u8 {
|
||||
if size == null {
|
||||
return null
|
||||
}
|
||||
bytes := AssetFileAllocate(cast(u32)embedded.size)
|
||||
size.* = 0
|
||||
if path == null || path[0] == 0 {
|
||||
return null
|
||||
}
|
||||
embedded := asset_lookup(path)
|
||||
if embedded.found {
|
||||
if embedded.data == null || embedded.size == 0 ||
|
||||
embedded.size > cast(usize)2147483647 {
|
||||
return null
|
||||
}
|
||||
bytes := AssetFileAllocate(cast(u32)embedded.size)
|
||||
if bytes == null {
|
||||
return null
|
||||
}
|
||||
AssetFileCopy(bytes, embedded.data, embedded.size)
|
||||
size.* = cast(s32)embedded.size
|
||||
return bytes
|
||||
}
|
||||
|
||||
length := AssetFileLength(path)
|
||||
if length <= 0 {
|
||||
return null
|
||||
}
|
||||
mode: [3]u8
|
||||
mode[0] = #char "r"
|
||||
mode[1] = #char "b"
|
||||
file := AssetFileOpen(path, *mode[0])
|
||||
if file == null {
|
||||
return null
|
||||
}
|
||||
bytes := AssetFileAllocate(cast(u32)length)
|
||||
if bytes == null {
|
||||
AssetFileClose(file)
|
||||
return null
|
||||
}
|
||||
AssetFileCopy(bytes, embedded.data, embedded.size)
|
||||
size.* = cast(s32)embedded.size
|
||||
read := AssetFileRead(bytes, 1, cast(usize)length, file)
|
||||
AssetFileClose(file)
|
||||
if read != cast(usize)length {
|
||||
AssetFileFree(bytes)
|
||||
return null
|
||||
}
|
||||
size.* = length
|
||||
return bytes
|
||||
}
|
||||
|
||||
length := AssetFileLength(path)
|
||||
if length <= 0 {
|
||||
return null
|
||||
InstallAssetFiles :: () {
|
||||
callback: AssetFileCallback = ReadAssetFile
|
||||
InstallAssetFileCallback(callback)
|
||||
}
|
||||
mode: [3]u8
|
||||
mode[0] = #char "r"
|
||||
mode[1] = #char "b"
|
||||
file := AssetFileOpen(path, *mode[0])
|
||||
if file == null {
|
||||
return null
|
||||
}
|
||||
bytes := AssetFileAllocate(cast(u32)length)
|
||||
if bytes == null {
|
||||
AssetFileClose(file)
|
||||
return null
|
||||
}
|
||||
read := AssetFileRead(bytes, 1, cast(usize)length, file)
|
||||
AssetFileClose(file)
|
||||
if read != cast(usize)length {
|
||||
AssetFileFree(bytes)
|
||||
return null
|
||||
}
|
||||
size.* = length
|
||||
return bytes
|
||||
}
|
||||
|
||||
#scope_export
|
||||
InstallAssetFiles :: () {
|
||||
callback: AssetFileCallback = ReadAssetFile
|
||||
InstallAssetFileCallback(callback)
|
||||
}
|
||||
+611
-353
File diff suppressed because it is too large.
Load diff
@@ -1,14 +1,9 @@
|
||||
c :: #system_library "c";
|
||||
raylib :: #system_library "raylib";
|
||||
GetTime :: () -> float64 #foreign raylib;
|
||||
IsWindowHidden :: () -> bool #foreign raylib;
|
||||
ClearWindowState :: (flags: u32) #foreign raylib;
|
||||
SetWindowState :: (flags: u32) #foreign raylib;
|
||||
RestoreWindow :: () #foreign raylib;
|
||||
MinimizeWindow :: () #foreign raylib;
|
||||
FLAG_WINDOW_HIDDEN :: 128;
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign raylib "TraceLog";
|
||||
tray_memcmp :: (left: *void, right: *void, count: usize) -> s32 #foreign c "memcmp";
|
||||
#import, file "host_clock.zi";
|
||||
#import, file "host_window.zi";
|
||||
#import, file "host_window_state.zi";
|
||||
#import, file "app_trace.zi";
|
||||
#import, file "../habits/habit_types.zi";
|
||||
#import, file "../habits/habit_days.zi";
|
||||
#import, file "../core/types.zi";
|
||||
@@ -28,7 +23,13 @@ tray_memcmp :: (left: *void, right: *void, count: usize) -> s32 #foreign c "memc
|
||||
#import, file "tray_status.zi";
|
||||
#import "tray"
|
||||
#import "tray_props"
|
||||
TrayImageExport :: #import "kryon/ImageExport";
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
#import, file "icon_png.zi";
|
||||
#import "std/file"
|
||||
#import "vec"
|
||||
} else {
|
||||
TrayImageExport :: #import "kryon/ImageExport";
|
||||
}
|
||||
#import, file "../app/locale.zi";
|
||||
#import "c_string"
|
||||
#import, file "../app/assets.zi";
|
||||
@@ -169,7 +170,7 @@ SeedTraySnapshot :: () {
|
||||
next: AppTraySnapshot
|
||||
app: *InnerBreeze = CurrentApp()
|
||||
next = AppTraySnapshot.{}
|
||||
next.window_visible = ifx (IsWindowHidden()) then (0) else (1)
|
||||
next.window_visible = ifx (HostWindowHidden()) then (0) else (1)
|
||||
if app != null {
|
||||
next.break_mode = app.breaks.mode
|
||||
next.break_reading_mode = app.breaks.reading_mode
|
||||
@@ -263,7 +264,7 @@ ApplyTrayMenuSnapshot :: (snapshot: *AppTraySnapshot) {
|
||||
menu: TrayMenuStorage
|
||||
BuildTrayMenu(snapshot, *menu)
|
||||
TraySetMenu(menu.items[:])
|
||||
visible := ifx (snapshot != null) then (snapshot.window_visible) else (ifx (IsWindowHidden()) then (0) else (1))
|
||||
visible := ifx (snapshot != null) then (snapshot.window_visible) else (ifx (HostWindowHidden()) then (0) else (1))
|
||||
TraySetActivateAction(cast(s32)GetTrayWindowAction(visible))
|
||||
}
|
||||
#program_export
|
||||
@@ -312,8 +313,19 @@ TrayIconFromAssets :: () -> string {
|
||||
return ""
|
||||
}
|
||||
path := AppTextFromCString(*TrayIconFile[0], cast(s32)TrayIconFile.count)
|
||||
if !TrayImageExport.EncodedImageExport(asset.data, ".webp", path) {
|
||||
return ""
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
// The desktop raster decodes the WebP; Ziran writes the PNG.
|
||||
rgba: [ICON_SIZE * ICON_SIZE * 4]u8
|
||||
png: Vec(u8)
|
||||
if !IconPixels("assets/app/icon.webp", rgba[:]) ||
|
||||
!IconPng(ICON_SIZE, ICON_SIZE, rgba[:], *png) ||
|
||||
!WriteEntireFile(path, TextView(png[:])) {
|
||||
return ""
|
||||
}
|
||||
} else {
|
||||
if !TrayImageExport.EncodedImageExport(asset.data, ".webp", path) {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return path
|
||||
}
|
||||
@@ -332,8 +344,8 @@ desktop_tray_ready :: () -> s32 {
|
||||
return ifx (TrayReady != 0 && TrayVisible()) then (1) else (0)
|
||||
}
|
||||
RestoreTrayWindow :: () {
|
||||
ClearWindowState(FLAG_WINDOW_HIDDEN)
|
||||
RestoreWindow()
|
||||
HostShowWindow()
|
||||
HostRestoreAndFocusWindow()
|
||||
}
|
||||
HideTrayWindow :: () {
|
||||
if desktop_tray_ready() == 0 {
|
||||
@@ -341,11 +353,8 @@ HideTrayWindow :: () {
|
||||
}
|
||||
// The window vanishing with the process still running is the single
|
||||
// most confusing failure mode this app has; always say why it hid.
|
||||
message: [41]u8
|
||||
if CopyCString("APP: hiding main window (tray action)", message[:]) {
|
||||
NativeTraceLog(3, *message[0])
|
||||
}
|
||||
SetWindowState(FLAG_WINDOW_HIDDEN)
|
||||
TraceLog(3, "APP: hiding main window (tray action)")
|
||||
HostHideWindow()
|
||||
}
|
||||
#program_export
|
||||
desktop_tray_keep_running :: () -> s32 {
|
||||
@@ -384,7 +393,7 @@ UpdateTrayMenuSnapshot :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
next = AppTraySnapshot.{}
|
||||
next.window_visible = ifx (IsWindowHidden()) then (0) else (1)
|
||||
next.window_visible = ifx (HostWindowHidden()) then (0) else (1)
|
||||
next.break_mode = app.breaks.mode
|
||||
next.break_reading_mode = app.breaks.reading_mode
|
||||
FillTraySnapshotLabels(*next)
|
||||
@@ -427,7 +436,7 @@ desktop_tray_apply_action :: (app: *InnerBreeze, action: DesktopTrayAction, quit
|
||||
HideTrayWindow()
|
||||
|
||||
case DesktopTrayAction.DESKTOP_TRAY_ACTION_MINIMIZE;
|
||||
MinimizeWindow()
|
||||
HostMinimizeWindow()
|
||||
|
||||
case DesktopTrayAction.DESKTOP_TRAY_ACTION_CLOSE_REQUEST;
|
||||
app_request_desktop_close(app)
|
||||
@@ -510,8 +519,8 @@ desktop_tray_update_status :: (app: *InnerBreeze) {
|
||||
if app == null || TrayReady == 0 {
|
||||
return
|
||||
}
|
||||
now = GetTime()
|
||||
window_visible = ifx (IsWindowHidden()) then (0) else (1)
|
||||
now = HostSeconds()
|
||||
window_visible = ifx (HostWindowHidden()) then (0) else (1)
|
||||
if TrayStatusUpdateInitialized != 0 && window_visible == TrayLastWindowVisible && now < TrayNextStatusUpdateTime {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,9 +4,14 @@
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
host_clock_c :: #system_library "c";
|
||||
HostMonotonicSeconds :: () -> float64 #foreign host_clock_c "app_monotonic_seconds";
|
||||
host_frame_started: float64;
|
||||
host_frame_seconds: float32;
|
||||
HostSleepMicroseconds :: (microseconds: u32) -> s32 #foreign host_clock_c "usleep";
|
||||
} else {
|
||||
host_clock_raylib :: #system_library "raylib";
|
||||
HostRaylibSeconds :: () -> float64 #foreign host_clock_raylib "GetTime";
|
||||
HostRaylibFrameSeconds :: () -> float32 #foreign host_clock_raylib "GetFrameTime";
|
||||
HostRaylibWait :: (seconds: float64) #foreign host_clock_raylib "WaitTime";
|
||||
}
|
||||
|
||||
HostSeconds :: () -> float64 {
|
||||
@@ -16,3 +21,34 @@ HostSeconds :: () -> float64 {
|
||||
return HostRaylibSeconds()
|
||||
}
|
||||
}
|
||||
|
||||
// Waits SECONDS without drawing.
|
||||
HostWait :: (seconds: float64) {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
if seconds > 0.0 {
|
||||
unused HostSleepMicroseconds(cast(u32)(seconds * 1000000.0))
|
||||
}
|
||||
} else {
|
||||
HostRaylibWait(seconds)
|
||||
}
|
||||
}
|
||||
|
||||
// How long the last frame took, from its start to this one's, in seconds.
|
||||
HostFrameSeconds :: () -> float32 {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return host_frame_seconds
|
||||
} else {
|
||||
return HostRaylibFrameSeconds()
|
||||
}
|
||||
}
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
// The desktop frame loop calls this as each frame begins.
|
||||
HostFrameStarted :: () {
|
||||
now := HostMonotonicSeconds()
|
||||
if host_frame_started > 0.0 {
|
||||
host_frame_seconds = cast(float32)(now - host_frame_started)
|
||||
}
|
||||
host_frame_started = now
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// The app's frames on the host the build targets. A raylib host runs the
|
||||
// app's frame procedure in its own frame loop. On Kryon's desktop host a
|
||||
// frame polls the window's events, draws, presents and then waits as the
|
||||
// host's frame clock paces it: 60 frames a second while pixels change and
|
||||
// 15 once they stay the same.
|
||||
#import, file "host_clock.zi";
|
||||
#import, file "host_window.zi";
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop :: #import "desktop_runtime";
|
||||
} else {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
Canvas :: #import "kryon/canvas_host";
|
||||
} else {
|
||||
RaylibRuntime :: #import "kryon/raylib_runtime";
|
||||
}
|
||||
}
|
||||
|
||||
// Runs one frame of PROCEDURE. False when the frame could not run. On the
|
||||
// desktop host a window the window system ended runs no frame, and
|
||||
// HostWindowClosing then reports it.
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
HostFrameProcedure :: #type (argument: *void) #c_call;
|
||||
|
||||
HostRunFrame :: (procedure: HostFrameProcedure, argument: *void) -> bool {
|
||||
if !Desktop.PollDesktop() {
|
||||
HostMarkWindowEnded()
|
||||
return true
|
||||
}
|
||||
HostFrameStarted()
|
||||
Desktop.BeginDesktopFrame()
|
||||
procedure(argument)
|
||||
presented := Desktop.EndDesktopFrame()
|
||||
if presented {
|
||||
HostMarkWindowPresented()
|
||||
}
|
||||
Desktop.PauseDesktop()
|
||||
return presented
|
||||
}
|
||||
} else {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
HostFrameProcedure :: #type (argument: *void) #c_call;
|
||||
|
||||
HostRunFrame :: (procedure: HostFrameProcedure, argument: *void) -> bool {
|
||||
procedure(argument)
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
HostRunFrame :: (procedure: RaylibRuntime.RaylibFrameProcedure, argument: *void) -> bool {
|
||||
return RaylibRuntime.RunRaylibAppFrame(procedure, argument)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pictures whose files changed load again. The desktop raster has no call to
|
||||
// drop its cached pictures yet, so there they stay until the app restarts.
|
||||
HostInvalidatePictures :: () {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
Canvas.InvalidateCanvasAssets()
|
||||
} else {
|
||||
#if !#defined(DESKTOP_HOST) {
|
||||
RaylibRuntime.InvalidateRaylibAssets()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HostInvalidatePicturesUnder :: (folder: string) {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
Canvas.InvalidateCanvasAssetsUnder(folder)
|
||||
} else {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
unused folder
|
||||
} else {
|
||||
RaylibRuntime.InvalidateRaylibAssetsUnder(folder)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,19 +9,21 @@
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop :: #import "desktop_runtime";
|
||||
Keyboard :: #import "desktop_keyboard";
|
||||
host_input_last_pointer: Vector2;
|
||||
} else {
|
||||
host_input_raylib :: #system_library "raylib";
|
||||
RaylibKeyPressed :: (key: s32) -> bool #foreign host_input_raylib "IsKeyPressed";
|
||||
RaylibKeyDown :: (key: s32) -> bool #foreign host_input_raylib "IsKeyDown";
|
||||
RaylibKeyRepeated :: (key: s32) -> bool #foreign host_input_raylib "IsKeyPressedRepeat";
|
||||
RaylibNextKeyPressed :: () -> s32 #foreign host_input_raylib "GetKeyPressed";
|
||||
RaylibMousePosition :: () -> Vector2 #foreign host_input_raylib "GetMousePosition";
|
||||
RaylibMousePressed :: (button: s32) -> bool #foreign host_input_raylib "IsMouseButtonPressed";
|
||||
RaylibMouseDown :: (button: s32) -> bool #foreign host_input_raylib "IsMouseButtonDown";
|
||||
RaylibMouseReleased :: (button: s32) -> bool #foreign host_input_raylib "IsMouseButtonReleased";
|
||||
RaylibWheel :: () -> Vector2 #foreign host_input_raylib "GetMouseWheelMoveV";
|
||||
RaylibMouseDelta :: () -> Vector2 #foreign host_input_raylib "GetMouseDelta";
|
||||
RaylibSetCursor :: (cursor: s32) #foreign host_input_raylib "SetMouseCursor";
|
||||
#if !#defined(PLATFORM_WEB) {
|
||||
RaylibRuntime :: #import "kryon/raylib_runtime";
|
||||
}
|
||||
RaylibKeyReleased :: (key: s32) -> bool #foreign host_input_raylib "IsKeyReleased";
|
||||
}
|
||||
|
||||
HOST_MOUSE_LEFT :: 0
|
||||
@@ -43,6 +45,30 @@ HostKeyDown :: (key: s32) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
// A held key's auto-repeat this frame.
|
||||
HostKeyRepeated :: (key: s32) -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return Keyboard.DesktopKeyRepeated(key)
|
||||
} else {
|
||||
return RaylibKeyRepeated(key)
|
||||
}
|
||||
}
|
||||
|
||||
// A key first pressed this frame, or 0. Raylib reports them in order, one per
|
||||
// call; the desktop host reports the lowest key code pressed.
|
||||
HostKeyPressedThisFrame :: () -> s32 {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
for key: cast(s32)32..348 {
|
||||
if Keyboard.DesktopKeyPressed(key) {
|
||||
return key
|
||||
}
|
||||
}
|
||||
return 0
|
||||
} else {
|
||||
return RaylibNextKeyPressed()
|
||||
}
|
||||
}
|
||||
|
||||
// The primary button at the pointer's window position this frame.
|
||||
HostPointer :: () -> PointerFrame {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
@@ -64,6 +90,20 @@ HostSecondaryPointer :: () -> SecondaryPointerFrame {
|
||||
}
|
||||
}
|
||||
|
||||
// Whether the pointer moved over the window since the last call (raylib:
|
||||
// during the last frame).
|
||||
HostPointerMoved :: () -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
pointer := Desktop.PollPointer()
|
||||
moved := pointer.x != host_input_last_pointer.x || pointer.y != host_input_last_pointer.y
|
||||
host_input_last_pointer = Vector2.{pointer.x, pointer.y}
|
||||
return moved
|
||||
} else {
|
||||
delta := RaylibMouseDelta()
|
||||
return delta.x != 0.0 || delta.y != 0.0
|
||||
}
|
||||
}
|
||||
|
||||
// Wheel steps this frame: x sideways, positive to the right on desktop
|
||||
// hosts and to the left in browsers; y positive away from the person.
|
||||
HostWheel :: () -> Vector2 {
|
||||
@@ -74,7 +114,8 @@ HostWheel :: () -> Vector2 {
|
||||
}
|
||||
}
|
||||
|
||||
// The held modifier keys as KeyModifier bits; none in browsers.
|
||||
// The held modifier keys as KeyModifier bits; none in browsers. On raylib a
|
||||
// modifier released since the last frame still applies to a key pressed with it.
|
||||
HostModifiers :: () -> s32 {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return Desktop.DesktopModifiers()
|
||||
@@ -82,7 +123,21 @@ HostModifiers :: () -> s32 {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
return 0
|
||||
} else {
|
||||
return RaylibRuntime.RaylibModifiers()
|
||||
// Left and right Shift, Control and Alt are 340-342 and 344-346.
|
||||
modifiers: s32 = 0
|
||||
for key: cast(s32)340..346 {
|
||||
if RaylibKeyDown(key) || RaylibKeyReleased(key) {
|
||||
side := ifx key >= 344 then key - 344 else key - 340
|
||||
if side == 0 {
|
||||
modifiers |= KeyModifierShift
|
||||
} else if side == 1 {
|
||||
modifiers |= KeyModifierControl
|
||||
} else if side == 2 {
|
||||
modifiers |= KeyModifierAlt
|
||||
}
|
||||
}
|
||||
}
|
||||
return modifiers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-35
@@ -1,21 +1,20 @@
|
||||
// The app's main window on the host the build targets: raylib's window, or
|
||||
// on Kryon's desktop host the SDL window desktop_runtime opens and draws
|
||||
// with Cairo. A frame there polls the window's events, draws, presents and
|
||||
// then waits as the host's frame clock paces it: 60 frames a second while
|
||||
// pixels change and 15 once they stay the same.
|
||||
// with Cairo. host_frame.zi runs its frames.
|
||||
#import "geometry"
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop :: #import "desktop_runtime";
|
||||
WindowState :: #import "desktop_window_state";
|
||||
Raster :: #import "cairo_raster";
|
||||
Raster :: #import "Cairo";
|
||||
RenderScale :: #import "cairo_render_scale";
|
||||
host_window_closing: bool;
|
||||
// The window shows once its first frame is painted; before that it is
|
||||
// not yet a hidden window.
|
||||
host_window_presented: bool;
|
||||
} else {
|
||||
WindowRuntime :: #import "kryon/window_runtime";
|
||||
WindowClose :: #import "window_close";
|
||||
#if !#defined(PLATFORM_WEB) {
|
||||
RaylibRuntime :: #import "kryon/raylib_runtime";
|
||||
}
|
||||
}
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
@@ -47,34 +46,12 @@ HostWindowHeight :: () -> s32 {
|
||||
}
|
||||
}
|
||||
|
||||
// Runs one frame of PROCEDURE. False when the frame could not run. On the
|
||||
// desktop host a window the window system ended runs no frame, and
|
||||
// HostWindowClosing then reports it.
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
HostFrameProcedure :: #type (argument: *void) #c_call;
|
||||
|
||||
HostRunFrame :: (procedure: HostFrameProcedure, argument: *void) -> bool {
|
||||
if !Desktop.PollDesktop() {
|
||||
host_window_closing = true
|
||||
return true
|
||||
}
|
||||
Desktop.BeginDesktopFrame()
|
||||
procedure(argument)
|
||||
presented := Desktop.EndDesktopFrame()
|
||||
Desktop.PauseDesktop()
|
||||
return presented
|
||||
}
|
||||
} else {
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
HostFrameProcedure :: #type (argument: *void) #c_call;
|
||||
|
||||
HostRunFrame :: (procedure: HostFrameProcedure, argument: *void) -> bool {
|
||||
procedure(argument)
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
HostRunFrame :: (procedure: RaylibRuntime.RaylibFrameProcedure, argument: *void) -> bool {
|
||||
return RaylibRuntime.RunRaylibAppFrame(procedure, argument)
|
||||
// Draws the main window's frames at SCALE pixels per layout unit, as
|
||||
// the camera zoom does on raylib hosts.
|
||||
HostSetRenderScale :: (scale: float32) {
|
||||
if scale > 0.0 {
|
||||
unused RenderScale.RasterSetScale(scale)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,6 +93,18 @@ HostTakeCloseRequest :: () -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
// The frame loop found the window or the session ended.
|
||||
HostMarkWindowEnded :: () {
|
||||
host_window_closing = true
|
||||
}
|
||||
|
||||
// The frame loop presented a frame.
|
||||
HostMarkWindowPresented :: () {
|
||||
host_window_presented = true
|
||||
}
|
||||
}
|
||||
|
||||
// The window system ended the window or the session.
|
||||
HostWindowClosing :: () -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
@@ -127,7 +116,7 @@ HostWindowClosing :: () -> bool {
|
||||
|
||||
HostWindowHidden :: () -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return !Desktop.WindowVisibleHost()
|
||||
return host_window_presented && !Desktop.WindowVisibleHost()
|
||||
} else {
|
||||
return WindowRuntime.WindowHidden()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// The app's main window among the desktop's windows: focus, title, hiding to
|
||||
// the tray, minimize, restore and the monitor it is on. Raylib's window on
|
||||
// raylib hosts; on Kryon's desktop host the window desktop_runtime opened.
|
||||
// Only focus is a question every host answers; the rest is for desktop
|
||||
// windows, which Android and the browser do not have.
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop :: #import "desktop_runtime";
|
||||
WindowState :: #import "desktop_window_state";
|
||||
} else {
|
||||
host_window_focus_raylib :: #system_library "raylib";
|
||||
RaylibWindowFocused :: () -> bool #foreign host_window_focus_raylib "IsWindowFocused";
|
||||
}
|
||||
|
||||
// Whether the window has the keyboard focus.
|
||||
HostWindowFocused :: () -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return Desktop.WindowFocusedHost()
|
||||
} else {
|
||||
return RaylibWindowFocused()
|
||||
}
|
||||
}
|
||||
|
||||
// Raylib's window state on every other host. Android and the browser declare
|
||||
// it too, as the tray code they compile always did, though only desktop
|
||||
// windows act on it.
|
||||
HOST_WINDOW_RAYLIB :: !#defined(DESKTOP_HOST)
|
||||
#if HOST_WINDOW_RAYLIB {
|
||||
#import "c_string"
|
||||
host_window_raylib :: #system_library "raylib";
|
||||
RaylibSetWindowTitle :: (title: *u8) #foreign host_window_raylib "SetWindowTitle";
|
||||
RaylibSetWindowState :: (flags: u32) #foreign host_window_raylib "SetWindowState";
|
||||
RaylibClearWindowState :: (flags: u32) #foreign host_window_raylib "ClearWindowState";
|
||||
RaylibRestoreWindow :: () #foreign host_window_raylib "RestoreWindow";
|
||||
RaylibMinimizeWindow :: () #foreign host_window_raylib "MinimizeWindow";
|
||||
RaylibFocusWindow :: () #foreign host_window_raylib "SetWindowFocused";
|
||||
RaylibCurrentMonitor :: () -> s32 #foreign host_window_raylib "GetCurrentMonitor";
|
||||
RaylibMonitorWidth :: (monitor: s32) -> s32 #foreign host_window_raylib "GetMonitorWidth";
|
||||
RaylibMonitorHeight :: (monitor: s32) -> s32 #foreign host_window_raylib "GetMonitorHeight";
|
||||
// FLAG_WINDOW_HIDDEN, and with FLAG_WINDOW_MINIMIZED.
|
||||
RAYLIB_WINDOW_HIDDEN :: 128
|
||||
RAYLIB_WINDOW_HIDDEN_MINIMIZED :: 640
|
||||
}
|
||||
|
||||
#if #defined(DESKTOP_HOST) || HOST_WINDOW_RAYLIB {
|
||||
HostSetWindowTitle :: (title: string) {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
unused Desktop.DesktopSetTitle(title)
|
||||
} else {
|
||||
bytes: [256]u8
|
||||
if CopyCString(title, bytes[:]) {
|
||||
RaylibSetWindowTitle(*bytes[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shows a hidden window, as from the tray.
|
||||
HostShowWindow :: () {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop.WindowSetVisibleHost(true)
|
||||
} else {
|
||||
RaylibClearWindowState(cast(u32)RAYLIB_WINDOW_HIDDEN)
|
||||
}
|
||||
}
|
||||
|
||||
// Hides the window while the app keeps running in the tray.
|
||||
HostHideWindow :: () {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop.WindowSetVisibleHost(false)
|
||||
} else {
|
||||
RaylibSetWindowState(cast(u32)RAYLIB_WINDOW_HIDDEN)
|
||||
}
|
||||
}
|
||||
|
||||
HostMinimizeWindow :: () {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
unused WindowState.DesktopMinimize()
|
||||
} else {
|
||||
RaylibMinimizeWindow()
|
||||
}
|
||||
}
|
||||
|
||||
// Brings a minimized or hidden-behind window back and gives it focus.
|
||||
HostRestoreAndFocusWindow :: () {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop.WindowSetVisibleHost(true)
|
||||
unused WindowState.DesktopRestore()
|
||||
unused WindowState.DesktopRaise()
|
||||
} else {
|
||||
// Clear the states at once; RestoreWindow alone waits for a later
|
||||
// SDL event, after the no-tray loop has already checked them.
|
||||
RaylibClearWindowState(cast(u32)RAYLIB_WINDOW_HIDDEN_MINIMIZED)
|
||||
RaylibRestoreWindow()
|
||||
RaylibFocusWindow()
|
||||
}
|
||||
}
|
||||
|
||||
// The monitor the window is on, in pixels.
|
||||
HostMonitorSize :: () -> (width: s32, height: s32) {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
bounds := WindowState.DesktopMonitorBounds()
|
||||
return cast(s32)bounds.width, cast(s32)bounds.height
|
||||
} else {
|
||||
monitor := RaylibCurrentMonitor()
|
||||
return RaylibMonitorWidth(monitor), RaylibMonitorHeight(monitor)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// App icons as pixels and PNG files. RGBA pixels become a PNG with Ziran's
|
||||
// own encoder on every native host. On Kryon's desktop host an embedded
|
||||
// picture, such as the app icon, is decoded to RGBA by the desktop raster.
|
||||
#import "std/image"
|
||||
#import "std/png_linux"
|
||||
#import "vec"
|
||||
|
||||
ICON_SIZE :: 128
|
||||
|
||||
// Encodes WIDTH by HEIGHT RGBA pixels as a PNG into OUTPUT.
|
||||
IconPng :: (width: s32, height: s32, rgba: []u8, output: *Vec(u8)) -> bool {
|
||||
count := cast(s64)width * cast(s64)height * 4
|
||||
if width <= 0 || height <= 0 || rgba.count < count {
|
||||
return false
|
||||
}
|
||||
picture: Image
|
||||
picture.width = width
|
||||
picture.height = height
|
||||
if !VecResize(picture.pixels, count) {
|
||||
return false
|
||||
}
|
||||
for index: cast(s64)0..count - 1 {
|
||||
picture.pixels[index] = rgba[index]
|
||||
}
|
||||
return WritePNG(*picture, output)
|
||||
}
|
||||
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Cairo :: #import "Cairo";
|
||||
icon_argb: [ICON_SIZE * ICON_SIZE]u32;
|
||||
|
||||
// The picture at PATH, embedded or on disk, scaled to ICON_SIZE square
|
||||
// as RGBA into RGBA.
|
||||
IconPixels :: (path: string, rgba: []u8) -> bool {
|
||||
if rgba.count < ICON_SIZE * ICON_SIZE * 4 ||
|
||||
!Cairo.CairoImagePixels(path, ICON_SIZE, ICON_SIZE, icon_argb[:], false) {
|
||||
return false
|
||||
}
|
||||
for index: 0..ICON_SIZE * ICON_SIZE - 1 {
|
||||
pixel := icon_argb[index]
|
||||
rgba[index * 4] = cast(u8)((pixel >> 16) & 255)
|
||||
rgba[index * 4 + 1] = cast(u8)((pixel >> 8) & 255)
|
||||
rgba[index * 4 + 2] = cast(u8)(pixel & 255)
|
||||
rgba[index * 4 + 3] = cast(u8)(pixel >> 24)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,10 @@
|
||||
#import "file_linux"
|
||||
#import "c_string"
|
||||
#import "byte_text_linux"
|
||||
#import, file "raylib_host.zi";
|
||||
#import "vec"
|
||||
#import, file "icon_png.zi";
|
||||
#import, file "../apps/package_files.zi";
|
||||
|
||||
#if !#defined(PLATFORM_WEB) {
|
||||
raylib :: #system_library "raylib";
|
||||
IconPng :: (image: RaylibImage, extension: *u8, size: *s32) -> *u8 #foreign raylib "ExportImageToMemory";
|
||||
IconFree :: (memory: *void) #foreign raylib "MemFree";
|
||||
}
|
||||
|
||||
LauncherIconWrite :: (path: string, shape: string, windows: bool) -> bool {
|
||||
#if !#defined(PLATFORM_WEB) {
|
||||
coverage: [9216]u8
|
||||
@@ -30,13 +25,9 @@ LauncherIconWrite :: (path: string, shape: string, windows: bool) -> bool {
|
||||
pixels[at + 3] = 255
|
||||
}
|
||||
}
|
||||
image: RaylibImage = .{cast(*void)*pixels[0], 128, 128, 1, 7}
|
||||
extension: [8]u8
|
||||
unused CopyCString(".png", extension[:])
|
||||
size: s32
|
||||
png := IconPng(image, *extension[0], *size)
|
||||
if png == null || size <= 0 { return false }
|
||||
defer { IconFree(cast(*void)png) }
|
||||
png: Vec(u8)
|
||||
if !IconPng(128, 128, pixels[:], *png) || png.count == 0 { return false }
|
||||
size := cast(s32)png.count
|
||||
file := OpenReplace(path)
|
||||
if !file.valid { return false }
|
||||
offset: s64 = 0
|
||||
@@ -52,7 +43,7 @@ LauncherIconWrite :: (path: string, shape: string, windows: bool) -> bool {
|
||||
ok = WriteAt(file, header[:], 0) == 22
|
||||
offset = 22
|
||||
}
|
||||
ok = ok && WriteAt(file, BytesFromPointer(png, cast(u64)size), offset) == size && SyncFile(file)
|
||||
ok = ok && WriteAt(file, png[:], offset) == size && SyncFile(file)
|
||||
closed := CloseFile(file)
|
||||
return ok && closed
|
||||
}
|
||||
|
||||
@@ -2,16 +2,28 @@
|
||||
#import "c_string"
|
||||
#import "byte_text_linux"
|
||||
#import, file "app_trace.zi";
|
||||
#import, file "host_clock.zi";
|
||||
#import "device_host"
|
||||
#import "window_close"
|
||||
#import "asset_files"
|
||||
WindowIcon :: #import "kryon/window_icon";
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop :: #import "desktop_runtime";
|
||||
#import, file "icon_png.zi";
|
||||
desktop_icon_rgba: [ICON_SIZE * ICON_SIZE * 4]u8;
|
||||
|
||||
// The window icon from an embedded picture, given to SDL as RGBA.
|
||||
SetDesktopIconFromAsset :: (path: string) -> bool {
|
||||
return IconPixels(path, desktop_icon_rgba[:]) &&
|
||||
Desktop.DesktopSetIcon(ICON_SIZE, ICON_SIZE, desktop_icon_rgba[:])
|
||||
}
|
||||
} else {
|
||||
#import "window_close"
|
||||
WindowIcon :: #import "kryon/window_icon";
|
||||
}
|
||||
#import, file "../app/assets.zi";
|
||||
|
||||
c :: #system_library "c";
|
||||
ScreenshotEnvironmentBytes :: (name: *u8) -> *u8 #foreign c "getenv";
|
||||
raylib :: #system_library "raylib";
|
||||
HostTraceLog :: (level: s32, format: *u8, arguments: ..any) #foreign raylib "TraceLog";
|
||||
update_apply_at_exit :: () -> s32 #foreign c;
|
||||
WindowReady :: () -> bool #foreign raylib "IsWindowReady";
|
||||
WindowHandle :: () -> *void #foreign raylib "GetWindowHandle";
|
||||
@@ -43,6 +55,7 @@ FindText :: (text: *u8, needle: *u8) -> *u8 #foreign c "strstr";
|
||||
}
|
||||
|
||||
MAIN_SDL :: #defined(NATIVE_WINDOW_HAVE_SDL) && !#defined(PLATFORM_WEB) && !#defined(_WIN32) && !#defined(ANDROID_BUILD)
|
||||
DESKTOP_WINDOW :: #defined(DESKTOP_HOST)
|
||||
#if MAIN_SDL {
|
||||
sdl :: #system_library "SDL2";
|
||||
CurrentWindow :: () -> *void #foreign sdl "SDL_GL_GetCurrentWindow";
|
||||
@@ -67,7 +80,6 @@ MAIN_SDL :: #defined(NATIVE_WINDOW_HAVE_SDL) && !#defined(PLATFORM_WEB) && !#def
|
||||
geometry_launch_width: s32;
|
||||
geometry_launch_height: s32;
|
||||
geometry_viewport: AndroidViewport;
|
||||
GeometryTime :: () -> float64 #foreign raylib "GetTime";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +162,14 @@ SetDesktopWindowIcon :: (path: *u8) {
|
||||
return
|
||||
}
|
||||
encoded := TextFromBytes(BytesFromPointer(asset.data, cast(u64)asset.size))
|
||||
if !WindowIcon.SetWindowIcon(encoded, TextFromCString(path)) {
|
||||
applied := false
|
||||
#if DESKTOP_WINDOW {
|
||||
unused encoded
|
||||
applied = SetDesktopIconFromAsset(TextFromCString(path))
|
||||
} else {
|
||||
applied = WindowIcon.SetWindowIcon(encoded, TextFromCString(path))
|
||||
}
|
||||
if !applied {
|
||||
TraceLog(4, "APP: Failed to decode or apply window icon asset")
|
||||
}
|
||||
}
|
||||
@@ -286,25 +305,36 @@ native_before_window :: () {
|
||||
|
||||
#program_export
|
||||
native_after_window :: (icon_path: *u8) -> s32 {
|
||||
if !WindowReady() {
|
||||
TraceLog(5, "APP: InitWindow failed")
|
||||
#if #defined(_WIN32) && !#defined(ANDROID_BUILD) {
|
||||
dialog: [3072]u8
|
||||
title: [32]u8
|
||||
if StartupErrorMessage(TraceRecentErrors(), dialog[:]) &&
|
||||
CopyCString("Inner Breeze", title[:]) {
|
||||
ErrorMessage(null, *dialog[0], *title[0], 0x10)
|
||||
// The desktop host's window is open once HostOpenWindow returns.
|
||||
#if !DESKTOP_WINDOW {
|
||||
if !WindowReady() {
|
||||
TraceLog(5, "APP: InitWindow failed")
|
||||
#if #defined(_WIN32) && !#defined(ANDROID_BUILD) {
|
||||
dialog: [3072]u8
|
||||
title: [32]u8
|
||||
if StartupErrorMessage(TraceRecentErrors(), dialog[:]) &&
|
||||
CopyCString("Inner Breeze", title[:]) {
|
||||
ErrorMessage(null, *dialog[0], *title[0], 0x10)
|
||||
}
|
||||
TraceClose()
|
||||
}
|
||||
TraceClose()
|
||||
return 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
#if MAIN_SDL {
|
||||
window := CurrentWindow()
|
||||
window: *void
|
||||
#if DESKTOP_WINDOW {
|
||||
window = Desktop.DesktopWindow()
|
||||
} else {
|
||||
window = CurrentWindow()
|
||||
}
|
||||
if window != null {
|
||||
GrabWindow(window, 0)
|
||||
app_device_attach_window(window)
|
||||
WindowCloseWatch(window)
|
||||
// The desktop host intercepts its own window's close.
|
||||
#if !DESKTOP_WINDOW {
|
||||
WindowCloseWatch(window)
|
||||
}
|
||||
}
|
||||
}
|
||||
#if #defined(_WIN32) && !#defined(ANDROID_BUILD) {
|
||||
@@ -348,7 +378,9 @@ native_after_window :: (icon_path: *u8) -> s32 {
|
||||
|
||||
#program_export
|
||||
native_platform_shutdown :: () {
|
||||
WindowCloseStop()
|
||||
#if !DESKTOP_WINDOW {
|
||||
WindowCloseStop()
|
||||
}
|
||||
TraceClose()
|
||||
}
|
||||
|
||||
@@ -371,7 +403,7 @@ native_update_apply_at_exit :: () -> s32 {
|
||||
native_android_report_geometry :: (viewport: AndroidViewport,
|
||||
layout_width: s32, layout_height: s32, render_scale: float32,
|
||||
practice: s32, paused: s32) {
|
||||
now := GeometryTime()
|
||||
now := HostSeconds()
|
||||
if ViewportEqual(viewport, geometry_viewport) &&
|
||||
geometry_time >= 0.0 && now - geometry_time < 1.0 {
|
||||
return
|
||||
@@ -424,11 +456,13 @@ native_update_apply_at_exit :: () -> s32 {
|
||||
height: s32
|
||||
GetAndroidSurfaceSize(*width, *height)
|
||||
format: [160]u8
|
||||
if CopyCString("ANDROID_VIEWPORT: surface=%dx%d viewport=%d,%d %dx%d insets l=%d t=%d r=%d b=%d", format[:]) {
|
||||
HostTraceLog(3, *format[0], width, height, viewport.x,
|
||||
viewport.y, viewport.width, viewport.height,
|
||||
viewport.insets.left, viewport.insets.top,
|
||||
viewport.insets.right, viewport.insets.bottom)
|
||||
message: [256]u8
|
||||
if CopyCString("ANDROID_VIEWPORT: surface=%dx%d viewport=%d,%d %dx%d insets l=%d t=%d r=%d b=%d", format[:]) &&
|
||||
FormatText(*message[0], 256, *format[0], width, height, viewport.x,
|
||||
viewport.y, viewport.width, viewport.height,
|
||||
viewport.insets.left, viewport.insets.top,
|
||||
viewport.insets.right, viewport.insets.bottom) > 0 {
|
||||
TraceLog(3, TextFromCString(*message[0]))
|
||||
}
|
||||
last_viewport = viewport.*
|
||||
}
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
#import, file "../app/metrics.zi";
|
||||
#import, file "../practices/practice_registry.zi";
|
||||
#import, file "../practices/practice_audio_controls.zi";
|
||||
#import "raylib_secondary_window"
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
#import "desktop_secondary_window"
|
||||
} else {
|
||||
#import "raylib_secondary_window"
|
||||
}
|
||||
#import, file "host_window_state.zi";
|
||||
#import "window_flags"
|
||||
using NativeWindowFlags;
|
||||
#import, file "android/android_picture_window.zi";
|
||||
@@ -20,12 +25,6 @@ Button :: #import "kryon/button";
|
||||
|
||||
using ButtonEmphasis;
|
||||
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
raylib :: #system_library "raylib";
|
||||
RestoreWindow :: () #foreign raylib;
|
||||
SetWindowFocused :: () #foreign raylib;
|
||||
PracticeClearWindowState :: (flags: u32) #foreign raylib "ClearWindowState";
|
||||
}
|
||||
|
||||
practice_window: SecondaryWindow;
|
||||
practice_window_session: Session;
|
||||
@@ -111,11 +110,7 @@ ClosePracticeWindow :: (app: *InnerBreeze) {
|
||||
|
||||
FocusPracticeApp :: () {
|
||||
#if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) {
|
||||
// Clear both flags immediately; RestoreWindow alone waits for a later
|
||||
// SDL event, after the no-tray loop has already checked them.
|
||||
PracticeClearWindowState(cast(u32)(128 + 512))
|
||||
RestoreWindow()
|
||||
SetWindowFocused()
|
||||
HostRestoreAndFocusWindow()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+144
-40
@@ -2,11 +2,11 @@
|
||||
// thread as the player; callbacks never touch app state or the audio thread.
|
||||
#import "c_string"
|
||||
#import, file "audio_runtime.zi";
|
||||
#import, file "host_clock.zi";
|
||||
|
||||
#if !#defined(PLATFORM_WEB) && !#defined(ANDROID_BUILD) {
|
||||
#import "net_http_curl_linux"
|
||||
curl :: #system_library "curl";
|
||||
raylib :: #system_library "raylib";
|
||||
c :: #system_library "c";
|
||||
EasyInit :: () -> *void #foreign curl "curl_easy_init";
|
||||
EasyCleanup :: (easy: *void) #foreign curl "curl_easy_cleanup";
|
||||
@@ -18,16 +18,23 @@
|
||||
MultiCleanup :: (multi: *void) -> s32 #foreign curl "curl_multi_cleanup";
|
||||
EasyPause :: (easy: *void, mask: s32) -> s32 #foreign curl "curl_easy_pause";
|
||||
MoveBytes :: (to: *void, from: *void, length: usize) -> *void #foreign c "memmove";
|
||||
Clock :: () -> float64 #foreign raylib "GetTime";
|
||||
LoadStream :: (rate: u32, bits: u32, channels: u32) -> NativeAudioStream #foreign raylib "LoadAudioStream";
|
||||
UnloadStream :: (stream: NativeAudioStream) #foreign raylib "UnloadAudioStream";
|
||||
PlayStream :: (stream: NativeAudioStream) #foreign raylib "PlayAudioStream";
|
||||
StreamProcessed :: (stream: NativeAudioStream) -> bool #foreign raylib "IsAudioStreamProcessed";
|
||||
UpdateStream :: (stream: NativeAudioStream, data: *void, frames: s32) #foreign raylib "UpdateAudioStream";
|
||||
StreamVolume :: (stream: NativeAudioStream, volume: float32) #foreign raylib "SetAudioStreamVolume";
|
||||
StreamBufferSize :: (frames: s32) #foreign raylib "SetAudioStreamBufferSizeDefault";
|
||||
// The PCM output: a raylib audio stream, or on Kryon's desktop host a
|
||||
// stream voice of its mixer. Both take signed 16-bit blocks.
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Mixer :: #import "audio_mixer";
|
||||
} else {
|
||||
raylib :: #system_library "raylib";
|
||||
LoadStream :: (rate: u32, bits: u32, channels: u32) -> NativeAudioStream #foreign raylib "LoadAudioStream";
|
||||
UnloadStream :: (stream: NativeAudioStream) #foreign raylib "UnloadAudioStream";
|
||||
PlayStream :: (stream: NativeAudioStream) #foreign raylib "PlayAudioStream";
|
||||
StreamProcessed :: (stream: NativeAudioStream) -> bool #foreign raylib "IsAudioStreamProcessed";
|
||||
UpdateStream :: (stream: NativeAudioStream, data: *void, frames: s32) #foreign raylib "UpdateAudioStream";
|
||||
StreamVolume :: (stream: NativeAudioStream, volume: float32) #foreign raylib "SetAudioStreamVolume";
|
||||
StreamBufferSize :: (frames: s32) #foreign raylib "SetAudioStreamBufferSizeDefault";
|
||||
}
|
||||
|
||||
// Public dr_mp3 low-level push API, already compiled by raylib.
|
||||
// dr_mp3's low-level push API: raylib's copy, or on the desktop host the
|
||||
// audio package's libziran_mp3.a, which decodes to float samples.
|
||||
Mp3Bits :: struct {
|
||||
buffer: *u8
|
||||
position: s32
|
||||
@@ -76,9 +83,16 @@
|
||||
layer: s32
|
||||
bitrate: s32
|
||||
}
|
||||
Mp3Init :: (decoder: *Mp3Decoder) #foreign raylib "drmp3dec_init";
|
||||
Mp3Decode :: (decoder: *Mp3Decoder, input: *u8, length: s32,
|
||||
pcm: *s16, info: *Mp3Frame) -> s32 #foreign raylib "drmp3dec_decode_frame";
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
radio_mp3 :: #system_library "ziran_mp3";
|
||||
Mp3Init :: (decoder: *Mp3Decoder) #foreign radio_mp3 "drmp3dec_init";
|
||||
Mp3DecodeFloat :: (decoder: *Mp3Decoder, input: *u8, length: s32,
|
||||
pcm: *float32, info: *Mp3Frame) -> s32 #foreign radio_mp3 "drmp3dec_decode_frame";
|
||||
} else {
|
||||
Mp3Init :: (decoder: *Mp3Decoder) #foreign raylib "drmp3dec_init";
|
||||
Mp3Decode :: (decoder: *Mp3Decoder, input: *u8, length: s32,
|
||||
pcm: *s16, info: *Mp3Frame) -> s32 #foreign raylib "drmp3dec_decode_frame";
|
||||
}
|
||||
WriteCallback :: #type (data: *u8, size: usize, count: usize, context: *void) -> usize #c_call;
|
||||
|
||||
radio_multi: *void;
|
||||
@@ -87,7 +101,11 @@
|
||||
radio_length: s32;
|
||||
radio_paused: bool;
|
||||
radio_decoder: Mp3Decoder;
|
||||
radio_stream: NativeAudioStream;
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
radio_voice: Mixer.AudioVoice = .{-1, 0};
|
||||
} else {
|
||||
radio_stream: NativeAudioStream;
|
||||
}
|
||||
radio_pcm: [12288]s16;
|
||||
radio_samples: s32;
|
||||
radio_rate: s32;
|
||||
@@ -101,6 +119,102 @@
|
||||
radio_audible_until: float64;
|
||||
radio_url: [2048]u8;
|
||||
|
||||
// One MP3 frame into PCM as signed 16-bit samples; its frame count.
|
||||
RadioDecodeFrame :: (input: *u8, length: s32, pcm: *s16, info: *Mp3Frame) -> s32 {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
samples: [2304]float32
|
||||
frames := Mp3DecodeFloat(*radio_decoder, input, length, *samples[0], info)
|
||||
count := frames * info.channels
|
||||
if count > 2304 {
|
||||
count = 2304
|
||||
}
|
||||
for index: cast(s32)0..count - 1 {
|
||||
value := samples[index] * 32768.0
|
||||
if value > 32767.0 {
|
||||
value = 32767.0
|
||||
}
|
||||
if value < -32768.0 {
|
||||
value = -32768.0
|
||||
}
|
||||
pcm[index] = cast(s16)value
|
||||
}
|
||||
return frames
|
||||
} else {
|
||||
return Mp3Decode(*radio_decoder, input, length, pcm, info)
|
||||
}
|
||||
}
|
||||
|
||||
RadioStreamOpen :: () -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return radio_voice.slot >= 0
|
||||
} else {
|
||||
return radio_stream.buffer != null
|
||||
}
|
||||
}
|
||||
|
||||
RadioStreamClose :: () {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
if radio_voice.slot >= 0 {
|
||||
Mixer.AudioUnload(radio_voice)
|
||||
radio_voice = .{-1, 0}
|
||||
}
|
||||
} else {
|
||||
if radio_stream.buffer != null {
|
||||
UnloadStream(radio_stream)
|
||||
radio_stream = NativeAudioStream.{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opens a stream of 4096-frame blocks at RATE and plays it at the volume.
|
||||
RadioStreamStart :: (rate: s32, channels: s32) -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
radio_voice = Mixer.AudioOpenStream(rate, channels, 4096)
|
||||
if radio_voice.slot < 0 {
|
||||
return false
|
||||
}
|
||||
Mixer.AudioSetGain(radio_voice, radio_volume)
|
||||
unused Mixer.AudioPlay(radio_voice)
|
||||
return true
|
||||
} else {
|
||||
StreamBufferSize(4096)
|
||||
radio_stream = LoadStream(cast(u32)rate, 16, cast(u32)channels)
|
||||
StreamBufferSize(0)
|
||||
if radio_stream.buffer == null {
|
||||
return false
|
||||
}
|
||||
StreamVolume(radio_stream, radio_volume)
|
||||
PlayStream(radio_stream)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
RadioStreamWritable :: () -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return Mixer.AudioStreamWritable(radio_voice)
|
||||
} else {
|
||||
return StreamProcessed(radio_stream)
|
||||
}
|
||||
}
|
||||
|
||||
// Submits the first 4096 frames of radio_pcm.
|
||||
RadioStreamSubmit :: (samples: s32) {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
unused Mixer.AudioStreamSubmit(radio_voice, radio_pcm[0:samples])
|
||||
} else {
|
||||
unused samples
|
||||
UpdateStream(radio_stream, cast(*void)*radio_pcm[0], 4096)
|
||||
}
|
||||
}
|
||||
|
||||
RadioStreamVolume :: (volume: float32) {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Mixer.AudioSetGain(radio_voice, volume)
|
||||
} else {
|
||||
StreamVolume(radio_stream, volume)
|
||||
}
|
||||
}
|
||||
|
||||
ReceiveRadio :: (data: *u8, size: usize, count: usize, context: *void) -> usize {
|
||||
unused context
|
||||
length := size * count
|
||||
@@ -130,10 +244,7 @@
|
||||
unused MultiCleanup(radio_multi)
|
||||
radio_multi = null
|
||||
}
|
||||
if radio_stream.buffer != null {
|
||||
UnloadStream(radio_stream)
|
||||
radio_stream = NativeAudioStream.{}
|
||||
}
|
||||
RadioStreamClose()
|
||||
radio_length = 0
|
||||
radio_samples = 0
|
||||
radio_paused = false
|
||||
@@ -146,7 +257,7 @@
|
||||
NativeRadioRetry :: () {
|
||||
NativeRadioDisconnect()
|
||||
radio_state = 3
|
||||
radio_retry_at = Clock() + radio_retry_seconds
|
||||
radio_retry_at = HostSeconds() + radio_retry_seconds
|
||||
radio_retry_seconds *= 2.0
|
||||
if radio_retry_seconds > 30.0 {
|
||||
radio_retry_seconds = 30.0
|
||||
@@ -190,7 +301,7 @@
|
||||
return
|
||||
}
|
||||
radio_state = 1
|
||||
radio_last_audio = Clock()
|
||||
radio_last_audio = HostSeconds()
|
||||
}
|
||||
|
||||
NativeRadioOpen :: (url: string) -> bool {
|
||||
@@ -219,7 +330,7 @@
|
||||
return
|
||||
}
|
||||
if radio_multi == null {
|
||||
if Clock() >= radio_retry_at {
|
||||
if HostSeconds() >= radio_retry_at {
|
||||
NativeRadioConnect()
|
||||
}
|
||||
return
|
||||
@@ -230,7 +341,7 @@
|
||||
}
|
||||
running: s32
|
||||
result := MultiPerform(radio_multi, *running)
|
||||
if result != 0 || running == 0 || Clock() - radio_last_audio > 20.0 {
|
||||
if result != 0 || running == 0 || HostSeconds() - radio_last_audio > 20.0 {
|
||||
NativeRadioRetry()
|
||||
return
|
||||
}
|
||||
@@ -244,7 +355,7 @@
|
||||
while radio_length >= 4096 && radio_samples < 8192 && attempts < 32 {
|
||||
info: Mp3Frame
|
||||
pcm: [2304]s16
|
||||
frames := Mp3Decode(*radio_decoder, *radio_bytes[0], radio_length, *pcm[0], *info)
|
||||
frames := RadioDecodeFrame(*radio_bytes[0], radio_length, *pcm[0], *info)
|
||||
if info.bytes <= 0 || info.bytes > radio_length {
|
||||
break
|
||||
}
|
||||
@@ -260,38 +371,31 @@
|
||||
NativeRadioRetry()
|
||||
return
|
||||
}
|
||||
if radio_stream.buffer == null || info.rate != radio_rate || info.channels != radio_channels {
|
||||
if radio_stream.buffer != null {
|
||||
UnloadStream(radio_stream)
|
||||
}
|
||||
StreamBufferSize(4096)
|
||||
radio_stream = LoadStream(cast(u32)info.rate, 16, cast(u32)info.channels)
|
||||
StreamBufferSize(0)
|
||||
if radio_stream.buffer == null {
|
||||
if !RadioStreamOpen() || info.rate != radio_rate || info.channels != radio_channels {
|
||||
RadioStreamClose()
|
||||
if !RadioStreamStart(info.rate, info.channels) {
|
||||
NativeRadioRetry()
|
||||
return
|
||||
}
|
||||
radio_rate = info.rate
|
||||
radio_channels = info.channels
|
||||
radio_samples = 0
|
||||
StreamVolume(radio_stream, radio_volume)
|
||||
PlayStream(radio_stream)
|
||||
}
|
||||
samples := frames * info.channels
|
||||
for index: cast(s32)0..samples - 1 {
|
||||
radio_pcm[radio_samples + index] = pcm[index]
|
||||
}
|
||||
radio_samples += samples
|
||||
radio_last_audio = Clock()
|
||||
radio_last_audio = HostSeconds()
|
||||
}
|
||||
chunk := 4096 * radio_channels
|
||||
if chunk > 0 && radio_samples >= chunk && StreamProcessed(radio_stream) {
|
||||
UpdateStream(radio_stream, cast(*void)*radio_pcm[0], 4096)
|
||||
if chunk > 0 && radio_samples >= chunk && RadioStreamWritable() {
|
||||
RadioStreamSubmit(chunk)
|
||||
radio_samples -= chunk
|
||||
unused MoveBytes(cast(*void)*radio_pcm[0], cast(*void)*radio_pcm[chunk], cast(usize)(radio_samples * 2))
|
||||
// The two stream buffers cover only submitted PCM. A decoder
|
||||
// stall must report buffering as soon as that audio runs out.
|
||||
now := Clock()
|
||||
now := HostSeconds()
|
||||
if radio_audible_until < now { radio_audible_until = now }
|
||||
duration := 4096.0 / cast(float64)radio_rate
|
||||
radio_audible_until += duration
|
||||
@@ -305,13 +409,13 @@
|
||||
|
||||
NativeRadioVolume :: (volume: float32) {
|
||||
radio_volume = volume
|
||||
if radio_stream.buffer != null {
|
||||
StreamVolume(radio_stream, volume)
|
||||
if RadioStreamOpen() {
|
||||
RadioStreamVolume(volume)
|
||||
}
|
||||
}
|
||||
|
||||
NativeRadioState :: () -> s32 {
|
||||
if radio_state == 2 && Clock() >= radio_audible_until { return 1 }
|
||||
if radio_state == 2 && HostSeconds() >= radio_audible_until { return 1 }
|
||||
return radio_state
|
||||
}
|
||||
}
|
||||
+43
-41
@@ -2,13 +2,13 @@
|
||||
#import "c_string"
|
||||
#import "drawing_props"
|
||||
#import "geometry"
|
||||
#import "window_visible"
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
#import, file "android/android_startup.zi";
|
||||
AndroidSurface :: #import "kryon/AndroidSurface";
|
||||
}
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
#if #defined(PLATFORM_WEB) == false && !#defined(DESKTOP_HOST) {
|
||||
#import "kryon/Raylib"
|
||||
#import "window_visible"
|
||||
}
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
CanvasWindow :: #import "canvas_window";
|
||||
@@ -17,8 +17,6 @@
|
||||
CanvasTexture :: #import "canvas_texture";
|
||||
}
|
||||
|
||||
raylib :: #system_library "raylib";
|
||||
|
||||
FLAG_WINDOW_RESIZABLE :: 4
|
||||
FLAG_WINDOW_ALWAYS_RUN :: 256
|
||||
KEY_SPACE :: 32
|
||||
@@ -40,51 +38,55 @@ RaylibImage :: struct {
|
||||
format: s32
|
||||
}
|
||||
|
||||
HostInitWindow :: (width: s32, height: s32, title: *u8) #foreign raylib "InitWindow";
|
||||
HostCloseWindow :: () #foreign raylib "CloseWindow";
|
||||
HostExportImage :: (image: RaylibImage, path: *u8) -> bool #foreign raylib "ExportImage";
|
||||
// raylib's window and image export; Kryon's desktop host opens its window
|
||||
// through host_window.zi and captures with the raster.
|
||||
#if !#defined(DESKTOP_HOST) {
|
||||
raylib :: #system_library "raylib";
|
||||
HostInitWindow :: (width: s32, height: s32, title: *u8) #foreign raylib "InitWindow";
|
||||
HostCloseWindow :: () #foreign raylib "CloseWindow";
|
||||
HostExportImage :: (image: RaylibImage, path: *u8) -> bool #foreign raylib "ExportImage";
|
||||
|
||||
|
||||
InitWindow :: (width: s32, height: s32, title: string) {
|
||||
title_bytes: [256]u8
|
||||
if !CopyCString(title, title_bytes[:]) {
|
||||
return
|
||||
}
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
if !AndroidWaitForWindow() {
|
||||
InitWindow :: (width: s32, height: s32, title: string) {
|
||||
title_bytes: [256]u8
|
||||
if !CopyCString(title, title_bytes[:]) {
|
||||
return
|
||||
}
|
||||
if width <= 0 || height <= 0 {
|
||||
surface_width: s32
|
||||
surface_height: s32
|
||||
if !AndroidSurface.GetAndroidPendingSurfaceSize(*surface_width, *surface_height) {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
if !AndroidWaitForWindow() {
|
||||
return
|
||||
}
|
||||
if width <= 0 {
|
||||
width = surface_width
|
||||
}
|
||||
if height <= 0 {
|
||||
height = surface_height
|
||||
if width <= 0 || height <= 0 {
|
||||
surface_width: s32
|
||||
surface_height: s32
|
||||
if !AndroidSurface.GetAndroidPendingSurfaceSize(*surface_width, *surface_height) {
|
||||
return
|
||||
}
|
||||
if width <= 0 {
|
||||
width = surface_width
|
||||
}
|
||||
if height <= 0 {
|
||||
height = surface_height
|
||||
}
|
||||
}
|
||||
}
|
||||
HostInitWindow(width, height, *title_bytes[0])
|
||||
// A window nobody can see, as SDL opens without a reachable display,
|
||||
// closes again so startup reports that it failed.
|
||||
if !WindowVisible() {
|
||||
HostCloseWindow()
|
||||
return
|
||||
}
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
// Kryon then draws each icon as one texture, not its many rectangles.
|
||||
RaylibUseIconTextures()
|
||||
}
|
||||
}
|
||||
HostInitWindow(width, height, *title_bytes[0])
|
||||
// A window nobody can see, as SDL opens without a reachable display,
|
||||
// closes again so startup reports that it failed.
|
||||
if !WindowVisible() {
|
||||
HostCloseWindow()
|
||||
return
|
||||
}
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
// Kryon then draws each icon as one texture, not its many rectangles.
|
||||
RaylibUseIconTextures()
|
||||
}
|
||||
}
|
||||
|
||||
ExportImage :: (image: RaylibImage, path: string) -> bool {
|
||||
path_bytes: [4096]u8
|
||||
if !CopyCString(path, path_bytes[:]) {
|
||||
return false
|
||||
ExportImage :: (image: RaylibImage, path: string) -> bool {
|
||||
path_bytes: [4096]u8
|
||||
if !CopyCString(path, path_bytes[:]) {
|
||||
return false
|
||||
}
|
||||
return HostExportImage(image, *path_bytes[0])
|
||||
}
|
||||
return HostExportImage(image, *path_bytes[0])
|
||||
}
|
||||
@@ -17,7 +17,6 @@ TextField :: #import "kryon/text_field";
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
Desktop :: #import "desktop_runtime";
|
||||
Keyboard :: #import "desktop_keyboard";
|
||||
#import "input_delivery"
|
||||
#import "byte_text_linux"
|
||||
|
||||
TEXT_INPUT_TYPED_LIMIT :: 64
|
||||
@@ -35,7 +34,7 @@ TextField :: #import "kryon/text_field";
|
||||
queue := Desktop.DesktopInputQueue()
|
||||
while queue.count > 0 {
|
||||
event := queue.events[queue.head]
|
||||
queue.head = (queue.head + 1) % INPUT_DELIVERY_CAPACITY
|
||||
queue.head = (queue.head + 1) % cast(s32)queue.events.count
|
||||
queue.count -= 1
|
||||
if event.text && text_input_typed_count < TEXT_INPUT_TYPED_LIMIT {
|
||||
text_input_typed[text_input_typed_count] = event.code
|
||||
|
||||
@@ -2,8 +2,18 @@
|
||||
#import, file "../../apps/practice/practice_probe.zi";
|
||||
#import, file "app_host.zi";
|
||||
#import, file "raylib_host.zi";
|
||||
#import, file "host_window.zi";
|
||||
#import, file "../app/app_types.zi";
|
||||
|
||||
OpenProbeWindow :: (size: WindowSize, title: string) -> bool {
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
return HostOpenWindow(size.width, size.height, title)
|
||||
} else {
|
||||
InitWindow(size.width, size.height, title)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// A negative result means no tool accepted the command line.
|
||||
TryRunStartupTool :: (app: *InnerBreeze, argc: s32, argv: **u8) -> s32 {
|
||||
mode := PracticeProbeMode(argc, argv)
|
||||
@@ -14,13 +24,14 @@ TryRunStartupTool :: (app: *InnerBreeze, argc: s32, argv: **u8) -> s32 {
|
||||
if mode == 1 || mode == 4 {
|
||||
size = ifx mode == 4 then WindowSize.{480, 780}
|
||||
else WindowSize.{900, 720}
|
||||
InitWindow(size.width, size.height, "Practice component probe")
|
||||
if !OpenProbeWindow(size, "Practice component probe") {
|
||||
return 1
|
||||
}
|
||||
} else {
|
||||
Prepare(argc, argv)
|
||||
size = InitialWindowSize()
|
||||
ConfigureWindow()
|
||||
InitWindow(size.width, size.height, WindowTitle())
|
||||
if FinishWindowSetup() == 0 {
|
||||
if !OpenProbeWindow(size, WindowTitle()) || FinishWindowSetup() == 0 {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
#import "session"
|
||||
#import "media_audio"
|
||||
#import "media_audio_host"
|
||||
#import "media_audio_raylib"
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
#import "media_audio_desktop"
|
||||
} else {
|
||||
#import "media_audio_raylib"
|
||||
}
|
||||
#import, file "../app/assets.zi";
|
||||
#import, file "../app/app_types.zi";
|
||||
|
||||
@@ -48,7 +52,11 @@ VoiceAudioStart :: (app: *InnerBreeze, voice: s32, path: string, gain: float32)
|
||||
return false
|
||||
}
|
||||
if !voice_audio_provider {
|
||||
MediaAudioUseRaylib()
|
||||
#if #defined(DESKTOP_HOST) {
|
||||
MediaAudioUseDesktop()
|
||||
} else {
|
||||
MediaAudioUseRaylib()
|
||||
}
|
||||
voice_audio_provider = true
|
||||
}
|
||||
voice_audio_session = session
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../../platform/app_trace.zi";
|
||||
#import, file "../../app/modal_rules.zi";
|
||||
#import, file "../../core/types.zi";
|
||||
#import, file "../../app/route_types.zi";
|
||||
@@ -50,7 +51,6 @@ BackgroundAudioInterrupt :: () #foreign c;
|
||||
LOG_ERROR :: 5;
|
||||
LOG_INFO :: 3;
|
||||
LOG_WARNING :: 4;
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
app_audio_ensure_ready :: (app: *InnerBreeze) #foreign c;
|
||||
settings_audio_stop_preview :: (app: *InnerBreeze) #foreign c;
|
||||
data_root_host_buffer :: () -> *u8 {
|
||||
@@ -158,11 +158,10 @@ copy_text_checked :: (out: *u8, out_size: s64, input: string) -> s32 {
|
||||
}
|
||||
|
||||
log_music :: (level: s32, message: string, detail: string) {
|
||||
format: [3]u8 = .[37, 115, 0]
|
||||
buffer: [1024]u8
|
||||
if !AppCopyText(message, buffer[:]) { return }
|
||||
if !AppAppendText(detail, buffer[:]) { return }
|
||||
NativeTraceLog(level, *format[0], *buffer[0])
|
||||
TraceLog(level, AppTextFromCString(*buffer[0], 1024))
|
||||
}
|
||||
|
||||
set_status :: (app: *InnerBreeze, message: string) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#import, file "../../platform/host_input.zi";
|
||||
#import, file "../../platform/host_clock.zi";
|
||||
#import, file "../../../apps/practice/practice_achievements.zi";
|
||||
#import, file "../../apps/shared_state.zi";
|
||||
#import, file "../../apps/module_host.zi";
|
||||
#import, file "../../apps/practice_types.zi";
|
||||
c3 :: #system_library "c";
|
||||
GetTabBarHeight :: () -> s32 #foreign c3;
|
||||
GetFrameTime :: () -> float32 #foreign c3;
|
||||
IsKeyPressed :: (key: s32) -> bool #foreign c3;
|
||||
KEY_SPACE :: 32;
|
||||
save_settings :: (app: *InnerBreeze) #foreign c3;
|
||||
app_play_breath_cue :: (app: *InnerBreeze, direction: s32) #foreign c3;
|
||||
@@ -361,12 +361,12 @@ patterns_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if IsKeyPressed(KEY_SPACE) || content.action == PRACTICE_PATTERNS_PAUSE {
|
||||
if HostKeyPressed(KEY_SPACE) || content.action == PRACTICE_PATTERNS_PAUSE {
|
||||
app.patterns.paused = 1
|
||||
}
|
||||
|
||||
if app.backgrounded == 0 {
|
||||
dt := cast(float64)GetFrameTime()
|
||||
dt := cast(float64)HostFrameSeconds()
|
||||
if dt < 0.0 {
|
||||
dt = 0.0
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../../platform/host_clock.zi";
|
||||
#import, file "../../apps/practice_ui_types.zi";
|
||||
#import, file "../../apps/practice_types.zi";
|
||||
#import, file "../practice_movement_host.zi";
|
||||
@@ -5,7 +6,6 @@
|
||||
#import, file "../../apps/module_host.zi";
|
||||
#import, file "../../apps/practice_types.zi";
|
||||
c3 :: #system_library "c";
|
||||
GetFrameTime :: () -> float32 #foreign c3;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c3;
|
||||
sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c3;
|
||||
#import, file "../../app/modal_rules.zi";
|
||||
@@ -213,7 +213,7 @@ update_timer :: (app: *InnerBreeze) {
|
||||
app.session_paused != 0 {
|
||||
return
|
||||
}
|
||||
advance_seconds(app, cast(float64)GetFrameTime())
|
||||
advance_seconds(app, cast(float64)HostFrameSeconds())
|
||||
}
|
||||
|
||||
// Speaks the line for the breath taken now. After the first round, whose
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#import, file "../../platform/host_clock.zi";
|
||||
#import, file "../../apps/practice_ui_types.zi";
|
||||
#import, file "../../apps/practice_types.zi";
|
||||
#import, file "../practice_movement_host.zi";
|
||||
#import, file "../../apps/shared_state.zi";
|
||||
c3 :: #system_library "c";
|
||||
GetFrameTime :: () -> float32 #foreign c3;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c3;
|
||||
sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c3;
|
||||
save_settings :: (app: *InnerBreeze) #foreign c3 "save_settings";
|
||||
@@ -214,7 +214,7 @@ TaiChiSubtitle :: (app: *InnerBreeze) -> string {
|
||||
#program_export
|
||||
tai_chi_draw_window :: (app: *InnerBreeze, picture: Rectangle, status: []u8) -> string {
|
||||
PracticeNarrationUpdate(app, "taichi", TaiChiCueKey(app))
|
||||
TaiChiDrawFigure(app.ui.session, *app.tai_chi, picture, cast(float64)GetFrameTime(), false,
|
||||
TaiChiDrawFigure(app.ui.session, *app.tai_chi, picture, cast(float64)HostFrameSeconds(), false,
|
||||
LocaleText("exercise_tai_chi"))
|
||||
status[0] = 0
|
||||
text := TaiChiCueText(app)
|
||||
@@ -226,7 +226,7 @@ tai_chi_draw_window :: (app: *InnerBreeze, picture: Rectangle, status: []u8) ->
|
||||
|
||||
TaiChiSessionFigure :: (app: *InnerBreeze, request: PracticeFigureRequest) {
|
||||
TaiChiDrawFigure(app.ui.session, *app.tai_chi, request.bounds,
|
||||
cast(float64)GetFrameTime(), app.tai_chi.time <= 0.0, request.alt_text)
|
||||
cast(float64)HostFrameSeconds(), app.tai_chi.time <= 0.0, request.alt_text)
|
||||
}
|
||||
|
||||
#program_export
|
||||
@@ -275,7 +275,7 @@ tai_chi_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
|
||||
}
|
||||
PracticeNarrationUpdate(app, "taichi", TaiChiCueKey(app))
|
||||
if app.session_paused == 0 {
|
||||
TaiChiAdvanceBy(app, cast(float64)GetFrameTime())
|
||||
TaiChiAdvanceBy(app, cast(float64)HostFrameSeconds())
|
||||
}
|
||||
unused center_x
|
||||
unused center_y
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
c :: #system_library "c";
|
||||
GetFrameTime :: () -> float32 #foreign c;
|
||||
#import, file "../../platform/host_clock.zi";
|
||||
#import "modal_rules"
|
||||
#import "app_types"
|
||||
#import "types"
|
||||
@@ -92,7 +92,7 @@ whm_preview_step_elapsed :: (preview: *BreathSession, remainder: *float64) {
|
||||
if preview == null {
|
||||
return
|
||||
}
|
||||
seconds := cast(float64)GetFrameTime()
|
||||
seconds := cast(float64)HostFrameSeconds()
|
||||
if seconds > 0.12 { seconds = 0.12 }
|
||||
fraction: float64 = 0.0
|
||||
if remainder != null { fraction = remainder.* }
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#import, file "../../platform/host_input.zi";
|
||||
#import, file "../../platform/app_trace.zi";
|
||||
#import, file "../../platform/host_clock.zi";
|
||||
Box :: #import "kryon/box";
|
||||
Button :: #import "kryon/button";
|
||||
Shape :: #import "kryon/shape";
|
||||
@@ -26,7 +29,6 @@ app_init :: (app: *void) #foreign c;
|
||||
app_close_modal :: (app: *InnerBreeze) #foreign c;
|
||||
app_draw_session_exit_modal :: (app: *InnerBreeze, can_save: s32, save_message: string, discard_message: string) -> SessionExitModalResult #foreign c;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c;
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c;
|
||||
practice_update_session_sounds :: (app: *InnerBreeze) #foreign c;
|
||||
practice_background_start :: (app: *InnerBreeze, id: s32) #foreign c;
|
||||
@@ -43,10 +45,7 @@ clampi :: (value: s32, min_value: s32, max_value: s32) -> s32 {
|
||||
sinf :: (v: float32) -> float32 #foreign c;
|
||||
cosf :: (v: float32) -> float32 #foreign c;
|
||||
fmaxf :: (a: float32, b: float32) -> float32 #foreign c;
|
||||
GetFrameTime :: () -> float32 #foreign c;
|
||||
IsMouseButtonReleased :: (button: s32) -> bool #foreign c;
|
||||
MOUSE_BUTTON_LEFT :: 0;
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
#import "modal_rules"
|
||||
#import "app_types"
|
||||
#import "session_screen"
|
||||
@@ -99,11 +98,7 @@ ANDROID :: #defined(ANDROID_BUILD)
|
||||
}
|
||||
|
||||
whm_log :: (level: s32, message: string) {
|
||||
format: [3]u8 = .[37, 115, 0]
|
||||
buffer: [256]u8
|
||||
if AppCopyText(message, buffer[:]) {
|
||||
NativeTraceLog(level, *format[0], *buffer[0])
|
||||
}
|
||||
TraceLog(level, message)
|
||||
}
|
||||
|
||||
whm_elapsed_remainder: float64 = 0.0;
|
||||
@@ -434,7 +429,7 @@ session_advance_visible_frame :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
|
||||
session_advance_seconds(app, cast(float64)GetFrameTime())
|
||||
session_advance_seconds(app, cast(float64)HostFrameSeconds())
|
||||
}
|
||||
|
||||
#program_export
|
||||
@@ -1179,8 +1174,8 @@ session_update_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32, hover
|
||||
return
|
||||
}
|
||||
if practice_whm_frame.double_tap {
|
||||
if IsMouseButtonReleased(MOUSE_BUTTON_LEFT) {
|
||||
now: float64 = GetTime()
|
||||
if HostPointer().released {
|
||||
now: float64 = HostSeconds()
|
||||
if app.breath_tap_last_time > 0.0 && now - app.breath_tap_last_time <= 0.35 {
|
||||
app.breath_tap_last_time = 0.0
|
||||
finish_hold(app)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
c :: #system_library "c";
|
||||
#import, file "../platform/host_input.zi";
|
||||
#import, file "../core/types.zi";
|
||||
#import, file "../app/app_types.zi";
|
||||
#import, file "../app/app.zi";
|
||||
#import, file "../app/app_route_state.zi";
|
||||
#import, file "../platform/raylib_host.zi";
|
||||
raylib :: #system_library "raylib";
|
||||
IsMouseButtonPressed :: (button: s32) -> bool #foreign raylib;
|
||||
GetMousePosition :: () -> Vector2 #foreign raylib;
|
||||
#import, file "../breaks/break_rules.zi";
|
||||
#import, file "../breaks/break_reminder_layout.zi";
|
||||
|
||||
@@ -468,8 +466,9 @@ break_overlay_draw :: (app: *InnerBreeze) {
|
||||
|
||||
// Practice chip clicks for this route; the overlay-window route
|
||||
// hit-tests the same geometry in app_breaks_window_click.
|
||||
if IsMouseButtonPressed(MOUSE_BUTTON_LEFT) {
|
||||
mouse := GetMousePosition()
|
||||
pointer := HostPointer()
|
||||
if pointer.pressed {
|
||||
mouse := Vector2.{pointer.x, pointer.y}
|
||||
if TreeHitAt(app.ui.session, mouse.x, mouse.y) >= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "geometry"
|
||||
#import "bundle_host"
|
||||
#import "byte_text_linux"
|
||||
@@ -86,7 +87,6 @@ diary_theme_dark: bool;
|
||||
diary_theme_parent: s32 = -1;
|
||||
diary_theme_colors: StyleColors;
|
||||
c :: #system_library "c";
|
||||
DiaryNow :: () -> float64 #foreign c "GetTime";
|
||||
|
||||
DiaryThemeColors :: (theme_id: s32, dark: bool) -> StyleColors {
|
||||
parent := ParentThemeRevision()
|
||||
@@ -360,7 +360,7 @@ DiaryShowText :: (text: string) {
|
||||
|
||||
DiaryNotice :: (key: string) {
|
||||
diary_spelling_notice = key
|
||||
diary_spelling_notice_until = DiaryNow() + 6.0
|
||||
diary_spelling_notice_until = HostSeconds() + 6.0
|
||||
}
|
||||
|
||||
DiaryHistoryCurrent :: () -> bool {
|
||||
@@ -442,7 +442,7 @@ DiarySpelling :: () {
|
||||
DiaryShowText(corrected)
|
||||
// The correction is one step, which undo reverts as a whole.
|
||||
DiaryHistoryObserve(*diary_history, diary_state.year, diary_state.month, diary_state.day,
|
||||
diary_state.text, DiaryNow(), false)
|
||||
diary_state.text, HostSeconds(), false)
|
||||
}
|
||||
|
||||
#program_export
|
||||
@@ -451,7 +451,7 @@ diary_screen_draw :: (app: *InnerBreeze) {
|
||||
DiaryPhotoPicker(app)
|
||||
typed: [512]u8
|
||||
input := SampleTextAreaInput(diary_focused, typed[:])
|
||||
input.now_seconds = DiaryNow()
|
||||
input.now_seconds = HostSeconds()
|
||||
DiaryPortableFrame(app.ui.session,
|
||||
Rectangle.{0.0, 0.0, cast(float32)app.ui.view_width,
|
||||
cast(float32)(app.ui.view_height - app_content_bottom_reserved(app))},
|
||||
@@ -480,7 +480,7 @@ diary_screen_draw :: (app: *InnerBreeze) {
|
||||
diary_ui.bottom = app_content_bottom_reserved(app)
|
||||
diary_ui.scale = MetricsScale()
|
||||
diary_ui.font = AppFontSize()
|
||||
diary_ui.now = DiaryNow()
|
||||
diary_ui.now = HostSeconds()
|
||||
diary_ui.photo_error = diary_photo_error
|
||||
colors := DiaryThemeColors(app.theme_id, app.dark_mode != 0)
|
||||
diary_ui.link_color = colors.link
|
||||
@@ -508,7 +508,7 @@ diary_screen_draw :: (app: *InnerBreeze) {
|
||||
WidgetHostEnd()
|
||||
if diary_loaded && !diary_state.load_error {
|
||||
DiaryHistoryObserve(*diary_history, diary_state.year, diary_state.month, diary_state.day,
|
||||
diary_state.text, DiaryNow(), true)
|
||||
diary_state.text, HostSeconds(), true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "geometry"
|
||||
Layout :: #import "kryon/layout";
|
||||
#import "kryon/tree"
|
||||
@@ -12,7 +13,6 @@ Layout :: #import "kryon/layout";
|
||||
#import, file "../apps/package_files.zi";
|
||||
#import, file "../../apps/lists/sharing.zi";
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c;
|
||||
#import, file "../app/app_types.zi";
|
||||
#import, file "../app/locale.zi";
|
||||
@@ -431,7 +431,7 @@ draw_elist_screen :: (app: *InnerBreeze) {
|
||||
.pending_count_text = AppTextFromCString(*lists_pending_number[0], 24),
|
||||
.next_id = next_id, .profile_icon = app.profile_picture_icon}
|
||||
message := elist_message_for(*app.elist, LISTS_FRAME, -1)
|
||||
message.now = GetTime()
|
||||
message.now = HostSeconds()
|
||||
WidgetHostBegin(app.ui.session, HostedAssetAllowed)
|
||||
AppsUiBegin(ListsUiCall, cast(*void)app)
|
||||
message = ListsUiRun(message)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import, file "../apps/shared_state.zi";
|
||||
#import, file "../apps/habits_types.zi";
|
||||
#import, file "../apps/habits_ui_types.zi";
|
||||
@@ -14,7 +15,6 @@
|
||||
// their days and does what it asks. Habit persistence and counting rules
|
||||
// live in the habit modules.
|
||||
raylib_input :: #system_library "raylib";
|
||||
GetTime :: () -> float64 #foreign raylib_input;
|
||||
|
||||
#import, file "../app/app.zi";
|
||||
#import, file "../core/types.zi";
|
||||
@@ -579,7 +579,7 @@ HabitScreenListFrame :: (app: *InnerBreeze, geometry: HabitScreenGeometry) -> Ha
|
||||
.ink_dark_class = CssClass("ink-dark"),
|
||||
.ink_light_class = CssClass("ink-light"),
|
||||
.modal_active = app.modal.active != 0, .touch = HabitScreenTouch(),
|
||||
.now = GetTime(), .today = habits_today_index(), .habit_count = habits.count,
|
||||
.now = HostSeconds(), .today = habits_today_index(), .habit_count = habits.count,
|
||||
.habit_limit = HABIT_MAX, .halves = HabitShopBalance(app),
|
||||
.screen_mode = habits.screen_mode, .view_mode = habits.view_mode,
|
||||
.selected = habits.selected, .scroll = habits.scroll,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "std/json_scan"
|
||||
#import "std/format"
|
||||
#import, file "../../apps/lumi/lumi_achievements.zi";
|
||||
@@ -141,7 +142,6 @@ lumi_agreement_bytes: [8192]u8;
|
||||
lumi_agreement_strong: [32]Text.Range;
|
||||
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
|
||||
// Seconds of row measuring per frame. A long chat is measured across frames
|
||||
// behind a loading bar, so nothing else on screen, such as a minimized
|
||||
@@ -995,12 +995,12 @@ LumiRowsMeasure :: () -> bool {
|
||||
if lumi_row_offsets.count == lumi_ui.chat_count + 1 {
|
||||
return true
|
||||
}
|
||||
started := GetTime()
|
||||
started := HostSeconds()
|
||||
access := LumiRowAccessNow()
|
||||
while lumi_rows_measured < lumi_ui.chat_count {
|
||||
unused LumiMeasuredRow(lumi_rows_measured, access)
|
||||
lumi_rows_measured += 1
|
||||
if GetTime() - started >= LUMI_MEASURE_BUDGET {
|
||||
if HostSeconds() - started >= LUMI_MEASURE_BUDGET {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -1026,7 +1026,7 @@ LumiDrawLoading :: (app: *InnerBreeze) {
|
||||
LoadingScreen.Draw(app.ui.session, LoadingScreen.Props.{.key = Layout.KeyHash("inbe/lumi/loading"),
|
||||
.bounds = area, .title = app_nav_route_label(APP_NAV_ROUTE_LUMI),
|
||||
.detail = LocaleText("lumi_loading"),
|
||||
.icon_shape = AssetRead("assets/lumi/sidebar.shape").data, .now = GetTime(),
|
||||
.icon_shape = AssetRead("assets/lumi/sidebar.shape").data, .now = HostSeconds(),
|
||||
.scale = MetricsScale(), .has_progress = lumi_ui.chat_count > 0,
|
||||
.completed = lumi_rows_measured, .total = lumi_ui.chat_count})
|
||||
AppRequestSmoothFrames(2)
|
||||
@@ -1149,7 +1149,7 @@ lumi_screen_draw :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
// Opening the chat again starts from its newest messages, like Telegram.
|
||||
opened_at := GetTime()
|
||||
opened_at := HostSeconds()
|
||||
if opened_at - lumi_last_drawn > 1.0 {
|
||||
LumiStoreShowNewest()
|
||||
lumi_history_loading = false
|
||||
@@ -1179,7 +1179,7 @@ lumi_screen_draw :: (app: *InnerBreeze) {
|
||||
// to animate, and a quiet frame does not animate.
|
||||
quiet := LumiFrameQuiet(app)
|
||||
if !quiet || lumi_ui.now == 0.0 {
|
||||
lumi_ui.now = GetTime()
|
||||
lumi_ui.now = HostSeconds()
|
||||
}
|
||||
if !lumi_ui.waiting {
|
||||
lumi_waiting_since = -1.0
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// The screen of an app the node offers, such as Chess. The app draws itself
|
||||
// with hosted Kryon widgets; this screen supplies its frame, its text in the
|
||||
// person's language and the account's friends.
|
||||
#import, file "../platform/host_input.zi";
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "byte_text_linux"
|
||||
#import "text_buffer"
|
||||
#import "json_scan"
|
||||
@@ -23,9 +25,7 @@ Text :: #import "kryon/text";
|
||||
#import "tree_input"
|
||||
#import "test_driver"
|
||||
#import, file "../platform/raylib_text_input.zi";
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
#import "kryon/raylib_runtime"
|
||||
}
|
||||
#import "image_raster"
|
||||
#import, file "../apps/node_apps.zi";
|
||||
#import, file "../apps/node_app_runner.zi";
|
||||
#import, file "../apps/node_app_open.zi";
|
||||
@@ -70,15 +70,11 @@ using TextAlign;
|
||||
using AndroidImportKind;
|
||||
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
NodePressedKey :: () -> s32 #foreign c "GetKeyPressed";
|
||||
NodeKeyRepeated :: (key: s32) -> bool #foreign c "IsKeyPressedRepeat";
|
||||
|
||||
// A held key repeats as the system repeats typing, so a game keeps moving
|
||||
// while an arrow is held; GetKeyPressed reports only the first press.
|
||||
// while an arrow is held; a press reports only the first one.
|
||||
NodeRepeatedKey :: () -> s32 {
|
||||
for key: cast(s32)32..348 {
|
||||
if NodeKeyRepeated(key) { return key }
|
||||
if HostKeyRepeated(key) { return key }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -137,7 +133,7 @@ NodeScreenUiCall :: (context: *void, module: *u8, function: *u8,
|
||||
return 1
|
||||
}
|
||||
if name == "AppKeyHost" && count == 0 {
|
||||
key := NodeAppKeyFor(NodePressedKey(), NodeRepeatedKey())
|
||||
key := NodeAppKeyFor(HostKeyPressedThisFrame(), NodeRepeatedKey())
|
||||
if key == 0 && TestDriverActive() {
|
||||
for candidate: cast(s32)32..348 {
|
||||
if TestDriverKeyPressed(candidate) {
|
||||
@@ -292,7 +288,7 @@ NodeScreenPictureProgress :: (slot: s32) -> NodeScreenPictures {
|
||||
for image: node_tree_images {
|
||||
if TextUntilNul(image.digest[:]) != digest { continue }
|
||||
result.total += 1
|
||||
if ImageWidth(image.path) >= 0 { result.ready += 1 }
|
||||
if AssetWidth(image.path) >= 0 { result.ready += 1 }
|
||||
}
|
||||
}
|
||||
return result
|
||||
@@ -310,7 +306,7 @@ NodeScreenProgress :: (app: *InnerBreeze, area: Rectangle, title: string,
|
||||
}
|
||||
LoadingScreen.Draw(app.ui.session, LoadingScreen.Props.{.key = Layout.KeyHash("inbe/app/loading"),
|
||||
.bounds = area, .title = title, .detail = stage, .icon_shape = shape,
|
||||
.now = GetTime(), .scale = MetricsScale(), .has_progress = known_progress && total > 0,
|
||||
.now = HostSeconds(), .scale = MetricsScale(), .has_progress = known_progress && total > 0,
|
||||
.completed = done, .total = total})
|
||||
AppRequestSmoothFrames(2)
|
||||
}
|
||||
@@ -384,7 +380,7 @@ node_app_screen_draw :: (app: *InnerBreeze) {
|
||||
}
|
||||
node_screen_frame = AppUiFrame.{.session = app.ui.session, .width = app.ui.view_width,
|
||||
.height = app.ui.view_height, .bottom = app_content_bottom_reserved(app),
|
||||
.scale = MetricsScale(), .font = AppFontSize(), .now = GetTime(), .dark = app.dark_mode != 0}
|
||||
.scale = MetricsScale(), .font = AppFontSize(), .now = HostSeconds(), .dark = app.dark_mode != 0}
|
||||
unused AppCopyText(storage_get_setting_text("sync_public_id"), node_screen_account[:])
|
||||
message := AppMessage.{.action = APP_FRAME, .screen = ScreenNodeApp, .name = name,
|
||||
.locale = AppTextFromCString(*app.language[0], 16),
|
||||
@@ -396,7 +392,7 @@ node_app_screen_draw :: (app: *InnerBreeze) {
|
||||
typed: [1024]u8
|
||||
if NodeAppPortable(slot) || node_runners[slot].nested != null {
|
||||
input := SampleTextFieldInput(true, typed[:])
|
||||
key := NodeAppKeyFor(NodePressedKey(), NodeRepeatedKey())
|
||||
key := NodeAppKeyFor(HostKeyPressedThisFrame(), NodeRepeatedKey())
|
||||
// Native and IME commands are sampled with the field input. Keep
|
||||
// them even when the raw key queue has already been drained.
|
||||
if input.commit { key = TextInputKeyEnter }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
c3 :: #system_library "c";
|
||||
#import, file "../platform/host_input.zi";
|
||||
#import "byte_text_linux"
|
||||
IsKeyPressed :: (key: s32) -> bool #foreign c3;
|
||||
#import, file "../platform/app_trace.zi";
|
||||
KEY_LEFT :: 263;
|
||||
KEY_RIGHT :: 262;
|
||||
@@ -488,7 +488,7 @@ practice_home_frame_for :: (app: *InnerBreeze, ids: []s32, listed: s32) -> Pract
|
||||
// While Lumi's guide is open, the arrow keys and swipes are the
|
||||
// guide's: choosing another practice under it would start it over.
|
||||
.choosing = app.modal.active == 0 && practice_screen_first_run_guide_active(app) == 0,
|
||||
.key_left = IsKeyPressed(KEY_LEFT), .key_right = IsKeyPressed(KEY_RIGHT),
|
||||
.key_left = HostKeyPressed(KEY_LEFT), .key_right = HostKeyPressed(KEY_RIGHT),
|
||||
.swipe = app.practice_home_swipe, .swipe_frame = app.ui.manual_swipe_frame,
|
||||
.practice = app.exercise_type, .title = practice_home_title(app.exercise_type),
|
||||
.subtitle = practice_home_subtitle(app.exercise_type),
|
||||
@@ -801,9 +801,9 @@ practice_screen_draw_first_run_guide :: (app: *InnerBreeze) {
|
||||
.reserved_top = app_content_top_reserved(app),
|
||||
.reserved_bottom = app_content_bottom_reserved(app),
|
||||
.max_width = AppScale(300),
|
||||
.previous_requested = IsKeyPressed(KEY_LEFT),
|
||||
.next_requested = IsKeyPressed(KEY_RIGHT) || IsKeyPressed(KEY_ENTER),
|
||||
.close_requested = IsKeyPressed(KEY_BACK) || IsKeyPressed(KEY_ESCAPE)
|
||||
.previous_requested = HostKeyPressed(KEY_LEFT),
|
||||
.next_requested = HostKeyPressed(KEY_RIGHT) || HostKeyPressed(KEY_ENTER),
|
||||
.close_requested = HostKeyPressed(KEY_BACK) || HostKeyPressed(KEY_ESCAPE)
|
||||
})
|
||||
if result.changed != 0 {
|
||||
save_settings(app)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../platform/host_clock.zi";
|
||||
#import "entity/dew_model"
|
||||
ProfileReferralLocale :: #import "entity/referral_locales";
|
||||
#import "geometry"
|
||||
@@ -51,7 +52,6 @@ profile_topup_failed: bool;
|
||||
profile_topup_copied: bool;
|
||||
profile_play_prices_deadline: float64;
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
EntityHostOpenReferrals :: (app: *InnerBreeze, invitation: string) -> bool #foreign c;
|
||||
// Top-up minimums under 0.001 XMR are not worth naming.
|
||||
TopUpMinimumShown :: 1000000000
|
||||
@@ -457,7 +457,7 @@ ProfileTopUpOpen :: (app: *InnerBreeze) {
|
||||
profile_topup_started = false
|
||||
profile_topup_failed = false
|
||||
profile_topup_copied = false
|
||||
profile_play_prices_deadline = GetTime() + 15.0
|
||||
profile_play_prices_deadline = HostSeconds() + 15.0
|
||||
if dew_play.enabled {
|
||||
// Ask on opening, even when the idle app has drawn very few frames.
|
||||
unused PlayBillingProducts(DEW_PLAY_PRODUCTS, dew_play.state[:])
|
||||
@@ -529,7 +529,7 @@ ProfileTopUpPlayNotice :: (billing: *PlayBillingState, shown: s32) -> string {
|
||||
if error != "" && error != "cancelled" {
|
||||
return LocaleText("profile_dew_play_unavailable")
|
||||
}
|
||||
if GetTime() >= profile_play_prices_deadline {
|
||||
if HostSeconds() >= profile_play_prices_deadline {
|
||||
return LocaleText("profile_dew_play_unavailable")
|
||||
}
|
||||
return LocaleText("profile_dew_play_loading")
|
||||
@@ -587,7 +587,7 @@ ProfileTopUpPlayContent :: (app: *InnerBreeze, x: s32, y: *s32, width: s32, draw
|
||||
}
|
||||
if shown == 0 && notice == LocaleText("profile_dew_play_unavailable") {
|
||||
if ProfileDewButton(app, LocaleText("retry_button"), x, y, width, busy, draw) {
|
||||
profile_play_prices_deadline = GetTime() + 15.0
|
||||
profile_play_prices_deadline = HostSeconds() + 15.0
|
||||
unused PlayBillingProducts(DEW_PLAY_PRODUCTS, dew_play.state[:])
|
||||
}
|
||||
} else if shown == 0 && notice == LocaleText("profile_dew_play_loading") {
|
||||
@@ -596,7 +596,7 @@ ProfileTopUpPlayContent :: (app: *InnerBreeze, x: s32, y: *s32, width: s32, draw
|
||||
.key = Layout.KeyHash("profile/dew/play/loading"),
|
||||
.bounds = Rectangle.{cast(float32)x, cast(float32)y.*,
|
||||
cast(float32)width, cast(float32)AppScale(28)},
|
||||
.now = GetTime(), .scale = MetricsScale() * 0.7})
|
||||
.now = HostSeconds(), .scale = MetricsScale() * 0.7})
|
||||
AppRequestSmoothFrames(2)
|
||||
}
|
||||
y.* += AppScale(36)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import, file "../../platform/host_clock.zi";
|
||||
#import "geometry"
|
||||
#import "control_props"
|
||||
Button :: #import "kryon/button";
|
||||
@@ -30,7 +31,6 @@ using ButtonEmphasis;
|
||||
using Text.Wrap;
|
||||
using AppNavRoute;
|
||||
c :: #system_library "c";
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
|
||||
appearance_inspector: [8192]u8;
|
||||
appearance_inspector_revision: s32 = -1;
|
||||
@@ -197,10 +197,10 @@ settings_appearance_draw :: (app: *InnerBreeze, x: s32, width: s32,
|
||||
if AppReplaceText(bytes[:], edited.edit.start, edited.edit.end, edited.edit.replacement) {
|
||||
unused StyleSetDraft(style_editor_scope, AppTextFromCString(*bytes[0], StyleSourceCapacity))
|
||||
state.custom_pending = true
|
||||
state.custom_preview_at = GetTime() + 0.25
|
||||
state.custom_preview_at = HostSeconds() + 0.25
|
||||
}
|
||||
}
|
||||
if state.custom_pending && GetTime() >= state.custom_preview_at {
|
||||
if state.custom_pending && HostSeconds() >= state.custom_preview_at {
|
||||
unused AppearancePreview(app, style_editor_scope)
|
||||
state.custom_pending = false
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#import "c_string"
|
||||
#import "byte_text_linux"
|
||||
#import "file"
|
||||
#import "vec"
|
||||
#import, file "sqlite.zi";
|
||||
|
||||
// Filesystem calls have native platform implementations. Upgrade decisions and
|
||||
@@ -8,8 +11,6 @@ UpgradePathExists :: (path: *u8) -> s32 #foreign c "path_exists";
|
||||
UpgradeRemove :: (path: *u8) -> s32 #foreign c "storage_remove_path";
|
||||
UpgradeRename :: (source: *u8, destination: *u8) -> s32 #foreign c "storage_rename_path";
|
||||
UpgradeWriteMarker :: (path: *u8, value: *u8) -> s32 #foreign c "storage_write_migration_marker";
|
||||
UpgradeLoadFile :: (path: *u8, size: *s32) -> *u8 #foreign c "LoadFileData";
|
||||
UpgradeUnloadFile :: (bytes: *u8) #foreign c "UnloadFileData";
|
||||
|
||||
UpgradePathCapacity :: 512
|
||||
|
||||
@@ -37,22 +38,18 @@ UpgradeValidPath :: (path: *u8) -> bool {
|
||||
return index > 0 && index < UpgradePathCapacity
|
||||
}
|
||||
|
||||
// The marker holds the upgraded database's name and a newline.
|
||||
UpgradeMarkerValid :: (marker: *u8, database_name: *u8) -> bool {
|
||||
size: s32 = 0
|
||||
bytes := UpgradeLoadFile(marker, *size)
|
||||
if bytes == null || size <= 1 {
|
||||
if bytes != null {
|
||||
UpgradeUnloadFile(bytes)
|
||||
}
|
||||
bytes: Vec(u8)
|
||||
if !ReadFileInto(TextFromCString(marker), *bytes) || bytes.count <= 1 {
|
||||
return false
|
||||
}
|
||||
size := cast(s32)bytes.count
|
||||
index: s32 = 0
|
||||
while index < size && database_name[index] != cast(u8)0 && bytes[index] == database_name[index] {
|
||||
index += 1
|
||||
}
|
||||
valid := database_name[index] == cast(u8)0 && index + 1 == size && bytes[index] == cast(u8)10
|
||||
UpgradeUnloadFile(bytes)
|
||||
return valid
|
||||
return database_name[index] == cast(u8)0 && index + 1 == size && bytes[index] == cast(u8)10
|
||||
}
|
||||
|
||||
UpgradeQuickCheck :: (database: *void) -> bool {
|
||||
|
||||
+3
-6
@@ -4,7 +4,6 @@ time :: (t: *s64) -> s64 #foreign c;
|
||||
LOG_INFO :: 3
|
||||
LOG_WARNING :: 4
|
||||
LOG_ERROR :: 5
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
sqlite3_open_v2 :: (path: *u8, database: **void, flags: s32, vfs: *u8) -> s32 #foreign sqlite3_lib "sqlite3_open_v2";
|
||||
sqlite3_busy_timeout :: (database: *void, milliseconds: s32) -> s32 #foreign sqlite3_lib "sqlite3_busy_timeout";
|
||||
sqlite3_total_changes64 :: (database: *void) -> s64 #foreign sqlite3_lib "sqlite3_total_changes64";
|
||||
@@ -65,6 +64,7 @@ storage_sqlite_errmsg :: (db: *void) -> *u8 #foreign sqlite3_lib "sqlite3_errmsg
|
||||
STORAGE_PATH_SIZE :: 1024
|
||||
|
||||
|
||||
#import, file "../platform/app_trace.zi";
|
||||
#import, file "state.zi";
|
||||
#import, file "storage_layout.zi";
|
||||
#import, file "path_join.zi";
|
||||
@@ -85,10 +85,7 @@ migrate_legacy_file_sessions_once :: (root: *u8) -> s32 #foreign c;
|
||||
#import, file "sql_transaction.zi";
|
||||
|
||||
LogStorage :: (level: s32, message: string) {
|
||||
buffer: [256]u8
|
||||
if AppCopyText(message, buffer[:]) {
|
||||
NativeTraceLog(level, *buffer[0])
|
||||
}
|
||||
TraceLog(level, message)
|
||||
}
|
||||
|
||||
LogStorageText :: (level: s32, message: string, detail: string) {
|
||||
@@ -104,7 +101,7 @@ LogStorageText :: (level: s32, message: string, detail: string) {
|
||||
index += 1
|
||||
}
|
||||
buffer[used] = cast(u8)0
|
||||
NativeTraceLog(level, *buffer[0])
|
||||
TraceLog(level, AppTextFromCString(*buffer[0], 256))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,26 +2,66 @@
|
||||
// Directory enumeration and byte loading are native filesystem operations;
|
||||
// path recognition and session insertion are checked Ziran rules.
|
||||
#import "c_string"
|
||||
#import "byte_text_linux"
|
||||
#import "file"
|
||||
#import "file_linux"
|
||||
#import "vec"
|
||||
#import, file "legacy_session.zi";
|
||||
|
||||
c :: #system_library "c";
|
||||
|
||||
// The layout of raylib's FilePathList, which the host returns by value.
|
||||
LegacyPaths :: struct {
|
||||
count: u32
|
||||
paths: **u8
|
||||
}
|
||||
|
||||
LegacyDirectoryFiles :: (root: *u8, filter: *u8,
|
||||
recursive: bool) -> LegacyPaths #foreign c "LoadDirectoryFilesEx";
|
||||
LegacyUnloadDirectoryFiles :: (paths: LegacyPaths) #foreign c "UnloadDirectoryFiles";
|
||||
LegacyIsRegularFile :: (path: *u8) -> bool #foreign c "IsPathFile";
|
||||
LegacyLoadFileData :: (path: *u8, size: *s32) -> *u8 #foreign c "LoadFileData";
|
||||
LegacyUnloadFileData :: (bytes: *u8) #foreign c "UnloadFileData";
|
||||
LegacyMetaEquals :: (key: *u8, value: *u8) -> s32 #foreign c "meta_equals";
|
||||
LegacyDbExecText :: (sql: *u8, value: *u8) -> s32 #foreign c "db_exec_text";
|
||||
LegacyStoragePersist :: () #foreign c "storage_schedule_persist";
|
||||
|
||||
// Imports every session file below DIRECTORY, in its subfolders too. False
|
||||
// when a session file could not be read or imported; a folder that cannot
|
||||
// be listed holds nothing to import.
|
||||
LegacyImportTree :: (directory: string, imported: *u32) -> bool {
|
||||
cursor := OpenDirectory(directory)
|
||||
if !cursor.valid {
|
||||
return true
|
||||
}
|
||||
defer { unused CloseDirectory(*cursor) }
|
||||
ok := true
|
||||
while true {
|
||||
entry := NextDirectoryEntry(*cursor)
|
||||
if !entry.valid {
|
||||
break
|
||||
}
|
||||
name := TextFromCString(*entry.name[0])
|
||||
if name == "." || name == ".." {
|
||||
continue
|
||||
}
|
||||
joined: Vec(u8)
|
||||
BuilderPrint(*joined, "%/%", directory, name)
|
||||
path := BuilderFinish(joined)
|
||||
// A link or an unknown entry is followed, as stat would.
|
||||
folder := entry.kind == .Directory
|
||||
if entry.kind == .Link || entry.kind == .Unknown {
|
||||
folder = DirectoryExists(path)
|
||||
}
|
||||
if folder {
|
||||
if !LegacyImportTree(path, imported) {
|
||||
ok = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
c_path: [4096]u8
|
||||
if entry.kind == .Other || !CopyCString(path, c_path[:]) || LegacyIsSessionPath(*c_path[0]) == 0 {
|
||||
continue
|
||||
}
|
||||
bytes: Vec(u8)
|
||||
if !ReadFileInto(path, *bytes) || bytes.count == 0 {
|
||||
ok = false
|
||||
} else if LegacyImportBytes(*c_path[0], *bytes[0], cast(u64)bytes.count) == 0 {
|
||||
ok = false
|
||||
} else {
|
||||
imported.* += 1
|
||||
}
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
#program_export
|
||||
migrate_legacy_file_sessions_once :: (root: *u8) -> s32 {
|
||||
if root == null || root[0] == cast(u8)0 {
|
||||
@@ -35,31 +75,8 @@ migrate_legacy_file_sessions_once :: (root: *u8) -> s32 {
|
||||
if LegacyMetaEquals(*marker[0], *completed[0]) != 0 {
|
||||
return 1
|
||||
}
|
||||
paths := LegacyDirectoryFiles(root, null, true)
|
||||
imported: u32 = 0
|
||||
ok := true
|
||||
index: u32 = 0
|
||||
while index < paths.count {
|
||||
path := paths.paths[index]
|
||||
if path != null && LegacyIsRegularFile(path) && LegacyIsSessionPath(path) != 0 {
|
||||
size: s32 = 0
|
||||
bytes := LegacyLoadFileData(path, *size)
|
||||
if bytes == null || size <= 0 {
|
||||
ok = false
|
||||
} else {
|
||||
if LegacyImportBytes(path, bytes, cast(u64)size) == 0 {
|
||||
ok = false
|
||||
} else {
|
||||
imported += 1
|
||||
}
|
||||
}
|
||||
if bytes != null {
|
||||
LegacyUnloadFileData(bytes)
|
||||
}
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
LegacyUnloadDirectoryFiles(paths)
|
||||
ok := LegacyImportTree(TextFromCString(root), *imported)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user