PDA

View Full Version : Image viewing in lscript interface



Anti-Distinctly
11-08-2008, 06:45 PM
Hi,
I need to be able to load an image from the image list in layout, and have that show up in a lscript interface. I've managed to do all of this so far, but the problem is that the images can be very large and I need to be able to see any part of it. (the purpose being so that the user can select certain points on the image and have those recorded)
Currently, I can't find anyway to do this. I'm using the ctrlimage interface control at the moment.

Is there any way to navigate an image in an interface similar to how one navigates in the image viewer? (using alt click to drag, etc)

Blochi
11-09-2008, 02:08 AM
Not natively, you would have to code this yourself.

My approach would be to turn the image into a Glyph, and show it in an ctlviewport(). The user will automatically have scrollbars, for on-image drag behavior you can catch modifier keys and mouse movements in a mousetrack() function and use it to reposition the viewport.

Blochi

Blochi
11-09-2008, 02:13 AM
PS: Here are some doc links: ctlviewport() (http://www.mikegreen.name/Lscript/Source/Control_Commands.htm#ctlviewport) and Mouse Functions (http://www.mikegreen.name/Lscript/Source/Interface_Commands.htm#Mouse_Object_Agent)

Anti-Distinctly
11-09-2008, 03:04 AM
That's great. Thanks man, I'll give that a whirl.

Anti-Distinctly
11-09-2008, 12:28 PM
I'm attempting to write a mouse move function to move the view...here's the test code so far;



reqmousemove: md
{
if(md.ctl && mCapture && md.keys[3])
{
md.ctl.xoffset = 50;
}
}


This just results in an 'invalid object reference' error, followed by an 'internal stack error'.
The docs clearly state that they are assignable;


In addition, the Control Object Agent class now exports two new data members called xoffset and yoffset.
...they can be assigned values to position the viewport at a specific location on the virtual canvass


Any ideas?

Blochi
11-10-2008, 09:16 AM
I wouldn't rely on the control OA getting handed through to the Mouse OA.

Make the control global and do something like this:


var click_x, click_y, c1;

c1=ctlviewport....

reqmousemove: md
{
if(mCapture && md.keys[3] && md.x >= c1.x && md.x <= c1.x+c1.width && md.y >= c1.y && md.y <= c1.x+c1.height)
{
c1.xoffset = c1.xoffset + md.x - click_x;
c1.yoffset = c1.yoffset + md.y - click_y;
requpdate(c1);
}
}

reqmousedown: md
{
// remember original click position
click_x = md.x;
click_y = md.y;
}

Anti-Distinctly
11-12-2008, 06:44 AM
I wouldn't rely on the control OA getting handed through to the Mouse OA.

Of course not, how foolish of me :)
Seriously though, thanks.