white_gold 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) 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 +0 -8
  5. data/lib/white_gold/abi/extern_object.rb +6 -1
  6. data/lib/white_gold/abi/unpacker.rb +4 -2
  7. data/lib/white_gold/convention/bang_nest.rb +12 -2
  8. data/lib/white_gold/convention/bang_nested_caller.rb +34 -34
  9. data/lib/white_gold/convention/container_widgets.rb +53 -51
  10. data/lib/white_gold/convention/page.rb +22 -4
  11. data/lib/white_gold/{dsl → convention}/theme/color_attribute.rb +2 -0
  12. data/lib/white_gold/{dsl → convention}/theme/outline_attribute.rb +2 -0
  13. data/lib/white_gold/convention/theme/text_styles_attribute.rb +18 -0
  14. data/lib/white_gold/{dsl → convention}/theme/texture_attribute.rb +2 -0
  15. data/lib/white_gold/{dsl → convention}/theme/theme_attributed.rb +4 -18
  16. data/lib/white_gold/{dsl → convention}/theme/theme_component.rb +14 -3
  17. data/lib/white_gold/convention/theme_attributes.rb +49 -0
  18. data/lib/white_gold/convention/tree_node.rb +43 -0
  19. data/lib/white_gold/convention/widget_like.rb +0 -6
  20. data/lib/white_gold/dsl/backend_gui.rb +1 -0
  21. data/lib/white_gold/dsl/button_base.rb +17 -2
  22. data/lib/white_gold/dsl/canvas.rb +40 -0
  23. data/lib/white_gold/dsl/chat_box.rb +12 -1
  24. data/lib/white_gold/dsl/child_window.rb +22 -1
  25. data/lib/white_gold/dsl/color.rb +5 -2
  26. data/lib/white_gold/dsl/color_picker.rb +9 -0
  27. data/lib/white_gold/dsl/combo_box.rb +30 -2
  28. data/lib/white_gold/dsl/container.rb +17 -11
  29. data/lib/white_gold/dsl/edit_box.rb +29 -0
  30. data/lib/white_gold/dsl/file_dialog.rb +17 -0
  31. data/lib/white_gold/dsl/font.rb +5 -1
  32. data/lib/white_gold/dsl/grid.rb +3 -3
  33. data/lib/white_gold/dsl/group.rb +5 -0
  34. data/lib/white_gold/dsl/knob.rb +10 -0
  35. data/lib/white_gold/dsl/label.rb +14 -0
  36. data/lib/white_gold/dsl/list_box.rb +27 -11
  37. data/lib/white_gold/dsl/list_view.rb +29 -6
  38. data/lib/white_gold/dsl/menu_bar.rb +21 -48
  39. data/lib/white_gold/dsl/message_box.rb +8 -2
  40. data/lib/white_gold/dsl/panel_list_box.rb +3 -3
  41. data/lib/white_gold/dsl/progress_bar.rb +14 -0
  42. data/lib/white_gold/dsl/radio_button.rb +25 -0
  43. data/lib/white_gold/dsl/range_slider.rb +8 -0
  44. data/lib/white_gold/dsl/scrollbar.rb +19 -0
  45. data/lib/white_gold/dsl/separator_line.rb +5 -0
  46. data/lib/white_gold/dsl/sfml/circle_shape.rb +7 -0
  47. data/lib/white_gold/dsl/sfml/convex_shape.rb +15 -0
  48. data/lib/white_gold/dsl/sfml/rectangle_shape.rb +7 -0
  49. data/lib/white_gold/dsl/sfml/shape.rb +19 -0
  50. data/lib/white_gold/dsl/sfml/text.rb +22 -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/slider.rb +15 -0
  65. data/lib/white_gold/dsl/spin_button.rb +14 -0
  66. data/lib/white_gold/dsl/tab_container.rb +2 -2
  67. data/lib/white_gold/dsl/tabs.rb +26 -2
  68. data/lib/white_gold/dsl/text_area.rb +16 -0
  69. data/lib/white_gold/dsl/theme.rb +11 -51
  70. data/lib/white_gold/dsl/tree_view.rb +41 -33
  71. data/lib/white_gold/dsl/widget.rb +81 -39
  72. data/lib/white_gold/generated/tgui-abi-loader.gf.rb +197 -47
  73. data/lib/white_gold/library/theme/light.rb +15 -3
  74. data/lib/white_gold/master.rb +21 -40
  75. data/lib/white_gold/path/object.path.rb +0 -11
  76. data/lib/white_gold/tgui-abi.rb +17 -16
  77. data/lib/white_gold/version.rb +3 -0
  78. data/lib/white_gold.rb +29 -28
  79. metadata +26 -39
  80. data/lib/white_gold/dsl/theme/button_theme.rb +0 -19
  81. data/lib/white_gold/dsl/theme/chat_box_theme.rb +0 -16
  82. data/lib/white_gold/dsl/theme/child_window_theme.rb +0 -25
  83. data/lib/white_gold/dsl/theme/color_picker_theme.rb +0 -14
  84. data/lib/white_gold/dsl/theme/combo_box_theme.rb +0 -33
  85. data/lib/white_gold/dsl/theme/common_renderer.rb +0 -7
  86. data/lib/white_gold/dsl/theme/edit_box_theme.rb +0 -34
  87. data/lib/white_gold/dsl/theme/file_dialog_theme.rb +0 -22
  88. data/lib/white_gold/dsl/theme/group_theme.rb +0 -9
  89. data/lib/white_gold/dsl/theme/knob_theme.rb +0 -15
  90. data/lib/white_gold/dsl/theme/label_theme.rb +0 -20
  91. data/lib/white_gold/dsl/theme/list_box_theme.rb +0 -25
  92. data/lib/white_gold/dsl/theme/list_view_theme.rb +0 -27
  93. data/lib/white_gold/dsl/theme/menu_bar_theme.rb +0 -21
  94. data/lib/white_gold/dsl/theme/message_box_theme.rb +0 -11
  95. data/lib/white_gold/dsl/theme/progress_bar_theme.rb +0 -19
  96. data/lib/white_gold/dsl/theme/radio_button_theme.rb +0 -30
  97. data/lib/white_gold/dsl/theme/scrollbar_theme.rb +0 -24
  98. data/lib/white_gold/dsl/theme/separator_line_theme.rb +0 -9
  99. data/lib/white_gold/dsl/theme/slider_theme.rb +0 -20
  100. data/lib/white_gold/dsl/theme/spin_button_theme.rb +0 -19
  101. data/lib/white_gold/dsl/theme/tabs_theme.rb +0 -29
  102. data/lib/white_gold/dsl/theme/text_area_theme.rb +0 -22
  103. data/lib/white_gold/dsl/theme/text_styles_attribute.rb +0 -13
  104. data/lib/white_gold/dsl/theme/tree_view_theme.rb +0 -26
  105. data/lib/white_gold/dsl/theme/widget_theme.rb +0 -12
  106. /data/lib/white_gold/{dsl → convention}/theme/boolean_attribute.rb +0 -0
  107. /data/lib/white_gold/{dsl → convention}/theme/float_attribute.rb +0 -0
  108. /data/lib/white_gold/dsl/{checkbox.rb → check_box.rb} +0 -0
@@ -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 = RectangleShape.new.send! **na, &b
14
+ host._abi_draw shape
15
+ end
16
+
17
+ def! :circle do |**na, &b|
18
+ shape = CircleShape.new.send! **na, &b
19
+ host._abi_draw shape
20
+ end
21
+
22
+ def! :convex do |**na, &b|
23
+ shape = ConvexShape.new.send! **na, &b
24
+ host._abi_draw shape
25
+ end
26
+
27
+ def! :text do |**na, &b|
28
+ text = Text.new.send! **na, &b
29
+ host._abi_draw text
30
+ end
31
+
32
+ end
33
+
34
+ def! :draw do |&b|
35
+ Draw.new(self, nil).send! &b
36
+ _abi_display
37
+ end
38
+
39
+ end
40
+ end
@@ -1,9 +1,20 @@
1
1
  require_relative 'widget'
2
+ require_relative 'scrollbar'
2
3
  require_relative '../convention/widget_like'
3
4
 
4
5
  module Tgui
5
6
  class ChatBox < Widget
6
7
 
8
+ class Theme < Widget::Theme
9
+ theme_attr :borders, :outline
10
+ theme_attr :padding, :outline
11
+ theme_attr :background_color, :color
12
+ theme_attr :border_color, :color
13
+ theme_attr :texture_background, :texture
14
+ theme_comp :scrollbar, Scrollbar::Theme
15
+ theme_attr :scrollbar_width, :float
16
+ end
17
+
7
18
  api_attr :objects do
8
19
  []
9
20
  end
@@ -33,7 +44,7 @@ module Tgui
33
44
  _abi_add_line abi_pack_string(text), abi_pack(Color, color), abi_pack(TextStyles, *style)
34
45
  line = Line.new self, objects.size
35
46
  objects << object
36
- upon! line, **na, &b
47
+ line.send! **na, &b
37
48
  end
38
49
 
39
50
  def [](index)
@@ -1,13 +1,34 @@
1
1
  require_relative 'container'
2
+ require_relative 'button'
2
3
  require_relative 'signal/signal'
3
4
 
4
5
  module Tgui
5
6
  class ChildWindow < Container
6
7
 
8
+ class Theme < Widget::Theme
9
+ theme_attr :borders, :outline
10
+ theme_attr :title_bar_height, :float
11
+ theme_attr :title_bar_color, :color
12
+ theme_attr :title_color, :color
13
+ theme_attr :background_color, :color
14
+ theme_attr :border_color, :color
15
+ theme_attr :border_color_focused, :color
16
+ theme_attr :border_below_title_bar, :float
17
+ theme_attr :distance_to_side, :float
18
+ theme_attr :padding_between_buttons, :float
19
+ theme_attr :minimum_resizable_border_width, :float
20
+ theme_attr :show_text_on_title_buttons, :boolean
21
+ theme_attr :texture_title_bar, :texture
22
+ theme_attr :texture_background, :texture
23
+ theme_comp :close_button, Button::Theme
24
+ theme_comp :maximize_button, Button::Theme
25
+ theme_comp :minimize_button, Button::Theme
26
+ end
27
+
7
28
  class SignalClosing < Tgui::Signal
8
29
  def block_caller &b
9
30
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |ptr|
10
- @widget.page.upon! @widget do
31
+ @widget.send! do
11
32
  b.(ptr, @widget)
12
33
  end
13
34
  end
@@ -21,6 +21,9 @@ module Tgui
21
21
  return arg
22
22
  when String
23
23
  r, g, b, a = *tones_from_string(arg)
24
+ when :random
25
+ r, g, b = 5.times.map{ rand 255 }
26
+ a = 255
24
27
  when Symbol
25
28
  r, g, b, a = *PREDEFINED_COLORS[arg]
26
29
  when Numeric
@@ -61,12 +64,12 @@ module Tgui
61
64
  Color.new *Color.hsv_to_rgb(h, s, (v - shadow).clamp(0, 255)), alpha
62
65
  end
63
66
 
64
- def to_a
67
+ def to_arr
65
68
  [red, green, blue, alpha]
66
69
  end
67
70
 
68
71
  def to_s
69
- "##{to_a.map{ _1.to_s(16).ljust(2, '0') }.join}"
72
+ "##{to_arr.map{ _1.to_s(16).ljust(2, '0') }.join}"
70
73
  end
71
74
 
72
75
  def inspect
@@ -1,9 +1,18 @@
1
1
  require_relative 'child_window'
2
+ require_relative 'button'
3
+ require_relative 'label'
4
+ require_relative 'slider'
2
5
  require_relative 'signal/signal_color'
3
6
 
4
7
  module Tgui
5
8
  class ColorPicker < ChildWindow
6
9
 
10
+ class Theme < ChildWindow::Theme
11
+ theme_comp :button, Button::Theme
12
+ theme_comp :label, Label::Theme
13
+ theme_comp :slider, Slider::Theme
14
+ end
15
+
7
16
  abi_attr :color, Color
8
17
  abi_signal :on_color_change, SignalColor
9
18
  abi_signal :on_ok_press, SignalColor
@@ -1,15 +1,43 @@
1
1
  require_relative 'widget'
2
+ require_relative 'list_box'
2
3
  require_relative 'signal/signal_item'
3
4
  require_relative '../convention/widget_like'
4
5
 
5
6
  module Tgui
6
7
  class ComboBox < Widget
7
8
 
9
+ class Theme < Widget::Theme
10
+ theme_attr :borders, :outline
11
+ theme_attr :padding, :outline
12
+ theme_attr :text_style, :text_styles
13
+ theme_attr :default_text_style, :text_styles
14
+ theme_attr :background_color, :color
15
+ theme_attr :background_color_disabled, :color
16
+ theme_attr :text_color, :color
17
+ theme_attr :text_color_disabled, :color
18
+ theme_attr :default_text_color, :color
19
+ theme_attr :arrow_background_color, :color
20
+ theme_attr :arrow_background_color_disabled, :color
21
+ theme_attr :arrow_background_color_hover, :color
22
+ theme_attr :arrow_color, :color
23
+ theme_attr :arrow_color_hover, :color
24
+ theme_attr :arrow_color_disabled, :color
25
+ theme_attr :texture_background, :texture
26
+ theme_attr :texture_background_disabled, :texture
27
+ theme_attr :border_color, :color
28
+ theme_attr :texture_background, :texture
29
+ theme_attr :texture_background_disabled, :texture
30
+ theme_attr :texture_arrow, :texture
31
+ theme_attr :texture_arrow_hover, :texture
32
+ theme_attr :texture_arrow_disabled, :texture
33
+ theme_comp :list_box, ListBox::Theme
34
+ end
35
+
8
36
  class SignalItem < Tgui::SignalItem
9
37
  def block_caller &b
10
38
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP]) do |str1, str2|
11
39
  id = @widget.abi_unpack_string(str2)
12
- @widget.page.upon! @widget do
40
+ @widget.send! do
13
41
  b.(@widget.self_get_object_by_id(id), @widget)
14
42
  end
15
43
  end
@@ -71,7 +99,7 @@ module Tgui
71
99
  _abi_add_item abi_pack_string(text), abi_pack_string(id)
72
100
  item = Item.new self, id
73
101
  self_objects[id] = object
74
- upon! item, **na, &b
102
+ item.send! **na, &b
75
103
  end
76
104
 
77
105
  def selected
@@ -19,7 +19,7 @@ module Tgui
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
@@ -5,6 +5,35 @@ require_relative 'signal/signal_typed_size_t'
5
5
  module Tgui
6
6
  class EditBox < ClickableWidget
7
7
 
8
+ class Theme < Widget::Theme
9
+ theme_attr :text_style, :text_styles
10
+ theme_attr :default_text_style, :text_styles
11
+ theme_attr :borders, :outline
12
+ theme_attr :padding, :outline
13
+ theme_attr :caret_width, :float
14
+ theme_attr :text_color, :color
15
+ theme_attr :text_color_disabled, :color
16
+ theme_attr :text_color_focused, :color
17
+ theme_attr :selected_text_color, :color
18
+ theme_attr :selected_text_background_color, :color
19
+ theme_attr :default_text_color, :color
20
+ theme_attr :background_color, :color
21
+ theme_attr :background_color_hover, :color
22
+ theme_attr :background_color_disabled, :color
23
+ theme_attr :background_color_focused, :color
24
+ theme_attr :caret_color, :color
25
+ theme_attr :caret_color_hover, :color
26
+ theme_attr :caret_color_focused, :color
27
+ theme_attr :border_color, :color
28
+ theme_attr :border_color_hover, :color
29
+ theme_attr :border_color_disabled, :color
30
+ theme_attr :border_color_focused, :color
31
+ theme_attr :texture, :texture
32
+ theme_attr :texture_hover, :texture
33
+ theme_attr :texture_disabled, :texture
34
+ theme_attr :texture_focused, :texture
35
+ end
36
+
8
37
  def abi_pack_integer_range *a
9
38
  if a.size == 1
10
39
  if a[0].is_a? Range
@@ -1,8 +1,25 @@
1
1
  require_relative 'child_window'
2
+ require_relative 'list_view'
3
+ require_relative 'edit_box'
4
+ require_relative 'label'
5
+ require_relative 'combo_box'
6
+ require_relative 'button'
2
7
 
3
8
  module Tgui
4
9
  class FileDialog < ChildWindow
5
10
 
11
+ class Theme < ChildWindow::Theme
12
+ theme_comp :list_view, ListView::Theme
13
+ theme_comp :edit_box, EditBox::Theme
14
+ theme_comp :filename_label, Label::Theme
15
+ theme_comp :file_type_combo_box, ComboBox::Theme
16
+ theme_comp :button, Button::Theme
17
+ theme_comp :back_button, Button::Theme
18
+ theme_comp :forward_button, Button::Theme
19
+ theme_comp :up_button, Button::Theme
20
+ theme_attr :arrow_on_navigation_buttons_visible, :boolean
21
+ end
22
+
6
23
  abi_def :selected_paths, nil => (String..) # not empty only in onFileSelected callback
7
24
  abi_attr :path, String
8
25
  abi_attr :filename, String
@@ -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
@@ -84,9 +84,9 @@ module Tgui
84
84
 
85
85
  def add widget, id
86
86
  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
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
90
90
  if direction == :column
91
91
  next_column false
92
92
  else
@@ -2,5 +2,10 @@ require_relative 'container'
2
2
 
3
3
  module Tgui
4
4
  class Group < Container
5
+
6
+ class Theme < Widget::Theme
7
+ theme_attr :padding, :outline
8
+ end
9
+
5
10
  end
6
11
  end
@@ -4,6 +4,16 @@ require_relative 'signal/signal_float'
4
4
  module Tgui
5
5
  class Knob < Widget
6
6
 
7
+ class Theme < Widget::Theme
8
+ theme_attr :borders, :outline
9
+ theme_attr :background_color, :color
10
+ theme_attr :thumb_color, :color
11
+ theme_attr :border_color, :color
12
+ theme_attr :texture_background, :texture
13
+ theme_attr :texture_foreground, :texture
14
+ theme_attr :image_rotation, :float
15
+ end
16
+
7
17
  abi_attr :start, Float, :start_rotation
8
18
  abi_attr :end, Float, :end_rotation
9
19
  abi_attr :min, Float, :minimum
@@ -4,6 +4,20 @@ require_relative 'scrollbar'
4
4
  module Tgui
5
5
  class Label < ClickableWidget
6
6
 
7
+ class Theme < Widget::Theme
8
+ theme_attr :borders, :outline
9
+ theme_attr :padding, :outline
10
+ theme_attr :text_color, :color
11
+ theme_attr :background_color, :color
12
+ theme_attr :border_color, :color
13
+ theme_attr :text_style, :text_styles
14
+ theme_attr :text_outline_color, :color
15
+ theme_attr :text_outline_thickness, :float
16
+ theme_attr :texture_background, :texture
17
+ theme_comp :scrollbar, Scrollbar::Theme
18
+ theme_attr :scrollbar_width, :float
19
+ end
20
+
7
21
  abi_attr :text, String
8
22
  abi_attr :scrollbar_value, Integer
9
23
  abi_attr :auto_size?, Boolean, :get_
@@ -1,15 +1,35 @@
1
1
  require_relative 'widget'
2
+ require_relative 'scrollbar'
2
3
  require_relative 'signal/signal_item'
3
4
  require_relative 'signal/signal_u_int'
4
5
 
5
6
  module Tgui
6
7
  class ListBox < Widget
7
8
 
9
+ class Theme < Widget::Theme
10
+ theme_attr :borders, :outline
11
+ theme_attr :padding, :outline
12
+ theme_attr :text_style, :text_styles
13
+ theme_attr :selected_text_style, :text_styles
14
+ theme_attr :background_color, :color
15
+ theme_attr :background_color_hover, :color
16
+ theme_attr :selected_background_color, :color
17
+ theme_attr :selected_background_color_hover, :color
18
+ theme_attr :text_color, :color
19
+ theme_attr :text_color_hover, :color
20
+ theme_attr :selected_text_color, :color
21
+ theme_attr :selected_text_color_hover, :color
22
+ theme_attr :border_color, :color
23
+ theme_attr :texture_background, :texture
24
+ theme_comp :scrollbar, Scrollbar::Theme
25
+ theme_attr :scrollbar_width, :float
26
+ end
27
+
8
28
  class SignalItem < Tgui::SignalItem
9
29
  def block_caller &b
10
30
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP]) do |str1, str2|
11
31
  id = @widget.abi_unpack_string(str2)
12
- @widget.page.upon! @widget do
32
+ @widget.send! do
13
33
  b.(@widget.self_get_object_by_id(id), @widget)
14
34
  end
15
35
  end
@@ -35,26 +55,22 @@ module Tgui
35
55
  abi_signal :on_scroll, SignalUInt
36
56
  abi_attr :text_alignment, TextAlignment
37
57
 
38
- class Item
39
- def initialize list_box, id
40
- @list_box = list_box
41
- @id = id
42
- end
58
+ class Item < WidgetLike
43
59
 
44
60
  def object=(object)
45
- @list_box.self_objects[@id] = object
61
+ host.self_objects[id] = object
46
62
  end
47
63
 
48
64
  def object
49
- return @list_box.self_objects[@id]
65
+ return host.self_objects[id]
50
66
  end
51
67
 
52
68
  def text=(text)
53
- @list_box._abi_change_item_by_id @id, abi_pack_string(text)
69
+ host._abi_change_item_by_id id, abi_pack_string(text)
54
70
  end
55
71
 
56
72
  def remove
57
- @list_box._abi_remove_item_by_id @id
73
+ host._abi_remove_item_by_id id
58
74
  end
59
75
  end
60
76
 
@@ -64,7 +80,7 @@ module Tgui
64
80
  _abi_add_item abi_pack_string(text), abi_pack_string(id)
65
81
  item = Item.new self, id
66
82
  na[:object] ||= object
67
- upon! item, **na, &b
83
+ item.send! **na, &b
68
84
  end
69
85
 
70
86
  def remove_all
@@ -1,14 +1,37 @@
1
1
  require_relative 'widget'
2
+ require_relative 'scrollbar'
2
3
  require_relative '../convention/widget_like'
3
4
  require_relative 'signal/signal_int'
4
5
 
5
6
  module Tgui
6
7
  class ListView < Widget
7
8
 
9
+ class Theme < Widget::Theme
10
+ theme_attr :borders, :outline
11
+ theme_attr :padding, :outline
12
+ theme_attr :background_color, :color
13
+ theme_attr :background_color_hover, :color
14
+ theme_attr :selected_background_color, :color
15
+ theme_attr :selected_background_color_hover, :color
16
+ theme_attr :text_color, :color
17
+ theme_attr :text_color_hover, :color
18
+ theme_attr :selected_text_color, :color
19
+ theme_attr :selected_text_color_hover, :color
20
+ theme_attr :header_background_color, :color
21
+ theme_attr :header_text_color, :color
22
+ theme_attr :border_color, :color
23
+ theme_attr :separator_color, :color
24
+ theme_attr :grid_lines_color, :color
25
+ theme_attr :texture_header_background, :texture
26
+ theme_attr :texture_background, :texture
27
+ theme_comp :scrollbar, Scrollbar::Theme
28
+ theme_attr :scrollbar_width, :float
29
+ end
30
+
8
31
  class ListViewItemSignal < Tgui::SignalInt
9
32
  def block_caller &b
10
33
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |index|
11
- @widget.page.upon! @widget do
34
+ @widget.send! do
12
35
  b.(@widget.self_objects[index], @widget)
13
36
  end
14
37
  end
@@ -18,7 +41,7 @@ module Tgui
18
41
  class ListViewColumnSignal < Tgui::SignalInt
19
42
  def block_caller &b
20
43
  Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_INT]) do |index|
21
- @widget.page.upon! @widget do
44
+ @widget.send! do
22
45
  b.(@widget.columns[index], @widget)
23
46
  end
24
47
  end
@@ -70,14 +93,14 @@ module Tgui
70
93
  index = _abi_add_column
71
94
  column = Column.new self, index
72
95
  columns << column
73
- upon! column, **na, &b
96
+ column.send! **na, &b
74
97
  end
75
98
 
76
99
  def! :item do |object, **na, &b|
77
100
  self_add_object object, na[:index]
78
101
  item = Item.new self, object
79
102
  na.delete :index
80
- upon! item, **na, &b
103
+ item.send! **na, &b
81
104
  end
82
105
 
83
106
  def items=(items)
@@ -150,7 +173,7 @@ module Tgui
150
173
 
151
174
  def! :grid_lines do | **na, &b|
152
175
  lines = GridLines.new self
153
- upon! lines, **na, &b
176
+ lines.send! **na, &b
154
177
  end
155
178
 
156
179
  def grid_lines=(grid_lines)
@@ -176,7 +199,7 @@ module Tgui
176
199
 
177
200
  def! :header do |**na, &b|
178
201
  header = Header.new self
179
- upon! header, **na, &b
202
+ header.send! **na, &b
180
203
  end
181
204
 
182
205
  def header=(header)
@@ -1,10 +1,27 @@
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
 
5
6
  module Tgui
6
7
  class MenuBar < Widget
7
8
 
9
+ class Theme < Widget::Theme
10
+ theme_attr :background_color, :color
11
+ theme_attr :selected_background_color, :color
12
+ theme_attr :text_color, :color
13
+ theme_attr :selected_text_color, :color
14
+ theme_attr :text_color_disabled, :color
15
+ theme_attr :separator_color, :color
16
+ theme_attr :texture_background, :texture
17
+ theme_attr :texture_item_background, :texture
18
+ theme_attr :texture_selected_item_background, :texture
19
+ theme_attr :distance_to_side, :float
20
+ theme_attr :separator_thickness, :float
21
+ theme_attr :separator_vertical_padding, :float
22
+ theme_attr :separator_side_padding, :float
23
+ end
24
+
8
25
  class ItemPressSignal
9
26
  def initialize menu_bar, path
10
27
  @menu_bar = menu_bar
@@ -13,7 +30,7 @@ module Tgui
13
30
 
14
31
  def connect &b
15
32
  on_press = Fiddle::Closure::BlockCaller.new(0, [0]) do
16
- @menu_bar.page.upon! @menu_bar do
33
+ @menu_bar.send! do
17
34
  b.(@path.last, @path, @menu_bar)
18
35
  end
19
36
  end
@@ -40,57 +57,13 @@ module Tgui
40
57
  end
41
58
  SignalItemHierarchy.fetch_path vector, loader
42
59
  object_path = @widget.self_object_path path
43
- @widget.page.upon! @widget do
60
+ @widget.send! do
44
61
  b.(object_path.last, object_path, @widget)
45
62
  end
46
63
  end
47
64
  end
48
65
  end
49
66
 
50
- class TreeNode
51
- def initialize text
52
- @text = text
53
- @nodes = {}
54
- end
55
-
56
- attr_accessor :text
57
- attr :nodes
58
-
59
- def [](*path, grow: false)
60
- if grow
61
- path.reduce(self){|node, o| node.nodes[o] ||= TreeNode.new(nil) }
62
- else
63
- path.reduce(self){|node, o| node&.nodes[o] }
64
- end
65
- end
66
-
67
- def cut *path, last
68
- self[*path].nodes.delete last
69
- end
70
-
71
- def cut_branches *path
72
- self[*path].nodes = {}
73
- end
74
-
75
- def path_str_to_object *path
76
- object_path = []
77
- path.reduce self do |node, str|
78
- o, node = *node.nodes.find{|k, v| v.text == str }
79
- object_path << o
80
- node
81
- end
82
- object_path
83
- end
84
-
85
- def path_object_to_str *path
86
- str_path = []
87
- path.reduce self do |node, o|
88
- node[o].tap{ str_path << _1.text }
89
- end
90
- str_path
91
- end
92
- end
93
-
94
67
  api_attr :self_tree do
95
68
  TreeNode.new nil
96
69
  end
@@ -106,7 +79,7 @@ module Tgui
106
79
  host._abi_add_menu_item _1, _2
107
80
  end
108
81
  item = Item.new host, item_path
109
- upon! item, **na, &b
82
+ item.send! **na, &b
110
83
  end
111
84
 
112
85
  def! :separator do
@@ -192,7 +165,7 @@ module Tgui
192
165
  self_tree[object, grow: true].text = text
193
166
  _abi_add_menu abi_pack_string(text)
194
167
  item = Menu.new self, object
195
- upon! item, **na, &b
168
+ item.send! **na, &b
196
169
  end
197
170
 
198
171
  def items=(items)