@@ -51,30 +51,43 @@ static SDL_EventType_MenuExt EVENT_START = (SDL_EventType_MenuExt)0;
51
51
52
52
void PrintMenuItems (SDL_Renderer * renderer , SDL_MenuItem * menu_item , int indent , int * total_index )
53
53
{
54
+ SDL_MenuItem * app_menu = NULL ;
55
+ Sint64 item_count = 0 ;
56
+ Sint64 i = 0 ;
57
+
54
58
if (!menu_item ) {
55
59
return ;
56
60
}
57
61
58
- SDL_MenuItem * app_menu = SDL_GetMenuBarAppMenu (menu_item );
59
- if (app_menu ) {
60
- SDL_RenderDebugText (renderer , (float )(8 * indent * 2 ), (float )(* total_index * 8 ), " -> AppMenu" );
61
- ++ (* total_index );
62
- }
63
-
64
62
const char * label = SDL_GetMenuItemLabel (menu_item );
65
63
66
64
if (!label ) {
67
65
label = "no label given" ;
68
66
}
69
67
70
68
SDL_RenderDebugText (renderer , (float )(8 * indent * 2 ), (float )(* total_index * 8 ), label );
71
-
72
69
++ (* total_index );
70
+
71
+
72
+ if (SDL_GetMenuItemType (menu_item ) == SDL_MENUITEM_MENUBAR ) {
73
+ app_menu = SDL_GetMenuBarAppMenu (menu_item );
74
+
75
+ if (app_menu ) {
76
+ SDL_RenderDebugText (renderer , (float )(8 * (indent + 1 ) * 2 ), (float )(* total_index * 8 ), " -> AppMenu" );
77
+ ++ (* total_index );
78
+
79
+ item_count = SDL_GetMenuChildItems (app_menu );
80
+
81
+ for (i = 0 ; i < item_count ; ++ i ) {
82
+ PrintMenuItems (renderer , SDL_GetMenuChildItem (app_menu , (size_t )i ), indent + 2 , total_index );
83
+ }
84
+ }
85
+ }
73
86
74
- size_t item_count = SDL_GetMenuChildItems (menu_item );
87
+ item_count = SDL_GetMenuChildItems (menu_item );
75
88
76
- for (size_t i = 0 ; i < item_count ; ++ i ) {
77
- PrintMenuItems (renderer , SDL_GetMenuChildItem (menu_item , i ), indent + 1 , total_index );
89
+ for (i = 0 ; i < item_count ; ++ i ) {
90
+ PrintMenuItems (renderer , SDL_GetMenuChildItem (menu_item , ( size_t ) i ), indent + 1 , total_index );
78
91
}
79
92
}
80
93
@@ -114,10 +127,10 @@ void CreateMenuBar_1()
114
127
115
128
SDL_MenuItem * app_menu = SDL_GetMenuBarAppMenu (menu_bar_1 );
116
129
if (app_menu ) {
117
- SDL_assert (!SDL_CreateMenuItem (menu_bar_1 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
118
- SDL_CreateMenuItem (app_menu , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
130
+ SDL_assert (!SDL_CreateMenuItem (menu_bar_1 , "Exit 1 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
131
+ SDL_CreateMenuItem (app_menu , "Exit 1 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
119
132
} else {
120
- SDL_CreateMenuItem (menu_bar_1 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
133
+ SDL_CreateMenuItem (menu_bar_1 , "Exit 1 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
121
134
}
122
135
}
123
136
@@ -161,10 +174,10 @@ void CreateMenuBar_2()
161
174
162
175
SDL_MenuItem * app_menu = SDL_GetMenuBarAppMenu (menu_bar_2 );
163
176
if (app_menu ) {
164
- SDL_assert (!SDL_CreateMenuItem (menu_bar_2 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
165
- SDL_CreateMenuItem (app_menu , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
177
+ SDL_assert (!SDL_CreateMenuItem (menu_bar_2 , "Exit 2 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT ));
178
+ SDL_CreateMenuItem (app_menu , "Exit 2 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
166
179
} else {
167
- SDL_CreateMenuItem (menu_bar_2 , "Exit" , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
180
+ SDL_CreateMenuItem (menu_bar_2 , "Exit 2 " , SDL_MENUITEM_BUTTON , MENU_BAR_EXIT );
168
181
}
169
182
}
170
183
0 commit comments