white_gold 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/dll/openal32.dll +0 -0
- data/ext/dll/sfml-audio-2.dll +0 -0
- data/ext/dll/sfml-graphics-2.dll +0 -0
- data/ext/dll/sfml-network-2.dll +0 -0
- data/ext/dll/sfml-system-2.dll +0 -0
- data/ext/dll/sfml-window-2.dll +0 -0
- data/ext/dll/tgui.dll +0 -0
- data/ext/so/libsfml-audio.so +0 -0
- data/ext/so/libsfml-graphics.so +0 -0
- data/ext/so/libsfml-network.so +0 -0
- data/ext/so/libsfml-system.so +0 -0
- data/ext/so/libsfml-window.so +0 -0
- data/ext/so/libtgui.so +0 -0
- data/lib/white_gold/abi/alias.rb +50 -0
- data/lib/white_gold/abi/enum.rb +43 -0
- data/lib/white_gold/abi/extern_object.rb +180 -0
- data/lib/white_gold/abi/interface/interface.rb +114 -0
- data/lib/white_gold/abi/interface/interface_collection_out.rb +29 -0
- data/lib/white_gold/abi/interface/interface_composed_out.rb +28 -0
- data/lib/white_gold/abi/interface/interface_single_out.rb +19 -0
- data/lib/white_gold/abi/packer.rb +28 -0
- data/lib/white_gold/abi/reducer.rb +12 -0
- data/lib/white_gold/abi/unpacker.rb +27 -0
- data/lib/white_gold/convention/api_child.rb +30 -0
- data/lib/white_gold/convention/bang_def.rb +5 -0
- data/lib/white_gold/convention/bang_nest.rb +16 -0
- data/lib/white_gold/convention/bang_nested_caller.rb +48 -0
- data/lib/white_gold/convention/bool_property.rb +13 -0
- data/lib/white_gold/convention/boolean.rb +2 -0
- data/lib/white_gold/convention/club.rb +26 -0
- data/lib/white_gold/convention/container_widgets.rb +181 -0
- data/lib/white_gold/convention/page.rb +96 -0
- data/lib/white_gold/convention/proc_method_factory.rb +22 -0
- data/lib/white_gold/convention/unit.rb +22 -0
- data/lib/white_gold/convention/widget_like.rb +146 -0
- data/lib/white_gold/dsl/backend_gui.rb +37 -0
- data/lib/white_gold/dsl/bitmap_button.rb +11 -0
- data/lib/white_gold/dsl/box_layout.rb +47 -0
- data/lib/white_gold/dsl/box_layout_ratios.rb +13 -0
- data/lib/white_gold/dsl/button.rb +10 -0
- data/lib/white_gold/dsl/button_base.rb +18 -0
- data/lib/white_gold/dsl/chat_box.rb +65 -0
- data/lib/white_gold/dsl/checkbox.rb +6 -0
- data/lib/white_gold/dsl/child_window.rb +47 -0
- data/lib/white_gold/dsl/clickable_widget.rb +15 -0
- data/lib/white_gold/dsl/color.rb +124 -0
- data/lib/white_gold/dsl/color_picker.rb +12 -0
- data/lib/white_gold/dsl/combo_box.rb +135 -0
- data/lib/white_gold/dsl/container.rb +95 -0
- data/lib/white_gold/dsl/edit_box.rb +38 -0
- data/lib/white_gold/dsl/file_dialog.rb +86 -0
- data/lib/white_gold/dsl/font.rb +23 -0
- data/lib/white_gold/dsl/grid.rb +131 -0
- data/lib/white_gold/dsl/group.rb +6 -0
- data/lib/white_gold/dsl/gui.rb +16 -0
- data/lib/white_gold/dsl/horizontal_layout.rb +6 -0
- data/lib/white_gold/dsl/horizontal_wrap.rb +6 -0
- data/lib/white_gold/dsl/knob.rb +16 -0
- data/lib/white_gold/dsl/label.rb +21 -0
- data/lib/white_gold/dsl/list_box.rb +125 -0
- data/lib/white_gold/dsl/list_view.rb +239 -0
- data/lib/white_gold/dsl/menu_bar.rb +252 -0
- data/lib/white_gold/dsl/message_box.rb +90 -0
- data/lib/white_gold/dsl/outline.rb +52 -0
- data/lib/white_gold/dsl/panel.rb +16 -0
- data/lib/white_gold/dsl/panel_list_box.rb +83 -0
- data/lib/white_gold/dsl/picture.rb +12 -0
- data/lib/white_gold/dsl/progress_bar.rb +19 -0
- data/lib/white_gold/dsl/radio_button.rb +18 -0
- data/lib/white_gold/dsl/radio_button_group.rb +14 -0
- data/lib/white_gold/dsl/range_slider.rb +15 -0
- data/lib/white_gold/dsl/rich_text_label.rb +6 -0
- data/lib/white_gold/dsl/scrollable_panel.rb +53 -0
- data/lib/white_gold/dsl/scrollbar.rb +28 -0
- data/lib/white_gold/dsl/separator_line.rb +6 -0
- data/lib/white_gold/dsl/signal/global_signal.rb +33 -0
- data/lib/white_gold/dsl/signal/signal.rb +44 -0
- data/lib/white_gold/dsl/signal/signal_animation_type.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_bool.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_color.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_float.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_int.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_item.rb +6 -0
- data/lib/white_gold/dsl/signal/signal_item_hierarchy.rb +9 -0
- data/lib/white_gold/dsl/signal/signal_panel_list_box_item.rb +7 -0
- data/lib/white_gold/dsl/signal/signal_pointer.rb +15 -0
- data/lib/white_gold/dsl/signal/signal_range.rb +15 -0
- data/lib/white_gold/dsl/signal/signal_show_effect.rb +17 -0
- data/lib/white_gold/dsl/signal/signal_string.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_typed_int_bool_ptr.rb +15 -0
- data/lib/white_gold/dsl/signal/signal_typed_size_t.rb +6 -0
- data/lib/white_gold/dsl/signal/signal_u_int.rb +16 -0
- data/lib/white_gold/dsl/signal/signal_vector2f.rb +14 -0
- data/lib/white_gold/dsl/slider.rb +26 -0
- data/lib/white_gold/dsl/spin_button.rb +24 -0
- data/lib/white_gold/dsl/spin_control.rb +15 -0
- data/lib/white_gold/dsl/subwidget_container.rb +9 -0
- data/lib/white_gold/dsl/tab_container.rb +121 -0
- data/lib/white_gold/dsl/tabs.rb +91 -0
- data/lib/white_gold/dsl/text_area.rb +34 -0
- data/lib/white_gold/dsl/texture.rb +53 -0
- data/lib/white_gold/dsl/theme/boolean_attribute.rb +13 -0
- data/lib/white_gold/dsl/theme/button_theme.rb +19 -0
- data/lib/white_gold/dsl/theme/chat_box_theme.rb +16 -0
- data/lib/white_gold/dsl/theme/child_window_theme.rb +25 -0
- data/lib/white_gold/dsl/theme/color_attribute.rb +13 -0
- data/lib/white_gold/dsl/theme/color_picker_theme.rb +14 -0
- data/lib/white_gold/dsl/theme/combo_box_theme.rb +33 -0
- data/lib/white_gold/dsl/theme/common_renderer.rb +7 -0
- data/lib/white_gold/dsl/theme/edit_box_theme.rb +34 -0
- data/lib/white_gold/dsl/theme/file_dialog_theme.rb +22 -0
- data/lib/white_gold/dsl/theme/float_attribute.rb +13 -0
- data/lib/white_gold/dsl/theme/group_theme.rb +9 -0
- data/lib/white_gold/dsl/theme/knob_theme.rb +15 -0
- data/lib/white_gold/dsl/theme/label_theme.rb +20 -0
- data/lib/white_gold/dsl/theme/list_box_theme.rb +25 -0
- data/lib/white_gold/dsl/theme/list_view_theme.rb +27 -0
- data/lib/white_gold/dsl/theme/menu_bar_theme.rb +21 -0
- data/lib/white_gold/dsl/theme/message_box_theme.rb +11 -0
- data/lib/white_gold/dsl/theme/outline_attribute.rb +13 -0
- data/lib/white_gold/dsl/theme/progress_bar_theme.rb +19 -0
- data/lib/white_gold/dsl/theme/radio_button_theme.rb +30 -0
- data/lib/white_gold/dsl/theme/scrollbar_theme.rb +24 -0
- data/lib/white_gold/dsl/theme/separator_line_theme.rb +9 -0
- data/lib/white_gold/dsl/theme/slider_theme.rb +20 -0
- data/lib/white_gold/dsl/theme/spin_button_theme.rb +19 -0
- data/lib/white_gold/dsl/theme/tabs_theme.rb +29 -0
- data/lib/white_gold/dsl/theme/text_area_theme.rb +22 -0
- data/lib/white_gold/dsl/theme/text_styles_attribute.rb +13 -0
- data/lib/white_gold/dsl/theme/texture_attribute.rb +17 -0
- data/lib/white_gold/dsl/theme/theme_attributed.rb +51 -0
- data/lib/white_gold/dsl/theme/theme_component.rb +23 -0
- data/lib/white_gold/dsl/theme/tree_view_theme.rb +26 -0
- data/lib/white_gold/dsl/theme/widget_theme.rb +12 -0
- data/lib/white_gold/dsl/theme.rb +144 -0
- data/lib/white_gold/dsl/toggle_button.rb +10 -0
- data/lib/white_gold/dsl/tool_tip.rb +21 -0
- data/lib/white_gold/dsl/tree_view.rb +186 -0
- data/lib/white_gold/dsl/util.rb +17 -0
- data/lib/white_gold/dsl/vertical_layout.rb +6 -0
- data/lib/white_gold/dsl/widget.rb +279 -0
- data/lib/white_gold/dsl/window.rb +16 -0
- data/lib/white_gold/generated/tgui-abi-loader.gf.rb +1813 -0
- data/lib/white_gold/library/theme/light.rb +111 -0
- data/lib/white_gold/master.rb +170 -0
- data/lib/white_gold/path/kernel.path.rb +3 -0
- data/lib/white_gold/path/numeric.path.rb +9 -0
- data/lib/white_gold/path/object.path.rb +22 -0
- data/lib/white_gold/path/string.path.rb +5 -0
- data/lib/white_gold/tgui-abi.rb +255 -0
- data/lib/white_gold/tgui-config.rb +20 -0
- data/lib/white_gold.rb +47 -0
- metadata +209 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'widget_theme'
|
2
|
+
require_relative 'scrollbar_theme'
|
3
|
+
|
4
|
+
module Tgui
|
5
|
+
class TreeViewTheme < WidgetTheme
|
6
|
+
|
7
|
+
theme_attr :borders, :outline
|
8
|
+
theme_attr :padding, :outline
|
9
|
+
theme_attr :background_color, :color
|
10
|
+
theme_attr :background_color_hover, :color
|
11
|
+
theme_attr :selected_background_color, :color
|
12
|
+
theme_attr :selected_background_color_hover, :color
|
13
|
+
theme_attr :border_color, :color
|
14
|
+
theme_attr :text_color, :color
|
15
|
+
theme_attr :text_color_hover, :color
|
16
|
+
theme_attr :selected_text_color, :color
|
17
|
+
theme_attr :selected_text_color_hover, :color
|
18
|
+
theme_comp :scrollbar, ScrollbarTheme
|
19
|
+
theme_attr :scrollbar_width, :float
|
20
|
+
theme_attr :texture_background, :texture
|
21
|
+
theme_attr :texture_branch_expanded, :texture
|
22
|
+
theme_attr :texture_branch_collapsed, :texture
|
23
|
+
theme_attr :texture_leaf, :texture
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require_relative '../abi/extern_object'
|
3
|
+
require_relative '../convention/bang_nest'
|
4
|
+
Dir.each_child File.dirname(__FILE__) + "/theme" do |filename|
|
5
|
+
require_relative "theme/#{filename}"
|
6
|
+
end
|
7
|
+
|
8
|
+
module Tgui
|
9
|
+
class Theme < ExternObject
|
10
|
+
include BangNest
|
11
|
+
extend ThemeAttributed
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
def default=(theme)
|
16
|
+
_abi_set_default Util.expand_path(theme)
|
17
|
+
end
|
18
|
+
|
19
|
+
def default
|
20
|
+
self.new pointer: _abi_get_default
|
21
|
+
end
|
22
|
+
|
23
|
+
def finalizer pointer
|
24
|
+
_abi_finalizer pointer
|
25
|
+
end
|
26
|
+
|
27
|
+
def loadpath seed
|
28
|
+
case seed
|
29
|
+
when :light then File.dirname(File.dirname(__FILE__)) + '/library/theme/light.rb'
|
30
|
+
when String then Util.expand_path(seed)
|
31
|
+
else raise "#{seed} not available"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def api_attr name, &init
|
36
|
+
define_method "#{name}=" do |value|
|
37
|
+
@@data_storage[Theme.get_unshared(@pointer).to_i][name] = value
|
38
|
+
end
|
39
|
+
|
40
|
+
init ||= proc{ nil }
|
41
|
+
|
42
|
+
define_method name do
|
43
|
+
@@data_storage[Theme.get_unshared(@pointer).to_i][name] ||= init.()
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
abi_static :get_unshared
|
49
|
+
|
50
|
+
api_attr :attributes do
|
51
|
+
{}
|
52
|
+
end
|
53
|
+
api_attr :next_renderer_id do
|
54
|
+
"_0"
|
55
|
+
end
|
56
|
+
|
57
|
+
attr :source
|
58
|
+
def source=(path)
|
59
|
+
@source = Util.expand_path(path)
|
60
|
+
end
|
61
|
+
|
62
|
+
def reset_attributes
|
63
|
+
self.attributes = {}
|
64
|
+
end
|
65
|
+
|
66
|
+
def! :custom do |comp, seed, **na, &b|
|
67
|
+
self.next_renderer_id = renderer_id = next_renderer_id.next
|
68
|
+
send("#{comp}!", renderer_id, seed, **na, &b)
|
69
|
+
self_commit
|
70
|
+
renderer_id
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
theme_attr :text_color, :color
|
75
|
+
theme_attr :text_color_hover, :color
|
76
|
+
theme_attr :text_color_disabled, :color
|
77
|
+
theme_attr :background_color, :color
|
78
|
+
theme_attr :background_color_hover, :color
|
79
|
+
theme_attr :background_color_disabled, :color
|
80
|
+
theme_attr :selected_text_color, :color
|
81
|
+
theme_attr :selected_text_color_hover, :color
|
82
|
+
theme_attr :selected_background_color, :color
|
83
|
+
theme_attr :selected_background_color_hover, :color
|
84
|
+
theme_attr :border_color, :color
|
85
|
+
theme_attr :borders, :outline
|
86
|
+
theme_attr :scrollbar_width, :float
|
87
|
+
theme_attr :arrow_background_color, :color
|
88
|
+
theme_attr :arrow_background_color_hover, :color
|
89
|
+
theme_attr :arrow_background_color_disabled, :color
|
90
|
+
theme_attr :arrow_color, :color
|
91
|
+
theme_attr :arrow_color_hover, :color
|
92
|
+
theme_attr :arrow_color_disabled, :color
|
93
|
+
|
94
|
+
theme_comp :button, ButtonTheme
|
95
|
+
theme_comp :chat_box, ChatBoxTheme
|
96
|
+
theme_comp :child_window, ChildWindowTheme
|
97
|
+
theme_comp :color_picker, ColorPickerTheme
|
98
|
+
theme_comp :combobox, ComboBoxTheme, "ComboBox"
|
99
|
+
theme_comp :editbox, EditBoxTheme, "EditBox"
|
100
|
+
theme_comp :file_dialog, FileDialogTheme
|
101
|
+
theme_comp :group, GroupTheme
|
102
|
+
theme_comp :knob, KnobTheme
|
103
|
+
theme_comp :label, LabelTheme
|
104
|
+
theme_comp :listbox, ListBoxTheme, "ListBox"
|
105
|
+
theme_comp :list_view, ListViewTheme
|
106
|
+
theme_comp :menu, MenuBarTheme, "MenuBar"
|
107
|
+
theme_comp :message_box, MessageBoxTheme
|
108
|
+
theme_comp :progress_bar, ProgressBarTheme
|
109
|
+
theme_comp :radio_button, RadioButtonTheme
|
110
|
+
theme_comp :scrollbar, ScrollbarTheme
|
111
|
+
theme_comp :separator, SeparatorLineTheme
|
112
|
+
theme_comp :slider, SliderTheme
|
113
|
+
theme_comp :spin_button, SpinButtonTheme
|
114
|
+
theme_comp :tabs, TabsTheme
|
115
|
+
theme_comp :text_area, TextAreaTheme
|
116
|
+
theme_comp :tree_view, TreeViewTheme
|
117
|
+
theme_comp :widget, WidgetTheme
|
118
|
+
|
119
|
+
def self_commit custom_rendered = nil
|
120
|
+
if attributes.size > 0
|
121
|
+
file = Tempfile.new
|
122
|
+
begin
|
123
|
+
if @source
|
124
|
+
File.foreach @source do |line|
|
125
|
+
file << line
|
126
|
+
end
|
127
|
+
end
|
128
|
+
attributes.each do |k, v|
|
129
|
+
file << v.to_theme << "\n"
|
130
|
+
end
|
131
|
+
file.close
|
132
|
+
_abi_load file.path
|
133
|
+
ensure
|
134
|
+
file.close!
|
135
|
+
end
|
136
|
+
else
|
137
|
+
_abi_load @source if @source
|
138
|
+
end
|
139
|
+
custom_rendered&.each do |widget, renderer|
|
140
|
+
widget.self_renderer = renderer
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../abi/extern_object'
|
2
|
+
|
3
|
+
module Tgui
|
4
|
+
class ToolTip < ExternObject
|
5
|
+
extend Packer
|
6
|
+
|
7
|
+
attr_accessor :page
|
8
|
+
|
9
|
+
abi_static :initial_delay=, :set_
|
10
|
+
abi_static :initial_delay, :get_
|
11
|
+
abi_static :distance_to_mouse=, :set_
|
12
|
+
|
13
|
+
def self.distance_to_mouse
|
14
|
+
abi_unpack_vector2f _abi_get_distance_to_mouse
|
15
|
+
end
|
16
|
+
|
17
|
+
abi_static :show_on_disabled=, :set_show_on_disabled_widgets
|
18
|
+
abi_static :show_on_disabled?, :get_show_on_disabled_widgets
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require_relative 'widget'
|
2
|
+
require_relative 'signal/signal_item_hierarchy'
|
3
|
+
|
4
|
+
module Tgui
|
5
|
+
class TreeView < Widget
|
6
|
+
|
7
|
+
class SignalItemHierarchy < Tgui::SignalItemHierarchy
|
8
|
+
def block_caller &b
|
9
|
+
Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |vector|
|
10
|
+
path = []
|
11
|
+
loader = Fiddle::Closure::BlockCaller.new(0, [Fiddle::TYPE_VOIDP]) do |str|
|
12
|
+
path << @widget.abi_unpack_string(str)
|
13
|
+
end
|
14
|
+
SignalItemHierarchy.fetch_path vector, loader
|
15
|
+
object_path = @widget.self_tree.path_str_to_object path
|
16
|
+
@widget.page.upon! @widget do
|
17
|
+
b.(object_path.last, object_path, @widget)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class TreeNode
|
24
|
+
def initialize object
|
25
|
+
@object = object
|
26
|
+
@nodes = {}
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_accessor :object
|
30
|
+
attr :nodes
|
31
|
+
|
32
|
+
def [](*path, grow: false)
|
33
|
+
if grow
|
34
|
+
path.reduce(self){|node, str| node.nodes[str] ||= TreeNode.new nil }
|
35
|
+
else
|
36
|
+
path.reduce(self){|node, str| node&.nodes[str] }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def cut *path, last
|
41
|
+
self[*path].nodes.delete last
|
42
|
+
end
|
43
|
+
|
44
|
+
def path_str_to_object path
|
45
|
+
objects = []
|
46
|
+
path.reduce(self){|node, str| node[str].tap{|n| objects << n.object } }
|
47
|
+
objects
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
api_attr :self_tree do
|
52
|
+
TreeNode.new nil
|
53
|
+
end
|
54
|
+
api_attr :format do
|
55
|
+
:to_s
|
56
|
+
end
|
57
|
+
|
58
|
+
class Item < WidgetLike
|
59
|
+
|
60
|
+
alias_method :path, :id
|
61
|
+
|
62
|
+
def self_path_block &b
|
63
|
+
host.self_path_block path, &b
|
64
|
+
end
|
65
|
+
|
66
|
+
def expanded=(expanded)
|
67
|
+
self_path_block do
|
68
|
+
expanded ? host._abi_expand(_1, _2) : host._abi_collapse(_1, _2)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def collapsed=(collapsed)
|
73
|
+
self.expanded = !collapsed
|
74
|
+
end
|
75
|
+
|
76
|
+
def selected=(selected)
|
77
|
+
if selected
|
78
|
+
self_path_block do
|
79
|
+
host.select_item(_1, _2)
|
80
|
+
end
|
81
|
+
else
|
82
|
+
selected_item = host.selected_item
|
83
|
+
if selected_item.path == path
|
84
|
+
host.deselect_item
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def remove
|
90
|
+
self_path_block do
|
91
|
+
host._abi_remove_item _1, _2, abi_pack_boolean(false)
|
92
|
+
host.self_tree.cut *_3
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def! :item do |object, **na, &b|
|
97
|
+
host.self_add_item path, object, **na, &b
|
98
|
+
end
|
99
|
+
|
100
|
+
def [](*path_end)
|
101
|
+
Item.new host, [*path, *path_end]
|
102
|
+
end
|
103
|
+
|
104
|
+
def object
|
105
|
+
path.last
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def! :item do |object, **na, &b|
|
110
|
+
self_add_item [], object, **na, &b
|
111
|
+
end
|
112
|
+
|
113
|
+
def items=(items)
|
114
|
+
self_items items
|
115
|
+
end
|
116
|
+
|
117
|
+
def items
|
118
|
+
self_collect_items self_tree
|
119
|
+
end
|
120
|
+
|
121
|
+
def [](*path)
|
122
|
+
Item.new self, path
|
123
|
+
end
|
124
|
+
|
125
|
+
def remove *path
|
126
|
+
self[*path].remove
|
127
|
+
end
|
128
|
+
|
129
|
+
def selected=(path)
|
130
|
+
self[*path].selected = true
|
131
|
+
end
|
132
|
+
|
133
|
+
def selected_item
|
134
|
+
path = self_selected_item_path
|
135
|
+
path.empty? ? nil : Item.new(self, self_tree.path_str_to_object(path))
|
136
|
+
end
|
137
|
+
|
138
|
+
def selected
|
139
|
+
selected_item&.object
|
140
|
+
end
|
141
|
+
|
142
|
+
abi_def :expand_all
|
143
|
+
abi_def :collapse_all
|
144
|
+
abi_def :deselect
|
145
|
+
abi_def :remove_all
|
146
|
+
abi_attr :item_height, Integer
|
147
|
+
abi_attr :vertical_scrollbar_value, Integer
|
148
|
+
abi_attr :horizontal_scrollbar_value, Integer
|
149
|
+
abi_signal :on_item_select, SignalItemHierarchy
|
150
|
+
abi_signal :on_double_click, SignalItemHierarchy
|
151
|
+
abi_signal :on_expand, SignalItemHierarchy
|
152
|
+
abi_signal :on_collapse, SignalItemHierarchy
|
153
|
+
abi_signal :on_right_click, SignalItemHierarchy
|
154
|
+
|
155
|
+
# internal
|
156
|
+
|
157
|
+
abi_def :self_selected_item_path, :get_selected_item, nil => (String..)
|
158
|
+
|
159
|
+
def self_items items, path = []
|
160
|
+
items.each do |k, v|
|
161
|
+
self_add_item path, k
|
162
|
+
self_items v, [*path, k] if v.is_a? Hash
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def self_collect_items tree_node
|
167
|
+
tree_node.nodes.map{|k, v| [v.object, self_collect_items(v)]}.to_h
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
def self_add_item path, object, **na, &b
|
172
|
+
new_path = [*path, object]
|
173
|
+
self_path_block new_path do
|
174
|
+
_abi_add_item _1, _2, abi_pack_boolean(true)
|
175
|
+
self_tree[*_3, grow: true].object = object
|
176
|
+
end
|
177
|
+
item = Item.new self, new_path
|
178
|
+
upon! item, **na, &b
|
179
|
+
end
|
180
|
+
|
181
|
+
def self_path_block path, &b
|
182
|
+
path = path.map(&format)
|
183
|
+
b.(*abi_pack(String.., *path), path)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../abi/extern_object'
|
2
|
+
|
3
|
+
module Tgui
|
4
|
+
class Util < ExternObject
|
5
|
+
|
6
|
+
abi_static :free
|
7
|
+
|
8
|
+
def self.expand_path path, exist: true
|
9
|
+
if !path.match?(/^\w:\//) # TODO UNIX
|
10
|
+
path = File.expand_path(path, File.dirname(ENV["OCRAN_EXECUTABLE"] || $0))
|
11
|
+
end
|
12
|
+
raise "File #{path} not found" if exist && !File.exist?(path)
|
13
|
+
path
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,279 @@
|
|
1
|
+
require_relative '../abi/extern_object'
|
2
|
+
require_relative '../convention/bang_nested_caller'
|
3
|
+
require_relative '../convention/unit'
|
4
|
+
require_relative '../convention/widget_like'
|
5
|
+
require_relative '../convention/api_child'
|
6
|
+
require_relative 'theme/widget_theme'
|
7
|
+
require_relative 'color'
|
8
|
+
require_relative 'outline'
|
9
|
+
require_relative 'texture'
|
10
|
+
require_relative 'signal/signal'
|
11
|
+
require_relative 'signal/signal_vector2f'
|
12
|
+
require_relative 'signal/signal_show_effect'
|
13
|
+
require_relative 'signal/signal_animation_type'
|
14
|
+
require_relative 'tool_tip'
|
15
|
+
|
16
|
+
module Tgui
|
17
|
+
class Widget < ExternObject
|
18
|
+
include BangNestedCaller
|
19
|
+
extend BangDef
|
20
|
+
|
21
|
+
attr_accessor :page
|
22
|
+
|
23
|
+
def window
|
24
|
+
page.window
|
25
|
+
end
|
26
|
+
|
27
|
+
abi_attr :text_size, Integer
|
28
|
+
abi_attr :enabled?
|
29
|
+
|
30
|
+
def! :disabled do |disabled = true|
|
31
|
+
self.enabled = !disabled
|
32
|
+
end
|
33
|
+
|
34
|
+
def theme_comp
|
35
|
+
:widget
|
36
|
+
end
|
37
|
+
|
38
|
+
def! :renderer do |seed = VOID, **na, &b|
|
39
|
+
seed = page.custom_renderers[self] if seed == VOID
|
40
|
+
if !na.empty? || b
|
41
|
+
upon! page.theme do
|
42
|
+
seed = custom! theme_comp, seed, **na, &b
|
43
|
+
end
|
44
|
+
page.custom_renderers[self] = seed
|
45
|
+
elsif !seed
|
46
|
+
page.custom_renderers.delete self
|
47
|
+
else
|
48
|
+
page.custom_renderers[self] = seed
|
49
|
+
end
|
50
|
+
self.self_renderer = seed
|
51
|
+
end
|
52
|
+
|
53
|
+
def renderer=(renderer)
|
54
|
+
case renderer
|
55
|
+
when Hash
|
56
|
+
api_bang_renderer **renderer
|
57
|
+
when Proc
|
58
|
+
api_bang_renderer &renderer
|
59
|
+
else
|
60
|
+
page.custom_renderers[self] = renderer
|
61
|
+
self.self_renderer = renderer
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
abi_def :self_renderer=, :set_renderer, proc.self_renderer => nil
|
66
|
+
|
67
|
+
abi_attr :focused?
|
68
|
+
abi_attr :focusable?
|
69
|
+
abi_signal :on_position_change, Tgui::SignalVector2f
|
70
|
+
abi_signal :on_size_change, Tgui::SignalVector2f
|
71
|
+
abi_signal :on_focus, Tgui::Signal
|
72
|
+
abi_signal :on_unfocus, Tgui::Signal
|
73
|
+
abi_signal :on_mouse_enter, Tgui::Signal
|
74
|
+
abi_signal :on_mouse_leave, Tgui::Signal
|
75
|
+
abi_signal :on_show_effect_finish, Tgui::SignalShowEffect
|
76
|
+
abi_signal :on_animation_finish, Tgui::SignalAnimationType
|
77
|
+
abi_attr :position, "PositionLayout"
|
78
|
+
abi_def :absolute_position, :get_, nil => "PositionLayout"
|
79
|
+
abi_attr :size, "SizeLayout"
|
80
|
+
abi_def :full_size, :get_, nil => "SizeLayout"
|
81
|
+
abi_def :height=, :set_, "SingleSizeLayout" => nil
|
82
|
+
|
83
|
+
def height
|
84
|
+
size[1]
|
85
|
+
end
|
86
|
+
|
87
|
+
abi_def :width=, :set_, "SingleSizeLayout" => nil
|
88
|
+
|
89
|
+
def width
|
90
|
+
size[0]
|
91
|
+
end
|
92
|
+
|
93
|
+
abi_def :can_gain_focus?, :can_gain_focus, nil => Boolean
|
94
|
+
abi_def :container?, nil => Boolean
|
95
|
+
|
96
|
+
def! :tooltip do |*a, **na, &b|
|
97
|
+
if block_given?
|
98
|
+
tooltip = ToolTip.new
|
99
|
+
tooltip.page = page
|
100
|
+
upon! tooltip, **na, &b
|
101
|
+
_abi_set_tool_tip tooltip.widget if tooltip.widget
|
102
|
+
else
|
103
|
+
widget = _abi_get_tool_tip
|
104
|
+
return nil if widget.null?
|
105
|
+
tooltip = ToolTip.new
|
106
|
+
tooltip.widget = widget
|
107
|
+
return tooltip
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
abi_attr :mouse_cursor, CursorType
|
112
|
+
abi_def :draggable?, :is_widget_, nil => Boolean
|
113
|
+
abi_def :mouse_down?, nil => Boolean
|
114
|
+
|
115
|
+
abi_enum "ShowEffectType", :fade, :scale, :slide_to_right, :slide_to_left, :slide_to_bottom,
|
116
|
+
:slide_to_top, slide_from_left: :slide_to_right, slide_from_right: :slide_to_left,
|
117
|
+
slide_from_top: :slide_to_bottom, slide_from_bottom: :slide_to_top
|
118
|
+
|
119
|
+
def visible=(a)
|
120
|
+
if a.is_a? Array
|
121
|
+
if a[0]
|
122
|
+
show *a[1..]
|
123
|
+
else
|
124
|
+
hide *a[1..]
|
125
|
+
end
|
126
|
+
else
|
127
|
+
_abi_set_visible abi_pack_boolean(a)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
abi_def :visible?, nil => Boolean
|
132
|
+
|
133
|
+
def show effect = nil, duration = 1000
|
134
|
+
if effect
|
135
|
+
_abi_show_with_effect abi_pack(ShowEffectType, effect), abi_pack_integer(duration)
|
136
|
+
else
|
137
|
+
_abi_set_visible 1
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def hide effect = nil, duration = 1000
|
142
|
+
if effect
|
143
|
+
_abi_hide_with_effect abi_pack(ShowEffectType, effect), abi_pack_integer(duration)
|
144
|
+
else
|
145
|
+
_abi_set_visible 0
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def pack_animation_time o
|
150
|
+
o ? o.to_i : 1000
|
151
|
+
end
|
152
|
+
|
153
|
+
abi_def :move, :move_with_animation, ["SizeLayout", :pack_animation_time] => nil
|
154
|
+
abi_def :resize, :resize_with_animation, ["PositionLayout", :pack_animation_time] => nil
|
155
|
+
|
156
|
+
abi_enum "AnimationType", :move, :resize, :opacity
|
157
|
+
|
158
|
+
abi_def :finish_animations, :finish_all_animations
|
159
|
+
abi_def :front, :move_to_
|
160
|
+
abi_def :back, :move_to_
|
161
|
+
|
162
|
+
abi_enum "KeyCode", nil, :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k,
|
163
|
+
:l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z,
|
164
|
+
:num0, :num1, :num2, :num3, :num4, :num5, :num6, :num7, :num8, :num9,
|
165
|
+
:escape, :left_control, :left_shift, :left_alt, :left_system,
|
166
|
+
:right_control, :right_shift, :right_alt, :right_system,
|
167
|
+
:menu, :left_bracket, :right_bracket, :semicolon, :comma,
|
168
|
+
:period, :quote, :slash, :backslash, :tilde, :equal, :minus,
|
169
|
+
:space, :enter, :backspace, :tab, :page_up, :page_down, :end,
|
170
|
+
:home, :insert, :delete, :add, :substract, :multiply, :divide,
|
171
|
+
:left, :right, :up, :down, :numpad0, :numpad1, :numpad2, :numpad3,
|
172
|
+
:numpad4, :numpad5, :numpad6, :numpad7, :numpad8, :numpad9,
|
173
|
+
:f1, :f2, :f3, :f4, :f5, :f6, :f7, :f8, :f9, :f10, :f11, :f12,
|
174
|
+
:f13, :f14, :f15, :pause
|
175
|
+
|
176
|
+
class Robot < WidgetLike
|
177
|
+
def initialize widget
|
178
|
+
super(widget, nil)
|
179
|
+
end
|
180
|
+
|
181
|
+
abi_def :mouse_move, :mouse_moved, [Float, Float] => nil
|
182
|
+
|
183
|
+
def mouse_press x, y, down: false
|
184
|
+
host._abi_left_mouse_pressed abi_pack_float(x), abi_pack_float(y)
|
185
|
+
mouse_release x, y if !down
|
186
|
+
end
|
187
|
+
|
188
|
+
abi_def :mouse_release, :left_mouse_released, [Float, Float] => nil
|
189
|
+
abi_def :right_mouse_press, :right_mouse_pressed, [Float, Float] => nil
|
190
|
+
abi_def :right_mouse_release, :right_mouse_released, [Float, Float] => nil
|
191
|
+
|
192
|
+
def key_press key, alt: false, control: false, shift: false, system: false
|
193
|
+
host._abi_key_pressed abi_pack(KeyCode, key),
|
194
|
+
abi_pack_boolean(alt),
|
195
|
+
abi_pack_boolean(control),
|
196
|
+
abi_pack_boolean(shift),
|
197
|
+
abi_pack_boolean(system)
|
198
|
+
end
|
199
|
+
|
200
|
+
def text text
|
201
|
+
text.each_codepoint do |cp|
|
202
|
+
host._abi_text_entered abi_pack_integer(cp)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def scroll delta, x, y, touch = false
|
207
|
+
host._abi_scrolled abi_pack_float(delta), abi_pack_float(x), abi_pack_float(y), abi_pack_boolean(touch)
|
208
|
+
end
|
209
|
+
|
210
|
+
abi_def :tooltip, :ask_toop_tip, [Float, Float] => nil
|
211
|
+
end
|
212
|
+
|
213
|
+
def! :robot do |**na, &b|
|
214
|
+
robot = Robot.new self
|
215
|
+
upon! robot, **na, &b if block_given?
|
216
|
+
robot
|
217
|
+
end
|
218
|
+
|
219
|
+
def flags=(flags)
|
220
|
+
flags.each do |f|
|
221
|
+
send("#{f}=", true)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def self.api_attr name, &init
|
226
|
+
define_method "#{name}=" do |value|
|
227
|
+
@@data_storage[Widget.get_unshared(@pointer).to_i][name] = value
|
228
|
+
end
|
229
|
+
|
230
|
+
init ||= proc{ nil }
|
231
|
+
|
232
|
+
define_method name do
|
233
|
+
@@data_storage[Widget.get_unshared(@pointer).to_i][name] ||= init.()
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
def respond_to? name
|
239
|
+
super || bang_respond_to?(name)
|
240
|
+
end
|
241
|
+
|
242
|
+
def method_missing name, *a, **na, &b
|
243
|
+
if name.end_with? "!"
|
244
|
+
bang_method_missing name, *a, **na, &b
|
245
|
+
else super
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def self_cast_up widget, type = nil, equip: true
|
250
|
+
return nil if widget.null?
|
251
|
+
type = abi_unpack_string(Widget.get_type widget) if !type
|
252
|
+
casted = Tgui.const_get(type).new pointer: widget
|
253
|
+
equip_child_widget casted if equip
|
254
|
+
casted
|
255
|
+
end
|
256
|
+
|
257
|
+
abi_static :get_type
|
258
|
+
abi_static :get_unshared
|
259
|
+
|
260
|
+
class << self
|
261
|
+
include ApiChild
|
262
|
+
|
263
|
+
def self_renderer widget, renderer
|
264
|
+
case renderer
|
265
|
+
when Module
|
266
|
+
renderer.name.split("::").last
|
267
|
+
when nil, false, VOID
|
268
|
+
self_renderer widget, widget.class
|
269
|
+
else
|
270
|
+
renderer.to_s
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def finalizer pointer
|
275
|
+
_abi_finalizer pointer
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|