white_gold 0.0.2 → 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 (79) 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/extern_object.rb +6 -1
  6. data/lib/white_gold/abi/interface/interface.rb +3 -7
  7. data/lib/white_gold/abi/unpacker.rb +4 -2
  8. data/lib/white_gold/convention/bang_def.rb +14 -0
  9. data/lib/white_gold/convention/bang_nest.rb +12 -2
  10. data/lib/white_gold/convention/bang_nested_caller.rb +65 -32
  11. data/lib/white_gold/convention/container_widgets.rb +61 -96
  12. data/lib/white_gold/convention/page.rb +28 -4
  13. data/lib/white_gold/convention/theme/boolean_attribute.rb +11 -9
  14. data/lib/white_gold/convention/theme/color_attribute.rb +11 -9
  15. data/lib/white_gold/convention/theme/float_attribute.rb +11 -9
  16. data/lib/white_gold/convention/theme/outline_attribute.rb +11 -9
  17. data/lib/white_gold/convention/theme/text_styles_attribute.rb +16 -9
  18. data/lib/white_gold/convention/theme/texture_attribute.rb +14 -12
  19. data/lib/white_gold/convention/theme/theme_attributed.rb +1 -1
  20. data/lib/white_gold/convention/theme/theme_component.rb +1 -1
  21. data/lib/white_gold/convention/theme_attributes.rb +6 -2
  22. data/lib/white_gold/convention/tree_node.rb +43 -0
  23. data/lib/white_gold/convention/widget/keyboard_control.rb +30 -0
  24. data/lib/white_gold/convention/widget_class_aliases.rb +24 -0
  25. data/lib/white_gold/convention/widget_like.rb +0 -6
  26. data/lib/white_gold/dsl/backend_gui.rb +1 -0
  27. data/lib/white_gold/dsl/canvas.rb +40 -0
  28. data/lib/white_gold/dsl/chat_box.rb +1 -1
  29. data/lib/white_gold/dsl/child_window.rb +1 -1
  30. data/lib/white_gold/dsl/color.rb +9 -4
  31. data/lib/white_gold/dsl/combo_box.rb +2 -2
  32. data/lib/white_gold/dsl/container.rb +18 -12
  33. data/lib/white_gold/dsl/custom_widget.rb +28 -0
  34. data/lib/white_gold/dsl/font.rb +5 -1
  35. data/lib/white_gold/dsl/grid.rb +37 -13
  36. data/lib/white_gold/dsl/gui.rb +10 -1
  37. data/lib/white_gold/dsl/label.rb +3 -0
  38. data/lib/white_gold/dsl/list_box.rb +7 -11
  39. data/lib/white_gold/dsl/list_view.rb +6 -6
  40. data/lib/white_gold/dsl/menu_bar.rb +5 -48
  41. data/lib/white_gold/dsl/message_box.rb +3 -3
  42. data/lib/white_gold/dsl/panel.rb +8 -0
  43. data/lib/white_gold/dsl/panel_list_box.rb +12 -3
  44. data/lib/white_gold/dsl/radio_button.rb +15 -2
  45. data/lib/white_gold/dsl/scrollable_panel.rb +7 -0
  46. data/lib/white_gold/dsl/sfml/circle_shape.rb +11 -0
  47. data/lib/white_gold/dsl/sfml/convex_shape.rb +19 -0
  48. data/lib/white_gold/dsl/sfml/rectangle_shape.rb +11 -0
  49. data/lib/white_gold/dsl/sfml/shape.rb +19 -0
  50. data/lib/white_gold/dsl/sfml/text.rb +26 -0
  51. data/lib/white_gold/dsl/signal/global_signal.rb +1 -1
  52. data/lib/white_gold/dsl/signal/signal.rb +1 -1
  53. data/lib/white_gold/dsl/signal/signal_animation_type.rb +1 -1
  54. data/lib/white_gold/dsl/signal/signal_bool.rb +1 -1
  55. data/lib/white_gold/dsl/signal/signal_color.rb +1 -1
  56. data/lib/white_gold/dsl/signal/signal_float.rb +1 -1
  57. data/lib/white_gold/dsl/signal/signal_int.rb +1 -1
  58. data/lib/white_gold/dsl/signal/signal_pointer.rb +1 -1
  59. data/lib/white_gold/dsl/signal/signal_range.rb +1 -1
  60. data/lib/white_gold/dsl/signal/signal_show_effect.rb +1 -1
  61. data/lib/white_gold/dsl/signal/signal_string.rb +1 -1
  62. data/lib/white_gold/dsl/signal/signal_u_int.rb +1 -1
  63. data/lib/white_gold/dsl/signal/signal_vector2f.rb +1 -1
  64. data/lib/white_gold/dsl/tab_container.rb +2 -2
  65. data/lib/white_gold/dsl/tabs.rb +2 -2
  66. data/lib/white_gold/dsl/theme.rb +2 -2
  67. data/lib/white_gold/dsl/toggle_button.rb +3 -0
  68. data/lib/white_gold/dsl/tree_view.rb +21 -33
  69. data/lib/white_gold/dsl/widget.rb +112 -49
  70. data/lib/white_gold/dsl/window.rb +7 -0
  71. data/lib/white_gold/generated/tgui-abi-loader.gf.rb +273 -48
  72. data/lib/white_gold/library/theme/light.rb +8 -1
  73. data/lib/white_gold/master.rb +43 -42
  74. data/lib/white_gold/path/array.path.rb +16 -0
  75. data/lib/white_gold/tgui-abi.rb +48 -38
  76. data/lib/white_gold/version.rb +3 -0
  77. data/lib/white_gold.rb +31 -28
  78. metadata +20 -6
  79. data/lib/white_gold/abi/reducer.rb +0 -12
@@ -1,4 +1,5 @@
1
1
  require_relative 'widget'
2
+ require_relative '../convention/tree_node'
2
3
  require_relative '../convention/widget_like'
3
4
  require_relative 'signal/signal_item_hierarchy'
4
5
 
@@ -29,7 +30,7 @@ module Tgui
29
30
 
30
31
  def connect &b
31
32
  on_press = Fiddle::Closure::BlockCaller.new(0, [0]) do
32
- @menu_bar.page.upon! @menu_bar do
33
+ @menu_bar.host! do
33
34
  b.(@path.last, @path, @menu_bar)
34
35
  end
35
36
  end
@@ -56,57 +57,13 @@ module Tgui
56
57
  end
57
58
  SignalItemHierarchy.fetch_path vector, loader
58
59
  object_path = @widget.self_object_path path
59
- @widget.page.upon! @widget do
60
+ @widget.host! do
60
61
  b.(object_path.last, object_path, @widget)
61
62
  end
62
63
  end
63
64
  end
64
65
  end
65
66
 
66
- class TreeNode
67
- def initialize text
68
- @text = text
69
- @nodes = {}
70
- end
71
-
72
- attr_accessor :text
73
- attr :nodes
74
-
75
- def [](*path, grow: false)
76
- if grow
77
- path.reduce(self){|node, o| node.nodes[o] ||= TreeNode.new(nil) }
78
- else
79
- path.reduce(self){|node, o| node&.nodes[o] }
80
- end
81
- end
82
-
83
- def cut *path, last
84
- self[*path].nodes.delete last
85
- end
86
-
87
- def cut_branches *path
88
- self[*path].nodes = {}
89
- end
90
-
91
- def path_str_to_object *path
92
- object_path = []
93
- path.reduce self do |node, str|
94
- o, node = *node.nodes.find{|k, v| v.text == str }
95
- object_path << o
96
- node
97
- end
98
- object_path
99
- end
100
-
101
- def path_object_to_str *path
102
- str_path = []
103
- path.reduce self do |node, o|
104
- node[o].tap{ str_path << _1.text }
105
- end
106
- str_path
107
- end
108
- end
109
-
110
67
  api_attr :self_tree do
111
68
  TreeNode.new nil
112
69
  end
@@ -122,7 +79,7 @@ module Tgui
122
79
  host._abi_add_menu_item _1, _2
123
80
  end
124
81
  item = Item.new host, item_path
125
- upon! item, **na, &b
82
+ scope! item, **na, &b
126
83
  end
127
84
 
128
85
  def! :separator do
@@ -208,7 +165,7 @@ module Tgui
208
165
  self_tree[object, grow: true].text = text
209
166
  _abi_add_menu abi_pack_string(text)
210
167
  item = Menu.new self, object
211
- upon! item, **na, &b
168
+ scope! item, **na, &b
212
169
  end
213
170
 
214
171
  def items=(items)
@@ -37,7 +37,7 @@ module Tgui
37
37
  end
38
38
 
39
39
  def press_signal_execute
40
- host.page.upon! host do
40
+ host.host! do
41
41
  @on_press_callbacks.each do |c|
42
42
  c.(id, self, host)
43
43
  end
@@ -52,7 +52,7 @@ module Tgui
52
52
  _abi_add_button abi_pack_string(text)
53
53
  button = Button.new self, object
54
54
  self_buttons[text] = button
55
- upon! button, **na, &b
55
+ scope! button, **na, &b
56
56
  end
57
57
 
58
58
  def [](object)
@@ -73,7 +73,7 @@ module Tgui
73
73
  self_buttons[text] = button
74
74
  text
75
75
  end
76
- self_change_buttons names
76
+ self_change_buttons *names
77
77
  end
78
78
 
79
79
  def buttons
@@ -4,6 +4,14 @@ require_relative 'signal/signal_vector2f'
4
4
  module Tgui
5
5
  class Panel < Group
6
6
 
7
+ class Theme < Group::Theme
8
+ theme_attr :borders, :outline
9
+ theme_attr :border_color, :color
10
+ theme_attr :background_color, :color
11
+ theme_attr :texture_background, :texture
12
+ theme_attr :rounded_border_radius, :float
13
+ end
14
+
7
15
  abi_signal :on_mouse_press, SignalVector2f
8
16
  abi_signal :on_mouse_release, SignalVector2f
9
17
  abi_signal :on_click, SignalVector2f
@@ -5,10 +5,19 @@ require_relative 'signal/signal_panel_list_box_item'
5
5
  module Tgui
6
6
  class PanelListBox < ScrollablePanel
7
7
 
8
+ class Theme < ScrollablePanel::Theme
9
+
10
+ theme_attr :items_background_color, :color
11
+ theme_attr :items_background_color_hover, :color
12
+ theme_attr :selected_items_background_color, :color
13
+ theme_attr :selected_items_background_color_hover, :color
14
+
15
+ end
16
+
8
17
  class SignalPanelListBoxItem < Tgui::SignalPanelListBoxItem
9
18
  def block_caller &b
10
19
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |id|
11
- @widget.page.upon! @widget do
20
+ @widget.host! do
12
21
  b.(@widget.self_objects.key(@widget.abi_unpack_string(id)), @widget)
13
22
  end
14
23
  end
@@ -22,7 +31,7 @@ module Tgui
22
31
  panel = Panel.new pointer: _abi_add_item(id, abi_pack_integer(index))
23
32
  panel.page = page
24
33
  self_objects[object] = id
25
- upon! panel, **na, &b
34
+ scope! panel, **na, &b
26
35
  end
27
36
 
28
37
  def [](object)
@@ -71,7 +80,7 @@ module Tgui
71
80
  def! :template do |**na, &b|
72
81
  panel = Panel.new(pointer: _abi_get_panel_template)
73
82
  panel.page = page
74
- upon! panel, **na, &b
83
+ scope! panel, **na, &b
75
84
  end
76
85
 
77
86
  # internal
@@ -28,6 +28,10 @@ module Tgui
28
28
  theme_attr :text_style, :text_styles
29
29
  theme_attr :text_style_checked, :text_styles
30
30
  end
31
+
32
+ api_attr :format do
33
+ :to_s
34
+ end
31
35
 
32
36
  abi_attr :checked?
33
37
  abi_attr :text, String
@@ -35,9 +39,18 @@ module Tgui
35
39
  abi_signal :on_check, Signal
36
40
  abi_signal :on_uncheck, Signal
37
41
  abi_signal :on_change, SignalBoolean
38
- api_attr :object do
42
+
43
+ def object
44
+ self_object
45
+ end
46
+
47
+ def object=(object)
48
+ self.self_object = object
49
+ self.text = object.then(&format)
50
+ end
51
+
52
+ api_attr :self_object do
39
53
  nil
40
54
  end
41
-
42
55
  end
43
56
  end
@@ -5,6 +5,13 @@ require_relative 'scrollbar'
5
5
  module Tgui
6
6
  class ScrollablePanel < Panel
7
7
 
8
+ class Theme < Panel::Theme
9
+
10
+ theme_comp :scrollbar, Tgui::Scrollbar::Theme
11
+ theme_attr :scrollbar_width, :float
12
+
13
+ end
14
+
8
15
  abi_attr :content_size, Vector2f
9
16
  abi_def :content_offset, :get_, nil => Vector2f
10
17
  abi_def :scrollbar_width, :get_, nil => Float
@@ -0,0 +1,11 @@
1
+ require_relative 'shape'
2
+
3
+ module Tgui
4
+ class CircleShape < Shape
5
+ abi_attr :radius, Float
6
+
7
+ def self.finalizer pointer
8
+ _abi_delete pointer
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'shape'
2
+
3
+ module Tgui
4
+ class ConvexShape < Shape
5
+ def initialized
6
+ @point_count = 0
7
+ end
8
+
9
+ def! :point do |x, y|
10
+ _abi_set_point_count @point_count + 1
11
+ _abi_set_point @point_count, *abi_pack(Vector2f, x, y)
12
+ @point_count += 1
13
+ end
14
+
15
+ def self.finalizer pointer
16
+ _abi_delete pointer
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'shape'
2
+
3
+ module Tgui
4
+ class RectangleShape < Shape
5
+ abi_attr :size, Vector2f
6
+
7
+ def self.finalizer pointer
8
+ _abi_delete pointer
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../../abi/extern_object'
2
+ require_relative '../../convention/bang_nest'
3
+
4
+ module Tgui
5
+ class Shape < ExternObject
6
+ include BangNest
7
+
8
+ abi_attr :texture, Texture
9
+ abi_attr :radius, Float
10
+ abi_attr :point_count, Integer
11
+ abi_attr :color, Color, :fill_color
12
+ abi_attr :border_color, Color, :outline_color
13
+ abi_attr :border, Float, :outline_thickness
14
+ abi_attr :position, Vector2f
15
+ abi_attr :rotation, Float
16
+ abi_attr :scale, Vector2f
17
+ abi_attr :origin, Vector2f
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../../abi/extern_object'
2
+
3
+ module Tgui
4
+ class Text < ExternObject
5
+ include BangNest
6
+
7
+ abi_attr :string, String
8
+ abi_attr :font, Font
9
+ abi_attr :character_size, Integer
10
+ abi_attr :line_spacing, Float
11
+ abi_attr :letter_spacing, Float
12
+ abi_attr :style, TextStyles
13
+ abi_attr :color, Color, :fill_color
14
+ abi_attr :border_color, Color, :outline_color
15
+ abi_attr :border, Float, :outline_thickness
16
+ abi_def :character_position, :find_character_pos, Integer => Vector2f
17
+ abi_attr :position, Vector2f
18
+ abi_attr :rotation, Float
19
+ abi_attr :scale, Vector2f
20
+ abi_attr :origin, Vector2f
21
+
22
+ def self.finalizer pointer
23
+ _abi_delete pointer
24
+ end
25
+ end
26
+ end
@@ -6,7 +6,7 @@ module Tgui
6
6
 
7
7
  def block_caller &b
8
8
  Fiddle::Closure::BlockCaller.new(0, [0]) do
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(@widget)
11
11
  end
12
12
  end
@@ -10,7 +10,7 @@ module Tgui
10
10
 
11
11
  def block_caller &b
12
12
  Fiddle::Closure::BlockCaller.new(0, [0]) do
13
- @widget.page.upon! @widget do
13
+ @widget.host! do
14
14
  b.(@widget)
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller
7
7
  block_caller = Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |animation_type|
8
8
  at = @widget.abi_unpack AnimationType, animation_type
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(at, @widget)
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |int|
8
8
  b = @widget.abi_unpack Boolean, int
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(b, @widget)
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |ptr|
8
8
  c = @widget.abi_unpack Color, ptr
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(c, @widget)
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_FLOAT]) do |float|
8
8
  f = @widget.abi_unpack_float float
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(f, @widget)
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |int|
8
8
  i = @widget.abi_unpack_integer int
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(i, @widget)
11
11
  end
12
12
  end
@@ -5,7 +5,7 @@ module Tgui
5
5
 
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |pointer|
8
- @widget.page.upon! @widget do
8
+ @widget.host! do
9
9
  b.(pointer, @widget)
10
10
  end
11
11
  end
@@ -5,7 +5,7 @@ module Tgui
5
5
 
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_FLOAT, Fiddle::TYPE_FLOAT]) do |min, max|
8
- @widget.page.upon! @widget do
8
+ @widget.host! do
9
9
  b.(min..max, @widget)
10
10
  end
11
11
  end
@@ -7,7 +7,7 @@ module Tgui
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT, Fiddle::TYPE_INT]) do |show_effect_type, shown|
8
8
  effect_type = @widget.abi_unpack ShowEffectType, show_effect_type
9
9
  shown = @widget.abi_unpack Boolean, shown
10
- @widget.page.upon! @widget do
10
+ @widget.host! do
11
11
  b.(effect_type, shown, @widget)
12
12
  end
13
13
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |str|
8
8
  string = @widget.abi_unpack_string(str)
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(string, @widget)
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Tgui
6
6
  def block_caller &b
7
7
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |uint|
8
8
  int = @widget.abi_unpack Integer, uint
9
- @widget.page.upon! @widget do
9
+ @widget.host! do
10
10
  b.(int, @widget)
11
11
  end
12
12
  end
@@ -5,7 +5,7 @@ module Tgui
5
5
  def block_caller &b
6
6
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |ptr|
7
7
  vector = @widget.abi_unpack Vector2f, ptr
8
- @widget.page.upon! @widget do
8
+ @widget.host! do
9
9
  b.(vector, @widget)
10
10
  end
11
11
  end
@@ -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
- upon! tab_panel, **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
- upon! tabs, **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
- upon! tab, **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.page.upon! @widget 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
- upon! attribute, **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
 
@@ -1,4 +1,5 @@
1
1
  require_relative 'widget'
2
+ require_relative '../convention/tree_node'
2
3
  require_relative 'signal/signal_item_hierarchy'
3
4
 
4
5
  module Tgui
@@ -32,42 +33,14 @@ module Tgui
32
33
  path << @widget.abi_unpack_string(str)
33
34
  end
34
35
  SignalItemHierarchy.fetch_path vector, loader
35
- object_path = @widget.self_tree.path_str_to_object path
36
- @widget.page.upon! @widget do
36
+ object_path = @widget.self_tree.path_str_to_object *path
37
+ @widget.host! do
37
38
  b.(object_path.last, object_path, @widget)
38
39
  end
39
40
  end
40
41
  end
41
42
  end
42
43
 
43
- class TreeNode
44
- def initialize object
45
- @object = object
46
- @nodes = {}
47
- end
48
-
49
- attr_accessor :object
50
- attr :nodes
51
-
52
- def [](*path, grow: false)
53
- if grow
54
- path.reduce(self){|node, str| node.nodes[str] ||= TreeNode.new nil }
55
- else
56
- path.reduce(self){|node, str| node&.nodes[str] }
57
- end
58
- end
59
-
60
- def cut *path, last
61
- self[*path].nodes.delete last
62
- end
63
-
64
- def path_str_to_object path
65
- objects = []
66
- path.reduce(self){|node, str| node[str].tap{|n| objects << n.object } }
67
- objects
68
- end
69
- end
70
-
71
44
  api_attr :self_tree do
72
45
  TreeNode.new nil
73
46
  end
@@ -121,6 +94,14 @@ module Tgui
121
94
  Item.new host, [*path, *path_end]
122
95
  end
123
96
 
97
+ def text=(text)
98
+ host.self_change_item path, text
99
+ end
100
+
101
+ def text
102
+ host.self_tree[*path].text
103
+ end
104
+
124
105
  def object
125
106
  path.last
126
107
  end
@@ -192,15 +173,22 @@ module Tgui
192
173
  new_path = [*path, object]
193
174
  self_path_block new_path do
194
175
  _abi_add_item _1, _2, abi_pack_boolean(true)
195
- self_tree[*_3, grow: true].object = object
176
+ self_tree[*new_path, grow: true].text = _3
196
177
  end
197
178
  item = Item.new self, new_path
198
- upon! item, **na, &b
179
+ scope! item, **na, &b
180
+ end
181
+
182
+ def self_change_item path, text, **na, &b
183
+ self_path_block path do
184
+ _abi_change_item _1, _2, text
185
+ self_tree[*path].text = text
186
+ end
199
187
  end
200
188
 
201
189
  def self_path_block path, &b
202
190
  path = path.map(&format)
203
- b.(*abi_pack(String.., *path), path)
191
+ b.(*abi_pack(String.., *path), path.last)
204
192
  end
205
193
  end
206
194
  end