diff --git a/src/app/stream/video/session_video.c b/src/app/stream/video/session_video.c index 96e5d8cd..425d5128 100644 --- a/src/app/stream/video/session_video.c +++ b/src/app/stream/video/session_video.c @@ -185,7 +185,7 @@ void vdec_stat_submit(const struct VIDEO_STATS *src, unsigned long now) { dst->receivedFps = (float) dst->receivedFrames / ((float) delta / 1000); dst->decodedFps = (float) dst->submittedFrames / ((float) delta / 1000); LiGetEstimatedRttInfo(&dst->rtt, &dst->rttVariance); - if (!streaming_overlay_shown()) { + if (!streaming_stats_shown()) { return; } int latencyUs = 0; diff --git a/src/app/ui/streaming/streaming.controller.c b/src/app/ui/streaming/streaming.controller.c index dafd3c23..e57e34de 100644 --- a/src/app/ui/streaming/streaming.controller.c +++ b/src/app/ui/streaming/streaming.controller.c @@ -38,7 +38,7 @@ static void overlay_key_cb(lv_event_t *e); static void update_buttons_layout(streaming_controller_t *controller); -bool stats_showing(streaming_controller_t *controller); +static void pin_toggle(lv_event_t *e); const lv_fragment_class_t streaming_controller_class = { .constructor_cb = constructor, @@ -51,21 +51,21 @@ const lv_fragment_class_t streaming_controller_class = { .instance_size = sizeof(streaming_controller_t), }; -static bool overlay_showing; +static bool overlay_showing = false, overlay_pinned = false; static streaming_controller_t *current_controller = NULL; bool streaming_overlay_shown() { return overlay_showing; } -bool stats_showing(streaming_controller_t *controller) { - return streaming_overlay_shown() || controller->stats->parent != controller->overlay; +bool streaming_stats_shown() { + return overlay_showing || overlay_pinned; } bool streaming_refresh_stats() { streaming_controller_t *controller = current_controller; if (!controller) { return false; } - if (!stats_showing(controller)) { + if (!streaming_stats_shown()) { return false; } app_t *app = controller->global; @@ -222,6 +222,8 @@ static void on_view_created(lv_fragment_t *self, lv_obj_t *view) { controller->notice = notice; controller->notice_label = notice_label; + lv_obj_add_event_cb(controller->stats_pin, pin_toggle, LV_EVENT_VALUE_CHANGED, controller->stats); + #if !defined(TARGET_WEBOS) const app_settings_t *settings = &controller->global->settings; if (settings->syskey_capture) { @@ -330,3 +332,21 @@ static void update_buttons_layout(streaming_controller_t *controller) { lv_area_center(&coords, &controller->button_points[4]); app_input_set_button_points(&controller->global->ui.input, controller->button_points); } + +static void pin_toggle(lv_event_t *e) { + lv_obj_t *toggle_view = lv_event_get_user_data(e); + lv_fragment_t *fragment = lv_obj_get_user_data(toggle_view); + bool checked = lv_obj_has_state(lv_event_get_current_target(e), LV_STATE_CHECKED); + bool pinned = toggle_view->parent != fragment->obj; + overlay_pinned = checked; + if (checked == pinned) { + return; + } + if (checked) { + lv_obj_set_parent(toggle_view, lv_layer_top()); + lv_obj_add_state(toggle_view, LV_STATE_USER_1); + } else { + lv_obj_set_parent(toggle_view, fragment->obj); + lv_obj_clear_state(toggle_view, LV_STATE_USER_1); + } +} diff --git a/src/app/ui/streaming/streaming.controller.h b/src/app/ui/streaming/streaming.controller.h index 487f18e6..6730819c 100644 --- a/src/app/ui/streaming/streaming.controller.h +++ b/src/app/ui/streaming/streaming.controller.h @@ -30,6 +30,7 @@ typedef struct { lv_obj_t *host_latency; lv_obj_t *vdec_latency; } stats_items; + lv_obj_t *stats_pin; lv_obj_t *notice, *notice_label; lv_style_t overlay_button_style; lv_style_t overlay_button_style_focused; @@ -56,6 +57,8 @@ void streaming_overlay_resized(streaming_controller_t *controller); bool streaming_overlay_shown(); +bool streaming_stats_shown(); + bool streaming_refresh_stats(); void streaming_notice_show(const char *message); \ No newline at end of file diff --git a/src/app/ui/streaming/streaming.view.c b/src/app/ui/streaming/streaming.view.c index 1392df34..e27a8de5 100644 --- a/src/app/ui/streaming/streaming.view.c +++ b/src/app/ui/streaming/streaming.view.c @@ -1,17 +1,15 @@ #include "streaming.controller.h" -#include "lvgl/ext/lv_child_group.h" - #include "util/i18n.h" #include "util/font.h" #include "hints.h" + +#include "lvgl/ext/lv_child_group.h" #include "lvgl/theme/lv_theme_moonlight.h" static lv_obj_t *stat_label(lv_obj_t *parent, const char *title); -static lv_obj_t *overlay_title(lv_obj_t *parent, const char *title); - -static void pin_toggle(lv_event_t *e); +static lv_obj_t *overlay_title(lv_obj_t *parent, const char *title, streaming_controller_t *controller); lv_obj_t *streaming_scene_create(lv_fragment_t *self, lv_obj_t *parent) { streaming_controller_t *controller = (streaming_controller_t *) self; @@ -119,7 +117,7 @@ lv_obj_t *streaming_scene_create(lv_fragment_t *self, lv_obj_t *parent) { lv_obj_align(stats, LV_ALIGN_TOP_RIGHT, -LV_DPX(20), LV_DPX(20)); lv_obj_set_user_data(stats, controller); - overlay_title(stats, locstr("Performance")); + overlay_title(stats, locstr("Performance"), controller); controller->stats_items.resolution = stat_label(stats, "Resolution"); controller->stats_items.decoder = stat_label(stats, "Decoder"); @@ -192,7 +190,7 @@ static lv_obj_t *stat_label(lv_obj_t *parent, const char *title) { return value; } -static lv_obj_t *overlay_title(lv_obj_t *parent, const char *title) { +static lv_obj_t *overlay_title(lv_obj_t *parent, const char *title, streaming_controller_t *controller) { lv_obj_t *stats_title = lv_label_create(parent); lv_label_set_text_static(stats_title, title); lv_obj_set_width(stats_title, LV_PCT(100)); @@ -226,23 +224,6 @@ static lv_obj_t *overlay_title(lv_obj_t *parent, const char *title) { lv_img_set_src(stat_pin_content, MAT_SYMBOL_PUSH_PIN); lv_obj_align(stats_pin, LV_ALIGN_RIGHT_MID, 0, 0); - lv_obj_add_event_cb(stats_pin, pin_toggle, LV_EVENT_VALUE_CHANGED, parent); + controller->stats_pin = stats_pin; return stats_title; } - -static void pin_toggle(lv_event_t *e) { - lv_obj_t *toggle_view = lv_event_get_user_data(e); - lv_fragment_t *fragment = lv_obj_get_user_data(toggle_view); - bool checked = lv_obj_has_state(lv_event_get_current_target(e), LV_STATE_CHECKED); - bool pinned = toggle_view->parent != fragment->obj; - if (checked == pinned) { - return; - } - if (checked) { - lv_obj_set_parent(toggle_view, lv_layer_top()); - lv_obj_add_state(toggle_view, LV_STATE_USER_1); - } else { - lv_obj_set_parent(toggle_view, fragment->obj); - lv_obj_clear_state(toggle_view, LV_STATE_USER_1); - } -}