SlideShare une entreprise Scribd logo
Glimmer DSL for SWT
Ruby Desktop Development GUI Framework
Andy Maleh (Senior Software Developer at Lexop)
Montreal.rb • 2022-10-05
We Want Native GUI
● We want to build a native Graphical User Interface in Ruby to:
○ Productively build apps that support visual user interaction
○ Build online applications for specific users w/o needing browser
○ Quickly build offline applications that do not need Internet
○ Report and summarize data from databases securely locally
○ Provide user-friendly platform-conforming native user interfaces
We Want Native GUI
● We want to build a native Graphical User Interface in Ruby to:
○ Avoid writing many layers of complex web code
○ Avoid wasting time fine-tuning graphical user interfaces
○ Provide fast performance for graphical widget input/output
○ Quickly invent brand new visual concepts for user interaction
○ Build local games
Intro GUI Samples
Intro GUI Samples
● Prerequisites: JRuby & JVM
● Install:
○ gem install glimmer-dsl-swt
● Run samples through Glimmer Meta-Sample (Sample of Samples):
○ glimmer samples
Intro GUI Samples
● Hello, World!
Intro GUI Samples
● Contact Manager
Intro GUI Samples
● Tetris
Real World Apps - Math Bowling 2
Real World Apps - Math Bowling 2
Real World Apps - Are We There Yet?
Real World Apps - Gladiator Code Editor
Real World Apps - DCR Prog Lang
Real World Apps - Befunge Prog Lang
Real World Apps - Klondike Solitaire
Real World Apps - Wordle
Real World Apps - Wordle
GUI DSL Basics
● Widget Keyword
○ Underscored case of SWT widget class name
○ Declarative widget construction
GUI DSL Basics
● 1) Widget Keyword
○ Underscored case of SWT widget class name
○ Declarative widget construction
GUI DSL Basics
● 1) Widget Keyword
○ Underscored case of SWT widget class name
○ Declarative widget construction
GUI DSL Basics
● 1) Widget Keyword
○ Underscored case of SWT widget class name
○ Declarative widget construction
GUI DSL Basics
● 1) Widget Keyword
○ Underscored case of SWT widget class name
○ Declarative widget construction
GUI DSL Basics
● 2) Widget Arguments
○ Optional
○ Usually SWT Styles (underscored-case Ruby symbols)
GUI DSL Basics
● 2) Widget Arguments
○ Optional
○ Usually SWT Styles (underscored-case Ruby symbols)
GUI DSL Basics
● 3) Widget Content Block
○ Properties
○ Listeners
GUI DSL Basics
● 3) Widget Content Block
○ Properties
○ Listeners
GUI DSL Basics
● 3a) Widget Content Block - Properties
○ Include Layout and Layout Data
GUI DSL Basics
● 3a) Widget Content Block - Properties
GUI DSL Basics
● 3b) Widget Content Block - Listeners
○ Observer Pattern
○ Imperative code block
GUI DSL Basics
● 3b) Widget Content Block - Listeners
GUI DSL Basics
● 3b) Widget Content Block - Listeners
GUI DSL Basics
● 4) Widget Operations
○ Invoked through Ruby Methods
○ Match SWT widget API
○ Proxy calls to SWT wrapped widget objects
○ JRuby provides ruby-friendly versions of SWT API methods
○ Behavior is sometimes augmented with smart defaults
■ e.g. shell.open starts GUI event loop
GUI DSL Basics
● 4) Widget Operations
GUI DSL Basics
● 4) Widget Operations
GUI DSL Basics
● 4) Widget Operations
Software Architecture - MVC
Software Architecture - MVC
Software Architecture - MVP
MVC Example - Explicit Controller
https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvc-example---explicit-controller
MVC Example - Implicit Controller
https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvc-example---implicit-controller
MVC Example - Explicit Presenter
https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvp-example---explicit-presenter
MVC Example - Implicit Presenter
https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvp-example---implicit-presenter
MVC Example - Bidirectional Data-Binding
https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvp-example---implicit-presenter-with-bidirectional-data-binding
Data-Binding
● Bidirectional with <=> for read/write properties
Data-Binding
● Unidirectional with <= for read-only properties
Data-Binding
● Converters
○ on_read from the model
○ on_write to the model
Data-Binding
● Converters
○ on_read from the model
○ on_write to the model
Data-Binding
● Hooks
○ before_read
○ after_read
○ before_write
○ after_write
Data-Binding
● Nested Data-Binding
Data-Binding
● Indexed Data-Binding
Data-Binding
● Keyed Data-Binding
Data-Binding
● Computed Data-Binding
Widget Samples - General
● Hello, World!
● Hello, Label!
● Hello, Text!
● Hello, Button!
● Hello, Spinner!
● Hello, Checkbox!
● Hello, Radio!
● Hello, Shell!
● Hello, Combo!
● Hello, List!
● Hello, Table!
● Hello, Refined Table!
● Hello, Tree!
● Hello, Styled Text!
● Hello, Code Text!
● Hello, Browser!
(Webkit/Edge/Chromium webview
with ability to hook Ruby code to
JavaScript page events)
Widget Samples - Organizational
● Hello, Composite!
● Hello, Scrolled Composite!
● Hello, Sash Form!
● Hello, Group!
● Hello, Tab!
● Hello, Tool Bar!
● Hello, Cool Bar!
● Hello, Tray Item!
● Hello, Menu Bar!
● Hello, Pop Up Context Menu!
Widget Samples - Dialogs
● Hello, Message Box!
● Hello, Color Dialog!
● Hello, Font Dialog!
● Hello, File Dialog!
● Hello, Directory Dialog!
● Hello, Print Dialog!
● Hello, Dialog!
Canvas Graphics
● Canvas Shape DSL shapes:
○ point
○ line
○ rectangle
○ oval
○ arc
○ polygon
○ polyline
○ image
○ text
Canvas Graphics
● Hello, Canvas!
● Hello, Canvas Shape Listeners!
● Hello, Canvas Data Binding!
● Hello, Canvas Drag and Drop!
● Hello, Canvas Transform!
● Hello, Canvas Path!
● Hello, Canvas Animation!
● Hello, Canvas Animation Multi!
Custom Components
● Custom Widgets (Hello, Custom Widget!)
○ include Glimmer::UI::CustomWidget
○ Accept options
○ Useful for:
■ Specializing Widgets
■ Aggregating Widgets
■ Build brand new non-native widgets with Canvas graphics
Custom Components
● Custom Shells (Hello, Custom Shell!)
○ include Glimmer::UI::CustomShell
○ Or include Glimmer::UI::CustomWindow
○ Or include Glimmer::UI::Application
○ Apps or Reusable custom windows
○ Custom shells are also custom widgets
Custom Components
● Custom Shapes (Hello, Custom Shape!)
○ include Glimmer::UI::CustomShape
○ Accept options
○ Aggregate multiple shapes
○ Support relative positioning
Drag and Drop
● drag_source
● drop_target
● on_drag_detected
● on_drag_start
● on_drag_set_data
● on_drop
● Hello, Drag and Drop!
● Hello, Canvas Drag and Drop!
Canvas Drag and Drop
● drag_source
● on_drop
● drag_and_move
● Run glimmer command to get instructions:
○ glimmer
glimmer scaffold[app_name]
glimmer scaffold:customshape[name,namespace]
glimmer scaffold:customshell[name,namespace]
glimmer scaffold:customwidget[name,namespace]
Scaffolding
Scaffolding
● Run glimmer command to get instructions:
○ glimmer
glimmer scaffold:desktopify[app_name,website]
glimmer scaffold:gem:customshape[name,namespace]
glimmer scaffold:gem:customshell[name,namespace]
glimmer scaffold:gem:customwidget[name,namespace]
Scaffolding - Application
● glimmer scaffold[app] will generate a full app
● Models live in app/app_name/model namespace
● Views live in app/app_name/view namespace
● App can be run with bin/script or this command:
○ glimmer run
● App can be packaged as a Ruby gem out of the box using Juwelier
● App main window entry point is:
app/app_name/view/app_view.rb
Native Executable Packaging
● Make sure to have MSI packaging prerequisites on Windows only
● Run packaging command:
○ glimmer package
● Run specialized packaging command:
○ glimmer package[dmg]
○ glimmer package[pkg]
○ glimmer package[msi]
○ glimmer package[deb]
○ glimmer package[rpm]
Native Executable Packaging
● On Mac, it will generate under packages:
○ DMG file format
○ PKG file format
● On Windows, it will generate under packages:
○ EXE file format
○ MSI file format
● On Linux, it will generate under packages:
○ DEB file format
○ RPM file format
Review Intro GUI Samples
● Hello, World!
Review Intro GUI Samples
● Contact Manager
Review Intro GUI Samples
● Tetris
Summary
● We Want Native GUI
● Intro GUI Samples
● Real World Apps
● GUI DSL Basics
● Data-Binding
● Software Architecture
● Widget Samples
● Canvas Graphics
● Custom Components
● Drag and Drop
● Scaffolding
● Native Executable Packaging
Other Glimmer GUI
DSLs
● Glimmer DSL for LibUI (CRuby)
[Fukuoka Ruby 2022 Special
Award Winner]
● Glimmer DSL for Tk (CRuby)
● Glimmer DSL for GTK (CRuby)
● Glimmer DSL for FX (CRuby)
● Glimmer DSL for Swing (JRuby)
● Glimmer DSL for JavaFX (JRuby)
Resources
● https://github.com/AndyObtiva
/glimmer-dsl-swt
● https://github.com/AndyObtiva
● https://andymaleh.blogspot.com
● https://twitter.com/AndyObtiva
● https://www.youtube.com/chann
el/UC5hzDE23HZXsZLAxYk2UJEw
● We are hiring at https://lexop.com

Contenu connexe

Similaire à Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI Framework

Griffon for the Enterprise
Griffon for the EnterpriseGriffon for the Enterprise
Griffon for the Enterprise
James Williams
 
Intro to Flutter SDK
Intro to Flutter SDKIntro to Flutter SDK
Intro to Flutter SDK
digitaljoni
 
How I Built My Code Editor in Ruby
How I Built My Code Editor in RubyHow I Built My Code Editor in Ruby
How I Built My Code Editor in Ruby
Andy Maleh
 
Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)
Igalia
 
2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer
Horacio Gonzalez
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
WebStackAcademy
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
Paul Jensen
 
React native introduction (Mobile Warsaw)
React native introduction (Mobile Warsaw)React native introduction (Mobile Warsaw)
React native introduction (Mobile Warsaw)
Jarek Potiuk
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
Emma Jane Hogbin Westby
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Women in Technology Poland
 
Dust.js
Dust.jsDust.js
Android Lollipop: The developer's perspective
Android Lollipop: The developer's perspectiveAndroid Lollipop: The developer's perspective
Android Lollipop: The developer's perspective
Sebastian Vieira
 
Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
Matthias Luebken
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
Robert Schadek
 
Introducing chrome apps (ogura)
Introducing chrome apps (ogura)Introducing chrome apps (ogura)
Introducing chrome apps (ogura)
Kazuhiro Ogura
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
Masashi Umezawa
 
Xlab #2: wzorce projektowe
Xlab #2: wzorce projektoweXlab #2: wzorce projektowe
Xlab #2: wzorce projektowe
XSolve
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
Dmytro Ovcharenko
 
Dot Net Training in Chennai
Dot Net Training in ChennaiDot Net Training in Chennai
Dot Net Training in Chennai
jeevanfita
 
The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)
Igalia
 

Similaire à Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI Framework (20)

Griffon for the Enterprise
Griffon for the EnterpriseGriffon for the Enterprise
Griffon for the Enterprise
 
Intro to Flutter SDK
Intro to Flutter SDKIntro to Flutter SDK
Intro to Flutter SDK
 
How I Built My Code Editor in Ruby
How I Built My Code Editor in RubyHow I Built My Code Editor in Ruby
How I Built My Code Editor in Ruby
 
Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)
 
2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
 
React native introduction (Mobile Warsaw)
React native introduction (Mobile Warsaw)React native introduction (Mobile Warsaw)
React native introduction (Mobile Warsaw)
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Dust.js
Dust.jsDust.js
Dust.js
 
Android Lollipop: The developer's perspective
Android Lollipop: The developer's perspectiveAndroid Lollipop: The developer's perspective
Android Lollipop: The developer's perspective
 
Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
Introducing chrome apps (ogura)
Introducing chrome apps (ogura)Introducing chrome apps (ogura)
Introducing chrome apps (ogura)
 
Revealing ALLSTOCKER
Revealing ALLSTOCKERRevealing ALLSTOCKER
Revealing ALLSTOCKER
 
Xlab #2: wzorce projektowe
Xlab #2: wzorce projektoweXlab #2: wzorce projektowe
Xlab #2: wzorce projektowe
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
 
Dot Net Training in Chennai
Dot Net Training in ChennaiDot Net Training in Chennai
Dot Net Training in Chennai
 
The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)
 

Plus de Andy Maleh

Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
Andy Maleh
 
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupBecoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Andy Maleh
 
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Andy Maleh
 
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy MalehRailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
Andy Maleh
 
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbUltra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Andy Maleh
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Andy Maleh
 
Software Craftsmanship VS Software Engineering
Software Craftsmanship VS Software EngineeringSoftware Craftsmanship VS Software Engineering
Software Craftsmanship VS Software Engineering
Andy Maleh
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
Andy Maleh
 
Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)
Andy Maleh
 
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Andy Maleh
 
Software Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for RubyistsSoftware Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for Rubyists
Andy Maleh
 
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for RubyistsSoftware Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Andy Maleh
 
The Rails Engine That Could - In Motion
The Rails Engine That Could - In MotionThe Rails Engine That Could - In Motion
The Rails Engine That Could - In Motion
Andy Maleh
 
The Rails Engine That Could
The Rails Engine That CouldThe Rails Engine That Could
The Rails Engine That Could
Andy Maleh
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
Andy Maleh
 
Simplifying Desktop Development With Glimmer
Simplifying Desktop Development With GlimmerSimplifying Desktop Development With Glimmer
Simplifying Desktop Development With Glimmer
Andy Maleh
 

Plus de Andy Maleh (16)

Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
 
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby MeetupBecoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
Becoming a SOC2 Ruby Shop - Montreal.rb November, 5, 2022 Ruby Meetup
 
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014Ultra Light and Maintainable Rails Wizards at RailsConf 2014
Ultra Light and Maintainable Rails Wizards at RailsConf 2014
 
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy MalehRailsConf 2014 Recap at Montreal.rb by Andy Maleh
RailsConf 2014 Recap at Montreal.rb by Andy Maleh
 
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rbUltra Light and Maintainable Wizards in Rails at Montreal.rb
Ultra Light and Maintainable Wizards in Rails at Montreal.rb
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
 
Software Craftsmanship VS Software Engineering
Software Craftsmanship VS Software EngineeringSoftware Craftsmanship VS Software Engineering
Software Craftsmanship VS Software Engineering
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
 
Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)Software Craftsmanship vs Software Engineering (Lightning Talk)
Software Craftsmanship vs Software Engineering (Lightning Talk)
 
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
Software Design Trilogy Part III - Domain Driven Design for Ruby on Rails App...
 
Software Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for RubyistsSoftware Design Trilogy Part II - Design Patterns for Rubyists
Software Design Trilogy Part II - Design Patterns for Rubyists
 
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for RubyistsSoftware Design Trilogy Part I - Responsibility Driven Design for Rubyists
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
 
The Rails Engine That Could - In Motion
The Rails Engine That Could - In MotionThe Rails Engine That Could - In Motion
The Rails Engine That Could - In Motion
 
The Rails Engine That Could
The Rails Engine That CouldThe Rails Engine That Could
The Rails Engine That Could
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
 
Simplifying Desktop Development With Glimmer
Simplifying Desktop Development With GlimmerSimplifying Desktop Development With Glimmer
Simplifying Desktop Development With Glimmer
 

Dernier

Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert
vaishalijagtap12
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
Severalnines
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
DevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps ServicesDevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps Services
seospiralmantra
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 

Dernier (20)

Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
DevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps ServicesDevOps Consulting Company | Hire DevOps Services
DevOps Consulting Company | Hire DevOps Services
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 

Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI Framework

  • 1. Glimmer DSL for SWT Ruby Desktop Development GUI Framework Andy Maleh (Senior Software Developer at Lexop) Montreal.rb • 2022-10-05
  • 2. We Want Native GUI ● We want to build a native Graphical User Interface in Ruby to: ○ Productively build apps that support visual user interaction ○ Build online applications for specific users w/o needing browser ○ Quickly build offline applications that do not need Internet ○ Report and summarize data from databases securely locally ○ Provide user-friendly platform-conforming native user interfaces
  • 3. We Want Native GUI ● We want to build a native Graphical User Interface in Ruby to: ○ Avoid writing many layers of complex web code ○ Avoid wasting time fine-tuning graphical user interfaces ○ Provide fast performance for graphical widget input/output ○ Quickly invent brand new visual concepts for user interaction ○ Build local games
  • 5. Intro GUI Samples ● Prerequisites: JRuby & JVM ● Install: ○ gem install glimmer-dsl-swt ● Run samples through Glimmer Meta-Sample (Sample of Samples): ○ glimmer samples
  • 6. Intro GUI Samples ● Hello, World!
  • 7. Intro GUI Samples ● Contact Manager
  • 9. Real World Apps - Math Bowling 2
  • 10. Real World Apps - Math Bowling 2
  • 11. Real World Apps - Are We There Yet?
  • 12. Real World Apps - Gladiator Code Editor
  • 13. Real World Apps - DCR Prog Lang
  • 14. Real World Apps - Befunge Prog Lang
  • 15. Real World Apps - Klondike Solitaire
  • 16. Real World Apps - Wordle
  • 17. Real World Apps - Wordle
  • 18. GUI DSL Basics ● Widget Keyword ○ Underscored case of SWT widget class name ○ Declarative widget construction
  • 19. GUI DSL Basics ● 1) Widget Keyword ○ Underscored case of SWT widget class name ○ Declarative widget construction
  • 20. GUI DSL Basics ● 1) Widget Keyword ○ Underscored case of SWT widget class name ○ Declarative widget construction
  • 21. GUI DSL Basics ● 1) Widget Keyword ○ Underscored case of SWT widget class name ○ Declarative widget construction
  • 22. GUI DSL Basics ● 1) Widget Keyword ○ Underscored case of SWT widget class name ○ Declarative widget construction
  • 23. GUI DSL Basics ● 2) Widget Arguments ○ Optional ○ Usually SWT Styles (underscored-case Ruby symbols)
  • 24. GUI DSL Basics ● 2) Widget Arguments ○ Optional ○ Usually SWT Styles (underscored-case Ruby symbols)
  • 25. GUI DSL Basics ● 3) Widget Content Block ○ Properties ○ Listeners
  • 26. GUI DSL Basics ● 3) Widget Content Block ○ Properties ○ Listeners
  • 27. GUI DSL Basics ● 3a) Widget Content Block - Properties ○ Include Layout and Layout Data
  • 28. GUI DSL Basics ● 3a) Widget Content Block - Properties
  • 29. GUI DSL Basics ● 3b) Widget Content Block - Listeners ○ Observer Pattern ○ Imperative code block
  • 30. GUI DSL Basics ● 3b) Widget Content Block - Listeners
  • 31. GUI DSL Basics ● 3b) Widget Content Block - Listeners
  • 32. GUI DSL Basics ● 4) Widget Operations ○ Invoked through Ruby Methods ○ Match SWT widget API ○ Proxy calls to SWT wrapped widget objects ○ JRuby provides ruby-friendly versions of SWT API methods ○ Behavior is sometimes augmented with smart defaults ■ e.g. shell.open starts GUI event loop
  • 33. GUI DSL Basics ● 4) Widget Operations
  • 34. GUI DSL Basics ● 4) Widget Operations
  • 35. GUI DSL Basics ● 4) Widget Operations
  • 39. MVC Example - Explicit Controller https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvc-example---explicit-controller
  • 40. MVC Example - Implicit Controller https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvc-example---implicit-controller
  • 41. MVC Example - Explicit Presenter https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvp-example---explicit-presenter
  • 42. MVC Example - Implicit Presenter https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvp-example---implicit-presenter
  • 43. MVC Example - Bidirectional Data-Binding https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#mvp-example---implicit-presenter-with-bidirectional-data-binding
  • 44. Data-Binding ● Bidirectional with <=> for read/write properties
  • 45. Data-Binding ● Unidirectional with <= for read-only properties
  • 46. Data-Binding ● Converters ○ on_read from the model ○ on_write to the model
  • 47. Data-Binding ● Converters ○ on_read from the model ○ on_write to the model
  • 48. Data-Binding ● Hooks ○ before_read ○ after_read ○ before_write ○ after_write
  • 53. Widget Samples - General ● Hello, World! ● Hello, Label! ● Hello, Text! ● Hello, Button! ● Hello, Spinner! ● Hello, Checkbox! ● Hello, Radio! ● Hello, Shell! ● Hello, Combo! ● Hello, List! ● Hello, Table! ● Hello, Refined Table! ● Hello, Tree! ● Hello, Styled Text! ● Hello, Code Text! ● Hello, Browser! (Webkit/Edge/Chromium webview with ability to hook Ruby code to JavaScript page events)
  • 54. Widget Samples - Organizational ● Hello, Composite! ● Hello, Scrolled Composite! ● Hello, Sash Form! ● Hello, Group! ● Hello, Tab! ● Hello, Tool Bar! ● Hello, Cool Bar! ● Hello, Tray Item! ● Hello, Menu Bar! ● Hello, Pop Up Context Menu!
  • 55. Widget Samples - Dialogs ● Hello, Message Box! ● Hello, Color Dialog! ● Hello, Font Dialog! ● Hello, File Dialog! ● Hello, Directory Dialog! ● Hello, Print Dialog! ● Hello, Dialog!
  • 56. Canvas Graphics ● Canvas Shape DSL shapes: ○ point ○ line ○ rectangle ○ oval ○ arc ○ polygon ○ polyline ○ image ○ text
  • 57. Canvas Graphics ● Hello, Canvas! ● Hello, Canvas Shape Listeners! ● Hello, Canvas Data Binding! ● Hello, Canvas Drag and Drop! ● Hello, Canvas Transform! ● Hello, Canvas Path! ● Hello, Canvas Animation! ● Hello, Canvas Animation Multi!
  • 58. Custom Components ● Custom Widgets (Hello, Custom Widget!) ○ include Glimmer::UI::CustomWidget ○ Accept options ○ Useful for: ■ Specializing Widgets ■ Aggregating Widgets ■ Build brand new non-native widgets with Canvas graphics
  • 59. Custom Components ● Custom Shells (Hello, Custom Shell!) ○ include Glimmer::UI::CustomShell ○ Or include Glimmer::UI::CustomWindow ○ Or include Glimmer::UI::Application ○ Apps or Reusable custom windows ○ Custom shells are also custom widgets
  • 60. Custom Components ● Custom Shapes (Hello, Custom Shape!) ○ include Glimmer::UI::CustomShape ○ Accept options ○ Aggregate multiple shapes ○ Support relative positioning
  • 61. Drag and Drop ● drag_source ● drop_target ● on_drag_detected ● on_drag_start ● on_drag_set_data ● on_drop ● Hello, Drag and Drop! ● Hello, Canvas Drag and Drop!
  • 62. Canvas Drag and Drop ● drag_source ● on_drop ● drag_and_move
  • 63. ● Run glimmer command to get instructions: ○ glimmer glimmer scaffold[app_name] glimmer scaffold:customshape[name,namespace] glimmer scaffold:customshell[name,namespace] glimmer scaffold:customwidget[name,namespace] Scaffolding
  • 64. Scaffolding ● Run glimmer command to get instructions: ○ glimmer glimmer scaffold:desktopify[app_name,website] glimmer scaffold:gem:customshape[name,namespace] glimmer scaffold:gem:customshell[name,namespace] glimmer scaffold:gem:customwidget[name,namespace]
  • 65. Scaffolding - Application ● glimmer scaffold[app] will generate a full app ● Models live in app/app_name/model namespace ● Views live in app/app_name/view namespace ● App can be run with bin/script or this command: ○ glimmer run ● App can be packaged as a Ruby gem out of the box using Juwelier ● App main window entry point is: app/app_name/view/app_view.rb
  • 66. Native Executable Packaging ● Make sure to have MSI packaging prerequisites on Windows only ● Run packaging command: ○ glimmer package ● Run specialized packaging command: ○ glimmer package[dmg] ○ glimmer package[pkg] ○ glimmer package[msi] ○ glimmer package[deb] ○ glimmer package[rpm]
  • 67. Native Executable Packaging ● On Mac, it will generate under packages: ○ DMG file format ○ PKG file format ● On Windows, it will generate under packages: ○ EXE file format ○ MSI file format ● On Linux, it will generate under packages: ○ DEB file format ○ RPM file format
  • 68. Review Intro GUI Samples ● Hello, World!
  • 69. Review Intro GUI Samples ● Contact Manager
  • 70. Review Intro GUI Samples ● Tetris
  • 71. Summary ● We Want Native GUI ● Intro GUI Samples ● Real World Apps ● GUI DSL Basics ● Data-Binding ● Software Architecture ● Widget Samples ● Canvas Graphics ● Custom Components ● Drag and Drop ● Scaffolding ● Native Executable Packaging
  • 72. Other Glimmer GUI DSLs ● Glimmer DSL for LibUI (CRuby) [Fukuoka Ruby 2022 Special Award Winner] ● Glimmer DSL for Tk (CRuby) ● Glimmer DSL for GTK (CRuby) ● Glimmer DSL for FX (CRuby) ● Glimmer DSL for Swing (JRuby) ● Glimmer DSL for JavaFX (JRuby)
  • 73. Resources ● https://github.com/AndyObtiva /glimmer-dsl-swt ● https://github.com/AndyObtiva ● https://andymaleh.blogspot.com ● https://twitter.com/AndyObtiva ● https://www.youtube.com/chann el/UC5hzDE23HZXsZLAxYk2UJEw ● We are hiring at https://lexop.com