Page 1 of 2
Clipping/cropping a group
Posted: Fri Oct 11, 2024 2:45 pm
by Klaus
Hi friends,
I want to clip a group by script but cannot get it to work!?
I want the content of the group to be clipped at the top and bottom.
See attached image, it shows what I want to achieve.
No problem when resizing manually but no dice by script so far.
I tried many variations of boundingrect, rect, clipstorect, lockloc, height and whatnot.
Any hints very welcome!
Best
Klaus
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 2:53 pm
by dunbarx
Klaus.
If I make a group and set its height property to a value smaller than the original, the top of the group stays put, and the bottom is truncated, so that is half the battle. If I then play with the scroll of the group, I can control the visible portion.
Craig
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 2:56 pm
by Klaus
Yes, but I don't want to "play with the scroll" I want to script it precisely.
But thank you, gives me food for thought!
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 3:00 pm
by dunbarx
Klaus.
I only "played" with setting the scroll to see if that property worked as I thought it might. I am sure you can figure out the numerical values of the scroll to make your group look the way you want.
Craig
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 4:36 pm
by richmond62
Your problem is that you do NOT really want to JUST resize the group: but you want to resize the group AND centre its contents.
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 5:19 pm
by Klaus
How did you know?

Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 5:45 pm
by richmond62
Because I just spent an hour getting FFFFed trying to get the thing to work:
Tried: crop
Tried: set the rectangle of group
Tried: a glass of whisky on the balcony . . .
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 5:50 pm
by richmond62
Something tells me (probably the whisky) that you need a group inside another group and you have to shift the inner group UP before you resize the outer group.
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 6:06 pm
by Klaus
I will either set the TOP and BOTTOM MARGINS of that group to negative values or, as Craig proposed,
just resize the group and set the scroll accordingly.
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 6:51 pm
by dunbarx
All good stuff.
To center a group the scroll way, simply determine the amount of total "crop" you want in pixels. Subtract half that value from the height of the group . Then set the scroll to that same value.
Craig
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 6:57 pm
by dunbarx
How would one do the same sort of thing horizontally?
There you really need to set the margins to a string of positive and negative values.
Playing with it, actually, I like the margin method best...
Craig
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 7:56 pm
by bn
I tried to do what Klaus seems to be aiming at.
I tried this and think that gathering the location of the controls of the group before resizing the group (which is locLocked) and then setting the location of the controls to their prior location after the resize of the group seems to do the trick.
Maybe this helps or I do not quite understand what Klaus wants.
Kind regards
Bernd
Re: Clipping/cropping a group
Posted: Fri Oct 11, 2024 8:03 pm
by Klaus
Hi Bernd,
sounds good, will try this tomorrow!
I think you understood what I'm after.
Best
Klaus
Re: Clipping/cropping a group
Posted: Sat Oct 12, 2024 3:21 pm
by Klaus
Hi Bernd,
tried that, but didn't work, since setting the height will not change the topleft of the group.
Best
Klaus
Re: Clipping/cropping a group
Posted: Sat Oct 12, 2024 3:34 pm
by dunbarx
Now I am confused.
1- What do the locs of the child controls have to do with cropping the group as a whole?
2- Isn't the margins property the best way to crop, since all four sides can be independently adjusted?
My first foray into this was based on Klaus' initial post, where only the top and bottom were adjusted. I assumed that the controls within did not matter. But my solution is not nearly as elegant and simple as using margins.
Craig