libui 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f74d579c937d71a61c613abe93ca07ae1bafa8c78933d7cd4f979fc92b327883
4
- data.tar.gz: f091c583e9fd5c53673232b4babc90f87c626a8185c4fcfb576ce9d89d36affa
3
+ metadata.gz: 6de141936b3efcb92a52161f0426d62485efe1e5aad3117f76cf97d0ddc8031b
4
+ data.tar.gz: b7ce62745c0c8dc93fc8ba0555a5240f0f56d73b68b6f6ba238153d6478d4f83
5
5
  SHA512:
6
- metadata.gz: 8897e6b92a054070600be68a2f646e7b79468ace0ed6b6c0de4713a2b3cf8e7a72ef35e6934d72f1d31112778a6f948c49ca74130d805e189a72c448144fd35f
7
- data.tar.gz: ad4f816e611238801cfefdbff60891f86703c92554fbca79691e4bcff1fd9a4dff45ebeabd78acd57aedaf56ff3f120b9cd16ca95788a469bb0cb58060194dcc
6
+ metadata.gz: 8caad6d8235897aa9b1c1c0782a425f85c4b7016d57464d69bfba9c3a1716eb5d3ea8520157ecc1a9209a299e863fc178c21897256e26e80b02a3beeff1be894
7
+ data.tar.gz: 2c328acfbc5862157124d6f31cf66950b07af1dacbbb81ee1f50340bb837bdb08e1d3b6abfaa9bfa5b8ecd81fe5e80a9d10e239c3489e534160ddb720135c502
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ![build](https://github.com/kojix2/libui/workflows/build/badge.svg)
4
4
  [![Gem Version](https://badge.fury.io/rb/libui.svg)](https://badge.fury.io/rb/libui)
5
+ <a href="https://github.com/AndyObtiva/glimmer-dsl-libui"><img alt="glimmer-dsl-libui" src="https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-logo-hi-res.svg" width="50" height="50" align="right"></a>
5
6
 
6
7
  :radio_button: [libui](https://github.com/andlabs/libui) - a portable GUI library - for Ruby
7
8
 
@@ -69,12 +70,13 @@ You can use [the documentation for libui's Go bindings](https://pkg.go.dev/githu
69
70
 
70
71
  ### Not object oriented?
71
72
 
72
- * At the moment, it is not object-oriented.
73
- * Instead of providing a half-baked object-oriented approach, leave it as is.
73
+ LibUI is not object-oriented, but provides high portability with minimal implementation.
74
+ If you want to write in an object-oriented way, please use the following DSLs built on top of LibUI.
74
75
 
75
76
  ### DSLs for LibUI
76
- * [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
77
- * [libui_paradise](https://rubygems.org/gems/libui_paradise)
77
+
78
+ * [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
79
+ * [libui_paradise](https://rubygems.org/gems/libui_paradise)
78
80
 
79
81
  ### How to use fiddle pointers?
80
82
 
@@ -100,6 +102,7 @@ font_button = UI.new_font_button
100
102
  # Allocate memory
101
103
  font_descriptor = UI::FFI::FontDescriptor.malloc
102
104
  font_descriptor.to_ptr.free = Fiddle::RUBY_FREE
105
+ # font_descriptor = UI::FFI::FontDescriptor.malloc(Fiddle::RUBY_FREE) # fiddle 1.0.1 or higher
103
106
 
104
107
  UI.font_button_on_changed(font_button) do
105
108
  UI.font_button_font(font_button, font_descriptor)
data/lib/libui/ffi.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'fiddle/import'
4
2
  require_relative 'fiddle_patch'
5
3
 
@@ -36,7 +34,7 @@ module LibUI
36
34
 
37
35
  # https://github.com/andlabs/libui/blob/master/ui.h
38
36
  # keep same order
39
-
37
+
40
38
  try_extern 'const char *uiInit(uiInitOptions *options)'
41
39
  try_extern 'void uiUninit(void)'
42
40
  try_extern 'void uiFreeInitError(const char *err)'
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module LibUI
4
2
  module LibUIBase
5
3
  FFI.func_map.each_key do |original_method_name|
@@ -12,24 +10,33 @@ module LibUI
12
10
 
13
11
  # The proc object is converted to a Closure::BlockCaller object.
14
12
  args.map!.with_index do |arg, idx|
15
- if arg.is_a?(Proc)
16
- # The types of the function arguments are recorded beforehand.
17
- # See the monkey patch in ffi.rb.
18
- callback = Fiddle::Closure::BlockCaller.new(
19
- *func.callback_argument_types[idx][1..2], &arg
20
- )
21
- # Protect from GC
22
- # See https://github.com/kojix2/LibUI/issues/8
23
- receiver = args[0]
24
- if receiver.instance_variable_defined?(:@callbacks)
25
- receiver.instance_variable_get(:@callbacks) << callback
26
- else
27
- receiver.instance_variable_set(:@callbacks, [callback])
28
- end
29
- callback
13
+ next arg unless arg.is_a?(Proc)
14
+
15
+ # now arg must be Proc
16
+
17
+ # The types of the function arguments are stored in advance.
18
+ # See the monkey patch in ffi.rb.
19
+ _f, ret_type, arg_types = func.callback_argument_types[idx]
20
+ # TODO: raise some nice error if _f is nil.
21
+
22
+ callback = Fiddle::Closure::BlockCaller.new(
23
+ ret_type, arg_types, &arg
24
+ )
25
+ # Protect from GC
26
+ # by giving the owner object a reference to the callback.
27
+ # See https://github.com/kojix2/LibUI/issues/8
28
+ owner = if idx == 0 or # UI.queue_main{}
29
+ owner.frozen? # UI.timer(100) {}
30
+ LibUIBase # or UI is better?
31
+ else
32
+ args[0] # receiver
33
+ end
34
+ if owner.instance_variable_defined?(:@callbacks)
35
+ owner.instance_variable_get(:@callbacks) << callback
30
36
  else
31
- arg
37
+ owner.instance_variable_set(:@callbacks, [callback])
32
38
  end
39
+ callback
33
40
  end
34
41
 
35
42
  # Make it possible to omit the last nil. This may be an over-optimization.
data/lib/libui/version.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module LibUI
4
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
5
3
  end
data/lib/libui.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative 'libui/version'
4
2
  require_relative 'libui/utils'
5
3
 
@@ -35,6 +33,21 @@ module LibUI
35
33
  warn 'error'
36
34
  warn UI.free_init_error(init)
37
35
  end
36
+
37
+ def open_type_features_add(otf, a, b, c, d, value)
38
+ a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
39
+ super(otf, a, b, c, d, value)
40
+ end
41
+
42
+ def open_type_features_remove(otf, a, b, c, d)
43
+ a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
44
+ super(otf, a, b, c, d)
45
+ end
46
+
47
+ def open_type_features_get(otf, a, b, c, d, value)
48
+ a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
49
+ super(otf, a, b, c, d, value)
50
+ end
38
51
  end
39
52
 
40
53
  # UI_ENUM
metadata CHANGED
@@ -1,85 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
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'
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description:
84
14
  email:
85
15
  - 2xijok@gmail.com