glimmer-dsl-swt 4.18.1.0 → 4.18.1.1

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: 174d5b75d96fe6595809e3f212aa30b4fd17caec61fe98018ce8fcf72880c036
4
- data.tar.gz: 42f16bb6b36d68dea3ed1886d1993f65b539cc47e22799a4c7bd02fad2208389
3
+ metadata.gz: 2aa85c5f6d4f5a71bbc9538f291fff86199d26219c7b919068b5be7f99fc4bfd
4
+ data.tar.gz: 4db3a940c06f112c309e822ce73b0a1e98317f87ae808c183f261d49d357c490
5
5
  SHA512:
6
- metadata.gz: 220d7fbbba99b5b9f65c334cd0aec9a3ddb4120227d3ea2876e7ab9327027d70e651b849a4891dd58e5e61f85dce01382919a212c2c39d9d79af83106596bfa3
7
- data.tar.gz: ca8a7864a504618abd517aaf97832a185b84e86b7fb21ef4a27ffd70edc068822d1d5aae0ebdd192c9cd5ab106411fd78512354f676e49e1ac2b0dd8a1072154
6
+ metadata.gz: 96d95b883f011fc5d706382c4a8f1eea500ccd9ad15bf1fb3c82e9c7509348d0dcd16ef4c99ef963eb3bb4760e63aca217d0f4ab43d404ea6c8fa636bdfc8adc
7
+ data.tar.gz: a5182246e7825790b8c63ed8b7506d0e35e93af1f5a2e60c8ad6e015cee6fb092357ef2ca842d6f4bcf432b9cc5676b8167ec2bb42ef6dde47d007e50e1c2ba0
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.18.1.1
4
+
5
+ - Add smart defaults for round rectangle angles (defaults to 60 degrees angles)
6
+ - Add smart default for gradient rectangle vertical option
7
+ - Small update to Hello, Canvas! Sample
8
+ - Convert SWT style symbol to SWT style integer if method takes integer but receives a symbol (or string)
9
+ - Make polygon not require [] for its array args
10
+ - Allow cycle to receive splatted array as varargs
11
+ - Change references to `Display.setAppName` and `Display.setAppVersion` to `Display.app_name =` and `Display.app_version =`
12
+ - Default Glimmer app name to "Glimmer" (instead of previous "SWT") unless `Display.app_name = "Somename"` is set by consumer before instantiating first display
13
+ - Set default background to system widget background default for fill shapes
14
+ - Set default foreground to black for draw shapes
15
+ - Fix issue with shapes always requiring a block (even an empty one) to render
16
+ - Fix issue with animation requiring changes to canvas directly in addition to shapes
17
+ - Fix issue with `glimmer list:gems:dsl` command
18
+ - Fix issue with scaffolding still depending on git-glimmer despite being merged back to git gem
19
+
3
20
  ### 4.18.1.0
4
21
 
5
22
  - Canvas Shape DSL
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.18.1.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.18.1.1
2
2
 
3
3
 
4
4
  ## JRuby Desktop Development GUI Framework
@@ -12,7 +12,7 @@
12
12
 
13
13
  (The Original Glimmer Library Since 2007. Beware of Imitators!)
14
14
 
15
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](#custom-shell-gem) on [Linux](https://www.linux.org/).
15
+ [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](#widgets), but also supports drawing Canvas Graphics like [Shapes](#canvas-shape-dsl) and [Animations](#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](#custom-shell-gem) on [Linux](https://www.linux.org/).
16
16
 
17
17
  [Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
18
18
 
@@ -456,7 +456,7 @@ jgem install glimmer-dsl-swt
456
456
 
457
457
  Or this command if you want a specific version:
458
458
  ```
459
- jgem install glimmer-dsl-swt -v 4.18.1.0
459
+ jgem install glimmer-dsl-swt -v 4.18.1.1
460
460
 
461
461
 
462
462
  ```
@@ -476,7 +476,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
476
476
 
477
477
  Add the following to `Gemfile`:
478
478
  ```
479
- gem 'glimmer-dsl-swt', '~> 4.18.1.0
479
+ gem 'glimmer-dsl-swt', '~> 4.18.1.1
480
480
  '
481
481
  ```
482
482
 
@@ -535,7 +535,7 @@ bin/glimmer samples
535
535
  Below are the full usage instructions that come up when running `glimmer` without args.
536
536
 
537
537
  ```
538
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.1.0
538
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.18.1.1
539
539
 
540
540
 
541
541
 
@@ -593,6 +593,8 @@ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
593
593
 
594
594
  Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
595
595
 
596
+ Note: under Zsh (Z Shell), glimmer can only be used in its advanced TUI mode (e.g. `glimmer` and then selecting a task) not the primitive rake task mode (e.g. `glimmer scaffold[app]`)
597
+
596
598
  ### Glimmer Samples
597
599
 
598
600
  You can list available Glimmer samples by running:
@@ -1013,8 +1015,8 @@ Output:
1013
1015
  Name Gem Version Author Description
1014
1016
 
1015
1017
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1016
- Opal glimmer-dsl-opal 0.8.0 AndyMaleh Glimmer DSL for Opal
1017
- Swt glimmer-dsl-swt 4.18.1.0
1018
+ Opal glimmer-dsl-opal 0.10.2 AndyMaleh Glimmer DSL for Opal
1019
+ Swt glimmer-dsl-swt 4.18.1.1
1018
1020
 
1019
1021
  AndyMaleh Glimmer DSL for SWT
1020
1022
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
@@ -2298,31 +2300,45 @@ Glimmer supports drawing graphics directly on a `canvas` widget via SWT (or any
2298
2300
 
2299
2301
  This is accomplished via the Shape DSL a sub-DSL of the Glimmer GUI DSL, which makes it possible to draw graphics declaratively with very understandable and maintainable syntax.
2300
2302
 
2301
- Shape keywords are listed below (they basically match method names and arguments on [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) minus the `draw` or `fill` prefix in downcase):
2302
- - `arc​(int x, int y, int width, int height, int startAngle, int arcAngle)`
2303
- - `focus​(int x, int y, int width, int height)`
2304
- - `image(Image image, int x, int y)`
2305
- - `line(int x1, int y1, int x2, int y2)`
2306
- - `oval(int x, int y, int width, int height)`
2307
- - `point​(int x, int y)`
2308
- - `polygon(int[] pointArray)`
2309
- - `polyline(int[] pointArray)`
2310
- - `rectangle(int x, int y, int width, int height)`
2311
- - `round_rectangle(int x, int y, int width, int height, int arcWidth, int arcHeight)`
2312
- - `gradiant_rectangle​(int x, int y, int width, int height, boolean vertical)`
2313
- - `text(String string, int x, int y)`
2314
-
2315
- Shape keywords that can be filled with color can take an additional keyword argument `fill: true`
2303
+ Shape keywords and their args (including defaults) are listed below (they basically match method names and arguments on [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) minus the `draw` or `fill` prefix in downcase):
2304
+ - `arc​(x, y, width, height, startAngle, arcAngle, fill: false)`
2305
+ - `focus​(x, y, width, height)`
2306
+ - `image(image, x, y)`
2307
+ - `line(x1, y1, x2, y2)`
2308
+ - `oval(x, y, width, height, fill: false)`
2309
+ - `point​(x, y)`
2310
+ - `polygon(pointArray, fill: false)`
2311
+ - `polyline(pointArray)`
2312
+ - `rectangle(x, y, width, height, fill: false)`
2313
+ - `round_rectangle(x, y, width, height, arcWidth = 60, arcHeight = 60, fill: false)`
2314
+ - `gradient_rectangle​(x, y, width, height, vertical = true, fill: false)`
2315
+ - `text(String string, x, y)`
2316
+
2317
+ Shape keywords that can be filled with color can take an keyword argument `fill: true` (defaults to false when not specified)
2316
2318
 
2317
2319
  Optionally, a shape keyword takes a block that can set any attributes from [org.eclipse.swt.graphics.GC](https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html) (methods starting with `set`), which enable setting the `background` for filling and `foreground` for drawing.
2318
2320
 
2321
+ Here is a list of supported attributes nestable within a block under shapes:
2322
+ - `alpha` sets transparency (integer between 0 and 255)
2323
+ - `antialias` enables antialiasing (SWT style value of :default, :off, :on whereby :default applies OS default)
2324
+ - `background` sets fill color for fillable shapes (standard color symbol (e.g. :red), `rgb(red_integer, green_integer, blue_integer)` color, or Color/ColorProxy object directly)
2325
+ - `clipping​(x, y, width, height)` clips area of painting
2326
+ - `fill_rule` sets filling rule (SWT style value of :fill_even_odd or :fill_winding)
2327
+ - `font` sets font (Hash of :name, :height, and :style just like standard widget font property, or Font/FontProxy object directly)
2328
+ - `line_cap` sets line cap (SWT style value of :cap_flat, :cap_round, or :cap_square)
2329
+ - `line_dash` line dash float values (automatically sets `line_style` to SWT style value of :line_custom)
2330
+ - `line_join` line join style (SWT style value of :join_miter, :join_round, or :join_bevel)
2331
+ - `line_style` line join style (SWT style value of :line_solid, :line_dash, :line_dot, :line_dashdot, or :line_dashdotdot)
2332
+ - `line_width` line width in integer (used in draw operations)
2333
+ - `text_anti_alias` enables text antialiasing (SWT style value of :default, :off, :on whereby :default applies OS default)
2334
+
2319
2335
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2320
2336
 
2321
2337
  ```ruby
2322
2338
  include Glimmer
2323
2339
 
2324
2340
  shell {
2325
- text 'Canvas Example!'
2341
+ text 'Canvas Example'
2326
2342
  minimum_size 320, 400
2327
2343
 
2328
2344
  canvas {
@@ -2344,6 +2360,10 @@ shell {
2344
2360
  }.open
2345
2361
  ```
2346
2362
 
2363
+ Screenshot:
2364
+
2365
+ ![Canvas Animation Example](images/glimmer-example-canvas.png)
2366
+
2347
2367
  Learn more at the [Hello, Canvas! Sample](#hello-canvas).
2348
2368
 
2349
2369
  ### Canvas Animation DSL
@@ -2360,7 +2380,7 @@ This example says it all (it moves a tiny red square across a blue background):
2360
2380
  include Glimmer
2361
2381
 
2362
2382
  shell {
2363
- text 'Canvas Animation Example!'
2383
+ text 'Canvas Animation Example'
2364
2384
  minimum_size 400, 400
2365
2385
 
2366
2386
  canvas {
@@ -2378,8 +2398,12 @@ shell {
2378
2398
  }.open
2379
2399
  ```
2380
2400
 
2381
- Keywords involved:
2382
- - `animation` declares an animation under a canvas, which renders frames indefinitely or finitely depending on properties
2401
+ Screenshot:
2402
+
2403
+ ![Canvas Animation Example](images/glimmer-example-canvas-animation.png)
2404
+
2405
+ Keywords:
2406
+ - `animation` declares an animation under a canvas, which renders frames using a frame block indefinitely or finitely depending on (cycle_count/frame_count) properties
2383
2407
  - `every` specifies delay in seconds between every two frame renders
2384
2408
  - `frame` a block that can contain Shape DSL syntax that is rendered dynamically with variables calculated on the fly
2385
2409
  - `cycle` a property that takes an array to cycle into a second variable for the `frame` block
@@ -2391,9 +2415,6 @@ API:
2391
2415
  - `#start` starts animation as a method on the animation object (returned from `animation` keyword)
2392
2416
  - `#stop` stops animation gracefully as a method on the animation object (returned from `animation` keyword)
2393
2417
 
2394
- Caveat:
2395
- In order for animation to occur, the frame block must include changes that happen directly on the canvas (like setting initial background updating every frame) not just changes to shapes. This should be fixed in the future.
2396
-
2397
2418
  Learn more at the [Hello, Canvas Animation! Sample](#hello-canvas-animation).
2398
2419
 
2399
2420
  ### Data-Binding
@@ -3579,12 +3600,12 @@ Example.new
3579
3600
 
3580
3601
  Application name (shows up on the Mac in top menu bar) and version may be specified upon [packaging](#packaging--distribution) by specifying "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
3581
3602
 
3582
- Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT Display.setAppName method before any Display object has been instantiated (i.e. before any Glimmer widget like shell has been declared).
3603
+ Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT `Display.app_name=` method before any Display object has been instantiated (i.e. before any Glimmer widget like shell has been declared).
3583
3604
 
3584
3605
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3585
3606
 
3586
3607
  ```ruby
3587
- Display.setAppName('Glimmer Demo')
3608
+ Display.app_name = 'Glimmer Demo'
3588
3609
 
3589
3610
  shell(:no_resize) {
3590
3611
  text "Glimmer"
@@ -3594,7 +3615,7 @@ shell(:no_resize) {
3594
3615
  }.open
3595
3616
  ```
3596
3617
 
3597
- Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
3618
+ Also, you may invoke `Display.app_version = '1.0.0'` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
3598
3619
 
3599
3620
  #### Checkbox Group Widget
3600
3621
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.18.1.0
1
+ 4.18.1.1
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.18.1.0 ruby lib
5
+ # stub: glimmer-dsl-swt 4.18.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.18.1.0"
9
+ s.version = "4.18.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2021-01-19"
14
+ s.date = "2021-01-20"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -39,7 +39,7 @@ module Glimmer
39
39
  end
40
40
 
41
41
  def interpret(parent, keyword, *args, &block)
42
- Glimmer::SWT::Custom::Shape.new(parent, keyword, *args)
42
+ Glimmer::SWT::Custom::Shape.new(parent, keyword, *args, &block)
43
43
  end
44
44
 
45
45
  def add_content(parent, &block)
@@ -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
@@ -57,11 +57,11 @@ module Glimmer
57
57
  lines = `gem search -d #{gem_prefix}`.split("\n")
58
58
  gems = lines.slice_before {|l| l.match(REGEX_GEM_LINE) }.to_a
59
59
  gems = gems.map do |gem|
60
- {
60
+ {
61
61
  name: gem[0].match(REGEX_GEM_LINE)[1],
62
62
  version: gem[0].match(REGEX_GEM_LINE)[2],
63
63
  author: gem[1].strip,
64
- description: gem[4..-1].map(&:strip).join(' ')
64
+ description: gem[4..-1]&.map(&:strip)&.join(' ').to_s
65
65
  }
66
66
  end.select do |gem|
67
67
  query.nil? || "#{gem[:name]} #{gem[:author]} #{gem[:description]}".downcase.include?(query.to_s.downcase)
@@ -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
@@ -113,7 +113,6 @@ module Glimmer
113
113
 
114
114
  group :development do
115
115
  gem 'rspec', '~> 3.5.0'
116
- gem 'git-glimmer', '1.7.0'
117
116
  gem 'juwelier', '2.4.9'
118
117
  gem 'warbler', '2.0.5'
119
118
  gem 'simplecov', '>= 0'
@@ -133,12 +132,12 @@ module Glimmer
133
132
  gem_summary = human_name(app_name)
134
133
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
135
134
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
136
- system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
135
+ system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
137
136
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
138
137
  cd gem_name
139
138
  rm_rf 'lib'
140
139
  write '.gitignore', GITIGNORE
141
- write '.ruby-version', RUBY_VERSION
140
+ write '.ruby-version', RUBY_VERSION
142
141
  write '.ruby-gemset', app_name
143
142
  write 'VERSION', '1.0.0'
144
143
  write 'LICENSE.txt', "Copyright (c) #{Time.now.year} #{app_name}"
@@ -178,7 +177,7 @@ module Glimmer
178
177
  system "bundle"
179
178
  system "rspec --init"
180
179
  else
181
- system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
180
+ system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
182
181
  end
183
182
  write 'spec/spec_helper.rb', spec_helper_file
184
183
  if OS.windows?
@@ -191,7 +190,7 @@ module Glimmer
191
190
  else
192
191
  system "glimmer run"
193
192
  end
194
- end
193
+ end
195
194
  end
196
195
 
197
196
  def custom_shell(custom_shell_name, namespace, shell_type = nil, shell_options = {})
@@ -231,11 +230,11 @@ module Glimmer
231
230
  end
232
231
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
233
232
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
234
- system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
233
+ system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
235
234
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
236
235
  cd gem_name
237
236
  write '.gitignore', GITIGNORE
238
- write '.ruby-version', RUBY_VERSION
237
+ write '.ruby-version', RUBY_VERSION
239
238
  write '.ruby-gemset', gem_name
240
239
  write 'VERSION', '1.0.0'
241
240
  write 'Gemfile', GEMFILE
@@ -256,7 +255,7 @@ module Glimmer
256
255
  system "rspec --init"
257
256
  else
258
257
  system "bash -c '#{RVM_FUNCTION}\n cd .\n bundle\n rspec --init\n'"
259
- end
258
+ end
260
259
  write 'spec/spec_helper.rb', spec_helper_file
261
260
 
262
261
  mkdir_p 'package/windows'
@@ -283,7 +282,7 @@ module Glimmer
283
282
  system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app" if OS.mac?
284
283
  else
285
284
  system "glimmer run"
286
- end
285
+ end
287
286
  end
288
287
  puts "Finished creating #{gem_name} Ruby gem."
289
288
  puts 'Edit Rakefile to configure gem details.'
@@ -305,11 +304,11 @@ module Glimmer
305
304
 
306
305
  return puts("The directory '#{gem_name}' already exists. Please either remove or pick a different name.") if Dir.exist?(gem_name)
307
306
  system "jruby -S gem install juwelier -v2.4.9 --no-document" unless juwelier_exists?
308
- system "jruby -r git-glimmer -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
307
+ system "jruby -S juwelier --markdown --rspec --summary '#{gem_summary}' --description '#{gem_summary}' #{gem_name}"
309
308
  return puts('Your Git user.name and/or github.user are missing! Please add in for Juwelier to help Glimmer with Scaffolding.') if `git config --get github.user`.strip.empty? && `git config --get user.name`.strip.empty?
310
309
  cd gem_name
311
310
  write '.gitignore', GITIGNORE
312
- write '.ruby-version', RUBY_VERSION
311
+ write '.ruby-version', RUBY_VERSION
313
312
  write '.ruby-gemset', gem_name
314
313
  write 'VERSION', '1.0.0'
315
314
  write 'Gemfile', GEMFILE
@@ -397,9 +396,9 @@ module Glimmer
397
396
  class #{class_name(app_name)}
398
397
  include Glimmer
399
398
 
400
- APP_ROOT = File.expand_path('../..', __FILE__)
399
+ APP_ROOT = File.expand_path('../..', __FILE__)
401
400
  VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
402
- LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
401
+ LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
403
402
 
404
403
  def open
405
404
  app_view.open
@@ -443,7 +442,7 @@ module Glimmer
443
442
 
444
443
  launcher = Glimmer::Launcher.new([runner] + ARGV)
445
444
  launcher.launch
446
- end
445
+ end
447
446
  MULTI_LINE_STRING
448
447
  end
449
448
 
@@ -482,7 +481,7 @@ module Glimmer
482
481
 
483
482
  launcher = Glimmer::Launcher.new([runner] + ARGV)
484
483
  launcher.launch
485
- end
484
+ end
486
485
  MULTI_LINE_STRING
487
486
  end
488
487
 
@@ -502,15 +501,15 @@ module Glimmer
502
501
  end
503
502
  spec_pattern_line_index = lines.index(lines.detect {|l| l.include?('spec.pattern =') })
504
503
  lines.insert(spec_pattern_line_index+1, " spec.ruby_opts = [Glimmer::Launcher.jruby_os_specific_options]")
505
- lines << "\nrequire 'glimmer/rake_task'\n"
504
+ lines << "\nrequire 'glimmer/rake_task'\n"
506
505
  file_content = lines.join("\n")
507
506
  if custom_shell_name
508
- file_content << <<~MULTI_LINE_STRING
507
+ file_content << <<~MULTI_LINE_STRING
509
508
  Glimmer::RakeTask::Package.javapackager_extra_args =
510
509
  " -name '#{human_name(custom_shell_name)}'" +
511
510
  " -title '#{human_name(custom_shell_name)}'" +
512
511
  " -Bmac.CFBundleName='#{human_name(custom_shell_name)}'" +
513
- " -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).camelcase(:upper)}'"
512
+ " -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).camelcase(:upper)}'"
514
513
  # " -BlicenseType=" +
515
514
  # " -Bmac.category=" +
516
515
  # " -Bmac.signing-key-developer-id-app="
@@ -575,8 +574,8 @@ module Glimmer
575
574
  if %i[gem app desktopify].include?(shell_type)
576
575
  custom_shell_file_content += <<-MULTI_LINE_STRING
577
576
  before_body {
578
- Display.setAppName('#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}')
579
- Display.setAppVersion(VERSION)
577
+ Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
578
+ Display.app_version = VERSION
580
579
  @display = display {
581
580
  on_about {
582
581
  display_about_dialog
@@ -600,7 +599,7 @@ module Glimmer
600
599
  ## Use after_body block to setup observers for widgets in body
601
600
  #
602
601
  # after_body {
603
- #
602
+ #
604
603
  # }
605
604
 
606
605
  ## Add widget content inside custom shell body
@@ -616,10 +615,10 @@ module Glimmer
616
615
  MULTI_LINE_STRING
617
616
 
618
617
  if shell_type == :desktopify
619
- custom_shell_file_content += <<-MULTI_LINE_STRING
618
+ custom_shell_file_content += <<-MULTI_LINE_STRING
620
619
  browser {
621
- url "#{shell_options[:website]}"
622
- }
620
+ url "#{shell_options[:website]}"
621
+ }
623
622
  MULTI_LINE_STRING
624
623
  else
625
624
  custom_shell_file_content += <<-MULTI_LINE_STRING
@@ -628,7 +627,7 @@ module Glimmer
628
627
  text bind(self, :greeting)
629
628
  font height: 40
630
629
  layout_data :fill, :center, true, true
631
- }
630
+ }
632
631
  MULTI_LINE_STRING
633
632
  end
634
633
 
@@ -690,7 +689,7 @@ module Glimmer
690
689
  text 'Greeting'
691
690
  font style: :bold
692
691
  [
693
- 'Hello, World!',
692
+ 'Hello, World!',
694
693
  'Howdy, Partner!'
695
694
  ].each do |greeting_text|
696
695
  button(:radio) {
@@ -733,19 +732,19 @@ module Glimmer
733
732
  #
734
733
  #
735
734
  # before_body {
736
- #
735
+ #
737
736
  # }
738
737
 
739
738
  ## Use after_body block to setup observers for widgets in body
740
739
  #
741
740
  # after_body {
742
- #
741
+ #
743
742
  # }
744
743
 
745
744
  ## Add widget content under custom widget body
746
745
  ##
747
- ## If you want to add a shell as the top-most widget,
748
- ## consider creating a custom shell instead
746
+ ## If you want to add a shell as the top-most widget,
747
+ ## consider creating a custom shell instead
749
748
  ## (Glimmer::UI::CustomShell offers shell convenience methods, like show and hide)
750
749
  #
751
750
  body {
@@ -28,9 +28,9 @@ module Glimmer
28
28
  class Animation
29
29
  include Properties # TODO rename to Properties
30
30
 
31
- attr_reader :parent, :options, :frame_index
31
+ attr_reader :parent, :options, :frame_index, :cycle
32
32
  alias current_frame_index frame_index
33
- attr_accessor :frame_block, :every, :cycle, :cycle_count, :frame_count, :started
33
+ attr_accessor :frame_block, :every, :cycle_count, :frame_count, :started
34
34
  # TODO consider supporting an async: false option
35
35
 
36
36
  def initialize(parent)
@@ -43,43 +43,18 @@ module Glimmer
43
43
  @parent.on_widget_disposed { stop }
44
44
  start if @started
45
45
  end
46
-
46
+
47
47
  def start
48
- swt_display = Glimmer::SWT::DisplayProxy.instance.swt_display
49
- return if swt_display.is_disposed?
48
+ swt_display = DisplayProxy.instance.swt_display
50
49
  Thread.new do
51
- frame_rendering_block = lambda do
52
- block_args = [@frame_index]
53
- block_args << @cycle[@frame_index % @cycle.length] if @cycle.is_a?(Array)
54
- swt_display.async_exec do
55
- @parent.clear_shapes
56
- @parent.content {
57
- frame_block.call(*block_args)
58
- }
59
- end
60
- @frame_index += 1
61
- sleep(every) if every.is_a?(Numeric)
62
- end
63
-
64
50
  if cycle_count.is_a?(Integer) && cycle.is_a?(Array)
65
51
  (cycle_count * cycle.length).times do
66
- break if break_condition?
67
- begin
68
- frame_rendering_block.call
69
- rescue => e
70
- Glimmer::Config.logger.error {e}
71
- break
72
- end
52
+ break unless draw_frame(swt_display)
73
53
  end
74
54
  else
75
55
  loop do
76
- break if break_condition?
77
- begin
78
- frame_rendering_block.call
79
- rescue => e
80
- Glimmer::Config.logger.error {e}
81
- break
82
- end
56
+ # this code has to be duplicated to break from a loop (break keyword only works when literally in a loop block)
57
+ break unless draw_frame(swt_display)
83
58
  end
84
59
  end
85
60
  @started = false
@@ -102,11 +77,40 @@ module Glimmer
102
77
  send(ruby_attribute_getter(attribute_name))
103
78
  end
104
79
 
80
+ def cycle=(*args)
81
+ if args.size == 1
82
+ if args.first.is_a?(Array)
83
+ @cycle = args.first
84
+ else
85
+ @cycle = [args.first]
86
+ end
87
+ elsif args.size > 1
88
+ @cycle = args
89
+ end
90
+ end
91
+
105
92
  private
106
93
 
107
- def break_condition?
108
- !@started || (@frame_count.is_a?(Integer) && @frame_index == @frame_count)
94
+ # Returns true on success of painting a frame and false otherwise
95
+ def draw_frame(swt_display)
96
+ return false if !@started || (@frame_count.is_a?(Integer) && @frame_index == @frame_count)
97
+ block_args = [@frame_index]
98
+ block_args << @cycle[@frame_index % @cycle.length] if @cycle.is_a?(Array)
99
+ swt_display.async_exec do
100
+ @parent.clear_shapes
101
+ @parent.content {
102
+ frame_block.call(*block_args)
103
+ }
104
+ @parent.redraw
105
+ end
106
+ @frame_index += 1
107
+ sleep(every) if every.is_a?(Numeric)
108
+ true
109
+ rescue => e
110
+ Glimmer::Config.logger.error {e}
111
+ false
109
112
  end
113
+
110
114
  end
111
115
 
112
116
  end
@@ -55,7 +55,7 @@ module Glimmer
55
55
 
56
56
  attr_reader :parent, :name, :args, :options, :swt_widget, :paint_listener_proxy
57
57
 
58
- def initialize(parent, keyword, *args)
58
+ def initialize(parent, keyword, *args, &property_block)
59
59
  @parent = parent
60
60
  @name = keyword
61
61
  @method_name = self.class.method_name(keyword, args)
@@ -64,6 +64,7 @@ module Glimmer
64
64
  @swt_widget = parent.respond_to?(:swt_display) ? parent.swt_display : parent.swt_widget
65
65
  @properties = {}
66
66
  @parent.shapes << self
67
+ post_add_content if property_block.nil?
67
68
  end
68
69
 
69
70
  def fill?
@@ -76,11 +77,15 @@ module Glimmer
76
77
 
77
78
  def post_add_content
78
79
  event_handler = lambda do |event|
80
+ @properties['background'] = [DisplayProxy.instance.get_system_color(SWTProxy(:color_widget_background))] if fill? && !@properties.keys.map(&:to_s).include?('background')
81
+ @properties['foreground'] = [ColorProxy.new(0, 0, 0)] if draw? && !@properties.keys.map(&:to_s).include?('foreground')
79
82
  @properties.each do |property, args|
80
83
  method_name = attribute_setter(property)
81
- handle_conversions(method_name, args)
84
+ apply_property_arg_conversions(method_name, args)
82
85
  event.gc.send(method_name, *args)
83
86
  end
87
+ apply_shape_arg_conversions(@method_name, @args)
88
+ apply_shape_arg_defaults(@method_name, @args)
84
89
  event.gc.send(@method_name, *@args)
85
90
  end
86
91
  if parent.respond_to?(:swt_display)
@@ -90,28 +95,42 @@ module Glimmer
90
95
  end
91
96
  end
92
97
 
93
- def handle_conversions(method_name, args)
98
+ def apply_property_arg_conversions(method_name, args)
94
99
  the_java_method = org.eclipse.swt.graphics.GC.java_class.declared_instance_methods.detect {|m| m.name == method_name}
95
- if args.first.is_a?(Symbol) || args.first.is_a?(String)
100
+ if (args.first.is_a?(Symbol) || args.first.is_a?(String))
96
101
  if the_java_method.parameter_types.first == Color.java_class
97
102
  args[0] = ColorProxy.new(args[0])
98
103
  end
104
+ if the_java_method.parameter_types.first == Java::int.java_class
105
+ args[0] = SWTProxy[args[0]]
106
+ end
99
107
  end
100
108
  if args.first.is_a?(ColorProxy)
101
109
  args[0] = args[0].swt_color
102
110
  end
103
- if args.first.is_a?(Hash)
104
- if the_java_method.parameter_types.first == Font.java_class
105
- args[0] = FontProxy.new(args[0])
106
- end
111
+ if args.first.is_a?(Hash) && the_java_method.parameter_types.first == Font.java_class
112
+ args[0] = FontProxy.new(args[0])
107
113
  end
108
114
  if args.first.is_a?(FontProxy)
109
115
  args[0] = args[0].swt_font
110
116
  end
111
-
112
- # TODO convert SWT style symbol to integer if method takes integer
113
117
  end
114
118
 
119
+ def apply_shape_arg_conversions(method_name, args)
120
+ if args.size > 1 && (method_name.include?('polygon') || method_name.include?('polyline'))
121
+ args[0] = args.dup
122
+ args[1..-1] = []
123
+ end
124
+ end
125
+
126
+ def apply_shape_arg_defaults(method_name, args)
127
+ if method_name.include?('round_rectangle') && args.size.between?(4, 5)
128
+ (6 - args.size).times {args << 60}
129
+ elsif method_name.include?('gradient_rectangle') && args.size == 4
130
+ args << true
131
+ end
132
+ end
133
+
115
134
  def has_attribute?(attribute_name, *args)
116
135
  # TODO test that attribute getter responds too
117
136
  self.class.gc_instance_methods.include?(attribute_setter(attribute_name))
@@ -56,6 +56,7 @@ module Glimmer
56
56
  attr_reader :swt_display
57
57
 
58
58
  def initialize(*args)
59
+ Display.app_name ||= 'Glimmer'
59
60
  @swt_display = Display.new(*args)
60
61
  @swt_display.set_data('proxy', self)
61
62
  end
@@ -150,7 +150,7 @@ class MetaSampleApplication
150
150
  end
151
151
 
152
152
  def launch
153
- Display.setAppName('Glimmer Meta-Sample')
153
+ Display.app_name = 'Glimmer Meta-Sample'
154
154
  shell {
155
155
  minimum_size 1280, 768
156
156
  text 'Glimmer Meta-Sample (The Sample of Samples)'
@@ -1,31 +1,10 @@
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
1
  include Glimmer
23
2
 
24
3
  shell {
25
4
  text 'Hello, Canvas!'
26
5
  minimum_size 320, 400
27
6
 
28
- canvas {
7
+ canvas { |prox|
29
8
  background :yellow
30
9
  rectangle(0, 0, 220, 400, fill: true) {
31
10
  background :red
@@ -41,8 +20,8 @@ shell {
41
20
  background :magenta
42
21
  foreground :dark_blue
43
22
  }
44
- rectangle(200, 80, 108, 36) {
45
- foreground color(:dark_blue)
23
+ rectangle(205, 50, 88, 96) {
24
+ foreground color(:yellow)
46
25
  }
47
26
  text('Picasso', 60, 80) {
48
27
  background :yellow
@@ -55,8 +34,10 @@ shell {
55
34
  arc(210, 210, 100, 100, 30, -77, fill: true) {
56
35
  background :red
57
36
  }
58
- polygon([250, 210, 260, 170, 270, 210, 290, 230, 250, 210]) {
37
+ polygon(250, 210, 260, 170, 270, 210, 290, 230, 250, 210, fill: true) {
59
38
  background :dark_yellow
39
+ foreground :yellow
60
40
  }
41
+ polygon(250, 110, 260, 70, 270, 110, 290, 130, 250, 110)
61
42
  }
62
43
  }.open
@@ -35,7 +35,7 @@ shell {
35
35
  oval(0, 0, 400, 400) { # x, y, width, height
36
36
  foreground :black # sets oval background color
37
37
  }
38
- arc(0, 0, 400, 400, -1*index%360, 10, fill: true) { # x, y, width, height, start angle, arc angle
38
+ arc(0, 0, 400, 400, -1.4*index%360, 10, fill: true) { # x, y, width, height, start angle, arc angle
39
39
  background rgb(200, 200, 50) # sets arc background color
40
40
  }
41
41
  }
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.18.1.0
4
+ version: 4.18.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement