glimmer-dsl-libui 0.9.4 → 0.9.5

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: 722844f182b70508ed2e98484db762ea72297e7e9634042b2d888ca5b8c65f99
4
+ data.tar.gz: 88e9f08337452b1d59b90a54f30f489c0acc02154f2b57991de7c5d08c1347fa
5
5
  SHA512:
6
- metadata.gz: 5395eb43d9bc4a6aee0a18d498334a15475bd17cd976853bfb79c831eb55cdda6d68a9f8f04d62586d6d442004f0c74cef96f4f11e2ac53a08fba100813f989d
7
- data.tar.gz: 8d8ed838367b768e7c18d47027f0b8a11d5728bf578339867b60411566dec0ada11294f9691008489f8fedaf971548d0c8bdc927f1b2f53f8f3de0a8e9a90b01
6
+ metadata.gz: cad7f6be9a53386679ff80bfbb0c763428e003dcbf07f812c3d76b4f0dc581239d6e376b2e70bef030bbe1ff64554dae4fc3be55e9618c8dda6bf8a72da51752
7
+ data.tar.gz: 34a2ef4fa8f372dd69e9de1f768197118a5c30fcc140f178d39285fd75326db7f2f8b76fe9faf8812c3f862d8652d931580124fd252147466f4c5fb3600e8c3f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.5
4
+
5
+ - Scaffold Custom Control via `glimmer scaffold:customcontrol[name,namespace]`
6
+
3
7
  ## 0.9.4
4
8
 
5
9
  - Scaffold Custom Window via `glimmer scaffold:customwindow[name,namespace]`
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.5
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,7 @@ 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)
355
356
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
356
357
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
357
358
  - [API](#api)
@@ -422,7 +423,7 @@ gem install glimmer-dsl-libui
422
423
  Or install via Bundler `Gemfile`:
423
424
 
424
425
  ```ruby
425
- gem 'glimmer-dsl-libui', '~> 0.9.4'
426
+ gem 'glimmer-dsl-libui', '~> 0.9.5'
426
427
  ```
427
428
 
428
429
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -803,7 +804,7 @@ class HelloWorld
803
804
  end
804
805
  ```
805
806
 
806
- When the generated file is required in another view, the custom window keyword `greeting_window` become available and reusable, like by calling:
807
+ 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
808
 
808
809
  ```ruby
809
810
  greeting_window.show
@@ -864,7 +865,7 @@ module Station
864
865
  end
865
866
  ```
866
867
 
867
- When that file is required, the `train` keyword becomes available:
868
+ When that file is required in another view (e.g. `require 'station/view/train'`), the `train` keyword becomes available:
868
869
 
869
870
  ```ruby
870
871
  train.show
@@ -882,6 +883,194 @@ Or another `train` custom window view:
882
883
  hello_world__view__train.show
883
884
  ```
884
885
 
886
+ ### Scaffold Custom Control
887
+
888
+ 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:
889
+
890
+ ```
891
+ glimmer scaffold:customcontrol[name,namespace]
892
+ ```
893
+
894
+ The name represents the custom control view class name (it can be underscored, and Glimmer will automatically classify it).
895
+
896
+ 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).
897
+
898
+ You can also use the shorter `cc` alias for `customcontrol`:
899
+
900
+ ```
901
+ glimmer scaffold:cc[name,namespace]
902
+ ```
903
+
904
+ For example by running this command under a `hello_world` application:
905
+
906
+ ```
907
+ glimmer scaffold:cw[model_form]
908
+ ```
909
+
910
+ That will generate this class under `app/hello_world/view/model_form`:
911
+
912
+ ```ruby
913
+ class HelloWorld
914
+ module View
915
+ class ModelForm
916
+ include Glimmer::LibUI::CustomControl
917
+
918
+ ## Add options like the following to configure CustomControl by outside consumers
919
+ #
920
+ # options :custom_text, :background_color
921
+ # option :foreground_color, default: :red
922
+
923
+ # Replace example options with your own options
924
+ option :model
925
+ option :attributes
926
+
927
+ ## Use before_body block to pre-initialize variables to use in body
928
+ #
929
+ #
930
+ before_body do
931
+ # Replace example code with your own before_body code
932
+ default_model_attributes = [:first_name, :last_name, :email]
933
+ default_model_class = Struct.new(*default_model_attributes)
934
+ self.model ||= default_model_class.new
935
+ self.attributes ||= default_model_attributes
936
+ end
937
+
938
+ ## Use after_body block to setup observers for controls in body
939
+ #
940
+ # after_body do
941
+ #
942
+ # end
943
+
944
+ ## Add control content under custom control body
945
+ ##
946
+ ## If you want to add a window as the top-most control,
947
+ ## consider creating a custom window instead
948
+ ## (Glimmer::LibUI::CustomWindow offers window convenience methods, like show and hide)
949
+ #
950
+ body {
951
+ # Replace example content (model_form custom control) with your own custom control content.
952
+ form {
953
+ attributes.each do |attribute|
954
+ entry { |e|
955
+ label attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')
956
+ text <=> [model, attribute]
957
+ }
958
+ end
959
+ }
960
+ }
961
+
962
+ end
963
+ end
964
+ end
965
+ ```
966
+
967
+ 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:
968
+
969
+ ```ruby
970
+ window {
971
+ vertical_box {
972
+ label('Form:')
973
+ model_form(model: some_model, attributes: array_of_attributes)
974
+ }
975
+ }
976
+ ```
977
+
978
+ Here is an example that generates a custom control with a namespace:
979
+
980
+ ```
981
+ glimmer scaffold:cw[model_form,common]
982
+ ```
983
+
984
+ That will generate this class under `app/common/view/model_form`:
985
+
986
+ ```ruby
987
+ module Common
988
+ module View
989
+ class ModelForm
990
+ include Glimmer::LibUI::CustomControl
991
+
992
+ ## Add options like the following to configure CustomControl by outside consumers
993
+ #
994
+ # options :custom_text, :background_color
995
+ # option :foreground_color, default: :red
996
+
997
+ # Replace example options with your own options
998
+ option :model
999
+ option :attributes
1000
+
1001
+ ## Use before_body block to pre-initialize variables to use in body
1002
+ #
1003
+ #
1004
+ before_body do
1005
+ # Replace example code with your own before_body code
1006
+ default_model_attributes = [:first_name, :last_name, :email]
1007
+ default_model_class = Struct.new(*default_model_attributes)
1008
+ self.model ||= default_model_class.new
1009
+ self.attributes ||= default_model_attributes
1010
+ end
1011
+
1012
+ ## Use after_body block to setup observers for controls in body
1013
+ #
1014
+ # after_body do
1015
+ #
1016
+ # end
1017
+
1018
+ ## Add control content under custom control body
1019
+ ##
1020
+ ## If you want to add a window as the top-most control,
1021
+ ## consider creating a custom window instead
1022
+ ## (Glimmer::LibUI::CustomWindow offers window convenience methods, like show and hide)
1023
+ #
1024
+ body {
1025
+ # Replace example content (model_form custom control) with your own custom control content.
1026
+ form {
1027
+ attributes.each do |attribute|
1028
+ entry { |e|
1029
+ label attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')
1030
+ text <=> [model, attribute]
1031
+ }
1032
+ end
1033
+ }
1034
+ }
1035
+
1036
+ end
1037
+ end
1038
+ end
1039
+ ```
1040
+
1041
+ When that file is required in another view (e.g. `require 'common/view/model_form'`), the `model_form` keyword becomes available:
1042
+
1043
+ ```ruby
1044
+ window {
1045
+ vertical_box {
1046
+ label('Form:')
1047
+ model_form(model: some_model, attributes: array_of_attributes)
1048
+ }
1049
+ }
1050
+ ```
1051
+
1052
+ 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:
1053
+
1054
+ ```ruby
1055
+ window {
1056
+ vertical_box {
1057
+ label('Form:')
1058
+ common__view__model_form(model: some_model, attributes: array_of_attributes)
1059
+ }
1060
+ }
1061
+ ```
1062
+
1063
+ Or another `model_form` custom control view:
1064
+
1065
+ ```ruby
1066
+ window {
1067
+ vertical_box {
1068
+ label('Form:')
1069
+ hello_world__view__model_form(model: some_model, attributes: array_of_attributes)
1070
+ }
1071
+ }
1072
+ ```
1073
+
885
1074
  ## Girb (Glimmer IRB)
886
1075
 
887
1076
  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.5
Binary file
@@ -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"
@@ -368,7 +368,7 @@ module Glimmer
368
368
  puts 'Run `rake release` to release into rubygems.org once ready.'
369
369
  end
370
370
 
371
- def application_model(current_dir_name)
371
+ def app_model(current_dir_name)
372
372
  model_name = 'Greeting'
373
373
  namespace ||= current_dir_name
374
374
  root_dir = File.exist?('app') ? 'app' : 'lib'
@@ -704,13 +704,21 @@ end
704
704
  #
705
705
  # options :custom_text, :background_color
706
706
  # option :foreground_color, default: :red
707
+
708
+ # Replace example options with your own options
709
+ option :model
710
+ option :attributes
707
711
 
708
712
  ## Use before_body block to pre-initialize variables to use in body
709
713
  #
710
714
  #
711
- # before_body do
712
- #
713
- # end
715
+ before_body do
716
+ # Replace example code with your own before_body code
717
+ default_model_attributes = [:first_name, :last_name, :email]
718
+ default_model_class = Struct.new(*default_model_attributes)
719
+ self.model ||= default_model_class.new
720
+ self.attributes ||= default_model_attributes
721
+ end
714
722
 
715
723
  ## Use after_body block to setup observers for controls in body
716
724
  #
@@ -725,9 +733,14 @@ end
725
733
  ## (Glimmer::LibUI::CustomWindow offers window convenience methods, like show and hide)
726
734
  #
727
735
  body {
728
- # Replace example content below with custom control content
729
- label {
730
- background :red
736
+ # Replace example content (model_form custom control) with your own custom control content.
737
+ form {
738
+ attributes.each do |attribute|
739
+ entry { |e|
740
+ label attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')
741
+ text <=> [model, attribute]
742
+ }
743
+ end
731
744
  }
732
745
  }
733
746
 
@@ -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|
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh