Re: Making a cursor (cross hair) track between image displays
- From: jcupitt gmail com
- To: "Tilton, James C. (GSFC-6063)" <james c tilton nasa gov>
- Cc: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: Making a cursor (cross hair) track between image displays
- Date: Wed, 4 Apr 2012 16:12:22 +0100
On 4 April 2012 15:37, Tilton, James C. (GSFC-6063)
<james c tilton nasa gov> wrote:
Your response is very helpful. The one key question that remains for me is:
How do I draw a "floating crosshair"?
You need to do it by hand, unfortunately, though it's not so hard (I think).
The trick (in my opinion) is to have a compositing model for your
drawing areas. Imagine them as a stack of 2D elements which you draw
back-to-front in your expose handler. I wrote a mail on this a month
or so ago, though it was in relation to rubber-banding:
--------
The implementation can be very simple, you don't need to really keep
separate layers around. You could just have a bool in your draw state
for "display rubberband" and that would be enough. Your expose might
looks like:
expose:
draw background
if rubber-band:
draw rubberband
then in your mouse event handler you could have:
on left-down:
set rubber-band
queue draw for pixels touched by rubber band
on motion:
if rubber-band:
queue draw for pixels touched by rubber band
update band position
queue draw for pixels touched by rubber band
on left-up:
unset rubber-band
queue draw for pixels touched by rubber band
The various canvas widgets do basically exactly this for you.
J
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]