Skip to content

Commit 7b6a41f

Browse files
libretroadminLibretroAdmin
authored andcommitted
menu_setting: move the OSK overlay group into descriptor rows
The first hand-CONFIG builder migrated to def-file rows rather than just reshaped: the three OSK overlay settings - preset path, auto-scale toggle, opacity - were built imperatively with their commands, refresh handlers, ranges and flags poked on afterward. They are descriptor rows now. The preset's runtime default (the OSK overlay directory) rides in through the existing _DS variant that reads the default from a settings field, so even that holdout needed no new grammar; the auto-scale and opacity customizations map onto the EX row slots that were already there. The builder body collapses to one ADD_DESC; the settings dump is byte-identical, proving every target, default, range, flag, command and handler reproduced exactly, and the referee reads three more settings index-faithful and three fewer hand-built. Net 43 lines out of the builder plus a 28-line def file, and - the point of the exercise - three settings crossed from code the walker can never swallow into data it can. This is the template for the thirty-odd hand-CONFIG builders that hold the bulk of the surface; each movable row that crosses is one the walker eventually reaches.
1 parent 8f976cf commit 7b6a41f

2 files changed

Lines changed: 39 additions & 54 deletions

File tree

menu/menu_setting.c

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15290,6 +15290,13 @@ static void settings_build_overlay(
1529015290
}
1529115291
}
1529215292

15293+
#ifdef HAVE_OVERLAY
15294+
static const setting_desc_t osk_overlay_desc_0[] = {
15295+
/* GENERATED: rows come from settings_def_osk_overlay.h in order. */
15296+
#include "../settings/settings_def_osk_overlay.h"
15297+
};
15298+
#endif
15299+
1529315300
static void settings_build_osk_overlay(
1529415301
settings_t *settings, global_t *global,
1529515302
rarch_setting_t **list, rarch_setting_info_t *list_info,
@@ -15310,60 +15317,7 @@ static void settings_build_osk_overlay(
1531015317

1531115318
START_SUB_GROUP(list, list_info, "State", &group_info, &subgroup_info, parent_group);
1531215319

15313-
/* Descriptor holdout: runtime default value. */
15314-
CONFIG_PATH(
15315-
list, list_info,
15316-
settings->paths.path_osk_overlay,
15317-
sizeof(settings->paths.path_osk_overlay),
15318-
MENU_ENUM_LABEL_OSK_OVERLAY_PRESET,
15319-
MENU_ENUM_LABEL_VALUE_OSK_OVERLAY_PRESET,
15320-
settings->paths.directory_osk_overlay,
15321-
&group_info,
15322-
&subgroup_info,
15323-
parent_group,
15324-
general_write_handler,
15325-
general_read_handler);
15326-
MENU_SETTINGS_LIST_CURRENT_ADD_VALUES(list, list_info, "cfg");
15327-
MENU_SETTINGS_LIST_CURRENT_ADD_CMD(list, list_info, CMD_EVENT_OVERLAY_INIT);
15328-
15329-
/* Descriptor holdout: poke tail outside the descriptor grammar. */
15330-
CONFIG_BOOL(
15331-
list, list_info,
15332-
&settings->bools.input_osk_overlay_auto_scale,
15333-
MENU_ENUM_LABEL_INPUT_OSK_OVERLAY_AUTO_SCALE,
15334-
MENU_ENUM_LABEL_VALUE_INPUT_OSK_OVERLAY_AUTO_SCALE,
15335-
DEFAULT_INPUT_OVERLAY_AUTO_SCALE,
15336-
MENU_ENUM_LABEL_VALUE_OFF,
15337-
MENU_ENUM_LABEL_VALUE_ON,
15338-
&group_info,
15339-
&subgroup_info,
15340-
parent_group,
15341-
general_write_handler,
15342-
general_read_handler,
15343-
SD_FLAG_NONE
15344-
);
15345-
SETTINGS_ACTION_SET(ok, &(*list)[list_info->index - 1], &setting_bool_action_left_with_refresh)
15346-
SETTINGS_ACTION_SET(left, &(*list)[list_info->index - 1], &setting_bool_action_left_with_refresh)
15347-
SETTINGS_ACTION_SET(right, &(*list)[list_info->index - 1], &setting_bool_action_right_with_refresh)
15348-
MENU_SETTINGS_LIST_CURRENT_ADD_CMD(list, list_info, CMD_EVENT_OVERLAY_SET_SCALE_FACTOR);
15349-
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_CMD_APPLY_AUTO);
15350-
15351-
CONFIG_FLOAT(
15352-
list, list_info,
15353-
&settings->floats.input_osk_overlay_opacity,
15354-
MENU_ENUM_LABEL_OSK_OVERLAY_OPACITY,
15355-
MENU_ENUM_LABEL_VALUE_OSK_OVERLAY_OPACITY,
15356-
DEFAULT_INPUT_OVERLAY_OPACITY,
15357-
"%.2f",
15358-
&group_info,
15359-
&subgroup_info,
15360-
parent_group,
15361-
general_write_handler,
15362-
general_read_handler);
15363-
SETTINGS_ACTION_SET(ok, &(*list)[list_info->index - 1], &setting_action_ok_uint)
15364-
MENU_SETTINGS_LIST_CURRENT_ADD_CMD(list, list_info, CMD_EVENT_OVERLAY_SET_ALPHA_MOD);
15365-
menu_settings_list_current_add_range(list, list_info, 0, 1, 0.01, true, true);
15366-
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_CMD_APPLY_AUTO);
15320+
ADD_DESC(osk_overlay_desc_0);
1536715321

1536815322
GROUP_END();
1536915323
#endif
@@ -17937,6 +17891,9 @@ static const settings_desc_table_t settings_desc_registry[] = {
1793717891
{ frame_throttli_desc_3, (uint16_t)ARRAY_SIZE(frame_throttli_desc_3) },
1793817892
#endif
1793917893
#ifdef HAVE_GFX_WIDGETS
17894+
#ifdef HAVE_OVERLAY
17895+
{ osk_overlay_desc_0, (uint16_t)ARRAY_SIZE(osk_overlay_desc_0) },
17896+
#endif
1794017897
{ osn_desc_0, (uint16_t)ARRAY_SIZE(osn_desc_0) },
1794117898
#endif
1794217899
#ifdef HAVE_GFX_WIDGETS
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Single-source definitions: on-screen keyboard overlay group.
2+
* Grammar identical to settings_def_video_sync.h plus S_FLOAT and
3+
* the _NS no-sublabel variants; the descriptor argument span
4+
* matches SDESC_<kind>_ROW; row order is menu display order;
5+
* h2json.py parses these rows for the Crowdin source upload. */
6+
7+
#ifdef HAVE_OVERLAY
8+
/* Preset path defaults to the OSK overlay directory at runtime, so
9+
* the default rides in via the _DS variant reading that settings
10+
* field; the "cfg" filter and overlay-init command are row data. */
11+
S_PATH_DS(path_osk_overlay, OSK_OVERLAY_PRESET,
12+
"osk_overlay_preset",
13+
directory_osk_overlay, SD_FLAG_NONE, CMD_EVENT_OVERLAY_INIT, "cfg", NULL, 0,
14+
"OSK Overlay Preset",
15+
"Select and load an on-screen keyboard overlay preset.")
16+
/* Auto-scale toggles a live rescale: refresh on left/right/ok and a
17+
* scale-factor command, applied automatically. */
18+
S_BOOL_EX(input_osk_overlay_auto_scale, INPUT_OSK_OVERLAY_AUTO_SCALE,
19+
"input_osk_overlay_auto_scale",
20+
DEFAULT_INPUT_OVERLAY_AUTO_SCALE, SD_FLAG_CMD_APPLY_AUTO, 0, CMD_EVENT_OVERLAY_SET_SCALE_FACTOR, setting_bool_action_left_with_refresh, NULL, NULL, NULL, setting_bool_action_left_with_refresh, setting_bool_action_right_with_refresh, 0,
21+
"Auto-Scale OSK Overlay",
22+
"Automatically scale the on-screen keyboard overlay to fit the screen and adjust for aspect ratios.")
23+
S_FLOAT_EX(input_osk_overlay_opacity, OSK_OVERLAY_OPACITY,
24+
"input_osk_overlay_opacity",
25+
DEFAULT_INPUT_OVERLAY_OPACITY, "%.2f", SD_FLAG_CMD_APPLY_AUTO, SDESC_RANGE_MINMAX, CMD_EVENT_OVERLAY_SET_ALPHA_MOD, 0.0f, 1.0f, 0.01f, setting_action_ok_uint, NULL, NULL, NULL, NULL, NULL, 0,
26+
"OSK Overlay Opacity",
27+
"Opacity of the on-screen keyboard overlay.")
28+
#endif

0 commit comments

Comments
 (0)