glimmer-dsl-libui 0.0.12 → 0.0.13

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: 8be478e9d224fabeac6b2d42b7ccae6f7063491c88b1ea14e90cf1665e379bdf
4
- data.tar.gz: b8b9b58fe072ec1973263ae20dbbe5407d7dceb30290420dd6734397cd850918
3
+ metadata.gz: 19ebb3b2df3f14388664e392c4fbac8b121c6adf5638e78ddf308c7455c76c02
4
+ data.tar.gz: a631ed4518643c2d05ff39568f3fad815aa8729b01e1ee45ace9162bc9cf93be
5
5
  SHA512:
6
- metadata.gz: 534bf3ffa94019746c5a1291af5d8a676766221ea299e627cbb38dd1e3814f941688b8cf0182f243b942e73180f2f642c93598ca4d03a3a2df36cc249459316a
7
- data.tar.gz: 3d6a77dcaffdedc6149d2efdb05df1e01f6499114054d5d43f83d576abeed0791d7cc6138335087fbfbd4d29bd481b1c016e71fe4c40af963218fd6e5227b3be
6
+ metadata.gz: 9e0fccb89ce28c472c65cabc9ff1a6044cb19c3277e960e726ea7f642ccc2861f12b6c4ec1d31a562f7d05ce64a92dcb5696a544b9dd4a2ebad25e2cd82dd61b
7
+ data.tar.gz: 4429a478c94b4105c079ddcda93b247271bae083a5b6c3b91e9c76c895a3273b27fced8d37262555b5139a0a19c98e63224eee3eb9ac44d89d379db151fa72ae
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.13
4
+
5
+ - Support examples/date_time_picker.rb
6
+ - Support `date_time_picker`, `date_picker`, and `time_picker` controls having `time`/`time=`/`set_time` property
7
+
3
8
  ## 0.0.12
4
9
 
5
10
  - Have examples/meta_example.rb allow code editing to enable experimentation and learning
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.12
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.13
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.12](#-glimmer-dsl-for-libui-0012)
46
+ - [Glimmer DSL for LibUI 0.0.13](#-glimmer-dsl-for-libui-0013)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -65,6 +65,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
65
65
  - [Control Gallery](#control-gallery)
66
66
  - [Font Button](#font-button)
67
67
  - [Color Button](#color-button)
68
+ - [Date Time Picker](#date-time-picker)
68
69
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
69
70
  - [Help](#help)
70
71
  - [Issues](#issues)
@@ -152,7 +153,7 @@ gem install glimmer-dsl-libui
152
153
  Or install via Bundler `Gemfile`:
153
154
 
154
155
  ```ruby
155
- gem 'glimmer-dsl-libui', '~> 0.0.12'
156
+ gem 'glimmer-dsl-libui', '~> 0.0.13'
156
157
  ```
157
158
 
158
159
  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.
@@ -186,7 +187,7 @@ Any control returned by a [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) keyword d
186
187
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
187
188
 
188
189
  ```ruby
189
- w = window('hello world', 300, 200, 1)
190
+ w = window('hello world')
190
191
  puts w.title # => hello world
191
192
  w.title = 'howdy'
192
193
  puts w.title # => howdy
@@ -199,7 +200,7 @@ Controls are wrapped as Ruby proxy objects, having a `#libui` method to obtain t
199
200
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
200
201
 
201
202
  ```ruby
202
- w = window('hello world', 300, 200, 1) # => #<Glimmer::LibUI::WindowProxy:0x00007fde4ea39fb0
203
+ w = window('hello world') # => #<Glimmer::LibUI::WindowProxy:0x00007fde4ea39fb0
203
204
  w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
204
205
  ```
205
206
 
@@ -212,8 +213,8 @@ Control(Args) | Properties | Listeners
212
213
  `checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
213
214
  `combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
214
215
  `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`
215
- `date_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
216
- `date_time_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
216
+ `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`
217
+ `date_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`
217
218
  `editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
218
219
  `entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
219
220
  `font_button` | `font` [read-only] (`Hash` of keys: `:family`, `:size`, `:weight`, `:italic`, `:stretch`), `family` as `String`, `size` as `Float`, `weight` as `Integer`, `italic` as `Integer`, `stretch` as `Integer` | `on_changed`
@@ -235,7 +236,7 @@ Control(Args) | Properties | Listeners
235
236
  `spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
236
237
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
237
238
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
238
- `time_picker` | `time` (`LibUI::FFI::TM`) | `on_changed`
239
+ `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`
239
240
  `vertical_box` | `padded` (Boolean) | None
240
241
  `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`
241
242
 
@@ -284,6 +285,7 @@ Control(Args) | Properties | Listeners
284
285
  - On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
285
286
  - When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
286
287
  - When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
288
+ - For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
287
289
 
288
290
  ### Original API
289
291
 
@@ -1465,8 +1467,6 @@ Linux
1465
1467
  New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1466
1468
 
1467
1469
  ```ruby
1468
- # frozen_string_literal: true
1469
-
1470
1470
  require 'glimmer-dsl-libui'
1471
1471
 
1472
1472
  include Glimmer
@@ -1481,6 +1481,96 @@ window('color button', 230) {
1481
1481
  }.show
1482
1482
  ```
1483
1483
 
1484
+ ### Date Time Picker
1485
+
1486
+ [examples/date_time_picker.rb](examples/date_time_picker.rb)
1487
+
1488
+ Run with this command from the root of the project if you cloned the project:
1489
+
1490
+ ```
1491
+ ruby -r './lib/glimmer-dsl-libui' examples/date_time_picker.rb
1492
+ ```
1493
+
1494
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
1495
+
1496
+ ```
1497
+ ruby -r glimmer-dsl-libui -e "require 'examples/date_time_picker'"
1498
+ ```
1499
+
1500
+ Mac
1501
+
1502
+ ![glimmer-dsl-libui-mac-date-time-picker.png](images/glimmer-dsl-libui-mac-date-time-picker.png)
1503
+
1504
+ Linux
1505
+
1506
+ ![glimmer-dsl-libui-linux-date-time-picker.png](images/glimmer-dsl-libui-linux-date-time-picker.png)
1507
+
1508
+ [LibUI](https://github.com/kojix2/LibUI) Original Version:
1509
+
1510
+ ```ruby
1511
+ require 'libui'
1512
+
1513
+ UI = LibUI
1514
+
1515
+ UI.init
1516
+
1517
+ vbox = UI.new_vertical_box
1518
+
1519
+ date_time_picker = UI.new_date_time_picker
1520
+
1521
+ time = UI::FFI::TM.malloc
1522
+
1523
+ UI.date_time_picker_on_changed(date_time_picker) do
1524
+ UI.date_time_picker_time(date_time_picker, time)
1525
+ p sec: time.tm_sec,
1526
+ min: time.tm_min,
1527
+ hour: time.tm_hour,
1528
+ mday: time.tm_mday,
1529
+ mon: time.tm_mon,
1530
+ year: time.tm_year,
1531
+ wday: time.tm_wday,
1532
+ yday: time.tm_yday,
1533
+ isdst: time.tm_isdst
1534
+ end
1535
+ UI.box_append(vbox, date_time_picker, 1)
1536
+
1537
+ main_window = UI.new_window('Date Time Pickers', 300, 200, 1)
1538
+ UI.window_on_closing(main_window) do
1539
+ puts 'Bye Bye'
1540
+ UI.control_destroy(main_window)
1541
+ UI.quit
1542
+ 0
1543
+ end
1544
+ UI.window_set_child(main_window, vbox)
1545
+ UI.control_show(main_window)
1546
+
1547
+ UI.main
1548
+ UI.quit
1549
+ ```
1550
+
1551
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
1552
+
1553
+ ```ruby
1554
+ require 'glimmer-dsl-libui'
1555
+
1556
+ include Glimmer
1557
+
1558
+ window('Date Time Pickers', 300, 200) {
1559
+ vertical_box {
1560
+ date_time_picker { |dtp|
1561
+ on_changed do
1562
+ time = dtp.time
1563
+ p time
1564
+ end
1565
+ }
1566
+ }
1567
+
1568
+ on_closing do
1569
+ puts 'Bye Bye'
1570
+ end
1571
+ }.show
1572
+ ```
1573
+
1484
1574
  ## Contributing to glimmer-dsl-libui
1485
1575
 
1486
1576
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.13
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ window('Date Time Pickers', 300, 200) {
8
+ vertical_box {
9
+ date_time_picker { |dtp|
10
+ on_changed do
11
+ time = dtp.time
12
+ p time
13
+ end
14
+ }
15
+ }
16
+
17
+ on_closing do
18
+ puts 'Bye Bye'
19
+ end
20
+ }.show
Binary file
@@ -27,6 +27,13 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class DatePickerProxy < DateTimePickerProxy
30
+ def time(value = nil)
31
+ if value.nil?
32
+ super.slice(:mday, :mon, :year, :wday, :yday)
33
+ else
34
+ super
35
+ end
36
+ end
30
37
  end
31
38
  end
32
39
  end
@@ -30,6 +30,39 @@ module Glimmer
30
30
  def libui_api_keyword
31
31
  'date_time_picker'
32
32
  end
33
+
34
+ def time(value = nil)
35
+ @time ||= ::LibUI::FFI::TM.malloc
36
+ ::LibUI.date_time_picker_time(@libui, @time)
37
+ if value.nil?
38
+ {
39
+ sec: @time.tm_sec,
40
+ min: @time.tm_min,
41
+ hour: @time.tm_hour,
42
+ mday: @time.tm_mday,
43
+ mon: @time.tm_mon + 1,
44
+ year: @time.tm_year + 1900,
45
+ wday: @time.tm_wday + 1,
46
+ yday: @time.tm_yday + 1,
47
+ dst: @time.tm_isdst == 1
48
+ }
49
+ else
50
+ @time.tm_sec = value[:sec] unless value[:sec].nil?
51
+ @time.tm_min = value[:min] unless value[:min].nil?
52
+ @time.tm_hour = value[:hour] unless value[:hour].nil?
53
+ @time.tm_mday = value[:mday] unless value[:mday].nil?
54
+ @time.tm_mon = value[:mon] - 1 unless value[:mon].nil?
55
+ @time.tm_year = value[:year] - 1900 unless value[:year].nil?
56
+ ::LibUI.date_time_picker_set_time(@libui, @time)
57
+ end
58
+ end
59
+ alias set_time time
60
+ alias time= time
61
+
62
+ def destroy
63
+ Fiddle.free @time unless @time.nil?
64
+ super
65
+ end
33
66
  end
34
67
  end
35
68
  end
@@ -27,6 +27,13 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class TimePickerProxy < DateTimePickerProxy
30
+ def time(value = nil)
31
+ if value.nil?
32
+ super.slice(:sec, :min, :hour)
33
+ else
34
+ super
35
+ end
36
+ end
30
37
  end
31
38
  end
32
39
  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.0.12
4
+ version: 0.0.13
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-21 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -186,6 +186,7 @@ files:
186
186
  - examples/basic_window2.rb
187
187
  - examples/color_button.rb
188
188
  - examples/control_gallery.rb
189
+ - examples/date_time_picker.rb
189
190
  - examples/font_button.rb
190
191
  - examples/meta_example.rb
191
192
  - examples/midi_player.rb