keeping the boundaries of an img to the outside of the stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

keeping the boundaries of an img to the outside of the stack

Post by magice » Wed May 28, 2014 8:27 pm

Ok here is my situation. At work one of my data entry people has to upload and organize 1200-1500 pictures daily. This process was working well while she was on a windows xp machine. Now they have upgraded her to Windows 7, and the photo viewer opens a new window every time she clicks to look at a picture. This results in hundreds of windows open or lots of clicking to close them. Having been unable to find a suitable viewer to replace Photo Viewer, I decided to write one that works the way we need it to. I have everything working, but i want to make a few tweeks. Specifically, I want the boundaries of the image to stay outside of the window when moved. The code I have for moving the image is as follows.

Code: Select all

on mouseDown
   set the lockcursor to false
   set the cursor to hand
   set the lockcursor to true
   put the first item of the mouseLoc into tWOff
   put the second item of the mouseLoc into tHOff
   put the first item in the loc of img "Image" into tWI
   put the second item in the loc of img "Image" into tHI
   put tWI - tWOff  into tWI
   put tHi -tHOff into tHi
   put true into tMouseD
end mouseDown
on mouseUp
   set the lockcursor to false
   set the cursor to arrow
   set the lockcursor to true
   put false into tMouseD
end mouseUp
on mouseMove tX tY
   if tMouseD
   then
      set the loc of image "image" to (tWI + tX), (tHI + tY)
   end If
end mouseMove
As you can see, when the image is larger than the stack, for instance when it is zoomed, the image can be dragged off the stack. How can I keep the left of the image to the left of the stack, top of the image above the top of the stack etc. without hindering motion in other directions and while preserving image aspect ratio.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: keeping the boundaries of an img to the outside of the s

Post by Simon » Wed May 28, 2014 10:44 pm

Hi magice,
Isn't this a case for a scrolling group?
http://lessons.runrev.com/m/4071/l/4442 ... chitecture
Maybe I missed something.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: keeping the boundaries of an img to the outside of the s

Post by keram » Thu May 29, 2014 2:54 am

Hi magice,

I don't want to counteract the joy of creating your own app, but just in case... FastStone Image Viewer may be what you need - ready to use. http://www.faststone.org/FSViewerDetail.htm

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: keeping the boundaries of an img to the outside of the s

Post by magice » Thu May 29, 2014 3:33 pm

Thank you both. Simon your method works fine. layerMode is fairly new, and it is not something I have run into before. it is exactly what I needed.

Post Reply