raylib-spinel 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ # raygui_compat.rb — the gem's RGui* helper layer for the Spinel path.
4
+ #
5
+ # raygui_helper.rb defines RGui* wrappers that take a Rectangle and return the
6
+ # updated value(s) plus the control result (the C API's out-params become
7
+ # return values). raygui_ffi.rb ships flat-coordinate RGui* forms for the
8
+ # hello_raylib scenes; this file defines the gem-shaped ones, and because it is
9
+ # loaded after raygui_ffi.rb it wins on the gem-compat path. The value shims
10
+ # (rl_Gui*Value + rl_Gui_Get*) carry the out-params out of C.
11
+ module Raylib
12
+ def self.RGuiTabBar(bounds, text, count, active)
13
+ res = Raylib.rl_GuiTabBarValue(bounds.x, bounds.y, bounds.width, bounds.height,
14
+ text, (count || 0).to_i, (active || 0).to_i)
15
+ [Raylib.rl_Gui_GetInt, res]
16
+ end
17
+
18
+ def self.RGuiToggle(bounds, text, active)
19
+ res = Raylib.rl_GuiToggleValue(bounds.x, bounds.y, bounds.width, bounds.height,
20
+ text, Raylib.int_flag(active))
21
+ [Raylib.rl_Gui_GetInt, res]
22
+ end
23
+
24
+ def self.RGuiToggleGroup(bounds, text, active)
25
+ res = Raylib.rl_GuiToggleGroupValue(bounds.x, bounds.y, bounds.width,
26
+ bounds.height, text, (active || 0).to_i)
27
+ [Raylib.rl_Gui_GetInt, res]
28
+ end
29
+
30
+ def self.RGuiToggleSlider(bounds, text, active)
31
+ res = Raylib.rl_GuiToggleSliderValue(bounds.x, bounds.y, bounds.width,
32
+ bounds.height, text, (active || 0).to_i)
33
+ [Raylib.rl_Gui_GetInt, res]
34
+ end
35
+
36
+ def self.RGuiCheckBox(bounds, text, checked)
37
+ res = Raylib.rl_GuiCheckBoxValue(bounds.x, bounds.y, bounds.width,
38
+ bounds.height, text, Raylib.int_flag(checked))
39
+ [Raylib.rl_Gui_GetInt != 0, res]
40
+ end
41
+
42
+ def self.RGuiComboBox(bounds, text, active)
43
+ res = Raylib.rl_GuiComboBoxValue(bounds.x, bounds.y, bounds.width,
44
+ bounds.height, text, (active || 0).to_i)
45
+ [Raylib.rl_Gui_GetInt, res]
46
+ end
47
+
48
+ def self.RGuiDropdownBox(bounds, text, active, edit_mode)
49
+ res = Raylib.rl_GuiDropdownBoxValue(bounds.x, bounds.y, bounds.width,
50
+ bounds.height, text, (active || 0).to_i,
51
+ Raylib.int_flag(edit_mode))
52
+ [Raylib.rl_Gui_GetInt, res]
53
+ end
54
+
55
+ def self.RGuiSpinner(bounds, text, value, min_value, max_value, edit_mode)
56
+ res = Raylib.rl_GuiSpinnerValue(bounds.x, bounds.y, bounds.width,
57
+ bounds.height, text, (value || 0).to_i, (min_value || 0).to_i,
58
+ (max_value || 0).to_i, Raylib.int_flag(edit_mode))
59
+ [Raylib.rl_Gui_GetInt, res]
60
+ end
61
+
62
+ def self.RGuiValueBox(bounds, text, value, min_value, max_value, edit_mode)
63
+ res = Raylib.rl_GuiValueBoxValue(bounds.x, bounds.y, bounds.width,
64
+ bounds.height, text, (value || 0).to_i, (min_value || 0).to_i,
65
+ (max_value || 0).to_i, Raylib.int_flag(edit_mode))
66
+ [Raylib.rl_Gui_GetInt, res]
67
+ end
68
+
69
+ def self.RGuiSlider(bounds, text_left, text_right, value, min_value, max_value)
70
+ res = Raylib.rl_GuiSliderValue(bounds.x, bounds.y, bounds.width,
71
+ bounds.height, text_left, text_right, (value || 0).to_f,
72
+ (min_value || 0).to_f, (max_value || 0).to_f)
73
+ [Raylib.rl_Gui_GetFloat, res]
74
+ end
75
+
76
+ def self.RGuiSliderBar(bounds, text_left, text_right, value, min_value,
77
+ max_value)
78
+ res = Raylib.rl_GuiSliderBarValue(bounds.x, bounds.y, bounds.width,
79
+ bounds.height, text_left, text_right,
80
+ (value || 0).to_f, (min_value || 0).to_f, (max_value || 0).to_f)
81
+ [Raylib.rl_Gui_GetFloat, res]
82
+ end
83
+
84
+ def self.RGuiProgressBar(bounds, text_left, text_right, value, min_value,
85
+ max_value)
86
+ res = Raylib.rl_GuiProgressBarValue(bounds.x, bounds.y, bounds.width,
87
+ bounds.height, text_left, text_right,
88
+ (value || 0).to_f, (min_value || 0).to_f, (max_value || 0).to_f)
89
+ [Raylib.rl_Gui_GetFloat, res]
90
+ end
91
+
92
+ def self.RGuiListView(bounds, text, scroll_index, active)
93
+ res = Raylib.rl_GuiListViewValue(bounds.x, bounds.y, bounds.width,
94
+ bounds.height, text, (scroll_index || 0).to_i, (active || 0).to_i)
95
+ [Raylib.rl_Gui_GetInt2, Raylib.rl_Gui_GetInt, res]
96
+ end
97
+
98
+ def self.RGuiListViewEx(bounds, text, count, scroll_index, active, focus)
99
+ res = Raylib.rl_GuiListViewExValue(bounds.x, bounds.y, bounds.width,
100
+ bounds.height, text, (count || 0).to_i, text.bytesize, (scroll_index || 0).to_i,
101
+ (active || 0).to_i, (focus || 0).to_i)
102
+ [Raylib.rl_Gui_GetInt, Raylib.rl_Gui_GetInt2, Raylib.rl_Gui_GetInt3, res]
103
+ end
104
+
105
+ def self.RGuiColorBarAlpha(bounds, text, alpha)
106
+ res = Raylib.rl_GuiColorBarAlphaValue(bounds.x, bounds.y, bounds.width,
107
+ bounds.height, text, (alpha || 0).to_f)
108
+ [Raylib.rl_Gui_GetFloat, res]
109
+ end
110
+
111
+ def self.RGuiColorBarHue(bounds, text, value)
112
+ res = Raylib.rl_GuiColorBarHueValue(bounds.x, bounds.y, bounds.width,
113
+ bounds.height, text, (value || 0).to_f)
114
+ [Raylib.rl_Gui_GetFloat, res]
115
+ end
116
+ end