【问题标题】:How to obtain a macOS transparent titlebar effect in SWT/Shoes via JRuby如何通过 JRuby 在 SWT/Shoes 中获得 macOS 透明标题栏效果
【发布时间】:2018-06-25 13:24:20
【问题描述】:

我正在尝试在使用鞋子时获得这种效果(透明标题栏和全尺寸内容)。但是,我认为SWT 甚至不提供此选项。

我怎样才能做到这一点?

【问题讨论】:

    标签: java swt jruby shoes shoes-4


    【解决方案1】:

    我是这样实现的:

    我将此代码放在我的 Shoes.app 声明之前

    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
    

    【讨论】:

    • 非常好,可以用纯 SWT 做到这一点吗?
    • 纯粹是指Java SWT而不是JRuby?还是使用常规的 SWT API?
    • 我的意思是在 Java SWT 中
    猜你喜欢
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多