lc-soft/LCUI

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 replace display.show_rect_border with display.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 of PARALLEL_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


@lc-soft has funded $15.00 to this issue.


posted by issuehunt-app[bot] over 5 years ago

@lc-soft has funded $15.00 to this issue.


posted by issuehunt-app[bot] over 5 years ago

This issue does not need to be processed, its content needs to be updated

posted by lc-soft about 5 years ago

@lc-soft , I've started this issue.

  • It looks as though the changes related to paint_flashing aren't needed. The fields and methods referenced are gone.
  • Do you have suggestions on how to validate this?
  • Is the funding on it still valid?
posted by jduo almost 5 years ago

@lc-soft , I've started this issue.

Please pause first.

It looks as though the changes related to paint_flashing aren't needed. The fields and methods referenced are gone.

https://github.com/lc-soft/LCUI/blob/17d7d86530614ab65fc5d1984a45b5a3014b0cdf/src/display.c#L85-L93

Do you have suggestions on how to validate this?

Please give me time to consider.

Is the funding on it still valid?

The current bonus is $30, but I see that you are requesting an increase of $50. It has exceeded my budget,I need to consider it because the priority of this issue is very low.

image

posted by lc-soft almost 5 years ago

@lc-soft , I've started this issue.

Please pause first.

It looks as though the changes related to paint_flashing aren't needed. The fields and methods referenced are gone.

https://github.com/lc-soft/LCUI/blob/17d7d86530614ab65fc5d1984a45b5a3014b0cdf/src/display.c#L85-L93

Thanks. I'll update this struct. I believe the changelog mentions that LCUIDisplay_ShowRectBorder() LCUIDisplay_HideRectBorder() have been removed though. Is there anything I need to do related to these calls?

Do you have suggestions on how to validate this?

Please give me time to consider.

Is the funding on it still valid?

The current bonus is $30, but I see that you are requesting an increase of $50. It has exceeded my budget,I need to consider it because the priority of this issue is very low.

I really meant that as an increase to $50, not an increase of $50. I'm new to IssueHunt and may have issued the request incorrectly. The $20 increase was largely about my uncertainty with working with event handlers in this project and being a bit unclear on how to verify this.

image

posted by jduo almost 5 years ago

@lc-soft has funded $20.00 to this issue.


posted by issuehunt-app[bot] almost 5 years ago

@jduo

I really meant that as an increase to $50, not an increase of $50. ...

The bonus has been increased to $50, please note that issuehunt has a service fee (10%).

Is there anything I need to do related to these calls?

https://github.com/lc-soft/LCUI/blob/17d7d86530614ab65fc5d1984a45b5a3014b0cdf/src/display.c#L624-L629

Do you have suggestions on how to validate this?

how to validate this? Do you mean how to validate that the code in this issue is working properly? Well, you need to add test/test_settings.c to test whether these settings take effect.

Other suggestions:

posted by lc-soft almost 5 years ago

I've put up an initial PR with what I think cover the code changes required. Note that in display.c, you've suggested holding a pointer to the settings, but the API only lets you copy the global settings (which I feel is safer than giving direct access to the global settings, especially with regards to sending event settings change notifications).

I'll work on adding unit tests next.

posted by jduo almost 5 years ago

@lc-soft has rewarded $45.00 to @jduo. See it on IssueHunt

  • :moneybag: Total deposit: $50.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $5.00
posted by issuehunt-app[bot] almost 5 years ago

Fund this Issue

$50.00
Rewarded

Rewarded pull request

Recent activities

jduo was rewarded by lc-soft for lc-soft/LCUI# 191
almost 5 years ago
jduo submitted an output to  lc-soft/ LCUI# 191
almost 5 years ago