white_gold 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
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,13 +1,20 @@
1
- class TextStylesAttribute
2
- def initialize name, value
3
- @name = name
4
- @value = value
5
- end
1
+ require_relative '../../abi/extern_object'
2
+
3
+ module Tgui
4
+ class TextStylesAttribute
5
+ def initialize name, value
6
+ @name = name
7
+ @value = Array(value).map do |style|
8
+ raise "Invalid style #{style}" if !ExternObject::TextStyles[style]
9
+ style.to_s.upcase
10
+ end.join("|")
11
+ end
6
12
 
7
- attr :name
8
- attr :value
13
+ attr :name
14
+ attr :value
9
15
 
10
- def to_theme
11
- "#{name} = #{value.to_s};"
16
+ def to_theme
17
+ "#{name} = #{value};"
18
+ end
12
19
  end
13
20
  end
@@ -1,19 +1,21 @@
1
1
  require_relative '../../dsl/texture'
2
2
 
3
- class TextureAttribute
4
- def initialize name, value
5
- @name = name
6
- @value = Texture.from *value
7
- end
3
+ module Tgui
4
+ class TextureAttribute
5
+ def initialize name, value
6
+ @name = name
7
+ @value = Texture.from *value
8
+ end
8
9
 
9
- attr :name
10
- attr :value
10
+ attr :name
11
+ attr :value
11
12
 
12
- def to_theme
13
- "#{name} = #{value.to_theme};"
14
- end
13
+ def to_theme
14
+ "#{name} = #{value.to_theme};"
15
+ end
15
16
 
16
- def self.base_class
17
- Texture
17
+ def self.base_class
18
+ Texture
19
+ end
18
20
  end
19
21
  end
@@ -30,7 +30,7 @@ module Tgui
30
30
  def! name do |custom_name = nil, base_name = nil, **na, &b|
31
31
  attribute = type.new(base_name, custom_name)
32
32
  attribute = attributes[attribute.name] ||= attribute
33
- upon! attribute, **na, &b
33
+ attribute.host! **na, &b
34
34
  end
35
35
  end
36
36
  end
@@ -26,7 +26,7 @@ module Tgui
26
26
  end
27
27
 
28
28
  def to_theme
29
- return "" if @attributes.empty? && !@custom_name
29
+ # return "" if @attributes.empty? && !@custom_name
30
30
  header = @custom_name ? "#{@custom_name} : #{base_name}" : name
31
31
  "#{header} {\n#{@attributes.values.map(&:to_theme).join("\n")}\n}"
32
32
  end
@@ -22,6 +22,7 @@ module Tgui
22
22
 
23
23
  theme_comp :button, ButtonBase::Theme
24
24
  theme_comp :chatbox, ChatBox::Theme
25
+ theme_comp :checkbox, RadioButton::Theme
25
26
  theme_comp :child_window, ChildWindow::Theme
26
27
  theme_comp :color_picker, ColorPicker::Theme
27
28
  theme_comp :combobox, ComboBox::Theme
@@ -34,6 +35,8 @@ module Tgui
34
35
  theme_comp :listview, ListView::Theme
35
36
  theme_comp :menu, MenuBar::Theme
36
37
  theme_comp :messagebox, MessageBox::Theme
38
+ theme_comp :panel, Panel::Theme
39
+ theme_comp :panel_listbox, PanelListBox::Theme
37
40
  theme_comp :progressbar, ProgressBar::Theme
38
41
  theme_comp :radio_button, RadioButton::Theme
39
42
  theme_comp :range_slider, RangeSlider::Theme
@@ -42,8 +45,9 @@ module Tgui
42
45
  theme_comp :slider, Slider::Theme
43
46
  theme_comp :spin_button, SpinButton::Theme
44
47
  theme_comp :tabs, Tabs::Theme
45
- theme_comp :text_area, TextArea::Theme
46
- theme_comp :tree_view, TreeView::Theme
48
+ theme_comp :textarea, TextArea::Theme
49
+ theme_comp :toggle_button, ToggleButton::Theme
50
+ theme_comp :treeview, TreeView::Theme
47
51
  theme_comp :widget, Widget::Theme
48
52
  end
49
53
  end
@@ -0,0 +1,43 @@
1
+ class TreeNode
2
+ def initialize text
3
+ @text = text
4
+ @nodes = {}
5
+ end
6
+
7
+ attr_accessor :text
8
+ attr :nodes
9
+
10
+ def [](*path, grow: false)
11
+ if grow
12
+ path.reduce(self){|node, o| node.nodes[o] ||= TreeNode.new(nil) }
13
+ else
14
+ path.reduce(self){|node, o| node&.nodes[o] }
15
+ end
16
+ end
17
+
18
+ def cut *path, last
19
+ self[*path].nodes.delete last
20
+ end
21
+
22
+ def cut_branches *path
23
+ self[*path].nodes = {}
24
+ end
25
+
26
+ def path_str_to_object *path
27
+ object_path = []
28
+ path.reduce self do |node, str|
29
+ o, node = *node.nodes.find{|k, v| v.text == str }
30
+ object_path << o
31
+ node
32
+ end
33
+ object_path
34
+ end
35
+
36
+ def path_object_to_str *path
37
+ str_path = []
38
+ path.reduce self do |node, o|
39
+ node[o].tap{ str_path << _1.text }
40
+ end
41
+ str_path
42
+ end
43
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../../dsl/custom_widget'
2
+
3
+ module Tgui
4
+ class KeyboardControl < CustomWidget
5
+
6
+ api_attr :key_press_listeners do
7
+ {}
8
+ end
9
+
10
+ def initialized
11
+ self.self_can_gain_focus = proc do
12
+ 1
13
+ end
14
+
15
+ self.self_key_press = proc do |key, alt, control, shift, system|
16
+ key_symbol = KeyCode[key]
17
+ self.key_press_listeners[key_symbol]&.each do |listener|
18
+ listener.call(key_symbol, alt, control, shift, system)
19
+ end
20
+ end
21
+ end
22
+
23
+ def! :on_key do |*keys, &b|
24
+ keys.each do |k|
25
+ (self.key_press_listeners[k] ||= []) << b
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module Tgui
2
+ Chatbox = ChatBox
3
+ Checkbox = CheckBox
4
+ Combobox = ComboBox
5
+ Editbox = EditBox
6
+ Hlayout = HorizontalLayout
7
+ Hwrap = HorizontalWrap
8
+ Listbox = ListBox
9
+ Listview = ListView
10
+ Menu = MenuBar
11
+ Messagebox = MessageBox
12
+ PanelListbox = PanelListBox
13
+ PanelTabs = TabContainer
14
+ Progressbar = ProgressBar
15
+ FancyLabel = RichTextLabel
16
+ Radio = RadioButton
17
+ RadioGroup = RadioButtonGroup
18
+ Separator = SeparatorLine
19
+ Spinner = SpinButton
20
+ Spinbox = SpinControl
21
+ Textarea = TextArea
22
+ Treeview = TreeView
23
+ Vlayout = VerticalLayout
24
+ end
@@ -137,10 +137,4 @@ class WidgetLike
137
137
 
138
138
  attr :host
139
139
  attr :id
140
-
141
- def flags=(flags)
142
- flags.each do |f|
143
- send("#{f}=", true)
144
- end
145
- end
146
140
  end
@@ -31,6 +31,7 @@ module Tgui
31
31
  abi_def :pop_mouse_cursor, :restore_override_mouse_cursor
32
32
  abi_def :px_to_crd, :map_pixel_to_coords, [Integer, Integer] => [Float, Float]
33
33
  abi_def :crd_to_px, :map_coords_to_pixel, [Float, Float] => [Float, Float]
34
+ abi_attr :keyboard_navigation?, Boolean, :keyboard_navigation_enabled
34
35
  abi_signal :on_view_change, ViewSignal
35
36
 
36
37
  end
@@ -0,0 +1,40 @@
1
+ require_relative 'clickable_widget'
2
+
3
+ module Tgui
4
+ class Canvas < ClickableWidget
5
+
6
+ class Draw < WidgetLike
7
+
8
+ def! :fill do |*color|
9
+ host._abi_clear host.abi_pack(Color, *color)
10
+ end
11
+
12
+ def! :rectangle do |**na, &b|
13
+ shape = scope! RectangleShape.new, **na, &b
14
+ host._abi_draw shape
15
+ end
16
+
17
+ def! :circle do |**na, &b|
18
+ shape = scope! CircleShape.new, **na, &b
19
+ host._abi_draw shape
20
+ end
21
+
22
+ def! :convex do |**na, &b|
23
+ shape = scope! ConvexShape.new, **na, &b
24
+ host._abi_draw shape
25
+ end
26
+
27
+ def! :text do |**na, &b|
28
+ text = scope! Text.new, **na, &b
29
+ host._abi_draw text
30
+ end
31
+
32
+ end
33
+
34
+ def! :draw do |&b|
35
+ scope! Draw.new(self, nil), &b
36
+ _abi_display
37
+ end
38
+
39
+ end
40
+ end
@@ -44,7 +44,7 @@ module Tgui
44
44
  _abi_add_line abi_pack_string(text), abi_pack(Color, color), abi_pack(TextStyles, *style)
45
45
  line = Line.new self, objects.size
46
46
  objects << object
47
- upon! line, **na, &b
47
+ scope! line, **na, &b
48
48
  end
49
49
 
50
50
  def [](index)
@@ -28,7 +28,7 @@ module Tgui
28
28
  class SignalClosing < Tgui::Signal
29
29
  def block_caller &b
30
30
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |ptr|
31
- @widget.page.upon! @widget do
31
+ @widget.host! do
32
32
  b.(ptr, @widget)
33
33
  end
34
34
  end
@@ -8,8 +8,10 @@ module Tgui
8
8
  green: [0, 200, 0, 255],
9
9
  blue: [0, 0, 200, 255],
10
10
  yellow: [200, 200, 0, 255],
11
- white: [200, 200, 200, 255],
12
- black: [0, 0, 0, 255]
11
+ white: [255, 255, 255, 255],
12
+ black: [0, 0, 0, 255],
13
+ gray: [100, 100, 100, 255],
14
+ transparent: [255, 255, 255, 0]
13
15
  }
14
16
 
15
17
  def self.from *arg
@@ -21,6 +23,9 @@ module Tgui
21
23
  return arg
22
24
  when String
23
25
  r, g, b, a = *tones_from_string(arg)
26
+ when :random
27
+ r, g, b = 5.times.map{ rand 255 }
28
+ a = 255
24
29
  when Symbol
25
30
  r, g, b, a = *PREDEFINED_COLORS[arg]
26
31
  when Numeric
@@ -61,12 +66,12 @@ module Tgui
61
66
  Color.new *Color.hsv_to_rgb(h, s, (v - shadow).clamp(0, 255)), alpha
62
67
  end
63
68
 
64
- def to_a
69
+ def to_arr
65
70
  [red, green, blue, alpha]
66
71
  end
67
72
 
68
73
  def to_s
69
- "##{to_a.map{ _1.to_s(16).ljust(2, '0') }.join}"
74
+ "##{to_arr.map{ _1.to_s(16).ljust(2, '0') }.join}"
70
75
  end
71
76
 
72
77
  def inspect
@@ -37,7 +37,7 @@ module Tgui
37
37
  def block_caller &b
38
38
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP]) do |str1, str2|
39
39
  id = @widget.abi_unpack_string(str2)
40
- @widget.page.upon! @widget do
40
+ @widget.host! do
41
41
  b.(@widget.self_get_object_by_id(id), @widget)
42
42
  end
43
43
  end
@@ -99,7 +99,7 @@ module Tgui
99
99
  _abi_add_item abi_pack_string(text), abi_pack_string(id)
100
100
  item = Item.new self, id
101
101
  self_objects[id] = object
102
- upon! item, **na, &b
102
+ scope! item, **na, &b
103
103
  end
104
104
 
105
105
  def selected
@@ -12,14 +12,14 @@ module Tgui
12
12
  return widgets
13
13
  end
14
14
 
15
- abi_def :add, [Object, String] => nil
15
+ abi_def :self_add, :add, [Object, String] => nil
16
16
  abi_def :remove_all
17
17
  abi_def :inner_size, :get_, nil => Vector2f
18
18
  abi_def :child_offset, :get_, nil => Vector2f
19
19
  abi_def :remove, Widget => nil
20
20
 
21
21
  def move_front widget, ceil = false
22
- widget = abi_pack_widget widget
22
+ widget = abi_pack(Widget, widget)
23
23
  if ceil
24
24
  _abi_move_widget_to_front widget
25
25
  else
@@ -28,7 +28,7 @@ module Tgui
28
28
  end
29
29
 
30
30
  def move_back widget, floor = false
31
- widget = abi_pack_widget widget
31
+ widget = abi_pack(Widget, widget)
32
32
  if floor
33
33
  _abi_move_widget_to_back widget
34
34
  else
@@ -37,13 +37,21 @@ module Tgui
37
37
  end
38
38
 
39
39
  def move_at index, widget
40
- _abi_set_widget_index abi_pack_widget(widget), abi_pack_integer(index)
40
+ _abi_set_widget_index abi_pack(Widget, widget), abi_pack_integer(index)
41
41
  end
42
42
 
43
43
  abi_def :index, :get_widget_, Widget => Integer
44
44
  abi_def :focused_child, :get_, nil => Widget
45
45
  abi_def :focused_leaf, :get_, nil => Widget
46
- abi_def :leaf_at_position, :get_widget_at_position, [Float, Float] => Widget
46
+
47
+ def leaf_at_position x, y
48
+ abi_unpack(Widget, _abi_get_widget_at_pos(api_pack_float(x), abi_pack_float(y), abi_pack_boolean(true)))
49
+ end
50
+
51
+ def child_at_position x, y
52
+ abi_unpack(Widget, _abi_get_widget_at_pos(api_pack_float(x), abi_pack_float(y), abi_pack_boolean(false)))
53
+ end
54
+
47
55
  abi_def :focus_next, :focus_next_widget
48
56
  abi_def :focus_previous, :focus_previous_widget
49
57
 
@@ -66,21 +74,19 @@ module Tgui
66
74
 
67
75
  # internal
68
76
 
69
- def abi_pack_widget o
77
+
78
+ abi_packer Widget do |o|
79
+ o = o.first if o.is_a? Array
70
80
  case o
71
81
  when Symbol
72
82
  self[o]
73
83
  when Widget
74
84
  o
75
85
  else
76
- raise "Unable to make Widget from #{o}"
86
+ raise "Unable to make Widget from #{o}(#{o.class})"
77
87
  end
78
88
  end
79
-
80
- def abi_unpack_widget o
81
- self_cast_up o
82
- end
83
-
89
+
84
90
  def self_get_widget_name a
85
91
  case a
86
92
  when Widget
@@ -0,0 +1,28 @@
1
+ require_relative 'widget'
2
+
3
+ module Tgui
4
+ class CustomWidget < Widget
5
+
6
+ api_attr :callbacks do
7
+ {}
8
+ end
9
+
10
+ def self_key_press=(value)
11
+ block_caller = Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_INT], &value)
12
+ _abi_impl_key_pressed block_caller
13
+ self.callbacks[:self_key_press] = block_caller
14
+ end
15
+
16
+ def self_can_gain_focus=(value)
17
+ block_caller = Fiddle::Closure::BlockCaller.new(Fiddle::TYPE_INT, [0], &value)
18
+ _abi_impl_can_gain_focus block_caller
19
+ self.callbacks[:self_can_gain_focus] = block_caller
20
+ end
21
+
22
+ def self_focus_changed=(value)
23
+ block_caller = Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT], &value)
24
+ _abi_impl_focus_changed block_caller
25
+ self.callbacks[:self_focus_changed] = block_caller
26
+ end
27
+ end
28
+ end
@@ -18,6 +18,10 @@ module Tgui
18
18
  end
19
19
  Font.new id
20
20
  end
21
-
21
+
22
+ def self.default
23
+ Font.new pointer: _abi_get_global_font
24
+ end
25
+
22
26
  end
23
27
  end
@@ -27,23 +27,47 @@ module Tgui
27
27
  abi_unpack(Outline, _abi_get_widget_padding(w))
28
28
  end
29
29
 
30
- abi_enum "Alignment", :center, :upper_left, :up, :upper_right, :right, :bottom_right, :bottom, :bottom_left, :left,
31
- top_left: :upper_left, left_top: :upper_left,
32
- top_right: :upper_right, right_top: :upper_right,
33
- right_bottom: :bottom_right, left_bottom: :bottom_left
30
+ abi_enum "Alignment", :center, :top_left, :top, :top_right, :right, :bottom_right, :bottom, :bottom_left, :left,
31
+ left_top: :top_left, right_top: :upper_right, right_bottom: :bottom_right, left_bottom: :bottom_left
32
+
33
+ abi_packer Alignment do |*arg|
34
+ case arg.size
35
+ when 1
36
+ o = arg.first
37
+ when 2
38
+ a = case arg[0]
39
+ when :begin then :left
40
+ when :end then :right
41
+ else arg[0]
42
+ end
43
+ b = case arg[1]
44
+ when :begin then :top
45
+ when :end then :bottom
46
+ else arg[1]
47
+ end
48
+ o = if a == :center && b == :center
49
+ :center
50
+ elsif a == :center
51
+ b
52
+ elsif b == :center
53
+ a
54
+ else
55
+ "#{a}_#{b}".to_sym
56
+ end
57
+ else raise "Unsupported argument #{arg}"
58
+ end
59
+ Alignment.sym_to_i o
60
+ end
34
61
 
35
62
  api_child :alignment= do |w, alignment|
36
- _abi_set_widget_alignment w, abi_pack(Alignment, alignment)
63
+ p abi_pack(Alignment, *alignment)
64
+ _abi_set_widget_alignment w, abi_pack(Alignment, *alignment)
37
65
  end
38
66
 
39
67
  api_child :alignment do |w|
40
68
  abi_unpack(Alignment, _abi_get_widget_alignment(w))
41
69
  end
42
70
 
43
- api_child :alignment do |w|
44
- Alignment[_abi_get_widget_alignment]
45
- end
46
-
47
71
  api_child :cell= do |w, cell|
48
72
  _abi_set_widget_cell w, abi_pack_integer(cell[0]), abi_pack_integer(cell[1])
49
73
  end
@@ -82,11 +106,11 @@ module Tgui
82
106
  return widgets
83
107
  end
84
108
 
85
- def add widget, id
109
+ def self_add widget, id
86
110
  super
87
- _abi_set_widget_cell abi_pack_widget(widget), *cell
88
- _abi_set_widget_alignment abi_pack_widget(widget), abi_pack(Alignment, alignment) if alignment
89
- _abi_set_widget_padding abi_pack_widget(widget), abi_pack(Outline, *padding) if padding
111
+ _abi_set_widget_cell abi_pack(Widget, widget), *cell
112
+ _abi_set_widget_alignment abi_pack(Widget, widget), abi_pack(Alignment, alignment) if alignment
113
+ _abi_set_widget_padding abi_pack(Widget, widget), abi_pack(Outline, *padding) if padding
90
114
  if direction == :column
91
115
  next_column false
92
116
  else
@@ -9,8 +9,17 @@ module Tgui
9
9
  abi_def :self_active?, :is_active, nil => Boolean
10
10
  abi_def :self_poll_events, :poll_events
11
11
  abi_def :self_draw, :draw
12
- abi_def :clear_color=, Color => nil
12
+ abi_def :background_color=, :set_clear_color, Color => nil
13
13
  abi_attr :clipboard, String
14
+ abi_def :screen_size, :get_, nil => Vector2u
15
+
16
+ attr_accessor :page
17
+
18
+ def! :messagebox do |*a, **na, &b|
19
+ messagebox = MessageBox.new
20
+ @page.send! :add, messagebox
21
+ @page.scope! messagebox, *a, **na, &b
22
+ end
14
23
 
15
24
  end
16
25
  end
@@ -26,6 +26,9 @@ module Tgui
26
26
  abi_def :ignore_mouse_events?, :ignoring_mouse_events, nil => Boolean
27
27
  abi_enum "HorizontalAlignment", :left, :center, :right
28
28
  abi_attr :horizontal_alignment, HorizontalAlignment
29
+ def alignment=(a)
30
+ self.horizontal_alignment = a
31
+ end
29
32
  abi_enum "VerticalAlignment", :top, :center, :bottom
30
33
  abi_attr :vertical_alignment, VerticalAlignment
31
34
  abi_enum Scrollbar::Policy
@@ -29,7 +29,7 @@ module Tgui
29
29
  def block_caller &b
30
30
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP]) do |str1, str2|
31
31
  id = @widget.abi_unpack_string(str2)
32
- @widget.page.upon! @widget do
32
+ @widget.host! do
33
33
  b.(@widget.self_get_object_by_id(id), @widget)
34
34
  end
35
35
  end
@@ -55,26 +55,22 @@ module Tgui
55
55
  abi_signal :on_scroll, SignalUInt
56
56
  abi_attr :text_alignment, TextAlignment
57
57
 
58
- class Item
59
- def initialize list_box, id
60
- @list_box = list_box
61
- @id = id
62
- end
58
+ class Item < WidgetLike
63
59
 
64
60
  def object=(object)
65
- @list_box.self_objects[@id] = object
61
+ host.self_objects[id] = object
66
62
  end
67
63
 
68
64
  def object
69
- return @list_box.self_objects[@id]
65
+ return host.self_objects[id]
70
66
  end
71
67
 
72
68
  def text=(text)
73
- @list_box._abi_change_item_by_id @id, abi_pack_string(text)
69
+ host._abi_change_item_by_id id, abi_pack_string(text)
74
70
  end
75
71
 
76
72
  def remove
77
- @list_box._abi_remove_item_by_id @id
73
+ host._abi_remove_item_by_id id
78
74
  end
79
75
  end
80
76
 
@@ -84,7 +80,7 @@ module Tgui
84
80
  _abi_add_item abi_pack_string(text), abi_pack_string(id)
85
81
  item = Item.new self, id
86
82
  na[:object] ||= object
87
- upon! item, **na, &b
83
+ scope! item, **na, &b
88
84
  end
89
85
 
90
86
  def remove_all
@@ -31,7 +31,7 @@ module Tgui
31
31
  class ListViewItemSignal < Tgui::SignalInt
32
32
  def block_caller &b
33
33
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |index|
34
- @widget.page.upon! @widget do
34
+ @widget.host! do
35
35
  b.(@widget.self_objects[index], @widget)
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ module Tgui
41
41
  class ListViewColumnSignal < Tgui::SignalInt
42
42
  def block_caller &b
43
43
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |index|
44
- @widget.page.upon! @widget do
44
+ @widget.host! do
45
45
  b.(@widget.columns[index], @widget)
46
46
  end
47
47
  end
@@ -93,14 +93,14 @@ module Tgui
93
93
  index = _abi_add_column
94
94
  column = Column.new self, index
95
95
  columns << column
96
- upon! column, **na, &b
96
+ scope! column, **na, &b
97
97
  end
98
98
 
99
99
  def! :item do |object, **na, &b|
100
100
  self_add_object object, na[:index]
101
101
  item = Item.new self, object
102
102
  na.delete :index
103
- upon! item, **na, &b
103
+ scope! item, **na, &b
104
104
  end
105
105
 
106
106
  def items=(items)
@@ -173,7 +173,7 @@ module Tgui
173
173
 
174
174
  def! :grid_lines do | **na, &b|
175
175
  lines = GridLines.new self
176
- upon! lines, **na, &b
176
+ scope! lines, **na, &b
177
177
  end
178
178
 
179
179
  def grid_lines=(grid_lines)
@@ -199,7 +199,7 @@ module Tgui
199
199
 
200
200
  def! :header do |**na, &b|
201
201
  header = Header.new self
202
- upon! header, **na, &b
202
+ scope! header, **na, &b
203
203
  end
204
204
 
205
205
  def header=(header)