fxruby-enhancement 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 815c35e0699b8a7cb0bc90b27f21789751af71fd
4
- data.tar.gz: c9cc4a024a7493888bc3e27ec96a319e1b8a1a63
3
+ metadata.gz: d3c7b8e5a27a1d979f10f9f7111b0c1dab700078
4
+ data.tar.gz: 2ecedc52cf7ec206590c7cc0a4646cd4c8f36c40
5
5
  SHA512:
6
- metadata.gz: 5e6d8150e9bb259e6bf9b12c63a1e874e6ebcc9ead1594cfc5cf0fd0f12d307e712bdfbe6cd92ba0ec68cfb98c8b0847ddc0430c63fe1337b0c756436a0ce304
7
- data.tar.gz: 36efe40ce1f47ab9d7a4623ede142171856c4648e45ba1a7c51bdfb67151774d7d35c615c0d7b57fa833a8fd4f0167f3ff637ed3ae3288cd17fc60e1c9230a41
6
+ metadata.gz: 960a428b033f972f812d4c4c28fa3932b2cc7322b6f3109230727c7a257697b2092f44d4123361cdbbcb96f4734481e6b3d67f22e57fbf0301c3e1eb2c66129b
7
+ data.tar.gz: f34e2d2b3e1363e63dec4be1b04f9131e16af4f9c08063db207aa7c5e9ff317a20c329a1c86e8a7ab1ec8c5bc295c72c3dbeb4bc8908cc5345a6c5f76b8570e1
data/.semver CHANGED
@@ -1,6 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 2
4
+ :patch: 3
5
5
  :special: ''
6
- :metadata: ''
data/Gemfile.lock CHANGED
@@ -6,7 +6,7 @@ GEM
6
6
  awesome_print (1.7.0)
7
7
  binding_of_caller (0.7.2)
8
8
  debug_inspector (>= 0.0.1)
9
- builder (3.2.2)
9
+ builder (3.2.3)
10
10
  byebug (9.0.6)
11
11
  coderay (1.1.1)
12
12
  debug_inspector (0.0.2)
@@ -28,7 +28,7 @@ GEM
28
28
  hashie (3.4.6)
29
29
  highline (1.7.8)
30
30
  interception (0.5)
31
- json (2.0.2)
31
+ json (2.0.3)
32
32
  juwelier (2.3.4)
33
33
  builder
34
34
  bundler (>= 1.13)
@@ -103,7 +103,7 @@ GEM
103
103
  simplecov-html (0.10.0)
104
104
  slop (3.6.0)
105
105
  thread_safe (0.3.5)
106
- yard (0.9.7)
106
+ yard (0.9.8)
107
107
 
108
108
  PLATFORMS
109
109
  ruby
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 Fred Mitchell
1
+ Copyright (c) 2016-2017 Fred Mitchell
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
data/README.org CHANGED
@@ -1,5 +1,5 @@
1
1
  #+OPTIONS: broken-links:mark
2
- * Table of Contents :TOC_5_gh:
2
+ * FXRuby Enhancement Table of Contents :TOC_5_gh:
3
3
  - [[#fxruby-enhancement][fxruby-enhancement]]
4
4
  - [[#introduction][Introduction]]
5
5
  - [[#installation][Installation]]
@@ -13,15 +13,15 @@
13
13
  - [[#the-queue_ding-queues][The Queue_Ding Queues]]
14
14
  - [[#enhancementingress][Enhancement.ingress]]
15
15
  - [[#enhancementegress][Enhancement.egress]]
16
- - [[#api--dsl][API & DSL]]
17
- - [[#ref-refc-and-tagging-your-objects][ref(), refc() and tagging your objects]]
18
- - [[#fox_component-and-fox_instance][fox_component and fox_instance]]
19
- - [[#fx_app][fx_app]]
20
- - [[#instance][instance]]
21
- - [[#ingress_handler][ingress_handler]]
22
- - [[#deferred_setup][deferred_setup]]
23
- - [[#mapping-between-fx_-declarations-and-the-fx-fxruby-objects][Mapping between fx_* declarations and the FX* FXRuby objects]]
24
- - [[#bindingfx][binding.fx]]
16
+ - [[#api--dsl][API & DSL]]
17
+ - [[#ref-refc-and-tagging-your-objects][ref(), refc() and tagging your objects]]
18
+ - [[#fox_component-and-fox_instance][fox_component and fox_instance]]
19
+ - [[#fx_app][fx_app]]
20
+ - [[#instance][instance]]
21
+ - [[#ingress_handler][ingress_handler]]
22
+ - [[#deferred_setup][deferred_setup]]
23
+ - [[#mapping-between-fx_-declarations-and-the-fx-fxruby-objects][Mapping between fx_* declarations and the FX* FXRuby objects]]
24
+ - [[#bindingfx][binding.fx]]
25
25
  - [[#examples][Examples]]
26
26
  - [[#hello-world-example-full-the-enhancement-way][Hello World example (full) the Enhancement Way]]
27
27
  - [[#hello-world-the-old-fxruby-way][Hello World the old fxruby way:]]
@@ -36,10 +36,10 @@
36
36
 
37
37
  * fxruby-enhancement
38
38
  ** Introduction
39
- The fxruby library is an excellent wrapper for the FOX toolkit.
39
+ The fxruby library is an excellent wrapper for the FOX Toolkit.
40
40
  However, it reflects the C++-ness of FOX, rather than being more
41
41
  Ruby-like. As such, creating composed objects with it tends to be
42
- rather ugly and cumbersome. For every new component you create with
42
+ rather cumbersome, given its C++ roots. For every new component you create with
43
43
  fxruby, you are handed back a reference to that object, which you'll
44
44
  need to store somewhere. And then all the subsequent child objects
45
45
  will need to be passed pointers to the parent objects.
@@ -75,7 +75,7 @@
75
75
  will automatically include it. However fxruby has a c-extension
76
76
  that must compile properly on your system. Normally, this is not
77
77
  a concern, but it is something to be aware of.
78
-
78
+
79
79
  ** Documentation
80
80
  *** In General
81
81
  fxruby-enhancement (which we will refer to as "Enhancement" from time
@@ -219,114 +219,186 @@
219
219
  #+begin_src
220
220
  #+end_src
221
221
 
222
- **** API & DSL
223
- ***** ref(), refc() and tagging your objects
224
- In an effort to eliminate the fuss and bother with
225
- scoping issues and object reference, ref(:some_tag) will
226
- retrive the FXRuby instance object so tagged with :some_tag.
227
-
228
- You may have anonymous, i.e., untagged objects, and those will
229
- not be findable by ref(). It is not necessary to tag all objects,
230
- either.
231
-
232
- refc() is similar to ref(), except it retrives the underlying
233
- component object insted. Indeed, the following are equivalent
234
- operations:
235
- #+begin_src ruby
236
- ref(:some_tag)
237
- refc(:some_tag).inst
238
- #+end_src
239
-
240
- There may be some edge cases where you might want to
241
- reference the underlying component ahead of FXRuby object
242
- instaniation, but in the vast majority of the cases, it should
243
- be unnecessary. My goal is to enable to do what you need, not
244
- to restrict you. You may need it for debugging, etc.
245
-
246
- Underlying, the component object is really a subclass of OpenScript.
247
- While you may like to stuff some additional data there,
248
- this is frowned upon because it might conflict with Enhancement.
249
- If you have a need for this, please do a issue in GitHub.
250
-
251
- ***** fox_component and fox_instance
252
- fox_component and fox_instance are roughly the
253
- equivalent of refc() and ref(), respecively. The
254
- difference mainly being that fox_component does no
255
- sanity checking, and is therefore slightly faster.
256
-
257
- At some point, they may be merged, but for now don't
258
- count on it.
259
-
260
- To initialize and run your app, you customairly do the
261
- following:
262
- #+begin_src ruby
263
- fox_component :app do |app|
264
- app.launch
265
- end
266
- #+end_src
267
-
268
- Which presumes your fx_app declaration was tagged with
269
- :app as follows:
270
- #+begin_src ruby
271
- fx_app :app do
272
- app_name "Your Amazingly Cool Application"
273
- vendor_name "YouDaMan"
274
- ...
275
- end
276
- #+end_src
277
-
278
- This is the only time you will reference the component
279
- object directly for the obvious reason that you must start
280
- from someonere.
281
-
282
- ***** fx_app
283
- To begin the declaration of your app, you must do the
284
- following somewhere:
285
- #+begin_src ruby
286
- fx_app :app do
287
- app_name "The Forbin Project"
288
- vendor_name "Colossus"
289
- ...
290
- end
291
- #+end_src
292
-
293
- Typeically you'd do this inside of a module, but you could do it also
294
- in a class body. Please see the examples.
295
-
296
- ***** TODO instance
297
- ***** TODO ingress_handler
298
- ***** TODO deferred_setup
299
- ***** TODO Mapping between fx_* declarations and the FX* FXRuby objects
300
- ***** binding.fx
301
- This is a way to split up your layouts into different .fx "modules", purely for
302
- organizational reasons. For example,
303
-
304
- #+begin_src ruby
305
- binding.fx "overview"
306
- #+end_src
307
-
308
- will load the overview.fx portion of the GUI, which happens to be a tab contents
309
- in the tab book, which in our case looks like:
310
-
311
- #+begin_src ruby
312
- # Overview Tab
313
-
314
- fx_tab_item { text "&Overview" }
315
- fx_horizontal_frame (:overview_info) {
316
- opts STD_FRAME|LAYOUT_FILL_Y
222
+ *** API & DSL
223
+ **** ref(), refc() and tagging your objects
224
+ In an effort to eliminate the fuss and bother with
225
+ scoping issues and object reference, ref(:some_tag) will
226
+ retrive the FXRuby instance object so tagged with :some_tag.
227
+
228
+ You may have anonymous, i.e., untagged objects, and those will
229
+ not be findable by ref(). It is not necessary to tag all objects,
230
+ either.
231
+
232
+ refc() is similar to ref(), except it retrives the underlying
233
+ component object insted. Indeed, the following are equivalent
234
+ operations:
235
+ #+begin_src ruby
236
+ ref(:some_tag)
237
+ refc(:some_tag).inst
238
+ #+end_src
239
+
240
+ There may be some edge cases where you might want to
241
+ reference the underlying component ahead of FXRuby object
242
+ instaniation, but in the vast majority of the cases, it should
243
+ be unnecessary. My goal is to enable to do what you need, not
244
+ to restrict you. You may need it for debugging, etc.
245
+
246
+ Underlying, the component object is really a subclass of OpenScript.
247
+ While you may like to stuff some additional data there,
248
+ this is frowned upon because it might conflict with Enhancement.
249
+ If you have a need for this, please do a issue in GitHub.
250
+
251
+ **** fox_component and fox_instance
252
+ fox_component and fox_instance are roughly the
253
+ equivalent of refc() and ref(), respecively. The
254
+ difference mainly being that fox_component does no
255
+ sanity checking, and is therefore slightly faster.
256
+
257
+ At some point, they may be merged, but for now don't
258
+ count on it.
259
+
260
+ To initialize and run your app, you customairly do the
261
+ following:
262
+ #+begin_src ruby
263
+ fox_component :app do |app|
264
+ app.launch
265
+ end
266
+ #+end_src
267
+
268
+ Which presumes your fx_app declaration was tagged with
269
+ :app as follows:
270
+ #+begin_src ruby
271
+ fx_app :app do
272
+ app_name "Your Amazingly Cool Application"
273
+ vendor_name "YouDaMan"
274
+ ...
275
+ end
276
+ #+end_src
277
+
278
+ This is the only time you will reference the component
279
+ object directly for the obvious reason that you must start
280
+ from someonere.
281
+
282
+ **** fx_app
283
+ To begin the declaration of your app, you must do the
284
+ following somewhere:
285
+ #+begin_src ruby
286
+ fx_app :app do
287
+ app_name "The Forbin Project"
288
+ vendor_name "Colossus"
289
+ ...
290
+ end
291
+ #+end_src
292
+
293
+ Typeically you'd do this inside of a module, but you could do it also
294
+ in a class body. Please see the examples.
295
+
296
+ **** instance
297
+ Inside of your component declaration, you will undoubtly
298
+ want to specify what you want to do once the FXRuby object
299
+ is actually instantiated. This is what the instance clause
300
+ will allow you to do. Your code block there will be passed
301
+ a reference to the FXRuby object, allowing you to set up
302
+ connections, change the component state, etc.
303
+
304
+ There are some added benefits as well. When making a connection,
305
+ with the normal FXRuby, you would do something like this:
306
+ #+begin_src ruby
307
+ ...
308
+ aButton.connect(SEL_COMMAND) { |sender, selector, data|
309
+ ... code to handle this event ...
310
+ }
311
+ #+end_src
312
+
313
+ But with Enhancement, you would be able to do it thusly:
314
+ #+begin_src ruby
315
+ fx_button(:my_button) {
316
+ ... configs for this FXButton object ...
317
+ instance { |button|
318
+ button.sel_command { |sender, selector, data|
319
+ ... code to handle this event ...
320
+ }
321
+ }
322
+ }
323
+ #+end_src
324
+
325
+ which will make it feel more Ruby-like and less C++-like.
326
+
327
+ **** ingress_handler
328
+ ingress_handler will allow you to set up the handler for
329
+ messages coming in from an external source to FXRuby thread,
330
+ such as RabbitMQ, network connections, databases, or anything else.
331
+ It allows you to do clean multhreaded Ruby without the normal worries
332
+ of semaphores and synchronization and the like -- it is all
333
+ handled for you "magically" behind the scenes!
334
+
335
+ You may have as many ingress_handlers specified as you like, as
336
+ each one needs to have a tag, and the tags are used to dispatch
337
+ the messages.
338
+
339
+ Here is an example taken from RubyNEAT Panel:
340
+ #+begin_src ruby
341
+ ingress_handler :status do |type, status|
342
+ suc, st = status.response
343
+
344
+ wlist = ref :ov_conn_neaters_widget_list
345
+ wlist.clearItems
346
+ st[:neaters].each { |neater| wlist.appendItem neater }
347
+
348
+ nlist = ref :ov_conn_neurons_list
349
+ nlist.clearItems
350
+ st[:neurons].each { |neuron| nlist.appendItem neuron}
351
+ end
352
+ #+end_src
353
+
354
+ Here you can see that a status message has been dispatched to
355
+ this ingress_handler, and that the message contains a list of
356
+ 'neaters' and 'neurons' that are being sent to the wlist
357
+ and nlist list (:ov_conn_neaters_widget_list and :ov_conn:_neurons_list),
358
+ respecively.
359
+
360
+ You may declare your ingress_handler anywhere in your code and have
361
+ the expected happen.
362
+
363
+ **** TODO deferred_setup
364
+ **** TODO Mapping between fx_* declarations and the FX* FXRuby objects
365
+ **** binding.fx
366
+ This is a way to split up your layouts into different .fx "modules", purely for
367
+ organizational reasons. For example,
368
+
369
+ #+begin_src ruby
370
+ binding.fx "overview"
371
+ #+end_src
372
+
373
+ will load the overview.fx portion of the GUI, which happens to be a tab contents
374
+ in the tab book, which in our case looks like:
375
+
376
+ #+begin_src ruby
377
+ # Overview Tab
378
+
379
+ fx_tab_item { text "&Overview" }
380
+ fx_horizontal_frame (:overview_info) {
381
+ opts STD_FRAME|LAYOUT_FILL_Y
317
382
 
318
- fx_group_box (:ov_connections_group) {
319
- text "Connections"
320
- opts STD_GROUPBOX|LAYOUT_FILL_Y
383
+ fx_group_box (:ov_connections_group) {
384
+ text "Connections"
385
+ opts STD_GROUPBOX|LAYOUT_FILL_Y
321
386
 
322
- fx_vertical_frame {
323
- opts LAYOUT_FILL_Y|LAYOUT_FILL_X #|PACK_UNIFORM_HEIGHT
387
+ fx_vertical_frame {
388
+ opts LAYOUT_FILL_Y|LAYOUT_FILL_X #|PACK_UNIFORM_HEIGHT
324
389
 
325
- fx_group_box (:ov_conn_rabbitmq) {
326
- ...
327
- #+end_src
390
+ fx_group_box (:ov_conn_rabbitmq) {
391
+ ...
392
+ #+end_src
328
393
 
329
394
  *** Examples
395
+ Because this is a spinoff project of the ongoing RubyNEAT
396
+ effort, there is a splendid RubyNEAT Panel example, that
397
+ is still in the works. However, you are free to look at the
398
+ code that is there to get good ideas.
399
+
400
+ https://github.com/flajann2/rubyneat-panel/tree/master/lib/rubyneat-panel
401
+
330
402
  Class-based enhancement (this has not been tested yet!!!):
331
403
  #+begin_src ruby
332
404
  class Main < FXMainWindow
@@ -796,14 +868,16 @@ end
796
868
  More examples can be found [[file:examples][HERE]].
797
869
 
798
870
  ** Release Notes
799
- | Version | Date | Notes |
800
- |---------+------------+-----------------|
801
- | 0.0.2 | 2017-01-11 | Initial release |
871
+ | Version | Date | Notes |
872
+ |---------+------------+---------------------------------------------------------|
873
+ | 0.0.2 | 2017-01-11 | Initial release |
874
+ | 0.0.3 | 2017-01-15 | Needed to require fox16/colors for FXColor to be loaded |
802
875
 
803
876
  ** Known Issues
804
- | Version | Date | Issues |
805
- |---------+------------+----------------------------|
806
- | 0.0.2 | 2017-01-11 | Not enough example code!!! |
877
+ | Version | Date | Issues |
878
+ |---------+------------+-------------------------------------------------------|
879
+ | 0.0.2 | 2017-01-11 | Not enough example code!!! Need more documentation!!! |
880
+
807
881
 
808
882
  ** Contributing to fxruby-enhancement
809
883
 
@@ -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: fxruby-enhancement 0.0.2 ruby lib
5
+ # stub: fxruby-enhancement 0.0.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "fxruby-enhancement".freeze
9
- s.version = "0.0.2"
9
+ s.version = "0.0.3"
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 = ["Fred Mitchell".freeze]
14
- s.date = "2017-01-11"
14
+ s.date = "2017-01-15"
15
15
  s.description = "The fxruby library is an excellent wrapper for the FOX toolkit. However, it reflects the\n C++-ness of FOX, rather than being more Ruby-like. As such, creating composed objects with\n it tends to be rather ugly and cumbersome.\n\n fxruby-enhancement is a wrapper for the wrapper, to \"rubyfy\" it and make it more easy to \n use for Rubyists. \n\n fxruby-enhancement is basically a DSL of sorts, and every effort has been taken to make \n it intuitive to use. Once you get the hang of it, you should be able to look at the FXRuby\n API documentation and infer the DSL construct for fxruby-enhancement.".freeze
16
16
  s.email = "fred.mitchell@gmx.de".freeze
17
17
  s.extra_rdoc_files = [
@@ -1,4 +1,5 @@
1
1
  require 'fox16'
2
+ require 'fox16/colors'
2
3
  require 'ostruct'
3
4
  require 'awesome_print'
4
5
  require 'forwardable'
@@ -57,7 +57,7 @@ module Fox
57
57
  @ingress_delay = @ms_ingress_delay_min
58
58
  until @ingress.empty?
59
59
  dispatch_to, payload = @ingress.next
60
- raise "Unknown dispatch #{dispatch_to}" unless @ingress_map.member? dispatch_to
60
+ raise "Unknown dispatch ':#{dispatch_to}'" unless @ingress_map.member? dispatch_to
61
61
  @ingress_map[dispatch_to].(dispatch_to, payload)
62
62
  end
63
63
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fxruby-enhancement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-11 00:00:00.000000000 Z
11
+ date: 2017-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semver2