libui 0.1.3.pre-x64-mingw32

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b7867dff67214b0276ed98d37c224d33c2456de92c244d1194f06fa467f3f1d1
4
+ data.tar.gz: d931cbc378194b1bd112e7cc9028a56d4e140e39db4380603d126304c058f95c
5
+ SHA512:
6
+ metadata.gz: a906911d11785965e42d51562ce34e243cb906e382be1813ed43fd6abfaf7b4dfa2eef398a3e087126a0e0fc5c361d0b074168835f62496d08ec9cca9992fc7b
7
+ data.tar.gz: 5c1a86f8c50a9297492b48c96be5ab77471939f5d2766e16393833aeba80c724f948858647b5b6363b7f4f0d4d280e85e8e367b5bfb55b6a338cf7d59ea87aa7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 kojix2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,251 @@
1
+ # LibUI
2
+
3
+ [![test](https://github.com/kojix2/LibUI/actions/workflows/test.yml/badge.svg)](https://github.com/kojix2/LibUI/actions/workflows/test.yml)
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>
6
+ [![Pre-build](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml/badge.svg?branch=pre-build)](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml)
7
+
8
+ LibUI is a Ruby wrapper for libui and libui-ng.
9
+
10
+ :rocket: [libui-ng](https://github.com/libui-ng/libui-ng) - A cross-platform portable GUI library
11
+
12
+ :radio_button: [libui](https://github.com/andlabs/libui) - Original version by andlabs.
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ gem install libui
18
+ ```
19
+
20
+ - The gem package includes the [official release](https://github.com/andlabs/libui/releases/tag/alpha4.1) of the libui shared library version 4.1 for Windows, Mac, and Linux.
21
+ - Namely `libui.dll`, `libui.dylib`, and `libui.so` (only 1.8MB in total).
22
+ - No dependencies required.
23
+ - The libui gem uses the standard Ruby library [Fiddle](https://github.com/ruby/fiddle) to call C functions.
24
+
25
+ | Windows | Mac | Linux |
26
+ | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
27
+ | <img src="https://user-images.githubusercontent.com/5798442/103118046-900ea780-46b0-11eb-81fc-32626762e4df.png"> | <img src="https://user-images.githubusercontent.com/5798442/103118059-99980f80-46b0-11eb-9d12-324ec4d297c9.png"> | <img src="https://user-images.githubusercontent.com/5798442/103118068-a0bf1d80-46b0-11eb-8c5c-3bdcc3dcfb26.png"> |
28
+
29
+ Notes:
30
+
31
+ - If you are using the 32-bit (x86) version of Ruby, you need to download the 32-bit (x86) native dll. See the [Development](#development) section.
32
+ - On Windows, libui may not work due to missing DLLs. In that case, you need to install [Visual C++ Redistributable](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist). See ([#48](https://github.com/kojix2/LibUI/issues/48))
33
+ - Users with [Raspberry Pi](https://www.raspberrypi.com/) or other platforms will need to compile the C libui library. See the [Development](#development) section.
34
+
35
+ ## Usage
36
+
37
+ ```ruby
38
+ require 'libui'
39
+
40
+ UI = LibUI
41
+
42
+ UI.init
43
+
44
+ main_window = UI.new_window('hello world', 200, 100, 1)
45
+
46
+ button = UI.new_button('Button')
47
+
48
+ UI.button_on_clicked(button) do
49
+ UI.msg_box(main_window, 'Information', 'You clicked the button')
50
+ end
51
+
52
+ UI.window_on_closing(main_window) do
53
+ puts 'Bye Bye'
54
+ UI.control_destroy(main_window)
55
+ UI.quit
56
+ 0
57
+ end
58
+
59
+ UI.window_set_child(main_window, button)
60
+ UI.control_show(main_window)
61
+
62
+ UI.main
63
+ UI.quit
64
+ ```
65
+
66
+ For more examples, see the [examples](https://github.com/kojix2/libui/tree/main/examples) directory.
67
+
68
+ ### General Rules
69
+
70
+ Compared to the original libui library written in C:
71
+
72
+ - Method names use snake_case.
73
+ - The last argument can be omitted if it's nil.
74
+ - A block can be passed as a callback.
75
+ - The block will be converted to a Proc object and added as the last argument.
76
+ - The last argument can still be omitted when nil.
77
+
78
+ You can use [the documentation for libui's Go bindings](https://pkg.go.dev/github.com/andlabs/ui) as a reference.
79
+
80
+ ### DSLs for LibUI
81
+
82
+ LibUI is not object-oriented because it is a thin Ruby wrapper (binding) for the procedural C libui library, mirroring its API structure.
83
+
84
+ To build actual applications, it is recommended to use a DSL for LibUI, as they enable writing object-oriented code the Ruby way (instead of procedural code the C way):
85
+
86
+ - [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
87
+ - [libui_paradise](https://rubygems.org/gems/libui_paradise)
88
+
89
+ ### Working with fiddle pointers
90
+
91
+ ```ruby
92
+ require 'libui'
93
+ UI = LibUI
94
+ UI.init
95
+ ```
96
+
97
+ To convert a pointer to a string:
98
+
99
+ ```ruby
100
+ label = UI.new_label("Ruby")
101
+ p pointer = UI.label_text(label) # #<Fiddle::Pointer>
102
+ p pointer.to_s # Ruby
103
+ ```
104
+
105
+ If you need to use C structs, you can do the following:
106
+
107
+ ```ruby
108
+ font_button = UI.new_font_button
109
+
110
+ # Allocate memory
111
+ font_descriptor = UI::FFI::FontDescriptor.malloc
112
+ font_descriptor.to_ptr.free = Fiddle::RUBY_FREE
113
+ # font_descriptor = UI::FFI::FontDescriptor.malloc(Fiddle::RUBY_FREE) # fiddle 1.0.1 or higher
114
+
115
+ UI.font_button_on_changed(font_button) do
116
+ UI.font_button_font(font_button, font_descriptor)
117
+ p family: font_descriptor.Family.to_s,
118
+ size: font_descriptor.Size,
119
+ weight: font_descriptor.Weight,
120
+ italic: font_descriptor.Italic,
121
+ stretch: font_descriptor.Stretch
122
+ end
123
+ ```
124
+
125
+ - Callbacks
126
+ - In Ruby/Fiddle, a C callback function is written as an object of
127
+ `Fiddle::Closure::BlockCaller` or `Fiddle::Closure`.
128
+ Be careful about Ruby's garbage collection - if the function object is collected, memory will be freed resulting in a segmentation violation when the callback is invoked.
129
+
130
+ ```ruby
131
+ # Assign to a local variable to prevent it from being collected by GC.
132
+ handler.MouseEvent = (c1 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
133
+ handler.MouseCrossed = (c2 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
134
+ handler.DragBroken = (c3 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
135
+ ```
136
+
137
+ ### Creating a Windows executable (.exe) with OCRA
138
+
139
+ OCRA (One-Click Ruby Application) builds Windows executables from Ruby source code.
140
+
141
+ - https://github.com/larsch/ocra/
142
+
143
+ To build an exe with Ocra, include 3 DLLs from the ruby_builtin_dlls folder:
144
+
145
+ ```sh
146
+ ocra examples/control_gallery.rb ^
147
+ --dll ruby_builtin_dlls/libssp-0.dll ^
148
+ --dll ruby_builtin_dlls/libgmp-10.dll ^
149
+ --dll ruby_builtin_dlls/libffi-7.dll ^
150
+ --gem-all=fiddle ^
151
+ ```
152
+
153
+ Add additional options below if necessary:
154
+
155
+ ```sh
156
+ --window ^
157
+ --add-all-core ^
158
+ --chdir-first ^
159
+ --icon assets\app.ico ^
160
+ --verbose ^
161
+ --output out\gallery.exe
162
+ ```
163
+
164
+ ## Development
165
+
166
+ ```sh
167
+ git clone https://github.com/kojix2/libui
168
+ cd libui
169
+ bundle install
170
+ bundle exec rake vendor:auto # vendor:build
171
+ bundle exec rake test
172
+ ```
173
+
174
+ ### Pre-built shared libraries for libui-ng
175
+
176
+ Use the following rake tasks to download the shared library required for your platform:
177
+
178
+ `rake -T`
179
+
180
+ ```
181
+ rake vendor:build[hash] # Build libui-ng latest master [commit hash]
182
+ rake vendor:libui-ng:macos # Download latest official pre-build for Mac to vendor directory
183
+ rake vendor:libui-ng:ubuntu_x64 # Download latest official pre-build for Ubuntu to vendor directory
184
+ rake vendor:macos_arm64 # Download pre-build for Mac to vendor directory
185
+ rake vendor:macos_x64 # Download pre-build for Mac to vendor directory
186
+ rake vendor:raspbian_aarch64 # Download pre-build for Raspbian to vendor directory
187
+ rake vendor:ubuntu_x64 # Download pre-build for Ubuntu to vendor directory
188
+ rake vendor:windows_x64 # Download pre-build for Windows to vendor directory
189
+ rake vendor:windows_x86 # Download pre-build for Windows to vendor directory
190
+ ```
191
+
192
+ For example, if you are using a 32-bit (x86) version of Ruby on Windows, type `vendor:windows_x86`.
193
+ These shared libraries are [artifacts](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml) of the [pre-build branch](https://github.com/kojix2/libui-ng/tree/pre-build) of [kojix2/libui-ng](https://github.com/kojix2/libui-ng). In that case, please let us know.
194
+
195
+ ### Using C libui compiled from source code
196
+
197
+ The following Rake task will compile libui-ng. meson or ninja is required.
198
+
199
+ `bundle exec rake vendor:build`
200
+
201
+ Alternatively, you can tell Ruby LibUI the location of shared libraries. Set the environment variable `LIBUIDIR` to specify the path to the shared library. (See [#46](https://github.com/kojix2/LibUI/issues/46#issuecomment-1041575792)). This is especially useful on platforms where the LibUI gem does not provide shared library, such as the ARM architecture (used in devices like Raspberry Pi).
202
+
203
+ Another simple approach is to replace the shared libraries in the gem vendor directory with the ones you have compiled.
204
+
205
+ ### Publishing gems
206
+
207
+ ```sh
208
+ ls vendor # check the vendor directory
209
+ rm -rf pkg # remove previously built gems
210
+ rake build_platform # build gems
211
+
212
+ # Check the contents of the gem
213
+ find pkg -name *.gem -exec sh -c "echo; echo \# {}; tar -O -f {} -x data.tar.gz | tar zt" \;
214
+
215
+ rake release_platform # publish gems
216
+ ```
217
+
218
+ ### libui or libui-ng
219
+
220
+ - From version 0.1.X, we plan to support only libui-ng/libui-ng.
221
+ - Version 0.0.X only supports andlabs/libui.
222
+
223
+ ## Contributing
224
+
225
+ Would you like to contribute to LibUI?
226
+
227
+ - Please feel free to send us your [pull requests](https://github.com/kojix2/libui/pulls).
228
+ - Small corrections, such as typo fixes, are appreciated.
229
+ - Did you find any bugs? Submit them in the [issues](https://github.com/kojix2/LibUI/issues) section!
230
+
231
+ Do you need commit rights?
232
+
233
+ - If you need commit rights to my repository or want to get admin rights and take over the project, please feel free to contact @kojix2.
234
+ - Many OSS projects become abandoned because only the founder has commit rights to the original repository.
235
+
236
+ Support libui-ng development
237
+
238
+ - Contributing to the development of libui-ng is a contribution to the entire libui community, including Ruby's LibUI.
239
+ - For example, it would be easier to release LibUI in Ruby if libui-ng could be built easily and official shared libraries could be distributed.
240
+
241
+ ## Acknowledgements
242
+
243
+ This project is inspired by libui-ruby.
244
+
245
+ - https://github.com/jamescook/libui-ruby
246
+
247
+ While libui-ruby uses [Ruby-FFI](https://github.com/ffi/ffi), this gem uses [Fiddle](https://github.com/ruby/fiddle).
248
+
249
+ ## License
250
+
251
+ [MIT License](https://opensource.org/licenses/MIT).