raylib_1.0.1_0fd26c4b/src/raylib-gui.adb

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
with Ada.Unchecked_Conversion;
package body Raylib.GUI is
   pragma Style_Checks ("M2000");
   function To_C_String_Array_Access (A : aliased Interfaces.C.Strings.chars_ptr_array) return C_String_Array_Access is
      function Convert
      is new Ada.Unchecked_Conversion (System.Address, C_String_Array_Access);
   begin
      return Convert (A'Address);
   end To_C_String_Array_Access;
   procedure GuiLoadStyle (fileName : String) is
      use Interfaces.C.Strings;
      C_fileName : Interfaces.C.Strings.chars_ptr := New_String (fileName);
   begin
      GuiLoadStyle (C_fileName);
      Free (C_fileName);
   end GuiLoadStyle;

   procedure GuiSetTooltip (tooltip : String) is
      use Interfaces.C.Strings;
      C_tooltip : Interfaces.C.Strings.chars_ptr := New_String (tooltip);
   begin
      GuiSetTooltip (C_tooltip);
      Free (C_tooltip);
   end GuiSetTooltip;

   function GuiIconText (iconId : Interfaces.C.int; text : String) return String is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant String := Value (GuiIconText (iconId, C_text));
   begin
      Free (C_text);
      return Result;
   end GuiIconText;

   function GuiLoadIcons (fileName : String; loadIconsName : Interfaces.C.C_bool) return access Interfaces.C.Strings.chars_ptr is
      use Interfaces.C.Strings;
      C_fileName : Interfaces.C.Strings.chars_ptr := New_String (fileName);
      Result : constant access Interfaces.C.Strings.chars_ptr := GuiLoadIcons (C_fileName, loadIconsName);
   begin
      Free (C_fileName);
      return Result;
   end GuiLoadIcons;

   function GuiWindowBox (bounds : Rectangle; title : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_title : Interfaces.C.Strings.chars_ptr := New_String (title);
      Result : constant Interfaces.C.int := GuiWindowBox (bounds, C_title);
   begin
      Free (C_title);
      return Result;
   end GuiWindowBox;

   function GuiGroupBox (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiGroupBox (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiGroupBox;

   function GuiLine (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiLine (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiLine;

   function GuiPanel (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiPanel (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiPanel;

   function GuiScrollPanel (bounds : Rectangle; text : String; content : Rectangle; scroll : access Vector2; view : access Rectangle) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiScrollPanel (bounds, C_text, content, scroll, view);
   begin
      Free (C_text);
      return Result;
   end GuiScrollPanel;

   function GuiLabel (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiLabel (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiLabel;

   function GuiButton (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiButton (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiButton;

   function GuiLabelButton (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiLabelButton (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiLabelButton;

   function GuiToggle (bounds : Rectangle; text : String; active : access Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiToggle (bounds, C_text, active);
   begin
      Free (C_text);
      return Result;
   end GuiToggle;

   function GuiToggleGroup (bounds : Rectangle; text : String; active : access Interfaces.C.int) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiToggleGroup (bounds, C_text, active);
   begin
      Free (C_text);
      return Result;
   end GuiToggleGroup;

   function GuiToggleSlider (bounds : Rectangle; text : String; active : access Interfaces.C.int) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiToggleSlider (bounds, C_text, active);
   begin
      Free (C_text);
      return Result;
   end GuiToggleSlider;

   function GuiCheckBox (bounds : Rectangle; text : String; checked : access Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiCheckBox (bounds, C_text, checked);
   begin
      Free (C_text);
      return Result;
   end GuiCheckBox;

   function GuiComboBox (bounds : Rectangle; text : String; active : access Interfaces.C.int) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiComboBox (bounds, C_text, active);
   begin
      Free (C_text);
      return Result;
   end GuiComboBox;

   function GuiDropdownBox (bounds : Rectangle; text : String; active : access Interfaces.C.int; editMode : Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiDropdownBox (bounds, C_text, active, editMode);
   begin
      Free (C_text);
      return Result;
   end GuiDropdownBox;

   function GuiSpinner (bounds : Rectangle; text : String; value : access Interfaces.C.int; minValue : Interfaces.C.int; maxValue : Interfaces.C.int; editMode : Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiSpinner (bounds, C_text, value, minValue, maxValue, editMode);
   begin
      Free (C_text);
      return Result;
   end GuiSpinner;

   function GuiValueBox (bounds : Rectangle; text : String; value : access Interfaces.C.int; minValue : Interfaces.C.int; maxValue : Interfaces.C.int; editMode : Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiValueBox (bounds, C_text, value, minValue, maxValue, editMode);
   begin
      Free (C_text);
      return Result;
   end GuiValueBox;

   function GuiTextBox (bounds : Rectangle; text : String; textSize : Interfaces.C.int; editMode : Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiTextBox (bounds, C_text, textSize, editMode);
   begin
      Free (C_text);
      return Result;
   end GuiTextBox;

   function GuiSlider (bounds : Rectangle; textLeft : String; textRight : String; value : access Interfaces.C.C_float; minValue : Interfaces.C.C_float; maxValue : Interfaces.C.C_float) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_textLeft : Interfaces.C.Strings.chars_ptr := New_String (textLeft);
      C_textRight : Interfaces.C.Strings.chars_ptr := New_String (textRight);
      Result : constant Interfaces.C.int := GuiSlider (bounds, C_textLeft, C_textRight, value, minValue, maxValue);
   begin
      Free (C_textLeft);
      Free (C_textRight);
      return Result;
   end GuiSlider;

   function GuiSliderBar (bounds : Rectangle; textLeft : String; textRight : String; value : access Interfaces.C.C_float; minValue : Interfaces.C.C_float; maxValue : Interfaces.C.C_float) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_textLeft : Interfaces.C.Strings.chars_ptr := New_String (textLeft);
      C_textRight : Interfaces.C.Strings.chars_ptr := New_String (textRight);
      Result : constant Interfaces.C.int := GuiSliderBar (bounds, C_textLeft, C_textRight, value, minValue, maxValue);
   begin
      Free (C_textLeft);
      Free (C_textRight);
      return Result;
   end GuiSliderBar;

   function GuiProgressBar (bounds : Rectangle; textLeft : String; textRight : String; value : access Interfaces.C.C_float; minValue : Interfaces.C.C_float; maxValue : Interfaces.C.C_float) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_textLeft : Interfaces.C.Strings.chars_ptr := New_String (textLeft);
      C_textRight : Interfaces.C.Strings.chars_ptr := New_String (textRight);
      Result : constant Interfaces.C.int := GuiProgressBar (bounds, C_textLeft, C_textRight, value, minValue, maxValue);
   begin
      Free (C_textLeft);
      Free (C_textRight);
      return Result;
   end GuiProgressBar;

   function GuiStatusBar (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiStatusBar (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiStatusBar;

   function GuiDummyRec (bounds : Rectangle; text : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiDummyRec (bounds, C_text);
   begin
      Free (C_text);
      return Result;
   end GuiDummyRec;

   function GuiGrid (bounds : Rectangle; text : String; spacing : Interfaces.C.C_float; subdivs : Interfaces.C.int; mouseCell : access Vector2) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiGrid (bounds, C_text, spacing, subdivs, mouseCell);
   begin
      Free (C_text);
      return Result;
   end GuiGrid;

   function GuiListView (bounds : Rectangle; text : String; scrollIndex : access Interfaces.C.int; active : access Interfaces.C.int) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiListView (bounds, C_text, scrollIndex, active);
   begin
      Free (C_text);
      return Result;
   end GuiListView;

   function GuiMessageBox (bounds : Rectangle; title : String; message : String; buttons : String) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_title : Interfaces.C.Strings.chars_ptr := New_String (title);
      C_message : Interfaces.C.Strings.chars_ptr := New_String (message);
      C_buttons : Interfaces.C.Strings.chars_ptr := New_String (buttons);
      Result : constant Interfaces.C.int := GuiMessageBox (bounds, C_title, C_message, C_buttons);
   begin
      Free (C_title);
      Free (C_message);
      Free (C_buttons);
      return Result;
   end GuiMessageBox;

   function GuiTextInputBox (bounds : Rectangle; title : String; message : String; buttons : String; text : Interfaces.C.Strings.chars_ptr; textMaxSize : Interfaces.C.int; secretViewActive : access Interfaces.C.C_bool) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_title : Interfaces.C.Strings.chars_ptr := New_String (title);
      C_message : Interfaces.C.Strings.chars_ptr := New_String (message);
      C_buttons : Interfaces.C.Strings.chars_ptr := New_String (buttons);
      Result : constant Interfaces.C.int := GuiTextInputBox (bounds, C_title, C_message, C_buttons, text, textMaxSize, secretViewActive);
   begin
      Free (C_title);
      Free (C_message);
      Free (C_buttons);
      return Result;
   end GuiTextInputBox;

   function GuiColorPicker (bounds : Rectangle; text : String; color_p : access Color) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiColorPicker (bounds, C_text, color_p);
   begin
      Free (C_text);
      return Result;
   end GuiColorPicker;

   function GuiColorPanel (bounds : Rectangle; text : String; color_p : access Color) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiColorPanel (bounds, C_text, color_p);
   begin
      Free (C_text);
      return Result;
   end GuiColorPanel;

   function GuiColorBarAlpha (bounds : Rectangle; text : String; alpha : access Interfaces.C.C_float) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiColorBarAlpha (bounds, C_text, alpha);
   begin
      Free (C_text);
      return Result;
   end GuiColorBarAlpha;

   function GuiColorBarHue (bounds : Rectangle; text : String; value : access Interfaces.C.C_float) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiColorBarHue (bounds, C_text, value);
   begin
      Free (C_text);
      return Result;
   end GuiColorBarHue;

   function GuiColorPickerHSV (bounds : Rectangle; text : String; colorHsv : access Vector3) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiColorPickerHSV (bounds, C_text, colorHsv);
   begin
      Free (C_text);
      return Result;
   end GuiColorPickerHSV;

   function GuiColorPanelHSV (bounds : Rectangle; text : String; colorHsv : access Vector3) return Interfaces.C.int is
      use Interfaces.C.Strings;
      C_text : Interfaces.C.Strings.chars_ptr := New_String (text);
      Result : constant Interfaces.C.int := GuiColorPanelHSV (bounds, C_text, colorHsv);
   begin
      Free (C_text);
      return Result;
   end GuiColorPanelHSV;

end Raylib.GUI;