How to obtain a macOS transparent titlebar effect in SWT/Shoes via JRuby

97 views Asked by At

I'm trying to obtain this effect (transparent title bar and full sized content) while using Shoes. However, I figured SWT doesn't even offer this option.

Transparent Title Bar

How can I attain this?

1

There are 1 answers

3
pedrozath On BEST ANSWER

This is how I achieved:

I placed this code right before my Shoes.app declaration

class Shoes
  module Swt
    class App
      def initialize_shell
        @image = ::Swt::Graphics::Image.new(::Swt.display, ICON)
        @shell = ::Swt::Widgets::Shell.new(::Swt.display, main_window_style)
        @shell.image = @image
        @shell.text = @dsl.app_title
        @shell.background_mode = ::Swt::SWT::INHERIT_DEFAULT
        @shell.background = @background.real
        full_size_byte_mask = 32768

        hack_cocoa_main_window('setTitleVisibility:', 1)
        hack_cocoa_main_window('setStyleMask:', @shell.view.window.styleMask | full_size_byte_mask)
        hack_cocoa_main_window('setTitlebarAppearsTransparent:', 1)
      end

      private

      def hack_cocoa_main_window(key, value, type=nil)
        key = org.eclipse.swt.internal.cocoa::OS.sel_registerName(key)
        id  = @shell.view.window.id
        msg_method = ['objc_msgSend', type].compact.join('_')
        org.eclipse.swt.internal.cocoa::OS.send(msg_method, id, key, value)
      end
    end
  end
end