comparison nuklear_ui/blastem_nuklear.c @ 2694:a6a27d4aa8ab

Ensure debug UI is not scaled based on main window size
author Michael Pavone <pavone@retrodev.com>
date Thu, 19 Jun 2025 20:24:14 -0700
parents 46dba737b931
children
comparison
equal deleted inserted replaced
2693:46dba737b931 2694:a6a27d4aa8ab
2735 fbimg->h = height; 2735 fbimg->h = height;
2736 fbimg->format = NK_FONT_ATLAS_RGBA32; 2736 fbimg->format = NK_FONT_ATLAS_RGBA32;
2737 return nk_image_ptr(fbimg); 2737 return nk_image_ptr(fbimg);
2738 } 2738 }
2739 2739
2740 static void font_init(struct nk_context *ctx) 2740 static void font_init(uint8_t window, struct nk_context *ctx)
2741 { 2741 {
2742 uint32_t height = window < FRAMEBUFFER_USER_START ? render_height() : 480;
2742 struct nk_font_atlas *atlas; 2743 struct nk_font_atlas *atlas;
2743 if (fb_context) { 2744 if (fb_context) {
2744 nk_rawfb_font_stash_begin(fb_context, &atlas); 2745 nk_rawfb_font_stash_begin(fb_context, &atlas);
2745 } else { 2746 } else {
2746 #ifndef DISABLE_OPENGL 2747 #ifndef DISABLE_OPENGL
2750 uint32_t font_size; 2751 uint32_t font_size;
2751 uint8_t *font = default_font(&font_size); 2752 uint8_t *font = default_font(&font_size);
2752 if (!font) { 2753 if (!font) {
2753 fatal_error("Failed to find default font path\n"); 2754 fatal_error("Failed to find default font path\n");
2754 } 2755 }
2755 def_font = nk_font_atlas_add_from_memory(atlas, font, font_size, render_height() / 24, NULL); 2756 def_font = nk_font_atlas_add_from_memory(atlas, font, font_size, height / 24, NULL);
2756 free(font); 2757 free(font);
2757 if (fb_context) { 2758 if (fb_context) {
2758 nk_rawfb_font_stash_end(fb_context); 2759 nk_rawfb_font_stash_end(fb_context);
2759 } else { 2760 } else {
2760 #ifndef DISABLE_OPENGL 2761 #ifndef DISABLE_OPENGL
2778 } 2779 }
2779 #endif 2780 #endif
2780 } 2781 }
2781 } 2782 }
2782 2783
2783 static void style_init(struct nk_context *ctx) 2784 static void style_init(uint8_t window, struct nk_context *ctx)
2784 { 2785 {
2785 ctx->style.checkbox.padding.x = render_height() / 120; 2786 uint32_t height = window < FRAMEBUFFER_USER_START ? render_height() : 480;
2786 ctx->style.checkbox.padding.y = render_height() / 120; 2787 ctx->style.checkbox.padding.x = height / 120;
2787 ctx->style.checkbox.border = render_height() / 240; 2788 ctx->style.checkbox.padding.y = height / 120;
2789 ctx->style.checkbox.border = height / 240;
2788 ctx->style.checkbox.cursor_normal.type = NK_STYLE_ITEM_COLOR; 2790 ctx->style.checkbox.cursor_normal.type = NK_STYLE_ITEM_COLOR;
2789 ctx->style.checkbox.cursor_normal.data.color = (struct nk_color){ 2791 ctx->style.checkbox.cursor_normal.data.color = (struct nk_color){
2790 .r = 255, .g = 128, .b = 0, .a = 255 2792 .r = 255, .g = 128, .b = 0, .a = 255
2791 }; 2793 };
2792 ctx->style.checkbox.cursor_hover = ctx->style.checkbox.cursor_normal; 2794 ctx->style.checkbox.cursor_hover = ctx->style.checkbox.cursor_normal;
2798 } 2800 }
2799 2801
2800 static void fb_resize(void) 2802 static void fb_resize(void)
2801 { 2803 {
2802 nk_rawfb_resize_fb(fb_context, NULL, render_width(), render_height(), 0); 2804 nk_rawfb_resize_fb(fb_context, NULL, render_width(), render_height(), 0);
2803 style_init(context); 2805 style_init(FRAMEBUFFER_UI, context);
2806 font_init(FRAMEBUFFER_UI, context);
2804 texture_init(); 2807 texture_init();
2805 } 2808 }
2806 2809
2807 static void context_created(void) 2810 static void context_created(void)
2808 { 2811 {
2910 fb_context = nk_rawfb_init(NULL, context, render_width(), render_height(), 0); 2913 fb_context = nk_rawfb_init(NULL, context, render_width(), render_height(), 0);
2911 render_set_ui_fb_resize_handler(fb_resize); 2914 render_set_ui_fb_resize_handler(fb_resize);
2912 #ifndef DISABLE_OPENGL 2915 #ifndef DISABLE_OPENGL
2913 } 2916 }
2914 #endif 2917 #endif
2915 style_init(ret); 2918 style_init(window, ret);
2916 font_init(ret); 2919 font_init(window, ret);
2917 return ret; 2920 return ret;
2918 } 2921 }
2919 2922
2920 void blastem_nuklear_init(uint8_t file_loaded) 2923 void blastem_nuklear_init(uint8_t file_loaded)
2921 { 2924 {