lc-soft/LCUI










The issue has been solved
Add custom settings #191
lc-soft posted onGitHub
Describe the solution you'd like
- Add
LCUI_Settings settings
to src/main.c:MainApp. - Add files:
- src/setttings.c
- include/LCUI/settings.h
- Change related files to apply settings:
- src/main.c
- src/gui/widget_task.c
- src/display.c
- ...
Usage:
LCUI_SettingsRec settings;
// Get global settings of the LCUI
Settings_Init(&settings);
// default settings:
// settings.paint_flashing = FALSE
// settings.Frame_rate_cap = 120
// settings.fps_meter = FALSE
// settings.record_profile = FALSE
// settings.parallel_rendering_threads = 4
// Set frame rate cap to 30
settings.frame_rate_cap = 30;
// Set parallel rendering threads to 8
settings.parallel_rendering_threads = 8;
// enable paint flashing
settings.paint_flashing = TRUE;
// start record performance profile
settings.record_profile = TRUE;
// show fps meter
settings.fps_meter = TRUE;
// apply this new settings, and trigger LCUI_SETTINGS_CHANGE event
LCUI_ApplySettings(&settings);
// Reset settings to default
LCUI_ResetSettings();
Additional context
settings.frame_rate_cap:
Call StepTimer_SetFrameLimit(MainApp.settings.frame_rate_cap)
when LCUI_SETTINGS_CHANGE event trigger
https://github.com/lc-soft/LCUI/blob/949db382a94370ac8a6f29611d7f40c717f7587c/src/main.c#L474
settings.paint_flashing:
- Remove
display.show_rect_border
,LCUIDisplay_ShowRectBorder()
,LCUIDisplay_HideRectBorder()
. - Add
LCUI_Settings settings
to the display struct, and replacedisplay.show_rect_border
withdisplay.settings->paint_flashing
https://github.com/lc-soft/LCUI/blob/949db382a94370ac8a6f29611d7f40c717f7587c/src/display.c#L233
settings.parallel_rendering_threads:
- Use
display.settings->parallel_rendering_threads
instead ofPARALLEL_RENDERING_THREADS
- The minimum value of
parallel_rendering_threads
is 1
https://github.com/lc-soft/LCUI/blob/949db382a94370ac8a6f29611d7f40c717f7587c/src/display.c#L132 settings.record_profile:
- Save profile data to
MainApp.profile
- Add
LCUI_GetProfile()
to get performance profile
https://github.com/lc-soft/LCUI/blob/949db382a94370ac8a6f29611d7f40c717f7587c/src/main.c#L183
settings.show_fps_meter:
No related code needs to be modified