Skip to content

Add custom settings #191

@lc-soft

Description

@lc-soft

Issuehunt badges

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

LCUI/src/main.c

Line 474 in 949db38

StepTimer_SetFrameLimit(MainApp.timer, LCUI_MAX_FRAMES_PER_SEC);

settings.paint_flashing:

  • Remove display.show_rect_border, LCUIDisplay_ShowRectBorder(), LCUIDisplay_HideRectBorder().
  • Add LCUI_Settings settings to the display struct, and replace display.show_rect_border with display.settings->paint_flashing

if (display.show_rect_border) {

settings.parallel_rendering_threads:

  • Use display.settings->parallel_rendering_threads instead of PARALLEL_RENDERING_THREADS
  • The minimum value of parallel_rendering_threads is 1

DirtyLayerRec layers[PARALLEL_RENDERING_THREADS];

settings.record_profile:

  • Save profile data to MainApp.profile
  • Add LCUI_GetProfile() to get performance profile

LCUI/src/main.c

Line 183 in 949db38

void LCUI_RunFrameWithProfile(LCUI_FrameProfile profile)

settings.show_fps_meter:

No related code needs to be modified


IssueHunt Summary

jduo jduo has been rewarded.

Backers (Total: $50.00)

Submitted pull Requests


Tips

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions