white_gold 0.0.4 → 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.
Files changed (40) 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/extern_object.rb +2 -2
  5. data/lib/white_gold/convention/container_widgets.rb +2 -2
  6. data/lib/white_gold/convention/page.rb +8 -4
  7. data/lib/white_gold/convention/theme/theme_attributed.rb +1 -1
  8. data/lib/white_gold/convention/theme/theme_component.rb +1 -1
  9. data/lib/white_gold/convention/widget_like.rb +1 -4
  10. data/lib/white_gold/dsl/backend_gui.rb +5 -4
  11. data/lib/white_gold/dsl/child_window.rb +1 -1
  12. data/lib/white_gold/dsl/color.rb +35 -27
  13. data/lib/white_gold/dsl/edit_box.rb +1 -2
  14. data/lib/white_gold/dsl/font.rb +4 -0
  15. data/lib/white_gold/dsl/gui.rb +5 -1
  16. data/lib/white_gold/dsl/label.rb +0 -2
  17. data/lib/white_gold/dsl/list_view.rb +6 -6
  18. data/lib/white_gold/dsl/outline.rb +4 -0
  19. data/lib/white_gold/dsl/picture.rb +0 -2
  20. data/lib/white_gold/dsl/radio_button.rb +1 -1
  21. data/lib/white_gold/dsl/sfml/shape.rb +3 -2
  22. data/lib/white_gold/dsl/sfml/text.rb +3 -1
  23. data/lib/white_gold/dsl/signal/signal_bool.rb +3 -3
  24. data/lib/white_gold/dsl/texture.rb +6 -1
  25. data/lib/white_gold/dsl/theme.rb +1 -2
  26. data/lib/white_gold/dsl/util.rb +3 -1
  27. data/lib/white_gold/dsl/widget.rb +10 -8
  28. data/lib/white_gold/dsl/window.rb +7 -4
  29. data/lib/white_gold/generated/tgui-abi-loader.gf.rb +30 -14
  30. data/lib/white_gold/master.rb +60 -47
  31. data/lib/white_gold/path/array.path.rb +0 -7
  32. data/lib/white_gold/path/object.path.rb +0 -6
  33. data/lib/white_gold/tgui-abi.rb +8 -13
  34. data/lib/white_gold/version.rb +1 -1
  35. data/lib/white_gold.rb +6 -6
  36. metadata +33 -8
  37. data/lib/white_gold/convention/bang_def.rb +0 -19
  38. data/lib/white_gold/convention/bang_nest.rb +0 -26
  39. data/lib/white_gold/convention/bang_nested_caller.rb +0 -81
  40. data/lib/white_gold/convention/proc_method_factory.rb +0 -22
@@ -3,14 +3,18 @@
3
3
 
4
4
  module Tgui
5
5
  module Abi
6
- extern 'void ABI_STATIC_Util_free(void* pointer)'
6
+ extern 'void ABI_STATIC_Util_deleteVector2f(Vector2f* vector)'
7
+ extern 'void ABI_STATIC_Util_deleteVector2i(Vector2i* vector)'
8
+ extern 'void ABI_STATIC_Util_deleteUIntRect(UIntRect* rect)'
7
9
  extern 'void* ABI_Color_new(int r, int g, int b, int a)'
10
+ extern 'void ABI_STATIC_Color_delete(Color* color)'
8
11
  extern 'int ABI_Color_get_red(Color* self)'
9
12
  extern 'int ABI_Color_get_green(Color* self)'
10
13
  extern 'int ABI_Color_get_blue(Color* self)'
11
14
  extern 'int ABI_Color_get_alpha(Color* self)'
12
15
  extern 'void* ABI_Color_applyOpacity(Color* self, float fade)'
13
16
  extern 'void* ABI_Outline_new(char* left, char* right, char* top, char* bottom)'
17
+ extern 'void ABI_STATIC_Outline_delete(Outline* outline)'
14
18
  extern 'float ABI_Outline_getLeft(Outline* self)'
15
19
  extern 'float ABI_Outline_getRight(Outline* self)'
16
20
  extern 'float ABI_Outline_getTop(Outline* self)'
@@ -37,6 +41,7 @@ module Tgui
37
41
  extern 'int ABI_SignalTypedSizeT_connect(SignalTypedSizeT* self, void(*f)(int))'
38
42
  extern 'int ABI_SignalPanelListBoxItem_connect(SignalPanelListBoxItem* self, void(*f)(const char32_t*))'
39
43
  extern 'void* ABI_Window_new(int width, int height, int style)'
44
+ extern 'void ABI_STATIC_Window_delete(sf::RenderWindow* self)'
40
45
  extern 'void ABI_Window_close(sf::WindowBase* self)'
41
46
  extern 'int ABI_Window_isOpen(sf::WindowBase* self)'
42
47
  extern 'void ABI_Window_setTitle(sf::WindowBase* self, char* title)'
@@ -68,9 +73,13 @@ module Tgui
68
73
  extern 'void ABI_BackendGui_setKeyboardNavigationEnabled(BackendGui* self, int enabled)'
69
74
  extern 'int ABI_BackendGui_isKeyboardNavigationEnabled(BackendGui* self)'
70
75
  extern 'void* ABI_BackendGui_onViewChange(BackendGui* self)'
76
+ extern 'void* ABI_BackendGui_onWindowFocus(BackendGui* self)'
77
+ extern 'void* ABI_BackendGui_onWindowUnfocus(BackendGui* self)'
71
78
  extern 'void* ABI_Font_new(char * id)'
79
+ extern 'void ABI_STATIC_Font_delete(Font* font)'
72
80
  extern 'void* ABI_STATIC_Font_getGlobalFont()'
73
81
  extern 'void* ABI_Gui_new(sf::RenderWindow* window)'
82
+ extern 'void ABI_STATIC_Gui_delete(Gui* self)'
74
83
  extern 'int ABI_Gui_isActive(Gui* self)'
75
84
  extern 'void ABI_Gui_pollEvents(Gui* self)'
76
85
  extern 'void ABI_Gui_draw(Gui* self)'
@@ -89,6 +98,7 @@ module Tgui
89
98
  extern 'void ABI_Theme_load(std::shared_ptr<Theme>* self, char* primary)'
90
99
  extern 'void* ABI_STATIC_Theme_getUnshared(std::shared_ptr<Theme>* pointer)'
91
100
  extern 'void* ABI_Texture_new(char* id, int partRectX, int partRectY, int partRectW, int partRectH, int middlePartX, int middlePartY, int middlePartW, int middlePartH, int smooth)'
101
+ extern 'void ABI_STATIC_Texture_delete(Texture* texture)'
92
102
  extern 'void* ABI_Texture_getId(Texture* self)'
93
103
  extern 'void* ABI_Texture_getImageSize(Texture* self)'
94
104
  extern 'void* ABI_Texture_getPartRect(Texture* self)'
@@ -150,6 +160,8 @@ module Tgui
150
160
  extern 'void ABI_Widget_setAutoLayout(Widget::Ptr* self, int autoLayout)'
151
161
  extern 'int ABI_Widget_getAutoLayout(Widget::Ptr* self)'
152
162
  extern 'void* ABI_Widget_getWidgetName(Widget::Ptr* self)'
163
+ extern 'void ABI_Widget_setIgnoreMouseEvents(Widget::Ptr* self, int ignore)'
164
+ extern 'int ABI_Widget_getIgnoreMouseEvents(Widget::Ptr* self)'
153
165
  extern 'void* ABI_Widget_onPositionChange(Widget::Ptr* self)'
154
166
  extern 'void* ABI_Widget_onSizeChange(Widget::Ptr* self)'
155
167
  extern 'void ABI_Widget_setColorRendererProperty(Widget::Ptr* self, char* property, Color* value)'
@@ -203,7 +215,7 @@ module Tgui
203
215
  extern 'unsigned int ABI_EditBox_getMaximumCharacters(EditBox::Ptr* self)'
204
216
  extern 'void ABI_EditBox_setAlignment(EditBox::Ptr* self, int alignment)'
205
217
  extern 'int ABI_EditBox_getAlignment(EditBox::Ptr* self)'
206
- extern 'void ABI_EditBox_limitTextWidth(EditBox::Ptr* self, int limit)'
218
+ extern 'void ABI_EditBox_setTextWidthLimited(EditBox::Ptr* self, int limit)'
207
219
  extern 'int ABI_EditBox_isTextWidthLimited(EditBox::Ptr* self)'
208
220
  extern 'void ABI_EditBox_setReadOnly(EditBox::Ptr* self, int read_only)'
209
221
  extern 'int ABI_EditBox_isReadOnly(EditBox::Ptr* self)'
@@ -230,8 +242,6 @@ module Tgui
230
242
  extern 'int ABI_Label_getAutoSize(Label::Ptr* self)'
231
243
  extern 'void ABI_Label_setMaximumTextWidth(Label::Ptr* self, float maximumWidth)'
232
244
  extern 'float ABI_Label_getMaximumTextWidth(Label::Ptr* self)'
233
- extern 'void ABI_Label_ignoreMouseEvents(Label::Ptr* self, int ignore)'
234
- extern 'int ABI_Label_ignoringMouseEvents(Label::Ptr* self)'
235
245
  extern 'void* ABI_RadioButton_new()'
236
246
  extern 'void ABI_RadioButton_setText(RadioButton::Ptr* self, char* text)'
237
247
  extern 'void* ABI_RadioButton_getText(RadioButton::Ptr* self)'
@@ -317,7 +327,7 @@ module Tgui
317
327
  extern 'void ABI_ChildWindow_setPositionLocked(ChildWindow::Ptr* self, int positionLocked)'
318
328
  extern 'int ABI_ChildWindow_isPositionLocked(ChildWindow::Ptr* self)'
319
329
  extern 'void ABI_ChildWindow_setKeepInParent(ChildWindow::Ptr* self, int enabled)'
320
- extern 'int ABI_ChildWindow_isKeptInParent(ChildWindow::Ptr* self)'
330
+ extern 'int ABI_ChildWindow_getKeepInParent(ChildWindow::Ptr* self)'
321
331
  extern 'void* ABI_ChildWindow_onMousePress(ChildWindow::Ptr* self)'
322
332
  extern 'void* ABI_ChildWindow_onClose(ChildWindow::Ptr* self)'
323
333
  extern 'void* ABI_ChildWindow_onMinimize(ChildWindow::Ptr* self)'
@@ -557,8 +567,6 @@ module Tgui
557
567
  extern 'int ABI_MessageBox_getButtonAlignment(MessageBox::Ptr* self)'
558
568
  extern 'void* ABI_MessageBox_onButtonPress(MessageBox::Ptr* self)'
559
569
  extern 'void* ABI_Picture_new(Texture* texture, int transparent)'
560
- extern 'void ABI_Picture_ignoreMouseEvents(Picture::Ptr* self, int ignore)'
561
- extern 'int ABI_Picture_isIgnoringMouseEvents(Picture::Ptr* self)'
562
570
  extern 'void* ABI_Picture_onDoubleClick(Picture::Ptr* self)'
563
571
  extern 'void* ABI_MenuBar_new()'
564
572
  extern 'void ABI_MenuBar_addMenu(MenuBar::Ptr* self, char* text)'
@@ -900,11 +908,14 @@ module Tgui
900
908
  end
901
909
 
902
910
  class Util
903
- def self._abi_free(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Util_free(*a); end
911
+ def self._abi_delete_vector2f(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Util_deleteVector2f(*a); end
912
+ def self._abi_delete_vector2i(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Util_deleteVector2i(*a); end
913
+ def self._abi_delete_u_int_rect(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Util_deleteUIntRect(*a); end
904
914
  end
905
915
 
906
916
  class Color
907
917
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Color_new(*a)); end
918
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Color_delete(*a); end
908
919
  def _abi_get_red(*a); Abi.call_arg_map! a; Abi.ABI_Color_get_red(@pointer, *a); end
909
920
  def _abi_get_green(*a); Abi.call_arg_map! a; Abi.ABI_Color_get_green(@pointer, *a); end
910
921
  def _abi_get_blue(*a); Abi.call_arg_map! a; Abi.ABI_Color_get_blue(@pointer, *a); end
@@ -914,6 +925,7 @@ module Tgui
914
925
 
915
926
  class Outline
916
927
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Outline_new(*a)); end
928
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Outline_delete(*a); end
917
929
  def _abi_get_left(*a); Abi.call_arg_map! a; Abi.ABI_Outline_getLeft(@pointer, *a); end
918
930
  def _abi_get_right(*a); Abi.call_arg_map! a; Abi.ABI_Outline_getRight(@pointer, *a); end
919
931
  def _abi_get_top(*a); Abi.call_arg_map! a; Abi.ABI_Outline_getTop(@pointer, *a); end
@@ -994,6 +1006,7 @@ module Tgui
994
1006
 
995
1007
  class Window
996
1008
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Window_new(*a)); end
1009
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Window_delete(*a); end
997
1010
  def _abi_close(*a); Abi.call_arg_map! a; Abi.ABI_Window_close(@pointer, *a); end
998
1011
  def _abi_is_open(*a); Abi.call_arg_map! a; Abi.ABI_Window_isOpen(@pointer, *a); end
999
1012
  def _abi_set_title(*a); Abi.call_arg_map! a; Abi.ABI_Window_setTitle(@pointer, *a); end
@@ -1028,15 +1041,19 @@ module Tgui
1028
1041
  def _abi_set_keyboard_navigation_enabled(*a); Abi.call_arg_map! a; Abi.ABI_BackendGui_setKeyboardNavigationEnabled(@pointer, *a); end
1029
1042
  def _abi_is_keyboard_navigation_enabled(*a); Abi.call_arg_map! a; Abi.ABI_BackendGui_isKeyboardNavigationEnabled(@pointer, *a); end
1030
1043
  def _abi_on_view_change(*a); Abi.call_arg_map! a; Abi.ABI_BackendGui_onViewChange(@pointer, *a); end
1044
+ def _abi_on_window_focus(*a); Abi.call_arg_map! a; Abi.ABI_BackendGui_onWindowFocus(@pointer, *a); end
1045
+ def _abi_on_window_unfocus(*a); Abi.call_arg_map! a; Abi.ABI_BackendGui_onWindowUnfocus(@pointer, *a); end
1031
1046
  end
1032
1047
 
1033
1048
  class Font
1034
1049
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Font_new(*a)); end
1050
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Font_delete(*a); end
1035
1051
  def self._abi_get_global_font(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Font_getGlobalFont(*a); end
1036
1052
  end
1037
1053
 
1038
1054
  class Gui
1039
1055
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Gui_new(*a)); end
1056
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Gui_delete(*a); end
1040
1057
  def _abi_is_active(*a); Abi.call_arg_map! a; Abi.ABI_Gui_isActive(@pointer, *a); end
1041
1058
  def _abi_poll_events(*a); Abi.call_arg_map! a; Abi.ABI_Gui_pollEvents(@pointer, *a); end
1042
1059
  def _abi_draw(*a); Abi.call_arg_map! a; Abi.ABI_Gui_draw(@pointer, *a); end
@@ -1061,6 +1078,7 @@ module Tgui
1061
1078
 
1062
1079
  class Texture
1063
1080
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Texture_new(*a)); end
1081
+ def self._abi_delete(*a); Abi.call_arg_map! a; Abi.ABI_STATIC_Texture_delete(*a); end
1064
1082
  def _abi_get_id(*a); Abi.call_arg_map! a; Abi.ABI_Texture_getId(@pointer, *a); end
1065
1083
  def _abi_get_image_size(*a); Abi.call_arg_map! a; Abi.ABI_Texture_getImageSize(@pointer, *a); end
1066
1084
  def _abi_get_part_rect(*a); Abi.call_arg_map! a; Abi.ABI_Texture_getPartRect(@pointer, *a); end
@@ -1125,6 +1143,8 @@ module Tgui
1125
1143
  def _abi_set_auto_layout(*a); Abi.call_arg_map! a; Abi.ABI_Widget_setAutoLayout(@pointer, *a); end
1126
1144
  def _abi_get_auto_layout(*a); Abi.call_arg_map! a; Abi.ABI_Widget_getAutoLayout(@pointer, *a); end
1127
1145
  def _abi_get_widget_name(*a); Abi.call_arg_map! a; Abi.ABI_Widget_getWidgetName(@pointer, *a); end
1146
+ def _abi_set_ignore_mouse_events(*a); Abi.call_arg_map! a; Abi.ABI_Widget_setIgnoreMouseEvents(@pointer, *a); end
1147
+ def _abi_get_ignore_mouse_events(*a); Abi.call_arg_map! a; Abi.ABI_Widget_getIgnoreMouseEvents(@pointer, *a); end
1128
1148
  def _abi_on_position_change(*a); Abi.call_arg_map! a; Abi.ABI_Widget_onPositionChange(@pointer, *a); end
1129
1149
  def _abi_on_size_change(*a); Abi.call_arg_map! a; Abi.ABI_Widget_onSizeChange(@pointer, *a); end
1130
1150
  def _abi_set_color_renderer_property(*a); Abi.call_arg_map! a; Abi.ABI_Widget_setColorRendererProperty(@pointer, *a); end
@@ -1193,7 +1213,7 @@ module Tgui
1193
1213
  def _abi_get_maximum_characters(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_getMaximumCharacters(@pointer, *a); end
1194
1214
  def _abi_set_alignment(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_setAlignment(@pointer, *a); end
1195
1215
  def _abi_get_alignment(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_getAlignment(@pointer, *a); end
1196
- def _abi_limit_text_width(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_limitTextWidth(@pointer, *a); end
1216
+ def _abi_set_text_width_limited(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_setTextWidthLimited(@pointer, *a); end
1197
1217
  def _abi_is_text_width_limited(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_isTextWidthLimited(@pointer, *a); end
1198
1218
  def _abi_set_read_only(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_setReadOnly(@pointer, *a); end
1199
1219
  def _abi_is_read_only(*a); Abi.call_arg_map! a; Abi.ABI_EditBox_isReadOnly(@pointer, *a); end
@@ -1223,8 +1243,6 @@ module Tgui
1223
1243
  def _abi_get_auto_size(*a); Abi.call_arg_map! a; Abi.ABI_Label_getAutoSize(@pointer, *a); end
1224
1244
  def _abi_set_maximum_text_width(*a); Abi.call_arg_map! a; Abi.ABI_Label_setMaximumTextWidth(@pointer, *a); end
1225
1245
  def _abi_get_maximum_text_width(*a); Abi.call_arg_map! a; Abi.ABI_Label_getMaximumTextWidth(@pointer, *a); end
1226
- def _abi_ignore_mouse_events(*a); Abi.call_arg_map! a; Abi.ABI_Label_ignoreMouseEvents(@pointer, *a); end
1227
- def _abi_ignoring_mouse_events(*a); Abi.call_arg_map! a; Abi.ABI_Label_ignoringMouseEvents(@pointer, *a); end
1228
1246
  end
1229
1247
 
1230
1248
  class RadioButton
@@ -1328,7 +1346,7 @@ module Tgui
1328
1346
  def _abi_set_position_locked(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_setPositionLocked(@pointer, *a); end
1329
1347
  def _abi_is_position_locked(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_isPositionLocked(@pointer, *a); end
1330
1348
  def _abi_set_keep_in_parent(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_setKeepInParent(@pointer, *a); end
1331
- def _abi_is_kept_in_parent(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_isKeptInParent(@pointer, *a); end
1349
+ def _abi_get_keep_in_parent(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_getKeepInParent(@pointer, *a); end
1332
1350
  def _abi_on_mouse_press(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_onMousePress(@pointer, *a); end
1333
1351
  def _abi_on_close(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_onClose(@pointer, *a); end
1334
1352
  def _abi_on_minimize(*a); Abi.call_arg_map! a; Abi.ABI_ChildWindow_onMinimize(@pointer, *a); end
@@ -1619,8 +1637,6 @@ module Tgui
1619
1637
 
1620
1638
  class Picture
1621
1639
  def initialize(*a, pointer: nil); Abi.call_arg_map! a; super(pointer: pointer || Abi.ABI_Picture_new(*a)); end
1622
- def _abi_ignore_mouse_events(*a); Abi.call_arg_map! a; Abi.ABI_Picture_ignoreMouseEvents(@pointer, *a); end
1623
- def _abi_is_ignoring_mouse_events(*a); Abi.call_arg_map! a; Abi.ABI_Picture_isIgnoringMouseEvents(@pointer, *a); end
1624
1640
  def _abi_on_double_click(*a); Abi.call_arg_map! a; Abi.ABI_Picture_onDoubleClick(@pointer, *a); end
1625
1641
  end
1626
1642
 
@@ -1,3 +1,5 @@
1
+ require 'extree'
2
+ require 'procify'
1
3
  require_relative 'convention/boolean'
2
4
  require_relative 'path/kernel.path'
3
5
  require_relative 'path/numeric.path'
@@ -9,10 +11,6 @@ require_relative 'convention/page'
9
11
  class WhiteGold
10
12
  include Tgui
11
13
 
12
- def [](method_name)
13
- method(method_name)
14
- end
15
-
16
14
  def fps=(fps)
17
15
  @frame_delay = 1.0 / fps
18
16
  end
@@ -24,7 +22,7 @@ class WhiteGold
24
22
  window_size = nil
25
23
  end
26
24
  window_size ||= [800, 600]
27
- @window = Window.new *eo.abi_pack(Vector2u, *window_size), *eo.abi_pack(ExternObject::WindowStyle, *(window_style || :default))
25
+ @window = Window.new *eo.abi_pack(Vector2i, *window_size), *eo.abi_pack(ExternObject::WindowStyle, *(window_style || :default))
28
26
  @gui = Gui.new window
29
27
  @preserved_pages = {}
30
28
  Theme.default = theme if theme
@@ -45,8 +43,8 @@ class WhiteGold
45
43
  if @current_page_id != @next_page_id
46
44
  if @current_page_id
47
45
  page = @preserved_pages[@current_page_id]
48
- BangNestedCaller.pop
49
- BangNestedCaller.close_scope page
46
+ Extree::Seed.pop
47
+ Extree::Seed.close_scope page
50
48
  @gui.self_remove page
51
49
  page.disconnect
52
50
  @preserved_pages.delete(@current_page_id)
@@ -85,8 +83,8 @@ class WhiteGold
85
83
  ExternObject.callback_storage = page.widget_callbacks
86
84
  ExternObject.global_callback_storage = page.global_callbacks
87
85
  ExternObject.data_storage = page.custom_data
88
- BangNestedCaller.open_scope page
89
- BangNestedCaller.push page
86
+ Extree::Seed.open_scope page
87
+ Extree::Seed.push page
90
88
  end
91
89
 
92
90
  attr_accessor :next_page_id
@@ -101,71 +99,86 @@ class WhiteGold
101
99
  end
102
100
 
103
101
  class Job
104
- NO_RESULT = Object.new
105
102
 
106
- def initialize delay:, repeat:, run: true, &b
107
- @delay = delay
103
+ def initialize repeat:, run: true, &b
104
+ @queue = Thread::Queue.new
105
+ @mutex = Thread::Mutex.new
108
106
  @repeat = repeat
109
107
  @job = b
110
- @result = NO_RESULT
111
- @counter = 0
112
108
  self.run if run
113
109
  end
114
110
 
115
111
  def run
116
- @thread = Thread.new do
117
- sleep(@delay / 1000.0) if @delay
118
- @result = @job.(self)
112
+ if !@thread || !@thread.alive?
113
+ @thread = Thread.new do
114
+ loop do
115
+ last_spin = false
116
+ @mutex.synchronize do
117
+ last_spin = !@repeat
118
+ end
119
+ @job.call self
120
+ break if last_spin
121
+ end
122
+ end
119
123
  end
120
124
  end
121
125
 
122
- def on_done &b
123
- @on_done = b
124
- b.(@result) if @thread && !@thread.alive?
126
+ def tip &b
127
+ @tip = b
128
+ b.(self) if @thread && !@thread.alive?
125
129
  self
126
130
  end
127
131
 
128
132
  def audit
129
- if @thread
130
- if @thread.alive?
131
- return true
132
- else
133
- @on_done.(@result) if @on_done
134
- if @repeat
135
- @counter += 1
136
- run
137
- return true
138
- else
139
- return false
140
- end
141
- end
142
- else
143
- return !!@job
144
- end
133
+ @tip&.call @queue.pop, self if !@queue.empty?
134
+ @thread ? @thread.alive? : !!@job
145
135
  end
146
136
 
147
- def finish result = NO_RESULT
148
- @thread.kill
149
- @result = result if result != NO_RESULT
137
+ attr_accessor :queue
138
+ attr :repeat
139
+
140
+ def <<(value)
141
+ @queue << value
142
+ self
150
143
  end
151
144
 
152
- attr :counter
153
- attr_accessor :repeat
145
+ def repeat=(repeat)
146
+ @mutex.synchronize do
147
+ @repeat = repeat
148
+ end
149
+ end
154
150
 
155
151
  def cancel
156
- @thread.kill
152
+ @thread&.kill
157
153
  @thread = @job = nil
158
154
  end
159
155
  end
160
156
 
161
- def job delay: nil, repeat: false, &b
162
- job = Job.new delay:, repeat:, &b
157
+ def job repeat: false, run: true, &b
158
+ job = Job.new repeat:, run:, &b
163
159
  @jobs << job
164
160
  job
165
161
  end
166
162
 
167
- def timer delay_ = nil, delay: nil, repeat: false, &b
168
- job delay: delay || delay_, repeat: do
169
- end.on_done &b
163
+ def after delay = nil, run: true, &b
164
+ if delay
165
+ job run: do |j|
166
+ sleep(delay / 1000.0)
167
+ j.queue << nil
168
+ end.tip &b
169
+ else
170
+ job(run: false).tip(&b).tap{ _1.queue << nil }
171
+ end
172
+ end
173
+
174
+ def timer target_pulse_time, run: true, &b
175
+ nms = nil
176
+ target_pulse_time /= 1000.0 # ms => s
177
+ job repeat: true, run: do |j|
178
+ ms = Time.now
179
+ nms = (nms || ms) + target_pulse_time
180
+ j.queue << ms if j.queue.empty?
181
+ sleep(nms - ms) if nms > ms
182
+ end.tip &b
170
183
  end
171
184
  end
@@ -6,11 +6,4 @@ class Array
6
6
  def y
7
7
  self[1]
8
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
9
  end
@@ -1,11 +1,5 @@
1
- require_relative '../convention/proc_method_factory'
2
-
3
1
  class Object
4
2
  def behalf client, &todo
5
3
  client.instance_exec self, client, &todo
6
4
  end
7
-
8
- def proc &block
9
- block_given? ? Kernel.proc(&block) : ProcMethodFactory.new(self)
10
- end
11
5
  end
@@ -29,7 +29,7 @@ module Tgui
29
29
  'float y'
30
30
  ]
31
31
 
32
- Vector2u = struct [
32
+ Vector2i = struct [
33
33
  'int x',
34
34
  'int y'
35
35
  ]
@@ -43,7 +43,7 @@ module Tgui
43
43
  end
44
44
 
45
45
  Vector2f = Abi::Vector2f
46
- Vector2u = Abi::Vector2u
46
+ Vector2i = Abi::Vector2i
47
47
  UIntRect = Abi::UIntRect
48
48
  end
49
49
 
@@ -85,11 +85,6 @@ require_relative 'convention/container_widgets'
85
85
  require_relative 'convention/theme_attributes'
86
86
 
87
87
  class ExternObject
88
- class << self
89
- def finalizer pointer
90
- Tgui::Util.free(pointer)
91
- end
92
- end
93
88
 
94
89
  abi_packer Object do |o|
95
90
  o = o.first if o.is_a? Array
@@ -178,7 +173,7 @@ class ExternObject
178
173
  [abi_pack_float(x), abi_pack_float(y)]
179
174
  end
180
175
 
181
- abi_packer Tgui::Abi::Vector2u do |*arg|
176
+ abi_packer Tgui::Abi::Vector2i do |*arg|
182
177
  case arg.size
183
178
  when 1
184
179
  a = arg.first
@@ -234,7 +229,7 @@ class ExternObject
234
229
  vector2f_unpacker = proc do |o|
235
230
  v = Tgui::Vector2f.new o
236
231
  r = [v.x, v.y]
237
- Tgui::Util.free(o)
232
+ Tgui::Util.delete_vector2f(o)
238
233
  r
239
234
  end
240
235
 
@@ -244,17 +239,17 @@ class ExternObject
244
239
 
245
240
  abi_unpacker Tgui::Vector2f, &vector2f_unpacker
246
241
 
247
- abi_unpacker Tgui::Vector2u do |o|
248
- v = Tgui::Vector2u.new o
242
+ abi_unpacker Tgui::Vector2i do |o|
243
+ v = Tgui::Vector2i.new o
249
244
  r = [v.x, v.y]
250
- Tgui::Util.free(o)
245
+ Tgui::Util.delete_vector2i(o)
251
246
  r
252
247
  end
253
248
 
254
249
  abi_unpacker Tgui::UIntRect do |o|
255
250
  v = Tgui::UIntRect.new o
256
251
  r = [v.left, v.top, v.width, v.height]
257
- Tgui::Util.free(o)
252
+ Tgui::Util.delete_u_int_rect(o)
258
253
  r
259
254
  end
260
255
 
@@ -1,3 +1,3 @@
1
1
  class WhiteGold
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/white_gold.rb CHANGED
@@ -5,8 +5,7 @@ include Tgui
5
5
  @white_gold_instance = WhiteGold.new
6
6
 
7
7
  class << self
8
- include BangNestedCaller
9
- include BangDef
8
+ include Extree
10
9
 
11
10
  def go page
12
11
  @white_gold_instance.go page.is_a?(Symbol) ? proc{ send(page) } : page
@@ -18,19 +17,20 @@ class << self
18
17
 
19
18
  def respond_to? name
20
19
  super ||
21
- (name.end_with?("!") && bang_respond_to?(name[...-1])) ||
20
+ (name.end_with?("!") && extree_respond_to?(name[...-1])) ||
22
21
  @white_gold_instance.page.respond_to?(name)
23
22
  end
24
23
 
25
24
  def method_missing name, *a, **na, &b
26
25
  if name.end_with? "!"
27
- bang_method_missing name[...-1], *a, **na, &b
26
+ extree_method_missing name[...-1], *a, **na, &b
28
27
  elsif @white_gold_instance.page.respond_to? name
29
28
  @white_gold_instance.page.send name, *a, **na, &b
30
29
  else super
31
30
  end
32
31
  end
33
32
  end
33
+ extend Extree::Branch
34
34
 
35
35
  def! :run do |page = nil|
36
36
  go page if page
@@ -46,5 +46,5 @@ if $0 != 'irb'
46
46
  end
47
47
  end
48
48
 
49
- BangNestedCaller.open_scope self
50
- BangNestedCaller.push self
49
+ Extree::Seed.open_scope self
50
+ Extree::Seed.push self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: white_gold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Łukasz Pomietło
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-29 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle
@@ -24,10 +24,38 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: extree
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: procify
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
27
55
  description: |2
28
56
  Ruby gem for building pure ruby graphical user interface.
29
57
  Uses TGUI & SFML as a backend.
30
- Dedicated to creating single-file applications and learning programming.
58
+ Dedicated to creating simple applications and learning programming.
31
59
  email: oficjalnyadreslukasza@gmail.com
32
60
  executables: []
33
61
  extensions: []
@@ -57,15 +85,11 @@ files:
57
85
  - lib/white_gold/abi/packer.rb
58
86
  - lib/white_gold/abi/unpacker.rb
59
87
  - lib/white_gold/convention/api_child.rb
60
- - lib/white_gold/convention/bang_def.rb
61
- - lib/white_gold/convention/bang_nest.rb
62
- - lib/white_gold/convention/bang_nested_caller.rb
63
88
  - lib/white_gold/convention/bool_property.rb
64
89
  - lib/white_gold/convention/boolean.rb
65
90
  - lib/white_gold/convention/club.rb
66
91
  - lib/white_gold/convention/container_widgets.rb
67
92
  - lib/white_gold/convention/page.rb
68
- - lib/white_gold/convention/proc_method_factory.rb
69
93
  - lib/white_gold/convention/theme/boolean_attribute.rb
70
94
  - lib/white_gold/convention/theme/color_attribute.rb
71
95
  - lib/white_gold/convention/theme/float_attribute.rb
@@ -177,6 +201,7 @@ licenses:
177
201
  - Zlib
178
202
  metadata:
179
203
  documentation_uri: https://github.com/lpogic/white_gold/blob/master/doc/wiki/README.md
204
+ homepage_uri: https://github.com/lpogic/white_gold
180
205
  post_install_message:
181
206
  rdoc_options: []
182
207
  require_paths:
@@ -192,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
217
  - !ruby/object:Gem::Version
193
218
  version: '0'
194
219
  requirements: []
195
- rubygems_version: 3.4.22
220
+ rubygems_version: 3.5.6
196
221
  signing_key:
197
222
  specification_version: 4
198
223
  summary: TGUI based Ruby gem for quick native application developing
@@ -1,19 +0,0 @@
1
- require_relative 'bang_nested_caller'
2
-
3
- module BangDef
4
- def def! name, &b
5
- define_method "api_bang_#{name}", &b
6
- end
7
-
8
- @@redef_index = 0
9
-
10
- def redef! name, &b
11
- @@redef_index = index = @@redef_index.next
12
- old = "api_bang_#{index}_#{name}"
13
- news = "api_bang_#{name}"
14
- alias_method old, news
15
- define_method news do |*a, **na, &bl|
16
- b.call old, *a, **na, &bl
17
- end
18
- end
19
- end
@@ -1,26 +0,0 @@
1
- require_relative 'bang_nested_caller'
2
-
3
- module BangNest
4
- include BangNestedCaller
5
-
6
- def respond_to? name
7
- super || (name.end_with?("!") && bang_respond_to?(name[...-1]))
8
- end
9
-
10
- def method_missing name, *a, **na, &b
11
- if name.end_with? "!"
12
- bang_method_missing name[...-1], *a, **na, &b
13
- else super
14
- end
15
- end
16
-
17
- def host! *a, **na, &b
18
- a.each do |k|
19
- send("#{k}=", true)
20
- end
21
- na.each do |k, v|
22
- send("#{k}=", v)
23
- end
24
- super(&b)
25
- end
26
- end