white_gold 0.0.3 → 0.0.4

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/ext/dll/tgui.dll +0 -0
  3. data/ext/so/libtgui.so +0 -0
  4. data/lib/white_gold/abi/enum.rb +1 -1
  5. data/lib/white_gold/abi/interface/interface.rb +3 -7
  6. data/lib/white_gold/convention/bang_def.rb +14 -0
  7. data/lib/white_gold/convention/bang_nest.rb +1 -1
  8. data/lib/white_gold/convention/bang_nested_caller.rb +55 -22
  9. data/lib/white_gold/convention/container_widgets.rb +46 -86
  10. data/lib/white_gold/convention/page.rb +10 -4
  11. data/lib/white_gold/convention/theme/boolean_attribute.rb +11 -9
  12. data/lib/white_gold/convention/theme/color_attribute.rb +11 -9
  13. data/lib/white_gold/convention/theme/float_attribute.rb +11 -9
  14. data/lib/white_gold/convention/theme/outline_attribute.rb +11 -9
  15. data/lib/white_gold/convention/theme/text_styles_attribute.rb +14 -12
  16. data/lib/white_gold/convention/theme/texture_attribute.rb +14 -12
  17. data/lib/white_gold/convention/theme/theme_attributed.rb +1 -1
  18. data/lib/white_gold/convention/theme/theme_component.rb +1 -1
  19. data/lib/white_gold/convention/theme_attributes.rb +6 -2
  20. data/lib/white_gold/convention/widget/keyboard_control.rb +30 -0
  21. data/lib/white_gold/convention/widget_class_aliases.rb +24 -0
  22. data/lib/white_gold/dsl/canvas.rb +5 -5
  23. data/lib/white_gold/dsl/chat_box.rb +1 -1
  24. data/lib/white_gold/dsl/child_window.rb +1 -1
  25. data/lib/white_gold/dsl/color.rb +4 -2
  26. data/lib/white_gold/dsl/combo_box.rb +2 -2
  27. data/lib/white_gold/dsl/container.rb +1 -1
  28. data/lib/white_gold/dsl/custom_widget.rb +28 -0
  29. data/lib/white_gold/dsl/grid.rb +34 -10
  30. data/lib/white_gold/dsl/gui.rb +10 -1
  31. data/lib/white_gold/dsl/label.rb +3 -0
  32. data/lib/white_gold/dsl/list_box.rb +2 -2
  33. data/lib/white_gold/dsl/list_view.rb +6 -6
  34. data/lib/white_gold/dsl/menu_bar.rb +4 -4
  35. data/lib/white_gold/dsl/message_box.rb +3 -3
  36. data/lib/white_gold/dsl/panel.rb +8 -0
  37. data/lib/white_gold/dsl/panel_list_box.rb +12 -3
  38. data/lib/white_gold/dsl/radio_button.rb +15 -2
  39. data/lib/white_gold/dsl/scrollable_panel.rb +7 -0
  40. data/lib/white_gold/dsl/sfml/circle_shape.rb +4 -0
  41. data/lib/white_gold/dsl/sfml/convex_shape.rb +4 -0
  42. data/lib/white_gold/dsl/sfml/rectangle_shape.rb +4 -0
  43. data/lib/white_gold/dsl/sfml/text.rb +4 -0
  44. data/lib/white_gold/dsl/signal/global_signal.rb +1 -1
  45. data/lib/white_gold/dsl/signal/signal.rb +1 -1
  46. data/lib/white_gold/dsl/signal/signal_animation_type.rb +1 -1
  47. data/lib/white_gold/dsl/signal/signal_bool.rb +1 -1
  48. data/lib/white_gold/dsl/signal/signal_color.rb +1 -1
  49. data/lib/white_gold/dsl/signal/signal_float.rb +1 -1
  50. data/lib/white_gold/dsl/signal/signal_int.rb +1 -1
  51. data/lib/white_gold/dsl/signal/signal_pointer.rb +1 -1
  52. data/lib/white_gold/dsl/signal/signal_range.rb +1 -1
  53. data/lib/white_gold/dsl/signal/signal_show_effect.rb +1 -1
  54. data/lib/white_gold/dsl/signal/signal_string.rb +1 -1
  55. data/lib/white_gold/dsl/signal/signal_u_int.rb +1 -1
  56. data/lib/white_gold/dsl/signal/signal_vector2f.rb +1 -1
  57. data/lib/white_gold/dsl/tab_container.rb +2 -2
  58. data/lib/white_gold/dsl/tabs.rb +2 -2
  59. data/lib/white_gold/dsl/theme.rb +2 -2
  60. data/lib/white_gold/dsl/toggle_button.rb +3 -0
  61. data/lib/white_gold/dsl/tree_view.rb +2 -2
  62. data/lib/white_gold/dsl/widget.rb +53 -23
  63. data/lib/white_gold/dsl/window.rb +7 -0
  64. data/lib/white_gold/generated/tgui-abi-loader.gf.rb +76 -1
  65. data/lib/white_gold/library/theme/light.rb +8 -1
  66. data/lib/white_gold/master.rb +30 -10
  67. data/lib/white_gold/path/array.path.rb +16 -0
  68. data/lib/white_gold/tgui-abi.rb +32 -22
  69. data/lib/white_gold/version.rb +1 -1
  70. data/lib/white_gold.rb +3 -1
  71. metadata +6 -3
  72. data/lib/white_gold/abi/reducer.rb +0 -12
@@ -75,7 +75,7 @@ module Tgui
75
75
  objects.insert index, object
76
76
  tab_panel = TabPanel.new self, index, panel_pointer
77
77
  tab_panel.page = page
78
- tab_panel.send! **na, &b
78
+ scope! tab_panel, **na, &b
79
79
  end
80
80
 
81
81
  def [](object)
@@ -93,7 +93,7 @@ module Tgui
93
93
  def! :tabs do |**na, &b|
94
94
  tabs = Tabs.new self, _abi_get_tabs
95
95
  tabs.page = page
96
- tabs.send! **na, &b
96
+ scope! tabs, **na, &b
97
97
  end
98
98
 
99
99
  def remove object
@@ -61,7 +61,7 @@ module Tgui
61
61
  end
62
62
  objects.insert index, object
63
63
  tab = Tab.new self, index
64
- tab.send! **na, &b
64
+ scope! tab, **na, &b
65
65
  end
66
66
 
67
67
  def remove object
@@ -101,7 +101,7 @@ module Tgui
101
101
 
102
102
  def block_caller &b
103
103
  Fiddle::Closure::BlockCaller.new(0, [0]) do
104
- @widget.send! do
104
+ @widget.host! do
105
105
  b.(@widget.selected, @widget)
106
106
  end
107
107
  end
@@ -70,7 +70,7 @@ module Tgui
70
70
  self.next_renderer_id = renderer_id = next_renderer_id.next
71
71
  attribute = type.new(seed, renderer_id)
72
72
  attributes[attribute.name] = attribute
73
- attribute.send! **na, &b
73
+ attribute.host! **na, &b
74
74
  self_commit
75
75
  renderer_id
76
76
  end
@@ -97,7 +97,7 @@ module Tgui
97
97
  _abi_load @source if @source
98
98
  end
99
99
  custom_rendered&.each do |widget, renderer|
100
- widget.self_renderer = renderer
100
+ widget.self_set_renderer renderer
101
101
  end
102
102
  end
103
103
  end
@@ -3,6 +3,9 @@ require_relative 'button_base'
3
3
  module Tgui
4
4
  class ToggleButton < ButtonBase
5
5
 
6
+ class Theme < ButtonBase::Theme
7
+ end
8
+
6
9
  abi_attr :down?
7
10
  abi_signal :on_toggle
8
11
 
@@ -34,7 +34,7 @@ module Tgui
34
34
  end
35
35
  SignalItemHierarchy.fetch_path vector, loader
36
36
  object_path = @widget.self_tree.path_str_to_object *path
37
- @widget.send! do
37
+ @widget.host! do
38
38
  b.(object_path.last, object_path, @widget)
39
39
  end
40
40
  end
@@ -176,7 +176,7 @@ module Tgui
176
176
  self_tree[*new_path, grow: true].text = _3
177
177
  end
178
178
  item = Item.new self, new_path
179
- item.send! **na, &b
179
+ scope! item, **na, &b
180
180
  end
181
181
 
182
182
  def self_change_item path, text, **na, &b
@@ -29,6 +29,10 @@ module Tgui
29
29
 
30
30
  attr_accessor :page
31
31
 
32
+ def window
33
+ page.window
34
+ end
35
+
32
36
  abi_attr :text_size, Integer
33
37
  abi_attr :enabled?
34
38
 
@@ -36,34 +40,40 @@ module Tgui
36
40
  self.enabled = !disabled
37
41
  end
38
42
 
39
- def! :renderer do |seed = VOID, **na, &b|
43
+ def! :theme do |seed = VOID, **na, &b|
40
44
  seed = page.custom_renderers[self] if seed == VOID
41
45
  if !na.empty? || b
42
- seed = page.theme.custom! self.class::Theme, seed, **na, &b
43
- page.custom_renderers[self] = seed
44
- elsif !seed
45
- page.custom_renderers.delete self
46
- else
46
+ if seed.is_a?(String) && seed =~ /_\d+/
47
+ page.theme.attributes[seed].host! **na, &b
48
+ page.theme.self_commit
49
+ else
50
+ seed = page.theme.custom! self.class::Theme, seed, **na, &b
51
+ page.custom_renderers[self] = seed
52
+ end
53
+ elsif seed
47
54
  page.custom_renderers[self] = seed
48
55
  end
49
- self.self_renderer = seed
56
+ self_set_renderer seed
50
57
  end
51
58
 
52
- def renderer=(renderer)
53
- case renderer
59
+ def theme=(theme)
60
+ case theme
54
61
  when Hash
55
- api_bang_renderer **renderer
62
+ api_bang_theme **theme
56
63
  when Proc
57
- api_bang_renderer &renderer
64
+ api_bang_theme &theme
58
65
  else
59
- page.custom_renderers[self] = renderer
60
- self.self_renderer = renderer
66
+ page.custom_renderers[self] = theme
67
+ self_set_renderer theme
61
68
  end
62
69
  end
63
70
 
64
- abi_def :self_renderer=, :set_renderer, proc.self_renderer => nil
71
+ abi_def :self_set_renderer, :set_renderer, proc.self_theme_name => nil
65
72
 
66
73
  abi_attr :focused?
74
+ def! :focus do |focus = VOID|
75
+ self.focused = focus
76
+ end
67
77
  abi_attr :focusable?
68
78
  abi_signal :on_position_change, Tgui::SignalVector2f
69
79
  abi_signal :on_size_change, Tgui::SignalVector2f
@@ -99,7 +109,7 @@ module Tgui
99
109
  if block_given?
100
110
  tooltip = ToolTip.new
101
111
  tooltip.page = page
102
- tooltip.send! **na, &b
112
+ scope! tooltip, **na, &b
103
113
  _abi_set_tool_tip tooltip.widget if tooltip.widget
104
114
  else
105
115
  widget = _abi_get_tool_tip
@@ -198,14 +208,14 @@ module Tgui
198
208
  end
199
209
 
200
210
  def! :navigation do |**na, &b|
201
- navigation.send! **na, &b
211
+ scope! navigation, **na, &b
202
212
  end
203
213
 
204
214
  def navigation
205
215
  Navigation.new self, nil
206
216
  end
207
217
 
208
- abi_enum "KeyCode", nil, :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k,
218
+ abi_enum "KeyCode", :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k,
209
219
  :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z,
210
220
  :num0, :num1, :num2, :num3, :num4, :num5, :num6, :num7, :num8, :num9,
211
221
  :escape, :left_control, :left_shift, :left_alt, :left_system,
@@ -258,10 +268,30 @@ module Tgui
258
268
 
259
269
  def! :robot do |**na, &b|
260
270
  robot = Robot.new self
261
- robot.send! **na, &b if block_given?
271
+ scope! robot, **na, &b if block_given?
262
272
  robot
263
273
  end
264
274
 
275
+ def! :messagebox do |*a, **na, &b|
276
+ page.api_bang_messagebox *a, **na, &b
277
+ end
278
+
279
+ def! :msg do |text, **buttons|
280
+ buttons["OK"] = nil if buttons.empty?
281
+ buttons = buttons.map do |k, v|
282
+ procedure = proc do |o, b, w|
283
+ v&.call
284
+ w.close true
285
+ end
286
+ [k, procedure]
287
+ end
288
+ page.api_bang_messagebox text:, position: :center, label_alignment: :center, buttons: buttons
289
+ end
290
+
291
+ def! :page do |*a, **na, &b|
292
+ page.host! *a, **na, &b
293
+ end
294
+
265
295
  def self.api_attr name, &init
266
296
  define_method "#{name}=" do |value|
267
297
  @@data_storage[Widget.get_unshared(@pointer).to_i][name] = value
@@ -302,14 +332,14 @@ module Tgui
302
332
  class << self
303
333
  include ApiChild
304
334
 
305
- def self_renderer widget, renderer = nil
306
- case renderer
335
+ def self_theme_name widget, theme = nil
336
+ case theme
307
337
  when Module
308
- renderer.name.split("::").last
338
+ theme.name.split("::").last
309
339
  when nil, false, VOID
310
- self_renderer widget, widget.class
340
+ self_theme_name widget, widget.class
311
341
  else
312
- renderer.to_s
342
+ theme.to_s
313
343
  end
314
344
  end
315
345
 
@@ -11,6 +11,13 @@ module Tgui
11
11
  end
12
12
  abi_def :open?
13
13
  abi_def :title=, String => nil
14
+ abi_attr :size, Vector2u
15
+ abi_attr :position, Vector2u
16
+ abi_def :has_focus?, nil => Boolean
17
+ abi_def :request_focus
18
+ def! :request_focus do
19
+ request_focus
20
+ end
14
21
 
15
22
  end
16
23
  end
@@ -36,10 +36,16 @@ module Tgui
36
36
  extern 'int ABI_SignalTypedIntBoolPtr_connect(SignalTypedIntBoolPtr* self, void(*f)(int, bool*))'
37
37
  extern 'int ABI_SignalTypedSizeT_connect(SignalTypedSizeT* self, void(*f)(int))'
38
38
  extern 'int ABI_SignalPanelListBoxItem_connect(SignalPanelListBoxItem* self, void(*f)(const char32_t*))'
39
- extern 'void* ABI_Window_new()'
39
+ extern 'void* ABI_Window_new(int width, int height, int style)'
40
40
  extern 'void ABI_Window_close(sf::WindowBase* self)'
41
41
  extern 'int ABI_Window_isOpen(sf::WindowBase* self)'
42
42
  extern 'void ABI_Window_setTitle(sf::WindowBase* self, char* title)'
43
+ extern 'void ABI_Window_setSize(sf::WindowBase* self, int width, int height)'
44
+ extern 'void* ABI_Window_getSize(sf::WindowBase* self)'
45
+ extern 'void ABI_Window_setPosition(sf::WindowBase* self, int x, int y)'
46
+ extern 'void* ABI_Window_getPosition(sf::WindowBase* self)'
47
+ extern 'void ABI_Window_requestFocus(sf::WindowBase* self)'
48
+ extern 'int ABI_Window_hasFocus(sf::WindowBase* self)'
43
49
  extern 'void ABI_BackendGui_setTextSize(BackendGui* self, int textSize)'
44
50
  extern 'int ABI_BackendGui_getTextSize(BackendGui* self)'
45
51
  extern 'void ABI_BackendGui_setAbsoluteView(BackendGui* self, int x, int y, int w, int h)'
@@ -76,6 +82,7 @@ module Tgui
76
82
  extern 'void ABI_Gui_setClearColor(Gui* self, Color* color)'
77
83
  extern 'void ABI_Gui_setClipboard(Gui* self, char* text)'
78
84
  extern 'void* ABI_Gui_getClipboard(Gui* self)'
85
+ extern 'void* ABI_Gui_getScreenSize(Gui* self)'
79
86
  extern 'void ABI_STATIC_Theme_setDefault(char* theme)'
80
87
  extern 'void* ABI_STATIC_Theme_getDefault()'
81
88
  extern 'void ABI_STATIC_Theme_finalizer(std::shared_ptr<Theme>* pointer)'
@@ -825,16 +832,20 @@ module Tgui
825
832
  extern 'void* ABI_Shape_getOrigin(sf::Shape* self)'
826
833
  extern 'int ABI_CircleShape_getPointCount(sf::CircleShape* self)'
827
834
  extern 'void* ABI_CircleShape_new()'
835
+ extern 'void ABI_STATIC_CircleShape_delete(sf::CircleShape* self)'
828
836
  extern 'void ABI_CircleShape_setRadius(sf::CircleShape* self, float radius)'
829
837
  extern 'float ABI_CircleShape_getRadius(sf::CircleShape* self)'
830
838
  extern 'void ABI_CircleShape_setPointCount(sf::CircleShape* self, int pointCount)'
831
839
  extern 'void* ABI_RectangleShape_new()'
840
+ extern 'void ABI_STATIC_RectangleShape_delete(sf::RectangleShape* self)'
832
841
  extern 'void ABI_RectangleShape_setSize(sf::RectangleShape* self, float width, float height)'
833
842
  extern 'void* ABI_RectangleShape_getSize(sf::RectangleShape* self)'
834
843
  extern 'void* ABI_ConvexShape_new()'
844
+ extern 'void ABI_STATIC_ConvexShape_delete(sf::ConvexShape* self)'
835
845
  extern 'void ABI_ConvexShape_setPoint(sf::ConvexShape* self, int index, float x, float y)'
836
846
  extern 'void ABI_ConvexShape_setPointCount(sf::ConvexShape* self, int pointCount)'
837
847
  extern 'void* ABI_Text_new()'
848
+ extern 'void ABI_STATIC_Text_delete(sf::Text* self)'
838
849
  extern 'void ABI_Text_setString(sf::Text* self, char* string)'
839
850
  extern 'void* ABI_Text_getString(sf::Text* self)'
840
851
  extern 'void ABI_Text_setFont(sf::Text* self, Font* font)'
@@ -861,6 +872,31 @@ module Tgui
861
872
  extern 'void ABI_Text_setOrigin(sf::Text* self, float x, float y)'
862
873
  extern 'void* ABI_Text_getOrigin(sf::Text* self)'
863
874
  extern 'void* ABI_Text_findCharacterPos(sf::Text* self, int index)'
875
+ extern 'void* ABI_CustomWidget_new()'
876
+ extern 'void ABI_CustomWidget_implPositionChanged(CustomWidgetForBindings::Ptr* self, void(*f)(float x, float y))'
877
+ extern 'void ABI_CustomWidget_implSizeChanged(CustomWidgetForBindings::Ptr* self, void(*f)(float width, float height))'
878
+ extern 'void ABI_CustomWidget_implVisibleChanged(CustomWidgetForBindings::Ptr* self, void(*f)(int visible))'
879
+ extern 'void ABI_CustomWidget_implEnableChanged(CustomWidgetForBindings::Ptr* self, void(*f)(int enable))'
880
+ extern 'void ABI_CustomWidget_implFocusChanged(CustomWidgetForBindings::Ptr* self, void(*f)(int focus))'
881
+ extern 'void ABI_CustomWidget_implCanGainFocus(CustomWidgetForBindings::Ptr* self, int(*f)(void))'
882
+ extern 'void ABI_CustomWidget_implGetFullSize(CustomWidgetForBindings::Ptr* self, float(*f)(void))'
883
+ extern 'void ABI_CustomWidget_implGetWidgetOffset(CustomWidgetForBindings::Ptr* self, float(*f)(void))'
884
+ extern 'void ABI_CustomWidget_implUpdateTimeFunction(CustomWidgetForBindings::Ptr* self, int(*f)(int time))'
885
+ extern 'void ABI_CustomWidget_implMouseOnWidget(CustomWidgetForBindings::Ptr* self, int(*f)(float x, float y))'
886
+ extern 'void ABI_CustomWidget_implLeftMousePressed(CustomWidgetForBindings::Ptr* self, int(*f)(float x, float y))'
887
+ extern 'void ABI_CustomWidget_implLeftMouseReleased(CustomWidgetForBindings::Ptr* self, void(*f)(float x, float y))'
888
+ extern 'void ABI_CustomWidget_implRightMousePressed(CustomWidgetForBindings::Ptr* self, void(*f)(float x, float y))'
889
+ extern 'void ABI_CustomWidget_implRightMouseReleased(CustomWidgetForBindings::Ptr* self, void(*f)(float x, float y))'
890
+ extern 'void ABI_CustomWidget_implMouseMoved(CustomWidgetForBindings::Ptr* self, void(*f)(float x, float y))'
891
+ extern 'void ABI_CustomWidget_implKeyPressed(CustomWidgetForBindings::Ptr* self, void(*f)(int key, int alt, int control, int shift, int system))'
892
+ extern 'void ABI_CustomWidget_implTextEntered(CustomWidgetForBindings::Ptr* self, void(*f)(int character))'
893
+ extern 'void ABI_CustomWidget_implScrolled(CustomWidgetForBindings::Ptr* self, int(*f)(float delta, float x, float y, int touch))'
894
+ extern 'void ABI_CustomWidget_implMouseNoLongerOnWidget(CustomWidgetForBindings::Ptr* self, void(*f)(void))'
895
+ extern 'void ABI_CustomWidget_implLeftMouseButtonNoLongerDown(CustomWidgetForBindings::Ptr* self, void(*f)(void))'
896
+ extern 'void ABI_CustomWidget_implMouseEnteredWidget(CustomWidgetForBindings::Ptr* self, void(*f)(void))'
897
+ extern 'void ABI_CustomWidget_implMouseLeftWidget(CustomWidgetForBindings::Ptr* self, void(*f)(void))'
898
+ extern 'void ABI_CustomWidget_implRendererChanged(CustomWidgetForBindings::Ptr* self, int(*f)(const char32_t* property))'
899
+ extern 'void ABI_CustomWidget_implDrawFunction(CustomWidgetForBindings::Ptr* self, void(*f)(BackendRenderTarget* target, RenderStates* states))'
864
900
  end
865
901
 
866
902
  class Util
@@ -961,6 +997,12 @@ module Tgui
961
997
  def _abi_close(*a); Abi.call_arg_map! a; Abi.ABI_Window_close(@pointer, *a); end
962
998
  def _abi_is_open(*a); Abi.call_arg_map! a; Abi.ABI_Window_isOpen(@pointer, *a); end
963
999
  def _abi_set_title(*a); Abi.call_arg_map! a; Abi.ABI_Window_setTitle(@pointer, *a); end
1000
+ def _abi_set_size(*a); Abi.call_arg_map! a; Abi.ABI_Window_setSize(@pointer, *a); end
1001
+ def _abi_get_size(*a); Abi.call_arg_map! a; Abi.ABI_Window_getSize(@pointer, *a); end
1002
+ def _abi_set_position(*a); Abi.call_arg_map! a; Abi.ABI_Window_setPosition(@pointer, *a); end
1003
+ def _abi_get_position(*a); Abi.call_arg_map! a; Abi.ABI_Window_getPosition(@pointer, *a); end
1004
+ def _abi_request_focus(*a); Abi.call_arg_map! a; Abi.ABI_Window_requestFocus(@pointer, *a); end
1005
+ def _abi_has_focus(*a); Abi.call_arg_map! a; Abi.ABI_Window_hasFocus(@pointer, *a); end
964
1006
  end
965
1007
 
966
1008
  class BackendGui
@@ -1006,6 +1048,7 @@ module Tgui
1006
1048
  def _abi_set_clear_color(*a); Abi.call_arg_map! a; Abi.ABI_Gui_setClearColor(@pointer, *a); end
1007
1049
  def _abi_set_clipboard(*a); Abi.call_arg_map! a; Abi.ABI_Gui_setClipboard(@pointer, *a); end
1008
1050
  def _abi_get_clipboard(*a); Abi.call_arg_map! a; Abi.ABI_Gui_getClipboard(@pointer, *a); end
1051
+ def _abi_get_screen_size(*a); Abi.call_arg_map! a; Abi.ABI_Gui_getScreenSize(@pointer, *a); end
1009
1052
  end
1010
1053
 
1011
1054
  class Theme
@@ -1914,6 +1957,7 @@ module Tgui
1914
1957
  class CircleShape
1915
1958
  def _abi_get_point_count(*a); Abi.call_arg_map! a; Abi.ABI_CircleShape_getPointCount(@pointer, *a); end
1916
1959
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_CircleShape_new(*a)); end
1960
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_CircleShape_delete(*a); end
1917
1961
  def _abi_set_radius(*a); Abi.call_arg_map! a; Abi.ABI_CircleShape_setRadius(@pointer, *a); end
1918
1962
  def _abi_get_radius(*a); Abi.call_arg_map! a; Abi.ABI_CircleShape_getRadius(@pointer, *a); end
1919
1963
  def _abi_set_point_count(*a); Abi.call_arg_map! a; Abi.ABI_CircleShape_setPointCount(@pointer, *a); end
@@ -1921,18 +1965,21 @@ module Tgui
1921
1965
 
1922
1966
  class RectangleShape
1923
1967
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_RectangleShape_new(*a)); end
1968
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_RectangleShape_delete(*a); end
1924
1969
  def _abi_set_size(*a); Abi.call_arg_map! a; Abi.ABI_RectangleShape_setSize(@pointer, *a); end
1925
1970
  def _abi_get_size(*a); Abi.call_arg_map! a; Abi.ABI_RectangleShape_getSize(@pointer, *a); end
1926
1971
  end
1927
1972
 
1928
1973
  class ConvexShape
1929
1974
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_ConvexShape_new(*a)); end
1975
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_ConvexShape_delete(*a); end
1930
1976
  def _abi_set_point(*a); Abi.call_arg_map! a; Abi.ABI_ConvexShape_setPoint(@pointer, *a); end
1931
1977
  def _abi_set_point_count(*a); Abi.call_arg_map! a; Abi.ABI_ConvexShape_setPointCount(@pointer, *a); end
1932
1978
  end
1933
1979
 
1934
1980
  class Text
1935
1981
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Text_new(*a)); end
1982
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Text_delete(*a); end
1936
1983
  def _abi_set_string(*a); Abi.call_arg_map! a; Abi.ABI_Text_setString(@pointer, *a); end
1937
1984
  def _abi_get_string(*a); Abi.call_arg_map! a; Abi.ABI_Text_getString(@pointer, *a); end
1938
1985
  def _abi_set_font(*a); Abi.call_arg_map! a; Abi.ABI_Text_setFont(@pointer, *a); end
@@ -1960,4 +2007,32 @@ module Tgui
1960
2007
  def _abi_get_origin(*a); Abi.call_arg_map! a; Abi.ABI_Text_getOrigin(@pointer, *a); end
1961
2008
  def _abi_find_character_pos(*a); Abi.call_arg_map! a; Abi.ABI_Text_findCharacterPos(@pointer, *a); end
1962
2009
  end
2010
+
2011
+ class CustomWidget
2012
+ def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_CustomWidget_new(*a)); end
2013
+ def _abi_impl_position_changed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implPositionChanged(@pointer, *a); end
2014
+ def _abi_impl_size_changed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implSizeChanged(@pointer, *a); end
2015
+ def _abi_impl_visible_changed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implVisibleChanged(@pointer, *a); end
2016
+ def _abi_impl_enable_changed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implEnableChanged(@pointer, *a); end
2017
+ def _abi_impl_focus_changed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implFocusChanged(@pointer, *a); end
2018
+ def _abi_impl_can_gain_focus(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implCanGainFocus(@pointer, *a); end
2019
+ def _abi_impl_get_full_size(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implGetFullSize(@pointer, *a); end
2020
+ def _abi_impl_get_widget_offset(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implGetWidgetOffset(@pointer, *a); end
2021
+ def _abi_impl_update_time_function(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implUpdateTimeFunction(@pointer, *a); end
2022
+ def _abi_impl_mouse_on_widget(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implMouseOnWidget(@pointer, *a); end
2023
+ def _abi_impl_left_mouse_pressed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implLeftMousePressed(@pointer, *a); end
2024
+ def _abi_impl_left_mouse_released(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implLeftMouseReleased(@pointer, *a); end
2025
+ def _abi_impl_right_mouse_pressed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implRightMousePressed(@pointer, *a); end
2026
+ def _abi_impl_right_mouse_released(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implRightMouseReleased(@pointer, *a); end
2027
+ def _abi_impl_mouse_moved(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implMouseMoved(@pointer, *a); end
2028
+ def _abi_impl_key_pressed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implKeyPressed(@pointer, *a); end
2029
+ def _abi_impl_text_entered(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implTextEntered(@pointer, *a); end
2030
+ def _abi_impl_scrolled(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implScrolled(@pointer, *a); end
2031
+ def _abi_impl_mouse_no_longer_on_widget(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implMouseNoLongerOnWidget(@pointer, *a); end
2032
+ def _abi_impl_left_mouse_button_no_longer_down(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implLeftMouseButtonNoLongerDown(@pointer, *a); end
2033
+ def _abi_impl_mouse_entered_widget(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implMouseEnteredWidget(@pointer, *a); end
2034
+ def _abi_impl_mouse_left_widget(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implMouseLeftWidget(@pointer, *a); end
2035
+ def _abi_impl_renderer_changed(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implRendererChanged(@pointer, *a); end
2036
+ def _abi_impl_draw_function(*a); Abi.call_arg_map! a; Abi.ABI_CustomWidget_implDrawFunction(@pointer, *a); end
2037
+ end
1963
2038
  end
@@ -41,7 +41,7 @@ editbox! do
41
41
  selected_text_background_color! 157, 185, 240
42
42
  end
43
43
 
44
- text_area! do
44
+ textarea! do
45
45
  background_color! 220
46
46
  default_text_color! 100
47
47
  caret_width! 2
@@ -59,6 +59,9 @@ combobox! do
59
59
  arrow_background_color_hover! 200
60
60
  end
61
61
 
62
+ label! do
63
+ end
64
+
62
65
  listbox! do
63
66
  background_color! 240
64
67
  background_color_hover! 220
@@ -76,6 +79,10 @@ menu! do
76
79
  separator_side_padding! 2
77
80
  end
78
81
 
82
+ panel! do
83
+ background_color! 235
84
+ end
85
+
79
86
  progressbar! do
80
87
  borders! 1
81
88
  end
@@ -17,8 +17,14 @@ class WhiteGold
17
17
  @frame_delay = 1.0 / fps
18
18
  end
19
19
 
20
- def init fps: nil, theme: nil
21
- @window = Window.new
20
+ def init fps: nil, theme: nil, window_size: nil, window_style: nil
21
+ eo = ExternObject.new pointer: nil, autofree: false # object for packing
22
+ if window_size == :fullscreen
23
+ window_style = :fullscreen
24
+ window_size = nil
25
+ end
26
+ window_size ||= [800, 600]
27
+ @window = Window.new *eo.abi_pack(Vector2u, *window_size), *eo.abi_pack(ExternObject::WindowStyle, *(window_style || :default))
22
28
  @gui = Gui.new window
23
29
  @preserved_pages = {}
24
30
  Theme.default = theme if theme
@@ -28,8 +34,8 @@ class WhiteGold
28
34
  @initialized = true
29
35
  end
30
36
 
31
- def run page = nil, fps: nil, theme: nil
32
- self.init fps: fps, theme: theme if !@initialized
37
+ def run page = nil, fps: nil, theme: nil, window_size: nil, window_style: nil
38
+ self.init fps: fps, theme: theme, window_size: window_size, window_style: window_style if !@initialized
33
39
  load_page page if page
34
40
 
35
41
  next_frame_time = Time.now
@@ -39,6 +45,8 @@ class WhiteGold
39
45
  if @current_page_id != @next_page_id
40
46
  if @current_page_id
41
47
  page = @preserved_pages[@current_page_id]
48
+ BangNestedCaller.pop
49
+ BangNestedCaller.close_scope page
42
50
  @gui.self_remove page
43
51
  page.disconnect
44
52
  @preserved_pages.delete(@current_page_id)
@@ -62,22 +70,23 @@ class WhiteGold
62
70
  when Class
63
71
  page = @preserved_pages[page_id] = page_id.new self
64
72
  init_page page
65
- page.send! do
66
- page.build
67
- end
73
+ page.build
68
74
  when Proc
69
75
  page = @preserved_pages[page_id] = Page.new self
70
76
  init_page page
71
- page_id.call
77
+ page.instance_eval &page_id
72
78
  end
73
79
  end
74
80
 
75
81
  def init_page page
76
82
  @gui.self_add page, "main_container"
83
+ @gui.page = page
77
84
  @current_page = page
78
85
  ExternObject.callback_storage = page.widget_callbacks
79
86
  ExternObject.global_callback_storage = page.global_callbacks
80
87
  ExternObject.data_storage = page.custom_data
88
+ BangNestedCaller.open_scope page
89
+ BangNestedCaller.push page
81
90
  end
82
91
 
83
92
  attr_accessor :next_page_id
@@ -99,6 +108,7 @@ class WhiteGold
99
108
  @repeat = repeat
100
109
  @job = b
101
110
  @result = NO_RESULT
111
+ @counter = 0
102
112
  self.run if run
103
113
  end
104
114
 
@@ -112,6 +122,7 @@ class WhiteGold
112
122
  def on_done &b
113
123
  @on_done = b
114
124
  b.(@result) if @thread && !@thread.alive?
125
+ self
115
126
  end
116
127
 
117
128
  def audit
@@ -121,6 +132,7 @@ class WhiteGold
121
132
  else
122
133
  @on_done.(@result) if @on_done
123
134
  if @repeat
135
+ @counter += 1
124
136
  run
125
137
  return true
126
138
  else
@@ -128,14 +140,22 @@ class WhiteGold
128
140
  end
129
141
  end
130
142
  else
131
- return true
143
+ return !!@job
132
144
  end
133
145
  end
134
146
 
135
147
  def finish result = NO_RESULT
136
- @repeat = false
148
+ @thread.kill
137
149
  @result = result if result != NO_RESULT
138
150
  end
151
+
152
+ attr :counter
153
+ attr_accessor :repeat
154
+
155
+ def cancel
156
+ @thread.kill
157
+ @thread = @job = nil
158
+ end
139
159
  end
140
160
 
141
161
  def job delay: nil, repeat: false, &b
@@ -0,0 +1,16 @@
1
+ class Array
2
+ def x
3
+ self[0]
4
+ end
5
+
6
+ def y
7
+ self[1]
8
+ end
9
+
10
+ alias_method :_insert, :[]=
11
+
12
+ def []=(*a)
13
+ a.size != 1 ? _insert(*a) : append(a[0])
14
+ return a.last
15
+ end
16
+ end