{"id":16382439,"url":"https://github.com/andyobtiva/glimmer-dsl-fx","last_synced_at":"2026-05-01T07:30:19.293Z","repository":{"id":56874622,"uuid":"441973918","full_name":"AndyObtiva/glimmer-dsl-fx","owner":"AndyObtiva","description":"Glimmer DSL for FX (FOX Toolkit Ruby Desktop Development GUI Library)","archived":false,"fork":false,"pushed_at":"2023-06-29T17:36:39.000Z","size":148,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T00:24:47.183Z","etag":null,"topics":["dsl","dsl-syntax","fox-toolkit","fxruby","glimmer-dsl","gui","ruby","ruby-gem","ruby-library","rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndyObtiva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-26T20:03:15.000Z","updated_at":"2022-02-22T18:42:14.000Z","dependencies_parsed_at":"2024-11-08T20:46:48.072Z","dependency_job_id":"1463813a-0da1-49e3-bd09-415cf0c1f7a1","html_url":"https://github.com/AndyObtiva/glimmer-dsl-fx","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"f88154f500434a59b52b11c461a4f9cea2b7de90"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Fglimmer-dsl-fx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Fglimmer-dsl-fx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Fglimmer-dsl-fx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Fglimmer-dsl-fx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndyObtiva","download_url":"https://codeload.github.com/AndyObtiva/glimmer-dsl-fx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240073544,"owners_count":19743777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsl","dsl-syntax","fox-toolkit","fxruby","glimmer-dsl","gui","ruby","ruby-gem","ruby-library","rubygem"],"created_at":"2024-10-11T04:05:23.991Z","updated_at":"2026-05-01T07:30:19.261Z","avatar_url":"https://github.com/AndyObtiva.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [\u003cimg src=\"https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png\" height=85 /\u003e](https://github.com/AndyObtiva/glimmer) Glimmer DSL for FX 0.0.2\n## FOX Toolkit Ruby Desktop Development GUI Library\n[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-fx.svg)](http://badge.fury.io/rb/glimmer-dsl-fx)\n[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [FX](http://www.fox-toolkit.org/) enables building desktop applications with the [FOX Toolkit](http://www.fox-toolkit.org/) via [FXRuby](https://github.com/larskanis/fxruby).\n\n[FOX Toolkit](http://www.fox-toolkit.org/) is the most popular cross-platform desktop GUI toolkit in [MRI Ruby](https://www.ruby-lang.org), having [900,000+ FXRuby gem downloads](https://rubygems.org/gems/fxruby) and counting! \n\n[FOX Toolkit](http://www.fox-toolkit.org/)'s forte is definitely Windows where no prerequisites are needed given that [FXRuby](https://github.com/larskanis/fxruby) includes Windows binaries out of the box.\n\n[Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx) aims to supercharge productivity and maintainability in developing [FOX Toolkit Ruby](https://rubygems.org/gems/fxruby) applications by providing a DSL similar to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) having:\n- Declarative DSL syntax that visually maps to the GUI widget hierarchy\n- Convention over configuration via smart defaults and automation of low-level details\n- Requiring the least amount of syntax possible to build GUI\n- Custom control support\n- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models\n- Scaffolding for new custom widgets, apps, and gems\n- Native-Executable packaging on Mac, Windows, and Linux.\n\nHello, World!\n\n```ruby\napp('HelloWorld', 'Glimmer') {\n  main_window('Hello, World!') {\n    label('Hello, World!', opts: [:layout_center_x, :layout_center_y])\n  }\n}.run\n```\n\nWindows | Mac\n--------|----\n![hello world screenshot windows](/screenshots/glimmer-dsl-fx-windows-hello-world.png) | ![hello world screenshot mac](/screenshots/glimmer-dsl-fx-mac-hello-world.png)\n\nNOTE: Glimmer DSL for FX is currently in early alpha mode (incomplete proof-of-concept). If you want it developed faster, then [open an issue report](https://github.com/AndyObtiva/glimmer-dsl-fx/issues/new). I have completed some GitHub project features much faster before due to [issue reports](https://github.com/AndyObtiva/glimmer-dsl-fx/issues) and [pull requests](https://github.com/AndyObtiva/glimmer-dsl-fx/pulls). 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.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.\n\nLearn more about the differences between various [Glimmer](https://github.com/AndyObtiva/glimmer) DSLs by looking at the **[Glimmer DSL Comparison Table](https://github.com/AndyObtiva/glimmer#glimmer-dsl-comparison-table)**.\n\n## Prerequisites\n\n### Linux\n\nRun:\n\n```\nsudo apt-get install g++ libxrandr-dev libfox-1.6-dev\n```\n\n### Mac\n\nMake sure [Homebrew](https://brew.sh/) is installed (e.g. by running `/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"`).\n\nRun:\n\n```\nbrew install fox\nbrew install xquartz\n```\n\n### Windows\n\nThe [glimmer-dsl-fx](https://rubygems.org/gems/glimmer-dsl-fx) gem already contains all required library dependencies.\n\n## Setup\n\n### Option 1: Install\n\nRun this command to install directly:\n```\ngem install glimmer-dsl-fx\n```\n\n### Option 2: Bundler\n\nAdd the following to `Gemfile`:\n```\ngem 'glimmer-dsl-fx', '~\u003e 0.0.2'\n```\n\nAnd, then run:\n```\nbundle\n```\n\n## Usage\n\nRequire the library and mixin the `Glimmer` module to utilize the Glimmer GUI DSL for FX:\n\n```ruby\napp('HelloWorld', 'Glimmer') {\n  main_window('Hello, World!') {\n    label('Hello, World!', opts: [:layout_center_x, :layout_center_y])\n  }\n}.run\n```\n\nFor actual application development outside of simple demos, mixin the `Glimmer` module into a custom application class instead:\n\n```ruby\nrequire 'glimmer-dsl-fx'\n\nclass SomeGlimmerApplication\n  include Glimmer\n  \n  def launch\n    app('HelloWorld', 'Glimmer') {\n      main_window('Hello, World!') {\n        label('Hello, World!', opts: [:layout_center_x, :layout_center_y])\n      }\n    }.run\n  end\nend\n\nSomeGlimmerApplication.new.launch\n```\n\n## Glimmer GUI DSL\n\nThe Glimmer GUI DSL enables development of desktop graphical user interfaces in a manner similar to HTML, but in one language, Ruby, thus avoiding the multi-language separation dissonance encountered on the web, especially given that Ruby looping/conditional constructs do not need scriptlets to be added around View code. This makes desktop development extremely productive.\n\n1 - Keywords\n\nAlways start with `app`.\n\nInside `app`, nest `main_window`, and inside `main_window`, you may declare any [FOX Toolkit control](http://www.fox-toolkit.org/ref16/classes.html) with its keyword, which is the underscored version of the class name minus the `FX` prefix. For example, `label` is the keyword for [`FXLabel`](http://www.fox-toolkit.org/ref16/classFX_1_1FXLabel.html)\n\nExamples:\n\n```ruby\nlabel\nbutton\ntext_field\n```\n\n2 - Arguments\n\nEvery [FOX Toolkit](http://www.fox-toolkit.org/) control usually requires one main argument that is [the second argument in the C++ API](http://www.fox-toolkit.org/ref16/classFX_1_1FXButton.html#a0) (e.g. button text or text_field column width) and extra kwargs specific to each control, like `:opts`, `:width`, and `:height` for `button`.\n\nThe [FOX Toolkit](http://www.fox-toolkit.org/) `:opts` argument value is usually bit-or'ed `Fox` constants (e.g. `FRAME_RAISED|FRAME_THICK`). In [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx), you simply supply them as a downcased underscored `Symbol` `Array` separated by commas (e.g. `[:frame_raised, :frame_thick]`)\n\nExample:\n\n```ruby\nlabel('Full Name', opts: [:layout_top, :justify_left])\nbutton('Submit Form', opts: [:frame_raised, :frame_thick], icon: submit_icon, width: 300, height: 200)\ntext_field(20, opts: [:justify_right, :frame_sunken, :frame_thick, :layout_side_top])\n```\n\nThe recommended style is to always wrap arguments with parentheses for control keywords.\n\n3 - Content Block\n\nYou may pass a content block to any [FOX Toolkit](http://www.fox-toolkit.org/) control keyword, which contains attributes and/or nested controls.\n\nExample:\n\n```ruby\napp('HelloWorld', 'Glimmer') {\n  main_window('Hello, World!') {\n    width 320\n    height 240\n  \n    vertical_frame {\n      label('Hello, Label!')\n      button('Hello, Button!')\n    }\n  }\n}.run\n```\n\nThe recommended style for the content block is always curly braces `{}` to denote as View nesting code different from looping/conditional logic, which utilizes `do;end` instead.\n\nAttribute arguments never have parentheses.\n\n4 - Listeners\n\nYou may declare listeners with `on(message_type) {...}` where `message_type` is an underscored `Symbol` version of a `Fox::SEL_XYZ` message type constant (e.g. `SEL_COMMAND`, `SEL_SELECTED`, `SEL_KEYPRESS`, `SEL_KEYRELEASE`, `SEL_CLICKED`, `SEL_LEFTBUTTONPRESS`, or `SEL_LEFTBUTTONRELEASE`), but without the `SEL_` prefix. For example: `on(:command) {...}`, `on(:selected) {...}`, `on(:keypress) {...}`, `on(:keyrelease) {...}`, `on(:clicked) {...}`, `on(:leftbuttonpress) {...}`, and `on(:leftbuttonrelease) {...}`.\n\nExample:\n\n```ruby\napp('HelloWorld', 'Glimmer') {\n  main_window('Hello, World!') {\n    button('Hello, Button!') { |b|\n      on(:command) {\n        b.text = 'Clicked'\n      }\n    }\n  }\n}.run\n```\n\nThe recommended style for listeners is always a `do; end` block.\n\n5 - Component Proxy \u0026 Methods\n\nWhen utilizing the Glimmer GUI DSL, you get back proxy objects that wrap [FOX Toolkit](http://www.fox-toolkit.org/) controls. To access the original control wrapped by the proxy object, you may call the `#fx` method.\n\nFurthermore, you may invoke any method available on the control indirectly on the proxy object, like the `#text` method on `label`.\n\n```ruby\nlabel1 = nil\napp('HelloWorld', 'Glimmer') {\n  main_window('Hello, World!') {\n    label1 = label('Full Name')\n  }\n}\nputs label1.text # prints: Full Name\nputs label1.fx.text # prints: Full Name\nlabel1.text = 'Name'\nputs label1.text # prints: Name\nputs label1.fx.text # prints: Name\nlabel1.fx.text = 'Whole Name'\nputs label1.text # prints: Whole Name\nputs label1.fx.text # prints: Whole Name\n```\n\n6 - Observe Model Attributes\n\nIn Smalltalk-MVC ([Model View Controller](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) Architectural Pattern), the View is an active View that observes the Model for changes and updates itself.\n\n![MVC](http://3.bp.blogspot.com/-4eW59Ao0ess/ToiBzAiYdZI/AAAAAAAAAOg/SiYa6XHwBFE/s320/Screen+shot+2011-10-02+at+10.22.11+AM.png)\n\nThis can be achieved with the Glimmer GUI DSL using the `observe` keyword, which takes a model (any object, including `self`) and attribute Symbol or String expression (e.g. `:count` or `'address.street'`), and decouples the Model from the View.\n\nThe model is automatically enhanced as an `Glimmer::DataBinding::ObservableModel` / `Glimmer::DataBinding::ObservableHash` / `Glimmer::DataBinding::ObservableArray` depending on its type to support notifying observers of attribute changes (when performed using the attribute writer, which automatically calls added method `notify_observers(attribute)`)\n\nNote that it is usually recommended to observe external model objects (not `self`), but `self` is OK in very simple cases or presentation-related attributes only.\n\nExample:\n\n```ruby\nrequire 'glimmer-dsl-fx'\n\nclass Counter\n  attr_accessor :count\n\n  def initialize\n    self.count = 0\n  end\nend\n\nclass HelloButton\n  include Glimmer\n  \n  def initialize\n    @counter = Counter.new\n\n    observe(@counter, :count) do |new_count|\n      @button.text = \"Click To Increment: #{new_count}\"\n    end\n  end\n  \n  def launch\n    app('HelloButton', 'Glimmer') {\n      main_window('Hello, Button!') {\n        @button = button('Click To Increment: 0', opts: [:frame_raised, :frame_thick, :layout_center_x, :layout_center_y]) {\n          on(:command) do\n            @counter.count += 1\n          end\n        }\n      }\n    }.run\n  end\nend\n\nHelloButton.new.launch\n```\n\nWindows | Mac\n--------|----\n![screenshots/glimmer-dsl-fx-windows-hello-button.png](screenshots/glimmer-dsl-fx-windows-hello-button.png) | ![screenshots/glimmer-dsl-fx-mac-hello-button.png](screenshots/glimmer-dsl-fx-mac-hello-button.png)\n\n## Smart Defaults and Conventions\n\n- `app` automatically shows `main_window` upon calling `run` while staring the main event loop.\n- `app` automatically invokes `open -a /Applications/Utilities/XQuartz.app` upon running on Mac.\n- Declaring `app` multiple times always returns the first `app` created ([FOX Toolkit](http://www.fox-toolkit.org/) does not support multiple `app` instances)\n\n## Girb (Glimmer IRB)\n\nYou can run the `girb` command (`bin/girb` if you cloned the project locally):\n\n```\ngirb\n```\n\nWindows | Mac\n--------|----\n![girb screenshot windows](/screenshots/glimmer-dsl-fx-windows-girb.png) | ![girb screenshot mac](/screenshots/glimmer-dsl-fx-mac-girb.png)\n\nThis gives you `irb` with the `glimmer-dsl-fx` gem loaded and the `Glimmer` module mixed into the main object for easy experimentation with GUI.\n\nNote: GIRB for Glimmer DSL for FX 0.0.2 is still very rudimentary and does not support entering code for multiple applications, yet only one. You would have to exit and re-enter after each application entered.\n\nGotcha: On the Mac, when you close a window opened in `girb`, it remains open until you enter `exit`.\n\n## Samples\n\nYou may checkout the [samples](samples) directory for examples of using [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx).\n\n### Hello Samples\n\n#### Hello, World!\n\n[samples/hello/hello_world.rb](/samples/hello/hello_world.rb)\n\nWindows | Mac\n--------|----\n![hello world screenshot windows](/screenshots/glimmer-dsl-fx-windows-hello-world.png) | ![hello world screenshot mac](/screenshots/glimmer-dsl-fx-mac-hello-world.png)\n\nRun (via installed gem):\n\n```\nruby -r glimmer-dsl-fx -e \"require 'samples/hello/hello_world'\"\n```\n\nRun (via locally cloned project):\n\n```\nruby -r ./lib/glimmer-dsl-fx.rb samples/hello/hello_world.rb\n```\n\nCode:\n\n```ruby\nrequire 'glimmer-dsl-fx'\n\ninclude Glimmer\n\napp('HelloWorld', 'Glimmer') {\n  main_window('Hello, World!') {\n    label('Hello, World!')\n  }\n}.run\n```\n\n#### Hello, Button!\n\n[samples/hello/hello_button.rb](/samples/hello/hello_button.rb)\n\nWindows | Mac\n--------|----\n![screenshots/glimmer-dsl-fx-windows-hello-button.png](screenshots/glimmer-dsl-fx-windows-hello-button.png) | ![screenshots/glimmer-dsl-fx-mac-hello-button.png](screenshots/glimmer-dsl-fx-mac-hello-button.png)\n\nRun (via installed gem):\n\n```\nruby -r glimmer-dsl-fx -e \"require 'samples/hello/hello_button'\"\n```\n\nRun (via locally cloned project):\n\n```\nruby -r ./lib/glimmer-dsl-fx.rb samples/hello/hello_button.rb\n```\n\nCode:\n\n```ruby\nrequire 'glimmer-dsl-fx'\n\nclass HelloButton\n  include Glimmer\n  \n  def initialize\n    @count = 0\n  end\n  \n  def launch\n    app('HelloButton', 'Glimmer') {\n      main_window('Hello, Button!') {\n        @button = button(\"Click To Increment: 0\", opts: [:frame_raised, :frame_thick, :layout_center_x, :layout_center_y]) {\n          on(:command) do\n            @count += 1\n            @button.text = \"Click To Increment: #{@count}\"\n          end\n        }\n      }\n    }.run\n  end\nend\n\nHelloButton.new.launch\n```\n\n## Resources\n\n- fxruby gem: https://github.com/larskanis/fxruby\n- FOX Toolkit: http://www.fox-toolkit.org\n- FOX Toolkit Documentation: http://www.fox-toolkit.org/doc.html\n- FOX Toolkit 1.6 API Reference: http://www.fox-toolkit.org/ref16/classes.html\n\n## Process\n\n[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)\n\n## Help\n\n### Issues\n\nIf you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-fx/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use FX than what is possible with [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-fx/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-fx/compare) on [GitHub](https://github.com). In the meantime while waiting for a fix, you may try older gem versions of [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx) in case you find one that does not have the issue and actually works.\n\n### Chat\n\nIf you need live help, try to [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## Planned Features and Feature Suggestions\n\nThese features have been planned or suggested. You might see them in a future version of [Glimmer DSL for FX](https://rubygems.org/gems/glimmer-dsl-fx). You are welcome to contribute more feature suggestions.\n\n[TODO.md](TODO.md)\n\n## Change Log\n\n[CHANGELOG.md](CHANGELOG.md)\n\n## Contributing\n\n-   Check out the latest master to make sure the feature hasn't been\n    implemented or the bug hasn't been fixed yet.\n-   Check out the issue tracker to make sure someone already hasn't\n    requested it and/or contributed it.\n-   Fork the project.\n-   Start a feature/bugfix branch.\n-   Commit and push until you are happy with your contribution.\n-   Make sure to add tests for it. This is important so I don't break it\n    in a future version unintentionally.\n-   Please try not to mess with the Rakefile, version, or history. If\n    you want to have your own version, or is otherwise necessary, that\n    is fine, but please isolate to its own commit so I can cherry-pick\n    around it.\n\n## Contributors\n\n* [Andy Maleh](https://github.com/AndyObtiva) (Founder)\n\n[Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-fx/graphs/contributors)\n\n## Copyright\n\n[LGPL](LICENSE.txt)\n\nCopyright (c) 2021 Andy Maleh.\n\n--\n\n[\u003cimg src=\"https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png\" height=40 /\u003e](https://github.com/AndyObtiva/glimmer) Built for [Glimmer](https://github.com/AndyObtiva/glimmer) (DSL Framework).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyobtiva%2Fglimmer-dsl-fx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyobtiva%2Fglimmer-dsl-fx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyobtiva%2Fglimmer-dsl-fx/lists"}