glimmer-dsl-swt 4.20.3.0 → 4.20.4.3

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: 581c69384ecd98621e42b9c109b26606bd02f971645d560b6a327a2afef193cd
4
- data.tar.gz: ff868723057cdcc85357713f63f1bcc449505bb79e28714e1ce95eada387c0e5
3
+ metadata.gz: 13212fd4b8a440d635d5172b493b979d12a1ec1da94e7ea50c5c55521e4ae80c
4
+ data.tar.gz: d7c3004d04d20b0c14e8f6f72ac4be6368844e0ecb892962c021414291e3a0d8
5
5
  SHA512:
6
- metadata.gz: fa48a538274e9a199d9f332d1fec5e3c99d235509673fcf2de5b3c646aa38306a093368adefe5161b81dcc8530b411b5bb1b304700cca4762d655185e5550916
7
- data.tar.gz: 1d04d38dcda31ef8c02c015cd558e62dc29ff54ad2e295d548f91633b8b6b6ec5e98dc9ef514c2250e4d90cce1a1764feb3be626af8a843bfb95a07722f2dbc6
6
+ metadata.gz: 6420272e89fe681bd64d68b4db5dc25ac19a52efd20e00e3a72b840ead51dcb3755396bd1b9e72a6e36b96719348c609c275e2827805809e7ecefdc00727d327
7
+ data.tar.gz: 40b0acce99bf96c49f5499034271faf126c40b5e8870ff62c9b22bf8f6501448cd7256cf583c30d2928e06572ee02862cae1445feac71427b29ef7d829a09f6c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.4.2
4
+
5
+ - Hello, Label!
6
+
7
+ ### 4.20.4.1
8
+
9
+ - Ensure a `table` with `:editable` style loses it if `items <= ...` one-way data-binding (having read_only: true option) was setup.
10
+ - Tweak/refactor/improve samples
11
+
12
+ ### 4.20.4.0
13
+
14
+ - Extracted Shine data-binding syntax and `BindExpression` to Glimmer 2
15
+
3
16
  ### 4.20.3.0
4
17
 
5
18
  - Shine data-binding support for `custom widgets`, `custom shells`, and `custom shapes`
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 SWT 4.20.3.0
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 SWT 4.20.4.3
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -15,9 +15,9 @@
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.3.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.4.3 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
19
19
 
20
- **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still an alpha, so default back to `bind` whenever needed).
20
+ **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still a beta, so default back to `bind` whenever needed).
21
21
 
22
22
  Please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) better by providing feedback and [contributing](#contributing) whenever possible. Any feature suggestions that are accepted could be implemented within weeks if not days.
23
23
 
@@ -347,7 +347,7 @@ jgem install glimmer-dsl-swt
347
347
 
348
348
  Or this command if you want a specific version:
349
349
  ```
350
- jgem install glimmer-dsl-swt -v 4.20.3.0
350
+ jgem install glimmer-dsl-swt -v 4.20.4.3
351
351
  ```
352
352
 
353
353
  `jgem` is JRuby's version of `gem` command.
@@ -375,7 +375,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
375
375
 
376
376
  Add the following to `Gemfile`:
377
377
  ```
378
- gem 'glimmer-dsl-swt', '~> 4.20.3.0'
378
+ gem 'glimmer-dsl-swt', '~> 4.20.4.3'
379
379
  ```
380
380
 
381
381
  And, then run:
@@ -396,7 +396,7 @@ glimmer
396
396
  ```
397
397
 
398
398
  ```
399
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.3.0
399
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.4.3
400
400
 
401
401
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
402
402
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.20.3.0
1
+ 4.20.4.3
@@ -2278,7 +2278,7 @@ Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you
2278
2278
 
2279
2279
  #### Shine
2280
2280
 
2281
- **(ALPHA FEATURE)**
2281
+ **(BETA FEATURE)**
2282
2282
 
2283
2283
  The new Shine syntax for View/Model Attribute Mapping allows data-binding visually with simple arrow operators in Ruby.
2284
2284
 
@@ -2302,7 +2302,7 @@ text <=> [@contact, :last_name]
2302
2302
  text <= [@contact, :name, computed_by: [:first_name, :last_name]]
2303
2303
  ```
2304
2304
 
2305
- Note that custom widgets and custom shapes are not supported by Shine syntax for data-binding yet, so continue to use `bind` with them for the time being.
2305
+ Given that Shine is new, if you encounter any issues, you can use `bind` instead.
2306
2306
 
2307
2307
  Check out [sample code](/samples) for more examples of Shine syntax in action, such as [Hello, Computed!](/docs/reference/GLIMMER_SAMPLES.md#hello-computed).
2308
2308
 
@@ -2,6 +2,7 @@
2
2
  - [Hello Samples](#hello-samples)
3
3
  - [Hello, World!](#hello-world)
4
4
  - [Hello, Button!](#hello-button)
5
+ - [Hello, Label!](#hello-label)
5
6
  - [Hello, Text!](#hello-text)
6
7
  - [Hello, Composite!](#hello-composite)
7
8
  - [Hello, Layout!](#hello-layout)
@@ -117,6 +118,28 @@ Hello, Button! Incremented 7 times!
117
118
 
118
119
  ![Hello Button Incremented](/images/glimmer-hello-button-incremented.png)
119
120
 
121
+ #### Hello, Label!
122
+
123
+ This sample demonstrates the use of the `label` widget in Glimmer.
124
+
125
+ Code:
126
+
127
+ [samples/hello/hello_label.rb](/samples/hello/hello_label.rb)
128
+
129
+ ![Hello Label Left Aligned](/images/glimmer-hello-label-left-aligned.png)
130
+
131
+ ![Hello Label Center Aligned](/images/glimmer-hello-label-center-aligned.png)
132
+
133
+ ![Hello Label Right Aligned](/images/glimmer-hello-label-right-aligned.png)
134
+
135
+ ![Hello Label Images](/images/glimmer-hello-label-images.png)
136
+
137
+ ![Hello Label Background Images](/images/glimmer-hello-label-background_images.png)
138
+
139
+ ![Hello Label Horizontal Separator](/images/glimmer-hello-label-horizontal-separator.png)
140
+
141
+ ![Hello Label Vertical Separator](/images/glimmer-hello-label-vertical-separator.png)
142
+
120
143
  #### Hello, Text!
121
144
 
122
145
  This sample demonstrates the use of the `text` widget in Glimmer, including data-binding (e.g. via the `<=>` operator) and event handling.
Binary file
@@ -30,6 +30,7 @@ if !['', 'false'].include?(ENV['GLIMMER_BUNDLER_SETUP'].to_s.strip.downcase)
30
30
  end
31
31
  require 'java'
32
32
  require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
33
+ require 'concurrent-ruby' # ensures glimmer relies on Concurrent data-structure classes (e.g. Concurrent::Array)
33
34
  require 'glimmer'
34
35
  require 'logging'
35
36
  require 'nested_inherited_jruby_include_package'
@@ -39,6 +39,7 @@ module Glimmer
39
39
  @model_binding = model_binding
40
40
  @read_only_sort = @model_binding.binding_options[:read_only_sort]
41
41
  @column_properties = @model_binding.binding_options[:column_properties] || @model_binding.binding_options[:column_attributes] || column_properties
42
+ @table.editable = false if @model_binding.binding_options[:read_only]
42
43
  if @table.respond_to?(:column_properties=)
43
44
  @table.column_properties = @column_properties
44
45
  else # assume custom widget
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -20,6 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/dsl/static_expression'
23
+ require 'glimmer/dsl/bind_expression'
23
24
  require 'glimmer/data_binding/model_binding'
24
25
 
25
26
  module Glimmer
@@ -30,28 +31,7 @@ module Glimmer
30
31
  # DataBindingCommandHandler for text and selection properties on Text and Spinner
31
32
  # or TableItemsDataBindingCommandHandler for items in a Table
32
33
  class BindExpression < StaticExpression
33
- def can_interpret?(parent, keyword, *args, &block)
34
- (
35
- keyword == 'bind' and
36
- (
37
- (
38
- (args.size == 2) and
39
- textual?(args[1])
40
- ) ||
41
- (
42
- (args.size == 3) and
43
- textual?(args[1]) and
44
- (args[2].is_a?(Hash))
45
- )
46
- )
47
- )
48
- end
49
-
50
- def interpret(parent, keyword, *args, &block)
51
- binding_options = args[2] || {}
52
- binding_options[:on_read] = binding_options.delete(:on_read) || binding_options.delete('on_read') || block
53
- DataBinding::ModelBinding.new(args[0], args[1].to_s, binding_options)
54
- end
34
+ include Glimmer::DSL::BindExpression
55
35
  end
56
36
  end
57
37
  end
@@ -6,7 +6,7 @@ class Timer
6
6
 
7
7
  import 'javax.sound.sampled'
8
8
 
9
- FILE_SOUND_ALARM = File.expand_path(File.join('timer', 'alarm1.wav'), __dir__)
9
+ FILE_SOUND_ALARM = File.expand_path(File.join('timer', 'sounds', 'alarm1.wav'), __dir__)
10
10
  COMMAND_KEY = OS.mac? ? :command : :ctrl
11
11
 
12
12
  ## Add options like the following to configure CustomShell by outside consumers
@@ -29,6 +29,7 @@ class Weather
29
29
 
30
30
  DEFAULT_FONT_HEIGHT = 30
31
31
  DEFAULT_FOREGROUND = :white
32
+ DEFAULT_BACKGROUND = rgb(135, 176, 235)
32
33
 
33
34
  attr_accessor :city, :temp, :temp_min, :temp_max, :feels_like, :humidity
34
35
 
@@ -54,7 +55,7 @@ class Weather
54
55
 
55
56
  text 'Glimmer Weather'
56
57
  minimum_size 400, 300
57
- background rgb(135, 176, 235)
58
+ background DEFAULT_BACKGROUND
58
59
 
59
60
  text {
60
61
  layout_data(:center, :center, true, true)
@@ -78,7 +79,7 @@ class Weather
78
79
  grid_layout 2, false
79
80
 
80
81
  text temp_unit
81
- background :transparent
82
+ background DEFAULT_BACKGROUND
82
83
 
83
84
  rectangle(0, 0, [:default, -2], [:default, -2], 15, 15) {
84
85
  foreground DEFAULT_FOREGROUND
@@ -128,8 +129,8 @@ class Weather
128
129
  @weather_mutex.synchronize do
129
130
  self.weather_data = JSON.parse(Net::HTTP.get('api.openweathermap.org', "/data/2.5/weather?q=#{city}&appid=1d16d70a9aec3570b5cbd27e6b421330"))
130
131
  end
131
- rescue
132
- # No Op
132
+ rescue => e
133
+ Glimmer::Config.logger.error "Unable to fetch weather due to error: #{e.full_message}"
133
134
  end
134
135
 
135
136
  def weather_data=(data)
@@ -148,14 +149,17 @@ class Weather
148
149
  end
149
150
 
150
151
  def kelvin_to_celsius(kelvin)
152
+ return nil if kelvin.nil?
151
153
  kelvin - 273.15
152
154
  end
153
155
 
154
156
  def celsius_to_fahrenheit(celsius)
157
+ return nil if celsius.nil?
155
158
  (celsius * 9 / 5 ) + 32
156
159
  end
157
160
 
158
161
  def kelvin_to_fahrenheit(kelvin)
162
+ return nil if kelvin.nil?
159
163
  celsius_to_fahrenheit(kelvin_to_celsius(kelvin))
160
164
  end
161
165
 
@@ -44,7 +44,7 @@ class HelloCTab
44
44
  foreground :blue
45
45
  selection_foreground :dark_blue
46
46
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
47
- image File.expand_path('hello_c_tab/usa.png', __dir__)
47
+ image File.expand_path('images/usa.png', __dir__)
48
48
 
49
49
  label {
50
50
  text 'Hello, World!'
@@ -58,7 +58,7 @@ class HelloCTab
58
58
  foreground :blue
59
59
  selection_foreground :dark_blue
60
60
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
61
- image File.expand_path('hello_c_tab/france.png', __dir__)
61
+ image File.expand_path('images/france.png', __dir__)
62
62
 
63
63
  label {
64
64
  text 'Bonjour, Univers!'
@@ -72,7 +72,7 @@ class HelloCTab
72
72
  foreground :blue
73
73
  selection_foreground :dark_blue
74
74
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
75
- image File.expand_path('hello_c_tab/mexico.png', __dir__)
75
+ image File.expand_path('images/mexico.png', __dir__)
76
76
 
77
77
  label {
78
78
  text 'Hola, Mundo!'
@@ -86,7 +86,7 @@ class HelloCTab
86
86
  foreground :blue
87
87
  selection_foreground :dark_blue
88
88
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
89
- image File.expand_path('hello_c_tab/germany.png', __dir__)
89
+ image File.expand_path('images/germany.png', __dir__)
90
90
 
91
91
  label {
92
92
  text 'Hallo, Welt!'
@@ -100,7 +100,7 @@ class HelloCTab
100
100
  foreground :blue
101
101
  selection_foreground :dark_blue
102
102
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
103
- image File.expand_path('hello_c_tab/italy.png', __dir__)
103
+ image File.expand_path('images/italy.png', __dir__)
104
104
 
105
105
  label {
106
106
  text 'Ciao, Mondo!'
@@ -114,7 +114,7 @@ class HelloCTab
114
114
  foreground :blue
115
115
  selection_foreground :dark_blue
116
116
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
117
- image File.expand_path('hello_c_tab/netherlands.png', __dir__)
117
+ image File.expand_path('images/netherlands.png', __dir__)
118
118
 
119
119
  label {
120
120
  text 'Hallo, Wereld!'
@@ -128,7 +128,7 @@ class HelloCTab
128
128
  foreground :blue
129
129
  selection_foreground :dark_blue
130
130
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
131
- image File.expand_path('hello_c_tab/denmark.png', __dir__)
131
+ image File.expand_path('images/denmark.png', __dir__)
132
132
 
133
133
  label {
134
134
  text 'Hej, Verden!'
@@ -142,7 +142,7 @@ class HelloCTab
142
142
  foreground :blue
143
143
  selection_foreground :dark_blue
144
144
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
145
- image File.expand_path('hello_c_tab/finland.png', __dir__)
145
+ image File.expand_path('images/finland.png', __dir__)
146
146
 
147
147
  label {
148
148
  text 'Hei, Maailma!'
@@ -156,7 +156,7 @@ class HelloCTab
156
156
  foreground :blue
157
157
  selection_foreground :dark_blue
158
158
  font name: 'Times New Roman', height: 30, style: [:bold, :italic]
159
- image File.expand_path('hello_c_tab/norway.png', __dir__)
159
+ image File.expand_path('images/norway.png', __dir__)
160
160
 
161
161
  label {
162
162
  text 'Hei, Verden!'
@@ -21,9 +21,27 @@
21
21
 
22
22
  require 'glimmer-dsl-swt'
23
23
 
24
- require_relative 'hello_computed/contact'
25
-
26
24
  class HelloComputed
25
+ class Contact
26
+ attr_accessor :first_name, :last_name, :year_of_birth
27
+
28
+ def initialize(attribute_map)
29
+ @first_name = attribute_map[:first_name]
30
+ @last_name = attribute_map[:last_name]
31
+ @year_of_birth = attribute_map[:year_of_birth]
32
+ end
33
+
34
+ def name
35
+ "#{last_name}, #{first_name}"
36
+ end
37
+
38
+ def age
39
+ Time.now.year - year_of_birth.to_i
40
+ rescue
41
+ 0
42
+ end
43
+ end
44
+
27
45
  include Glimmer::UI::CustomShell
28
46
 
29
47
  before_body {
@@ -88,12 +88,10 @@ class EmailShell
88
88
  end
89
89
 
90
90
  class HelloCustomShell
91
- include Glimmer::UI::CustomShell
92
-
93
91
  Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
94
92
  EmailSystem = Struct.new(:emails, keyword_init: true)
95
93
 
96
- before_body {
94
+ def initialize
97
95
  @email_system = EmailSystem.new(
98
96
  emails: [
99
97
  Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
@@ -104,10 +102,10 @@ class HelloCustomShell
104
102
  Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
105
103
  ]
106
104
  )
107
- }
105
+ end
108
106
 
109
- body {
110
- shell {
107
+ def launch
108
+ shell { |shell_proxy|
111
109
  grid_layout
112
110
 
113
111
  text 'Hello, Custom Shell!'
@@ -142,11 +140,19 @@ class HelloCustomShell
142
140
 
143
141
  on_mouse_up { |event|
144
142
  email = event.table_item.get_data
145
- email_shell(parent_shell: self, date: email.date, subject: email.subject, from: email.from, message: email.message).open
143
+
144
+ # open a custom email shell
145
+ email_shell(
146
+ parent_shell: shell_proxy,
147
+ date: email.date,
148
+ subject: email.subject,
149
+ from: email.from,
150
+ message: email.message
151
+ ).open
146
152
  }
147
153
  }
148
- }
149
- }
154
+ }.open
155
+ end
150
156
  end
151
157
 
152
- HelloCustomShell.launch
158
+ HelloCustomShell.new.launch
@@ -0,0 +1,194 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer-dsl-swt'
23
+
24
+ class HelloLabel
25
+ include Glimmer::UI::CustomShell
26
+
27
+ body {
28
+ shell {
29
+ text 'Hello, Label!'
30
+
31
+ tab_folder {
32
+ tab_item {
33
+ text 'left-aligned'
34
+
35
+ grid_layout 2, true
36
+
37
+ 1.upto(3) do |n|
38
+ label(:left) { # :left is default in English, so it is unnecessary
39
+ layout_data :fill, :center, true, false
40
+ text "Field #{n}"
41
+ }
42
+ text {
43
+ layout_data :fill, :center, true, false
44
+ text "Enter Field #{n}"
45
+ }
46
+ end
47
+ }
48
+
49
+ tab_item {
50
+ text 'center-aligned'
51
+
52
+ grid_layout 2, true
53
+
54
+ 1.upto(3) do |n|
55
+ label(:center) {
56
+ layout_data :fill, :center, true, false
57
+ text "Field #{n}"
58
+ }
59
+ text {
60
+ layout_data :fill, :center, true, false
61
+ text "Enter Field #{n}"
62
+ }
63
+ end
64
+ }
65
+
66
+ tab_item {
67
+ text 'right-aligned'
68
+
69
+ grid_layout 2, true
70
+
71
+ 1.upto(3) do |n|
72
+ label(:right) {
73
+ layout_data :fill, :center, true, false
74
+ text "Field #{n}"
75
+ }
76
+ text {
77
+ layout_data :fill, :center, true, false
78
+ text "Enter Field #{n}"
79
+ }
80
+ end
81
+ }
82
+
83
+ tab_item {
84
+ text 'images'
85
+
86
+ grid_layout 2, true
87
+
88
+ ['denmark', 'finland', 'norway'].each do |image_name|
89
+ label {
90
+ layout_data :fill, :center, true, false
91
+ image File.expand_path("images/#{image_name}.png", __dir__)
92
+ }
93
+ text {
94
+ layout_data :fill, :center, true, false
95
+ text "Enter Field #{image_name.capitalize}"
96
+ }
97
+ end
98
+ }
99
+
100
+ tab_item {
101
+ text 'background images'
102
+
103
+ grid_layout 2, true
104
+
105
+ ['italy', 'france', 'mexico'].each do |image_name|
106
+ label {
107
+ layout_data :center, :center, true, false
108
+ background_image File.expand_path("images/#{image_name}.png", __dir__)
109
+ text image_name.capitalize
110
+ font height: 26, style: :bold
111
+ }
112
+ text {
113
+ layout_data :fill, :center, true, false
114
+ text "Enter Field #{image_name.capitalize}"
115
+ }
116
+ end
117
+ }
118
+
119
+ tab_item {
120
+ text 'horizontal separator'
121
+
122
+ grid_layout 2, true
123
+
124
+ label {
125
+ layout_data :fill, :center, true, false
126
+ text "Field 1"
127
+ }
128
+ text {
129
+ layout_data :fill, :center, true, false
130
+ text "Enter Field 1"
131
+ }
132
+
133
+ label(:separator, :horizontal) {
134
+ layout_data(:fill, :center, true, false) {
135
+ horizontal_span 2
136
+ }
137
+ }
138
+
139
+ label {
140
+ layout_data :fill, :center, true, false
141
+ text "Field 2"
142
+ }
143
+ text {
144
+ layout_data :fill, :center, true, false
145
+ text "Enter Field 2"
146
+ }
147
+ }
148
+
149
+ tab_item {
150
+ text 'vertical separator'
151
+
152
+ grid_layout 3, true
153
+
154
+ label {
155
+ layout_data :fill, :center, true, false
156
+ text "Field 1"
157
+ }
158
+ label(:separator, :vertical) {
159
+ layout_data(:center, :center, false, false) {
160
+ vertical_span 3
161
+ }
162
+ }
163
+ text {
164
+ layout_data :fill, :center, true, false
165
+ text "Enter Field 1"
166
+ }
167
+
168
+ label {
169
+ layout_data :fill, :center, true, false
170
+ text "Field 2"
171
+ }
172
+ text {
173
+ layout_data :fill, :center, true, false
174
+ text "Enter Field 2"
175
+ }
176
+
177
+ label {
178
+ layout_data :fill, :center, true, false
179
+ text "Field 3"
180
+ }
181
+ text {
182
+ layout_data :fill, :center, true, false
183
+ text "Enter Field 3"
184
+ }
185
+ }
186
+
187
+ }
188
+
189
+ }
190
+
191
+ }
192
+ end
193
+
194
+ HelloLabel.launch
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.3.0
4
+ version: 4.20.4.3
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-08 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 1.3.1
18
+ version: 2.0.0
19
19
  name: glimmer
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.1
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -104,6 +104,46 @@ dependencies:
104
104
  - - "<"
105
105
  - !ruby/object:Gem::Version
106
106
  version: 2.0.0
107
+ - !ruby/object:Gem::Dependency
108
+ requirement: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.1.7
113
+ - - "<"
114
+ - !ruby/object:Gem::Version
115
+ version: 2.0.0
116
+ name: concurrent-ruby
117
+ prerelease: false
118
+ type: :runtime
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.1.7
124
+ - - "<"
125
+ - !ruby/object:Gem::Version
126
+ version: 2.0.0
127
+ - !ruby/object:Gem::Dependency
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.8.5
133
+ - - "<"
134
+ - !ruby/object:Gem::Version
135
+ version: 2.0.0
136
+ name: jruby-win32ole
137
+ prerelease: false
138
+ type: :runtime
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: 0.8.5
144
+ - - "<"
145
+ - !ruby/object:Gem::Version
146
+ version: 2.0.0
107
147
  - !ruby/object:Gem::Dependency
108
148
  requirement: !ruby/object:Gem::Requirement
109
149
  requirements:
@@ -198,26 +238,6 @@ dependencies:
198
238
  - - "<"
199
239
  - !ruby/object:Gem::Version
200
240
  version: 4.0.0
201
- - !ruby/object:Gem::Dependency
202
- requirement: !ruby/object:Gem::Requirement
203
- requirements:
204
- - - ">="
205
- - !ruby/object:Gem::Version
206
- version: 0.8.5
207
- - - "<"
208
- - !ruby/object:Gem::Version
209
- version: 2.0.0
210
- name: jruby-win32ole
211
- prerelease: false
212
- type: :runtime
213
- version_requirements: !ruby/object:Gem::Requirement
214
- requirements:
215
- - - ">="
216
- - !ruby/object:Gem::Version
217
- version: 0.8.5
218
- - - "<"
219
- - !ruby/object:Gem::Version
220
- version: 2.0.0
221
241
  - !ruby/object:Gem::Dependency
222
242
  requirement: !ruby/object:Gem::Requirement
223
243
  requirements:
@@ -390,7 +410,6 @@ files:
390
410
  - lib/glimmer/Rakefile
391
411
  - lib/glimmer/data_binding/list_selection_binding.rb
392
412
  - lib/glimmer/data_binding/observable_widget.rb
393
- - lib/glimmer/data_binding/shine.rb
394
413
  - lib/glimmer/data_binding/table_items_binding.rb
395
414
  - lib/glimmer/data_binding/tree_items_binding.rb
396
415
  - lib/glimmer/data_binding/widget_binding.rb
@@ -542,7 +561,6 @@ files:
542
561
  - samples/elaborate/tic_tac_toe/board.rb
543
562
  - samples/elaborate/tic_tac_toe/cell.rb
544
563
  - samples/elaborate/timer.rb
545
- - samples/elaborate/timer/alarm1.wav
546
564
  - samples/elaborate/timer/sounds/alarm1.wav
547
565
  - samples/elaborate/user_profile.rb
548
566
  - samples/elaborate/weather.rb
@@ -550,15 +568,6 @@ files:
550
568
  - samples/hello/hello_button.rb
551
569
  - samples/hello/hello_c_combo.rb
552
570
  - samples/hello/hello_c_tab.rb
553
- - samples/hello/hello_c_tab/denmark.png
554
- - samples/hello/hello_c_tab/finland.png
555
- - samples/hello/hello_c_tab/france.png
556
- - samples/hello/hello_c_tab/germany.png
557
- - samples/hello/hello_c_tab/italy.png
558
- - samples/hello/hello_c_tab/mexico.png
559
- - samples/hello/hello_c_tab/netherlands.png
560
- - samples/hello/hello_c_tab/norway.png
561
- - samples/hello/hello_c_tab/usa.png
562
571
  - samples/hello/hello_canvas.rb
563
572
  - samples/hello/hello_canvas_animation.rb
564
573
  - samples/hello/hello_canvas_animation_data_binding.rb
@@ -572,7 +581,6 @@ files:
572
581
  - samples/hello/hello_combo.rb
573
582
  - samples/hello/hello_composite.rb
574
583
  - samples/hello/hello_computed.rb
575
- - samples/hello/hello_computed/contact.rb
576
584
  - samples/hello/hello_cool_bar.rb
577
585
  - samples/hello/hello_cursor.rb
578
586
  - samples/hello/hello_custom_shape.rb
@@ -586,6 +594,7 @@ files:
586
594
  - samples/hello/hello_file_dialog.rb
587
595
  - samples/hello/hello_font_dialog.rb
588
596
  - samples/hello/hello_group.rb
597
+ - samples/hello/hello_label.rb
589
598
  - samples/hello/hello_layout.rb
590
599
  - samples/hello/hello_link.rb
591
600
  - samples/hello/hello_list_multi_selection.rb
@@ -608,6 +617,15 @@ files:
608
617
  - samples/hello/hello_tool_bar.rb
609
618
  - samples/hello/hello_tree.rb
610
619
  - samples/hello/hello_world.rb
620
+ - samples/hello/images/denmark.png
621
+ - samples/hello/images/finland.png
622
+ - samples/hello/images/france.png
623
+ - samples/hello/images/germany.png
624
+ - samples/hello/images/italy.png
625
+ - samples/hello/images/mexico.png
626
+ - samples/hello/images/netherlands.png
627
+ - samples/hello/images/norway.png
628
+ - samples/hello/images/usa.png
611
629
  - sounds/metronome-down.wav
612
630
  - sounds/metronome-up.wav
613
631
  - vendor/swt/linux/swt.jar
@@ -1,60 +0,0 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- module Glimmer
23
- module DataBinding
24
- class Shine
25
- include Glimmer
26
-
27
- def initialize(parent, parent_attribute)
28
- @parent = parent
29
- @parent_attribute = parent_attribute
30
- end
31
-
32
- alias original_compare <=>
33
-
34
- def <=>(other)
35
- if other.is_a?(Array)
36
- args_clone = other.clone
37
- @parent.content {
38
- send(@parent_attribute, bind(*args_clone))
39
- }
40
- else # || other.is_a?(Hash) # TODO support hash e.g. {model: model_obj, attribute: :some_attribute, more-options...}
41
- original_compare(other)
42
- end
43
- end
44
-
45
- def <=(other)
46
- if other.is_a?(Array)
47
- args_clone = other.clone
48
- if args_clone.last.is_a?(Hash)
49
- args_clone.last[:read_only] = true
50
- else # || other.is_a?(Hash) # TODO support hash e.g. {model: model_obj, attribute: :some_attribute, more-options...}
51
- args_clone << {read_only: true}
52
- end
53
- @parent.content {
54
- send(@parent_attribute, bind(*args_clone))
55
- }
56
- end
57
- end
58
- end
59
- end
60
- end
Binary file
@@ -1,42 +0,0 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- class HelloComputed
23
- class Contact
24
- attr_accessor :first_name, :last_name, :year_of_birth
25
-
26
- def initialize(attribute_map)
27
- @first_name = attribute_map[:first_name]
28
- @last_name = attribute_map[:last_name]
29
- @year_of_birth = attribute_map[:year_of_birth]
30
- end
31
-
32
- def name
33
- "#{last_name}, #{first_name}"
34
- end
35
-
36
- def age
37
- Time.now.year - year_of_birth.to_i
38
- rescue
39
- 0
40
- end
41
- end
42
- end