Anchordata module and moving objects.

Here's where to discuss using Stéphane Leys' very well done alternative runtime editor. If you're a control freak at runtime you have to check this out!

Anchordata module and moving objects.

Postby drpitcairn » Fri Dec 04, 2009 8:19 pm

I have been trying to make a window user resizable and used the anchordata module to do that. The card I am working with has several fields and buttons. I have made all of them anchordata objects and it works well except for this persistent problem: I get all the fields and buttons in the exact layout I want but when the window is resized and then returned to its former size the position of the fields and buttons is changed. Sometimes not much, other times quite a bit. I have tried locking all the objects but that does not solve it.
Is this just the way it is or am I not doing it quite right?

Thanks,
Richard
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Anchordata module and moving objects.

Postby S. Leys » Fri Dec 04, 2009 11:35 pm

rpitcairn wrote:I have been trying to make a window user resizable and used the anchordata module to do that. The card I am working with has several fields and buttons. I have made all of them anchordata objects and it works well except for this persistent problem: I get all the fields and buttons in the exact layout I want but when the window is resized and then returned to its former size the position of the fields and buttons is changed. Sometimes not much, other times quite a bit. I have tried locking all the objects but that does not solve it.
Is this just the way it is or am I not doing it quite right?


Send me the project, I'll look at that.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: Anchordata module and moving objects.

Postby drpitcairn » Wed Dec 09, 2009 7:39 pm

OK, I think I am catching on. Was able to set most of the objects so that moved nicely on the page without distortion or problems. One field however, was getting too narrow so I tried various permutations to see if I could get it better and did to some extent (would still like it slightly wider when window downsized). Here is a picture of the settings that worked. Problem is I have no idea what I did . What does minimum or maximum size refer to? From the edge of the window? From the other side of the object?
Anchordata.png
My settings that more or less work. What does the -20 refer to?
Anchordata.png (30.02 KiB) Viewed 3032 times
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Anchordata module and moving objects.

Postby S. Leys » Thu Dec 10, 2009 1:36 am

rpitcairn wrote: Problem is I have no idea what I did .


LOL.
You can't imagine how often it happens to me to write a working solution without understanding how it works.
When I find myself in such a situation, I use the cartesian method I posted in another thread.
- I read the LG
- I read it again
- When I'm sure that I've understood everything, I read it again
- I make test projects, each one of them testing ONE thing
- I try all the possible variants and see how they behave
- I read each line of my script and test variants, including those which are not supposed to work

It usually takes me a few days before I finally understand what I've done and why it works.
I guess that this is rather common. One can't expect going directly to the best solution (unless the problem is trivial), happy enough when we don't go directly to the worst solution.

Obviously, from your screenshot, you need to read the LG again :
To apply the divider resizing mode to a side you pass a hyphen followed by the desired minimum distance from the corresponding window edge. If you also want to specify a maximum distance then add a colon and the maximum value. For example, if an object's anchorData contains:
left,top,right,-100:300
then the left, top, and right will resize such that they remain a constant distance from the corresponding window edges, while the bottom edge will be adjusted proportionally but at least 100 pixels and no more than 300 pixels from the bottom of the window.

You're using "-:20" for the right of your object. The minimum is missing. You didn't fill the field in the dialog of the anchordata module when choosing "-" in the popup menu.
And remember that "proportional" implies a division, thus a real number thus, since SC is not doing floating point geometry, the proportion will be truncated to the nearest pixel which will inevitably lead to rounding errors. All these proportional features of anchordata need to be tested carefully. Personally, I'm using them only for dividers, using the tilde "~" relative to the divider for the anchordata of other objects. This way, if the result is not exactly what the user expects, he can move the divider with the mouse and rounding errors don't matter.
And don't forget to set the minimumsize of your window (or bg) to something compatible with the anchordata. Shrink your window (with liveresize true ;-)) until it begins to look weird, then set the minimumsize to something a bit larger.

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am

Re: Anchordata module and moving objects.

Postby drpitcairn » Thu Dec 10, 2009 8:18 am

S,
Thanks for that explanation. Sometimes my problem is that I read the LG several times and still don't understand it. Like you said (and Descarte suggests, using reductionism) I try to simplify by changing one thing at a time and did that with what I posted but then got into the frustrating situation of getting only more confused. So I post it hoping to have some sort of hint which you did provide. So thanks.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Anchordata module and moving objects.

Postby drpitcairn » Thu Dec 10, 2009 8:42 am

I can't find the LG text you posted. Searched under "divider" and "resize" and don't find in in the LG or MPI help. Can you direct me to the necessary word?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Anchordata module and moving objects.

Postby S. Leys » Fri Dec 11, 2009 12:53 am

rpitcairn wrote:I can't find the LG text you posted. Searched under "divider" and "resize" and don't find in in the LG or MPI help. Can you direct me to the necessary word?


Autoresize.
Which you could have found by one of the following methods :
- shift-clicking the "Autoresize of the bg" button in the anchordata module
- context-click the anchordata module, choose "Module help" in the popup, and click the link to "Autoresize" in the MPI help
- Ditto but click the link to "anchordta" in the MPI help, then select "Autoresize" in the "related" button of the LG.
- Do a text search in the LG with some significative word of the quote I posted, for instance, searching "anchorData" returns 2 hits , "anchorData" and "Autoresize"

S.
User avatar
S. Leys
 
Posts: 628
Joined: Sun Jul 06, 2008 11:03 am


Return to Using MPI

Who is online

Users browsing this forum: No registered users and 1 guest

cron