glimmer-dsl-libui 0.5.16 → 0.5.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: 99ed9eb0a65da64d13717cf3f967ceadc36c4a0eed74fcbb385bd5d19c812db2
4
- data.tar.gz: f24060ff8ef38a93c1f3174d3e01102d61d2c0c8d8466b1e0d32fedc8972c9ea
3
+ metadata.gz: b837f495b6ee88ac59beb20c32f1bd3c3fe3b777a4b195d64c2958afb46cf039
4
+ data.tar.gz: 515861c59a0136a1425f7eb24a9613686595bb2e09657ec096a2a6ec3552b9cc
5
5
  SHA512:
6
- metadata.gz: def5540396a5cffc5f1271d3bb2664d008cf26db2f88207dc75bc23fa9915a2badfa45db8778e59644c99cbb0753147361556de25d118acd51e2dc211abd4bc8
7
- data.tar.gz: 30ac47a92b4439aca5f3bc244514b400f810d8a9c855f64acf924544b448647d0d573d5218bc2e515ceb7bb469978b1e3e754d74d3ff86aea0b7d7247ee0e433
6
+ metadata.gz: 5e84bd0c82fdc0c8aa5876a628e1f0ecf327e08a692ff531764f1a2f9311f24ec89998a9a4959ba65f93a0aad8e645c24bb3a14348d96282e64be2ccdeaea983
7
+ data.tar.gz: 3870d2d46189f0b81c6490d169f7fef63e782d408a7d20038b43fd1ebbf90ebac34b615c4b96514f1cf1294dae6f4b56933fe0c55430c5e9b1fd542654025c4d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.5.17
4
+
5
+ - Ensure disabling pagination buttons in `refined_table` if page is at beginning or end
6
+ - Add a "of #{page_count} pages" label after the text control in `refined_table` pagination area
7
+ - Page count ("of #{page_count} pages" label) can be shown by setting `visible_page_count: true` in `refined_table` options
8
+ - Correct initial `page` option passed to `refined_table` if out of range
9
+ - If `refined_table` `model_array` has no more than a single page of data, then hide pagination buttons
10
+
3
11
  ## 0.5.16
4
12
 
5
13
  - `refined_table` custom control that renders a `table` with filtering and pagination, thus being able to handle a large data set (e.g. 50,000)
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.5.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.5.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)
@@ -584,7 +584,7 @@ gem install glimmer-dsl-libui
584
584
  Or install via Bundler `Gemfile`:
585
585
 
586
586
  ```ruby
587
- gem 'glimmer-dsl-libui', '~> 0.5.16'
587
+ gem 'glimmer-dsl-libui', '~> 0.5.17'
588
588
  ```
589
589
 
590
590
  Test that installation worked by running the [Meta-Example](#examples):
@@ -766,7 +766,7 @@ Keyword(Args) | Properties | Listeners
766
766
  `quit_menu_item` | None | `on_clicked`
767
767
  `radio_buttons` | `selected` (`Integer`) | `on_selected`
768
768
  `rectangle(x as Numeric, y as Numeric, width as Numeric, height as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `width` (`Numeric`), `height` (`Numeric`) | None
769
- `refined_table` | (EARLY ALPHA UNSTABLE API / CHECK SOURCE CODE FOR DETAILS) | (EARLY ALPHA UNSTABLE API / CHECK SOURCE CODE FOR DETAILS)
769
+ `refined_table` | `model_array` (`Array`), `table_columns` (`Hash`), `table_editable` (Boolean), `per_page` (`Integer`), `page` (`Integer`), `visible_page_count` (Boolean) | (EARLY ALPHA UNSTABLE API / CHECK SOURCE CODE FOR DETAILS)
770
770
  `scrolling_area(width = main_window.width, height = main_window.height)` | `auto_draw_enabled` (Boolean), `size` (`Array` of `width` (`Numeric`) and `height` (`Numeric`)), `width` (`Numeric`), `height` (`Numeric`) | `on_draw(area_draw_params)`, `on_mouse_event(area_mouse_event)`, `on_mouse_down(area_mouse_event)`, `on_mouse_up(area_mouse_event)`, `on_mouse_drag_started(area_mouse_event)`, `on_mouse_dragged(area_mouse_event)`, `on_mouse_dropped(area_mouse_event)`, `on_mouse_entered`, `on_mouse_exited`, `on_key_event(area_key_event)`, `on_key_down(area_key_event)`, `on_key_up(area_key_event)`
771
771
  `search_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
772
772
  `separator_menu_item` | None | None
@@ -998,11 +998,22 @@ Learn more by checking out [examples](#examples).
998
998
 
999
999
  [EARLY ALPHA FEATURE]
1000
1000
 
1001
- `refined_table` is a custom control provided exclusively by Glimmer DSL for LibUI that includes filtering and pagination support out of the box and can handle very large amounts of data (e.g. 50,000 rows).
1001
+ `refined_table` is a custom control provided exclusively by [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui)
1002
+ that includes filtering and pagination support out of the box and can handle very large amounts of data (e.g. 50,000 rows).
1002
1003
 
1003
1004
  It is currently an early alpha feature, so please test-drive and report issues if you encounter any.
1005
+ And, please keep in mind that the API might undergo big changes.
1004
1006
 
1005
- Also, the API might undergo big changes, so please keep that in mind.
1007
+ Options (passed as kwargs hash):
1008
+
1009
+ - `model_array` (`Array`): array of models for which attributes map to table columns
1010
+ - `table_columns` (`Hash`): this maps column types to symbols (e.g. `text_column` becomes `:text`) with hash options per column
1011
+ - `table_editable` (Boolean) [default: `false`]: this indicates if all table columns are editable or not.
1012
+ - `per_page` (`Integer`)
1013
+ - `page` (`Integer`)
1014
+ - `visible_page_count` (Boolean) [default: `false`]: shows "of PAGE_COUNT pages" after page `entry` field
1015
+
1016
+ If the initial `model_array` has no more than a single page of data, then pagination buttons are hidden (but, the filter field remains).
1006
1017
 
1007
1018
  Example code:
1008
1019
 
@@ -1016,9 +1027,10 @@ refined_table(
1016
1027
  'City' => :text,
1017
1028
  'State' => :text,
1018
1029
  },
1019
- table_editable: true,
1030
+ table_editable: true, # default value is false
1020
1031
  per_page: 20, # row count per page
1021
- page: 5, # initial page
1032
+ # page: 1, # initial page is 1
1033
+ # visible_page_count: true, # page count can be shown if preferred
1022
1034
  )
1023
1035
  ```
1024
1036
 
@@ -8046,148 +8058,21 @@ class PaginatedRefinedTable
8046
8058
  include Glimmer::LibUI::Application
8047
8059
 
8048
8060
  NAMES_FIRST = %w[
8049
- Liam
8050
- Noah
8051
- William
8052
- James
8053
- Oliver
8054
- Benjamin
8055
- Elijah
8056
- Lucas
8057
- Mason
8058
- Logan
8059
- Alexander
8060
- Ethan
8061
- Jacob
8062
- Michael
8063
- Daniel
8064
- Henry
8065
- Jackson
8066
- Sebastian
8067
- Aiden
8068
- Matthew
8069
- Samuel
8070
- David
8071
- Joseph
8072
- Carter
8073
- Owen
8074
- Wyatt
8075
- John
8076
- Jack
8077
- Luke
8078
- Jayden
8079
- Dylan
8080
- Grayson
8081
- Levi
8082
- Isaac
8083
- Gabriel
8084
- Julian
8085
- Mateo
8086
- Anthony
8087
- Jaxon
8088
- Lincoln
8089
- Joshua
8090
- Christopher
8091
- Andrew
8092
- Theodore
8093
- Caleb
8094
- Ryan
8095
- Asher
8096
- Nathan
8097
- Thomas
8098
- Leo
8099
- Isaiah
8100
- Charles
8101
- Josiah
8102
- Hudson
8103
- Christian
8104
- Hunter
8105
- Connor
8106
- Eli
8107
- Ezra
8108
- Aaron
8109
- Landon
8110
- Adrian
8111
- Jonathan
8112
- Nolan
8113
- Jeremiah
8114
- Easton
8115
- Elias
8116
- Colton
8117
- Cameron
8118
- Carson
8119
- Robert
8120
- Angel
8121
- Maverick
8122
- Nicholas
8123
- Dominic
8124
- Jaxson
8125
- Greyson
8126
- Adam
8127
- Ian
8128
- Austin
8129
- Santiago
8130
- Jordan
8131
- Cooper
8132
- Brayden
8133
- Roman
8134
- Evan
8135
- Ezekiel
8136
- Xaviar
8137
- Jose
8138
- Jace
8139
- Jameson
8140
- Leonardo
8141
- Axel
8142
- Everett
8143
- Kayden
8144
- Miles
8145
- Sawyer
8146
- Jason
8147
- Emma
8148
- Olivia
8149
- Bartholomew
8150
- Corey
8151
- Danielle
8152
- Eva
8153
- Felicity
8061
+ Liam Noah William James Oliver Benjamin Elijah Lucas Mason Logan Alexander Ethan Jacob Michael Daniel Henry Jackson Sebastian
8062
+ Aiden Matthew Samuel David Joseph Carter Owen Wyatt John Jack Luke Jayden Dylan Grayson Levi Isaac Gabriel Julian Mateo
8063
+ Anthony Jaxon Lincoln Joshua Christopher Andrew Theodore Caleb Ryan Asher Nathan Thomas Leo Isaiah Charles Josiah Hudson
8064
+ Christian Hunter Connor Eli Ezra Aaron Landon Adrian Jonathan Nolan Jeremiah Easton Elias Colton Cameron Carson Robert Angel
8065
+ Maverick Nicholas Dominic Jaxson Greyson Adam Ian Austin Santiago Jordan Cooper Brayden Roman Evan Ezekiel Xaviar Jose Jace
8066
+ Jameson Leonardo Axel Everett Kayden Miles Sawyer Jason Emma Olivia Bartholomew Corey Danielle Eva Felicity
8154
8067
  ]
8155
8068
 
8156
8069
  NAMES_LAST = %w[
8157
- Smith
8158
- Johnson
8159
- Williams
8160
- Brown
8161
- Jones
8162
- Miller
8163
- Davis
8164
- Wilson
8165
- Anderson
8166
- Taylor
8167
- George
8168
- Harrington
8169
- Iverson
8170
- Jackson
8171
- Korby
8172
- Levinson
8070
+ Smith Johnson Williams Brown Jones Miller Davis Wilson Anderson Taylor George Harrington Iverson Jackson Korby Levinson
8173
8071
  ]
8174
8072
 
8175
8073
  CITIES = [
8176
- 'Bellesville',
8177
- 'Lombardia',
8178
- 'Steepleton',
8179
- 'Deerenstein',
8180
- 'Schwartz',
8181
- 'Hollandia',
8182
- 'Saint Pete',
8183
- 'Grandville',
8184
- 'London',
8185
- 'Berlin',
8186
- 'Elktown',
8187
- 'Paris',
8188
- 'Garrison',
8189
- 'Muncy',
8190
- 'St Louis',
8074
+ 'Bellesville', 'Lombardia', 'Steepleton', 'Deerenstein', 'Schwartz', 'Hollandia', 'Saint Pete', 'Grandville', 'London',
8075
+ 'Berlin', 'Elktown', 'Paris', 'Garrison', 'Muncy', 'St Louis',
8191
8076
  ]
8192
8077
 
8193
8078
  STATES = [ 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA',
@@ -8265,7 +8150,7 @@ class PaginatedRefinedTable
8265
8150
  refined_table(
8266
8151
  model_array: contacts,
8267
8152
  table_columns: {
8268
- 'Name' => :text,
8153
+ 'Name' => {text: {editable: false}},
8269
8154
  'Email' => :text,
8270
8155
  'Phone' => :text,
8271
8156
  'City' => :text,
@@ -8273,6 +8158,8 @@ class PaginatedRefinedTable
8273
8158
  },
8274
8159
  table_editable: true,
8275
8160
  per_page: 20,
8161
+ # page: 1, # initial page is 1
8162
+ # visible_page_count: true, # page count can be shown if preferred
8276
8163
  )
8277
8164
  }
8278
8165
  }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.16
1
+ 0.5.17
@@ -6,148 +6,21 @@ class PaginatedRefinedTable
6
6
  include Glimmer::LibUI::Application
7
7
 
8
8
  NAMES_FIRST = %w[
9
- Liam
10
- Noah
11
- William
12
- James
13
- Oliver
14
- Benjamin
15
- Elijah
16
- Lucas
17
- Mason
18
- Logan
19
- Alexander
20
- Ethan
21
- Jacob
22
- Michael
23
- Daniel
24
- Henry
25
- Jackson
26
- Sebastian
27
- Aiden
28
- Matthew
29
- Samuel
30
- David
31
- Joseph
32
- Carter
33
- Owen
34
- Wyatt
35
- John
36
- Jack
37
- Luke
38
- Jayden
39
- Dylan
40
- Grayson
41
- Levi
42
- Isaac
43
- Gabriel
44
- Julian
45
- Mateo
46
- Anthony
47
- Jaxon
48
- Lincoln
49
- Joshua
50
- Christopher
51
- Andrew
52
- Theodore
53
- Caleb
54
- Ryan
55
- Asher
56
- Nathan
57
- Thomas
58
- Leo
59
- Isaiah
60
- Charles
61
- Josiah
62
- Hudson
63
- Christian
64
- Hunter
65
- Connor
66
- Eli
67
- Ezra
68
- Aaron
69
- Landon
70
- Adrian
71
- Jonathan
72
- Nolan
73
- Jeremiah
74
- Easton
75
- Elias
76
- Colton
77
- Cameron
78
- Carson
79
- Robert
80
- Angel
81
- Maverick
82
- Nicholas
83
- Dominic
84
- Jaxson
85
- Greyson
86
- Adam
87
- Ian
88
- Austin
89
- Santiago
90
- Jordan
91
- Cooper
92
- Brayden
93
- Roman
94
- Evan
95
- Ezekiel
96
- Xaviar
97
- Jose
98
- Jace
99
- Jameson
100
- Leonardo
101
- Axel
102
- Everett
103
- Kayden
104
- Miles
105
- Sawyer
106
- Jason
107
- Emma
108
- Olivia
109
- Bartholomew
110
- Corey
111
- Danielle
112
- Eva
113
- Felicity
9
+ Liam Noah William James Oliver Benjamin Elijah Lucas Mason Logan Alexander Ethan Jacob Michael Daniel Henry Jackson Sebastian
10
+ Aiden Matthew Samuel David Joseph Carter Owen Wyatt John Jack Luke Jayden Dylan Grayson Levi Isaac Gabriel Julian Mateo
11
+ Anthony Jaxon Lincoln Joshua Christopher Andrew Theodore Caleb Ryan Asher Nathan Thomas Leo Isaiah Charles Josiah Hudson
12
+ Christian Hunter Connor Eli Ezra Aaron Landon Adrian Jonathan Nolan Jeremiah Easton Elias Colton Cameron Carson Robert Angel
13
+ Maverick Nicholas Dominic Jaxson Greyson Adam Ian Austin Santiago Jordan Cooper Brayden Roman Evan Ezekiel Xaviar Jose Jace
14
+ Jameson Leonardo Axel Everett Kayden Miles Sawyer Jason Emma Olivia Bartholomew Corey Danielle Eva Felicity
114
15
  ]
115
16
 
116
17
  NAMES_LAST = %w[
117
- Smith
118
- Johnson
119
- Williams
120
- Brown
121
- Jones
122
- Miller
123
- Davis
124
- Wilson
125
- Anderson
126
- Taylor
127
- George
128
- Harrington
129
- Iverson
130
- Jackson
131
- Korby
132
- Levinson
18
+ Smith Johnson Williams Brown Jones Miller Davis Wilson Anderson Taylor George Harrington Iverson Jackson Korby Levinson
133
19
  ]
134
20
 
135
21
  CITIES = [
136
- 'Bellesville',
137
- 'Lombardia',
138
- 'Steepleton',
139
- 'Deerenstein',
140
- 'Schwartz',
141
- 'Hollandia',
142
- 'Saint Pete',
143
- 'Grandville',
144
- 'London',
145
- 'Berlin',
146
- 'Elktown',
147
- 'Paris',
148
- 'Garrison',
149
- 'Muncy',
150
- 'St Louis',
22
+ 'Bellesville', 'Lombardia', 'Steepleton', 'Deerenstein', 'Schwartz', 'Hollandia', 'Saint Pete', 'Grandville', 'London',
23
+ 'Berlin', 'Elktown', 'Paris', 'Garrison', 'Muncy', 'St Louis',
151
24
  ]
152
25
 
153
26
  STATES = [ 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA',
@@ -233,6 +106,8 @@ class PaginatedRefinedTable
233
106
  },
234
107
  table_editable: true,
235
108
  per_page: 20,
109
+ # page: 1, # initial page is 1
110
+ # visible_page_count: true, # page count can be hidden if preferred
236
111
  )
237
112
  }
238
113
  }
Binary file
@@ -6,6 +6,7 @@ class RefinedTable
6
6
  option :table_editable, default: false
7
7
  option :per_page, default: 10
8
8
  option :page, default: 1
9
+ option :visible_page_count, default: false
9
10
 
10
11
  attr_accessor :filtered_model_array, :filter_query, :filter_query_page_stack, :paginated_model_array
11
12
 
@@ -14,6 +15,7 @@ class RefinedTable
14
15
  @filter_query_page_stack = {}
15
16
  @filtered_model_array = model_array.dup
16
17
  @filtered_model_array_stack = {@filter_query => @filtered_model_array}
18
+ self.page = correct_page(page)
17
19
  paginate_model_array
18
20
  end
19
21
 
@@ -21,7 +23,7 @@ class RefinedTable
21
23
  vertical_box {
22
24
  table_filter
23
25
 
24
- table_paginator
26
+ table_paginator if page_count > 1
25
27
 
26
28
  @table = table {
27
29
  table_columns.each do |column_name, column_details|
@@ -74,8 +76,10 @@ class RefinedTable
74
76
  def table_paginator
75
77
  horizontal_box {
76
78
  stretchy false
77
-
79
+
78
80
  button('<<') {
81
+ enabled <= [self, :page, on_read: ->(val) {val > 1}]
82
+
79
83
  on_clicked do
80
84
  unless self.page == 0
81
85
  self.page = 1
@@ -83,7 +87,10 @@ class RefinedTable
83
87
  end
84
88
  end
85
89
  }
90
+
86
91
  button('<') {
92
+ enabled <= [self, :page, on_read: ->(val) {val > 1}]
93
+
87
94
  on_clicked do
88
95
  unless self.page == 0
89
96
  self.page = [page - 1, 1].max
@@ -91,6 +98,7 @@ class RefinedTable
91
98
  end
92
99
  end
93
100
  }
101
+
94
102
  entry {
95
103
  text <=> [self, :page,
96
104
  on_read: :to_s,
@@ -98,7 +106,16 @@ class RefinedTable
98
106
  after_write: ->(val) { paginate_model_array },
99
107
  ]
100
108
  }
109
+
110
+ if visible_page_count
111
+ label {
112
+ text <= [self, :paginated_model_array, on_read: ->(val) {"of #{page_count} pages"}]
113
+ }
114
+ end
115
+
101
116
  button('>') {
117
+ enabled <= [self, :page, on_read: ->(val) {val < page_count}]
118
+
102
119
  on_clicked do
103
120
  unless self.page == 0
104
121
  self.page = [page + 1, page_count].min
@@ -106,7 +123,10 @@ class RefinedTable
106
123
  end
107
124
  end
108
125
  }
126
+
109
127
  button('>>') {
128
+ enabled <= [self, :page, on_read: ->(val) {val < page_count}]
129
+
110
130
  on_clicked do
111
131
  unless self.page == 0
112
132
  self.page = page_count
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.5.16
4
+ version: 0.5.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: 2022-07-31 00:00:00.000000000 Z
11
+ date: 2022-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer