glimmer-dsl-opal 0.15.1 → 0.17.0

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: 724c0f462ad5dd94ef3eb8705f6ceb54b350c0f83976a6a7bb3f0506afe67f65
4
- data.tar.gz: 0ba2076cb72f46bbe855c746e80c3747d0d2834f73167266fb42752d873e6290
3
+ metadata.gz: 8ceab7c0ff7d7ef07cca7f798cfd6f1aa6d4e18b2aaa23d34ded024c491becec
4
+ data.tar.gz: cf4474df385496aad3d0519bd45f69cc51d185a0c7c60e0f941796bfd623cca7
5
5
  SHA512:
6
- metadata.gz: c52727efe6e7efc09cffe80991ccddf6fb4ee69835ecb46f21321ab912997980f6dd9ba9fc68117ce5864f61d63809037139d64b741ff509f66dfda09a2ab0a1
7
- data.tar.gz: e00c6998ab192d91340f27567c29b2b6ee63a65680ec316d0a3c74353c0905a04ed2f3771423b527c7441ee6d2dd8870d7c758a09e8151dd0223a4e6053f8a7a
6
+ metadata.gz: 99bb2e0b9a22b384eb78774d814ff9b15e6662d89f5e2ad402fc980da644cb3392b0c567d861b696ddbd77a889f40393b64ec8ed0059622114e1f703f52bfbb7
7
+ data.tar.gz: 4b3a76c993f70c32d0133678d5424ead94925836ffe1a45994879df165b008827bd5c9a6e8b107c32717bfeca82a86dad699363a9a36b640d2c1e5929eb91e38
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.17.0
4
+
5
+ - Support `menu` `visible` attribute to enable programmatic display of menu
6
+ - Support `arrow` widget
7
+ - Hello, Arrow! sample
8
+
9
+ ## 0.16.2
10
+
11
+ - Support `grid_layout` `margin_top`, `margin_right`, `margin_bottom`, and `margin_left` attributes
12
+ - Support `row_layout` `wrap` and `justify` attributes
13
+ - Hello, Layout! sample
14
+ - Partial CGI implementation to have `escapeHTML` (alias: `escape_html`) method
15
+ - HTML Escape label text content
16
+ - Fix issue with `row_layout` `fill` attribute not working
17
+
18
+ ## 0.16.1
19
+
20
+ - Support `grid_layout` `make_columns_equal_width`, `horizontal_spacing`, and `vertical_spacing` attributes
21
+ - Hello, Composite! sample
22
+
23
+ ## 0.16.0
24
+
25
+ - Support label widget background_image attribute
26
+ - Have File.expand_path support expanding paths even if they did not base off of __dir__ or __FILE__
27
+ - Custom specification of gems having image paths via server-side configuration in Glimmer::Config.gems_having_image_paths
28
+
3
29
  ## 0.15.1
4
30
 
5
31
  - Auto-expose images of gems that depend on glimmer-dsl-opal as downloadable asset links providing `/glimmer/image_paths` server call to obtain them
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 Opal 0.15.1 (Pure Ruby Web GUI)
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 Opal 0.17.0 (Pure Ruby Web GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
3
3
  [![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)
4
4
 
@@ -14,6 +14,8 @@ Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com
14
14
 
15
15
  #### Hello, Table! Sample
16
16
 
17
+ Code: [lib/glimmer-dsl-opal/samples/hello/hello_table.rb](lib/glimmer-dsl-opal/samples/hello/hello_table.rb)
18
+
17
19
  Glimmer GUI code from [glimmer-dsl-opal/samples/hello/hello_table.rb](lib/glimmer-dsl-opal/samples/hello/hello_table.rb):
18
20
 
19
21
  ```ruby
@@ -141,7 +143,7 @@ Hello, Table! Game Booked
141
143
 
142
144
  NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
143
145
 
144
- **Alpha Version** 0.15.1 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
146
+ **Alpha Version** 0.17.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
145
147
 
146
148
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
147
149
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -151,7 +153,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
151
153
 
152
154
  ## Table of Contents
153
155
 
154
- - [Glimmer DSL for Opal 0.15.1 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0151-pure-ruby-web-gui)
156
+ - [Glimmer DSL for Opal 0.17.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0170-pure-ruby-web-gui)
155
157
  - [Principles](#principles)
156
158
  - [Background](#background)
157
159
  - [Pre-requisites](#pre-requisites)
@@ -161,6 +163,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
161
163
  - [Hello Samples](#hello-samples)
162
164
  - [Hello, World!](#hello-world)
163
165
  - [Hello, Combo!](#hello-combo)
166
+ - [Hello, Composite!](#hello-composite)
164
167
  - [Hello, Computed!](#hello-computed)
165
168
  - [Hello, List Single Selection!](#hello-list-single-selection)
166
169
  - [Hello, List Multi Selection!](#hello-list-multi-selection)
@@ -221,7 +224,8 @@ Alternatively, web developers may directly use [Glimmer DSL for Opal](https://ru
221
224
  ## Pre-requisites
222
225
 
223
226
  - Rails 5: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
224
- - Opal 1: [https://github.com/opal/opal-rails](https://github.com/opal/opal-rails)
227
+ - Opal 1.0.4: [https://github.com/opal/opal](https://github.com/opal/opal)
228
+ - Opal-Rails 1.1.2: [https://github.com/opal/opal-rails](https://github.com/opal/opal-rails)
225
229
  - jQuery 3: [https://code.jquery.com/](https://code.jquery.com/) (jQuery 3.5.1 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
226
230
  - jQuery-UI 1.12: [https://code.jquery.com/](https://jqueryui.com/) (jQuery-UI 1.12.1 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
227
231
  - jQuery-UI Timepicker 0.3: [https://code.jquery.com/](https://fgelinas.com/code/timepicker/) (jQuery-UI Timepicker 0.3.3 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
@@ -249,10 +253,11 @@ rails new glimmer_app_server
249
253
  Add the following to `Gemfile`:
250
254
 
251
255
  ```
252
- gem 'opal-rails', '~> 1.1.2'
256
+ gem 'opal', '1.0.4'
257
+ gem 'opal-rails', '1.1.2'
253
258
  gem 'opal-async', '~> 1.2.0'
254
259
  gem 'opal-jquery', '~> 0.4.4'
255
- gem 'glimmer-dsl-opal', '~> 0.15.1'
260
+ gem 'glimmer-dsl-opal', '~> 0.17.0'
256
261
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
257
262
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
258
263
 
@@ -316,6 +321,7 @@ shell {
316
321
  The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have fully functional partial support in Opal:
317
322
 
318
323
  Widgets:
324
+ - `arrow`: featured in [Hello, Arrow!](#hello-arrow)
319
325
  - `button`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Message Box!](#hello-message-box) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
320
326
  - `browser`: featured in [Hello, Browser!](#hello-browser)
321
327
  - `calendar`: featured in [Hello, Date Time!](#hello-date-time)
@@ -488,7 +494,7 @@ HelloCombo.launch
488
494
  ```
489
495
  Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
490
496
 
491
- ![Glimmer DSL for SWT Hello Combo](https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-hello-combo.png)
497
+ ![Glimmer DSL for SWT Hello Combo](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/images/glimmer-hello-combo.png)
492
498
 
493
499
  Glimmer app on the web (using `glimmer-dsl-opal` gem):
494
500
 
@@ -503,6 +509,31 @@ You should see "Hello, Combo!"
503
509
 
504
510
  ![Glimmer DSL for Opal Hello Combo](images/glimmer-dsl-opal-hello-combo.png)
505
511
 
512
+ #### Hello, Composite!
513
+
514
+ Add the following require statement to `app/assets/javascripts/application.rb`
515
+
516
+ ```ruby
517
+ require 'glimmer-dsl-opal/samples/hello/hello_composite'
518
+ ```
519
+
520
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
521
+
522
+ ![Glimmer DSL for SWT Hello Composite](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/images/glimmer-hello-composite.png)
523
+
524
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
525
+
526
+ Start the Rails server:
527
+ ```
528
+ rails s
529
+ ```
530
+
531
+ Visit `http://localhost:3000`
532
+
533
+ You should see "Hello, Composite!"
534
+
535
+ ![Glimmer DSL for Opal Hello Composite](images/glimmer-dsl-opal-hello-composite.png)
536
+
506
537
  #### Hello, Computed!
507
538
 
508
539
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -626,6 +657,58 @@ You should see "Hello, Computed!"
626
657
 
627
658
  ![Glimmer DSL for Opal Hello Computed](images/glimmer-dsl-opal-hello-computed.png)
628
659
 
660
+ #### Hello, Layout!
661
+
662
+ Add the following require statement to `app/assets/javascripts/application.rb`
663
+
664
+
665
+ ```ruby
666
+ require 'glimmer-dsl-opal/samples/hello/hello_layout'
667
+ ```
668
+
669
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
670
+
671
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab1.png)
672
+
673
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab2.png)
674
+
675
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab3.png)
676
+
677
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab4.png)
678
+
679
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab5.png)
680
+
681
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab6.png)
682
+
683
+ ![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab7.png)
684
+
685
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
686
+
687
+ Start the Rails server:
688
+ ```
689
+ rails s
690
+ ```
691
+
692
+ Visit `http://localhost:3000`
693
+
694
+ You should see "Hello, Layout!"
695
+
696
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab1.png)
697
+
698
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab2.png)
699
+
700
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab3.png)
701
+
702
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab4.png)
703
+
704
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab4-shrunk.png)
705
+
706
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab5.png)
707
+
708
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab6.png)
709
+
710
+ ![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab7.png)
711
+
629
712
  #### Hello, List Single Selection!
630
713
 
631
714
  Add the following require statement to `app/assets/javascripts/application.rb`
@@ -677,6 +760,39 @@ You should see "Hello, List Multi Selection!"
677
760
 
678
761
  ![Glimmer DSL for Opal Hello List Multi Selection](images/glimmer-dsl-opal-hello-list-multi-selection.png)
679
762
 
763
+ #### Hello, Arrow!
764
+
765
+ Add the following require statement to `app/assets/javascripts/application.rb`
766
+
767
+ ```ruby
768
+ require 'glimmer-dsl-opal/samples/hello/hello_arrow'
769
+ ```
770
+
771
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
772
+
773
+ ![Glimmer DSL for SWT Hello Arrow](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-arrow.png)
774
+
775
+ ![Glimmer DSL for SWT Hello Arrow](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-arrow-menu.png)
776
+
777
+ ![Glimmer DSL for SWT Hello Arrow](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-arrow-item-selected.png)
778
+
779
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
780
+
781
+ Start the Rails server:
782
+ ```
783
+ rails s
784
+ ```
785
+
786
+ Visit `http://localhost:3000`
787
+
788
+ You should see "Hello, Arrow!"
789
+
790
+ ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow.png)
791
+
792
+ ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow-menu.png)
793
+
794
+ ![Glimmer DSL for Opal Hello Arrow](images/glimmer-dsl-opal-hello-arrow-item-selected.png)
795
+
680
796
  #### Hello, Browser!
681
797
 
682
798
  Add the following require statement to `app/assets/javascripts/application.rb`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.1
1
+ 0.17.0
@@ -3,8 +3,13 @@ require 'fileutils'
3
3
  module Glimmer
4
4
  class ImagePathsController < ApplicationController
5
5
  def index
6
+ # TODO apply caching in the future to avoid recopying files on every request
6
7
  Gem.loaded_specs.map(&:last).select {|s| s.name == 'glimmer-dsl-opal' || s.dependencies.detect {|dep| dep.name == 'glimmer-dsl-opal'} }
7
- full_gem_specs = Gem.loaded_specs.map(&:last).select {|s| s.name == 'glimmer-dsl-opal' || s.dependencies.detect {|dep| dep.name == 'glimmer-dsl-swt'} }
8
+ full_gem_specs = Gem.loaded_specs.map(&:last).select do |s|
9
+ s.name == 'glimmer-dsl-opal' ||
10
+ Glimmer::Config.gems_having_image_paths.to_a.include?(s.name) || # consider turning into a Glimmer::Config server-side option
11
+ s.dependencies.detect {|dep| dep.name == 'glimmer-dsl-swt'}
12
+ end
8
13
  full_gem_paths = full_gem_specs.map {|gem_spec| gem_spec.full_gem_path}
9
14
  full_gem_names = full_gem_paths.map {|path| File.basename(path)}
10
15
  full_gem_image_path_collections = full_gem_paths.map do |gem_path|
@@ -32,7 +37,7 @@ module Glimmer
32
37
  end
33
38
  end
34
39
  download_gem_image_paths = download_gem_image_paths.map {|p| "/assets/#{p}"}
35
-
40
+
36
41
  # TODO apply a security white list
37
42
  render json: download_gem_image_paths
38
43
  end
data/lib/cgi.rb ADDED
@@ -0,0 +1,14 @@
1
+ class CGI
2
+ class << self
3
+ def escapeHTML(string)
4
+ string.
5
+ gsub('&', '&amp;').
6
+ gsub('<', '&lt;').
7
+ gsub('>', '&gt;').
8
+ gsub("'", '&apos;').
9
+ gsub('"', '&quot;')
10
+ end
11
+ alias escape_html escapeHTML
12
+
13
+ end
14
+ end
@@ -50,6 +50,7 @@ if RUBY_ENGINE == 'opal'
50
50
  require 'to_collection'
51
51
  require 'pure-struct'
52
52
  require 'os'
53
+ require 'cgi'
53
54
  require 'file'
54
55
  require 'display'
55
56
  require 'glimmer-dsl-opal/vendor/jquery'
@@ -102,5 +103,6 @@ if RUBY_ENGINE == 'opal'
102
103
  result ||= method == 'handle'
103
104
  end
104
105
  else
106
+ require_relative 'glimmer/config'
105
107
  require_relative 'glimmer/engine'
106
108
  end
@@ -37,22 +37,16 @@ class File
37
37
  alias expand_path_without_glimmer expand_path
38
38
  def expand_path(path, base=nil)
39
39
  get_image_paths unless image_paths
40
- if base
41
- path = expand_path_without_glimmer(path, base)
42
- end
40
+ path = expand_path_without_glimmer(path, base) if base
43
41
  path_include_dir_or_file = !!path.match(REGEXP_DIR_FILE)
44
- if !path_include_dir_or_file
45
- path
46
- else
47
- essential_path = path.split('(dir)').last.split('(file)').last
48
- image_paths.detect do |image_path|
49
- image_path.include?(essential_path)
50
- end
42
+ essential_path = path.split('(dir)').last.split('(file)').last.split('../').last.split('./').last
43
+ image_paths.detect do |image_path|
44
+ image_path.include?(essential_path)
51
45
  end
52
46
  end
53
47
 
54
48
  def get_image_paths
55
- image_paths_json = Net::HTTP.get(`window.location.origin`, '/glimmer/image_paths.json')
49
+ image_paths_json = Net::HTTP.get(`window.location.origin`, "/glimmer/image_paths.json")
56
50
  self.image_paths = JSON.parse(image_paths_json)
57
51
  end
58
52
 
@@ -0,0 +1,65 @@
1
+ # Copyright (c) 2020-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
+ include Glimmer
23
+
24
+ shell {
25
+ row_layout(:vertical) {
26
+ fill true
27
+ center true
28
+ }
29
+
30
+ text 'Hello, Arrow!'
31
+
32
+ label(:center) {
33
+ text 'Click the arrow to get a menu.'
34
+ }
35
+
36
+ arrow { # can be customized by passing `:arrow` SWT style + `:left`, `:right`, `:up`, or `:down` (default)
37
+ @menu = menu {
38
+ menu_item {
39
+ text 'Item &1'
40
+
41
+ on_widget_selected do
42
+ message_box {
43
+ text 'Item 1'
44
+ message 'Item 1 selected!'
45
+ }.open
46
+ end
47
+ }
48
+ menu_item {
49
+ text 'Item &2'
50
+
51
+ on_widget_selected do
52
+ message_box {
53
+ text 'Item 2'
54
+ message 'Item 2 selected!'
55
+ }.open
56
+ end
57
+ }
58
+ }
59
+
60
+ on_widget_selected do |event|
61
+ event.widget.menu.visible = true
62
+ end
63
+ }
64
+
65
+ }.open
@@ -0,0 +1,69 @@
1
+ # Copyright (c) 2020-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 HelloComposite
23
+ include Glimmer::UI::CustomShell
24
+
25
+ body {
26
+ shell {
27
+ # shell (which is a composite) has fill_layout(:horizontal) by default with no margins
28
+ # we override below
29
+ fill_layout(:vertical)
30
+ text 'Hello, Composite!'
31
+
32
+ composite { # composite simply contains widgets for visual organization via a layout
33
+ # it has grid_layout(1, false) as its default layout
34
+ label {
35
+ text "Field is above its text widget"
36
+ }
37
+ text {
38
+ layout_data :fill, :center, true, false # fill horizontally, align center vertically, grab remaining horizontal space, but not vertical
39
+ }
40
+ }
41
+
42
+ composite { # composite simply contains widgets for visual organization via a layout
43
+ grid_layout 2, true
44
+
45
+ label {
46
+ text "Field has equal width to its text widget's"
47
+ }
48
+ text {
49
+ layout_data :fill, :center, true, false # fill horizontally, align center vertically, grab remaining horizontal space, but not vertical
50
+ }
51
+ }
52
+
53
+ composite { # composite simply contains widgets for visual organization via a layout
54
+ grid_layout 2, false
55
+
56
+ label {
57
+ text "Field has inequal width"
58
+ }
59
+
60
+ text {
61
+ layout_data :fill, :center, true, false # fill horizontally, align center vertically, grab remaining horizontal space, but not vertical
62
+ }
63
+ }
64
+ }
65
+
66
+ }
67
+ end
68
+
69
+ HelloComposite.launch