libui 0.0.1.alpha → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26cb6f0a4c335c4c9f931abf064dbffff73fb8243e2220ccc6b592218bd29582
4
- data.tar.gz: 2ef6c15d482a526f8526c69b7594e3623a962de67be653bf141f38755606072a
3
+ metadata.gz: f0214c682062d1e669d2ec2df579d91466b2d0330205231d00734e3d9b21fc57
4
+ data.tar.gz: 2bce2e4f6edf26bd2442e7205ef10ad59529f1e16f2a88aa0a282cb61d623ced
5
5
  SHA512:
6
- metadata.gz: 2628a7dc6419399749a04384f211dafafa135917a54b98578b400c666d552cb698a5177a2bce5b6f5af4ce19c7ca982f72a44096f25946703220a18ec764fbf2
7
- data.tar.gz: 373ded59492ba9268635c96f0232f00a2c82f42f96c96e57d11ad54af357bc34170ab9cd66249f8937983ac20aa0a70e3dba4626f7009b88b97fd17de7013635
6
+ metadata.gz: f700b08bb46f282b7298f7530bbbade2a59fcde144e54af97bb01a1766a98b3a133b10e064cd62a69621e2d61ff9d587bff17d850f96bb23b4e5c2ee101f97a7
7
+ data.tar.gz: 8571472b2ceb6fa2cd5d6627fce64c896e2ae651012fd8d949f9a94a6cf70dc48df6af7f379652c956b3b1e5e6725fb14465d616abdae776e9ec635c0c4150f9
data/README.md CHANGED
@@ -1,19 +1,122 @@
1
1
  # libui
2
+
3
+ ![build](https://github.com/kojix2/libui/workflows/build/badge.svg)
2
4
  [![Gem Version](https://badge.fury.io/rb/libui.svg)](https://badge.fury.io/rb/libui)
3
5
 
4
- [libui](https://github.com/andlabs/libui) - a portable GUI library -for Ruby
6
+ :radio_button: [libui](https://github.com/andlabs/libui) - a portable GUI library -for Ruby
5
7
 
6
8
  ## Installation
7
9
 
10
+ ```sh
11
+ gem install libui
8
12
  ```
9
- gem install libui --pre
10
- ```
13
+
14
+ The libui gem uses the standard Ruby library [Fiddle](https://github.com/ruby/fiddle) to call C functions. And this gem contains the official release of the libui shared library version 4.1 for Windows, Mac, and Linux. That means there is no need to install anything other than this gem.
11
15
 
12
16
  ## Usage
13
17
 
18
+ ```ruby
19
+ require 'libui'
20
+ UI = LibUI
21
+
22
+ UI.init
23
+
24
+ main_window = UI.new_window('hello world', 300, 200, 1)
25
+ UI.window_on_closing(main_window) do
26
+ puts 'Bye Bye'
27
+ UI.control_destroy(main_window)
28
+ UI.quit
29
+ 0
30
+ end
31
+
32
+ button = UI.new_button('Button')
33
+ UI.button_on_clicked(button) do
34
+ UI.msg_box(main_window, 'Information', 'You clicked the button')
35
+ 0
36
+ end
37
+
38
+ UI.window_set_child(main_window, button)
39
+ UI.control_show(main_window)
40
+
41
+ UI.main
42
+ UI.quit
43
+ ```
44
+
45
+ See [examples](https://github.com/kojix2/libui/tree/main/examples) directory.
46
+
47
+ ### General Rules
48
+
49
+ * The method names are snake_case.
50
+ * If the last argument is nil, it can be omitted.
51
+ * You can pass a block as a callback.
52
+ * Please return 0 explicitly in the block.
53
+ * The block will be converted to a Proc object and added to the last argument.
54
+ * Even in that case, it is possible to omit the last argument nil.
55
+
56
+ ### Not object oriented?
57
+
58
+ * At the moment, it is not object-oriented.
59
+ * Instead of providing a half-baked object-oriented approach, leave it as is.
60
+
61
+ ### How to use fiddle pointers?
62
+
63
+ ```ruby
64
+ require 'libui'
65
+ UI = LibUI
66
+ UI.init
67
+ ```
68
+
69
+ Convert a pointer to a string.
70
+
71
+ ```ruby
72
+ label = UI.new_label("Ruby")
73
+ p pointer = UI.label_text(label) # #<Fiddle::Pointer>
74
+ p pointer.to_s # Ruby
75
+ ```
76
+
77
+ If you need to use C structs, you can do the following.
78
+
79
+ ```ruby
80
+ font_button = UI.new_font_button
81
+
82
+ # Allocate memory
83
+ font_descriptor = UI::FFI::FontDescriptor.malloc
84
+
85
+ UI.font_button_on_changed(font_button) do
86
+ UI.font_button_font(font_button, font_descriptor)
87
+ p family: font_descriptor.Family.to_s,
88
+ size: font_descriptor.Size,
89
+ weight: font_descriptor.Weight,
90
+ italic: font_descriptor.Italic,
91
+ stretch: font_descriptor.Stretch
92
+ end
93
+ ```
94
+
95
+ ### How to create an executable (.exe) on Windows
96
+
97
+ OCRA (One-Click Ruby Application) builds Windows executables from Ruby source code.
98
+ * https://github.com/larsch/ocra/
99
+
14
100
  ## Development
15
101
 
16
- * Keep it simple
102
+ ```sh
103
+ git clone https://github.com/kojix2/libui
104
+ cd libui
105
+ bundle install
106
+ bundle exec rake vendor:all
107
+ bundle exec rake test
108
+ ```
109
+
110
+ Use the following rake tasks to download the libui binary files and save them in the vendor directory.
111
+
112
+ `rake -T`
113
+
114
+ ```
115
+ rake vendor:all # Download libui.so, libui.dylib, and libui.dll to ve...
116
+ rake vendor:linux # Download libui.so for Linux to vendor directory
117
+ rake vendor:mac # Download libui.dylib for Mac to vendor directory
118
+ rake vendor:windows # Download libui.dll for Windows to vendor directory
119
+ ```
17
120
 
18
121
  ## Contributing
19
122
 
@@ -21,10 +124,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/kojix2
21
124
 
22
125
  ## Acknowledgement
23
126
 
24
- libui-ruby ispired this project.
127
+ This project is inspired by libui-ruby.
128
+
25
129
  * https://github.com/jamescook/libui-ruby
26
130
 
27
- While libui-ruby uses FFI, this gem uses Fiddle.
131
+ While libui-ruby uses [Ruby-FFI](https://github.com/ffi/ffi), this gem uses [Fiddle](https://github.com/ruby/fiddle).
28
132
 
29
133
  ## License
30
134
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'libui/version'
4
+ require_relative 'libui/utils'
4
5
 
5
6
  module LibUI
6
7
  class Error < StandardError; end
@@ -8,17 +9,62 @@ module LibUI
8
9
  class << self
9
10
  attr_accessor :ffi_lib
10
11
  end
11
- self.ffi_lib = case RbConfig::CONFIG['host_os']
12
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
13
- # File.expand_path("libui.dll", ENV['LIBUIDIR'])
14
- File.expand_path('../vendor/libui.dll', __dir__)
15
- when /darwin|mac os/
16
- # File.expand_path("libui.dylib", ENV['LIBUIDIR'])
17
- File.expand_path('../vendor/libui.dylib', __dir__)
18
- else # TODO: Mac
19
- # File.expand_path("libui.so", ENV['LIBUIDIR'])
20
- File.expand_path('../vendor/libui.so', __dir__)
12
+
13
+ lib_name = case RbConfig::CONFIG['host_os']
14
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
15
+ 'libui.dll'
16
+ when /darwin|mac os/
17
+ 'libui.dylib'
18
+ else
19
+ 'libui.so'
20
+ end
21
+
22
+ self.ffi_lib = if ENV['LIBUIDIR'] && !ENV['LIBUIDIR'].empty?
23
+ File.expand_path(lib_name, ENV['LIBUIDIR'])
24
+ else
25
+ File.expand_path("../vendor/#{lib_name}", __dir__)
21
26
  end
22
27
 
23
- autoload :FFI, 'libui/ffi'
28
+ require_relative 'libui/ffi'
29
+
30
+ class << self
31
+ FFI.func_map.each_key do |original_method_name|
32
+ name = Utils.convert_to_ruby_method(original_method_name)
33
+ func = FFI.func_map[original_method_name]
34
+
35
+ define_method(name) do |*args, &blk|
36
+ # Assume that block is the last argument.
37
+ args << blk if blk
38
+
39
+ # The proc object is converted to a Closure::BlockCaller object.
40
+ args.map!.with_index do |arg, idx|
41
+ if arg.is_a?(Proc)
42
+ # The types of the function arguments are recorded beforehand.
43
+ # See the monkey patch in ffi.rb.
44
+ Fiddle::Closure::BlockCaller.new(*func.inner_functions[idx][1..2], &arg)
45
+ else
46
+ arg
47
+ end
48
+ end
49
+
50
+ # Make it possible to omit the last nil. This may be an over-optimization.
51
+ siz = func.argtype.size - 1
52
+ args[siz] = nil if args.size == siz
53
+
54
+ FFI.public_send(original_method_name, *args)
55
+ end
56
+ end
57
+
58
+ module CustomMethods
59
+ def init(opt = FFI::InitOptions.malloc)
60
+ i = super(opt)
61
+ unless i.size.zero?
62
+ warn 'error'
63
+ warn UI.free_init_error(init)
64
+ end
65
+ end
66
+ end
67
+
68
+ prepend CustomMethods
69
+ end
24
70
  end
@@ -2,6 +2,81 @@
2
2
 
3
3
  require 'fiddle/import'
4
4
 
5
+ module Fiddle
6
+ # Change the Function to hold a little more information.
7
+ # FIXME: Give inner_function a better name.
8
+ class Function
9
+ attr_accessor :inner_functions, :argtype
10
+ end
11
+
12
+ module Importer
13
+ def parse_signature(signature, tymap = nil)
14
+ tymap ||= {}
15
+ ret, func, args = split_signature(signature)
16
+ symname = func
17
+ ctype = parse_ctype(ret, tymap)
18
+ inner_funcs = [] # Added
19
+ argtype = split_arguments(args).collect.with_index do |arg, idx| # Added with_index
20
+ # Check if it is a function pointer or not
21
+ if arg =~ /\(\*.*\)\(.*\)/ # Added
22
+ # From the arguments, create a notation that looks like a function declaration
23
+ # int(*f)(int *, void *) -> int f(int *, void *)
24
+ func_arg = arg.sub('(*', ' ').sub(')', '') # Added
25
+ # Use Fiddle's parse_signature method again.
26
+ inner_funcs[idx] = parse_signature(func_arg) # Added
27
+ end # Added
28
+ parse_ctype(arg, tymap)
29
+ end
30
+ # Added inner_funcs. Original method return only 3 values.
31
+ [symname, ctype, argtype, inner_funcs]
32
+ end
33
+
34
+ # refactored
35
+ def split_signature(signature)
36
+ case compact(signature)
37
+ when /^(?:[\w*\s]+)\(\*(\w+)\((.*?)\)\)(?:\[\w*\]|\(.*?\));?$/
38
+ ret = TYPE_VOIDP
39
+ func = Regexp.last_match(1)
40
+ args = Regexp.last_match(2)
41
+ when /^([\w*\s]+[*\s])(\w+)\((.*?)\);?$/
42
+ ret = Regexp.last_match(1).strip
43
+ func = Regexp.last_match(2)
44
+ args = Regexp.last_match(3)
45
+ else
46
+ raise("can't parse the function prototype: #{signature}")
47
+ end
48
+ [ret, func, args]
49
+ end
50
+
51
+ def extern(signature, *opts)
52
+ symname, ctype, argtype, inner_funcs = parse_signature(signature, type_alias)
53
+ opt = parse_bind_options(opts)
54
+ f = import_function(symname, ctype, argtype, opt[:call_type])
55
+
56
+ f.inner_functions = inner_funcs # Added
57
+ f.argtype = argtype # Added
58
+
59
+ name = symname.gsub(/@.+/, '')
60
+ @func_map[name] = f
61
+ # define_method(name){|*args,&block| f.call(*args,&block)}
62
+ begin
63
+ /^(.+?):(\d+)/ =~ caller.first
64
+ file = Regexp.last_match(1)
65
+ line = Regexp.last_match(2).to_i
66
+ rescue StandardError
67
+ file, line = __FILE__, __LINE__ + 3
68
+ end
69
+ module_eval(<<-EOS, file, line)
70
+ def #{name}(*args, &block)
71
+ @func_map['#{name}'].call(*args,&block)
72
+ end
73
+ EOS
74
+ module_function(name)
75
+ f
76
+ end
77
+ end
78
+ end
79
+
5
80
  module LibUI
6
81
  module FFI
7
82
  extend Fiddle::Importer
@@ -9,210 +84,559 @@ module LibUI
9
84
  begin
10
85
  dlload LibUI.ffi_lib
11
86
  rescue LoadError
12
- raise LoadError, 'Could not find libui'
87
+ raise LoadError, 'Could not find libui shared library'
88
+ end
89
+
90
+ class << self
91
+ attr_reader :func_map
92
+
93
+ def try_extern(signature, *opts)
94
+ extern(signature, *opts)
95
+ rescue StandardError => e
96
+ warn "#{e.class.name}: #{e.message}"
97
+ end
98
+
99
+ def ffi_methods
100
+ @ffi_methods ||= func_map.each_key.to_a
101
+ end
13
102
  end
14
103
 
15
- typealias("uint32_t", "unsigned int")
16
-
17
- InitOptions = struct(['size_t size'])
18
-
19
- extern 'const char *uiInit(uiInitOptions *options)'
20
- extern 'void uiUninit(void)'
21
- extern 'void uiFreeInitError(const char *err)'
22
-
23
- extern 'void uiMain(void)'
24
- extern 'void uiMainSteps(void)'
25
- extern 'int uiMainStep(int wait)'
26
- extern 'void uiQuit(void)'
27
- extern 'void uiQueueMain(void (*f)(void *data), void *data)'
28
- extern 'void uiTimer(int milliseconds, int (*f)(void *data), void *data)'
29
- extern 'void uiOnShouldQuit(int (*f)(void *data), void *data)'
30
- extern 'void uiFreeText(char *text)'
31
-
32
- struct ['uint32_t Signature',
33
- 'uint32_t OSSignature',
34
- 'uint32_t TypeSignature',
35
- 'void (*Destroy)(uiControl *)',
36
- 'uintptr_t (*Handle)(uiControl *)',
37
- 'uiControl *(*Parent)(uiControl *)',
38
- 'void (*SetParent)(uiControl *, uiControl *)',
39
- 'int (*Toplevel)(uiControl *)',
40
- 'int (*Visible)(uiControl *)',
41
- 'void (*Show)(uiControl *)',
42
- 'void (*Hide)(uiControl *)',
43
- 'int (*Enabled)(uiControl *)',
44
- 'void (*Enable)(uiControl *)',
45
- 'void (*Disable)(uiControl *)']
46
-
47
- extern 'void uiControlDestroy(uiControl *)'
48
- extern 'uintptr_t uiControlHandle(uiControl *)'
49
- extern 'uiControl *uiControlParent(uiControl *)'
50
- extern 'void uiControlSetParent(uiControl *, uiControl *)'
51
- extern 'int uiControlToplevel(uiControl *)'
52
- extern 'int uiControlVisible(uiControl *)'
53
- extern 'void uiControlShow(uiControl *)'
54
- extern 'void uiControlHide(uiControl *)'
55
- extern 'int uiControlEnabled(uiControl *)'
56
- extern 'void uiControlEnable(uiControl *)'
57
- extern 'void uiControlDisable(uiControl *)'
58
-
59
- extern 'uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr)'
60
- extern 'void uiFreeControl(uiControl *)'
61
-
62
- extern 'void uiControlVerifySetParent(uiControl *, uiControl *)'
63
- extern 'int uiControlEnabledToUser(uiControl *)'
64
-
65
- extern 'void uiUserBugCannotSetParentOnToplevel(const char *type)'
104
+ typealias('uint32_t', 'unsigned int')
105
+
106
+ InitOptions = struct [
107
+ 'size_t Size'
108
+ ]
109
+
110
+ try_extern 'const char *uiInit(uiInitOptions *options)'
111
+ try_extern 'void uiUninit(void)'
112
+ try_extern 'void uiFreeInitError(const char *err)'
113
+
114
+ try_extern 'void uiMain(void)'
115
+ try_extern 'void uiMainSteps(void)'
116
+ try_extern 'int uiMainStep(int wait)'
117
+ try_extern 'void uiQuit(void)'
118
+ try_extern 'void uiQueueMain(void (*f)(void *data), void *data)'
119
+ try_extern 'void uiTimer(int milliseconds, int (*f)(void *data), void *data)'
120
+ try_extern 'void uiOnShouldQuit(int (*f)(void *data), void *data)'
121
+ try_extern 'void uiFreeText(char *text)'
122
+
123
+ Control = struct [
124
+ 'uint32_t Signature',
125
+ 'uint32_t OSSignature',
126
+ 'uint32_t TypeSignature',
127
+ 'void (*Destroy)(uiControl *)',
128
+ 'uintptr_t (*Handle)(uiControl *)',
129
+ 'uiControl *(*Parent)(uiControl *)',
130
+ 'void (*SetParent)(uiControl *, uiControl *)',
131
+ 'int (*Toplevel)(uiControl *)',
132
+ 'int (*Visible)(uiControl *)',
133
+ 'void (*Show)(uiControl *)',
134
+ 'void (*Hide)(uiControl *)',
135
+ 'int (*Enabled)(uiControl *)',
136
+ 'void (*Enable)(uiControl *)',
137
+ 'void (*Disable)(uiControl *)'
138
+ ]
139
+
140
+ try_extern 'void uiControlDestroy(uiControl *)'
141
+ try_extern 'uintptr_t uiControlHandle(uiControl *)'
142
+ try_extern 'uiControl *uiControlParent(uiControl *)'
143
+ try_extern 'void uiControlSetParent(uiControl *, uiControl *)'
144
+ try_extern 'int uiControlToplevel(uiControl *)'
145
+ try_extern 'int uiControlVisible(uiControl *)'
146
+ try_extern 'void uiControlShow(uiControl *)'
147
+ try_extern 'void uiControlHide(uiControl *)'
148
+ try_extern 'int uiControlEnabled(uiControl *)'
149
+ try_extern 'void uiControlEnable(uiControl *)'
150
+ try_extern 'void uiControlDisable(uiControl *)'
151
+
152
+ try_extern 'uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr)'
153
+ try_extern 'void uiFreeControl(uiControl *)'
154
+
155
+ try_extern 'void uiControlVerifySetParent(uiControl *, uiControl *)'
156
+ try_extern 'int uiControlEnabledToUser(uiControl *)'
157
+
158
+ try_extern 'void uiUserBugCannotSetParentOnToplevel(const char *type)'
66
159
 
67
160
  # uiWindow
68
- extern 'char *uiWindowTitle(uiWindow *w)'
69
- extern 'void uiWindowSetTitle(uiWindow *w, const char *title)'
70
- extern 'void uiWindowContentSize(uiWindow *w, int *width, int *height)'
71
- extern 'void uiWindowSetContentSize(uiWindow *w, int width, int height)'
72
- extern 'int uiWindowFullscreen(uiWindow *w)'
73
- extern 'void uiWindowSetFullscreen(uiWindow *w, int fullscreen)'
74
- extern 'void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data)'
75
- extern 'void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data)'
76
- extern 'int uiWindowBorderless(uiWindow *w)'
77
- extern 'void uiWindowSetBorderless(uiWindow *w, int borderless)'
78
- extern 'void uiWindowSetChild(uiWindow *w, uiControl *child)'
79
- extern 'int uiWindowMargined(uiWindow *w)'
80
- extern 'void uiWindowSetMargined(uiWindow *w, int margined)'
81
- extern 'uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)'
82
-
161
+
162
+ try_extern 'char *uiWindowTitle(uiWindow *w)'
163
+ try_extern 'void uiWindowSetTitle(uiWindow *w, const char *title)'
164
+ try_extern 'void uiWindowContentSize(uiWindow *w, int *width, int *height)'
165
+ try_extern 'void uiWindowSetContentSize(uiWindow *w, int width, int height)'
166
+ try_extern 'int uiWindowFullscreen(uiWindow *w)'
167
+ try_extern 'void uiWindowSetFullscreen(uiWindow *w, int fullscreen)'
168
+ try_extern 'void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data)'
169
+ try_extern 'void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data)'
170
+ try_extern 'int uiWindowBorderless(uiWindow *w)'
171
+ try_extern 'void uiWindowSetBorderless(uiWindow *w, int borderless)'
172
+ try_extern 'void uiWindowSetChild(uiWindow *w, uiControl *child)'
173
+ try_extern 'int uiWindowMargined(uiWindow *w)'
174
+ try_extern 'void uiWindowSetMargined(uiWindow *w, int margined)'
175
+ try_extern 'uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)'
176
+
83
177
  # uiButton
84
- extern 'char *uiButtonText(uiButton *b)'
85
- extern 'void uiButtonSetText(uiButton *b, const char *text)'
86
- extern 'void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data)'
87
- extern 'uiButton *uiNewButton(const char *text)'
88
-
178
+
179
+ try_extern 'char *uiButtonText(uiButton *b)'
180
+ try_extern 'void uiButtonSetText(uiButton *b, const char *text)'
181
+ try_extern 'void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data)'
182
+ try_extern 'uiButton *uiNewButton(const char *text)'
183
+
89
184
  # uiBox
90
- extern 'void uiBoxAppend(uiBox *b, uiControl *child, int stretchy)'
91
- extern 'void uiBoxDelete(uiBox *b, int index)'
92
- extern 'int uiBoxPadded(uiBox *b)'
93
- extern 'void uiBoxSetPadded(uiBox *b, int padded)'
94
- extern 'uiBox *uiNewHorizontalBox(void)'
95
- extern 'uiBox *uiNewVerticalBox(void)'
96
-
185
+
186
+ try_extern 'void uiBoxAppend(uiBox *b, uiControl *child, int stretchy)'
187
+ try_extern 'void uiBoxDelete(uiBox *b, int index)'
188
+ try_extern 'int uiBoxPadded(uiBox *b)'
189
+ try_extern 'void uiBoxSetPadded(uiBox *b, int padded)'
190
+ try_extern 'uiBox *uiNewHorizontalBox(void)'
191
+ try_extern 'uiBox *uiNewVerticalBox(void)'
192
+
97
193
  # uiCheckbox
98
- extern 'char *uiCheckboxText(uiCheckbox *c)'
99
- extern 'void uiCheckboxSetText(uiCheckbox *c, const char *text)'
100
- extern 'void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *c, void *data), void *data)'
101
- extern 'int uiCheckboxChecked(uiCheckbox *c)'
102
- extern 'void uiCheckboxSetChecked(uiCheckbox *c, int checked)'
103
- extern 'uiCheckbox *uiNewCheckbox(const char *text)'
104
-
194
+
195
+ try_extern 'char *uiCheckboxText(uiCheckbox *c)'
196
+ try_extern 'void uiCheckboxSetText(uiCheckbox *c, const char *text)'
197
+ try_extern 'void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *c, void *data), void *data)'
198
+ try_extern 'int uiCheckboxChecked(uiCheckbox *c)'
199
+ try_extern 'void uiCheckboxSetChecked(uiCheckbox *c, int checked)'
200
+ try_extern 'uiCheckbox *uiNewCheckbox(const char *text)'
201
+
105
202
  # uiEntry
106
- extern 'char *uiEntryText(uiEntry *e)'
107
- extern 'void uiEntrySetText(uiEntry *e, const char *text)'
108
- extern 'void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data)'
109
- extern 'int uiEntryReadOnly(uiEntry *e)'
110
- extern 'void uiEntrySetReadOnly(uiEntry *e, int readonly)'
111
- extern 'uiEntry *uiNewEntry(void)'
112
- extern 'uiEntry *uiNewPasswordEntry(void)'
113
- extern 'uiEntry *uiNewSearchEntry(void)'
114
-
203
+
204
+ try_extern 'char *uiEntryText(uiEntry *e)'
205
+ try_extern 'void uiEntrySetText(uiEntry *e, const char *text)'
206
+ try_extern 'void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data)'
207
+ try_extern 'int uiEntryReadOnly(uiEntry *e)'
208
+ try_extern 'void uiEntrySetReadOnly(uiEntry *e, int readonly)'
209
+ try_extern 'uiEntry *uiNewEntry(void)'
210
+ try_extern 'uiEntry *uiNewPasswordEntry(void)'
211
+ try_extern 'uiEntry *uiNewSearchEntry(void)'
212
+
115
213
  # uiLabel
116
- extern 'char *uiLabelText(uiLabel *l)'
117
- extern 'void uiLabelSetText(uiLabel *l, const char *text)'
118
- extern 'uiLabel *uiNewLabel(const char *text)'
119
-
214
+
215
+ try_extern 'char *uiLabelText(uiLabel *l)'
216
+ try_extern 'void uiLabelSetText(uiLabel *l, const char *text)'
217
+ try_extern 'uiLabel *uiNewLabel(const char *text)'
218
+
120
219
  # uiTab
121
- extern 'void uiTabAppend(uiTab *t, const char *name, uiControl *c)'
122
- extern 'void uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c)'
123
- extern 'void uiTabDelete(uiTab *t, int index)'
124
- extern 'int uiTabNumPages(uiTab *t)'
125
- extern 'int uiTabMargined(uiTab *t, int page)'
126
- extern 'void uiTabSetMargined(uiTab *t, int page, int margined)'
127
- extern 'uiTab *uiNewTab(void)'
128
-
220
+
221
+ try_extern 'void uiTabAppend(uiTab *t, const char *name, uiControl *c)'
222
+ try_extern 'void uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c)'
223
+ try_extern 'void uiTabDelete(uiTab *t, int index)'
224
+ try_extern 'int uiTabNumPages(uiTab *t)'
225
+ try_extern 'int uiTabMargined(uiTab *t, int page)'
226
+ try_extern 'void uiTabSetMargined(uiTab *t, int page, int margined)'
227
+ try_extern 'uiTab *uiNewTab(void)'
228
+
129
229
  # uiGroup
130
- extern 'char *uiGroupTitle(uiGroup *g)'
131
- extern 'void uiGroupSetTitle(uiGroup *g, const char *title)'
132
- extern 'void uiGroupSetChild(uiGroup *g, uiControl *c)'
133
- extern 'int uiGroupMargined(uiGroup *g)'
134
- extern 'void uiGroupSetMargined(uiGroup *g, int margined)'
135
- extern 'uiGroup *uiNewGroup(const char *title)'
136
-
230
+
231
+ try_extern 'char *uiGroupTitle(uiGroup *g)'
232
+ try_extern 'void uiGroupSetTitle(uiGroup *g, const char *title)'
233
+ try_extern 'void uiGroupSetChild(uiGroup *g, uiControl *c)'
234
+ try_extern 'int uiGroupMargined(uiGroup *g)'
235
+ try_extern 'void uiGroupSetMargined(uiGroup *g, int margined)'
236
+ try_extern 'uiGroup *uiNewGroup(const char *title)'
237
+
137
238
  # uiSpinbox
138
- extern 'int uiSpinboxValue(uiSpinbox *s)'
139
- extern 'void uiSpinboxSetValue(uiSpinbox *s, int value)'
140
- extern 'void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data)'
141
- extern 'uiSpinbox *uiNewSpinbox(int min, int max)'
142
-
239
+
240
+ try_extern 'int uiSpinboxValue(uiSpinbox *s)'
241
+ try_extern 'void uiSpinboxSetValue(uiSpinbox *s, int value)'
242
+ try_extern 'void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data)'
243
+ try_extern 'uiSpinbox *uiNewSpinbox(int min, int max)'
244
+
143
245
  # uiSlider
144
- extern 'int uiSliderValue(uiSlider *s)'
145
- extern 'void uiSliderSetValue(uiSlider *s, int value)'
146
- extern 'void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data)'
147
- extern 'uiSlider *uiNewSlider(int min, int max)'
148
-
246
+
247
+ try_extern 'int uiSliderValue(uiSlider *s)'
248
+ try_extern 'void uiSliderSetValue(uiSlider *s, int value)'
249
+ try_extern 'void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data)'
250
+ try_extern 'uiSlider *uiNewSlider(int min, int max)'
251
+
149
252
  # uiProgressBar
150
- extern 'int uiProgressBarValue(uiProgressBar *p)'
151
- extern 'void uiProgressBarSetValue(uiProgressBar *p, int n)'
152
- extern 'uiProgressBar *uiNewProgressBar(void)'
153
-
253
+
254
+ try_extern 'int uiProgressBarValue(uiProgressBar *p)'
255
+ try_extern 'void uiProgressBarSetValue(uiProgressBar *p, int n)'
256
+ try_extern 'uiProgressBar *uiNewProgressBar(void)'
257
+
154
258
  # uiSeparator
155
- extern 'uiSeparator *uiNewHorizontalSeparator(void)'
156
- extern 'uiSeparator *uiNewVerticalSeparator(void)'
157
-
259
+
260
+ try_extern 'uiSeparator *uiNewHorizontalSeparator(void)'
261
+ try_extern 'uiSeparator *uiNewVerticalSeparator(void)'
262
+
158
263
  # uiCombobox
159
- extern 'void uiComboboxAppend(uiCombobox *c, const char *text)'
160
- extern 'int uiComboboxSelected(uiCombobox *c)'
161
- extern 'void uiComboboxSetSelected(uiCombobox *c, int n)'
162
- extern 'void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data)'
163
- extern 'uiCombobox *uiNewCombobox(void)'
164
-
264
+
265
+ try_extern 'void uiComboboxAppend(uiCombobox *c, const char *text)'
266
+ try_extern 'int uiComboboxSelected(uiCombobox *c)'
267
+ try_extern 'void uiComboboxSetSelected(uiCombobox *c, int n)'
268
+ try_extern 'void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data)'
269
+ try_extern 'uiCombobox *uiNewCombobox(void)'
270
+
165
271
  # uiEditableCombobox
166
- extern 'void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text)'
167
- extern 'char *uiEditableComboboxText(uiEditableCombobox *c)'
168
- extern 'void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text)'
169
- extern 'void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data)'
170
- extern 'uiEditableCombobox *uiNewEditableCombobox(void)'
171
-
272
+
273
+ try_extern 'void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text)'
274
+ try_extern 'char *uiEditableComboboxText(uiEditableCombobox *c)'
275
+ try_extern 'void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text)'
276
+ try_extern 'void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data)'
277
+ try_extern 'uiEditableCombobox *uiNewEditableCombobox(void)'
278
+
172
279
  # uiRadioButtons
173
- extern 'void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)'
174
- extern 'int uiRadioButtonsSelected(uiRadioButtons *r)'
175
- extern 'void uiRadioButtonsSetSelected(uiRadioButtons *r, int n)'
176
- extern 'void uiRadioButtonsOnSelected(uiRadioButtons *r, void (*f)(uiRadioButtons *, void *), void *data)'
177
- extern 'uiRadioButtons *uiNewRadioButtons(void)'
178
-
179
- # uiDataTimePicker
180
- extern 'void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)'
181
- extern 'void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)'
182
- extern 'void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)'
183
- extern 'uiDateTimePicker *uiNewDateTimePicker(void)'
184
- extern 'uiDateTimePicker *uiNewDatePicker(void)'
185
- extern 'uiDateTimePicker *uiNewTimePicker(void)'
186
-
280
+
281
+ try_extern 'void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)'
282
+ try_extern 'int uiRadioButtonsSelected(uiRadioButtons *r)'
283
+ try_extern 'void uiRadioButtonsSetSelected(uiRadioButtons *r, int n)'
284
+ try_extern 'void uiRadioButtonsOnSelected(uiRadioButtons *r, void (*f)(uiRadioButtons *, void *), void *data)'
285
+ try_extern 'uiRadioButtons *uiNewRadioButtons(void)'
286
+
287
+ # uiDateTimePicker # Fixme: struct tm
288
+
289
+ try_extern 'void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)'
290
+ try_extern 'void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)'
291
+ try_extern 'void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)'
292
+ try_extern 'uiDateTimePicker *uiNewDateTimePicker(void)'
293
+ try_extern 'uiDateTimePicker *uiNewDatePicker(void)'
294
+ try_extern 'uiDateTimePicker *uiNewTimePicker(void)'
295
+
187
296
  # uiMultilineEntry
188
- extern 'char *uiMultilineEntryText(uiMultilineEntry *e)'
189
- extern 'void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)'
190
- extern 'void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)'
191
- extern 'void uiMultilineEntryOnChanged(uiMultilineEntry *e, void (*f)(uiMultilineEntry *e, void *data), void *data)'
192
- extern 'int uiMultilineEntryReadOnly(uiMultilineEntry *e)'
193
- extern 'void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly)'
194
- extern 'uiMultilineEntry *uiNewMultilineEntry(void)'
195
- extern 'uiMultilineEntry *uiNewNonWrappingMultilineEntry(void)'
196
-
297
+
298
+ try_extern 'char *uiMultilineEntryText(uiMultilineEntry *e)'
299
+ try_extern 'void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)'
300
+ try_extern 'void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)'
301
+ try_extern 'void uiMultilineEntryOnChanged(uiMultilineEntry *e, void (*f)(uiMultilineEntry *e, void *data), void *data)'
302
+ try_extern 'int uiMultilineEntryReadOnly(uiMultilineEntry *e)'
303
+ try_extern 'void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly)'
304
+ try_extern 'uiMultilineEntry *uiNewMultilineEntry(void)'
305
+ try_extern 'uiMultilineEntry *uiNewNonWrappingMultilineEntry(void)'
306
+
197
307
  # uiMenuItem
198
- extern 'void uiMenuItemEnable(uiMenuItem *m)'
199
- extern 'void uiMenuItemDisable(uiMenuItem *m)'
200
- extern 'void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, uiWindow *window, void *data), void *data)'
201
- extern 'int uiMenuItemChecked(uiMenuItem *m)'
202
- extern 'void uiMenuItemSetChecked(uiMenuItem *m, int checked)'
308
+
309
+ try_extern 'void uiMenuItemEnable(uiMenuItem *m)'
310
+ try_extern 'void uiMenuItemDisable(uiMenuItem *m)'
311
+ try_extern 'void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, uiWindow *window, void *data), void *data)'
312
+ try_extern 'int uiMenuItemChecked(uiMenuItem *m)'
313
+ try_extern 'void uiMenuItemSetChecked(uiMenuItem *m, int checked)'
203
314
 
204
315
  # uiMenu
205
- extern 'uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name)'
206
- extern 'uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name)'
207
- extern 'uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)'
208
- extern 'uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)'
209
- extern 'uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)'
210
- extern 'void uiMenuAppendSeparator(uiMenu *m)'
211
- extern 'uiMenu *uiNewMenu(const char *name)'
212
-
213
- extern 'char *uiOpenFile(uiWindow *parent)'
214
- extern 'char *uiSaveFile(uiWindow *parent)'
215
- extern 'void uiMsgBox(uiWindow *parent, const char *title, const char *description)'
216
- extern 'void uiMsgBoxError(uiWindow *parent, const char *title, const char *description)'
316
+
317
+ try_extern 'uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name)'
318
+ try_extern 'uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name)'
319
+ try_extern 'uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)'
320
+ try_extern 'uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)'
321
+ try_extern 'uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)'
322
+ try_extern 'void uiMenuAppendSeparator(uiMenu *m)'
323
+ try_extern 'uiMenu *uiNewMenu(const char *name)'
324
+
325
+ try_extern 'char *uiOpenFile(uiWindow *parent)'
326
+ try_extern 'char *uiSaveFile(uiWindow *parent)'
327
+ try_extern 'void uiMsgBox(uiWindow *parent, const char *title, const char *description)'
328
+ try_extern 'void uiMsgBoxError(uiWindow *parent, const char *title, const char *description)'
329
+
330
+ # uiArea
331
+
332
+ AreaHandler = struct [
333
+ 'void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *)',
334
+ 'void (*MouseEvent)(uiAreaHandler *, uiArea *, uiAreaMouseEvent *)',
335
+ 'void (*MouseCrossed)(uiAreaHandler *, uiArea *, int left)',
336
+ 'void (*DragBroken)(uiAreaHandler *, uiArea *)',
337
+ 'int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *)'
338
+ ]
339
+
340
+ typealias 'uiWindowResizeEdge', 'int'
341
+
342
+ try_extern 'void uiAreaSetSize(uiArea *a, int width, int height)'
343
+ try_extern 'void uiAreaQueueRedrawAll(uiArea *a)'
344
+ try_extern 'void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height)'
345
+ try_extern 'void uiAreaBeginUserWindowMove(uiArea *a)'
346
+ try_extern 'void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)'
347
+ try_extern 'uiArea *uiNewArea(uiAreaHandler *ah)'
348
+ try_extern 'uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)'
349
+
350
+ AreaDrawParams = struct [
351
+ 'uiDrawContext *Context',
352
+ 'double AreaWidth',
353
+ 'double AreaHeight',
354
+ 'double ClipX',
355
+ 'double ClipY',
356
+ 'double ClipWidth',
357
+ 'double ClipHeight'
358
+ ]
359
+ typealias 'uiDrawBrushType', 'int'
360
+ typealias 'uiDrawLineCap', 'int'
361
+ typealias 'uiDrawLineJoin', 'int'
362
+ typealias 'uiDrawFillMode', 'int'
363
+
364
+ DrawMatrix = struct [
365
+ 'double M11',
366
+ 'double M12',
367
+ 'double M21',
368
+ 'double M22',
369
+ 'double M31',
370
+ 'double M32'
371
+ ]
372
+
373
+ DrawBrush = struct [
374
+ 'uiDrawBrushType Type',
375
+ 'double R',
376
+ 'double G',
377
+ 'double B',
378
+ 'double A',
379
+ 'double X0',
380
+ 'double Y0',
381
+ 'double X1',
382
+ 'double Y1',
383
+ 'double OuterRadius',
384
+ 'uiDrawBrushGradientStop *Stops',
385
+ 'size_t NumStops'
386
+ ]
387
+
388
+ DrawBrushGradientStop = struct [
389
+ 'double Pos',
390
+ 'double R',
391
+ 'double G',
392
+ 'double B',
393
+ 'double A'
394
+ ]
395
+
396
+ DrawStrokeParams = struct [
397
+ 'uiDrawLineCap Cap',
398
+ 'uiDrawLineJoin Join',
399
+ 'double Thickness',
400
+ 'double MiterLimit',
401
+ 'double *Dashes',
402
+ 'size_t NumDashes',
403
+ 'double DashPhase'
404
+ ]
405
+
406
+ # uiDrawPath
407
+ try_extern 'uiDrawPath *uiDrawNewPath(uiDrawFillMode fillMode)'
408
+ try_extern 'void uiDrawFreePath(uiDrawPath *p)'
409
+ try_extern 'void uiDrawPathNewFigure(uiDrawPath *p, double x, double y)'
410
+ try_extern 'void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative)'
411
+ try_extern 'void uiDrawPathLineTo(uiDrawPath *p, double x, double y)'
412
+ try_extern 'void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative)'
413
+ try_extern 'void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY)'
414
+ try_extern 'void uiDrawPathCloseFigure(uiDrawPath *p)'
415
+ try_extern 'void uiDrawPathAddRectangle(uiDrawPath *p, double x, double y, double width, double height)'
416
+ try_extern 'void uiDrawPathEnd(uiDrawPath *p)'
417
+ try_extern 'void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStrokeParams *p)'
418
+ try_extern 'void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b)'
419
+
420
+ # uiDrawMatrix
421
+ try_extern 'void uiDrawMatrixSetIdentity(uiDrawMatrix *m)'
422
+ try_extern 'void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y)'
423
+ try_extern 'void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y)'
424
+ try_extern 'void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount)'
425
+ try_extern 'void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount)'
426
+ try_extern 'void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src)'
427
+ try_extern 'int uiDrawMatrixInvertible(uiDrawMatrix *m)'
428
+ try_extern 'int uiDrawMatrixInvert(uiDrawMatrix *m)'
429
+ try_extern 'void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y)'
430
+ try_extern 'void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y)'
431
+
432
+ try_extern 'void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m)'
433
+ try_extern 'void uiDrawClip(uiDrawContext *c, uiDrawPath *path)'
434
+ try_extern 'void uiDrawSave(uiDrawContext *c)'
435
+ try_extern 'void uiDrawRestore(uiDrawContext *c)'
436
+
437
+ # uiAttribute
438
+ try_extern 'void uiFreeAttribute(uiAttribute *a)'
439
+
440
+ typealias 'uiAttributeType', 'int'
441
+
442
+ try_extern 'uiAttributeType uiAttributeGetType(const uiAttribute *a)'
443
+ try_extern 'uiAttribute *uiNewFamilyAttribute(const char *family)'
444
+ try_extern 'const char *uiAttributeFamily(const uiAttribute *a)'
445
+ try_extern 'uiAttribute *uiNewSizeAttribute(double size)'
446
+ try_extern 'double uiAttributeSize(const uiAttribute *a)'
447
+
448
+ typealias 'uiTextWeight', 'int'
449
+
450
+ try_extern 'uiAttribute *uiNewWeightAttribute(uiTextWeight weight)'
451
+ try_extern 'uiTextWeight uiAttributeWeight(const uiAttribute *a)'
452
+
453
+ typealias 'uiTextItalic', 'int'
454
+
455
+ try_extern 'uiAttribute *uiNewItalicAttribute(uiTextItalic italic)'
456
+ try_extern 'uiTextItalic uiAttributeItalic(const uiAttribute *a)'
457
+
458
+ typealias 'uiTextStretch', 'int'
459
+
460
+ try_extern 'uiAttribute *uiNewStretchAttribute(uiTextStretch stretch)'
461
+ try_extern 'uiTextStretch uiAttributeStretch(const uiAttribute *a)'
462
+ try_extern 'uiAttribute *uiNewColorAttribute(double r, double g, double b, double a)'
463
+ try_extern 'void uiAttributeColor(const uiAttribute *a, double *r, double *g, double *b, double *alpha)'
464
+ try_extern 'uiAttribute *uiNewBackgroundAttribute(double r, double g, double b, double a)'
465
+
466
+ typealias 'uiUnderline', 'int'
467
+
468
+ try_extern 'uiAttribute *uiNewUnderlineAttribute(uiUnderline u)'
469
+ try_extern 'uiUnderline uiAttributeUnderline(const uiAttribute *a)'
470
+
471
+ typealias 'uiUnderlineColor', 'int'
472
+
473
+ try_extern 'uiAttribute *uiNewUnderlineColorAttribute(uiUnderlineColor u, double r, double g, double b, double a)'
474
+ try_extern 'void uiAttributeUnderlineColor(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha)'
475
+
476
+ # uiOpenTypeFeatures
477
+
478
+ typealias 'uiOpenTypeFeaturesForEachFunc', 'void*'
479
+
480
+ try_extern 'uiOpenTypeFeatures *uiNewOpenTypeFeatures(void)'
481
+ try_extern 'void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf)'
482
+ try_extern 'uiOpenTypeFeatures *uiOpenTypeFeaturesClone(const uiOpenTypeFeatures *otf)'
483
+ try_extern 'void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value)'
484
+ try_extern 'void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d)'
485
+ try_extern 'int uiOpenTypeFeaturesGet(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value)'
486
+ try_extern 'void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data)'
487
+ try_extern 'uiAttribute *uiNewFeaturesAttribute(const uiOpenTypeFeatures *otf)'
488
+ try_extern 'const uiOpenTypeFeatures *uiAttributeFeatures(const uiAttribute *a)'
489
+
490
+ # uiAttributedString
491
+
492
+ typealias 'uiAttributedStringForEachAttributeFunc', 'void*'
493
+
494
+ try_extern 'uiAttributedString *uiNewAttributedString(const char *initialString)'
495
+ try_extern 'void uiFreeAttributedString(uiAttributedString *s)'
496
+ try_extern 'const char *uiAttributedStringString(const uiAttributedString *s)'
497
+ try_extern 'size_t uiAttributedStringLen(const uiAttributedString *s)'
498
+ try_extern 'void uiAttributedStringAppendUnattributed(uiAttributedString *s, const char *str)'
499
+ try_extern 'void uiAttributedStringInsertAtUnattributed(uiAttributedString *s, const char *str, size_t at)'
500
+ try_extern 'void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end)'
501
+ try_extern 'void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribute *a, size_t start, size_t end)'
502
+ try_extern 'void uiAttributedStringForEachAttribute(const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data)'
503
+ try_extern 'size_t uiAttributedStringNumGraphemes(uiAttributedString *s)'
504
+ try_extern 'size_t uiAttributedStringByteIndexToGrapheme(uiAttributedString *s, size_t pos)'
505
+ try_extern 'size_t uiAttributedStringGraphemeToByteIndex(uiAttributedString *s, size_t pos)'
506
+
507
+ # uiFont
508
+
509
+ FontDescriptor = struct [
510
+ 'char *Family',
511
+ 'double Size',
512
+ 'uiTextWeight Weight',
513
+ 'uiTextItalic Italic',
514
+ 'uiTextStretch Stretch'
515
+ ]
516
+
517
+ typealias 'uiDrawTextAlign', 'int'
518
+
519
+ DrawTextLayoutParams = struct [
520
+ 'uiAttributedString *String',
521
+ 'uiFontDescriptor *DefaultFont',
522
+ 'double Width',
523
+ 'uiDrawTextAlign Align'
524
+ ]
525
+
526
+ try_extern 'uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *params)'
527
+ try_extern 'void uiDrawFreeTextLayout(uiDrawTextLayout *tl)'
528
+ try_extern 'void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y)'
529
+ try_extern 'void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height)'
530
+
531
+ # uiFontButton
532
+
533
+ try_extern 'void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc)'
534
+ try_extern 'void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data)'
535
+ try_extern 'uiFontButton *uiNewFontButton(void)'
536
+ try_extern 'void uiFreeFontButtonFont(uiFontDescriptor *desc)'
537
+
538
+ typealias 'uiModifiers', 'int'
539
+
540
+ AreaMouseEvent = struct [
541
+ 'double X',
542
+ 'double Y',
543
+ 'double AreaWidth',
544
+ 'double AreaHeight',
545
+ 'int Down',
546
+ 'int Up',
547
+ 'int Count',
548
+ 'uiModifiers Modifiers',
549
+ 'uint64_t Held1To64'
550
+ ]
551
+
552
+ typealias 'uiExtKey', 'int'
553
+
554
+ AreaKeyEvent = struct [
555
+ 'char Key',
556
+ 'uiExtKey ExtKey',
557
+ 'uiModifiers Modifier',
558
+ 'uiModifiers Modifiers',
559
+ 'int Up'
560
+ ]
561
+
562
+ # uiColorButton
563
+
564
+ try_extern 'void uiColorButtonColor(uiColorButton *b, double *r, double *g, double *bl, double *a)'
565
+ try_extern 'void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, double a)'
566
+ try_extern 'void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data)'
567
+ try_extern 'uiColorButton *uiNewColorButton(void)'
568
+
569
+ # uiForm
570
+
571
+ try_extern 'void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)'
572
+ try_extern 'void uiFormDelete(uiForm *f, int index)'
573
+ try_extern 'int uiFormPadded(uiForm *f)'
574
+ try_extern 'void uiFormSetPadded(uiForm *f, int padded)'
575
+ try_extern 'uiForm *uiNewForm(void)'
576
+
577
+ typealias 'uiAlign', 'int'
578
+
579
+ typealias 'uiAt', 'int'
580
+
581
+ # uiGrid
582
+
583
+ try_extern 'void uiGridAppend(uiGrid *g, uiControl *c, int left, int top, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign)'
584
+ try_extern 'void uiGridInsertAt(uiGrid *g, uiControl *c, uiControl *existing, uiAt at, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign)'
585
+ try_extern 'int uiGridPadded(uiGrid *g)'
586
+ try_extern 'void uiGridSetPadded(uiGrid *g, int padded)'
587
+ try_extern 'uiGrid *uiNewGrid(void)'
588
+
589
+ # uiImage
590
+
591
+ try_extern 'uiImage *uiNewImage(double width, double height)'
592
+ try_extern 'void uiFreeImage(uiImage *i)'
593
+ try_extern 'void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int byteStride)'
594
+
595
+ # uiTable
596
+ try_extern 'void uiFreeTableValue(uiTableValue *v)'
597
+
598
+ typealias 'uiTableValueType', 'int'
599
+
600
+ try_extern 'uiTableValueType uiTableValueGetType(const uiTableValue *v)'
601
+ try_extern 'uiTableValue *uiNewTableValueString(const char *str)'
602
+ try_extern 'const char *uiTableValueString(const uiTableValue *v)'
603
+ try_extern 'uiTableValue *uiNewTableValueImage(uiImage *img)'
604
+ try_extern 'uiImage *uiTableValueImage(const uiTableValue *v)'
605
+ try_extern 'uiTableValue *uiNewTableValueInt(int i)'
606
+ try_extern 'int uiTableValueInt(const uiTableValue *v)'
607
+ try_extern 'uiTableValue *uiNewTableValueColor(double r, double g, double b, double a)'
608
+ try_extern 'void uiTableValueColor(const uiTableValue *v, double *r, double *g, double *b, double *a)'
609
+
610
+ TableModelHandler = struct [
611
+ 'int (*NumColumns)(uiTableModelHandler *, uiTableModel *)',
612
+ 'uiTableValueType (*ColumnType)(uiTableModelHandler *, uiTableModel *, int)',
613
+ 'int (*NumRows)(uiTableModelHandler *, uiTableModel *)',
614
+ 'uiTableValue *(*CellValue)(uiTableModelHandler *mh, uiTableModel *m, int row, int column)',
615
+ 'void (*SetCellValue)(uiTableModelHandler *, uiTableModel *, int, int, const uiTableValue *)'
616
+ ]
617
+
618
+ try_extern 'uiTableModel *uiNewTableModel(uiTableModelHandler *mh)'
619
+ try_extern 'void uiFreeTableModel(uiTableModel *m)'
620
+ try_extern 'void uiTableModelRowInserted(uiTableModel *m, int newIndex)'
621
+ try_extern 'void uiTableModelRowChanged(uiTableModel *m, int index)'
622
+ try_extern 'void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)'
623
+
624
+ TableTextColumnOptionalParams = struct [
625
+ 'int ColorModelColumn'
626
+ ]
627
+
628
+ TableParams = struct [
629
+ 'uiTableModel *Model',
630
+ 'int RowBackgroundColorModelColumn'
631
+ ]
632
+
633
+ try_extern 'void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)'
634
+ try_extern 'void uiTableAppendImageColumn(uiTable *t, const char *name, int imageModelColumn)'
635
+ try_extern 'void uiTableAppendImageTextColumn(uiTable *t, const char *name, int imageModelColumn, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)'
636
+ try_extern 'void uiTableAppendCheckboxColumn(uiTable *t, const char *name, int checkboxModelColumn, int checkboxEditableModelColumn)'
637
+ try_extern 'void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxModelColumn, int checkboxEditableModelColumn, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)'
638
+ try_extern 'void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressModelColumn)'
639
+ try_extern 'void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonModelColumn, int buttonClickableModelColumn)'
640
+ try_extern 'uiTable *uiNewTable(uiTableParams *params)'
217
641
  end
218
642
  end
@@ -0,0 +1,19 @@
1
+ module LibUI
2
+ module Utils
3
+ class << self
4
+ def convert_to_ruby_method(original_method_name)
5
+ underscore(original_method_name.delete_prefix('ui'))
6
+ end
7
+
8
+ # Converting camel case to underscore case in ruby
9
+ # https://stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby#1509939
10
+ def underscore(str)
11
+ str.gsub(/::/, '/')
12
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
13
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
14
+ .tr('-', '_')
15
+ .downcase
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LibUI
4
- VERSION = '0.0.1.alpha'
4
+ VERSION = '0.0.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-07 00:00:00.000000000 Z
11
+ date: 2020-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubyzip
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - 2xijok@gmail.com
@@ -77,6 +91,7 @@ files:
77
91
  - README.md
78
92
  - lib/libui.rb
79
93
  - lib/libui/ffi.rb
94
+ - lib/libui/utils.rb
80
95
  - lib/libui/version.rb
81
96
  - vendor/LICENSE
82
97
  - vendor/README.md
@@ -98,11 +113,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
113
  version: '2.5'
99
114
  required_rubygems_version: !ruby/object:Gem::Requirement
100
115
  requirements:
101
- - - ">"
116
+ - - ">="
102
117
  - !ruby/object:Gem::Version
103
- version: 1.3.1
118
+ version: '0'
104
119
  requirements: []
105
- rubygems_version: 3.0.3
120
+ rubygems_version: 3.1.4
106
121
  signing_key:
107
122
  specification_version: 4
108
123
  summary: Ruby bindings to libui