glimmer-dsl-libui 0.4.16 → 0.4.17

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: 8acbe91938a88381cab6203cca03222967f2cf9f8b9acce1b1cc9334b7dee8a6
4
- data.tar.gz: a769546a4a2ecf9075c6161f8d2705c7a86c85f463c4c297cb9c7f45c8e90d72
3
+ metadata.gz: 7fc87cc5cdac4adda4a307a3b38ec3255efdacd9a97a667c6840788be005ab80
4
+ data.tar.gz: 2d57256b28fb43d584949d9316ceaf70ca67999b918ebfca5898aef99f78add4
5
5
  SHA512:
6
- metadata.gz: 80b750032c8d4c6605f8843ca3ff8cafee74e53c2b1f048c22fe23a830924966441a5c7c8818cca64e0526e3fb26d83f3339ab2b7c7133fa82cc5f5b5be43034
7
- data.tar.gz: 81306b073aa159bbd8abc931032da52ac447d0626657bf7dfeff73b49083fb83a23de5e8fd4718dbea5c9209760af00e72cca29845a15735b7a9ff6370ae2340
6
+ metadata.gz: 3490923e9e595407a17350f337f1a8128a59bba1d7b0b2ce2dde12c1425324b6ca8a7688a307290a79baece9eeda8f54bedb3c2e6eb59dbfc65d9702136b6271
7
+ data.tar.gz: f935b3d85c167e5697973e77a419ad2d929e3071a5013fba2dd3b04035b5da5d1e5623df10ceefb6535fed428b2f127f42373fb42b54853f61f0834031addb7f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.4.17
4
+
5
+ - Remove Windows workaround of always adding an extra row at the bottom of `table` as it is no longer necessary after adding a better workaround (on Windows, add & remove row just after constructing `table` to get rid of double-delete glitch)
6
+ - Improved parsing code of examples/cpu_percentage.rb for Windows to make it more resilient
7
+ - Upgrade to glimmer 2.5.3 to silently ignore frozen observables with `observe(*args, ignore_frozen: true)`
8
+ - Added equalizer gem dependency to properly provide equality methods for `Glimmer::LibUI::ControlProxy::ImageProxy`
9
+
3
10
  ## 0.4.16
4
11
 
5
12
  - Upgrade to glimmer 2.5.1
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.4.16
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.4.17
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
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -506,7 +506,7 @@ gem install glimmer-dsl-libui
506
506
  Or install via Bundler `Gemfile`:
507
507
 
508
508
  ```ruby
509
- gem 'glimmer-dsl-libui', '~> 0.4.16'
509
+ gem 'glimmer-dsl-libui', '~> 0.4.17'
510
510
  ```
511
511
 
512
512
  Test that installation worked by running the [Meta-Example](#examples):
@@ -1795,8 +1795,8 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
1795
1795
  #### Data-Binding Gotchas
1796
1796
 
1797
1797
  - Never data-bind a control property to an attribute on the same view object with the same exact name (e.g. binding `entry` `text` property to `self` `text` attribute) as it would conflict with it. Instead, data-bind view property to an attribute with a different name on the view object or with the same name, but on a presenter or model object (e.g. data-bind `entry` `text` to `self` `legal_text` attribute or to `contract` model `text` attribute)
1798
- - Data-binding a property utilizes the control's listener associated with the property (e.g. `on_changed` for `entry` `text`), so you cannot hook into the listener directly anymore as that would negate data-binding. Instead, you can add an `after_write: ->(val) {}` option to perform something on trigger of the control listener instead.
1799
- - Data-binding a View control to another View control directly is not a good idea. Instead, data-bind both View controls to the same Presenter/Model attribute, and that keeps them in sync while keeping the code decoupled.
1798
+ - Data-binding a property utilizes the control's listener associated with the property (e.g. `on_changed` for `entry` `text`), so although you can add another listener if you want ([Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) will happily add your listener to the list of listeners that will get notified by a certain event), sometimes it is recommended that you add an `after_read: ->(val) {}` or `after_write: ->(val) {}` block instead to perform something after data-binding reads from or writes to the Model attribute.
1799
+ - Data-binding a View control to another View control directly is not a good practice as it causes tight-coupling. Instead, data-bind both View controls to the same Presenter/Model attribute, and that keeps them in sync while keeping the code decoupled.
1800
1800
 
1801
1801
  ### API Gotchas
1802
1802
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.16
1
+ 0.4.17
data/bin/girb CHANGED
File without changes
@@ -11,7 +11,7 @@ Glimmer::LibUI.timer(1) do
11
11
  cpu_percentage_value = nil
12
12
  if OS.windows?
13
13
  cpu_percentage_raw_value = `wmic cpu get loadpercentage`
14
- cpu_percentage_value = cpu_percentage_raw_value.split("\n")[2].to_i
14
+ cpu_percentage_value = cpu_percentage_raw_value.split("\n").map(&:strip).find {|l| l.match(/^\d+$/)}.to_i
15
15
  elsif OS.mac?
16
16
  cpu_percentage_value = `ps -A -o %cpu | awk '{s+=$1} END {print s}'`.to_i
17
17
  elsif OS.linux?
Binary file
@@ -30,6 +30,12 @@ module Glimmer
30
30
  #
31
31
  # Follows the Proxy Design Pattern
32
32
  class BackgroundColorColumnProxy < ControlProxy
33
+ class << self
34
+ def default_value
35
+ :white
36
+ end
37
+ end
38
+
33
39
  include Column
34
40
 
35
41
  def name
@@ -31,6 +31,12 @@ module Glimmer
31
31
  #
32
32
  # Follows the Proxy Design Pattern
33
33
  class ButtonColumnProxy < ControlProxy
34
+ class << self
35
+ def default_value
36
+ ''
37
+ end
38
+ end
39
+
34
40
  include Column
35
41
  include EnableableColumn
36
42
 
@@ -31,6 +31,12 @@ module Glimmer
31
31
  #
32
32
  # Follows the Proxy Design Pattern
33
33
  class CheckboxColumnProxy < ControlProxy
34
+ class << self
35
+ def default_value
36
+ false
37
+ end
38
+ end
39
+
34
40
  include Column
35
41
  include EditableColumn
36
42
 
@@ -32,6 +32,12 @@ module Glimmer
32
32
  #
33
33
  # Follows the Proxy Design Pattern
34
34
  class CheckboxTextColorColumnProxy < ControlProxy
35
+ class << self
36
+ def default_value
37
+ [false, '', :black]
38
+ end
39
+ end
40
+
35
41
  include Column
36
42
  include TripleColumn
37
43
  include EditableColumn
@@ -32,6 +32,12 @@ module Glimmer
32
32
  #
33
33
  # Follows the Proxy Design Pattern
34
34
  class CheckboxTextColumnProxy < ControlProxy
35
+ class << self
36
+ def default_value
37
+ [false, '']
38
+ end
39
+ end
40
+
35
41
  include Column
36
42
  include DualColumn
37
43
  include EditableColumn
@@ -30,6 +30,12 @@ module Glimmer
30
30
  #
31
31
  # Follows the Proxy Design Pattern
32
32
  class ImageColumnProxy < ControlProxy
33
+ class << self
34
+ def default_value
35
+ Glimmer::LibUI::ICON
36
+ end
37
+ end
38
+
33
39
  include Column
34
40
 
35
41
  private
@@ -32,6 +32,12 @@ module Glimmer
32
32
  #
33
33
  # Follows the Proxy Design Pattern
34
34
  class ImageTextColorColumnProxy < ControlProxy
35
+ class << self
36
+ def default_value
37
+ [Glimmer::LibUI::ICON, '', :black]
38
+ end
39
+ end
40
+
35
41
  include Column
36
42
  include TripleColumn
37
43
  include EditableColumn
@@ -32,6 +32,12 @@ module Glimmer
32
32
  #
33
33
  # Follows the Proxy Design Pattern
34
34
  class ImageTextColumnProxy < ControlProxy
35
+ class << self
36
+ def default_value
37
+ [Glimmer::LibUI::ICON, '']
38
+ end
39
+ end
40
+
35
41
  include Column
36
42
  include DualColumn
37
43
  include EditableColumn
@@ -30,6 +30,12 @@ module Glimmer
30
30
  #
31
31
  # Follows the Proxy Design Pattern
32
32
  class ProgressBarColumnProxy < ControlProxy
33
+ class << self
34
+ def default_value
35
+ 0
36
+ end
37
+ end
38
+
33
39
  include Column
34
40
 
35
41
  private
@@ -32,6 +32,12 @@ module Glimmer
32
32
  #
33
33
  # Follows the Proxy Design Pattern
34
34
  class TextColorColumnProxy < ControlProxy
35
+ class << self
36
+ def default_value
37
+ ['', :black]
38
+ end
39
+ end
40
+
35
41
  include Column
36
42
  include DualColumn
37
43
  include EditableColumn
@@ -31,6 +31,12 @@ module Glimmer
31
31
  #
32
32
  # Follows the Proxy Design Pattern
33
33
  class TextColumnProxy < ControlProxy
34
+ class << self
35
+ def default_value
36
+ ''
37
+ end
38
+ end
39
+
34
40
  include Column
35
41
  include EditableColumn
36
42
 
@@ -24,6 +24,13 @@ module Glimmer
24
24
  class ControlProxy
25
25
  # Common logic for all column proxy objects
26
26
  module Column
27
+ class << self
28
+ # subclasses may override to provide a valid default value like a blank image for image columns and false for checkbox
29
+ def default_value
30
+ nil
31
+ end
32
+ end
33
+
27
34
  def initialize(keyword, parent, args, &block)
28
35
  @keyword = keyword
29
36
  @parent_proxy = parent
@@ -52,6 +52,7 @@ module Glimmer
52
52
 
53
53
  include Parent
54
54
  prepend Transformable
55
+ include Equalizer.new(:options, :data)
55
56
 
56
57
  attr_reader :data, :pixels, :shapes, :options
57
58
 
@@ -90,18 +90,18 @@ module Glimmer
90
90
  @cell_rows_observer ||= Glimmer::DataBinding::Observer.proc do |new_cell_rows|
91
91
  if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
92
92
  @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
93
- ::LibUI.table_model_row_deleted(model, row)
93
+ ::LibUI.table_model_row_deleted(model, row) if model && row
94
94
  notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
95
95
  end
96
96
  elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
97
97
  @cell_rows.array_diff_indexes(@last_cell_rows).each do |row|
98
- ::LibUI.table_model_row_inserted(model, row)
98
+ ::LibUI.table_model_row_inserted(model, row) if model && row
99
99
  notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
100
100
  end
101
101
  else
102
102
  @cell_rows.each_with_index do |new_row_data, row|
103
103
  if new_row_data != @last_cell_rows[row]
104
- ::LibUI.table_model_row_changed(model, row)
104
+ ::LibUI.table_model_row_changed(model, row) if model && row
105
105
  notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
106
106
  end
107
107
  end
@@ -109,7 +109,7 @@ module Glimmer
109
109
  @last_last_cell_rows = array_deep_clone(@last_cell_rows)
110
110
  @last_cell_rows = array_deep_clone(@cell_rows)
111
111
  end.tap do |cell_rows_observer|
112
- cell_rows_observer.observe(self, :cell_rows, recursive: true)
112
+ cell_rows_observer.observe(self, :cell_rows, recursive: true, ignore_frozen: true)
113
113
  end
114
114
  end
115
115
  @cell_rows
@@ -153,7 +153,7 @@ module Glimmer
153
153
  new_value = new_value.to_a if new_value.is_a?(Enumerator)
154
154
  if model_binding.binding_options[:column_attributes] || (!new_value.empty? && !new_value.first.is_a?(Array))
155
155
  @model_attribute_array_observer_registration&.deregister
156
- @model_attribute_array_observer_registration = model_attribute_observer.observe(new_value, @column_attributes)
156
+ @model_attribute_array_observer_registration = model_attribute_observer.observe(new_value, @column_attributes, ignore_frozen: true)
157
157
  model_attribute_observer.add_dependent(model_attribute_observer_registration => @model_attribute_array_observer_registration)
158
158
  end
159
159
  # TODO look if multiple notifications are happening as a result of observing array and observing model binding
@@ -310,6 +310,15 @@ module Glimmer
310
310
  @libui.tap do
311
311
  @columns.each {|column| column.respond_to?(:build_control, true) && column.send(:build_control) }
312
312
  end
313
+
314
+ if !@applied_windows_fix && OS.windows?
315
+ @applied_windows_fix = true
316
+ new_row = @columns&.select {|column| column.is_a?(Column)}&.map {|column| column.class.default_value}
317
+ if new_row
318
+ @cell_rows << new_row
319
+ @cell_rows.pop
320
+ end
321
+ end
313
322
  end
314
323
 
315
324
  def next_column_index
@@ -28,6 +28,7 @@ require 'glimmer'
28
28
  # require 'super_module'
29
29
  require 'color'
30
30
  require 'os'
31
+ require 'equalizer'
31
32
  require 'array_include_methods'
32
33
  require 'facets/hash/stringify_keys'
33
34
  require 'facets/string/underscore'
@@ -46,3 +47,8 @@ Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
46
47
  end
47
48
 
48
49
  ::LibUI.init
50
+ # begin
51
+ # PutsDebuggerer.printer = lambda { |m| puts m; $stdout.flush}
52
+ # rescue
53
+ ## No Op if puts_debuggerer is not loaded
54
+ # end
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.4.16
4
+ version: 0.4.17
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-12-06 00:00:00.000000000 Z
11
+ date: 2021-12-07 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.5.1
19
+ version: 2.5.3
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.5.1
26
+ version: 2.5.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: os
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.4.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: equalizer
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 0.0.11
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 0.0.11
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: juwelier
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -434,7 +448,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
434
448
  - !ruby/object:Gem::Version
435
449
  version: '0'
436
450
  requirements: []
437
- rubygems_version: 3.2.31
451
+ rubygems_version: 3.2.22
438
452
  signing_key:
439
453
  specification_version: 4
440
454
  summary: Glimmer DSL for LibUI