glimmer-dsl-swt 4.20.0.2 → 4.20.2.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +6 -6
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_SAMPLES.md +128 -49
  6. data/docs/reference/GLIMMER_STYLE_GUIDE.md +4 -3
  7. data/glimmer-dsl-swt.gemspec +0 -0
  8. data/lib/glimmer/data_binding/shine.rb +3 -1
  9. data/lib/glimmer/data_binding/table_items_binding.rb +2 -2
  10. data/lib/glimmer/data_binding/tree_items_binding.rb +2 -2
  11. data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +6 -3
  12. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +2 -2
  13. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +17 -12
  14. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +3 -3
  15. data/lib/glimmer/swt/display_proxy.rb +11 -8
  16. data/lib/glimmer/swt/proxy_properties.rb +2 -1
  17. data/lib/glimmer/swt/table_proxy.rb +15 -8
  18. data/lib/glimmer/swt/widget_proxy.rb +2 -2
  19. data/lib/glimmer/ui/custom_shell.rb +3 -3
  20. data/lib/glimmer/ui/custom_widget.rb +5 -2
  21. data/samples/elaborate/calculator.rb +116 -0
  22. data/samples/elaborate/calculator/model/command.rb +105 -0
  23. data/samples/elaborate/calculator/model/command/all_clear.rb +17 -0
  24. data/samples/elaborate/calculator/model/command/command_history.rb +0 -0
  25. data/samples/elaborate/calculator/model/command/equals.rb +18 -0
  26. data/samples/elaborate/calculator/model/command/number.rb +20 -0
  27. data/samples/elaborate/calculator/model/command/operation.rb +27 -0
  28. data/samples/elaborate/calculator/model/command/operation/add.rb +15 -0
  29. data/samples/elaborate/calculator/model/command/operation/divide.rb +15 -0
  30. data/samples/elaborate/calculator/model/command/operation/multiply.rb +15 -0
  31. data/samples/elaborate/calculator/model/command/operation/subtract.rb +15 -0
  32. data/samples/elaborate/calculator/model/command/point.rb +20 -0
  33. data/samples/elaborate/calculator/model/presenter.rb +30 -0
  34. data/samples/elaborate/login.rb +15 -13
  35. data/samples/elaborate/tetris.rb +6 -6
  36. data/samples/elaborate/tetris/view/high_score_dialog.rb +1 -1
  37. data/samples/elaborate/timer.rb +233 -0
  38. data/samples/elaborate/timer/alarm1.wav +0 -0
  39. data/samples/elaborate/timer/sounds/alarm1.wav +0 -0
  40. data/samples/elaborate/user_profile.rb +4 -2
  41. data/samples/elaborate/weather.rb +164 -0
  42. data/samples/hello/hello_cool_bar.rb +4 -4
  43. data/samples/hello/hello_layout.rb +6 -2
  44. data/samples/hello/hello_shell.rb +205 -0
  45. data/samples/hello/hello_table.rb +5 -5
  46. data/samples/hello/hello_text.rb +120 -0
  47. data/samples/hello/hello_tool_bar.rb +4 -4
  48. data/samples/hello/hello_tree.rb +11 -11
  49. metadata +21 -2
@@ -0,0 +1,120 @@
1
+ require 'glimmer-dsl-swt'
2
+
3
+ class HelloText
4
+ include Glimmer::UI::CustomShell
5
+
6
+ attr_accessor :default, :center, :left, :right, :password, :telephone, :read_only, :wrap, :multi
7
+
8
+ before_body {
9
+ self.default = 'default is :border style'
10
+ self.center = 'centered'
11
+ self.left = 'left-aligned'
12
+ self.right = 'right-aligned'
13
+ self.password = 'password'
14
+ self.telephone = '555-555-5555'
15
+ self.read_only = 'Telephone area code is 555'
16
+ self.wrap = 'wraps if text content is too long like this example'
17
+ self.multi = "multi-line enables hitting enter,\nbut does not wrap by default"
18
+ }
19
+
20
+ body {
21
+ shell {
22
+ grid_layout 2, false
23
+
24
+ text 'Hello, Text!'
25
+ minimum_size 350, 100
26
+
27
+ label {
28
+ text 'text'
29
+ }
30
+ text { # includes :border style by default
31
+ layout_data :fill, :center, true, false
32
+ text <=> [self, :default]
33
+ }
34
+
35
+ label {
36
+ text 'text(:center, :border)'
37
+ }
38
+ text(:center, :border) {
39
+ layout_data :fill, :center, true, false
40
+ text <=> [self, :center]
41
+ }
42
+
43
+ label {
44
+ text 'text(:left, :border)'
45
+ }
46
+ text(:left, :border) {
47
+ layout_data :fill, :center, true, false
48
+ text <=> [self, :left]
49
+ }
50
+
51
+ label {
52
+ text 'text(:right, :border)'
53
+ }
54
+ text(:right, :border) {
55
+ layout_data :fill, :center, true, false
56
+ text <=> [self, :right]
57
+ }
58
+
59
+ label {
60
+ text 'text(:password, :border)'
61
+ }
62
+ text(:password, :border) {
63
+ layout_data :fill, :center, true, false
64
+ text <=> [self, :password]
65
+ }
66
+
67
+ label {
68
+ text 'text(:read_only, :border)'
69
+ }
70
+ text(:read_only, :border) {
71
+ layout_data :fill, :center, true, false
72
+ text <=> [self, :read_only]
73
+ }
74
+
75
+ label {
76
+ text 'text with event handlers'
77
+ }
78
+ text {
79
+ layout_data :fill, :center, true, false
80
+ text <=> [self, :telephone]
81
+
82
+ # this event kicks in just after the user typed and before modifying the text attribute value
83
+ on_verify_text do |verify_event|
84
+ new_text = verify_event.widget.text.clone
85
+ new_text[verify_event.start...verify_event.end] = verify_event.text
86
+ verify_event.doit = telephone?(new_text)
87
+ end
88
+
89
+ # this event kicks in just after the text widget is verified and modified
90
+ on_modify_text do |modify_event|
91
+ self.read_only = "Telephone area code is #{modify_event.widget.text.gsub(/[^0-9]/, '')[0...3]}"
92
+ end
93
+ }
94
+
95
+ label {
96
+ text 'text(:wrap, :border)'
97
+ }
98
+ text(:wrap, :border) {
99
+ layout_data(:fill, :center, true, false) {
100
+ width_hint 100
101
+ }
102
+ text <=> [self, :wrap]
103
+ }
104
+
105
+ label {
106
+ text 'text(:multi, :border)'
107
+ }
108
+ text(:multi, :border) {
109
+ layout_data :fill, :center, true, false
110
+ text <=> [self, :multi]
111
+ }
112
+ }
113
+ }
114
+
115
+ def telephone?(text)
116
+ !!text.match(/^\d{0,3}[-.\/]?\d{0,3}[-.\/]?\d{0,4}$/)
117
+ end
118
+ end
119
+
120
+ HelloText.launch
@@ -31,7 +31,7 @@ class HelloToolBar
31
31
  end
32
32
 
33
33
  before_body {
34
- self.font_size = '10'
34
+ self.font_size = '30'
35
35
  }
36
36
 
37
37
  body {
@@ -76,9 +76,9 @@ class HelloToolBar
76
76
  }
77
77
 
78
78
  label {
79
- font height: 30
80
- text bind(self, :operation)
81
- text bind(self, :font_size)
79
+ font <= [self, :font_size, on_read: ->(size) { {height: size.to_i} }]
80
+ text <= [self, :operation]
81
+ text <= [self, :font_size]
82
82
  }
83
83
  }
84
84
  }
@@ -314,8 +314,8 @@ class HelloTree
314
314
  margin_height 5
315
315
  }
316
316
  @tree = tree {
317
- items bind(Employee, :ceo), tree_properties(children: :subordinates, text: :to_s)
318
- selection bind(Employee, :selected_employee)
317
+ items <= [Employee, :ceo, tree_properties: {children: :subordinates, text: :to_s}]
318
+ selection <=> [Employee, :selected_employee]
319
319
  }
320
320
  }
321
321
 
@@ -329,7 +329,7 @@ class HelloTree
329
329
  }
330
330
  text {
331
331
  layout_data(:fill, :center, true, false)
332
- text bind(Employee, "selected_employee.first_name")
332
+ text <=> [Employee, "selected_employee.first_name"]
333
333
  font height: 16
334
334
  }
335
335
 
@@ -340,7 +340,7 @@ class HelloTree
340
340
  }
341
341
  text {
342
342
  layout_data(:fill, :center, true, false)
343
- text bind(Employee, "selected_employee.last_name")
343
+ text <=> [Employee, "selected_employee.last_name"]
344
344
  font height: 16
345
345
  }
346
346
 
@@ -351,7 +351,7 @@ class HelloTree
351
351
  }
352
352
  combo {
353
353
  layout_data(:fill, :center, true, false)
354
- selection bind(Employee, "selected_employee.position")
354
+ selection <=> [Employee, "selected_employee.position"]
355
355
  font height: 16
356
356
  }
357
357
 
@@ -373,7 +373,7 @@ class HelloTree
373
373
  spinner {
374
374
  maximum 999_999
375
375
  minimum 0
376
- selection bind(Employee, "selected_employee.salary")
376
+ selection <=> [Employee, "selected_employee.salary"]
377
377
  font height: 16
378
378
  }
379
379
  }
@@ -385,7 +385,7 @@ class HelloTree
385
385
  }
386
386
  combo(:read_only) {
387
387
  layout_data(:fill, :center, true, false)
388
- selection bind(Employee, "selected_employee.health_insurance")
388
+ selection <=> [Employee, "selected_employee.health_insurance"]
389
389
  font height: 16
390
390
  }
391
391
 
@@ -396,7 +396,7 @@ class HelloTree
396
396
  }
397
397
  combo(:read_only) {
398
398
  layout_data(:fill, :center, true, false)
399
- selection bind(Employee, "selected_employee.desk_location")
399
+ selection <=> [Employee, "selected_employee.desk_location"]
400
400
  font height: 16
401
401
  }
402
402
 
@@ -414,7 +414,7 @@ class HelloTree
414
414
  spinner {
415
415
  maximum 100
416
416
  minimum 0
417
- selection bind(Employee, "selected_employee.sales_bonus_percentage")
417
+ selection <=> [Employee, "selected_employee.sales_bonus_percentage"]
418
418
  font height: 16
419
419
  }
420
420
  label {
@@ -441,7 +441,7 @@ class HelloTree
441
441
  spinner {
442
442
  maximum 999_999
443
443
  minimum 0
444
- selection bind(Employee, "selected_employee.merit_bonus")
444
+ selection <=> [Employee, "selected_employee.merit_bonus"]
445
445
  font height: 16
446
446
  }
447
447
  }
@@ -467,7 +467,7 @@ class HelloTree
467
467
  maximum 999_999_00
468
468
  minimum 0
469
469
  increment 100
470
- selection bind(Employee, "selected_employee.#{attribute}", on_read: ->(v) {v.to_f * 100}, on_write: ->(v) {v.to_f / 100})
470
+ selection <=> [Employee, "selected_employee.#{attribute}", on_read: ->(v) {v.to_f * 100}, on_write: ->(v) {v.to_f / 100}]
471
471
  font height: 16
472
472
  }
473
473
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.0.2
4
+ version: 4.20.2.0
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-07-03 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -505,6 +505,19 @@ files:
505
505
  - lib/glimmer/ui/custom_shell.rb
506
506
  - lib/glimmer/ui/custom_widget.rb
507
507
  - lib/glimmer/util/proc_tracker.rb
508
+ - samples/elaborate/calculator.rb
509
+ - samples/elaborate/calculator/model/command.rb
510
+ - samples/elaborate/calculator/model/command/all_clear.rb
511
+ - samples/elaborate/calculator/model/command/command_history.rb
512
+ - samples/elaborate/calculator/model/command/equals.rb
513
+ - samples/elaborate/calculator/model/command/number.rb
514
+ - samples/elaborate/calculator/model/command/operation.rb
515
+ - samples/elaborate/calculator/model/command/operation/add.rb
516
+ - samples/elaborate/calculator/model/command/operation/divide.rb
517
+ - samples/elaborate/calculator/model/command/operation/multiply.rb
518
+ - samples/elaborate/calculator/model/command/operation/subtract.rb
519
+ - samples/elaborate/calculator/model/command/point.rb
520
+ - samples/elaborate/calculator/model/presenter.rb
508
521
  - samples/elaborate/contact_manager.rb
509
522
  - samples/elaborate/contact_manager/contact.rb
510
523
  - samples/elaborate/contact_manager/contact_manager_presenter.rb
@@ -528,7 +541,11 @@ files:
528
541
  - samples/elaborate/tic_tac_toe.rb
529
542
  - samples/elaborate/tic_tac_toe/board.rb
530
543
  - samples/elaborate/tic_tac_toe/cell.rb
544
+ - samples/elaborate/timer.rb
545
+ - samples/elaborate/timer/alarm1.wav
546
+ - samples/elaborate/timer/sounds/alarm1.wav
531
547
  - samples/elaborate/user_profile.rb
548
+ - samples/elaborate/weather.rb
532
549
  - samples/hello/hello_browser.rb
533
550
  - samples/hello/hello_button.rb
534
551
  - samples/hello/hello_c_combo.rb
@@ -581,11 +598,13 @@ files:
581
598
  - samples/hello/hello_radio_group.rb
582
599
  - samples/hello/hello_sash_form.rb
583
600
  - samples/hello/hello_shape.rb
601
+ - samples/hello/hello_shell.rb
584
602
  - samples/hello/hello_spinner.rb
585
603
  - samples/hello/hello_styled_text.rb
586
604
  - samples/hello/hello_tab.rb
587
605
  - samples/hello/hello_table.rb
588
606
  - samples/hello/hello_table/baseball_park.png
607
+ - samples/hello/hello_text.rb
589
608
  - samples/hello/hello_tool_bar.rb
590
609
  - samples/hello/hello_tree.rb
591
610
  - samples/hello/hello_world.rb