glimmer-dsl-libui 0.0.21 → 0.0.25
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/CHANGELOG.md +24 -0
- data/README.md +182 -16
- data/VERSION +1 -1
- data/examples/basic_table.rb +1 -1
- data/examples/basic_table_button.rb +29 -0
- data/examples/basic_table_checkbox.rb +25 -0
- data/examples/basic_table_checkbox_text.rb +25 -0
- data/examples/basic_table_image.rb +1 -1
- data/examples/basic_table_image_text.rb +3 -7
- data/examples/editable_column_table.rb +1 -1
- data/examples/editable_table.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/dsl.rb +0 -4
- data/lib/glimmer/libui/button_column_proxy.rb +67 -0
- data/lib/glimmer/libui/checkbox_column_proxy.rb +42 -0
- data/lib/glimmer/libui/checkbox_text_column_proxy.rb +44 -0
- data/lib/glimmer/libui/column.rb +0 -2
- data/lib/glimmer/libui/dual_column.rb +0 -2
- data/lib/glimmer/libui/editable_column.rb +1 -2
- data/lib/glimmer/libui/enableable_column.rb +44 -0
- data/lib/glimmer/libui/image_part_proxy.rb +10 -0
- data/lib/glimmer/libui/image_proxy.rb +63 -0
- data/lib/glimmer/libui/image_text_column_proxy.rb +2 -0
- data/lib/glimmer/libui/table_proxy.rb +26 -20
- data/lib/glimmer/libui/text_column_proxy.rb +1 -0
- data/lib/glimmer/libui/window_proxy.rb +19 -10
- data/lib/glimmer-dsl-libui.rb +1 -0
- metadata +14 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ef6b80413ffc1933a0e36dd536f06d67538002ef7777aa682ef19f7ef01f7b28
         | 
| 4 | 
            +
              data.tar.gz: fb188b7bb041bdaf0a95aee368f339268459d41de7aa76947fa1504b56d465d2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1530e1e986263701efebab10a2eff549bcadb7bc23c8e67cdde4c622822b9c6a54d74d9b2ccffb700f48021d1f34b6b10b683d85d0062202055b4d7b20acfb2f
         | 
| 7 | 
            +
              data.tar.gz: 89df7b4eab9bdd449ead5ac40a92fa1f7e5b56a72191dc649bc53df96994a733d048eb99f1710149a1e26a87123e45413f2d4d973704ca0e16406a43764ce0c2
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,29 @@ | |
| 1 1 | 
             
            # Change Log
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 0.0.25
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            - New examples/basic_table_checkbox_text.rb
         | 
| 6 | 
            +
            - Support table `checkbox_text_column`
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ## 0.0.24
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            - New examples/basic_table_checkbox.rb
         | 
| 11 | 
            +
            - Support table `checkbox_column`
         | 
| 12 | 
            +
            - Improve support for table row deletion upon actual `cell_rows` deletion by handling multiple-row deletion not just single-row deletion
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ## 0.0.23
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            - Have `image` not require `width` and `height` if it only has one `image_part` (defaults to `image_part` `width` and `height`)
         | 
| 17 | 
            +
            - Upgrade to LibUI version 0.0.10
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## 0.0.22
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            - New examples/basic_table_button.rb
         | 
| 22 | 
            +
            - Support table `button_column`
         | 
| 23 | 
            +
            - Support table `button_column` `enabled` property
         | 
| 24 | 
            +
            - Support `on_clicked` listener for `button_column`
         | 
| 25 | 
            +
            - Support automatic table cell value reading management (table row deletion upon actual `cell_rows` deletion due to implicit data-binding)
         | 
| 26 | 
            +
             | 
| 3 27 | 
             
            ## 0.0.21
         | 
| 4 28 |  | 
| 5 29 | 
             
            - New examples/editable_column_table_image_text.rb
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.0. | 
| 1 | 
            +
            # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.0.25
         | 
| 2 2 | 
             
            ## Prerequisite-Free Ruby Desktop Development GUI Library
         | 
| 3 3 | 
             
            [](http://badge.fury.io/rb/glimmer-dsl-libui)
         | 
| 4 4 | 
             
            [](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
         | 
| @@ -43,7 +43,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes | |
| 43 43 |  | 
| 44 44 | 
             
            ## Table of Contents
         | 
| 45 45 |  | 
| 46 | 
            -
            - [Glimmer DSL for LibUI 0.0. | 
| 46 | 
            +
            - [Glimmer DSL for LibUI 0.0.25](#-glimmer-dsl-for-libui-0025)
         | 
| 47 47 | 
             
              - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
         | 
| 48 48 | 
             
              - [Usage](#usage)
         | 
| 49 49 | 
             
              - [API](#api)
         | 
| @@ -74,6 +74,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes | |
| 74 74 | 
             
                - [Editable Column Table](#editable-column-table)
         | 
| 75 75 | 
             
                - [Basic Table Image](#basic-table-image)
         | 
| 76 76 | 
             
                - [Basic Table Image Text](#basic-table-image-text)
         | 
| 77 | 
            +
                - [Basic Table Button](#basic-table-button)
         | 
| 78 | 
            +
                - [Basic Table Checkbox](#basic-table-checkbox)
         | 
| 79 | 
            +
                - [Basic Table Checkbox Text](#basic-table-checkbox-text)
         | 
| 77 80 | 
             
              - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
         | 
| 78 81 | 
             
              - [Help](#help)
         | 
| 79 82 | 
             
                - [Issues](#issues)
         | 
| @@ -161,7 +164,7 @@ gem install glimmer-dsl-libui | |
| 161 164 | 
             
            Or install via Bundler `Gemfile`:
         | 
| 162 165 |  | 
| 163 166 | 
             
            ```ruby
         | 
| 164 | 
            -
            gem 'glimmer-dsl-libui', '~> 0.0. | 
| 167 | 
            +
            gem 'glimmer-dsl-libui', '~> 0.0.25'
         | 
| 165 168 | 
             
            ```
         | 
| 166 169 |  | 
| 167 170 | 
             
            Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
         | 
| @@ -218,7 +221,10 @@ Control(Args) | Properties | Listeners | |
| 218 221 | 
             
            ------------- | ---------- | ---------
         | 
| 219 222 | 
             
            `about_menu_item` | None | `on_clicked`
         | 
| 220 223 | 
             
            `button(text as String)` | `text` (`String`) | `on_clicked`
         | 
| 224 | 
            +
            `button_column(name as String)` | `enabled` (Boolean) | None
         | 
| 221 225 | 
             
            `checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
         | 
| 226 | 
            +
            `checkbox_column(name as String)` | None | None
         | 
| 227 | 
            +
            `checkbox_text_column(name as String)` | `editable` (Boolean) | None
         | 
| 222 228 | 
             
            `combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
         | 
| 223 229 | 
             
            `color_button` | `color` (Array of `red` as `Float`, `green` as `Float`, `blue` as `Float`, `alpha` as `Float`), `red` as `Float`, `green` as `Float`, `blue` as `Float`, `alpha` as `Float` | `on_changed`
         | 
| 224 230 | 
             
            `date_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
         | 
| @@ -251,7 +257,7 @@ Control(Args) | Properties | Listeners | |
| 251 257 | 
             
            `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
         | 
| 252 258 | 
             
            `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
         | 
| 253 259 | 
             
            `table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values for `text_column` cells or `Array` of `image`/`String` for `image_text_column`)), `editable` as Boolean | None
         | 
| 254 | 
            -
            `text_column(name as String)` | `editable`  | 
| 260 | 
            +
            `text_column(name as String)` | `editable` (Boolean) | None
         | 
| 255 261 | 
             
            `time_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
         | 
| 256 262 | 
             
            `vertical_box` | `padded` (Boolean) | None
         | 
| 257 263 | 
             
            `window(title as String, width as Integer, height as Integer, has_menubar as Boolean)` | `borderless` (Boolean), `content_size` (width `Numeric`, height `Numeric`), `fullscreen` (Boolean), `margined` (Boolean), `title` (`String`) | `on_closing`, `on_content_size_changed`, `on_destroy`
         | 
| @@ -318,7 +324,9 @@ Control(Args) | Properties | Listeners | |
| 318 324 | 
             
            - Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
         | 
| 319 325 | 
             
            - The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
         | 
| 320 326 | 
             
            - Table model instances are automatically freed from memory after `window` is destroyed.
         | 
| 327 | 
            +
            - Table `cell_rows` data has implicit data-binding to table cell values. When deleting data from `cell_rows` array, then actual rows from the `table` are automatically deleted.
         | 
| 321 328 | 
             
            - `image` instances are automatically freed from memory after `window` is destroyed.
         | 
| 329 | 
            +
            - `image` `width` and `height` can be left off if it has one `image_part` only as they default to the same `width` and `height` of the `image_part`
         | 
| 322 330 |  | 
| 323 331 | 
             
            ### API Gotchas
         | 
| 324 332 |  | 
| @@ -1807,7 +1815,7 @@ data = [ | |
| 1807 1815 | 
             
              %w[cat meow],
         | 
| 1808 1816 | 
             
              %w[dog woof],
         | 
| 1809 1817 | 
             
              %w[checken cock-a-doodle-doo],
         | 
| 1810 | 
            -
              %w[ | 
| 1818 | 
            +
              %w[horse neigh],
         | 
| 1811 1819 | 
             
              %w[cow moo]
         | 
| 1812 1820 | 
             
            ]
         | 
| 1813 1821 |  | 
| @@ -1865,7 +1873,7 @@ data = [ | |
| 1865 1873 | 
             
              %w[cat meow],
         | 
| 1866 1874 | 
             
              %w[dog woof],
         | 
| 1867 1875 | 
             
              %w[chicken cock-a-doodle-doo],
         | 
| 1868 | 
            -
              %w[ | 
| 1876 | 
            +
              %w[horse neigh],
         | 
| 1869 1877 | 
             
              %w[cow moo]
         | 
| 1870 1878 | 
             
            ]
         | 
| 1871 1879 |  | 
| @@ -1924,7 +1932,7 @@ data = [ | |
| 1924 1932 | 
             
              %w[cat meow],
         | 
| 1925 1933 | 
             
              %w[dog woof],
         | 
| 1926 1934 | 
             
              %w[chicken cock-a-doodle-doo],
         | 
| 1927 | 
            -
              %w[ | 
| 1935 | 
            +
              %w[horse neigh],
         | 
| 1928 1936 | 
             
              %w[cow moo]
         | 
| 1929 1937 | 
             
            ]
         | 
| 1930 1938 |  | 
| @@ -1982,7 +1990,7 @@ data = [ | |
| 1982 1990 | 
             
              %w[cat calm meow],
         | 
| 1983 1991 | 
             
              %w[dog loyal woof],
         | 
| 1984 1992 | 
             
              %w[chicken bird cock-a-doodle-doo],
         | 
| 1985 | 
            -
              %w[ | 
| 1993 | 
            +
              %w[horse fast neigh],
         | 
| 1986 1994 | 
             
              %w[cow slow moo]
         | 
| 1987 1995 | 
             
            ]
         | 
| 1988 1996 |  | 
| @@ -2140,7 +2148,7 @@ IMAGE_ROWS = [] | |
| 2140 2148 | 
             
              data = canvas.to_rgba_stream
         | 
| 2141 2149 | 
             
              width = canvas.width
         | 
| 2142 2150 | 
             
              height = canvas.height
         | 
| 2143 | 
            -
              img = image | 
| 2151 | 
            +
              img = image {
         | 
| 2144 2152 | 
             
                image_part(data, width, height, width * 4)
         | 
| 2145 2153 | 
             
              }
         | 
| 2146 2154 | 
             
              IMAGE_ROWS << [img] # array of one column cell
         | 
| @@ -2218,23 +2226,19 @@ IMAGE_ROWS = [] | |
| 2218 2226 | 
             
              data = canvas.to_rgba_stream
         | 
| 2219 2227 | 
             
              width = canvas.width
         | 
| 2220 2228 | 
             
              height = canvas.height
         | 
| 2221 | 
            -
              img = image | 
| 2229 | 
            +
              img = image {
         | 
| 2222 2230 | 
             
                image_part(data, width, height, width * 4)
         | 
| 2223 2231 | 
             
              }
         | 
| 2224 2232 | 
             
              text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
         | 
| 2225 | 
            -
              IMAGE_ROWS << [[img, text],  | 
| 2233 | 
            +
              IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
         | 
| 2226 2234 | 
             
            rescue StandardError => e
         | 
| 2227 2235 | 
             
              warn url, e.message
         | 
| 2228 2236 | 
             
            end
         | 
| 2229 2237 |  | 
| 2230 | 
            -
            window('The Red Turtle',  | 
| 2238 | 
            +
            window('The Red Turtle', 670, 350) {
         | 
| 2231 2239 | 
             
              horizontal_box {
         | 
| 2232 2240 | 
             
                table {
         | 
| 2233 2241 | 
             
                  image_text_column('image/number')
         | 
| 2234 | 
            -
                  text_column('number')
         | 
| 2235 | 
            -
                  text_column('number (editable)') {
         | 
| 2236 | 
            -
                    editable true
         | 
| 2237 | 
            -
                  }
         | 
| 2238 2242 | 
             
                  image_text_column('image/number (editable)') {
         | 
| 2239 2243 | 
             
                    editable true
         | 
| 2240 2244 | 
             
                  }
         | 
| @@ -2245,6 +2249,168 @@ window('The Red Turtle', 900, 350) { | |
| 2245 2249 | 
             
            }.show
         | 
| 2246 2250 | 
             
            ```
         | 
| 2247 2251 |  | 
| 2252 | 
            +
            ### Basic Table Button
         | 
| 2253 | 
            +
             | 
| 2254 | 
            +
            [examples/basic_table_button.rb](examples/basic_table_button.rb)
         | 
| 2255 | 
            +
             | 
| 2256 | 
            +
            Run with this command from the root of the project if you cloned the project:
         | 
| 2257 | 
            +
             | 
| 2258 | 
            +
            ```
         | 
| 2259 | 
            +
            ruby -r './lib/glimmer-dsl-libui' examples/basic_table_button.rb
         | 
| 2260 | 
            +
            ```
         | 
| 2261 | 
            +
             | 
| 2262 | 
            +
            Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
         | 
| 2263 | 
            +
             | 
| 2264 | 
            +
            ```
         | 
| 2265 | 
            +
            ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_button'"
         | 
| 2266 | 
            +
            ```
         | 
| 2267 | 
            +
             | 
| 2268 | 
            +
            Mac
         | 
| 2269 | 
            +
             | 
| 2270 | 
            +
            
         | 
| 2271 | 
            +
            
         | 
| 2272 | 
            +
             | 
| 2273 | 
            +
            Linux
         | 
| 2274 | 
            +
             | 
| 2275 | 
            +
            
         | 
| 2276 | 
            +
            
         | 
| 2277 | 
            +
             | 
| 2278 | 
            +
            New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
         | 
| 2279 | 
            +
             | 
| 2280 | 
            +
            ```ruby
         | 
| 2281 | 
            +
            require 'glimmer-dsl-libui'
         | 
| 2282 | 
            +
             | 
| 2283 | 
            +
            include Glimmer
         | 
| 2284 | 
            +
             | 
| 2285 | 
            +
            data = [
         | 
| 2286 | 
            +
              %w[cat meow delete],
         | 
| 2287 | 
            +
              %w[dog woof delete],
         | 
| 2288 | 
            +
              %w[chicken cock-a-doodle-doo delete],
         | 
| 2289 | 
            +
              %w[horse neigh delete],
         | 
| 2290 | 
            +
              %w[cow moo delete]
         | 
| 2291 | 
            +
            ]
         | 
| 2292 | 
            +
             | 
| 2293 | 
            +
            window('Animal sounds', 300, 200) {
         | 
| 2294 | 
            +
              horizontal_box {
         | 
| 2295 | 
            +
                table {
         | 
| 2296 | 
            +
                  text_column('Animal')
         | 
| 2297 | 
            +
                  text_column('Description')
         | 
| 2298 | 
            +
                  button_column('Action') {
         | 
| 2299 | 
            +
                    on_clicked do |row|
         | 
| 2300 | 
            +
                      data.delete_at(row) # automatically deletes actual table row due to implicit data-binding
         | 
| 2301 | 
            +
                    end
         | 
| 2302 | 
            +
                  }
         | 
| 2303 | 
            +
             | 
| 2304 | 
            +
                  cell_rows data # implicit data-binding
         | 
| 2305 | 
            +
                }
         | 
| 2306 | 
            +
              }
         | 
| 2307 | 
            +
            }.show
         | 
| 2308 | 
            +
            ```
         | 
| 2309 | 
            +
             | 
| 2310 | 
            +
            ### Basic Table Checkbox
         | 
| 2311 | 
            +
             | 
| 2312 | 
            +
            [examples/basic_table_checkbox.rb](examples/basic_table_checkbox.rb)
         | 
| 2313 | 
            +
             | 
| 2314 | 
            +
            Run with this command from the root of the project if you cloned the project:
         | 
| 2315 | 
            +
             | 
| 2316 | 
            +
            ```
         | 
| 2317 | 
            +
            ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox.rb
         | 
| 2318 | 
            +
            ```
         | 
| 2319 | 
            +
             | 
| 2320 | 
            +
            Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
         | 
| 2321 | 
            +
             | 
| 2322 | 
            +
            ```
         | 
| 2323 | 
            +
            ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox'"
         | 
| 2324 | 
            +
            ```
         | 
| 2325 | 
            +
             | 
| 2326 | 
            +
            Mac
         | 
| 2327 | 
            +
             | 
| 2328 | 
            +
            
         | 
| 2329 | 
            +
             | 
| 2330 | 
            +
            Linux
         | 
| 2331 | 
            +
             | 
| 2332 | 
            +
            
         | 
| 2333 | 
            +
             | 
| 2334 | 
            +
            New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
         | 
| 2335 | 
            +
             | 
| 2336 | 
            +
            ```ruby
         | 
| 2337 | 
            +
            require 'glimmer-dsl-libui'
         | 
| 2338 | 
            +
             | 
| 2339 | 
            +
            include Glimmer
         | 
| 2340 | 
            +
             | 
| 2341 | 
            +
            data = [
         | 
| 2342 | 
            +
              ['cat', 'meow', true],
         | 
| 2343 | 
            +
              ['dog', 'woof', true],
         | 
| 2344 | 
            +
              ['chicken', 'cock-a-doodle-doo', false],
         | 
| 2345 | 
            +
              ['horse', 'neigh', true],
         | 
| 2346 | 
            +
              ['cow', 'moo', true]
         | 
| 2347 | 
            +
            ]
         | 
| 2348 | 
            +
             | 
| 2349 | 
            +
            window('Animal sounds', 300, 200) {
         | 
| 2350 | 
            +
              horizontal_box {
         | 
| 2351 | 
            +
                table {
         | 
| 2352 | 
            +
                  text_column('Animal')
         | 
| 2353 | 
            +
                  text_column('Description')
         | 
| 2354 | 
            +
                  checkbox_column('Mammal')
         | 
| 2355 | 
            +
             | 
| 2356 | 
            +
                  cell_rows data
         | 
| 2357 | 
            +
                }
         | 
| 2358 | 
            +
              }
         | 
| 2359 | 
            +
            }.show
         | 
| 2360 | 
            +
            ```
         | 
| 2361 | 
            +
             | 
| 2362 | 
            +
            ### Basic Table Checkbox Text
         | 
| 2363 | 
            +
             | 
| 2364 | 
            +
            [examples/basic_table_checkbox_text.rb](examples/basic_table_checkbox_text.rb)
         | 
| 2365 | 
            +
             | 
| 2366 | 
            +
            Run with this command from the root of the project if you cloned the project:
         | 
| 2367 | 
            +
             | 
| 2368 | 
            +
            ```
         | 
| 2369 | 
            +
            ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox_text.rb
         | 
| 2370 | 
            +
            ```
         | 
| 2371 | 
            +
             | 
| 2372 | 
            +
            Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
         | 
| 2373 | 
            +
             | 
| 2374 | 
            +
            ```
         | 
| 2375 | 
            +
            ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox_text'"
         | 
| 2376 | 
            +
            ```
         | 
| 2377 | 
            +
             | 
| 2378 | 
            +
            Mac
         | 
| 2379 | 
            +
             | 
| 2380 | 
            +
            
         | 
| 2381 | 
            +
             | 
| 2382 | 
            +
            Linux
         | 
| 2383 | 
            +
             | 
| 2384 | 
            +
            
         | 
| 2385 | 
            +
             | 
| 2386 | 
            +
            New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
         | 
| 2387 | 
            +
             | 
| 2388 | 
            +
            ```ruby
         | 
| 2389 | 
            +
            require 'glimmer-dsl-libui'
         | 
| 2390 | 
            +
             | 
| 2391 | 
            +
            include Glimmer
         | 
| 2392 | 
            +
             | 
| 2393 | 
            +
            data = [
         | 
| 2394 | 
            +
              ['cat', 'meow', [true, 'mammal']],
         | 
| 2395 | 
            +
              ['dog', 'woof', [true, 'mammal']],
         | 
| 2396 | 
            +
              ['chicken', 'cock-a-doodle-doo', [false, 'mammal']],
         | 
| 2397 | 
            +
              ['horse', 'neigh', [true, 'mammal']],
         | 
| 2398 | 
            +
              ['cow', 'moo', [true, 'mammal']]
         | 
| 2399 | 
            +
            ]
         | 
| 2400 | 
            +
             | 
| 2401 | 
            +
            window('Animal sounds', 400, 200) {
         | 
| 2402 | 
            +
              horizontal_box {
         | 
| 2403 | 
            +
                table {
         | 
| 2404 | 
            +
                  text_column('Animal')
         | 
| 2405 | 
            +
                  text_column('Sound')
         | 
| 2406 | 
            +
                  checkbox_text_column('Description')
         | 
| 2407 | 
            +
             | 
| 2408 | 
            +
                  cell_rows data
         | 
| 2409 | 
            +
                }
         | 
| 2410 | 
            +
              }
         | 
| 2411 | 
            +
            }.show
         | 
| 2412 | 
            +
            ```
         | 
| 2413 | 
            +
             | 
| 2248 2414 | 
             
            ## Contributing to glimmer-dsl-libui
         | 
| 2249 2415 |  | 
| 2250 2416 | 
             
            -   Check out the latest master to make sure the feature hasn't been
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.25
         | 
    
        data/examples/basic_table.rb
    CHANGED
    
    
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'glimmer-dsl-libui'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            include Glimmer
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            data = [
         | 
| 8 | 
            +
              %w[cat meow delete],
         | 
| 9 | 
            +
              %w[dog woof delete],
         | 
| 10 | 
            +
              %w[chicken cock-a-doodle-doo delete],
         | 
| 11 | 
            +
              %w[horse neigh delete],
         | 
| 12 | 
            +
              %w[cow moo delete]
         | 
| 13 | 
            +
            ]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            window('Animal sounds', 300, 200) {
         | 
| 16 | 
            +
              horizontal_box {
         | 
| 17 | 
            +
                table {
         | 
| 18 | 
            +
                  text_column('Animal')
         | 
| 19 | 
            +
                  text_column('Description')
         | 
| 20 | 
            +
                  button_column('Action') {
         | 
| 21 | 
            +
                    on_clicked do |row|
         | 
| 22 | 
            +
                      data.delete_at(row) # automatically deletes actual table row due to implicit data-binding
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                  }
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  cell_rows data # implicit data-binding
         | 
| 27 | 
            +
                }
         | 
| 28 | 
            +
              }
         | 
| 29 | 
            +
            }.show
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'glimmer-dsl-libui'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            include Glimmer
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            data = [
         | 
| 8 | 
            +
              ['cat', 'meow', true],
         | 
| 9 | 
            +
              ['dog', 'woof', true],
         | 
| 10 | 
            +
              ['chicken', 'cock-a-doodle-doo', false],
         | 
| 11 | 
            +
              ['horse', 'neigh', true],
         | 
| 12 | 
            +
              ['cow', 'moo', true]
         | 
| 13 | 
            +
            ]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            window('Animal sounds', 300, 200) {
         | 
| 16 | 
            +
              horizontal_box {
         | 
| 17 | 
            +
                table {
         | 
| 18 | 
            +
                  text_column('Animal')
         | 
| 19 | 
            +
                  text_column('Description')
         | 
| 20 | 
            +
                  checkbox_column('Mammal')
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  cell_rows data
         | 
| 23 | 
            +
                }
         | 
| 24 | 
            +
              }
         | 
| 25 | 
            +
            }.show
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'glimmer-dsl-libui'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            include Glimmer
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            data = [
         | 
| 8 | 
            +
              ['cat', 'meow', [true, 'mammal']],
         | 
| 9 | 
            +
              ['dog', 'woof', [true, 'mammal']],
         | 
| 10 | 
            +
              ['chicken', 'cock-a-doodle-doo', [false, 'mammal']],
         | 
| 11 | 
            +
              ['horse', 'neigh', [true, 'mammal']],
         | 
| 12 | 
            +
              ['cow', 'moo', [true, 'mammal']]
         | 
| 13 | 
            +
            ]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            window('Animal sounds', 400, 200) {
         | 
| 16 | 
            +
              horizontal_box {
         | 
| 17 | 
            +
                table {
         | 
| 18 | 
            +
                  text_column('Animal')
         | 
| 19 | 
            +
                  text_column('Sound')
         | 
| 20 | 
            +
                  checkbox_text_column('Description')
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  cell_rows data
         | 
| 23 | 
            +
                }
         | 
| 24 | 
            +
              }
         | 
| 25 | 
            +
            }.show
         | 
| @@ -20,23 +20,19 @@ IMAGE_ROWS = [] | |
| 20 20 | 
             
              data = canvas.to_rgba_stream
         | 
| 21 21 | 
             
              width = canvas.width
         | 
| 22 22 | 
             
              height = canvas.height
         | 
| 23 | 
            -
              img = image | 
| 23 | 
            +
              img = image {
         | 
| 24 24 | 
             
                image_part(data, width, height, width * 4)
         | 
| 25 25 | 
             
              }
         | 
| 26 26 | 
             
              text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
         | 
| 27 | 
            -
              IMAGE_ROWS << [[img, text],  | 
| 27 | 
            +
              IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
         | 
| 28 28 | 
             
            rescue StandardError => e
         | 
| 29 29 | 
             
              warn url, e.message
         | 
| 30 30 | 
             
            end
         | 
| 31 31 |  | 
| 32 | 
            -
            window('The Red Turtle',  | 
| 32 | 
            +
            window('The Red Turtle', 670, 350) {
         | 
| 33 33 | 
             
              horizontal_box {
         | 
| 34 34 | 
             
                table {
         | 
| 35 35 | 
             
                  image_text_column('image/number')
         | 
| 36 | 
            -
                  text_column('number')
         | 
| 37 | 
            -
                  text_column('number (editable)') {
         | 
| 38 | 
            -
                    editable true
         | 
| 39 | 
            -
                  }
         | 
| 40 36 | 
             
                  image_text_column('image/number (editable)') {
         | 
| 41 37 | 
             
                    editable true
         | 
| 42 38 | 
             
                  }
         | 
    
        data/examples/editable_table.rb
    CHANGED
    
    
    
        data/glimmer-dsl-libui.gemspec
    CHANGED
    
    | Binary file | 
| @@ -0,0 +1,67 @@ | |
| 1 | 
            +
            # Copyright (c) 2021 Andy Maleh
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            # the following conditions:
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            +
            require 'glimmer/libui/column'
         | 
| 24 | 
            +
            require 'glimmer/libui/enableable_column'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            module Glimmer
         | 
| 27 | 
            +
              module LibUI
         | 
| 28 | 
            +
                # Proxy for LibUI button column objects
         | 
| 29 | 
            +
                #
         | 
| 30 | 
            +
                # Follows the Proxy Design Pattern
         | 
| 31 | 
            +
                class ButtonColumnProxy < ControlProxy
         | 
| 32 | 
            +
                  include Column
         | 
| 33 | 
            +
                  include EnableableColumn
         | 
| 34 | 
            +
                  
         | 
| 35 | 
            +
                  def on_clicked(&block)
         | 
| 36 | 
            +
                    # TODO consider generalizing into custom listeners and moving to ControlProxy
         | 
| 37 | 
            +
                    @on_clicked_procs ||= []
         | 
| 38 | 
            +
                    @on_clicked_procs << block
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                  
         | 
| 41 | 
            +
                  def can_handle_listener?(listener_name)
         | 
| 42 | 
            +
                    listener_name == 'on_clicked' || super
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                  
         | 
| 45 | 
            +
                  def handle_listener(listener_name, &listener)
         | 
| 46 | 
            +
                    case listener_name
         | 
| 47 | 
            +
                    when 'on_clicked'
         | 
| 48 | 
            +
                      on_clicked(&listener)
         | 
| 49 | 
            +
                    else
         | 
| 50 | 
            +
                      super
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                  
         | 
| 54 | 
            +
                  def notify_listeners(listener_name, *args)
         | 
| 55 | 
            +
                    @on_clicked_procs&.each do |on_clicked_proc|
         | 
| 56 | 
            +
                      on_clicked_proc.call(*args)
         | 
| 57 | 
            +
                    end
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                      
         | 
| 60 | 
            +
                  private
         | 
| 61 | 
            +
                  
         | 
| 62 | 
            +
                  def build_control
         | 
| 63 | 
            +
                    @parent_proxy.append_button_column(name, column_index, enabled_value)
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
            end
         | 
| @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            # Copyright (c) 2021 Andy Maleh
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            # the following conditions:
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            +
            require 'glimmer/libui/column'
         | 
| 24 | 
            +
            require 'glimmer/libui/editable_column'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            module Glimmer
         | 
| 27 | 
            +
              module LibUI
         | 
| 28 | 
            +
                # Proxy for LibUI checkbox column objects
         | 
| 29 | 
            +
                #
         | 
| 30 | 
            +
                # Follows the Proxy Design Pattern
         | 
| 31 | 
            +
                class CheckboxColumnProxy < ControlProxy
         | 
| 32 | 
            +
                  include Column
         | 
| 33 | 
            +
            #       include EditableColumn # TODO enable this once checkbox column becomes editable on macosx in C libui (currently has a bug)
         | 
| 34 | 
            +
                  
         | 
| 35 | 
            +
                  private
         | 
| 36 | 
            +
                  
         | 
| 37 | 
            +
                  def build_control
         | 
| 38 | 
            +
                    @parent_proxy.append_checkbox_column(name, column_index, -1)
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            # Copyright (c) 2021 Andy Maleh
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            # the following conditions:
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            +
            require 'glimmer/libui/column'
         | 
| 24 | 
            +
            require 'glimmer/libui/dual_column'
         | 
| 25 | 
            +
            require 'glimmer/libui/editable_column'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            module Glimmer
         | 
| 28 | 
            +
              module LibUI
         | 
| 29 | 
            +
                # Proxy for LibUI checkbox text column objects
         | 
| 30 | 
            +
                #
         | 
| 31 | 
            +
                # Follows the Proxy Design Pattern
         | 
| 32 | 
            +
                class CheckboxTextColumnProxy < ControlProxy
         | 
| 33 | 
            +
                  include Column
         | 
| 34 | 
            +
                  include DualColumn
         | 
| 35 | 
            +
                  include EditableColumn # TODO split into editable_checkbox and editable_text properties in the future given that checkbox and text can be edited separately
         | 
| 36 | 
            +
                  
         | 
| 37 | 
            +
                  private
         | 
| 38 | 
            +
                  
         | 
| 39 | 
            +
                  def build_control
         | 
| 40 | 
            +
                    @parent_proxy.append_checkbox_text_column(name, column_index, -1, second_column_index, editable_value)
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
    
        data/lib/glimmer/libui/column.rb
    CHANGED
    
    | @@ -19,8 +19,6 @@ | |
| 19 19 | 
             
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 20 | 
             
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 21 |  | 
| 22 | 
            -
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            -
             | 
| 24 22 | 
             
            module Glimmer
         | 
| 25 23 | 
             
              module LibUI
         | 
| 26 24 | 
             
                # Common logic for all column proxy objects
         | 
| @@ -19,8 +19,6 @@ | |
| 19 19 | 
             
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 20 | 
             
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 21 |  | 
| 22 | 
            -
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            -
             | 
| 24 22 | 
             
            module Glimmer
         | 
| 25 23 | 
             
              module LibUI
         | 
| 26 24 | 
             
                # A dual column is one that represents two values (e.g. image and text or checkbox and text)
         | 
| @@ -19,13 +19,12 @@ | |
| 19 19 | 
             
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 20 | 
             
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 21 |  | 
| 22 | 
            -
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            -
             | 
| 24 22 | 
             
            module Glimmer
         | 
| 25 23 | 
             
              module LibUI
         | 
| 26 24 | 
             
                module EditableColumn
         | 
| 27 25 | 
             
                  def editable(value = nil)
         | 
| 28 26 | 
             
                    if value.nil?
         | 
| 27 | 
            +
                      @editable = false if @editable.nil?
         | 
| 29 28 | 
             
                      @editable
         | 
| 30 29 | 
             
                    else
         | 
| 31 30 | 
             
                      @editable = !!value
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            # Copyright (c) 2021 Andy Maleh
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            # the following conditions:
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            module Glimmer
         | 
| 23 | 
            +
              module LibUI
         | 
| 24 | 
            +
                module EnableableColumn
         | 
| 25 | 
            +
                  def enabled(value = nil)
         | 
| 26 | 
            +
                    if value.nil?
         | 
| 27 | 
            +
                      @enabled = true if @enabled.nil?
         | 
| 28 | 
            +
                      @enabled
         | 
| 29 | 
            +
                    else
         | 
| 30 | 
            +
                      @enabled = !!value
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  alias enabled= enabled
         | 
| 34 | 
            +
                  alias set_enabled enabled
         | 
| 35 | 
            +
                  alias enabled? enabled
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  private
         | 
| 38 | 
            +
                  
         | 
| 39 | 
            +
                  def enabled_value
         | 
| 40 | 
            +
                    enabled? ? -2 : -1
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| @@ -27,6 +27,16 @@ module Glimmer | |
| 27 27 | 
             
                #
         | 
| 28 28 | 
             
                # Follows the Proxy Design Pattern
         | 
| 29 29 | 
             
                class ImagePartProxy < ControlProxy
         | 
| 30 | 
            +
                  def initialize(keyword, parent, args, &block)
         | 
| 31 | 
            +
                    @keyword = keyword
         | 
| 32 | 
            +
                    @parent_proxy = parent
         | 
| 33 | 
            +
                    @args = args
         | 
| 34 | 
            +
                    @block = block
         | 
| 35 | 
            +
                    @enabled = true
         | 
| 36 | 
            +
                    @children = []
         | 
| 37 | 
            +
                    post_add_content if @block.nil?
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                  
         | 
| 30 40 | 
             
                  private
         | 
| 31 41 |  | 
| 32 42 | 
             
                  def build_control
         | 
| @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            # Copyright (c) 2021 Andy Maleh
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            # a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            # "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            # without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            # distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            # permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            # the following conditions:
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            # included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            +
            require 'glimmer/data_binding/observer'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            using ArrayIncludeMethods
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            module Glimmer
         | 
| 28 | 
            +
              module LibUI
         | 
| 29 | 
            +
                # Proxy for LibUI image objects
         | 
| 30 | 
            +
                #
         | 
| 31 | 
            +
                # Follows the Proxy Design Pattern
         | 
| 32 | 
            +
                class ImageProxy < ControlProxy
         | 
| 33 | 
            +
                  def initialize(keyword, parent, args, &block)
         | 
| 34 | 
            +
                    @keyword = keyword
         | 
| 35 | 
            +
                    @parent_proxy = parent
         | 
| 36 | 
            +
                    @args = args
         | 
| 37 | 
            +
                    @block = block
         | 
| 38 | 
            +
                    @enabled = true
         | 
| 39 | 
            +
                    @children = []
         | 
| 40 | 
            +
                    post_add_content if @block.nil?
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                  
         | 
| 43 | 
            +
                  def post_add_content
         | 
| 44 | 
            +
                    build_control
         | 
| 45 | 
            +
                    super
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             
         | 
| 48 | 
            +
                  def post_initialize_child(child)
         | 
| 49 | 
            +
                    @children << child
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                  
         | 
| 52 | 
            +
                  private
         | 
| 53 | 
            +
                  
         | 
| 54 | 
            +
                  def build_control
         | 
| 55 | 
            +
                    @args = [@children.first.args[1], @children.first.args[2]] if @children.size == 1 && (@args[0].nil? || @args[1].nil?)
         | 
| 56 | 
            +
                    super
         | 
| 57 | 
            +
                    @libui.tap do
         | 
| 58 | 
            +
                      @children.each {|child| child&.send(:build_control) }
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
            end
         | 
| @@ -20,6 +20,9 @@ | |
| 20 20 | 
             
            # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 21 21 |  | 
| 22 22 | 
             
            require 'glimmer/libui/control_proxy'
         | 
| 23 | 
            +
            require 'glimmer/data_binding/observer'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            using ArrayIncludeMethods
         | 
| 23 26 |  | 
| 24 27 | 
             
            module Glimmer
         | 
| 25 28 | 
             
              module LibUI
         | 
| @@ -63,18 +66,18 @@ module Glimmer | |
| 63 66 | 
             
                    if rows.nil?
         | 
| 64 67 | 
             
                      @cell_rows
         | 
| 65 68 | 
             
                    else
         | 
| 66 | 
            -
                       | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                           | 
| 71 | 
            -
                             | 
| 72 | 
            -
             | 
| 73 | 
            -
                             | 
| 69 | 
            +
                      @cell_rows = rows
         | 
| 70 | 
            +
                      @cell_rows.tap do
         | 
| 71 | 
            +
                        @last_cell_rows = @cell_rows.clone
         | 
| 72 | 
            +
                        Glimmer::DataBinding::Observer.proc do
         | 
| 73 | 
            +
                          if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
         | 
| 74 | 
            +
                            @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |index|
         | 
| 75 | 
            +
                              ::LibUI.table_model_row_deleted(model, index)
         | 
| 76 | 
            +
                            end
         | 
| 74 77 | 
             
                          end
         | 
| 75 | 
            -
             | 
| 78 | 
            +
                          @last_cell_rows = @cell_rows.clone
         | 
| 79 | 
            +
                        end.observe(self, :cell_rows)
         | 
| 76 80 | 
             
                      end
         | 
| 77 | 
            -
                      @cell_rows = rows
         | 
| 78 81 | 
             
                    end
         | 
| 79 82 | 
             
                  end
         | 
| 80 83 | 
             
                  alias cell_rows= cell_rows
         | 
| @@ -104,28 +107,26 @@ module Glimmer | |
| 104 107 | 
             
                    @model_handler.NumColumns   = rbcallback(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : 1}.sum }
         | 
| 105 108 | 
             
                    @model_handler.ColumnType   = rbcallback(4, [1, 1, 4]) do |_, _, column|
         | 
| 106 109 | 
             
                      case @columns[column]
         | 
| 107 | 
            -
                      when TextColumnProxy, NilClass
         | 
| 110 | 
            +
                      when TextColumnProxy, ButtonColumnProxy, NilClass
         | 
| 108 111 | 
             
                        0
         | 
| 109 112 | 
             
                      when ImageColumnProxy, ImageTextColumnProxy
         | 
| 110 113 | 
             
                        1
         | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
            #           when CheckboxTextColumnProxy
         | 
| 114 | 
            -
            #             2
         | 
| 114 | 
            +
                      when CheckboxColumnProxy, CheckboxTextColumnProxy
         | 
| 115 | 
            +
                        2
         | 
| 115 116 | 
             
            #           when ProgressBarColumnProxy
         | 
| 116 117 | 
             
            #             2
         | 
| 117 | 
            -
            #           when ButtonColumnProxy
         | 
| 118 | 
            -
            #             0
         | 
| 119 118 | 
             
                      end
         | 
| 120 119 | 
             
                    end
         | 
| 121 120 | 
             
                    @model_handler.NumRows      = rbcallback(4) { cell_rows.count }
         | 
| 122 121 | 
             
                    @model_handler.CellValue    = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
         | 
| 123 122 | 
             
                      the_cell_rows = expanded_cell_rows
         | 
| 124 123 | 
             
                      case @columns[column]
         | 
| 125 | 
            -
                      when TextColumnProxy, NilClass
         | 
| 124 | 
            +
                      when TextColumnProxy, ButtonColumnProxy, NilClass
         | 
| 126 125 | 
             
                        ::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
         | 
| 127 126 | 
             
                      when ImageColumnProxy, ImageTextColumnProxy
         | 
| 128 | 
            -
                        ::LibUI.new_table_value_image((expanded_cell_rows[row] && expanded_cell_rows[row][column]))
         | 
| 127 | 
            +
                        ::LibUI.new_table_value_image((expanded_cell_rows[row] && (expanded_cell_rows[row][column].respond_to?(:libui) ? expanded_cell_rows[row][column].libui : expanded_cell_rows[row][column])))
         | 
| 128 | 
            +
                      when CheckboxColumnProxy, CheckboxTextColumnProxy
         | 
| 129 | 
            +
                        ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column] == 1 || expanded_cell_rows[row][column].to_s.strip.downcase == 'true' ? 1 : 0)))
         | 
| 129 130 | 
             
                      end
         | 
| 130 131 | 
             
                    end
         | 
| 131 132 | 
             
                    @model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
         | 
| @@ -135,9 +136,14 @@ module Glimmer | |
| 135 136 | 
             
                        @cell_rows[row] ||= []
         | 
| 136 137 | 
             
                        @cell_rows[row][column] = ::LibUI.table_value_string(val).to_s
         | 
| 137 138 | 
             
                      when NilClass
         | 
| 138 | 
            -
                        # TODO ensure this works for editable table
         | 
| 139 139 | 
             
                        column = @columns[column - 1].index
         | 
| 140 140 | 
             
                        @cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
         | 
| 141 | 
            +
                      when ButtonColumnProxy
         | 
| 142 | 
            +
                        @columns[column].notify_listeners(:on_clicked, row)
         | 
| 143 | 
            +
                      when CheckboxColumnProxy, CheckboxTextColumnProxy
         | 
| 144 | 
            +
                        column = @columns[column].index
         | 
| 145 | 
            +
                        @cell_rows[row] ||= []
         | 
| 146 | 
            +
                        @cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
         | 
| 141 147 | 
             
                      end
         | 
| 142 148 | 
             
                    end
         | 
| 143 149 |  | 
| @@ -61,20 +61,29 @@ module Glimmer | |
| 61 61 | 
             
                    end
         | 
| 62 62 | 
             
                  end
         | 
| 63 63 |  | 
| 64 | 
            +
                  def can_handle_listener?(listener_name)
         | 
| 65 | 
            +
                    listener_name == 'on_destroy' || super
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                  
         | 
| 64 68 | 
             
                  def handle_listener(listener_name, &listener)
         | 
| 65 | 
            -
                     | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                         | 
| 71 | 
            -
                           | 
| 72 | 
            -
                           | 
| 73 | 
            -
             | 
| 69 | 
            +
                    case listener_name
         | 
| 70 | 
            +
                    when 'on_destroy'
         | 
| 71 | 
            +
                      on_destroy(&listener)
         | 
| 72 | 
            +
                    else
         | 
| 73 | 
            +
                      if listener_name == 'on_closing'
         | 
| 74 | 
            +
                        default_behavior_listener = Proc.new do
         | 
| 75 | 
            +
                          return_value = listener.call(self)
         | 
| 76 | 
            +
                          if return_value.is_a?(Numeric)
         | 
| 77 | 
            +
                            return_value
         | 
| 78 | 
            +
                          else
         | 
| 79 | 
            +
                            destroy
         | 
| 80 | 
            +
                            ::LibUI.quit
         | 
| 81 | 
            +
                            0
         | 
| 82 | 
            +
                          end
         | 
| 74 83 | 
             
                        end
         | 
| 75 84 | 
             
                      end
         | 
| 85 | 
            +
                      super(listener_name, &default_behavior_listener)
         | 
| 76 86 | 
             
                    end
         | 
| 77 | 
            -
                    super(listener_name, &default_behavior_listener)
         | 
| 78 87 | 
             
                  end
         | 
| 79 88 |  | 
| 80 89 | 
             
                  private
         | 
    
        data/lib/glimmer-dsl-libui.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: glimmer-dsl-libui
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.25
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Andy Maleh
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021-09- | 
| 11 | 
            +
            date: 2021-09-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: glimmer
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 2.1. | 
| 19 | 
            +
                    version: 2.1.5
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 2.1. | 
| 26 | 
            +
                    version: 2.1.5
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: os
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -50,14 +50,14 @@ dependencies: | |
| 50 50 | 
             
                requirements:
         | 
| 51 51 | 
             
                - - "~>"
         | 
| 52 52 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: 0.0. | 
| 53 | 
            +
                    version: 0.0.10
         | 
| 54 54 | 
             
              type: :runtime
         | 
| 55 55 | 
             
              prerelease: false
         | 
| 56 56 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 57 | 
             
                requirements:
         | 
| 58 58 | 
             
                - - "~>"
         | 
| 59 59 | 
             
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            -
                    version: 0.0. | 
| 60 | 
            +
                    version: 0.0.10
         | 
| 61 61 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 62 62 | 
             
              name: juwelier
         | 
| 63 63 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -197,6 +197,9 @@ files: | |
| 197 197 | 
             
            - examples/basic_button.rb
         | 
| 198 198 | 
             
            - examples/basic_entry.rb
         | 
| 199 199 | 
             
            - examples/basic_table.rb
         | 
| 200 | 
            +
            - examples/basic_table_button.rb
         | 
| 201 | 
            +
            - examples/basic_table_checkbox.rb
         | 
| 202 | 
            +
            - examples/basic_table_checkbox_text.rb
         | 
| 200 203 | 
             
            - examples/basic_table_image.rb
         | 
| 201 204 | 
             
            - examples/basic_table_image_text.rb
         | 
| 202 205 | 
             
            - examples/basic_window.rb
         | 
| @@ -224,9 +227,12 @@ files: | |
| 224 227 | 
             
            - lib/glimmer/dsl/libui/tab_item_expression.rb
         | 
| 225 228 | 
             
            - lib/glimmer/libui/about_menu_item_proxy.rb
         | 
| 226 229 | 
             
            - lib/glimmer/libui/box.rb
         | 
| 230 | 
            +
            - lib/glimmer/libui/button_column_proxy.rb
         | 
| 227 231 | 
             
            - lib/glimmer/libui/button_proxy.rb
         | 
| 228 232 | 
             
            - lib/glimmer/libui/check_menu_item_proxy.rb
         | 
| 233 | 
            +
            - lib/glimmer/libui/checkbox_column_proxy.rb
         | 
| 229 234 | 
             
            - lib/glimmer/libui/checkbox_proxy.rb
         | 
| 235 | 
            +
            - lib/glimmer/libui/checkbox_text_column_proxy.rb
         | 
| 230 236 | 
             
            - lib/glimmer/libui/color_button_proxy.rb
         | 
| 231 237 | 
             
            - lib/glimmer/libui/column.rb
         | 
| 232 238 | 
             
            - lib/glimmer/libui/combobox_proxy.rb
         | 
| @@ -236,6 +242,7 @@ files: | |
| 236 242 | 
             
            - lib/glimmer/libui/dual_column.rb
         | 
| 237 243 | 
             
            - lib/glimmer/libui/editable_column.rb
         | 
| 238 244 | 
             
            - lib/glimmer/libui/editable_combobox_proxy.rb
         | 
| 245 | 
            +
            - lib/glimmer/libui/enableable_column.rb
         | 
| 239 246 | 
             
            - lib/glimmer/libui/font_button_proxy.rb
         | 
| 240 247 | 
             
            - lib/glimmer/libui/form_proxy.rb
         | 
| 241 248 | 
             
            - lib/glimmer/libui/grid_proxy.rb
         | 
| @@ -243,6 +250,7 @@ files: | |
| 243 250 | 
             
            - lib/glimmer/libui/horizontal_box_proxy.rb
         | 
| 244 251 | 
             
            - lib/glimmer/libui/image_column_proxy.rb
         | 
| 245 252 | 
             
            - lib/glimmer/libui/image_part_proxy.rb
         | 
| 253 | 
            +
            - lib/glimmer/libui/image_proxy.rb
         | 
| 246 254 | 
             
            - lib/glimmer/libui/image_text_column_proxy.rb
         | 
| 247 255 | 
             
            - lib/glimmer/libui/label_proxy.rb
         | 
| 248 256 | 
             
            - lib/glimmer/libui/menu_item_proxy.rb
         |