用石英画在屏幕上 [英] Draw over screen with Quartz

查看:216
本文介绍了用石英画在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出什么是最好的方式,在屏幕上的所有其他项目的顶部绘制OS X。我不想阻碍用户与他们的应用程序交互的能力,但想注释他们。我想要能够绘制多达20个不同的注释。 Gizmodo截图的上半部恰好显示了我想做的事情。 http://gizmodo.com/assets/resources/2006/07/ 04%20Safari.jpg (对不起,我太新了,不能张贴为图片)



我我需要回答是:


  1. 我应该为
    创建一个窗口,每个绘图并绘制?如果
    那么,我如何最小化开销?

  2. 我应该使用什么样的窗口或其他上下文,我不想要任何窗口
    装饰? / li>

我不认为我想要创建20个窗口的开销,但我也不知道我想创建一个完整的包含我的上下文(我假设是一个子类NSView),因为我害怕会导致问题与下面的内容交互和b)打破只有重画的必要性的微妙(我的实际绘图可能只覆盖10 %的屏幕)



我以前没有使用Quartz2d,所以我只是不能得到我的头如何获得正确的上下文从文档。



感谢,



解决方案

你只能画一个窗口。你可以做一个透明的,无边框的窗口,但它需要在前面。



您可以将其级别设置为像 NSPopUpMenuWindowLevel ,以使其绘制在其他窗口之上(这将是非常讨厌给用户),但点击它会:



a)激活并带到您的应用程序前



b )防止应用程序接收鼠标事件



这是你想要的吗?


I'm trying to work out what the best way to draw over the top of all other items on the screen on OS X. I don't want to impede the user's ability to interact with their applications, but want to 'annotate' them. I want to be able to draw up to 20 different annotations. The top half of this screenshot from Gizmodo happens to nicely show the kind of thing I want to do. http://gizmodo.com/assets/resources/2006/07/04%20Safari.jpg (sorry, I'm too new to post it as an image)

The questions I think I need to answer are:

  1. Should I create a single window for each drawing and draw to that? If so, how do I minimise overhead?
  2. What kind of window or other context should I use given that I don't want any window decoration?

I don't think I want the overhead of creating 20 windows, but I also don't know that I want to create a full-screen, invisible window that contains my context (I presume a subclassed NSView), because I fear that will a) cause problems interacting with what's below and b) break the niceties of only redrawing when necessary (my actual drawing will likely only cover 10% of the screen)

I've not worked with Quartz2d before, so I just can't get my head around how to get the 'right' context to draw on from the documentation. Any help would be appreciated.

Thanks,

Who

解决方案

You can only draw into a window. You can make a transparent, borderless window but it will need to be at the front.

You could set it's level to something like NSPopUpMenuWindowLevel to make it draw above other windows (this will be very annoying to users) but clicking on it will:

a) activate and bring to the front your app

b) Prevent the app underneath receiving mouse events

Is that what you want?

这篇关于用石英画在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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