glimmer-dsl-libui 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc7805628b0893f2d955c437f8e46932acfbac8db7576cdd28021b12cfe8d942
4
- data.tar.gz: 4915a6b72d733ca9d4ba7fedf08abc66377bf9a9cd6eca288f1b1a60556951f2
3
+ metadata.gz: 032f3de542f72c7bec706935b9e233b59a861fc88568fef5dd1b1b788137674c
4
+ data.tar.gz: 9791ad59faff6d21dd4fa59668d65266b5da1ffbfa49c0bd5cfaf900ee2a2c8c
5
5
  SHA512:
6
- metadata.gz: ef4ac023c7fcb8638a335fd4cf28db03b8d784cb27f63b3edb411c05c5395740d7eb0593f9716657a516314bd6d1effd581abfdbb07de6c1a18225d037344472
7
- data.tar.gz: 2ee4dab775fd3ae4235b924f37879d84a61dffce138b0b25cd495464931ae20efc5f45ed34d4c6f9767dc2fc15bbb30eafb70fe37efa56de0d8505ea144be010
6
+ metadata.gz: 013d2d62c31f7738a06bd41aefcef7b7646a570148d7e6f413971df7f938cdb2781d050ae25143c56d8c77cc9b50537f783991415b5a5169dfab75741f9f4dd2
7
+ data.tar.gz: 8bd2666d00a15e966f3ea7e5c391cb88a1307249e9af63a576b2d6f29989c79a89b245bcc6fc9a36286f38aa2cc2b386586b4328eecb08b58a53119b347b8162
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.19
4
+
5
+ - New examples/editable_table.rb
6
+ - Support editable `table` control
7
+ - Fix issue with table `text_column` repeating the first column as the second
8
+
3
9
  ## 0.0.18
4
10
 
5
11
  - Support examples/basic_table_image.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.18
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.19
2
2
  ## Prerequisite-Free Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](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.18](#-glimmer-dsl-for-libui-0018)
46
+ - [Glimmer DSL for LibUI 0.0.19](#-glimmer-dsl-for-libui-0019)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -157,7 +157,7 @@ gem install glimmer-dsl-libui
157
157
  Or install via Bundler `Gemfile`:
158
158
 
159
159
  ```ruby
160
- gem 'glimmer-dsl-libui', '~> 0.0.18'
160
+ gem 'glimmer-dsl-libui', '~> 0.0.19'
161
161
  ```
162
162
 
163
163
  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.
@@ -245,7 +245,7 @@ Control(Args) | Properties | Listeners
245
245
  `spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
246
246
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
247
247
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
248
- `table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values)) | None
248
+ `table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values)), `editable` as Boolean | None
249
249
  `text_column(name as String)` | None | None
250
250
  `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`
251
251
  `vertical_box` | `padded` (Boolean) | None
@@ -1880,6 +1880,67 @@ window('Animal sounds', 300, 200) {
1880
1880
  }.show
1881
1881
  ```
1882
1882
 
1883
+ ### Editable Table
1884
+
1885
+ [examples/editable_table.rb](examples/editable_table.rb)
1886
+
1887
+ Run with this command from the root of the project if you cloned the project:
1888
+
1889
+ ```
1890
+ ruby -r './lib/glimmer-dsl-libui' examples/editable_table.rb
1891
+ ```
1892
+
1893
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
1894
+
1895
+ ```
1896
+ ruby -r glimmer-dsl-libui -e "require 'examples/editable_table'"
1897
+ ```
1898
+
1899
+ Mac
1900
+
1901
+ ![glimmer-dsl-libui-mac-editable-table.png](images/glimmer-dsl-libui-mac-editable-table.png)
1902
+ ![glimmer-dsl-libui-mac-editable-table-editing.png](images/glimmer-dsl-libui-mac-editable-table-editing.png)
1903
+ ![glimmer-dsl-libui-mac-editable-table-edited.png](images/glimmer-dsl-libui-mac-editable-table-edited.png)
1904
+
1905
+ Linux
1906
+
1907
+ ![glimmer-dsl-libui-linux-editable-table.png](images/glimmer-dsl-libui-linux-editable-table.png)
1908
+ ![glimmer-dsl-libui-linux-editable-table-editing.png](images/glimmer-dsl-libui-linux-editable-table-editing.png)
1909
+ ![glimmer-dsl-libui-linux-editable-table-edited.png](images/glimmer-dsl-libui-linux-editable-table-edited.png)
1910
+
1911
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1912
+
1913
+ ```ruby
1914
+ require 'glimmer-dsl-libui'
1915
+
1916
+ include Glimmer
1917
+
1918
+ data = [
1919
+ %w[cat meow],
1920
+ %w[dog woof],
1921
+ %w[chicken cock-a-doodle-doo],
1922
+ %w[hourse neigh],
1923
+ %w[cow moo]
1924
+ ]
1925
+
1926
+ window('Editable animal sounds', 300, 200) {
1927
+ horizontal_box {
1928
+ table {
1929
+ text_column('Animal')
1930
+ text_column('Description')
1931
+
1932
+ cell_rows data
1933
+ editable true
1934
+ }
1935
+ }
1936
+
1937
+ on_closing do
1938
+ puts 'Bye Bye'
1939
+ end
1940
+ }.show
1941
+ ```
1942
+
1943
+
1883
1944
  ### Basic Table Image
1884
1945
 
1885
1946
  This example has a prerequisite of installing `chunky_png` Ruby gem:
@@ -2030,8 +2091,8 @@ window('The Red Turtle', 310, 350, false) {
2030
2091
 
2031
2092
  cell_rows IMAGE_ROWS
2032
2093
  }
2033
-
2034
2094
  }
2095
+
2035
2096
  on_closing do
2036
2097
  puts 'Bye Bye'
2037
2098
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.18
1
+ 0.0.19
@@ -35,8 +35,8 @@ window('The Red Turtle', 310, 350, false) {
35
35
 
36
36
  cell_rows IMAGE_ROWS
37
37
  }
38
-
39
38
  }
39
+
40
40
  on_closing do
41
41
  puts 'Bye Bye'
42
42
  end
@@ -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],
9
+ %w[dog woof],
10
+ %w[chicken cock-a-doodle-doo],
11
+ %w[hourse neigh],
12
+ %w[cow moo]
13
+ ]
14
+
15
+ window('Editable animal sounds', 300, 200) {
16
+ horizontal_box {
17
+ table {
18
+ text_column('Animal')
19
+ text_column('Description')
20
+
21
+ cell_rows data
22
+ editable true
23
+ }
24
+ }
25
+
26
+ on_closing do
27
+ puts 'Bye Bye'
28
+ end
29
+ }.show
Binary file
@@ -25,6 +25,9 @@ module Glimmer
25
25
  module LibUI
26
26
  # Common logic for all column proxy objects
27
27
  module Column
28
+ attr_reader :appended
29
+ alias appended? appended
30
+
28
31
  def initialize(keyword, parent, args, &block)
29
32
  @keyword = keyword
30
33
  @parent_proxy = parent
@@ -37,6 +40,16 @@ module Glimmer
37
40
  def name
38
41
  @args.first
39
42
  end
43
+
44
+ private
45
+
46
+ def build_control
47
+ @appended = true
48
+ end
49
+
50
+ def next_column_index
51
+ @parent_proxy.columns.map(&:appended?).compact.count
52
+ end
40
53
  end
41
54
  end
42
55
  end
@@ -33,7 +33,8 @@ module Glimmer
33
33
  private
34
34
 
35
35
  def build_control
36
- @libui = @parent_proxy.append_image_column(name, @parent_proxy.columns.map(&:libui).compact.count)
36
+ @parent_proxy.append_image_column(name, next_column_index)
37
+ super
37
38
  end
38
39
  end
39
40
  end
@@ -68,13 +68,25 @@ module Glimmer
68
68
  alias cell_rows= cell_rows
69
69
  alias set_cell_rows cell_rows
70
70
 
71
+ def editable(value = nil)
72
+ if value.nil?
73
+ @editable
74
+ else
75
+ @editable = !!value
76
+ end
77
+ end
78
+ alias editable= editable
79
+ alias set_editable editable
80
+ alias editable? editable
81
+
71
82
  private
72
83
 
73
84
  def build_control
74
85
  @model_handler = ::LibUI::FFI::TableModelHandler.malloc
75
86
  @model_handler.NumColumns = rbcallback(4) { @columns.count }
76
87
  @model_handler.ColumnType = rbcallback(4) do
77
- # TODO support different values for different columns
88
+ # Note: this assumes all columns are the same type
89
+ # TODO support different values per different columns
78
90
  case @columns.first
79
91
  when TextColumnProxy
80
92
  0
@@ -91,6 +103,13 @@ module Glimmer
91
103
  ::LibUI.new_table_value_image((@cell_rows[row] && @cell_rows[row][column]))
92
104
  end
93
105
  end
106
+ @model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
107
+ case @columns[column]
108
+ when TextColumnProxy
109
+ @cell_rows[row] ||= []
110
+ @cell_rows[row][column] = ::LibUI.table_value_string(val).to_s
111
+ end
112
+ end
94
113
 
95
114
  @model = ::LibUI.new_table_model(@model_handler)
96
115
 
@@ -29,11 +29,12 @@ module Glimmer
29
29
  # Follows the Proxy Design Pattern
30
30
  class TextColumnProxy < ControlProxy
31
31
  include Column
32
-
32
+
33
33
  private
34
34
 
35
35
  def build_control
36
- @libui = @parent_proxy.append_text_column(name, @parent_proxy.columns.map(&:libui).compact.count, -1) # -1 for non-editable for now until editing is supported
36
+ @parent_proxy.append_text_column(name, next_column_index, @parent_proxy.editable? ? -2 : -1)
37
+ super
37
38
  end
38
39
  end
39
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -203,6 +203,7 @@ files:
203
203
  - examples/color_button.rb
204
204
  - examples/control_gallery.rb
205
205
  - examples/date_time_picker.rb
206
+ - examples/editable_table.rb
206
207
  - examples/font_button.rb
207
208
  - examples/form.rb
208
209
  - examples/grid.rb