glimmer-dsl-libui 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33e2f34a434ea4036e788ae6fee9b2329220f53b002357c5447cdf6d2421959b
4
- data.tar.gz: d38442e11122157bb2aa1db6a7881a3bc0e353c40842ccfdc823a357cdf9a16e
3
+ metadata.gz: c97e75e5d70341821d3b41fe832ae7efe1c70713ad673576a8498c4a3cd4ce70
4
+ data.tar.gz: 46fab85f1c845963a823a4e894987914dfbff128122db19b7ae4a82766f43044
5
5
  SHA512:
6
- metadata.gz: c0c9657f2d68852873bdbf8a294816a2bc684e5ca902e8c9c1d43d43ed0e313850ef127176470b29df0c000a4fe65465cc58948c0cfcdc182eef569c978fd72a
7
- data.tar.gz: b13df322764b9bd8e4fd2259992d2eff0abe2ed1f4e7e144deb8d15d56ddaccd6eaaa78fa40715eaff89dddbd201a4a9f2f6d77fd9ab8692cbf325043161510e
6
+ metadata.gz: 9aa8032624bfdca1b1dcdb399e16eb2246244f09d48cf476e20a35ce58b2d2b0e6bba34defb810a8265a1c838422fecffd09f568aabb797c7d5ba93c6ffed93d
7
+ data.tar.gz: 63206e935531bf431b417925fc4c569d685e6acbfc06e73d8231b7f53f60751bab0797ddfdd9580ca85d4cbc9d27e80b23b0bebccafa554ab988130e17478fe5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.2.8
4
+
5
+ - Support `table` `on_changed` listener to report all changes (of operation type `:deleted`, `:changed`, `:inserted`)
6
+ - Support `table` `on_edited` listener to report changes happening through direct table editing only
7
+ - Default value of `text` `width` argument looks into x and adjusts by leaving the same space on the right side
8
+
3
9
  ## 0.2.7
4
10
 
5
11
  - New examples/basic_table_color.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.2.7
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.2.8
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)
@@ -197,7 +197,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
197
197
 
198
198
  ## Table of Contents
199
199
 
200
- - [Glimmer DSL for LibUI 0.2.7](#-glimmer-dsl-for-libui-027)
200
+ - [Glimmer DSL for LibUI 0.2.8](#-glimmer-dsl-for-libui-028)
201
201
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
202
202
  - [Usage](#usage)
203
203
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
@@ -334,7 +334,7 @@ gem install glimmer-dsl-libui
334
334
  Or install via Bundler `Gemfile`:
335
335
 
336
336
  ```ruby
337
- gem 'glimmer-dsl-libui', '~> 0.2.7'
337
+ gem 'glimmer-dsl-libui', '~> 0.2.8'
338
338
  ```
339
339
 
340
340
  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.
@@ -460,7 +460,7 @@ Control(Args) | Properties | Listeners
460
460
  `string` | `font`, `color`, `background`, `underline`, `underline_color`, `open_type_features` | None
461
461
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
462
462
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
463
- `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
463
+ `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 | `on_changed {|row, type, row_data| ...}`, `on_edited {|row, row_data| ...}`
464
464
  `text(x = 0 as Numeric, y = 0 as Numeric, width = area_width as Numeric)` | `align`, `default_font` | None
465
465
  `text_column(name as String)` | `editable` (Boolean) | None
466
466
  `text_color_column(name as String)` | `editable` (Boolean) | None
@@ -2524,6 +2524,14 @@ window('Editable animal sounds', 300, 200) {
2524
2524
 
2525
2525
  cell_rows data
2526
2526
  editable true
2527
+
2528
+ on_changed do |row, type, row_data| # fires on all changes (even ones happening through data array)
2529
+ puts "Row #{row} #{type}: #{row_data}"
2530
+ end
2531
+
2532
+ on_edited do |row, row_data| # only fires on direct table editing
2533
+ puts "Row #{row} edited: #{row_data}"
2534
+ end
2527
2535
  }
2528
2536
  }
2529
2537
 
@@ -2882,6 +2890,10 @@ window('Animal sounds', 300, 200) {
2882
2890
  }
2883
2891
 
2884
2892
  cell_rows data # implicit data-binding
2893
+
2894
+ on_changed do |row, type, row_data|
2895
+ puts "Row #{row} #{type}: #{row_data}"
2896
+ end
2885
2897
  }
2886
2898
  }
2887
2899
  }.show
@@ -3239,6 +3251,10 @@ window('Contacts', 600, 600) { |w|
3239
3251
  text_column('State')
3240
3252
 
3241
3253
  cell_rows data # implicit data-binding
3254
+
3255
+ on_changed do |row, type, row_data|
3256
+ puts "Row #{row} #{type}: #{row_data}"
3257
+ end
3242
3258
  }
3243
3259
  }
3244
3260
  }.show
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -24,6 +24,10 @@ window('Animal sounds', 300, 200) {
24
24
  }
25
25
 
26
26
  cell_rows data # implicit data-binding
27
+
28
+ on_changed do |row, type, row_data|
29
+ puts "Row #{row} #{type}: #{row_data}"
30
+ end
27
31
  }
28
32
  }
29
33
  }.show
@@ -69,7 +69,7 @@ class CustomDrawText
69
69
  }
70
70
 
71
71
  area {
72
- text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
72
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
73
73
  # align :left # default alignment
74
74
 
75
75
  @string = string {
@@ -76,7 +76,7 @@ class CustomDrawText
76
76
 
77
77
  @area = area {
78
78
  on_draw do |area_draw_params|
79
- text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
79
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
80
80
  # align :left # default alignment
81
81
 
82
82
  string {
@@ -20,6 +20,14 @@ window('Editable animal sounds', 300, 200) {
20
20
 
21
21
  cell_rows data
22
22
  editable true
23
+
24
+ on_changed do |row, type, row_data| # fires on all changes (even ones happening through data array)
25
+ puts "Row #{row} #{type}: #{row_data}"
26
+ end
27
+
28
+ on_edited do |row, row_data| # only fires on direct table editing
29
+ puts "Row #{row} edited: #{row_data}"
30
+ end
23
31
  }
24
32
  }
25
33
 
@@ -82,6 +82,10 @@ window('Contacts', 600, 600) { |w|
82
82
  text_column('State')
83
83
 
84
84
  cell_rows data # implicit data-binding
85
+
86
+ on_changed do |row, type, row_data|
87
+ puts "Row #{row} #{type}: #{row_data}"
88
+ end
85
89
  }
86
90
  }
87
91
  }.show
Binary file
@@ -35,6 +35,8 @@ module Glimmer
35
35
  class TableProxy < ControlProxy
36
36
  include Glimmer::FiddleConsumer
37
37
 
38
+ LISTENERS = ['on_changed', 'on_edited']
39
+
38
40
  attr_reader :model_handler, :model, :table_params, :columns
39
41
 
40
42
  def initialize(keyword, parent, args, &block)
@@ -86,14 +88,19 @@ module Glimmer
86
88
  if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
87
89
  @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
88
90
  ::LibUI.table_model_row_deleted(model, row)
91
+ on_changed.each {|listener| listener.call(row, :deleted, @last_cell_rows[row])}
89
92
  end
90
93
  elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
91
94
  @cell_rows.array_diff_indexes(@last_cell_rows).each do |row|
92
95
  ::LibUI.table_model_row_inserted(model, row)
96
+ on_changed.each {|listener| listener.call(row, :inserted, @cell_rows[row])}
93
97
  end
94
98
  else
95
99
  @cell_rows.each_with_index do |new_row_data, row|
96
- ::LibUI.table_model_row_changed(model, row) if new_row_data != @last_cell_rows[row]
100
+ if new_row_data != @last_cell_rows[row]
101
+ ::LibUI.table_model_row_changed(model, row)
102
+ on_changed.each {|listener| listener.call(row, :changed, @cell_rows[row])}
103
+ end
97
104
  end
98
105
  end
99
106
  @last_cell_rows = @cell_rows.clone
@@ -175,6 +182,8 @@ module Glimmer
175
182
  @cell_rows[row] ||= []
176
183
  @cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
177
184
  end
185
+ on_changed.each {|listener| listener.call(row, :changed, @cell_rows[row])}
186
+ on_edited.each {|listener| listener.call(row, @cell_rows[row])}
178
187
  end
179
188
 
180
189
  @model = ::LibUI.new_table_model(@model_handler)
@@ -90,7 +90,7 @@ module Glimmer
90
90
 
91
91
  def width(value = nil)
92
92
  if value.nil?
93
- @width ||= args[2] || (AreaProxy.current_area_draw_params && AreaProxy.current_area_draw_params[:area_width])
93
+ @width ||= args[2] || (AreaProxy.current_area_draw_params && (AreaProxy.current_area_draw_params[:area_width] - 2*x))
94
94
  else
95
95
  @width = value
96
96
  redraw
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.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh