Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5729306ae | ||
|
|
d6373dab29 |
No files matched your search
@@ -1,4 +1,11 @@
|
||||
# Changelog
|
||||
## [1.2.4] - 2026-06-11
|
||||
### Fixed
|
||||
- Android sessions continue correctly when the notification shade causes focus loss with background playback enabled.
|
||||
- Android safe-area insets now offset the viewport at the top instead of creating bottom-only padding.
|
||||
- Progressive start speed defaults to 3, normal speed defaults to 6, and the start speed editor preview animates at the exact selected speed.
|
||||
- Dropdown menu text is clipped cleanly while scrolling.
|
||||
|
||||
## [1.2.3] - 2026-06-10
|
||||
### Fixed
|
||||
- History editing now scrolls to the active field once and keeps 16px Unifont row text aligned without clipping.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 67 KiB |
@@ -34,8 +34,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdk 19
|
||||
targetSdk 35
|
||||
versionCode 24
|
||||
versionName "1.2.3"
|
||||
versionCode 25
|
||||
versionName "1.2.4"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,14 +30,17 @@ public class MainActivity extends NativeActivity {
|
||||
private final int[] cachedInsets = new int[6];
|
||||
private boolean insetsInitialized = false;
|
||||
private PowerManager.WakeLock wakeLock = null;
|
||||
private boolean activityPaused = false;
|
||||
private boolean windowFocused = true;
|
||||
private boolean backgroundExecutionActive = false;
|
||||
private boolean autoPausedForLifecycle = false;
|
||||
|
||||
private native void nativeSetInsets(int status, int nav,
|
||||
int cutoutLeft, int cutoutTop, int cutoutRight, int cutoutBottom);
|
||||
private native void nativeWakeLockReady();
|
||||
private native void nativeTimerActivate();
|
||||
private native void nativeTimerDeactivate();
|
||||
private native void nativeSetBackgroundActive(boolean active);
|
||||
private native int nativeGetPlayInBackground();
|
||||
private native void nativePauseSession();
|
||||
private native int nativePauseSession();
|
||||
private native void nativeResumeSession();
|
||||
private native void nativeImportSelectedFile(String path);
|
||||
private native void nativeImportCancelled();
|
||||
@@ -296,36 +299,52 @@ public class MainActivity extends NativeActivity {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void syncLifecycleState(String reason) {
|
||||
int playInBackground = nativeGetPlayInBackground();
|
||||
boolean shouldRunInBackground = playInBackground != 0 && (activityPaused || !windowFocused);
|
||||
|
||||
Log.d(TAG, reason + ": play_in_background=" + playInBackground
|
||||
+ " activityPaused=" + activityPaused
|
||||
+ " windowFocused=" + windowFocused
|
||||
+ " backgroundActive=" + backgroundExecutionActive);
|
||||
|
||||
if (backgroundExecutionActive != shouldRunInBackground) {
|
||||
nativeSetBackgroundActive(shouldRunInBackground);
|
||||
backgroundExecutionActive = shouldRunInBackground;
|
||||
}
|
||||
|
||||
if (playInBackground == 0) {
|
||||
if (activityPaused && !autoPausedForLifecycle) {
|
||||
autoPausedForLifecycle = nativePauseSession() != 0;
|
||||
} else if (!activityPaused && autoPausedForLifecycle) {
|
||||
nativeResumeSession();
|
||||
autoPausedForLifecycle = false;
|
||||
}
|
||||
} else if (autoPausedForLifecycle) {
|
||||
nativeResumeSession();
|
||||
autoPausedForLifecycle = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
int playInBackground = nativeGetPlayInBackground();
|
||||
Log.d(TAG, "onPause: play_in_background = " + playInBackground);
|
||||
if (playInBackground == 0) {
|
||||
// Auto-pause if play in background is disabled
|
||||
Log.d(TAG, "onPause: Auto-pausing session (play in background disabled)");
|
||||
nativePauseSession();
|
||||
} else {
|
||||
// Continue in background
|
||||
Log.d(TAG, "onPause: Continuing in background (play in background enabled)");
|
||||
nativeTimerActivate();
|
||||
}
|
||||
activityPaused = true;
|
||||
syncLifecycleState("onPause");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int playInBackground = nativeGetPlayInBackground();
|
||||
Log.d(TAG, "onResume: play_in_background = " + playInBackground);
|
||||
if (playInBackground == 0) {
|
||||
// Auto-resume if play in background is disabled
|
||||
Log.d(TAG, "onResume: Auto-resuming session (play in background disabled)");
|
||||
nativeResumeSession();
|
||||
} else {
|
||||
// Just deactivate timer (session continued in background)
|
||||
Log.d(TAG, "onResume: Deactivating background timer");
|
||||
nativeTimerDeactivate();
|
||||
}
|
||||
activityPaused = false;
|
||||
syncLifecycleState("onResume");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
windowFocused = hasFocus;
|
||||
syncLifecycleState("onWindowFocusChanged");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
### Fixed
|
||||
- Android sessions continue correctly when the notification shade causes focus loss with background playback enabled.
|
||||
- Android safe-area insets now offset the viewport at the top instead of creating bottom-only padding.
|
||||
- Progressive start speed defaults to 3, normal speed defaults to 6, and the start speed editor preview animates at the exact selected speed.
|
||||
- Dropdown menu text is clipped cleanly while scrolling.
|
||||
+1
-1
@@ -79,7 +79,7 @@
|
||||
|
||||
<h1>Inner Breeze</h1>
|
||||
<p>guided breathing meditation based on the Wim Hof method</p>
|
||||
<p class="version">1.2.3</p>
|
||||
<p class="version">1.2.4</p>
|
||||
|
||||
<!-- Direct Downloads -->
|
||||
<nav aria-label="Platform downloads" class="platform-buttons">
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ inbeinit(Inbe *l)
|
||||
l->rmin = 25;
|
||||
l->rmax = 50;
|
||||
l->dir = 0;
|
||||
l->speed_level = 3;
|
||||
l->speed_level = DefaultSpeedLevel;
|
||||
l->breath_frame = 0;
|
||||
l->breath_half_ticks = 120;
|
||||
l->frame = 0;
|
||||
@@ -90,7 +90,7 @@ inbeinit(Inbe *l)
|
||||
l->max_rounds = DefaultMaxRounds;
|
||||
l->pause_seconds = DefaultPauseSeconds;
|
||||
l->progressive_speed = 1;
|
||||
l->progressive_start_speed = 3;
|
||||
l->progressive_start_speed = DefaultProgressiveStartSpeed;
|
||||
#ifdef __ANDROID__
|
||||
l->play_in_background = 1; // Enabled by default on Android
|
||||
#else
|
||||
|
||||
+3
-1
@@ -22,9 +22,11 @@ enum {
|
||||
enum {
|
||||
CountSize = 4,
|
||||
MaxRounds = 12,
|
||||
DefaultSpeedLevel = 6,
|
||||
DefaultMaxRounds = 4,
|
||||
DefaultMaxBreaths = 30,
|
||||
DefaultPauseSeconds = 2
|
||||
DefaultPauseSeconds = 2,
|
||||
DefaultProgressiveStartSpeed = 3
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
+11
-2
@@ -112,8 +112,17 @@ Motiv
|
||||
[speed_label]
|
||||
Rychlost
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
Progresivni rychlost
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
Pocatecni rychlost
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Upravit pocatecni rychlost
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Pocatecni rychlost
|
||||
---
|
||||
[play_in_background_label]
|
||||
Přehrávat na pozadí
|
||||
|
||||
+11
-2
@@ -94,8 +94,17 @@ Thema
|
||||
[speed_label]
|
||||
Geschwindigkeit
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
Progressive Geschwindigkeit
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
Startgeschwindigkeit
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Startgeschwindigkeit andern
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Startgeschwindigkeit
|
||||
---
|
||||
[play_in_background_label]
|
||||
Im Hintergrund abspielen
|
||||
|
||||
@@ -118,6 +118,12 @@ Progressive speed
|
||||
[progressive_start_speed_label]
|
||||
Start speed
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Modify start speed
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Start speed
|
||||
---
|
||||
[play_in_background_label]
|
||||
Play in background
|
||||
---
|
||||
|
||||
+11
-2
@@ -94,8 +94,17 @@ Tema
|
||||
[speed_label]
|
||||
Velocidad
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
Velocidad progresiva
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
Velocidad inicial
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Modificar velocidad inicial
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Velocidad inicial
|
||||
---
|
||||
[play_in_background_label]
|
||||
Reproducir en segundo plano
|
||||
|
||||
+11
-2
@@ -94,8 +94,17 @@ Thème
|
||||
[speed_label]
|
||||
Vitesse
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
Vitesse progressive
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
Vitesse de depart
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Modifier la vitesse de depart
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Vitesse de depart
|
||||
---
|
||||
[play_in_background_label]
|
||||
Lecture en arrière-plan
|
||||
|
||||
+11
-2
@@ -112,8 +112,17 @@ Tema
|
||||
[speed_label]
|
||||
Kecepatan
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
Kecepatan progresif
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
Kecepatan awal
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Ubah kecepatan awal
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Kecepatan awal
|
||||
---
|
||||
[play_in_background_label]
|
||||
Putar di latar belakang
|
||||
|
||||
+11
-2
@@ -112,8 +112,17 @@
|
||||
[speed_label]
|
||||
速度
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
プログレッシブ速度
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
開始速度
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
開始速度を変更
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
開始速度
|
||||
---
|
||||
[play_in_background_label]
|
||||
バックグラウンド再生
|
||||
|
||||
+8
-2
@@ -94,8 +94,14 @@
|
||||
[speed_label]
|
||||
속도
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_start_speed_label]
|
||||
시작 속도
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
시작 속도 수정
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
시작 속도
|
||||
---
|
||||
[play_in_background_label]
|
||||
백그라운드 재생
|
||||
|
||||
+11
-2
@@ -94,8 +94,17 @@ Tema
|
||||
[speed_label]
|
||||
Velocidade
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
Velocidade progressiva
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
Velocidade inicial
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
Modificar velocidade inicial
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
Velocidade inicial
|
||||
---
|
||||
[play_in_background_label]
|
||||
Executar em segundo plano
|
||||
|
||||
+11
-2
@@ -112,8 +112,17 @@
|
||||
[speed_label]
|
||||
速度
|
||||
---
|
||||
|
||||
Start speed
|
||||
[progressive_speed_label]
|
||||
渐进速度
|
||||
---
|
||||
[progressive_start_speed_label]
|
||||
起始速度
|
||||
---
|
||||
[modify_start_speed_button]
|
||||
修改起始速度
|
||||
---
|
||||
[progressive_start_speed_editor_title]
|
||||
起始速度
|
||||
---
|
||||
[play_in_background_label]
|
||||
后台播放
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
speed 8
|
||||
speed 6
|
||||
max_rounds 4
|
||||
max_breaths 30
|
||||
pause_seconds 2
|
||||
|
||||
@@ -35,22 +35,6 @@ static void android_wakelock_set_activity_impl(JNIEnv *env, jobject thiz) {
|
||||
android_wakelock_set_activity(env, thiz);
|
||||
}
|
||||
|
||||
// Called from Java when activity is paused
|
||||
static void android_timer_activate_impl(JNIEnv *env, jobject thiz) {
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "JNI: Timer ACTIVATE callback");
|
||||
android_timer_activate();
|
||||
}
|
||||
|
||||
// Called from Java when activity is resumed
|
||||
static void android_timer_deactivate_impl(JNIEnv *env, jobject thiz) {
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "JNI: Timer DEACTIVATE callback");
|
||||
android_timer_deactivate();
|
||||
}
|
||||
|
||||
static JavaVM *g_jvm = NULL;
|
||||
static jobject g_activity = NULL;
|
||||
|
||||
@@ -105,9 +89,32 @@ static jint nativeGetPlayInBackground(JNIEnv *env, jobject thiz)
|
||||
return 0; // Default to disabled
|
||||
}
|
||||
|
||||
// JNI function - Auto-pause session when app goes to background
|
||||
static void nativePauseSession(JNIEnv *env, jobject thiz)
|
||||
static void nativeSetBackgroundActive(JNIEnv *env, jobject thiz, jboolean active)
|
||||
{
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
|
||||
void *app = get_global_inbe_app();
|
||||
InbeApp *inbe_app = (InbeApp*)app;
|
||||
if (inbe_app != NULL) {
|
||||
inbe_app->backgrounded = active ? 1 : 0;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeSetBackgroundActive: activating background timer");
|
||||
android_timer_activate();
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeSetBackgroundActive: deactivating background timer");
|
||||
android_timer_deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
// JNI function - Auto-pause session when app goes to background
|
||||
static jint nativePauseSession(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: called");
|
||||
void *app = get_global_inbe_app();
|
||||
char msg[128];
|
||||
@@ -120,27 +127,25 @@ static void nativePauseSession(JNIEnv *env, jobject thiz)
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (!inbe_app->session_paused) {
|
||||
inbe_app->session_paused = 1;
|
||||
inbe_app->backgrounded = 1;
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: set session_paused = 1");
|
||||
#ifdef __ANDROID__
|
||||
if (inbe_app->inbe.play_in_background) {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: Releasing wake lock and stopping timer");
|
||||
android_wakelock_release();
|
||||
android_timer_stop();
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: SKIPPING wake lock/timer (play_in_background disabled)");
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: Session already paused, skipping");
|
||||
}
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_ERROR, "INBE_JNI", "nativePauseSession: app is NULL!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// JNI function - Auto-resume session when app returns to foreground
|
||||
static void nativeResumeSession(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: called");
|
||||
void *app = get_global_inbe_app();
|
||||
char msg[128];
|
||||
@@ -153,16 +158,8 @@ static void nativeResumeSession(JNIEnv *env, jobject thiz)
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (inbe_app->session_paused) {
|
||||
inbe_app->session_paused = 0;
|
||||
inbe_app->backgrounded = 0;
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: set session_paused = 0");
|
||||
#ifdef __ANDROID__
|
||||
if (inbe_app->inbe.play_in_background) {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: Acquiring wake lock and starting timer");
|
||||
android_wakelock_acquire();
|
||||
android_timer_start();
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: SKIPPING wake lock/timer (play_in_background disabled)");
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: Session not paused, skipping");
|
||||
}
|
||||
@@ -175,10 +172,9 @@ static void nativeResumeSession(JNIEnv *env, jobject thiz)
|
||||
static const JNINativeMethod g_methods[] = {
|
||||
{"nativeSetInsets", "(IIIIII)V", (void*)nativeSetInsets},
|
||||
{"nativeWakeLockReady", "()V", (void*)android_wakelock_set_activity_impl},
|
||||
{"nativeTimerActivate", "()V", (void*)android_timer_activate_impl},
|
||||
{"nativeTimerDeactivate", "()V", (void*)android_timer_deactivate_impl},
|
||||
{"nativeSetBackgroundActive", "(Z)V", (void*)nativeSetBackgroundActive},
|
||||
{"nativeGetPlayInBackground", "()I", (void*)nativeGetPlayInBackground},
|
||||
{"nativePauseSession", "()V", (void*)nativePauseSession},
|
||||
{"nativePauseSession", "()I", (void*)nativePauseSession},
|
||||
{"nativeResumeSession", "()V", (void*)nativeResumeSession},
|
||||
{"nativeImportSelectedFile", "(Ljava/lang/String;)V", (void*)android_import_native_selected},
|
||||
{"nativeImportCancelled", "()V", (void*)android_import_native_cancelled},
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#endif
|
||||
#include "version.h"
|
||||
#include "flint_ui.h"
|
||||
#include "flint_text_layout.h"
|
||||
#include "flint_dpi.h"
|
||||
|
||||
#if !defined(LOTUS_BUILD)
|
||||
@@ -120,96 +119,6 @@ static UITab g_tabs[] = {
|
||||
|
||||
static UITabBar g_tab_bar = {g_tabs, 3};
|
||||
|
||||
typedef struct ChoppedGlyph {
|
||||
int32_t value;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
int32_t offsetX;
|
||||
int32_t offsetY;
|
||||
int32_t advanceX;
|
||||
} ChoppedGlyph;
|
||||
|
||||
static Font
|
||||
load_chopped_font(const char *png_path, const char *dat_path)
|
||||
{
|
||||
Font font = {0};
|
||||
FILE *file = NULL;
|
||||
ChoppedGlyph *glyphs = NULL;
|
||||
GlyphInfo *glyph_infos = NULL;
|
||||
Rectangle *recs = NULL;
|
||||
int32_t glyph_count = 0;
|
||||
Image image = {0};
|
||||
Texture2D texture = {0};
|
||||
|
||||
file = fopen(dat_path, "rb");
|
||||
if(file == NULL)
|
||||
return font;
|
||||
|
||||
if(fread(&glyph_count, sizeof(glyph_count), 1, file) != 1 || glyph_count <= 0) {
|
||||
fclose(file);
|
||||
return font;
|
||||
}
|
||||
|
||||
glyphs = calloc((size_t)glyph_count, sizeof(*glyphs));
|
||||
glyph_infos = calloc((size_t)glyph_count, sizeof(*glyph_infos));
|
||||
recs = calloc((size_t)glyph_count, sizeof(*recs));
|
||||
if(glyphs == NULL || glyph_infos == NULL || recs == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if(fread(glyphs, sizeof(*glyphs), (size_t)glyph_count, file) != (size_t)glyph_count)
|
||||
goto cleanup;
|
||||
fclose(file);
|
||||
file = NULL;
|
||||
|
||||
image = LoadImage(png_path);
|
||||
if(image.data == NULL)
|
||||
goto cleanup;
|
||||
|
||||
texture = LoadTextureFromImage(image);
|
||||
UnloadImage(image);
|
||||
image = (Image){0};
|
||||
if(texture.id == 0)
|
||||
goto cleanup;
|
||||
SetTextureFilter(texture, TEXTURE_FILTER_POINT);
|
||||
|
||||
for(int i = 0; i < glyph_count; i++) {
|
||||
glyph_infos[i].value = glyphs[i].value;
|
||||
glyph_infos[i].offsetX = glyphs[i].offsetX;
|
||||
glyph_infos[i].offsetY = glyphs[i].offsetY;
|
||||
glyph_infos[i].advanceX = glyphs[i].advanceX;
|
||||
glyph_infos[i].image = (Image){0};
|
||||
|
||||
recs[i].x = (float)glyphs[i].x;
|
||||
recs[i].y = (float)glyphs[i].y;
|
||||
recs[i].width = (float)glyphs[i].w;
|
||||
recs[i].height = (float)glyphs[i].h;
|
||||
}
|
||||
|
||||
font.texture = texture;
|
||||
font.glyphs = glyph_infos;
|
||||
font.recs = recs;
|
||||
font.glyphCount = glyph_count;
|
||||
font.baseSize = LOCALE_FONT_BASE_SIZE;
|
||||
font.glyphPadding = 0;
|
||||
|
||||
free(glyphs);
|
||||
return font;
|
||||
|
||||
cleanup:
|
||||
if(file != NULL)
|
||||
fclose(file);
|
||||
if(image.data != NULL)
|
||||
UnloadImage(image);
|
||||
if(texture.id != 0)
|
||||
UnloadTexture(texture);
|
||||
free(glyphs);
|
||||
free(glyph_infos);
|
||||
free(recs);
|
||||
return (Font){0};
|
||||
}
|
||||
|
||||
static int
|
||||
load_locale_font(InbeApp *app)
|
||||
{
|
||||
@@ -219,7 +128,7 @@ load_locale_font(InbeApp *app)
|
||||
if(app == NULL)
|
||||
return 0;
|
||||
|
||||
font = load_chopped_font(LOCALE_FONT_PNG, LOCALE_FONT_DAT);
|
||||
font = flint_text_load_chopped_font(LOCALE_FONT_PNG, LOCALE_FONT_DAT, LOCALE_FONT_BASE_SIZE);
|
||||
if(font.texture.id == 0)
|
||||
return 0;
|
||||
|
||||
@@ -227,9 +136,7 @@ load_locale_font(InbeApp *app)
|
||||
app->font_shapes_texture = LoadTextureFromImage(white);
|
||||
UnloadImage(white);
|
||||
if(app->font_shapes_texture.id == 0) {
|
||||
UnloadTexture(font.texture);
|
||||
free(font.glyphs);
|
||||
free(font.recs);
|
||||
flint_text_unload_font(&font);
|
||||
return 0;
|
||||
}
|
||||
SetTextureFilter(app->font_shapes_texture, TEXTURE_FILTER_POINT);
|
||||
@@ -248,11 +155,7 @@ unload_locale_font(InbeApp *app)
|
||||
return;
|
||||
|
||||
flint_text_set_font((Font){0});
|
||||
if(app->locale_font.texture.id != 0)
|
||||
UnloadTexture(app->locale_font.texture);
|
||||
free(app->locale_font.glyphs);
|
||||
free(app->locale_font.recs);
|
||||
app->locale_font = (Font){0};
|
||||
flint_text_unload_font(&app->locale_font);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -589,7 +492,7 @@ load_settings(InbeApp *app)
|
||||
inbe_settings_path(settings_path, sizeof(settings_path));
|
||||
rini_data settings = rini_load(settings_path);
|
||||
|
||||
int speed = rini_get_value_fallback(settings, "speed", 8);
|
||||
int speed = rini_get_value_fallback(settings, "speed", DefaultSpeedLevel);
|
||||
int max_rounds = rini_get_value_fallback(settings, "max_rounds", DefaultMaxRounds);
|
||||
int max_breaths = rini_get_value_fallback(settings, "max_breaths", DefaultMaxBreaths);
|
||||
int pause_seconds = rini_get_value_fallback(settings, "pause_seconds", DefaultPauseSeconds);
|
||||
@@ -606,7 +509,7 @@ load_settings(InbeApp *app)
|
||||
#endif
|
||||
app->sound_volume = clampi(sound_volume, SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX);
|
||||
app->inbe.progressive_speed = rini_get_value_fallback(settings, "progressive_speed", 1) != 0;
|
||||
app->inbe.progressive_start_speed = clampi(rini_get_value_fallback(settings, "progressive_start_speed", 3),
|
||||
app->inbe.progressive_start_speed = clampi(rini_get_value_fallback(settings, "progressive_start_speed", DefaultProgressiveStartSpeed),
|
||||
SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX);
|
||||
app->advanced_session_controls = rini_get_value_fallback(settings, "advanced_session_controls", 0) != 0;
|
||||
app->hold_display_mode = clampi(rini_get_value_fallback(settings, "hold_display_mode", HOLD_DISPLAY_CIRCLE),
|
||||
@@ -794,7 +697,6 @@ inbe_app_init(void *vapp) {
|
||||
app->manual_drag_content = 0;
|
||||
app->manual_drag_content_y = 0;
|
||||
app->tutorial_step = 0;
|
||||
app->tutorial_layouts_initialized = 0;
|
||||
history_tab_reset(app);
|
||||
app->session_paused = 0;
|
||||
app->backgrounded = 0;
|
||||
@@ -802,6 +704,8 @@ inbe_app_init(void *vapp) {
|
||||
app->results_path[0] = '\0';
|
||||
update_session_sounds(app);
|
||||
reset_settings_preview(app);
|
||||
inbeinit(&app->start_speed_preview);
|
||||
app->start_speed_preview_speed = 0;
|
||||
|
||||
if(app->gear_icon.id == 0) {
|
||||
app->gear_icon = load_icon_texture("gear.png");
|
||||
@@ -1146,14 +1050,6 @@ inbe_app_destroy(void *vapp)
|
||||
SafeUnloadTexture(app->font_shapes_texture);
|
||||
unload_locale_font(app);
|
||||
|
||||
/* Cleanup tutorial text layouts */
|
||||
if(app->tutorial_layouts_initialized) {
|
||||
for(int i = 0; i < 5; i++) {
|
||||
flint_text_layout_free(app->tutorial_layouts[i]);
|
||||
free(app->tutorial_layouts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SafeUnloadSound(app->breath_in_sound);
|
||||
SafeUnloadSound(app->breath_out_sound);
|
||||
SafeUnloadSound(app->bell_sound);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "raylib.h"
|
||||
#include "../libinbe/inbe.h"
|
||||
#include "flint_text_layout.h"
|
||||
#include "app_fwd.h"
|
||||
|
||||
enum {
|
||||
@@ -78,6 +77,7 @@ typedef enum {
|
||||
UIModalConfirmExitSession,
|
||||
UIModalConfirmDeleteData,
|
||||
UIModalConfirmDeleteHistory,
|
||||
UIModalEditProgressiveStartSpeed,
|
||||
} UIModalType;
|
||||
|
||||
typedef struct {
|
||||
@@ -113,6 +113,8 @@ typedef enum HoldDisplayMode {
|
||||
struct InbeApp {
|
||||
Inbe inbe;
|
||||
Inbe settings_preview;
|
||||
Inbe start_speed_preview;
|
||||
int start_speed_preview_speed;
|
||||
Camera2D camera;
|
||||
int cursor_clickable;
|
||||
Texture2D gear_icon;
|
||||
@@ -174,9 +176,6 @@ struct InbeApp {
|
||||
int tutorial_step;
|
||||
int tutorial_seen;
|
||||
|
||||
FlintTextLayout *tutorial_layouts[6];
|
||||
int tutorial_layouts_initialized;
|
||||
|
||||
int theme_id;
|
||||
int dark_mode;
|
||||
#if defined(LOTUS_BUILD)
|
||||
@@ -228,5 +227,6 @@ void refresh_locale_dependent_text(InbeApp *app);
|
||||
void apply_language_selection(InbeApp *app, int language_index, int save_now);
|
||||
void draw_preview_inbe(Inbe *inbe, int center_x, int center_y);
|
||||
int draw_hold_display_mode_selector(InbeApp *app, int x, int y, int w);
|
||||
void settings_draw_progressive_start_speed_editor(InbeApp *app);
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -91,8 +91,8 @@ frame(void)
|
||||
int safe_left = insets.cutout_left;
|
||||
int safe_right = insets.cutout_right;
|
||||
|
||||
int content_x = 0;
|
||||
int content_y = 0;
|
||||
int content_x = safe_left;
|
||||
int content_y = safe_top;
|
||||
int content_width = android_clamp_content_size(width, safe_left, safe_right);
|
||||
int content_height = android_clamp_content_size(height, safe_top, safe_bottom);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "data.h"
|
||||
#include "locale.h"
|
||||
#include "flint_ui.h"
|
||||
#include "flint_text_layout.h"
|
||||
#include "raylib.h"
|
||||
|
||||
#include <dirent.h>
|
||||
@@ -1293,10 +1292,13 @@ history_tab_draw(InbeApp *app)
|
||||
if(count == 0) {
|
||||
int font = flint_px(16);
|
||||
const char *empty_text = locale_get("history_empty");
|
||||
FlintTextLayout empty_layout = flint_text_layout_parse(empty_text, (Texture2D){0}, FLINT_ICON_TYPE_NONE, font);
|
||||
flint_text_layout_reflow(&empty_layout, content_w, font, flint_px(22));
|
||||
flint_text_layout_draw(&empty_layout, content_x, &y, font, c_text);
|
||||
flint_text_layout_free(&empty_layout);
|
||||
flint_ui_paragraph_draw((FlintUIParagraph){
|
||||
.text = empty_text,
|
||||
.width = content_w,
|
||||
.font = font,
|
||||
.line_gap = flint_px(22),
|
||||
.color = c_text,
|
||||
}, content_x, &y);
|
||||
} else {
|
||||
if(app->history_level == HISTORY_LEVEL_EDIT_DAY && has_day) {
|
||||
int return_hover = 0;
|
||||
|
||||
+67
-81
@@ -2,11 +2,9 @@
|
||||
#include "app.h"
|
||||
#include "locale.h"
|
||||
#include "flint_ui.h"
|
||||
#include "flint_text_layout.h"
|
||||
#include "theme_meta.h"
|
||||
#include "raylib.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CONTENT_MAX_W 800 /* Responsive width for tutorial text reflow */
|
||||
|
||||
@@ -28,17 +26,6 @@ static const char *const TUTORIAL_KEYS[] = {
|
||||
#define TUTORIAL_STEPS_COUNT (sizeof(TUTORIAL_KEYS) / sizeof(TUTORIAL_KEYS[0]))
|
||||
#define TUTORIAL_LINE_SPACING flint_px(8) /* Normal readable line spacing */
|
||||
|
||||
/*
|
||||
* Wrapper for compatibility - using Flint's unified button utility
|
||||
* This function is deprecated - use ui_draw_generic_button() directly
|
||||
*/
|
||||
static int
|
||||
draw_tutorial_footer_button(InbeApp *app, int x, int y, int w, int h, const char *label, int *hover)
|
||||
{
|
||||
(void)app;
|
||||
return ui_draw_generic_button(x, y, w, h, label, UI_BUTTON_STYLE_PRIMARY, hover);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tutorial_hold_preview(InbeApp *app, int center_x, int center_y, int radius)
|
||||
{
|
||||
@@ -66,16 +53,32 @@ draw_tutorial_hold_preview(InbeApp *app, int center_x, int center_y, int radius)
|
||||
flint_ui_draw_text_centered(text, center_x, center_y, font, c_text);
|
||||
}
|
||||
|
||||
static void
|
||||
init_tutorial_layouts(InbeApp *app, int body_font)
|
||||
static FlintUIParagraph
|
||||
tutorial_paragraph(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
if(!app->tutorial_layouts_initialized) {
|
||||
for(int i = 0; i < (int)TUTORIAL_STEPS_COUNT; i++) {
|
||||
app->tutorial_layouts[i] = calloc(1, sizeof(FlintTextLayout));
|
||||
*app->tutorial_layouts[i] = flint_text_layout_parse(locale_get(TUTORIAL_KEYS[i]), (Texture2D){0}, FLINT_ICON_TYPE_NONE, body_font);
|
||||
}
|
||||
app->tutorial_layouts_initialized = 1;
|
||||
}
|
||||
int has_icon = step == 1;
|
||||
return (FlintUIParagraph){
|
||||
.text = locale_get(TUTORIAL_KEYS[step]),
|
||||
.icon = has_icon ? app->gear_icon : (Texture2D){0},
|
||||
.icon_type = has_icon ? FLINT_ICON_TYPE_GEAR : FLINT_ICON_TYPE_NONE,
|
||||
.icon_size = has_icon ? flint_px(14) : 0,
|
||||
.width = content_w,
|
||||
.font = body_font,
|
||||
.line_gap = TUTORIAL_LINE_SPACING,
|
||||
.color = c_text,
|
||||
};
|
||||
}
|
||||
|
||||
static int
|
||||
tutorial_paragraph_height(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
return flint_ui_paragraph_height(tutorial_paragraph(app, step, content_w, body_font));
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tutorial_paragraph(InbeApp *app, int step, int content_x, int *y, int content_w, int body_font)
|
||||
{
|
||||
flint_ui_paragraph_draw(tutorial_paragraph(app, step, content_w, body_font), content_x, y);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -84,14 +87,7 @@ manual_tab_reset_layouts(InbeApp *app)
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < (int)TUTORIAL_STEPS_COUNT; i++) {
|
||||
if(app->tutorial_layouts[i] != NULL) {
|
||||
flint_text_layout_free(app->tutorial_layouts[i]);
|
||||
free(app->tutorial_layouts[i]);
|
||||
app->tutorial_layouts[i] = NULL;
|
||||
}
|
||||
}
|
||||
app->tutorial_layouts_initialized = 0;
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -165,16 +161,6 @@ manual_tab_draw(InbeApp *app)
|
||||
int side_padding = flint_page_side_padding();
|
||||
flint_centered_column(responsive_max_w, side_padding, &content_x, &content_w);
|
||||
|
||||
/* Auto-reflow every frame */
|
||||
if(!app->tutorial_layouts_initialized) {
|
||||
init_tutorial_layouts(app, body_font);
|
||||
}
|
||||
|
||||
/* Reflow all layouts for current container width */
|
||||
for(int i = 0; i < (int)TUTORIAL_STEPS_COUNT; i++) {
|
||||
flint_text_layout_reflow(app->tutorial_layouts[i], content_w, body_font, TUTORIAL_LINE_SPACING);
|
||||
}
|
||||
|
||||
close_clicked = ui_draw_screen_header(title, 1);
|
||||
if(close_clicked)
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
@@ -183,19 +169,16 @@ manual_tab_draw(InbeApp *app)
|
||||
/* Don't include padding in this calculation - it's handled separately */
|
||||
int actual_content_h = 0; /* Content only, no padding */
|
||||
if(step == 0) {
|
||||
actual_content_h += flint_px(170) + flint_px(22) + flint_text_layout_get_height(app->tutorial_layouts[0]);
|
||||
actual_content_h += flint_px(170) + flint_px(22) +
|
||||
tutorial_paragraph_height(app, 0, content_w, body_font);
|
||||
} else if(step == 1) {
|
||||
/* Step 1 uses a fresh gear_layout for drawing - calculate height from it */
|
||||
FlintTextLayout temp_gear = flint_text_layout_parse(locale_get(TUTORIAL_KEYS[1]), app->gear_icon, FLINT_ICON_TYPE_GEAR, flint_px(14));
|
||||
flint_text_layout_reflow(&temp_gear, content_w, body_font, TUTORIAL_LINE_SPACING);
|
||||
actual_content_h += flint_text_layout_get_height(&temp_gear);
|
||||
flint_text_layout_free(&temp_gear);
|
||||
actual_content_h += tutorial_paragraph_height(app, 1, content_w, body_font);
|
||||
} else if(step == 2) {
|
||||
actual_content_h += flint_text_layout_get_height(app->tutorial_layouts[2]) + flint_px(68);
|
||||
actual_content_h += tutorial_paragraph_height(app, 2, content_w, body_font) + flint_px(68);
|
||||
if(app->inbe.progressive_speed)
|
||||
actual_content_h += flint_px(66);
|
||||
} else if(step == 3) {
|
||||
actual_content_h += flint_text_layout_get_height(app->tutorial_layouts[3]) + flint_px(20);
|
||||
actual_content_h += tutorial_paragraph_height(app, 3, content_w, body_font) + flint_px(20);
|
||||
/* Circle preview height - calculate actual rmax based on content_w */
|
||||
/* update_preview_bounds uses min(content_w, 132)/2 clamped to 60-120 for rmax */
|
||||
int preview_span = (content_w < flint_px(132)) ? content_w : flint_px(132);
|
||||
@@ -211,9 +194,10 @@ manual_tab_draw(InbeApp *app)
|
||||
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
|
||||
actual_content_h += flint_px(26) + flint_px(36) + flint_px(20);
|
||||
actual_content_h += hold_preview_extent * 2 + flint_px(24);
|
||||
actual_content_h += flint_text_layout_get_height(app->tutorial_layouts[4]);
|
||||
actual_content_h += tutorial_paragraph_height(app, 4, content_w, body_font);
|
||||
} else {
|
||||
actual_content_h += flint_px(200) + flint_px(22) + flint_text_layout_get_height(app->tutorial_layouts[5]);
|
||||
actual_content_h += flint_px(200) + flint_px(22) +
|
||||
tutorial_paragraph_height(app, 5, content_w, body_font);
|
||||
}
|
||||
/* Calculate scroll range for virtual content space */
|
||||
int top_padding = flint_px(16);
|
||||
@@ -269,20 +253,11 @@ manual_tab_draw(InbeApp *app)
|
||||
ui_draw_tutorial_image(app->angel_image, "angel.jpg", content_x, y, content_w, img_h);
|
||||
y += img_h + flint_px(22);
|
||||
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[0] != NULL) {
|
||||
flint_text_layout_draw(app->tutorial_layouts[0], content_x, &y, body_font, c_text);
|
||||
}
|
||||
draw_tutorial_paragraph(app, 0, content_x, &y, content_w, body_font);
|
||||
} else if(step == 1) {
|
||||
/* Step 1 text with gear icon - parse fresh each frame for proper icon binding */
|
||||
int icon_size = flint_px(14);
|
||||
FlintTextLayout gear_layout = flint_text_layout_parse(locale_get(TUTORIAL_KEYS[1]), app->gear_icon, FLINT_ICON_TYPE_GEAR, icon_size);
|
||||
flint_text_layout_reflow(&gear_layout, content_w, body_font, TUTORIAL_LINE_SPACING);
|
||||
flint_text_layout_draw(&gear_layout, content_x, &y, body_font, c_text);
|
||||
flint_text_layout_free(&gear_layout);
|
||||
draw_tutorial_paragraph(app, 1, content_x, &y, content_w, body_font);
|
||||
} else if(step == 2) {
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[2] != NULL) {
|
||||
flint_text_layout_draw(app->tutorial_layouts[2], content_x, &y, body_font, c_text);
|
||||
}
|
||||
draw_tutorial_paragraph(app, 2, content_x, &y, content_w, body_font);
|
||||
y += flint_px(18);
|
||||
{
|
||||
int progressive_speed = app->inbe.progressive_speed;
|
||||
@@ -302,22 +277,30 @@ manual_tab_draw(InbeApp *app)
|
||||
y += toggle_h + flint_px(20);
|
||||
if(app->inbe.progressive_speed) {
|
||||
int max_speed = app->inbe.speed_level;
|
||||
progressive_start_speed = clampi(progressive_start_speed, SETTINGS_SPEED_MIN, max_speed);
|
||||
if(ui_draw_slider(11, content_x, y, content_w,
|
||||
locale_get("progressive_start_speed_label"),
|
||||
SETTINGS_SPEED_MIN, max_speed,
|
||||
&progressive_start_speed, "")) {
|
||||
app->inbe.progressive_start_speed = progressive_start_speed;
|
||||
app->settings_preview.progressive_start_speed = progressive_start_speed;
|
||||
int modify_w = flint_text_measure(locale_get("modify_start_speed_button"), flint_ui_font()) + flint_px(24);
|
||||
int modify_h = flint_px(36);
|
||||
int modify_hover = 0;
|
||||
if(modify_w > content_w)
|
||||
modify_w = content_w;
|
||||
|
||||
if(progressive_start_speed != clampi(progressive_start_speed, SETTINGS_SPEED_MIN, max_speed)) {
|
||||
app->inbe.progressive_start_speed = clampi(progressive_start_speed, SETTINGS_SPEED_MIN, max_speed);
|
||||
app->settings_preview.progressive_start_speed = app->inbe.progressive_start_speed;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
if(ui_draw_generic_button(content_x, y, modify_w, modify_h,
|
||||
locale_get("modify_start_speed_button"),
|
||||
UI_BUTTON_STYLE_SECONDARY, &modify_hover)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalEditProgressiveStartSpeed;
|
||||
app->modal.selected_button = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(step == 3) {
|
||||
int speed = app->inbe.speed_level;
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[3] != NULL) {
|
||||
flint_text_layout_draw(app->tutorial_layouts[3], content_x, &y, body_font, c_text);
|
||||
}
|
||||
draw_tutorial_paragraph(app, 3, content_x, &y, content_w, body_font);
|
||||
y += flint_px(20); /* Increased spacing between text and circle */
|
||||
|
||||
update_preview_bounds(&app->settings_preview, content_w, flint_px(132));
|
||||
@@ -353,16 +336,12 @@ manual_tab_draw(InbeApp *app)
|
||||
y += flint_px(36) + flint_px(20) + hold_preview_extent;
|
||||
draw_tutorial_hold_preview(app, content_x + content_w / 2, y, hold_preview_radius);
|
||||
y += hold_preview_extent + flint_px(24);
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[4] != NULL) {
|
||||
flint_text_layout_draw(app->tutorial_layouts[4], content_x, &y, body_font, c_text);
|
||||
}
|
||||
draw_tutorial_paragraph(app, 4, content_x, &y, content_w, body_font);
|
||||
} else {
|
||||
int img_h = flint_px(200);
|
||||
ui_draw_tutorial_image(app->begin_image, "begin.jpg", content_x, y, content_w, img_h);
|
||||
y += img_h + flint_px(22);
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[5] != NULL) {
|
||||
flint_text_layout_draw(app->tutorial_layouts[5], content_x, &y, body_font, c_text);
|
||||
}
|
||||
draw_tutorial_paragraph(app, 5, content_x, &y, content_w, body_font);
|
||||
}
|
||||
EndScissorMode();
|
||||
|
||||
@@ -397,16 +376,19 @@ manual_tab_draw(InbeApp *app)
|
||||
footer_y - page_font - counter_gap, page_font, c_text);
|
||||
|
||||
if(step == 0) {
|
||||
if(draw_tutorial_footer_button(app, content_x, footer_y, button_w, button_h, left_label, &left_hover))
|
||||
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
|
||||
left_label, UI_BUTTON_STYLE_PRIMARY, &left_hover))
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
} else {
|
||||
if(draw_tutorial_footer_button(app, content_x, footer_y, button_w, button_h, left_label, &left_hover)) {
|
||||
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
|
||||
left_label, UI_BUTTON_STYLE_PRIMARY, &left_hover)) {
|
||||
app->tutorial_step--;
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(draw_tutorial_footer_button(app, content_x + button_w + footer_gap, footer_y, button_w, button_h, right_label, &right_hover)) {
|
||||
if(ui_draw_generic_button(content_x + button_w + footer_gap, footer_y, button_w, button_h,
|
||||
right_label, UI_BUTTON_STYLE_PRIMARY, &right_hover)) {
|
||||
if(step == (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
else {
|
||||
@@ -415,6 +397,10 @@ manual_tab_draw(InbeApp *app)
|
||||
}
|
||||
}
|
||||
|
||||
if(app->modal.active && app->modal.type == UIModalEditProgressiveStartSpeed) {
|
||||
settings_draw_progressive_start_speed_editor(app);
|
||||
}
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
app->settings_drag_slider = 0;
|
||||
if(app->settings_dirty)
|
||||
|
||||
+129
-107
@@ -1,9 +1,9 @@
|
||||
#include "settings_tab.h"
|
||||
#include "app.h"
|
||||
#include "app_session.h"
|
||||
#include "language_tab.h"
|
||||
#include "locale.h"
|
||||
#include "flint_ui.h"
|
||||
#include "flint_text_layout.h"
|
||||
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(_WIN32) && !defined(PLATFORM_WEB)
|
||||
#define INBE_HAS_FLINT_FILE_DIALOG 1
|
||||
#include "flint_file_dialog.h"
|
||||
@@ -84,11 +84,14 @@ draw_category_card(InbeApp *app, const char *title, const char *description,
|
||||
int title_y = flint_ui_text_y(title, (int)rect.y + padding_y, title_font, title_font);
|
||||
flint_text_draw(title, (int)rect.x + padding_x, title_y, title_font, c_text);
|
||||
|
||||
FlintTextLayout desc_layout = flint_text_layout_parse(description, (Texture2D){0}, FLINT_ICON_TYPE_NONE, desc_font);
|
||||
flint_text_layout_reflow(&desc_layout, text_w, desc_font, flint_px(8));
|
||||
int desc_y = title_y + title_font + flint_px(8);
|
||||
flint_text_layout_draw(&desc_layout, (int)rect.x + padding_x, &desc_y, desc_font, flint_darken(c_text, 30));
|
||||
flint_text_layout_free(&desc_layout);
|
||||
flint_ui_paragraph_draw((FlintUIParagraph){
|
||||
.text = description,
|
||||
.width = text_w,
|
||||
.font = desc_font,
|
||||
.line_gap = flint_px(8),
|
||||
.color = flint_darken(c_text, 30),
|
||||
}, (int)rect.x + padding_x, &desc_y);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -180,84 +183,99 @@ settings_draw_subtab_bar(InbeApp *app, int x, int y, int w, int h,
|
||||
return clicked_tab;
|
||||
}
|
||||
|
||||
static void
|
||||
settings_draw_exact_speed_preview(Inbe *preview, int *preview_speed,
|
||||
int speed, int max_rounds, int max_breaths,
|
||||
int pause_seconds, int content_w, int content_h,
|
||||
int center_x, int center_y)
|
||||
{
|
||||
if(preview == NULL || preview_speed == NULL)
|
||||
return;
|
||||
|
||||
if(*preview_speed != speed || preview->phase != InbePhaseBreathe) {
|
||||
inbeinit(preview);
|
||||
apply_settings(preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
preview->progressive_speed = 0;
|
||||
session_reset_round_breathe(preview);
|
||||
*preview_speed = speed;
|
||||
}
|
||||
|
||||
update_preview_bounds(preview, content_w, content_h);
|
||||
inbestep(preview);
|
||||
draw_preview_inbe(preview, center_x, center_y);
|
||||
}
|
||||
|
||||
void
|
||||
settings_draw_progressive_start_speed_editor(InbeApp *app)
|
||||
{
|
||||
int modal_w = flint_px(340);
|
||||
int modal_h = flint_px(360);
|
||||
if(modal_w > view_width - flint_px(24))
|
||||
modal_w = view_width - flint_px(24);
|
||||
if(modal_h > view_height - flint_px(24))
|
||||
modal_h = view_height - flint_px(24);
|
||||
int modal_x = (view_width - modal_w) / 2;
|
||||
int modal_y = (view_height - modal_h) / 2;
|
||||
int title_font = flint_ui_font();
|
||||
int title_y = modal_y + flint_px(14);
|
||||
int close_size = flint_px(22);
|
||||
int close_padding = flint_px(8);
|
||||
int close_w = close_size + close_padding * 2;
|
||||
int close_hover = 0;
|
||||
int max_speed = app->inbe.speed_level;
|
||||
int start_speed = clampi(app->inbe.progressive_start_speed, SETTINGS_SPEED_MIN, max_speed);
|
||||
|
||||
DrawRectangle(0, 0, view_width, view_height, (Color){0, 0, 0, 180});
|
||||
DrawRectangle(modal_x, modal_y, modal_w, modal_h, c_button);
|
||||
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h,
|
||||
flint_lighten(c_button, 40), flint_darken(c_button, 40));
|
||||
|
||||
const char *title = locale_get("progressive_start_speed_editor_title");
|
||||
int title_w = flint_text_measure(title, title_font);
|
||||
int title_max_w = modal_w - close_w * 2 - flint_px(24);
|
||||
while(title_font > flint_px(12) && title_w > title_max_w) {
|
||||
title_font--;
|
||||
title_w = flint_text_measure(title, title_font);
|
||||
}
|
||||
flint_text_draw(title, modal_x + (modal_w - title_w) / 2, title_y, title_font, c_text);
|
||||
|
||||
if(ui_draw_icon_btn_padded(modal_x + modal_w - close_w - flint_px(6), modal_y + flint_px(6),
|
||||
close_size, close_padding, app->x_icon, UI_ICON_TYPE_X, &close_hover)) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
return;
|
||||
}
|
||||
|
||||
settings_draw_exact_speed_preview(&app->start_speed_preview,
|
||||
&app->start_speed_preview_speed,
|
||||
start_speed,
|
||||
app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths),
|
||||
app->inbe.pause_seconds,
|
||||
modal_w - flint_px(48),
|
||||
flint_px(210),
|
||||
modal_x + modal_w / 2,
|
||||
modal_y + flint_px(150));
|
||||
|
||||
if(ui_draw_slider(12, modal_x + flint_px(24), modal_y + flint_px(250),
|
||||
modal_w - flint_px(48), locale_get("progressive_start_speed_label"),
|
||||
SETTINGS_SPEED_MIN, max_speed, &start_speed, "")) {
|
||||
app->inbe.progressive_start_speed = start_speed;
|
||||
app->start_speed_preview_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(LOTUS_BUILD)
|
||||
static void
|
||||
draw_theme_selector(InbeApp *app, int x, int y, int w)
|
||||
{
|
||||
int font = flint_ui_font();
|
||||
int small_font = flint_ui_font_small();
|
||||
const char *label = locale_get("theme_label");
|
||||
|
||||
flint_text_draw(label, x, y, font, c_text);
|
||||
|
||||
/* Light/Dark toggle */
|
||||
const char *theme_light_label = locale_get("theme_light");
|
||||
const char *theme_dark_label = locale_get("theme_dark");
|
||||
int theme_light_w = flint_text_measure(theme_light_label, font);
|
||||
int theme_dark_w = flint_text_measure(theme_dark_label, font);
|
||||
int max_label_w = (theme_light_w > theme_dark_w ? theme_light_w : theme_dark_w);
|
||||
|
||||
/* Calculate toggle width based on text measurements with padding */
|
||||
int toggle_w = max_label_w * 2 + flint_px(32); /* Space for both labels + padding */
|
||||
int min_toggle_w = flint_px(100); /* Minimum width */
|
||||
if(toggle_w < min_toggle_w) toggle_w = min_toggle_w;
|
||||
|
||||
int toggle_h = flint_px(28);
|
||||
int toggle_x = x + w - toggle_w - flint_px(8); /* Right-aligned with reduced margin */
|
||||
int toggle_y = y - 2;
|
||||
|
||||
if(ui_draw_toggle_switch(toggle_x, toggle_y, toggle_w, toggle_h, &app->dark_mode,
|
||||
theme_light_label, theme_dark_label)) {
|
||||
if(ui_draw_theme_switcher(x, y, w, locale_get("theme_label"),
|
||||
locale_get("theme_light"), locale_get("theme_dark"),
|
||||
&app->theme_id, &app->dark_mode)) {
|
||||
refresh_theme_colors(app->theme_id, app->dark_mode);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
int circle_size = flint_px(36);
|
||||
int circle_spacing = flint_px(32);
|
||||
int row_spacing = flint_px(48);
|
||||
int per_row = 3;
|
||||
int row_width = per_row * circle_size + (per_row - 1) * circle_spacing;
|
||||
int start_x = x + (w - row_width) / 2;
|
||||
int circle_y = y + flint_px(64);
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
|
||||
for(int i = 0; i < THEME_COUNT; i++) {
|
||||
int row = i / per_row;
|
||||
int col = i % per_row;
|
||||
int cx = start_x + col * (circle_size + circle_spacing) + circle_size / 2;
|
||||
int cy = circle_y + row * (circle_size + row_spacing);
|
||||
|
||||
Color theme_color = c_circle;
|
||||
if(!flint_theme_catalog_color((FlintThemeId)i, app->dark_mode != 0, "circle", &theme_color)) {
|
||||
const char *scope = app->dark_mode ? g_themes[i].dark_scope : g_themes[i].light_scope;
|
||||
theme_color = theme_get(scope, "circle");
|
||||
}
|
||||
DrawCircle(cx, cy, circle_size / 2, theme_color);
|
||||
|
||||
/* Draw selection ring */
|
||||
if(app->theme_id == i) {
|
||||
DrawCircleLines(cx, cy, circle_size / 2 + 2, c_text);
|
||||
} else {
|
||||
DrawCircleLines(cx, cy, circle_size / 2 + 1, flint_darken(c_bg, 30));
|
||||
}
|
||||
|
||||
/* Check for click */
|
||||
Rectangle bounds = {cx - circle_size / 2 - 4, cy - circle_size / 2 - 4, circle_size + 8, circle_size + 8};
|
||||
if(CheckCollisionPointRec(mouse_world, bounds) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
|
||||
!ui_dropdown_captures_click(mouse_world)) {
|
||||
app->theme_id = i;
|
||||
refresh_theme_colors(app->theme_id, app->dark_mode);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
if(CheckCollisionPointRec(mouse_world, bounds))
|
||||
app->cursor_clickable = 1;
|
||||
|
||||
/* Draw theme name below */
|
||||
const char *name = g_themes[i].name;
|
||||
int name_w = flint_text_measure(name, small_font);
|
||||
flint_text_draw(name, cx - name_w / 2, cy + circle_size / 2 + flint_px(6), small_font, c_text);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -524,14 +542,26 @@ settings_tab_draw(InbeApp *app)
|
||||
TraceLog(LOG_INFO, "INBE: Settings toggled progressive_speed to %d", progressive_speed);
|
||||
}
|
||||
if(app->inbe.progressive_speed) {
|
||||
progressive_start_speed = clampi(progressive_start_speed, SETTINGS_SPEED_MIN, speed);
|
||||
if(ui_draw_slider(5, content_x, progressive_toggle_y + toggle_h + flint_px(20),
|
||||
content_w, locale_get("progressive_start_speed_label"),
|
||||
SETTINGS_SPEED_MIN, speed, &progressive_start_speed, "")) {
|
||||
app->inbe.progressive_start_speed = progressive_start_speed;
|
||||
app->settings_preview.progressive_start_speed = progressive_start_speed;
|
||||
int modify_y = progressive_toggle_y + toggle_h + flint_px(20);
|
||||
int modify_w = flint_text_measure(locale_get("modify_start_speed_button"), flint_ui_font()) + flint_px(24);
|
||||
int modify_h = flint_px(36);
|
||||
int modify_hover = 0;
|
||||
if(modify_w > content_w)
|
||||
modify_w = content_w;
|
||||
|
||||
if(progressive_start_speed != clampi(progressive_start_speed, SETTINGS_SPEED_MIN, speed)) {
|
||||
app->inbe.progressive_start_speed = clampi(progressive_start_speed, SETTINGS_SPEED_MIN, speed);
|
||||
app->settings_preview.progressive_start_speed = app->inbe.progressive_start_speed;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
if(ui_draw_generic_button(content_x, modify_y, modify_w, modify_h,
|
||||
locale_get("modify_start_speed_button"),
|
||||
UI_BUTTON_STYLE_SECONDARY, &modify_hover)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalEditProgressiveStartSpeed;
|
||||
app->modal.selected_button = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} else if(app->settings_sub_tab == PRACTICE_SUBTAB_SESSION) {
|
||||
@@ -589,12 +619,12 @@ settings_tab_draw(InbeApp *app)
|
||||
if(ui_draw_generic_button(reset_x, reset_y, reset_w, reset_h,
|
||||
locale_get("reset_to_defaults_label"), UI_BUTTON_STYLE_SECONDARY, &reset_hover)) {
|
||||
/* Reset to default values */
|
||||
speed = 8;
|
||||
speed = DefaultSpeedLevel;
|
||||
max_rounds = DefaultMaxRounds;
|
||||
max_breaths = DefaultMaxBreaths;
|
||||
pause_seconds = DefaultPauseSeconds;
|
||||
app->inbe.progressive_start_speed = 3;
|
||||
app->settings_preview.progressive_start_speed = 3;
|
||||
app->inbe.progressive_start_speed = DefaultProgressiveStartSpeed;
|
||||
app->settings_preview.progressive_start_speed = DefaultProgressiveStartSpeed;
|
||||
app->advanced_session_controls = 0;
|
||||
app->hold_display_mode = HOLD_DISPLAY_CIRCLE;
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
@@ -778,7 +808,6 @@ settings_tab_draw(InbeApp *app)
|
||||
int import_y = text_y;
|
||||
int hover_import = 0;
|
||||
int hover_export = 0;
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
|
||||
/* Export button */
|
||||
int export_h = flint_px(36);
|
||||
@@ -859,24 +888,10 @@ settings_tab_draw(InbeApp *app)
|
||||
int delete_w = flint_text_measure(locale_get("delete_all_data_button"), font) + flint_px(24);
|
||||
int delete_x = content_x;
|
||||
int delete_y = export_y + export_h + flint_px(12);
|
||||
Rectangle delete_rect = {delete_x, delete_y, delete_w, export_h};
|
||||
|
||||
if(CheckCollisionPointRec(mouse_world, delete_rect)) {
|
||||
DrawRectangle(delete_x, delete_y, delete_w, export_h, c_button_hover);
|
||||
ui_draw_bevel(delete_x, delete_y, delete_w, export_h, flint_darken(c_button_hover, 40), flint_lighten(c_button_hover, 40));
|
||||
hover_delete = 1;
|
||||
app->cursor_clickable = 1;
|
||||
} else {
|
||||
DrawRectangle(delete_x, delete_y, delete_w, export_h, c_button);
|
||||
ui_draw_bevel(delete_x, delete_y, delete_w, export_h, flint_lighten(c_button, 40), flint_darken(c_button, 40));
|
||||
}
|
||||
flint_text_draw(locale_get("delete_all_data_button"), delete_x + flint_px(12),
|
||||
flint_ui_text_y(locale_get("delete_all_data_button"), delete_y, export_h, font),
|
||||
font, c_text);
|
||||
|
||||
/* Handle button clicks */
|
||||
if(hover_delete && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) &&
|
||||
!ui_dropdown_captures_click(mouse_world)) {
|
||||
if(ui_draw_generic_button(delete_x, delete_y, delete_w, export_h,
|
||||
locale_get("delete_all_data_button"),
|
||||
UI_BUTTON_STYLE_DANGER, &hover_delete)) {
|
||||
if(data_has_any()) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmDeleteData;
|
||||
@@ -910,10 +925,13 @@ settings_tab_draw(InbeApp *app)
|
||||
|
||||
/* App description */
|
||||
const char *desc_text = locale_get("about_description");
|
||||
FlintTextLayout desc_layout = flint_text_layout_parse(desc_text, (Texture2D){0}, FLINT_ICON_TYPE_NONE, font);
|
||||
flint_text_layout_reflow(&desc_layout, content_w, font, flint_px(10));
|
||||
flint_text_layout_draw(&desc_layout, content_x, &text_y, font, c_text);
|
||||
flint_text_layout_free(&desc_layout);
|
||||
flint_ui_paragraph_draw((FlintUIParagraph){
|
||||
.text = desc_text,
|
||||
.width = content_w,
|
||||
.font = font,
|
||||
.line_gap = flint_px(10),
|
||||
.color = c_text,
|
||||
}, content_x, &text_y);
|
||||
|
||||
/* Version info */
|
||||
text_y += flint_px(20);
|
||||
@@ -983,6 +1001,10 @@ settings_tab_draw(InbeApp *app)
|
||||
}
|
||||
}
|
||||
|
||||
if(app->modal.active && app->modal.type == UIModalEditProgressiveStartSpeed) {
|
||||
settings_draw_progressive_start_speed_editor(app);
|
||||
}
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
#define INBE_VERSION_MAJOR 1
|
||||
#define INBE_VERSION_MINOR 2
|
||||
#define INBE_VERSION_PATCH 3
|
||||
#define INBE_VERSION_STRING "1.2.3"
|
||||
#define INBE_VERSION_PATCH 4
|
||||
#define INBE_VERSION_STRING "1.2.4"
|
||||
|
||||
#endif
|
||||
Vendored
+1
-1
Submodule vendor/flint updated: b47053377c...407d5ab660.
Reference in new issue
Block a user