结合航空玻璃效果和SWT [英] Combining Aero Glass effects and SWT

查看:154
本文介绍了结合航空玻璃效果和SWT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个宠物项目,我一直在玩将Aero Glass效果集成到我的SWT应用程序中的概念。 也演示了如何执行此操作,但需要修改SWT库。 (至少,我相信,因为私人SWT功能被 @Override 覆盖。)



我怎么能避免控制变得透明?更好的是:我如何从透明度中受益(例如在其上放置图像喜欢这样),但是以明智的方式使用它?

解决方案

被覆盖的方法是包私人。为了在没有编译时错误的情况下覆盖它们,您必须将类放入与超类相同的包中,即 org.eclipse.swt org.eclipse.swt.widgets 包。你引用帖子的博客实际上在最后提到了这个实现细节,所以我不知道,这真的回答了你的问题。


As a pet project, I've been playing with the concept of integrating Aero Glass effects into my SWT application. Łukasz Milewski has an excellent blog post explaining how this can be accomplished, which pretty much boils down to this:

final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FormLayout());
final MARGINS margins = new MARGINS();
margins.cyTopHeight = -1;

final Composite c = new Composite(shell, SWT.NORMAL);
c.setBackground(new Color(shell.getDisplay(), new RGB(0, 0, 0)));
final FormData fd = new FormData();
fd.top = new FormAttachment(0, 0);
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
c.setLayoutData(fd);

OS.DwmExtendFrameIntoClientArea(shell.handle, margins);

shell.open();
while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
        display.sleep();
    }
}

This works beautifully, until you want to add a control. This results in black remaining transparent:

A follow-up post demonstrates how to do this, too, but requires modifying the SWT library. (At least, I believe so, because private SWT functions are overridden with @Override.)

How can I avoid controls becoming transparent? Even better: how can I benefit from transparency (e.g. placing images on it like so), but use it in a sensible way?

解决方案

The overridden methods are "package private". In order to override them without compile time errors, you have to put your classes into the same package as the super class, i.e. org.eclipse.swt or org.eclipse.swt.widgets package. The blog you cite post actually mentions this implementation detail at the end, so I don't know, it this really answers your question.

这篇关于结合航空玻璃效果和SWT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆