Re: Cursor zone
Re: Cursor zone
- Subject: Re: Cursor zone
- From: email@hidden
- Date: Mon, 18 Feb 2002 12:17:57 -0800
I totally agree with your statement. As you might know, I maintain a
searchable archive for both mailing-lists (can be found at
http://cocoa.mamasam.com ). Having people doing cross-posting means
they are
filling my HD and the search-engine with two times the same message
which I
would also like to avoid in the future. So, +1 for a merge.
But the reason I did cross-posts is because nobody replied to my first
post
on COCOADEV list (and this is not the first time it happens, and if you
look
at the rate of answered questions in general, it is very low anyway).
So I
thought people could be nicier on MACOSXDEV list and answer my question.
All reasonable. However, some people (or at least me) tend to save up
a few digests from the list and then reply in bulk periodically. This
lets me see which messages were already responded to by others, and
which messages have gone unanswered. So you might wait a bit longer
before cross-posting. That's all. I think we're in agreement.
I believe there is API to do this in CoreGraphics, from what I recall,
but it does not appear to be public. So you're out of luck. Log a bug
on Apple (so maybe they'll make this API public in the future), and
then
you have a few choices:
Could you tell me where I can find more info on this (in headers ?).
On the private CoreGraphics APIs? I'm afraid I can't, actually. And
if I could, I would probably be violating some Apple copyright or
something. I just happen to recall seeing API like this in the private
headers for CoreGraphics. Those headers are not part of the
Apple-external distribution of the OS.
I think filing a bug and waiting for Apple to publish more API is,
unfortunately, the main solution here.
o Add multiple tracking rects that more or less "scan convert" your
circle into a set of rectangular areas.
I have done that but it takes ages to draw. The picture is here and 3
seconds later, the sensitive rects appear. It looks to me like the
Cursor
Rect stuff in COCOA is not very well designed.
Actually, it might be because I just want the borders of the circle to
be
sensitive. To make that, I scan every points in my NSBitmapImageRep and
determine if they are white or black. If they are white, I check if
there is
a black point in the 8 pixels around. At the end, it makes many rects
and
they overlap sometimes. Could it be the reason of the time it takes to
draw?
Overlapping should be avoided, I believe. But it sounds like the way
you're generating the cursor rects (by scanning the bitmap and looking
at neighbors) might me responsible for most of your speed problem. This
sounds like an exceedingly gross solution. I would run Sampler on your
app and see where you are spending your time. It also sounds like
you're generating one cursor rect per pixel (!), which is really not
something the cursor rect stuff is designed to handle, I think.
o Use a single rect and live with it.
Not possible :(
o Try to use [NSCursor pushCursor] / [NSCursor popCursor], and
struggle
with the various issues raised earlier on the list about the problems
with this approach and its basic lack of support in the Kit.
I will have a look at that too.
I doubt pushCursor/popCursor will get you what you want. I managed to
get this approach working for some code I wrote a while ago, but that
was with full access to the AppKit sources, and it was still quite
difficult, and there were still bugs I was simply unable to get rid of
because of the underlying design of the cursor stuff. The assumption in
the Kit is that cursor rects are being used to control the cursor; if
you violate that assumption, you will run head-on into the Kit in
several places.
Do you think Cursor Rects are CPU consumming ? Am I limited in the
number of
rects I can use ? I have made tests with a big image full of circles :
I get
the spinning cursor for ages and my app is stuck.
I don't know the complexity of the algorithms used to handle cursor
rects. I would suspect they are O(N), so you will bog down if you make
too many of them. I don't know this for a fact, though. You are
certainly chewing through memory and CPU time creating all of them in
the way you are.
Anyway, thanks for your reply, I was getting afraid that I was the only
one
in the world with cursor problems... :-)
Nope. It's a big issue in OS X, primarily because using
pushCursor/popCursor is broken so you can't implement your own
cursor-control mechanism in cases where cursor rects don't suit your
needs. I lobbied hard for changes to this stuff while I was at Apple,
but there is a lot of code out there that depends upon the current API,
so it's hard to change...
I routinely see the wrong cursor in OS X apps from ProjectBuilder to
Mail. The way the cursor stuff works right now is just too messed up
for anybody to be able to get it right. I certainly hope that Apple is
aware of this problem and is working to remedy it. If you want complex
cursor behavior in your app, my recommendation would be to wait for
Apple to take the lead on solving this problem. It is really not
solvable by external developers, IMHO.
Ben Haller
Stick Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.