libui 0.1.2-x86_64-darwin → 0.2.0.pre-x86_64-darwin
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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +118 -66
- data/lib/libui/error.rb +10 -0
- data/lib/libui/ffi.rb +18 -4
- data/lib/libui/fiddle_patch.rb +8 -0
- data/lib/libui/version.rb +1 -1
- data/lib/libui.rb +46 -9
- data/vendor/README.md +20 -6
- data/vendor/libui.x86_64.dylib +0 -0
- metadata +21 -6
- data/vendor/libui.dylib +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4f93f77a77f68890634f59988823870d3f80baac5820856ac551dac128c47228
         | 
| 4 | 
            +
              data.tar.gz: 0aa9e66cbf90e9a5c3cfb1d86f11e82200f82eac2c9e88d21b2aeb1ad60d3275
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: abcecf91a66544d8d5365eb98c72b89b5fb8a638dbf7940f4a1fa5232c04b0d37c445ce49994bbec583926e63d6b008d9c519e4ca6f6ca5d390b8a24960bb972
         | 
| 7 | 
            +
              data.tar.gz: 1b22d167e1a2b692f5634390856274a9171b129ea1b8509cf381ea5f75ce06ecc3ade77808135bd78fb13637f7a327a3d2a8d386e1b85171313f0c09569f568e
         | 
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,34 +1,47 @@ | |
| 1 1 | 
             
            # LibUI
         | 
| 2 2 |  | 
| 3 | 
            -
            ](https://github.com/kojix2/LibUI/actions/workflows/test.yml)
         | 
| 4 4 | 
             
            [](https://badge.fury.io/rb/libui)
         | 
| 5 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 | 
            +
            [](https://github.com/kojix2/libui-ng/actions/workflows/pre-build.yml)
         | 
| 7 | 
            +
            [](https://tokei.kojix2.net/github/kojix2/LibUI)
         | 
| 6 8 |  | 
| 7 | 
            -
            LibUI is a Ruby wrapper for libui  | 
| 9 | 
            +
            LibUI is a Ruby wrapper for libui family.
         | 
| 8 10 |  | 
| 9 11 | 
             
            :rocket: [libui-ng](https://github.com/libui-ng/libui-ng) - A cross-platform portable GUI library
         | 
| 10 12 |  | 
| 11 | 
            -
            : | 
| 13 | 
            +
            :wrench: [libui-dev](https://github.com/petabyt/libui-dev) - Native UI library for C - with some extras
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            :radio_button: [libui](https://github.com/andlabs/libui) - Original version by andlabs.
         | 
| 12 16 |  | 
| 13 17 | 
             
            ## Installation
         | 
| 14 18 |  | 
| 19 | 
            +
            It is recommended to use libui-ng, via the --pre commandline flag:
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ```sh
         | 
| 22 | 
            +
            gem install libui --pre # libui-ng; this will fetch libui-0.1.3.pre-x86_64-linux.gem
         | 
| 23 | 
            +
            ```
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            If for some reason you would like to install the slightly older libui-0.1.2.gem release, issue:
         | 
| 26 | 
            +
             | 
| 15 27 | 
             
            ```sh
         | 
| 16 28 | 
             
            gem install libui
         | 
| 17 29 | 
             
            ```
         | 
| 18 30 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
               | 
| 21 | 
            -
             | 
| 22 | 
            -
               | 
| 31 | 
            +
            - The gem package includes the libui-ng shared library for Windows, Mac, and Linux.
         | 
| 32 | 
            +
              - Namely `libui.dll`, `libui.dylib`, or `libui.so`.
         | 
| 33 | 
            +
            - No dependencies required.
         | 
| 34 | 
            +
              - The libui gem uses the standard Ruby library [Fiddle](https://github.com/ruby/fiddle) to call C functions.
         | 
| 23 35 |  | 
| 24 | 
            -
            | Windows | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 36 | 
            +
            | Windows                                                                                                          | Mac                                                                                                              | Linux                                                                                                            |
         | 
| 37 | 
            +
            | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
         | 
| 38 | 
            +
            | <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"> |
         | 
| 27 39 |  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 40 | 
            +
            Notes:
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            - 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.
         | 
| 43 | 
            +
            - 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))
         | 
| 44 | 
            +
            - Users with [Raspberry Pi](https://www.raspberrypi.com/) or other platforms will need to compile the C libui library. See the [Development](#development) section.
         | 
| 32 45 |  | 
| 33 46 | 
             
            ## Usage
         | 
| 34 47 |  | 
| @@ -61,30 +74,30 @@ UI.main | |
| 61 74 | 
             
            UI.quit
         | 
| 62 75 | 
             
            ```
         | 
| 63 76 |  | 
| 64 | 
            -
             | 
| 77 | 
            +
            For more examples, see the [examples](https://github.com/kojix2/libui/tree/main/examples) directory.
         | 
| 65 78 |  | 
| 66 79 | 
             
            ### General Rules
         | 
| 67 80 |  | 
| 68 | 
            -
            Compared to original libui written in C | 
| 81 | 
            +
            Compared to the original libui library written in C:
         | 
| 69 82 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
               | 
| 74 | 
            -
               | 
| 83 | 
            +
            - Method names use snake_case.
         | 
| 84 | 
            +
            - The last argument can be omitted if it's nil.
         | 
| 85 | 
            +
            - A block can be passed as a callback.
         | 
| 86 | 
            +
              - The block will be converted to a Proc object and added as the last argument.
         | 
| 87 | 
            +
              - The last argument can still be omitted when nil.
         | 
| 75 88 |  | 
| 76 89 | 
             
            You can use [the documentation for libui's Go bindings](https://pkg.go.dev/github.com/andlabs/ui) as a reference.
         | 
| 77 90 |  | 
| 78 91 | 
             
            ### DSLs for LibUI
         | 
| 79 92 |  | 
| 80 | 
            -
            LibUI is  | 
| 93 | 
            +
            LibUI is not object-oriented because it is a thin Ruby wrapper (binding) for the procedural C libui library, mirroring its API structure.
         | 
| 81 94 |  | 
| 82 | 
            -
             | 
| 95 | 
            +
            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):
         | 
| 83 96 |  | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 97 | 
            +
            - [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
         | 
| 98 | 
            +
            - [libui_paradise](https://rubygems.org/gems/libui_paradise)
         | 
| 86 99 |  | 
| 87 | 
            -
            ###  | 
| 100 | 
            +
            ### Working with fiddle pointers
         | 
| 88 101 |  | 
| 89 102 | 
             
            ```ruby
         | 
| 90 103 | 
             
            require 'libui'
         | 
| @@ -92,7 +105,7 @@ UI = LibUI | |
| 92 105 | 
             
            UI.init
         | 
| 93 106 | 
             
            ```
         | 
| 94 107 |  | 
| 95 | 
            -
             | 
| 108 | 
            +
            To convert a pointer to a string:
         | 
| 96 109 |  | 
| 97 110 | 
             
            ```ruby
         | 
| 98 111 | 
             
            label = UI.new_label("Ruby")
         | 
| @@ -100,12 +113,12 @@ p pointer = UI.label_text(label) # #<Fiddle::Pointer> | |
| 100 113 | 
             
            p pointer.to_s # Ruby
         | 
| 101 114 | 
             
            ```
         | 
| 102 115 |  | 
| 103 | 
            -
            If you need to use C structs, you can do the following | 
| 116 | 
            +
            If you need to use C structs, you can do the following:
         | 
| 104 117 |  | 
| 105 118 | 
             
            ```ruby
         | 
| 106 119 | 
             
            font_button = UI.new_font_button
         | 
| 107 120 |  | 
| 108 | 
            -
            # Allocate memory | 
| 121 | 
            +
            # Allocate memory
         | 
| 109 122 | 
             
            font_descriptor = UI::FFI::FontDescriptor.malloc
         | 
| 110 123 | 
             
            font_descriptor.to_ptr.free = Fiddle::RUBY_FREE
         | 
| 111 124 | 
             
            # font_descriptor = UI::FFI::FontDescriptor.malloc(Fiddle::RUBY_FREE) # fiddle 1.0.1 or higher
         | 
| @@ -120,26 +133,25 @@ UI.font_button_on_changed(font_button) do | |
| 120 133 | 
             
            end
         | 
| 121 134 | 
             
            ```
         | 
| 122 135 |  | 
| 123 | 
            -
             | 
| 124 | 
            -
               | 
| 125 | 
            -
                `Fiddle::Closure::BlockCaller` or `Fiddle::Closure`. | 
| 126 | 
            -
                 | 
| 127 | 
            -
                If the function object is collected, memory will be freed 
         | 
| 128 | 
            -
                and a segmentation violation will occur when the callback is invoked.
         | 
| 136 | 
            +
            - Callbacks
         | 
| 137 | 
            +
              - In Ruby/Fiddle, a C callback function is written as an object of
         | 
| 138 | 
            +
                `Fiddle::Closure::BlockCaller` or `Fiddle::Closure`.
         | 
| 139 | 
            +
                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 140 |  | 
| 130 141 | 
             
            ```ruby
         | 
| 131 | 
            -
            # to a local variable to prevent it from being collected by GC.
         | 
| 142 | 
            +
            # Assign to a local variable to prevent it from being collected by GC.
         | 
| 132 143 | 
             
            handler.MouseEvent   = (c1 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
         | 
| 133 144 | 
             
            handler.MouseCrossed = (c2 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
         | 
| 134 145 | 
             
            handler.DragBroken   = (c3 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
         | 
| 135 146 | 
             
            ```
         | 
| 136 147 |  | 
| 137 | 
            -
            ###  | 
| 148 | 
            +
            ### Creating a Windows executable (.exe) with OCRA
         | 
| 149 | 
            +
             | 
| 150 | 
            +
            OCRA (One-Click Ruby Application) builds Windows executables from Ruby source code.
         | 
| 138 151 |  | 
| 139 | 
            -
             | 
| 140 | 
            -
            * https://github.com/larsch/ocra/
         | 
| 152 | 
            +
            - https://github.com/larsch/ocra/
         | 
| 141 153 |  | 
| 142 | 
            -
             | 
| 154 | 
            +
            To build an exe with Ocra, include 3 DLLs from the ruby_builtin_dlls folder:
         | 
| 143 155 |  | 
| 144 156 | 
             
            ```sh
         | 
| 145 157 | 
             
            ocra examples/control_gallery.rb        ^
         | 
| @@ -149,7 +161,7 @@ ocra examples/control_gallery.rb        ^ | |
| 149 161 | 
             
              --gem-all=fiddle                      ^
         | 
| 150 162 | 
             
            ```
         | 
| 151 163 |  | 
| 152 | 
            -
            Add additional options below if necessary | 
| 164 | 
            +
            Add additional options below if necessary:
         | 
| 153 165 |  | 
| 154 166 | 
             
            ```sh
         | 
| 155 167 | 
             
              --window                              ^
         | 
| @@ -162,59 +174,99 @@ Add additional options below if necessary. | |
| 162 174 |  | 
| 163 175 | 
             
            ## Development
         | 
| 164 176 |  | 
| 165 | 
            -
            LibUI is not object-oriented, but it provides high portability with a minimal implementation. 
         | 
| 166 | 
            -
             | 
| 167 177 | 
             
            ```sh
         | 
| 168 178 | 
             
            git clone https://github.com/kojix2/libui
         | 
| 169 179 | 
             
            cd libui
         | 
| 170 180 | 
             
            bundle install
         | 
| 171 | 
            -
            bundle exec rake vendor: | 
| 181 | 
            +
            bundle exec rake vendor:auto # vendor:build
         | 
| 172 182 | 
             
            bundle exec rake test
         | 
| 173 183 | 
             
            ```
         | 
| 174 184 |  | 
| 175 | 
            -
             | 
| 185 | 
            +
            ### Pre-built shared libraries for libui-ng
         | 
| 186 | 
            +
             | 
| 187 | 
            +
            Use the following rake tasks to download the shared library required for your platform:
         | 
| 176 188 |  | 
| 177 189 | 
             
            `rake -T`
         | 
| 178 190 |  | 
| 179 191 | 
             
            ```
         | 
| 180 | 
            -
            rake vendor: | 
| 181 | 
            -
            rake vendor: | 
| 182 | 
            -
            rake vendor: | 
| 183 | 
            -
            rake vendor: | 
| 184 | 
            -
            rake vendor: | 
| 185 | 
            -
            rake vendor: | 
| 186 | 
            -
            rake vendor: | 
| 187 | 
            -
            rake vendor: | 
| 192 | 
            +
            rake vendor:build[hash]          # Build libui-ng latest master [commit hash]
         | 
| 193 | 
            +
            rake vendor:libui-ng:macos       # Download latest official pre-build for Mac to vendor directory
         | 
| 194 | 
            +
            rake vendor:libui-ng:ubuntu_x64  # Download latest official pre-build for Ubuntu to vendor directory
         | 
| 195 | 
            +
            rake vendor:macos_arm64          # Download pre-build for Mac to vendor directory
         | 
| 196 | 
            +
            rake vendor:macos_x64            # Download pre-build for Mac to vendor directory
         | 
| 197 | 
            +
            rake vendor:raspbian_aarch64     # Download pre-build for Raspbian to vendor directory
         | 
| 198 | 
            +
            rake vendor:ubuntu_x64           # Download pre-build for Ubuntu to vendor directory
         | 
| 199 | 
            +
            rake vendor:windows_x64          # Download pre-build for Windows to vendor directory
         | 
| 200 | 
            +
            rake vendor:windows_x86          # Download pre-build for Windows to vendor directory
         | 
| 188 201 | 
             
            ```
         | 
| 189 202 |  | 
| 190 | 
            -
            For example,  | 
| 203 | 
            +
            For example, if you are using a 32-bit (x86) version of Ruby on Windows, type `vendor:windows_x86`.
         | 
| 204 | 
            +
            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.
         | 
| 205 | 
            +
             | 
| 206 | 
            +
            ### Using C libui compiled from source code
         | 
| 207 | 
            +
             | 
| 208 | 
            +
            The following Rake task will compile libui-ng. meson or ninja is required.
         | 
| 191 209 |  | 
| 192 | 
            -
             | 
| 210 | 
            +
            `bundle exec rake vendor:build`
         | 
| 193 211 |  | 
| 194 | 
            -
             | 
| 212 | 
            +
            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).
         | 
| 195 213 |  | 
| 196 214 | 
             
            Another simple approach is to replace the shared libraries in the gem vendor directory with the ones you have compiled.
         | 
| 197 215 |  | 
| 216 | 
            +
            ### Publishing gems
         | 
| 217 | 
            +
             | 
| 218 | 
            +
            #### Automated Publishing
         | 
| 219 | 
            +
             | 
| 220 | 
            +
            Push a version tag to automatically publish platform-specific gems:
         | 
| 221 | 
            +
             | 
| 222 | 
            +
            ```sh
         | 
| 223 | 
            +
            git tag v0.1.3
         | 
| 224 | 
            +
            git push origin v0.1.3
         | 
| 225 | 
            +
            ```
         | 
| 226 | 
            +
             | 
| 227 | 
            +
            Requires `RUBYGEMS_API_KEY` repository secret with scoped API key.
         | 
| 228 | 
            +
             | 
| 229 | 
            +
            #### Manual Publishing
         | 
| 230 | 
            +
             | 
| 231 | 
            +
            ```sh
         | 
| 232 | 
            +
            ls vendor             # check the vendor directory
         | 
| 233 | 
            +
            rm -rf pkg            # remove previously built gems
         | 
| 234 | 
            +
            rake build_platform   # build gems
         | 
| 235 | 
            +
             | 
| 236 | 
            +
            # Check the contents of the gem
         | 
| 237 | 
            +
            find pkg -name *.gem -exec sh -c "echo; echo \# {}; tar -O -f {} -x data.tar.gz | tar zt" \;
         | 
| 238 | 
            +
             | 
| 239 | 
            +
            rake release_platform # publish gems
         | 
| 240 | 
            +
            ```
         | 
| 241 | 
            +
             | 
| 198 242 | 
             
            ### libui or libui-ng
         | 
| 199 243 |  | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 244 | 
            +
            - From version 0.1.X, we plan to support only libui-ng/libui-ng.
         | 
| 245 | 
            +
            - Version 0.0.X only supports andlabs/libui.
         | 
| 202 246 |  | 
| 203 247 | 
             
            ## Contributing
         | 
| 204 248 |  | 
| 205 | 
            -
            Would you like to  | 
| 206 | 
            -
             | 
| 207 | 
            -
             | 
| 208 | 
            -
             | 
| 249 | 
            +
            Would you like to contribute to LibUI?
         | 
| 250 | 
            +
             | 
| 251 | 
            +
            - Please feel free to send us your [pull requests](https://github.com/kojix2/libui/pulls).
         | 
| 252 | 
            +
              - Small corrections, such as typo fixes, are appreciated.
         | 
| 253 | 
            +
            - Did you find any bugs? Submit them in the [issues](https://github.com/kojix2/LibUI/issues) section!
         | 
| 254 | 
            +
             | 
| 255 | 
            +
            Do you need commit rights?
         | 
| 256 | 
            +
             | 
| 257 | 
            +
            - 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.
         | 
| 258 | 
            +
            - Many OSS projects become abandoned because only the founder has commit rights to the original repository.
         | 
| 259 | 
            +
             | 
| 260 | 
            +
            Support libui-ng development
         | 
| 209 261 |  | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 262 | 
            +
            - Contributing to the development of libui-ng is a contribution to the entire libui community, including Ruby's LibUI.
         | 
| 263 | 
            +
            - 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.
         | 
| 212 264 |  | 
| 213 | 
            -
            ##  | 
| 265 | 
            +
            ## Acknowledgements
         | 
| 214 266 |  | 
| 215 267 | 
             
            This project is inspired by libui-ruby.
         | 
| 216 268 |  | 
| 217 | 
            -
             | 
| 269 | 
            +
            - https://github.com/jamescook/libui-ruby
         | 
| 218 270 |  | 
| 219 271 | 
             
            While libui-ruby uses [Ruby-FFI](https://github.com/ffi/ffi), this gem uses [Fiddle](https://github.com/ruby/fiddle).
         | 
| 220 272 |  | 
    
        data/lib/libui/error.rb
    ADDED
    
    
    
        data/lib/libui/ffi.rb
    CHANGED
    
    | @@ -1,15 +1,24 @@ | |
| 1 1 | 
             
            require 'fiddle/import'
         | 
| 2 2 | 
             
            require_relative 'fiddle_patch'
         | 
| 3 | 
            +
            require_relative 'error'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module LibUI
         | 
| 6 | 
            +
              class Error < StandardError; end
         | 
| 7 | 
            +
             | 
| 5 8 | 
             
              module FFI
         | 
| 6 9 | 
             
                extend Fiddle::Importer
         | 
| 7 10 | 
             
                extend FiddlePatch
         | 
| 8 11 |  | 
| 9 | 
            -
                 | 
| 10 | 
            -
                   | 
| 11 | 
            -
                 | 
| 12 | 
            -
                  raise  | 
| 12 | 
            +
                if LibUI.ffi_lib.nil?
         | 
| 13 | 
            +
                  raise LibraryNotFoundError, 'Could not find libui shared library. LibUI.ffi_lib is nil.'
         | 
| 14 | 
            +
                elsif !File.exist?(LibUI.ffi_lib)
         | 
| 15 | 
            +
                  raise LibraryNotFoundError, "Could not find libui shared library: #{LibUI.ffi_lib}"
         | 
| 16 | 
            +
                else
         | 
| 17 | 
            +
                  begin
         | 
| 18 | 
            +
                    dlload LibUI.ffi_lib
         | 
| 19 | 
            +
                  rescue LoadError
         | 
| 20 | 
            +
                    raise LibraryLoadError, "Could not load libui shared library: #{LibUI.ffi_lib}"
         | 
| 21 | 
            +
                  end
         | 
| 13 22 | 
             
                end
         | 
| 14 23 |  | 
| 15 24 | 
             
                class << self
         | 
| @@ -18,6 +27,8 @@ module LibUI | |
| 18 27 | 
             
                  def try_extern(signature, *opts)
         | 
| 19 28 | 
             
                    extern(signature, *opts)
         | 
| 20 29 | 
             
                  rescue StandardError => e
         | 
| 30 | 
            +
                    # Do not raise error when the function is not found
         | 
| 31 | 
            +
                    # because some functions may not be available on older versions of libui.
         | 
| 21 32 | 
             
                    warn "#{e.class.name}: #{e.message}"
         | 
| 22 33 | 
             
                  end
         | 
| 23 34 |  | 
| @@ -89,6 +100,9 @@ module LibUI | |
| 89 100 |  | 
| 90 101 | 
             
                try_extern 'char *uiWindowTitle(uiWindow *w)'
         | 
| 91 102 | 
             
                try_extern 'void uiWindowSetTitle(uiWindow *w, const char *title)'
         | 
| 103 | 
            +
                try_extern 'void uiWindowPosition(uiWindow *w, int *x, int *y)'
         | 
| 104 | 
            +
                try_extern 'void uiWindowSetPosition(uiWindow *w, int x, int y)'
         | 
| 105 | 
            +
                try_extern 'void uiWindowOnPositionChanged(uiWindow *w, void (*f)(uiWindow *sender, void *senderData), void *data)'
         | 
| 92 106 | 
             
                try_extern 'void uiWindowContentSize(uiWindow *w, int *width, int *height)'
         | 
| 93 107 | 
             
                try_extern 'void uiWindowSetContentSize(uiWindow *w, int width, int height)'
         | 
| 94 108 | 
             
                try_extern 'int uiWindowFullscreen(uiWindow *w)'
         | 
    
        data/lib/libui/fiddle_patch.rb
    CHANGED
    
    | @@ -1,4 +1,12 @@ | |
| 1 1 | 
             
            module LibUI
         | 
| 2 | 
            +
              # This module overrides Fiddle's mtehods
         | 
| 3 | 
            +
              # - Fiddle::Importer#extern
         | 
| 4 | 
            +
              # - Fiddle::CParser#parse_signature
         | 
| 5 | 
            +
              # Original methods are in
         | 
| 6 | 
            +
              # - https://github.com/ruby/fiddle/blob/master/lib/fiddle/import.rb
         | 
| 7 | 
            +
              # - https://github.com/ruby/fiddle/blob/master/lib/fiddle/cparser.rb
         | 
| 8 | 
            +
              # These changes add the ability to parse the signatures of functions given as arguments.
         | 
| 9 | 
            +
             | 
| 2 10 | 
             
              module FiddlePatch
         | 
| 3 11 | 
             
                def parse_signature(signature, tymap = nil)
         | 
| 4 12 | 
             
                  tymap ||= {}
         | 
    
        data/lib/libui/version.rb
    CHANGED
    
    
    
        data/lib/libui.rb
    CHANGED
    
    | @@ -1,21 +1,39 @@ | |
| 1 1 | 
             
            require_relative 'libui/version'
         | 
| 2 2 | 
             
            require_relative 'libui/utils'
         | 
| 3 | 
            +
            require_relative 'libui/error'
         | 
| 3 4 | 
             
            require 'rbconfig'
         | 
| 4 5 |  | 
| 5 6 | 
             
            module LibUI
         | 
| 6 | 
            -
              class Error < StandardError; end
         | 
| 7 | 
            -
             | 
| 8 7 | 
             
              class << self
         | 
| 9 8 | 
             
                attr_accessor :ffi_lib
         | 
| 10 9 | 
             
              end
         | 
| 11 10 |  | 
| 12 | 
            -
               | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 11 | 
            +
              host_cpu = case RbConfig::CONFIG['host_cpu']
         | 
| 12 | 
            +
                         when /i\d86/
         | 
| 13 | 
            +
                           'x86'
         | 
| 14 | 
            +
                         else
         | 
| 15 | 
            +
                           RbConfig::CONFIG['host_cpu']
         | 
| 16 | 
            +
                         end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              lib_name = [
         | 
| 19 | 
            +
                # For libui-ng shared libraries compiled with (rake vendor:build)
         | 
| 20 | 
            +
                "libui.#{RbConfig::CONFIG['host_cpu']}.#{RbConfig::CONFIG['SOEXT']}",
         | 
| 21 | 
            +
                # For libui-ng shared library downloaded from RubyGems.org
         | 
| 22 | 
            +
                "libui.#{host_cpu}.#{RbConfig::CONFIG['SOEXT']}",
         | 
| 23 | 
            +
                # For backward compatibility or manual compilation of libui-ng
         | 
| 24 | 
            +
                "libui.#{RbConfig::CONFIG['SOEXT']}"
         | 
| 25 | 
            +
              ]
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              self.ffi_lib = \
         | 
| 28 | 
            +
                if ENV['LIBUIDIR'] && !ENV['LIBUIDIR'].empty?
         | 
| 29 | 
            +
                  lib_name.lazy
         | 
| 30 | 
            +
                          .map { |name| File.expand_path(name, ENV['LIBUIDIR']) }
         | 
| 31 | 
            +
                          .find { |path| File.exist?(path) }
         | 
| 32 | 
            +
                else
         | 
| 33 | 
            +
                  lib_name.lazy
         | 
| 34 | 
            +
                          .map { |name| File.expand_path("../vendor/#{name}", __dir__) }
         | 
| 35 | 
            +
                          .find { |path| File.exist?(path) }
         | 
| 36 | 
            +
                end
         | 
| 19 37 |  | 
| 20 38 | 
             
              require_relative 'libui/ffi'
         | 
| 21 39 | 
             
              require_relative 'libui/libui_base'
         | 
| @@ -35,6 +53,25 @@ module LibUI | |
| 35 53 | 
             
                  warn UI.free_init_error(init)
         | 
| 36 54 | 
             
                end
         | 
| 37 55 |  | 
| 56 | 
            +
                # Gets the window position.
         | 
| 57 | 
            +
                # Coordinates are measured from the top left corner of the screen.
         | 
| 58 | 
            +
                # @param w [Fiddle::Pointer] Pointer of uiWindow instance.
         | 
| 59 | 
            +
                # @return [Array] position of the window. [x, y]
         | 
| 60 | 
            +
                # @note This method may return inaccurate or dummy values on Unix platforms.
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                def window_position(w)
         | 
| 63 | 
            +
                  x_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
         | 
| 64 | 
            +
                  y_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
         | 
| 65 | 
            +
                  super(w, x_ptr, y_ptr)
         | 
| 66 | 
            +
                  x = x_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*')
         | 
| 67 | 
            +
                  y = y_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*')
         | 
| 68 | 
            +
                  [x, y]
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                # FIXME: This is a workaround for a old version of Fiddle.
         | 
| 72 | 
            +
                # Fiddle 1.1.2 and above should be able to handle one character string.
         | 
| 73 | 
            +
                # See https://github.com/ruby/fiddle/issues/96
         | 
| 74 | 
            +
             | 
| 38 75 | 
             
                def open_type_features_add(otf, a, b, c, d, value)
         | 
| 39 76 | 
             
                  a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
         | 
| 40 77 | 
             
                  super(otf, a, b, c, d, value)
         | 
    
        data/vendor/README.md
    CHANGED
    
    | @@ -68,6 +68,16 @@ For the sake of completeness, I should note that the default value of `--layout` | |
| 68 68 |  | 
| 69 69 | 
             
            Backends other than `ninja` should work, but are untested by me.
         | 
| 70 70 |  | 
| 71 | 
            +
            ## Testing
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            ### Automated Unit Tests
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            Run the included unit tests via `meson test -C build`. Alternatively you can also run the `unit` executable manually.
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            ### Manual Testing Suite
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            Run the manual quality assurance test suite via `qa` and follow the instructions laid out within.
         | 
| 80 | 
            +
             | 
| 71 81 | 
             
            ## Installation
         | 
| 72 82 |  | 
| 73 83 | 
             
            Meson also supports installing from source; if you use Ninja, just do
         | 
| @@ -82,9 +92,13 @@ When running `meson`, the `--prefix` option will set the installation prefix. [T | |
| 82 92 |  | 
| 83 93 | 
             
            Can be built from AUR: https://aur.archlinux.org/packages/libui-ng-git/
         | 
| 84 94 |  | 
| 85 | 
            -
            ## Documentation
         | 
| 95 | 
            +
            ## Documentation [WIP]
         | 
| 96 | 
            +
             | 
| 97 | 
            +
            [API](https://libui-ng.github.io/libui-ng/), check the [modules](https://libui-ng.github.io/libui-ng/modules.html) section for an overview of (nearly all) uiControls.
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            Consult the `ui.h` comments for the uiControls missing in the docs.
         | 
| 86 100 |  | 
| 87 | 
            -
             | 
| 101 | 
            +
            Check the `examples` directory for fully fledged examples. Check out the `tests` directory and subdirectories for more real world usage.
         | 
| 88 102 |  | 
| 89 103 | 
             
            ## Language Bindings
         | 
| 90 104 |  | 
| @@ -96,7 +110,7 @@ Language | Bindings | |
| 96 110 | 
             
            --- | ---
         | 
| 97 111 | 
             
            C++ | [libui-cpp](https://github.com/billyquith/libui-cpp), [cpp-libui-qtlike](https://github.com/aoloe/cpp-libui-qtlike)
         | 
| 98 112 | 
             
            C# / .NET Framework | [LibUI.Binding](https://github.com/NattyNarwhal/LibUI.Binding)
         | 
| 99 | 
            -
            C# / .NET Core | [DevZH.UI](https://github.com/noliar/DevZH.UI), [SharpUI](https://github.com/benpye/sharpui/) | 
| 113 | 
            +
            C# / .NET Core | [DevZH.UI](https://github.com/noliar/DevZH.UI), [SharpUI](https://github.com/benpye/sharpui/)
         | 
| 100 114 | 
             
            CHICKEN Scheme | [wasamasa/libui](https://github.com/wasamasa/libui)
         | 
| 101 115 | 
             
            Common Lisp | [jinwoo/cl-ui](https://github.com/jinwoo/cl-ui)
         | 
| 102 116 | 
             
            Crystal | [libui.cr](https://github.com/Fusion/libui.cr), [hedron](https://github.com/Qwerp-Derp/hedron), [iu](https://github.com/grkek/iu)
         | 
| @@ -109,13 +123,13 @@ JavaScript/Node.js | [libui-node](https://github.com/parro-it/libui-node), [libu | |
| 109 123 | 
             
            Julia | [Libui.jl](https://github.com/joa-quim/Libui.jl)
         | 
| 110 124 | 
             
            Kotlin | [kotlin-libui](https://github.com/msink/kotlin-libui)
         | 
| 111 125 | 
             
            Lua | [libuilua](https://github.com/zevv/libuilua), [libui-lua](https://github.com/mdombroski/libui-lua), [lui](http://tset.de/lui/index.html), [lui](https://github.com/zhaozg/lui)
         | 
| 112 | 
            -
            Nim | [ui](https://github.com/nim-lang/ui)
         | 
| 126 | 
            +
            Nim | [ui](https://github.com/nim-lang/ui), [uing](https://github.com/neroist/uing)
         | 
| 113 127 | 
             
            Perl6 | [perl6-libui](https://github.com/Garland-g/perl6-libui)
         | 
| 114 | 
            -
            PHP | [ui](https://github.com/krakjoe/ui)
         | 
| 128 | 
            +
            PHP | [ui](https://github.com/krakjoe/ui), [Ardillo](https://github.com/ardillo-php/ext)
         | 
| 115 129 | 
             
            Python | [pylibui](https://github.com/joaoventura/pylibui)
         | 
| 116 130 | 
             
            Ring | [RingLibui](https://github.com/ring-lang/ring/tree/master/extensions/ringlibui)
         | 
| 117 131 | 
             
            Ruby | [libui-ruby](https://github.com/jamescook/libui-ruby), [LibUI](https://github.com/kojix2/libui), [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
         | 
| 118 | 
            -
            Rust | [libui-ng-sys](https://github.com/norepimorphism/libui-ng-sys), [boing](https://github.com/norepimorphism/boing), [libui-rs](https://github.com/rust-native-ui/libui-rs)
         | 
| 132 | 
            +
            Rust | [libui-ng-sys](https://github.com/norepimorphism/libui-ng-sys), [boing](https://github.com/norepimorphism/boing), [libui-rs](https://github.com/rust-native-ui/libui-rs), [libui](https://github.com/libui-rs/libui)
         | 
| 119 133 | 
             
            Scala | [scalaui](https://github.com/lolgab/scalaui)
         | 
| 120 134 | 
             
            Swift | [libui-swift](https://github.com/sclukey/libui-swift)
         | 
| 121 135 |  | 
| Binary file | 
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,29 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: libui
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0.pre
         | 
| 5 5 | 
             
            platform: x86_64-darwin
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - kojix2
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 12 | 
            -
            dependencies: | 
| 11 | 
            +
            date: 2025-08-16 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: fiddle
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 13 27 | 
             
            description:
         | 
| 14 28 | 
             
            email:
         | 
| 15 29 | 
             
            - 2xijok@gmail.com
         | 
| @@ -20,6 +34,7 @@ files: | |
| 20 34 | 
             
            - LICENSE.txt
         | 
| 21 35 | 
             
            - README.md
         | 
| 22 36 | 
             
            - lib/libui.rb
         | 
| 37 | 
            +
            - lib/libui/error.rb
         | 
| 23 38 | 
             
            - lib/libui/ffi.rb
         | 
| 24 39 | 
             
            - lib/libui/fiddle_patch.rb
         | 
| 25 40 | 
             
            - lib/libui/libui_base.rb
         | 
| @@ -27,7 +42,7 @@ files: | |
| 27 42 | 
             
            - lib/libui/version.rb
         | 
| 28 43 | 
             
            - vendor/LICENSE.md
         | 
| 29 44 | 
             
            - vendor/README.md
         | 
| 30 | 
            -
            - vendor/libui.dylib
         | 
| 45 | 
            +
            - vendor/libui.x86_64.dylib
         | 
| 31 46 | 
             
            homepage: https://github.com/kojix2/libui
         | 
| 32 47 | 
             
            licenses:
         | 
| 33 48 | 
             
            - MIT
         | 
| @@ -40,14 +55,14 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 40 55 | 
             
              requirements:
         | 
| 41 56 | 
             
              - - ">="
         | 
| 42 57 | 
             
                - !ruby/object:Gem::Version
         | 
| 43 | 
            -
                  version: '2. | 
| 58 | 
            +
                  version: '2.6'
         | 
| 44 59 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 45 60 | 
             
              requirements:
         | 
| 46 61 | 
             
              - - ">="
         | 
| 47 62 | 
             
                - !ruby/object:Gem::Version
         | 
| 48 63 | 
             
                  version: '0'
         | 
| 49 64 | 
             
            requirements: []
         | 
| 50 | 
            -
            rubygems_version: 3.5. | 
| 65 | 
            +
            rubygems_version: 3.5.22
         | 
| 51 66 | 
             
            signing_key:
         | 
| 52 67 | 
             
            specification_version: 4
         | 
| 53 68 | 
             
            summary: Ruby bindings to libui
         | 
    
        data/vendor/libui.dylib
    DELETED
    
    | Binary file |