DEV Community

Cover image for Glimmer DSL for SWT 4.21 (New SWT/JRuby/JDK)
Andy Maleh
Andy Maleh

Posted on

Glimmer DSL for SWT 4.21 (New SWT/JRuby/JDK)

Glimmer DSL for SWT 4.21 is the quarterly major release that ships with a new version of SWT (released in 2021-09) as well as other big changes like JRuby 9.3.0.0 and JDK 16:

  • Upgrade to SWT 4.21
  • Upgrade to JDK 16.0.2
  • Upgrade to JRuby 9.3.0.0
  • Update packaging to rely on JDK 16 jpackage (instead of older JDK 8 javapackager)
  • Renamed Glimmer::RakeTask::Package.javapackager_extra_args to Glimmer::RakeTask::Package.jpackage_extra_args to match the name of jpackage in JDK 16
  • Change package/[os] scaffolding placement for packaging icons into icons/[os] to accomodate Java 9 Module security for icon retrieval from within a JAR

The biggest difference in this version of SWT is auto-switching to Dark Mode on the Mac.

image 1

image 2

image 3

If you encounter any issues due to the big upgrade from JDK 8 to JDK 16 and jpackage for native-executable packaging, please report in an issue request. There is one annoying message that shows up during packaging with Warbler (unsupported Java version "16", defaulting to 1.7), which seems caused by running JRuby on JDK 16, but I was able to contain its damage and render it harmless (at least as far as I could tell).

In other news, a new Glimmer DSL has been brewing:

Glimmer DSL for LibUI is a prerequisite-free CRuby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent native GUI that just works!

glimmer dsl libui

# From: https://github.com/AndyObtiva/glimmer-dsl-libui#control-gallery

require 'glimmer-dsl-libui'

include Glimmer

menu('File') {
  menu_item('Open') {
    on_clicked do
      file = open_file(MAIN_WINDOW)
      puts file unless file.nil?
    end
  }

  menu_item('Save') {
    on_clicked do
      file = save_file(MAIN_WINDOW)
      puts file unless file.nil?
    end
  }

  quit_menu_item {
    on_clicked do
      puts 'Bye Bye'
    end
  }

  preferences_menu_item # Can optionally contain an on_clicked listener
}

menu('Edit') {
  check_menu_item('Checkable Item_')
  separator_menu_item
  menu_item('Disabled Item_') {
    enabled false
  }
}

menu('Help') {
  menu_item('Help')

  about_menu_item # Can optionally contain an on_clicked listener
}

MAIN_WINDOW = window('Control Gallery', 600, 500) {
  margined true

  on_closing do
    puts 'Bye Bye'
  end

  vertical_box {
    horizontal_box {
      group('Basic Controls') {
        vertical_box {
          button('Button') {
            stretchy false

            on_clicked do
              msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
            end
          }

          checkbox('Checkbox') {
            stretchy false

            on_toggled do |c|
              checked = c.checked?
              MAIN_WINDOW.title = "Checkbox is #{checked}"
              c.text = "I am the checkbox (#{checked})"
            end
          }

          label('Label') { stretchy false }

          horizontal_separator { stretchy false }

          date_picker { stretchy false }

          time_picker { stretchy false }

          date_time_picker { stretchy false }

          font_button { stretchy false }

          color_button { stretchy false }
        }
      }

      vertical_box {
        group('Numbers') {
          stretchy false

          vertical_box {
            spinbox(0, 100) {
              stretchy false
              value 42

              on_changed do |s|
                puts "New Spinbox value: #{s.value}"
              end
            }

            slider(0, 100) {
              stretchy false

              on_changed do |s|
                v = s.value
                puts "New Slider value: #{v}"
                @progress_bar.value = v
              end
            }

            @progress_bar = progress_bar { stretchy false }
          }
        }

        group('Lists') {
          stretchy false

          vertical_box {
            combobox {
              stretchy false
              items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument

              on_selected do |c|
                puts "New combobox selection: #{c.selected}"
              end
            }

            editable_combobox {
              stretchy false
              items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
            }

            radio_buttons {
              items 'Radio Button 1', 'Radio Button 2', 'Radio Button 3' # also accepts a single array argument
            }
          }
        }

        tab {
          tab_item('Page 1') {
            horizontal_box {
              entry {
                text 'Please enter your feelings'

                on_changed do |e|
                  puts "Current textbox data: '#{e.text}'"
                end
              }
            }
          }

          tab_item('Page 2') {
            horizontal_box
          }

          tab_item('Page 3') {
            horizontal_box
          }
        }
      }
    }
  }
}

MAIN_WINDOW.show
Enter fullscreen mode Exit fullscreen mode

Happy Glimmering!

Top comments (0)