glimmer-dsl-libui 0.9.4 → 0.9.6

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: 916c5f10df3886ef6a5eed0ba6cbade95141812b5f5ab302ba3fb6dc0449a989
4
- data.tar.gz: 6558bc6824e050a4f36c8d89d8ee2eded34017e2f931905f7469e045e56ab5e7
3
+ metadata.gz: 06c9ed7f6b104ec0f5a034ee6f74fa2398de9b1d11ffea2e2d1448f07e2c7e43
4
+ data.tar.gz: 48591881860e3317e2e79a88840fcb0b51d093ba017e0b74dc45e8382ead00b3
5
5
  SHA512:
6
- metadata.gz: 5395eb43d9bc4a6aee0a18d498334a15475bd17cd976853bfb79c831eb55cdda6d68a9f8f04d62586d6d442004f0c74cef96f4f11e2ac53a08fba100813f989d
7
- data.tar.gz: 8d8ed838367b768e7c18d47027f0b8a11d5728bf578339867b60411566dec0ada11294f9691008489f8fedaf971548d0c8bdc927f1b2f53f8f3de0a8e9a90b01
6
+ metadata.gz: d17b5b51140d69186f2237efffdce6a9e65ec675e568fcb96c911593cb934392ad423da0ea64e75573ef5d657f3690b87a3bca9723e04ca103922b98204e24a1
7
+ data.tar.gz: 658eb9d2fa4b00a7c4edbb85ef42dbbb3b81f04e4c16e3ccd93715e252a726317bd6fec59081047d6b6698bfb38ab8594413afee6638eccc2373ccb0a8830fcd
data/CHANGELOG.md CHANGED
@@ -1,8 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.6
4
+
5
+ - Scaffold Custom Window Gem via `glimmer scaffold:gem:customwindow[name,namespace]` (or alias: `glimmer scaffold:gem:cw[name,namespace]`)
6
+ - List Custom Window Gems (expected name format: `glimmer-libui-cw-gemname-namespace`) via `glimmer list:gems:customwindow[query]` (or alias: `glimmer list:gems:cw[query]`)
7
+ - List Glimmer DSLs via `glimmer list:gems:dsl[query]`
8
+
9
+ ## 0.9.5
10
+
11
+ - Scaffold Custom Control via `glimmer scaffold:customcontrol[name,namespace]` (or alias: `glimmer scaffold:cc[name,namespace]`)
12
+
3
13
  ## 0.9.4
4
14
 
5
- - Scaffold Custom Window via `glimmer scaffold:customwindow[name,namespace]`
15
+ - Scaffold Custom Window via `glimmer scaffold:customwindow[name,namespace]` (or alias: `glimmer scaffold:cw[name,namespace]`)
6
16
 
7
17
  ## 0.9.3
8
18
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.9.4
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.9.6
2
2
  ## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
@@ -28,7 +28,7 @@ The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/gl
28
28
  - Requiring the [least amount of syntax](#glimmer-gui-dsl-concepts) possible to build GUI
29
29
  - [Custom Control](#custom-keywords) support
30
30
  - [Bidirectional/Unidirectional Data-Binding](#data-binding) to declaratively wire and automatically synchronize GUI Views with Models
31
- - [Scaffolding](scaffold-application) for new custom controls, apps, and gems
31
+ - [Scaffolding](#scaffold-application) for new custom windows/controls, apps, and gems
32
32
  - [Far Future Plan] Native-Executable packaging on Mac, Windows, and Linux.
33
33
 
34
34
  Hello, World!
@@ -352,6 +352,10 @@ Learn more about the differences between various [Glimmer](https://github.com/An
352
352
  - [Run Examples](#run-examples)
353
353
  - [Scaffold Application](#scaffold-application)
354
354
  - [Scaffold Custom Window](#scaffold-custom-window)
355
+ - [Scaffold Custom Control](#scaffold-custom-control)
356
+ - [Scaffold Custom Window Gem](#scaffold-custom-window-gem)
357
+ - [List Custom Window Gems](#list-custom-window-gems)
358
+ - [List Glimmer DSLs](#list-glimmer-dsls)
355
359
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
356
360
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
357
361
  - [API](#api)
@@ -422,7 +426,7 @@ gem install glimmer-dsl-libui
422
426
  Or install via Bundler `Gemfile`:
423
427
 
424
428
  ```ruby
425
- gem 'glimmer-dsl-libui', '~> 0.9.4'
429
+ gem 'glimmer-dsl-libui', '~> 0.9.6'
426
430
  ```
427
431
 
428
432
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -738,9 +742,9 @@ When you are in a scaffolded application, you can scaffold a new custom window (
738
742
  glimmer scaffold:customwindow[name,namespace]
739
743
  ```
740
744
 
741
- The name represents the custom window view class name (it can be underscored, and Glimmer will automatically classify it).
745
+ The `name` represents the custom window view class name (it can be underscored, and Glimmer will automatically classify it).
742
746
 
743
- The namespace is optional and represents the module that the custom window view class will live under. If left off, the main application class namespace is used (e.g. the top-level `HelloWorld` class namespace for a `hello_world` application).
747
+ The `namespace` is optional and represents the module that the custom window view class will live under. If left off, the main application class namespace is used (e.g. the top-level `HelloWorld` class namespace for a `hello_world` application).
744
748
 
745
749
  You can also use the shorter `cw` alias for `customwindow`:
746
750
 
@@ -803,7 +807,7 @@ class HelloWorld
803
807
  end
804
808
  ```
805
809
 
806
- When the generated file is required in another view, the custom window keyword `greeting_window` become available and reusable, like by calling:
810
+ When the generated file is required in another view (e.g. `require 'hello_world/view/greeting_window'`), the custom window keyword `greeting_window` become available and reusable, like by calling:
807
811
 
808
812
  ```ruby
809
813
  greeting_window.show
@@ -864,7 +868,7 @@ module Station
864
868
  end
865
869
  ```
866
870
 
867
- When that file is required, the `train` keyword becomes available:
871
+ When that file is required in another view (e.g. `require 'station/view/train'`), the `train` keyword becomes available:
868
872
 
869
873
  ```ruby
870
874
  train.show
@@ -882,6 +886,282 @@ Or another `train` custom window view:
882
886
  hello_world__view__train.show
883
887
  ```
884
888
 
889
+ ### Scaffold Custom Control
890
+
891
+ When you are in a scaffolded application, you can scaffold a new custom control (a control that you can put anything in to represent a view concept in your application) by running this command:
892
+
893
+ ```
894
+ glimmer scaffold:customcontrol[name,namespace]
895
+ ```
896
+
897
+ The `name` represents the custom control view class name (it can be underscored, and Glimmer will automatically classify it).
898
+
899
+ The `namespace` is optional and represents the module that the custom control view class will live under. If left off, the main application class namespace is used (e.g. the top-level `HelloWorld` class namespace for a `hello_world` application).
900
+
901
+ You can also use the shorter `cc` alias for `customcontrol`:
902
+
903
+ ```
904
+ glimmer scaffold:cc[name,namespace]
905
+ ```
906
+
907
+ For example by running this command under a `hello_world` application:
908
+
909
+ ```
910
+ glimmer scaffold:cw[model_form]
911
+ ```
912
+
913
+ That will generate this class under `app/hello_world/view/model_form`:
914
+
915
+ ```ruby
916
+ class HelloWorld
917
+ module View
918
+ class ModelForm
919
+ include Glimmer::LibUI::CustomControl
920
+
921
+ ## Add options like the following to configure CustomControl by outside consumers
922
+ #
923
+ # options :custom_text, :background_color
924
+ # option :foreground_color, default: :red
925
+
926
+ # Replace example options with your own options
927
+ option :model
928
+ option :attributes
929
+
930
+ ## Use before_body block to pre-initialize variables to use in body
931
+ #
932
+ #
933
+ before_body do
934
+ # Replace example code with your own before_body code
935
+ default_model_attributes = [:first_name, :last_name, :email]
936
+ default_model_class = Struct.new(*default_model_attributes)
937
+ self.model ||= default_model_class.new
938
+ self.attributes ||= default_model_attributes
939
+ end
940
+
941
+ ## Use after_body block to setup observers for controls in body
942
+ #
943
+ # after_body do
944
+ #
945
+ # end
946
+
947
+ ## Add control content under custom control body
948
+ ##
949
+ ## If you want to add a window as the top-most control,
950
+ ## consider creating a custom window instead
951
+ ## (Glimmer::LibUI::CustomWindow offers window convenience methods, like show and hide)
952
+ #
953
+ body {
954
+ # Replace example content (model_form custom control) with your own custom control content.
955
+ form {
956
+ attributes.each do |attribute|
957
+ entry { |e|
958
+ label attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')
959
+ text <=> [model, attribute]
960
+ }
961
+ end
962
+ }
963
+ }
964
+
965
+ end
966
+ end
967
+ end
968
+ ```
969
+
970
+ When the generated file is required in another view (e.g. `require 'hello_world/view/model_form'`), the custom control keyword `model_form` become available and reusable, like by calling:
971
+
972
+ ```ruby
973
+ window {
974
+ vertical_box {
975
+ label('Form:')
976
+ model_form(model: some_model, attributes: array_of_attributes)
977
+ }
978
+ }
979
+ ```
980
+
981
+ Here is an example that generates a custom control with a namespace:
982
+
983
+ ```
984
+ glimmer scaffold:cw[model_form,common]
985
+ ```
986
+
987
+ That will generate this class under `app/common/view/model_form`:
988
+
989
+ ```ruby
990
+ module Common
991
+ module View
992
+ class ModelForm
993
+ include Glimmer::LibUI::CustomControl
994
+
995
+ ## Add options like the following to configure CustomControl by outside consumers
996
+ #
997
+ # options :custom_text, :background_color
998
+ # option :foreground_color, default: :red
999
+
1000
+ # Replace example options with your own options
1001
+ option :model
1002
+ option :attributes
1003
+
1004
+ ## Use before_body block to pre-initialize variables to use in body
1005
+ #
1006
+ #
1007
+ before_body do
1008
+ # Replace example code with your own before_body code
1009
+ default_model_attributes = [:first_name, :last_name, :email]
1010
+ default_model_class = Struct.new(*default_model_attributes)
1011
+ self.model ||= default_model_class.new
1012
+ self.attributes ||= default_model_attributes
1013
+ end
1014
+
1015
+ ## Use after_body block to setup observers for controls in body
1016
+ #
1017
+ # after_body do
1018
+ #
1019
+ # end
1020
+
1021
+ ## Add control content under custom control body
1022
+ ##
1023
+ ## If you want to add a window as the top-most control,
1024
+ ## consider creating a custom window instead
1025
+ ## (Glimmer::LibUI::CustomWindow offers window convenience methods, like show and hide)
1026
+ #
1027
+ body {
1028
+ # Replace example content (model_form custom control) with your own custom control content.
1029
+ form {
1030
+ attributes.each do |attribute|
1031
+ entry { |e|
1032
+ label attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')
1033
+ text <=> [model, attribute]
1034
+ }
1035
+ end
1036
+ }
1037
+ }
1038
+
1039
+ end
1040
+ end
1041
+ end
1042
+ ```
1043
+
1044
+ When that file is required in another view (e.g. `require 'common/view/model_form'`), the `model_form` keyword becomes available:
1045
+
1046
+ ```ruby
1047
+ window {
1048
+ vertical_box {
1049
+ label('Form:')
1050
+ model_form(model: some_model, attributes: array_of_attributes)
1051
+ }
1052
+ }
1053
+ ```
1054
+
1055
+ If for whatever reason, you end up with 2 custom control views having the same name with different namespaces, then you can invoke the specific custom control you want by including the Ruby namespace in underscored format separated by double-underscores:
1056
+
1057
+ ```ruby
1058
+ window {
1059
+ vertical_box {
1060
+ label('Form:')
1061
+ common__view__model_form(model: some_model, attributes: array_of_attributes)
1062
+ }
1063
+ }
1064
+ ```
1065
+
1066
+ Or another `model_form` custom control view:
1067
+
1068
+ ```ruby
1069
+ window {
1070
+ vertical_box {
1071
+ label('Form:')
1072
+ hello_world__view__model_form(model: some_model, attributes: array_of_attributes)
1073
+ }
1074
+ }
1075
+ ```
1076
+
1077
+ ### Scaffold Custom Window Gem
1078
+
1079
+ You can scaffold a Ruby gem around a reusable Custom Window by running this command:
1080
+
1081
+ ```
1082
+ glimmer scaffold:gem:customwindow[name,namespace]
1083
+ ```
1084
+
1085
+ That will generate a custom window gem project under the naming convention: `glimmer-libui-cw-name-namespace`
1086
+
1087
+ The naming convention helps with discoverability of Ruby gems using the command `glimmer list:gems:customwindow[query]` (or alias: `glimmer list:gems:cw[query]`) where filtering `query` is optional.
1088
+
1089
+ The `name` is the custom window class name, which must not contain dashes by convention (multiple words can be concatenated or can use underscores between them).
1090
+
1091
+ The `namespace` is needed to avoid clashing with other custom window gems that other software engineers might have thought of. It is recommended not to include dashes between words in it by convention yet concatenated words or underscores between them.
1092
+
1093
+ Here is a shorter alias for the custom window gem scaffolding command:
1094
+
1095
+ ```
1096
+ glimmer scaffold:gem:cw[name,namespace]
1097
+ ```
1098
+
1099
+ You can package the newly scaffolded project as a Ruby gem by running this command:
1100
+
1101
+ ```
1102
+ glimmer package:gem
1103
+ ```
1104
+
1105
+ Or by using the raw rake command:
1106
+
1107
+ ```
1108
+ rake build
1109
+ ```
1110
+
1111
+ You can generate the application gemspec explicitly if needed with this command (though it is not needed to build the gem):
1112
+
1113
+ ```
1114
+ glimmer package:gemspec
1115
+ ```
1116
+
1117
+ Or by using the raw rake command:
1118
+
1119
+ ```
1120
+ rake gemspec:generate
1121
+ ```
1122
+
1123
+ The project optionally allows you to run the custom window as its own separate app with a binary script (`bin/gem_name`) to see it, which helps with prototyping it.
1124
+
1125
+ But, typically consumers of the gem would include it in their own project, which makes the gem keyword available in the Glimmer GUI DSL where `Glimmer`. `Glimmer::LibUI::Application`, `Glimmer::LibUI::CustomWindow`, or `Glimmer::LibUI::CustomControl` is mixed.
1126
+
1127
+ For example:
1128
+
1129
+ ```ruby
1130
+ require 'glimmer-libui-cw-greeter-acme'
1131
+
1132
+ ...
1133
+ greeter.show
1134
+ ...
1135
+ ```
1136
+
1137
+ ### List Custom Window Gems
1138
+
1139
+ Custom window gems are scaffolded to follow the naming convention: `glimmer-libui-cw-name-namespace`
1140
+
1141
+ The naming convention helps with discoverability of Ruby gems using the command:
1142
+
1143
+ ```
1144
+ glimmer list:gems:customwindow[query]
1145
+ ```
1146
+
1147
+ Or by using the shorter alias:
1148
+
1149
+ ```
1150
+ glimmer list:gems:cw[query]
1151
+ ```
1152
+
1153
+ The filtering `query` is optional.
1154
+
1155
+ ### List Glimmer DSLs
1156
+
1157
+ Glimmer DSLs can be listed with this command:
1158
+
1159
+ ```
1160
+ glimmer list:gems:dsl[query]
1161
+ ```
1162
+
1163
+ The filtering `query` is optional.
1164
+
885
1165
  ## Girb (Glimmer IRB)
886
1166
 
887
1167
  You can run the `girb` command (`bin/girb` if you cloned the project locally) to do some quick and dirty experimentation and learning:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.6
Binary file
@@ -30,25 +30,25 @@ module Glimmer
30
30
  REGEX_GEM_LINE = /^([^\(]+) \(([^\)]+)\)$/
31
31
 
32
32
  def custom_control_gems(query=nil)
33
- list_gems('glimmer-cw-', query) do |result|
33
+ list_gems('glimmer-libui-cc-', query) do |result|
34
34
  puts
35
- puts " Glimmer Custom Control Gems#{" matching [#{query}]" if query} at rubygems.org:"
35
+ puts " Glimmer DSL for LibUI Custom Control Gems#{" matching [#{query}]" if query} at rubygems.org:"
36
36
  puts result
37
37
  end
38
38
  end
39
39
 
40
40
  def custom_window_gems(query=nil)
41
- list_gems('glimmer-cs-', query) do |result|
41
+ list_gems('glimmer-libui-cw-', query) do |result|
42
42
  puts
43
- puts " Glimmer Custom Window Gems#{" matching [#{query}]" if query} at rubygems.org:"
43
+ puts " Glimmer DSL for LibUI Custom Window Gems#{" matching [#{query}]" if query} at rubygems.org:"
44
44
  puts result
45
45
  end
46
46
  end
47
47
 
48
48
  def custom_shape_gems(query=nil)
49
- list_gems('glimmer-cp-', query) do |result|
49
+ list_gems('glimmer-libui-cs-', query) do |result|
50
50
  puts
51
- puts " Glimmer Custom Shape Gems#{" matching [#{query}]" if query} at rubygems.org:"
51
+ puts " Glimmer DSL for LibUI Custom Shape Gems#{" matching [#{query}]" if query} at rubygems.org:"
52
52
  puts result
53
53
  end
54
54
  end
@@ -155,7 +155,7 @@ module Glimmer
155
155
  mkdir_p "app/#{file_name(app_name)}/model"
156
156
  mkdir_p "app/#{file_name(app_name)}/view"
157
157
  custom_window(class_name(app_name), current_dir_name, window_type, custom_window_class_name: 'Application')
158
- application_model(current_dir_name)
158
+ app_model(current_dir_name)
159
159
 
160
160
  mkdir_p 'icons/windows'
161
161
  icon_file = "icons/windows/#{human_name(app_name)}.ico"
@@ -219,7 +219,7 @@ module Glimmer
219
219
  end
220
220
 
221
221
  def custom_window_gem(custom_window_name, namespace)
222
- gem_name = "glimmer-cs-#{compact_name(custom_window_name)}"
222
+ gem_name = "glimmer-libui-cw-#{compact_name(custom_window_name)}"
223
223
  gem_summary = "#{human_name(custom_window_name)} - Glimmer Custom Window"
224
224
  begin
225
225
  custom_window_keyword = dsl_control_name(custom_window_name)
@@ -249,6 +249,7 @@ module Glimmer
249
249
  write 'Rakefile', gem_rakefile(custom_window_name, namespace, gem_name)
250
250
  append "lib/#{gem_name}.rb", gem_main_file(custom_window_name, namespace)
251
251
  custom_window(custom_window_name, namespace, :gem)
252
+ app_model(current_dir_name, namespace)
252
253
 
253
254
  mkdir_p "lib/#{gem_name}"
254
255
  write "lib/#{gem_name}/launch.rb", gem_launch_file(gem_name, custom_window_name, namespace)
@@ -291,7 +292,7 @@ module Glimmer
291
292
  end
292
293
 
293
294
  def custom_control_gem(custom_control_name, namespace)
294
- gem_name = "glimmer-cw-#{compact_name(custom_control_name)}"
295
+ gem_name = "glimmer-libui-cc-#{compact_name(custom_control_name)}"
295
296
  gem_summary = "#{human_name(custom_control_name)} - Glimmer Custom Control"
296
297
  if namespace
297
298
  gem_name += "-#{compact_name(namespace)}"
@@ -330,7 +331,7 @@ module Glimmer
330
331
  end
331
332
 
332
333
  def custom_shape_gem(custom_shape_name, namespace)
333
- gem_name = "glimmer-cp-#{compact_name(custom_shape_name)}"
334
+ gem_name = "glimmer-libui-cs-#{compact_name(custom_shape_name)}"
334
335
  gem_summary = "#{human_name(custom_shape_name)} - Glimmer Custom Shape"
335
336
  if namespace
336
337
  gem_name += "-#{compact_name(namespace)}"
@@ -368,7 +369,7 @@ module Glimmer
368
369
  puts 'Run `rake release` to release into rubygems.org once ready.'
369
370
  end
370
371
 
371
- def application_model(current_dir_name)
372
+ def app_model(current_dir_name, namespace = nil)
372
373
  model_name = 'Greeting'
373
374
  namespace ||= current_dir_name
374
375
  root_dir = File.exist?('app') ? 'app' : 'lib'
@@ -542,7 +543,7 @@ module Glimmer
542
543
 
543
544
  if %i[gem app].include?(window_type)
544
545
  custom_window_file_content += <<-MULTI_LINE_STRING
545
- require '#{current_dir_name}/model/greeting'
546
+ require '#{window_type == :app ? current_dir_name : namespace}/model/greeting'
546
547
 
547
548
  MULTI_LINE_STRING
548
549
  end
@@ -579,7 +580,7 @@ require '#{current_dir_name}/model/greeting'
579
580
  #
580
581
  MULTI_LINE_STRING
581
582
 
582
- if %i[gem app].include?(window_type)
583
+ if window_type == :app
583
584
  custom_window_file_content += <<-MULTI_LINE_STRING
584
585
  before_body do
585
586
  @greeting = Model::Greeting.new
@@ -609,6 +610,12 @@ require '#{current_dir_name}/model/greeting'
609
610
  end
610
611
  }
611
612
  }
613
+ end
614
+ MULTI_LINE_STRING
615
+ elsif window_type == :gem
616
+ custom_window_file_content += <<-MULTI_LINE_STRING
617
+ before_body do
618
+ @greeting = Model::Greeting.new
612
619
  end
613
620
  MULTI_LINE_STRING
614
621
  else
@@ -638,12 +645,30 @@ require '#{current_dir_name}/model/greeting'
638
645
 
639
646
  margined true
640
647
 
641
- label {
642
- #{%i[gem app].include?(window_type) ? "text <= [@greeting, :text]" : "text '#{human_name(custom_window_name)}'"}
648
+ vertical_box {
649
+ MULTI_LINE_STRING
650
+
651
+ if window_type == :gem
652
+ custom_window_file_content += <<-MULTI_LINE_STRING
653
+
654
+ button('Preferences...') {
655
+ stretchy false
656
+
657
+ on_clicked do
658
+ display_preferences_dialog
659
+ end
660
+ }
661
+ MULTI_LINE_STRING
662
+ end
663
+
664
+ custom_window_file_content += <<-MULTI_LINE_STRING
665
+ label {
666
+ #{%i[gem app].include?(window_type) ? "text <= [@greeting, :text]" : "text '#{human_name(custom_window_name)}'"}
667
+ }
643
668
  }
644
669
  }
645
670
  }
646
- MULTI_LINE_STRING
671
+ MULTI_LINE_STRING
647
672
 
648
673
  if %i[gem app].include?(window_type)
649
674
  custom_window_file_content += <<-MULTI_LINE_STRING
@@ -704,13 +729,21 @@ end
704
729
  #
705
730
  # options :custom_text, :background_color
706
731
  # option :foreground_color, default: :red
732
+
733
+ # Replace example options with your own options
734
+ option :model
735
+ option :attributes
707
736
 
708
737
  ## Use before_body block to pre-initialize variables to use in body
709
738
  #
710
739
  #
711
- # before_body do
712
- #
713
- # end
740
+ before_body do
741
+ # Replace example code with your own before_body code
742
+ default_model_attributes = [:first_name, :last_name, :email]
743
+ default_model_class = Struct.new(*default_model_attributes)
744
+ self.model ||= default_model_class.new
745
+ self.attributes ||= default_model_attributes
746
+ end
714
747
 
715
748
  ## Use after_body block to setup observers for controls in body
716
749
  #
@@ -725,9 +758,14 @@ end
725
758
  ## (Glimmer::LibUI::CustomWindow offers window convenience methods, like show and hide)
726
759
  #
727
760
  body {
728
- # Replace example content below with custom control content
729
- label {
730
- background :red
761
+ # Replace example content (model_form custom control) with your own custom control content.
762
+ form {
763
+ attributes.each do |attribute|
764
+ entry { |e|
765
+ label attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')
766
+ text <=> [model, attribute]
767
+ }
768
+ end
731
769
  }
732
770
  }
733
771
 
@@ -103,16 +103,16 @@ namespace :glimmer do
103
103
  task :cw, [:name, :namespace] => :customwindow
104
104
  task :custom_window, [:name, :namespace] => :customwindow
105
105
  task :"custom-window", [:name, :namespace] => :customwindow
106
- #
107
- # desc 'Scaffold Glimmer::UI::CustomControl subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cc]'
108
- # task :customcontrol, [:name, :namespace] do |t, args|
109
- # require_relative 'rake_task/scaffold'
110
- # Glimmer::RakeTask::Scaffold.custom_control(args[:name], args[:namespace])
111
- # end
112
- #
113
- # task :cc, [:name, :namespace] => :customcontrol
114
- # task :custom_control, [:name, :namespace] => :customcontrol
115
- # task :"custom-control", [:name, :namespace] => :customcontrol
106
+
107
+ desc 'Scaffold Glimmer::UI::CustomControl subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cc]'
108
+ task :customcontrol, [:name, :namespace] do |t, args|
109
+ require_relative 'rake_task/scaffold'
110
+ Glimmer::RakeTask::Scaffold.custom_control(args[:name], args[:namespace])
111
+ end
112
+
113
+ task :cc, [:name, :namespace] => :customcontrol
114
+ task :custom_control, [:name, :namespace] => :customcontrol
115
+ task :"custom-control", [:name, :namespace] => :customcontrol
116
116
  #
117
117
  # desc 'Scaffold Glimmer::UI::CustomShape subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cs]'
118
118
  # task :customshape, [:name, :namespace] do |t, args|
@@ -124,16 +124,16 @@ namespace :glimmer do
124
124
  # task :custom_shape, [:name, :namespace] => :customshape
125
125
  # task :"custom-shape", [:name, :namespace] => :customshape
126
126
  #
127
- # namespace :gem do
128
- # desc 'Scaffold Glimmer::UI::CustomWindow subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cw]'
129
- # task :customwindow, [:name, :namespace] do |t, args|
130
- # require_relative 'rake_task/scaffold'
131
- # Glimmer::RakeTask::Scaffold.custom_window_gem(args[:name], args[:namespace])
132
- # end
133
- #
134
- # task :cw, [:name, :namespace] => :customwindow
135
- # task :custom_window, [:name, :namespace] => :customwindow
136
- # task :"custom-window", [:name, :namespace] => :customwindow
127
+ namespace :gem do
128
+ desc 'Scaffold Glimmer::UI::CustomWindow subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cw]'
129
+ task :customwindow, [:name, :namespace] do |t, args|
130
+ require_relative 'rake_task/scaffold'
131
+ Glimmer::RakeTask::Scaffold.custom_window_gem(args[:name], args[:namespace])
132
+ end
133
+
134
+ task :cw, [:name, :namespace] => :customwindow
135
+ task :custom_window, [:name, :namespace] => :customwindow
136
+ task :"custom-window", [:name, :namespace] => :customwindow
137
137
  #
138
138
  # desc 'Scaffold Glimmer::UI::CustomControl subclass (part of a view) under its own Ruby gem project (namespace is required) [alt: scaffold:gem:cc]'
139
139
  # task :customcontrol, [:name, :namespace] do |t, args|
@@ -154,11 +154,7 @@ namespace :glimmer do
154
154
  # task :cs, [:name, :namespace] => :customshape
155
155
  # task :custom_shape, [:name, :namespace] => :customshape
156
156
  # task :"custom-shape", [:name, :namespace] => :customshape
157
- # end
158
- #
159
- # task :custom_window_gem, [:name, :namespace] => 'gem:customwindow'
160
- # task :custom_control_gem, [:name, :namespace] => 'gem:customcontrol'
161
- # task :custom_shape_gem, [:name, :namespace] => 'gem:customshape'
157
+ end
162
158
  end
163
159
 
164
160
  namespace :list do
@@ -198,13 +194,6 @@ namespace :glimmer do
198
194
  task :dsl, [:query] => :list_require do |t, args|
199
195
  Glimmer::RakeTask::List.dsl_gems(args[:query])
200
196
  end
201
-
202
197
  end
203
-
204
- # legacy support
205
-
206
- task :custom_window_gems, [:name, :namespace] => 'gems:customwindow'
207
- task :custom_control_gems, [:name, :namespace] => 'gems:customcontrol'
208
-
209
198
  end
210
199
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh