Page 1 of 1
Zoom in/out on group - 2nd try
Posted: Sun Mar 09, 2014 11:41 am
by palanolho
Greetings everyone,
I'm in need of some help, in case anyone can help me ...
So, here's the situation:
I have group that contain several graphics inside and I want to zoom out ( for example to 50% to have a better view over all graphics inside the group) and zoom in again.
I was able to work this out and the resize of the graphics is working fine. The problem is the location of the graphic that doesn't stay where it should after the zoom.
so, how am I approaching the zoom:
- each graphic has its original size store on a custom property.
- When I zoom, I multiply the W and H of the graphic by the Zoom factor (zoom percentage divided by 100). This works just fine.
- Then, I also multiply the graphic location by the zoom facto to move the graphic to the correct location after the resize. However this is not working as I expected.
Then I started to think that, in order for this method to work, I would also need to have the "initial" location (ig, the location of the object at 100% zoom). Do I really need it?
When I add a new graphic to the group and the zoom is at 100%, that would be easy. The problem would be "how to update the location, when the graphic is moved and the zoom is not at 100% (or a new graphic is added to the group when the zoom is not at 100%).
So, my question is: Does anyone can see what am I missing? is there another/better way to do this?
I have attached a example stack for you to see.
Any thanks in advance,
- Miguel Pinto
Re: Zoom in/out on group - 2nd try
Posted: Sun Mar 09, 2014 1:25 pm
by bn
Hi Miguel,
have a look at
http://forums.runrev.com/phpBB2/viewtop ... hilit=zoom
The stack over there kind of works, what is wrong with it?
Kind regards
Bernd
Re: Zoom in/out on group - 2nd try
Posted: Sun Mar 09, 2014 1:41 pm
by palanolho
the problem with that one is that I was using the coordinates of the rectangle of the graphic and that's something that will be constantly changing and it will be very difficult to track the Original Size.
That's why I'm trying to this new approach where I only need to know the graphic W and H. (that's why I called it "2nd try2

)
When you move a grahic inside the group, the rectangle changes but the W and H doesn't. Do you see my dilemma ?

Re: Zoom in/out on group - 2nd try
Posted: Sun Mar 09, 2014 2:07 pm
by bn
Hi Miguel,
actually I meant the last stack I posted
http://forums.runrev.com/phpBB2/viewtop ... oom#p79421
It does so by storing the locations of objects at 100% zoom and the location of the group. Then you can do your math on that.
Now your objects just move to the loc of the group and stay there. Which is not surprising since you always scale from the current loc of the objects. Not from a constant reference.
Now if you want to add content at varying zoom scales you could like wise take into account the current zoom and use that for storing a custom property of the object which reflects the loc of the object at 100% zoom. Likewise for size of objects that get added while the zoom is not 100%.
Except for adding objects at zoom levels <> 100 its all in the stack "main_app4.livecode.zip"
Kind regards
Bernd
Re: Zoom in/out on group - 2nd try
Posted: Sun Mar 09, 2014 2:17 pm
by palanolho
Let me check again than
thanks
- Miguel
Re: Zoom in/out on group - 2nd try
Posted: Wed Mar 12, 2014 9:26 am
by palanolho
Greetings everyone,
Just to let you know that I I'm working on a solution based on Ben's suggestions.
I'm having some issues at the moment but I'll post the solution or some more questions as soon as I can.
Cheers,
- Miguel
Re: Zoom in/out on group - 2nd try
Posted: Mon Apr 07, 2014 7:10 pm
by palanolho
Hi everyone,
So, I have been playing with this and will submit here a Test stack I have created so that you could check the problems I'm having.
Mainly, I have 2 issues and I'm dealing with one at the time
1- setting/defining the location of graphic on 100% zoom is not working correctly when the content of the group does not fit all inside the group rect (ie, the group is scrollable)
2- setting/defining the location of the graphic when Zoom different from 100%
All the code I have done for both is on the attached stack, however, I'm trying to fix first the problem when the group is scrollable (and hopefully the 2nd will be also fixed).
The stack is simple:
- It has a small form to apply a different size to the group area (green area)
- It has a scroll to zoom (also usable by clicking in the spyglass icons)
- It has a green button that you can drag to the group that will create a graphic inside the group (so you can play with it)
(The best way to test this is to work with the stack in the smallest possible size)
So, my first goal is ... Make this work regardless of the size of the area inside the group.
If anyone find any insight on it, I'll be all ears
Many thanks in advance,
- Miguel
Re: Zoom in/out on group - 2nd try
Posted: Mon Apr 07, 2014 8:51 pm
by bn
Hi Miguel,
I had a short look at your stack and did what was discussed at length in the oher thread.
Groups that scroll have the funny behavior to let content of the group snap to the topLeft of the group regardless what you code.
I even bug reported it and in the stack I posted there was a work-around that by placing a very small graphic into the topLeft corner of the group lets the group behave normally.
I added a graphic "gPlaceHolder" and position it with its topLeft to the topLeft of the group.
I added code to prevent this graphic to be deleted on preOpenStack and position the graphic at that same location when using the scrollbar to resize the zoom-factor.
Then you are still doing some stuff in your library on start-Up that I did not look into.
I marked my changes with comments and --BN
It is a lot easier to ask for help and you make it easier on yourself if you isolate the problem in stack as small as possible to concentrate on the problem.
Kind regards
Bernd