glimmer-dsl-libui 0.4.11 → 0.4.12
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 +10 -0
- data/README.md +366 -14
- data/VERSION +1 -1
- data/examples/basic_table_color.rb +104 -26
- data/examples/basic_table_color2.rb +2 -14
- data/examples/basic_table_color3.rb +37 -0
- data/examples/basic_table_image.rb +1 -1
- data/examples/basic_table_image2.rb +2 -14
- data/examples/basic_table_image3.rb +44 -0
- data/examples/basic_table_image_text.rb +1 -2
- data/examples/basic_table_image_text2.rb +2 -13
- data/examples/basic_table_image_text3.rb +44 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +4 -0
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +8 -6
- data/lib/glimmer/libui.rb +2 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49e65f2fefc1a5ef7d91c52bee0257bc03bd2ddd989d560b8887bfa9b24a3c5
|
4
|
+
data.tar.gz: c89fd384832f204d9f2edfb3faa99e526c0541817515286333dcdc89f9cb0ef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c55ae21fadef21af8a3fbf36a20e08b5454a9ab9bd9bad4c2f3ac1097b2684e675c593187e8b4c8a87596e2ca8a354c71846a80452a8e9c75c01aca811af9ca
|
7
|
+
data.tar.gz: 91616b1ffa09f0d92d807c2f1e25edf4b0e5145ec68e73dbc2b1fbf3f3f82f25a44613d9e7e67129c12751f6085fac68ae7ae6fc7a633c58404b73a30f0caade
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.12
|
4
|
+
|
5
|
+
- Support `table` data-binding to model rows when utilizing dual-columns or triple-columns (e.g. columns having color and/or a checkbox in addition to text)
|
6
|
+
- Support passing `table` `image`/`image_text` `cell_rows` `image` data as file path/image args directly (without using `image` keyword)
|
7
|
+
- Add examples/basic_table_color.rb version that data-binds to model rows instead of raw data
|
8
|
+
- Simplify examples/basic_table_color.rb to pass image data as file-path/width/height arguments directly
|
9
|
+
- Simplify examples/basic_table_image.rb to pass image data as file url directly
|
10
|
+
- Simplify examples/basic_table_image_text.rb to pass image data as file url directly
|
11
|
+
- Fix issue with hex color support for colors starting with `'#'`
|
12
|
+
|
3
13
|
## 0.4.11
|
4
14
|
|
5
15
|
- Support `table` `cell_rows` explicit bidirectional data-binding (with `<=>` sign)
|
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.
|
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.12
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -356,6 +356,11 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
356
356
|
- [Custom Keywords](#custom-keywords)
|
357
357
|
- [Observer Pattern](#observer-pattern)
|
358
358
|
- [Data-Binding](#data-binding)
|
359
|
+
- [Bidirectional (Two-Way) Data-Binding](#bidirectional-two-way-data-binding)
|
360
|
+
- [Table Data-Binding](#table-data-binding)
|
361
|
+
- [Unidirectional (One-Way) Data-Binding](#unidirectional-one-way-data-binding)
|
362
|
+
- [Data-Binding API](#data-binding-api)
|
363
|
+
- [Data-Binding Gotchas](#data-binding-gotchas)
|
359
364
|
- [API Gotchas](#api-gotchas)
|
360
365
|
- [Original API](#original-api)
|
361
366
|
- [Packaging](#packaging)
|
@@ -495,7 +500,7 @@ gem install glimmer-dsl-libui
|
|
495
500
|
Or install via Bundler `Gemfile`:
|
496
501
|
|
497
502
|
```ruby
|
498
|
-
gem 'glimmer-dsl-libui', '~> 0.4.
|
503
|
+
gem 'glimmer-dsl-libui', '~> 0.4.12'
|
499
504
|
```
|
500
505
|
|
501
506
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -848,7 +853,9 @@ window('Contacts', 600, 600) { |w|
|
|
848
853
|
}.show
|
849
854
|
```
|
850
855
|
|
851
|
-
|
856
|
+
Mac | Windows | Linux
|
857
|
+
----|---------|------
|
858
|
+
 |  | 
|
852
859
|
|
853
860
|
Learn more by checking out [examples](#examples).
|
854
861
|
|
@@ -1502,6 +1509,8 @@ Data-binding supports utilizing the [MVP (Model View Presenter)](https://en.wiki
|
|
1502
1509
|
|
1503
1510
|

|
1504
1511
|
|
1512
|
+
#### Bidirectional (Two-Way) Data-Binding
|
1513
|
+
|
1505
1514
|
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) supports bidirectional (two-way) data-binding of the following controls/properties via the `<=>` operator (indicating data is moving in both directions between View and Model):
|
1506
1515
|
- `checkbox`: `checked`
|
1507
1516
|
- `check_menu_item`: `checked`
|
@@ -1542,6 +1551,162 @@ entry {
|
|
1542
1551
|
|
1543
1552
|
That is data-binding `entered_text` attribute on `self` to `entry` `text` property and printing text after write to the model.
|
1544
1553
|
|
1554
|
+
##### Table Data-Binding
|
1555
|
+
|
1556
|
+
One note about `table` `cell_rows` data-binding is that it works with either:
|
1557
|
+
- Raw data `Array` (rows) of `Array`s (column cells)
|
1558
|
+
- Model `Array` (rows) of objects having attributes (column cells) matching the underscored names of `table` columns by convention. Model attribute names can be overridden when needed by passing an `Array` enumerating all mapped model attributes in the order of `table` columns or alternatively a `Hash` mapping only the column names that have model attribute names different from their table column underscored version.
|
1559
|
+
|
1560
|
+
Example of `table` implicit data-binding of `cell_rows` to raw data `Array` of `Array`s (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1561
|
+
|
1562
|
+
```ruby
|
1563
|
+
require 'glimmer-dsl-libui'
|
1564
|
+
|
1565
|
+
include Glimmer
|
1566
|
+
|
1567
|
+
data = [
|
1568
|
+
['Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO'],
|
1569
|
+
['Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA'],
|
1570
|
+
['Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL'],
|
1571
|
+
['Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA'],
|
1572
|
+
['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'],
|
1573
|
+
]
|
1574
|
+
|
1575
|
+
window('Contacts', 600, 600) {
|
1576
|
+
table {
|
1577
|
+
text_column('Name')
|
1578
|
+
text_column('Email')
|
1579
|
+
text_column('Phone')
|
1580
|
+
text_column('City')
|
1581
|
+
text_column('State')
|
1582
|
+
|
1583
|
+
cell_rows data
|
1584
|
+
}
|
1585
|
+
}.show
|
1586
|
+
```
|
1587
|
+
|
1588
|
+
Example of `table` explicit data-binding of `cell_rows` to Model `Array` (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1589
|
+
|
1590
|
+
```ruby
|
1591
|
+
require 'glimmer-dsl-libui'
|
1592
|
+
|
1593
|
+
class SomeTable
|
1594
|
+
Contact = Struct.new(:name, :email, :phone, :city, :state)
|
1595
|
+
|
1596
|
+
include Glimmer
|
1597
|
+
|
1598
|
+
attr_accessor :contacts
|
1599
|
+
|
1600
|
+
def initialize
|
1601
|
+
@contacts = [
|
1602
|
+
Contact.new('Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO'),
|
1603
|
+
Contact.new('Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA'),
|
1604
|
+
Contact.new('Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL'),
|
1605
|
+
Contact.new('Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA'),
|
1606
|
+
Contact.new('Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'),
|
1607
|
+
]
|
1608
|
+
end
|
1609
|
+
|
1610
|
+
def launch
|
1611
|
+
window('Contacts', 600, 200) {
|
1612
|
+
table {
|
1613
|
+
text_column('Name')
|
1614
|
+
text_column('Email')
|
1615
|
+
text_column('Phone')
|
1616
|
+
text_column('City')
|
1617
|
+
text_column('State')
|
1618
|
+
|
1619
|
+
cell_rows <=> [self, :contacts] # explicit data-binding to Model Array auto-inferring model attribute names from underscored table column names by convention
|
1620
|
+
}
|
1621
|
+
}.show
|
1622
|
+
end
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
SomeTable.new.launch
|
1626
|
+
```
|
1627
|
+
|
1628
|
+
Example of `table` explicit data-binding of `cell_rows` to Model `Array` with `column_attributes` `Hash` mapping for custom column names (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1629
|
+
|
1630
|
+
```ruby
|
1631
|
+
require 'glimmer-dsl-libui'
|
1632
|
+
|
1633
|
+
class SomeTable
|
1634
|
+
Contact = Struct.new(:name, :email, :phone, :city, :state)
|
1635
|
+
|
1636
|
+
include Glimmer
|
1637
|
+
|
1638
|
+
attr_accessor :contacts
|
1639
|
+
|
1640
|
+
def initialize
|
1641
|
+
@contacts = [
|
1642
|
+
Contact.new('Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO'),
|
1643
|
+
Contact.new('Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA'),
|
1644
|
+
Contact.new('Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL'),
|
1645
|
+
Contact.new('Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA'),
|
1646
|
+
Contact.new('Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'),
|
1647
|
+
]
|
1648
|
+
end
|
1649
|
+
|
1650
|
+
def launch
|
1651
|
+
window('Contacts', 600, 200) {
|
1652
|
+
table {
|
1653
|
+
text_column('Name')
|
1654
|
+
text_column('Email')
|
1655
|
+
text_column('Phone')
|
1656
|
+
text_column('City/Town')
|
1657
|
+
text_column('State/Province')
|
1658
|
+
|
1659
|
+
cell_rows <=> [self, :contacts, column_attributes: {'City/Town' => :city, 'State/Province' => :state}]
|
1660
|
+
}
|
1661
|
+
}.show
|
1662
|
+
end
|
1663
|
+
end
|
1664
|
+
|
1665
|
+
SomeTable.new.launch
|
1666
|
+
```
|
1667
|
+
|
1668
|
+
Example of `table` explicit data-binding of `cell_rows` to Model `Array` with complete `column_attributes` `Array` mapping (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1669
|
+
|
1670
|
+
```ruby
|
1671
|
+
require 'glimmer-dsl-libui'
|
1672
|
+
|
1673
|
+
class SomeTable
|
1674
|
+
Contact = Struct.new(:name, :email, :phone, :city, :state)
|
1675
|
+
|
1676
|
+
include Glimmer
|
1677
|
+
|
1678
|
+
attr_accessor :contacts
|
1679
|
+
|
1680
|
+
def initialize
|
1681
|
+
@contacts = [
|
1682
|
+
Contact.new('Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO'),
|
1683
|
+
Contact.new('Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA'),
|
1684
|
+
Contact.new('Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL'),
|
1685
|
+
Contact.new('Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA'),
|
1686
|
+
Contact.new('Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA'),
|
1687
|
+
]
|
1688
|
+
end
|
1689
|
+
|
1690
|
+
def launch
|
1691
|
+
window('Contacts', 600, 200) {
|
1692
|
+
table {
|
1693
|
+
text_column('Full Name')
|
1694
|
+
text_column('Email Address')
|
1695
|
+
text_column('Phone Number')
|
1696
|
+
text_column('City or Town')
|
1697
|
+
text_column('State or Province')
|
1698
|
+
|
1699
|
+
cell_rows <=> [self, :contacts, column_attributes: [:name, :email, :phone, :city, :state]]
|
1700
|
+
}
|
1701
|
+
}.show
|
1702
|
+
end
|
1703
|
+
end
|
1704
|
+
|
1705
|
+
SomeTable.new.launch
|
1706
|
+
```
|
1707
|
+
|
1708
|
+
#### Unidirectional (One-Way) Data-Binding
|
1709
|
+
|
1545
1710
|
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) supports unidirectional (one-way) data-binding of any control/shape/attributed-string property via the `<=` operator (indicating data is moving from the right side, which is the Model, to the left side, which is the GUI View object).
|
1546
1711
|
|
1547
1712
|
Example of unidirectional data-binding:
|
@@ -1564,6 +1729,8 @@ window {
|
|
1564
1729
|
|
1565
1730
|
That is data-binding the `window` `title` property to the `score` attribute of a `@game`, but converting on read from the Model to a `String`.
|
1566
1731
|
|
1732
|
+
#### Data-Binding API
|
1733
|
+
|
1567
1734
|
To summarize the data-binding API:
|
1568
1735
|
- `view_property <=> [model, attribute, *read_or_write_options]`: Bidirectional (two-way) data-binding to Model attribute accessor
|
1569
1736
|
- `view_property <= [model, attribute, *read_only_options]`: Unidirectional (one-way) data-binding to Model attribute reader
|
@@ -1594,12 +1761,13 @@ entry {
|
|
1594
1761
|
}
|
1595
1762
|
```
|
1596
1763
|
|
1597
|
-
|
1764
|
+
Learn more from data-binding usage in [Login](#login) (4 data-binding versions), [Basic Entry](#basic-entry), [Form](#form), [Form Table](#form-table) (5 data-binding versions), [Method-Based Custom Keyword](#method-based-custom-keyword), [Snake](#snake) and [Tic Tac Toe](#tic_tac_toe) examples.
|
1765
|
+
|
1766
|
+
#### Data-Binding Gotchas
|
1767
|
+
|
1598
1768
|
- 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)
|
1599
1769
|
- 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.
|
1600
1770
|
|
1601
|
-
Learn more from data-binding usage in [Login](#login) (4 data-binding versions), [Basic Entry](#basic-entry), [Form](#form), [Form Table](#form-table), [Method-Based Custom Keyword](#method-based-custom-keyword), [Snake](#snake) and [Tic Tac Toe](#tic_tac_toe) examples.
|
1602
|
-
|
1603
1771
|
### API Gotchas
|
1604
1772
|
|
1605
1773
|
- There is no proper way to destroy `grid` children due to [libui](https://github.com/andlabs/libui) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`).
|
@@ -2925,7 +3093,44 @@ UI.main
|
|
2925
3093
|
UI.quit
|
2926
3094
|
```
|
2927
3095
|
|
2928
|
-
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3096
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (passing file url as image):
|
3097
|
+
|
3098
|
+
```ruby
|
3099
|
+
# frozen_string_literal: true
|
3100
|
+
|
3101
|
+
# NOTE:
|
3102
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
3103
|
+
|
3104
|
+
require 'glimmer-dsl-libui'
|
3105
|
+
|
3106
|
+
include Glimmer
|
3107
|
+
|
3108
|
+
IMAGE_ROWS = []
|
3109
|
+
|
3110
|
+
50.times do |i|
|
3111
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
3112
|
+
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
3113
|
+
IMAGE_ROWS << [url] # array of one column cell
|
3114
|
+
rescue StandardError => e
|
3115
|
+
warn url, e.message
|
3116
|
+
end
|
3117
|
+
|
3118
|
+
window('The Red Turtle', 310, 350, false) {
|
3119
|
+
horizontal_box {
|
3120
|
+
table {
|
3121
|
+
image_column('www.ghibli.jp/works/red-turtle')
|
3122
|
+
|
3123
|
+
cell_rows IMAGE_ROWS
|
3124
|
+
}
|
3125
|
+
}
|
3126
|
+
|
3127
|
+
on_closing do
|
3128
|
+
puts 'Bye Bye'
|
3129
|
+
end
|
3130
|
+
}.show
|
3131
|
+
```
|
3132
|
+
|
3133
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (automatic construction of `image`):
|
2929
3134
|
|
2930
3135
|
```ruby
|
2931
3136
|
# NOTE:
|
@@ -2960,7 +3165,7 @@ window('The Red Turtle', 310, 350, false) {
|
|
2960
3165
|
}.show
|
2961
3166
|
```
|
2962
3167
|
|
2963
|
-
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version
|
3168
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (manual construction of `image` from `image_part`):
|
2964
3169
|
|
2965
3170
|
```ruby
|
2966
3171
|
# NOTE:
|
@@ -3028,7 +3233,44 @@ Mac | Windows | Linux
|
|
3028
3233
|
----|---------|------
|
3029
3234
|
 |  | 
|
3030
3235
|
|
3031
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3236
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (passing file url as image):
|
3237
|
+
|
3238
|
+
```ruby
|
3239
|
+
# frozen_string_literal: true
|
3240
|
+
|
3241
|
+
# NOTE:
|
3242
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
3243
|
+
|
3244
|
+
require 'glimmer-dsl-libui'
|
3245
|
+
|
3246
|
+
include Glimmer
|
3247
|
+
|
3248
|
+
IMAGE_ROWS = []
|
3249
|
+
|
3250
|
+
5.times do |i|
|
3251
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
3252
|
+
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
3253
|
+
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
3254
|
+
IMAGE_ROWS << [[url, text], [url, text]] # cell values are dual-element arrays
|
3255
|
+
rescue StandardError => e
|
3256
|
+
warn url, e.message
|
3257
|
+
end
|
3258
|
+
|
3259
|
+
window('The Red Turtle', 670, 350) {
|
3260
|
+
horizontal_box {
|
3261
|
+
table {
|
3262
|
+
image_text_column('image/number')
|
3263
|
+
image_text_column('image/number (editable)') {
|
3264
|
+
editable true
|
3265
|
+
}
|
3266
|
+
|
3267
|
+
cell_rows IMAGE_ROWS
|
3268
|
+
}
|
3269
|
+
}
|
3270
|
+
}.show
|
3271
|
+
```
|
3272
|
+
|
3273
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (automatic construction of `image`):
|
3032
3274
|
|
3033
3275
|
```ruby
|
3034
3276
|
# NOTE:
|
@@ -3402,16 +3644,126 @@ Mac | Windows | Linux
|
|
3402
3644
|
----|---------|------
|
3403
3645
|
 |  | 
|
3404
3646
|
|
3405
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3647
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version (with explicit [data-binding](#data-binding) to model rows using a presenter):
|
3406
3648
|
|
3407
3649
|
```ruby
|
3408
|
-
|
3650
|
+
require 'glimmer-dsl-libui'
|
3651
|
+
|
3652
|
+
class BasicTableColor
|
3653
|
+
Animal = Struct.new(:name, :sound, :mammal)
|
3654
|
+
|
3655
|
+
class AnimalPresenter < Animal
|
3656
|
+
def name_color
|
3657
|
+
color = case name
|
3658
|
+
when 'cat'
|
3659
|
+
:red
|
3660
|
+
when 'dog'
|
3661
|
+
:yellow
|
3662
|
+
when 'chicken'
|
3663
|
+
:beige
|
3664
|
+
when 'horse'
|
3665
|
+
:purple
|
3666
|
+
when 'cow'
|
3667
|
+
:gray
|
3668
|
+
end
|
3669
|
+
[name, color]
|
3670
|
+
end
|
3671
|
+
|
3672
|
+
def sound_color
|
3673
|
+
color = case name
|
3674
|
+
when 'cat', 'chicken', 'cow'
|
3675
|
+
:blue
|
3676
|
+
when 'dog', 'horse'
|
3677
|
+
{r: 240, g: 32, b: 32}
|
3678
|
+
end
|
3679
|
+
[sound, color]
|
3680
|
+
end
|
3681
|
+
|
3682
|
+
def mammal_description_color
|
3683
|
+
color = case name
|
3684
|
+
when 'cat', 'dog', 'horse', 'cow'
|
3685
|
+
:green
|
3686
|
+
when 'chicken'
|
3687
|
+
:red
|
3688
|
+
end
|
3689
|
+
[mammal, 'mammal', color]
|
3690
|
+
end
|
3691
|
+
|
3692
|
+
def image_description_color
|
3693
|
+
color = case name
|
3694
|
+
when 'cat', 'dog', 'horse'
|
3695
|
+
:dark_blue
|
3696
|
+
when 'chicken'
|
3697
|
+
:beige
|
3698
|
+
when 'cow'
|
3699
|
+
:brown
|
3700
|
+
end
|
3701
|
+
[img, 'Glimmer', color]
|
3702
|
+
end
|
3703
|
+
|
3704
|
+
def img
|
3705
|
+
# scale image to 24x24 (can be passed as file path String only instead of Array to avoid scaling)
|
3706
|
+
[File.expand_path('../icons/glimmer.png', __dir__), 24, 24]
|
3707
|
+
end
|
3708
|
+
|
3709
|
+
def background_color
|
3710
|
+
case name
|
3711
|
+
when 'cat'
|
3712
|
+
{r: 255, g: 120, b: 0, a: 0.5}
|
3713
|
+
when 'dog'
|
3714
|
+
:skyblue
|
3715
|
+
when 'chicken'
|
3716
|
+
{r: 5, g: 120, b: 110}
|
3717
|
+
when 'horse'
|
3718
|
+
'#13a1fb'
|
3719
|
+
when 'cow'
|
3720
|
+
0x12ff02
|
3721
|
+
end
|
3722
|
+
end
|
3723
|
+
end
|
3724
|
+
|
3725
|
+
include Glimmer
|
3726
|
+
|
3727
|
+
attr_accessor :animals
|
3728
|
+
|
3729
|
+
def initialize
|
3730
|
+
@animals = [
|
3731
|
+
AnimalPresenter.new('cat', 'meow', true),
|
3732
|
+
AnimalPresenter.new('dog', 'woof', true),
|
3733
|
+
AnimalPresenter.new('chicken', 'cock-a-doodle-doo', false),
|
3734
|
+
AnimalPresenter.new('horse', 'neigh', true),
|
3735
|
+
AnimalPresenter.new('cow', 'moo', true),
|
3736
|
+
]
|
3737
|
+
end
|
3738
|
+
|
3739
|
+
def launch
|
3740
|
+
window('Animals', 500, 200) {
|
3741
|
+
horizontal_box {
|
3742
|
+
table {
|
3743
|
+
text_color_column('Animal')
|
3744
|
+
text_color_column('Sound')
|
3745
|
+
checkbox_text_color_column('Description')
|
3746
|
+
image_text_color_column('GUI')
|
3747
|
+
background_color_column # must always be the last column and always expects data-binding model attribute `background_color` when binding to Array of models
|
3748
|
+
|
3749
|
+
cell_rows <= [self, :animals, column_attributes: {'Animal' => :name_color, 'Sound' => :sound_color, 'Description' => :mammal_description_color, 'GUI' => :image_description_color}]
|
3750
|
+
}
|
3751
|
+
}
|
3752
|
+
}.show
|
3753
|
+
end
|
3754
|
+
end
|
3755
|
+
|
3756
|
+
BasicTableColor.new.launch
|
3757
|
+
```
|
3409
3758
|
|
3759
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (with implicit [data-binding](#data-binding) to raw data rows):
|
3760
|
+
|
3761
|
+
```ruby
|
3410
3762
|
require 'glimmer-dsl-libui'
|
3411
3763
|
|
3412
3764
|
include Glimmer
|
3413
3765
|
|
3414
|
-
img =
|
3766
|
+
img = [File.expand_path('../icons/glimmer.png', __dir__), 24, 24] # scales image to 24x24 (can be passed as file path String only instead of Array to avoid scaling)
|
3415
3767
|
|
3416
3768
|
data = [
|
3417
3769
|
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
@@ -3436,7 +3788,7 @@ window('Animals', 500, 200) {
|
|
3436
3788
|
}.show
|
3437
3789
|
```
|
3438
3790
|
|
3439
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version
|
3791
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (with implicit [data-binding](#data-binding) to raw data rows and manual construction of [libui](https://github.com/andlabs/libui) `image` from `image_part`):
|
3440
3792
|
|
3441
3793
|
```ruby
|
3442
3794
|
require 'glimmer-dsl-libui'
|
@@ -6536,7 +6888,7 @@ class FormTable
|
|
6536
6888
|
text_column('State')
|
6537
6889
|
|
6538
6890
|
editable true
|
6539
|
-
cell_rows <=> [self, :contacts] # explicit data-binding to Model Array
|
6891
|
+
cell_rows <=> [self, :contacts] # explicit data-binding to Model Array auto-inferring model attribute names from underscored table column names by convention
|
6540
6892
|
|
6541
6893
|
on_changed do |row, type, row_data|
|
6542
6894
|
puts "Row #{row} #{type}: #{row_data}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.12
|
@@ -1,29 +1,107 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
3
|
+
class BasicTableColor
|
4
|
+
Animal = Struct.new(:name, :sound, :mammal)
|
5
|
+
|
6
|
+
class AnimalPresenter < Animal
|
7
|
+
def name_color
|
8
|
+
color = case name
|
9
|
+
when 'cat'
|
10
|
+
:red
|
11
|
+
when 'dog'
|
12
|
+
:yellow
|
13
|
+
when 'chicken'
|
14
|
+
:beige
|
15
|
+
when 'horse'
|
16
|
+
:purple
|
17
|
+
when 'cow'
|
18
|
+
:gray
|
19
|
+
end
|
20
|
+
[name, color]
|
21
|
+
end
|
22
|
+
|
23
|
+
def sound_color
|
24
|
+
color = case name
|
25
|
+
when 'cat', 'chicken', 'cow'
|
26
|
+
:blue
|
27
|
+
when 'dog', 'horse'
|
28
|
+
{r: 240, g: 32, b: 32}
|
29
|
+
end
|
30
|
+
[sound, color]
|
31
|
+
end
|
32
|
+
|
33
|
+
def mammal_description_color
|
34
|
+
color = case name
|
35
|
+
when 'cat', 'dog', 'horse', 'cow'
|
36
|
+
:green
|
37
|
+
when 'chicken'
|
38
|
+
:red
|
39
|
+
end
|
40
|
+
[mammal, 'mammal', color]
|
41
|
+
end
|
42
|
+
|
43
|
+
def image_description_color
|
44
|
+
color = case name
|
45
|
+
when 'cat', 'dog', 'horse'
|
46
|
+
:dark_blue
|
47
|
+
when 'chicken'
|
48
|
+
:beige
|
49
|
+
when 'cow'
|
50
|
+
:brown
|
51
|
+
end
|
52
|
+
[img, 'Glimmer', color]
|
53
|
+
end
|
54
|
+
|
55
|
+
def img
|
56
|
+
# scale image to 24x24 (can be passed as file path String only instead of Array to avoid scaling)
|
57
|
+
[File.expand_path('../icons/glimmer.png', __dir__), 24, 24]
|
58
|
+
end
|
59
|
+
|
60
|
+
def background_color
|
61
|
+
case name
|
62
|
+
when 'cat'
|
63
|
+
{r: 255, g: 120, b: 0, a: 0.5}
|
64
|
+
when 'dog'
|
65
|
+
:skyblue
|
66
|
+
when 'chicken'
|
67
|
+
{r: 5, g: 120, b: 110}
|
68
|
+
when 'horse'
|
69
|
+
'#13a1fb'
|
70
|
+
when 'cow'
|
71
|
+
0x12ff02
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
include Glimmer
|
77
|
+
|
78
|
+
attr_accessor :animals
|
79
|
+
|
80
|
+
def initialize
|
81
|
+
@animals = [
|
82
|
+
AnimalPresenter.new('cat', 'meow', true),
|
83
|
+
AnimalPresenter.new('dog', 'woof', true),
|
84
|
+
AnimalPresenter.new('chicken', 'cock-a-doodle-doo', false),
|
85
|
+
AnimalPresenter.new('horse', 'neigh', true),
|
86
|
+
AnimalPresenter.new('cow', 'moo', true),
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def launch
|
91
|
+
window('Animals', 500, 200) {
|
92
|
+
horizontal_box {
|
93
|
+
table {
|
94
|
+
text_color_column('Animal')
|
95
|
+
text_color_column('Sound')
|
96
|
+
checkbox_text_color_column('Description')
|
97
|
+
image_text_color_column('GUI')
|
98
|
+
background_color_column # must always be the last column and always expects data-binding model attribute `background_color` when binding to Array of models
|
99
|
+
|
100
|
+
cell_rows <= [self, :animals, column_attributes: {'Animal' => :name_color, 'Sound' => :sound_color, 'Description' => :mammal_description_color, 'GUI' => :image_description_color}]
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}.show
|
104
|
+
end
|
105
|
+
end
|
25
106
|
|
26
|
-
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}.show
|
107
|
+
BasicTableColor.new.launch
|
@@ -1,20 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
|
-
require 'chunky_png'
|
5
2
|
|
6
3
|
include Glimmer
|
7
4
|
|
8
|
-
|
9
|
-
canvas = ChunkyPNG::Canvas.from_io(f)
|
10
|
-
f.close
|
11
|
-
canvas.resample_nearest_neighbor!(24, 24)
|
12
|
-
data = canvas.to_rgba_stream
|
13
|
-
width = canvas.width
|
14
|
-
height = canvas.height
|
15
|
-
img = image {
|
16
|
-
image_part(data, width, height, width * 4)
|
17
|
-
}
|
5
|
+
img = [File.expand_path('../icons/glimmer.png', __dir__), 24, 24] # scales image to 24x24 (can be passed as file path String only instead of Array to avoid scaling)
|
18
6
|
|
19
7
|
data = [
|
20
8
|
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
@@ -31,7 +19,7 @@ window('Animals', 500, 200) {
|
|
31
19
|
text_color_column('Sound')
|
32
20
|
checkbox_text_color_column('Description')
|
33
21
|
image_text_color_column('GUI')
|
34
|
-
background_color_column
|
22
|
+
background_color_column # must be the last column
|
35
23
|
|
36
24
|
cell_rows data
|
37
25
|
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
require 'chunky_png'
|
3
|
+
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
f = File.open(File.expand_path('../icons/glimmer.png', __dir__))
|
7
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
8
|
+
f.close
|
9
|
+
canvas.resample_nearest_neighbor!(24, 24)
|
10
|
+
data = canvas.to_rgba_stream
|
11
|
+
width = canvas.width
|
12
|
+
height = canvas.height
|
13
|
+
img = image {
|
14
|
+
image_part(data, width, height, width * 4)
|
15
|
+
}
|
16
|
+
|
17
|
+
data = [
|
18
|
+
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
19
|
+
[['dog', :yellow] , ['woof', {r: 240, g: 32, b: 32}] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], :skyblue],
|
20
|
+
[['chicken', :beige], ['cock-a-doodle-doo', :blue] , [false, 'mammal', :red] , [img, 'Glimmer', :beige], {r: 5, g: 120, b: 110}],
|
21
|
+
[['horse', :purple] , ['neigh', {r: 240, g: 32, b: 32}], [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], '13a1fb'],
|
22
|
+
[['cow', :gray] , ['moo', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :brown], 0x12ff02]
|
23
|
+
]
|
24
|
+
|
25
|
+
window('Animals', 500, 200) {
|
26
|
+
horizontal_box {
|
27
|
+
table {
|
28
|
+
text_color_column('Animal')
|
29
|
+
text_color_column('Sound')
|
30
|
+
checkbox_text_color_column('Description')
|
31
|
+
image_text_color_column('GUI')
|
32
|
+
background_color_column('Mammal')
|
33
|
+
|
34
|
+
cell_rows data
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}.show
|
@@ -12,7 +12,7 @@ IMAGE_ROWS = []
|
|
12
12
|
50.times do |i|
|
13
13
|
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
14
14
|
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
15
|
-
IMAGE_ROWS << [
|
15
|
+
IMAGE_ROWS << [url] # array of one column cell
|
16
16
|
rescue StandardError => e
|
17
17
|
warn url, e.message
|
18
18
|
end
|
@@ -4,8 +4,6 @@
|
|
4
4
|
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
5
5
|
|
6
6
|
require 'glimmer-dsl-libui'
|
7
|
-
require 'chunky_png'
|
8
|
-
require 'open-uri'
|
9
7
|
|
10
8
|
include Glimmer
|
11
9
|
|
@@ -13,18 +11,8 @@ IMAGE_ROWS = []
|
|
13
11
|
|
14
12
|
50.times do |i|
|
15
13
|
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
16
|
-
puts "Processing Image: #{url}"
|
17
|
-
|
18
|
-
f = URI.open(url)
|
19
|
-
canvas = ChunkyPNG::Canvas.from_io(f)
|
20
|
-
f.close
|
21
|
-
data = canvas.to_rgba_stream
|
22
|
-
width = canvas.width
|
23
|
-
height = canvas.height
|
24
|
-
img = image {
|
25
|
-
image_part(data, width, height, width * 4)
|
26
|
-
}
|
27
|
-
IMAGE_ROWS << [img] # array of one column cell
|
14
|
+
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
15
|
+
IMAGE_ROWS << [image(url)] # array of one column cell
|
28
16
|
rescue StandardError => e
|
29
17
|
warn url, e.message
|
30
18
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# NOTE:
|
4
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
5
|
+
|
6
|
+
require 'glimmer-dsl-libui'
|
7
|
+
require 'chunky_png'
|
8
|
+
require 'open-uri'
|
9
|
+
|
10
|
+
include Glimmer
|
11
|
+
|
12
|
+
IMAGE_ROWS = []
|
13
|
+
|
14
|
+
50.times do |i|
|
15
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
16
|
+
puts "Processing Image: #{url}"
|
17
|
+
$stdout.flush # for Windows
|
18
|
+
f = URI.open(url)
|
19
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
20
|
+
f.close
|
21
|
+
data = canvas.to_rgba_stream
|
22
|
+
width = canvas.width
|
23
|
+
height = canvas.height
|
24
|
+
img = image {
|
25
|
+
image_part(data, width, height, width * 4)
|
26
|
+
}
|
27
|
+
IMAGE_ROWS << [img] # array of one column cell
|
28
|
+
rescue StandardError => e
|
29
|
+
warn url, e.message
|
30
|
+
end
|
31
|
+
|
32
|
+
window('The Red Turtle', 310, 350, false) {
|
33
|
+
horizontal_box {
|
34
|
+
table {
|
35
|
+
image_column('www.ghibli.jp/works/red-turtle')
|
36
|
+
|
37
|
+
cell_rows IMAGE_ROWS
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
on_closing do
|
42
|
+
puts 'Bye Bye'
|
43
|
+
end
|
44
|
+
}.show
|
@@ -13,8 +13,7 @@ IMAGE_ROWS = []
|
|
13
13
|
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
14
14
|
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
15
15
|
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
16
|
-
|
17
|
-
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
16
|
+
IMAGE_ROWS << [[url, text], [url, text]] # cell values are dual-element arrays
|
18
17
|
rescue StandardError => e
|
19
18
|
warn url, e.message
|
20
19
|
end
|
@@ -4,8 +4,6 @@
|
|
4
4
|
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
5
5
|
|
6
6
|
require 'glimmer-dsl-libui'
|
7
|
-
require 'chunky_png'
|
8
|
-
require 'open-uri'
|
9
7
|
|
10
8
|
include Glimmer
|
11
9
|
|
@@ -13,18 +11,9 @@ IMAGE_ROWS = []
|
|
13
11
|
|
14
12
|
5.times do |i|
|
15
13
|
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
16
|
-
puts "Processing Image: #{url}"
|
17
|
-
$stdout.flush # for Windows
|
18
|
-
f = URI.open(url)
|
19
|
-
canvas = ChunkyPNG::Canvas.from_io(f)
|
20
|
-
f.close
|
21
|
-
data = canvas.to_rgba_stream
|
22
|
-
width = canvas.width
|
23
|
-
height = canvas.height
|
24
|
-
img = image {
|
25
|
-
image_part(data, width, height, width * 4)
|
26
|
-
}
|
14
|
+
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
27
15
|
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
16
|
+
img = image(url)
|
28
17
|
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
29
18
|
rescue StandardError => e
|
30
19
|
warn url, e.message
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# NOTE:
|
4
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
5
|
+
|
6
|
+
require 'glimmer-dsl-libui'
|
7
|
+
require 'chunky_png'
|
8
|
+
require 'open-uri'
|
9
|
+
|
10
|
+
include Glimmer
|
11
|
+
|
12
|
+
IMAGE_ROWS = []
|
13
|
+
|
14
|
+
5.times do |i|
|
15
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
16
|
+
puts "Processing Image: #{url}"
|
17
|
+
$stdout.flush # for Windows
|
18
|
+
f = URI.open(url)
|
19
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
20
|
+
f.close
|
21
|
+
data = canvas.to_rgba_stream
|
22
|
+
width = canvas.width
|
23
|
+
height = canvas.height
|
24
|
+
img = image {
|
25
|
+
image_part(data, width, height, width * 4)
|
26
|
+
}
|
27
|
+
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
28
|
+
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
29
|
+
rescue StandardError => e
|
30
|
+
warn url, e.message
|
31
|
+
end
|
32
|
+
|
33
|
+
window('The Red Turtle', 670, 350) {
|
34
|
+
horizontal_box {
|
35
|
+
table {
|
36
|
+
image_text_column('image/number')
|
37
|
+
image_text_column('image/number (editable)') {
|
38
|
+
editable true
|
39
|
+
}
|
40
|
+
|
41
|
+
cell_rows IMAGE_ROWS
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}.show
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -145,7 +145,7 @@ module Glimmer
|
|
145
145
|
@column_attributes = model_binding.binding_options[:column_attributes]
|
146
146
|
else
|
147
147
|
column_attribute_mapping = model_binding.binding_options[:column_attributes].is_a?(Hash) ? model_binding.binding_options[:column_attributes] : {}
|
148
|
-
@column_attributes = columns.map(&:name).map {|column_name| column_attribute_mapping[column_name] || column_name.underscore}
|
148
|
+
@column_attributes = columns.select {|column| column.is_a?(Column)}.map(&:name).map {|column_name| column_attribute_mapping[column_name] || column_name.underscore}
|
149
149
|
end
|
150
150
|
model_attribute_observer = model_attribute_observer_registration = nil
|
151
151
|
model_attribute_observer = Glimmer::DataBinding::Observer.proc do
|
@@ -208,11 +208,13 @@ module Glimmer
|
|
208
208
|
when Column::TextColumnProxy, Column::ButtonColumnProxy, Column::TextColorColumnProxy, :text
|
209
209
|
::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
|
210
210
|
when Column::ImageColumnProxy, Column::ImageTextColumnProxy, Column::ImageTextColorColumnProxy
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
211
|
+
# TODO refactor to eliminate redundancy and share similar code
|
212
|
+
row = row - 1 if OS.windows? && row == cell_rows.count
|
213
|
+
img = expanded_cell_rows[row][column]
|
214
|
+
img = ControlProxy::ImageProxy.new('image', nil, img) if img.is_a?(Array)
|
215
|
+
img = ControlProxy::ImageProxy.new('image', nil, [img]) if img.is_a?(String)
|
216
|
+
img = img.respond_to?(:libui) ? img.libui : img
|
217
|
+
::LibUI.new_table_value_image(img)
|
216
218
|
when Column::CheckboxColumnProxy, Column::CheckboxTextColumnProxy, Column::CheckboxTextColorColumnProxy
|
217
219
|
::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))) || 0)
|
218
220
|
when Column::ProgressBarColumnProxy
|
data/lib/glimmer/libui.rb
CHANGED
@@ -63,7 +63,7 @@ module Glimmer
|
|
63
63
|
value[:b] = value.delete(:blue) if value[:blue]
|
64
64
|
value[:a] = value.delete(:alpha) if value[:alpha]
|
65
65
|
value
|
66
|
-
elsif value.is_a?(String) && !value.start_with?('0x') && !value.downcase.match(/^((([1-9a-f]){6})|(([1-9a-f]){3}))$/)
|
66
|
+
elsif value.is_a?(String) && !value.start_with?('0x') && !value.start_with?('#') && !value.downcase.match(/^((([1-9a-f]){6})|(([1-9a-f]){3}))$/)
|
67
67
|
color = Color::RGB.extract_colors(value).first
|
68
68
|
color.nil? ? {} : {
|
69
69
|
r: color.red,
|
@@ -79,11 +79,11 @@ module Glimmer
|
|
79
79
|
|
80
80
|
def hex_to_rgb(value)
|
81
81
|
if value.is_a?(String)
|
82
|
+
value = "0x#{value[1..-1]}" if value.start_with?('#')
|
82
83
|
if !value.start_with?('0x')
|
83
84
|
value = value.chars.map {|char| [char, char]}.flatten.join if value.length == 3
|
84
85
|
value = "0x#{value}"
|
85
86
|
end
|
86
|
-
value = "0x#{value[1..-1]}" if value.start_with?('#')
|
87
87
|
value = value.to_i(16)
|
88
88
|
end
|
89
89
|
if value.is_a?(Integer)
|
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.
|
4
|
+
version: 0.4.12
|
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-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -237,10 +237,13 @@ files:
|
|
237
237
|
- examples/basic_table_checkbox_text.rb
|
238
238
|
- examples/basic_table_color.rb
|
239
239
|
- examples/basic_table_color2.rb
|
240
|
+
- examples/basic_table_color3.rb
|
240
241
|
- examples/basic_table_image.rb
|
241
242
|
- examples/basic_table_image2.rb
|
243
|
+
- examples/basic_table_image3.rb
|
242
244
|
- examples/basic_table_image_text.rb
|
243
245
|
- examples/basic_table_image_text2.rb
|
246
|
+
- examples/basic_table_image_text3.rb
|
244
247
|
- examples/basic_table_progress_bar.rb
|
245
248
|
- examples/basic_transform.rb
|
246
249
|
- examples/basic_transform2.rb
|