Limiting scatter area within a layout

564 views
Skip to first unread message

The Wonton

unread,
Oct 23, 2014, 4:48:54 PM10/23/14
to kivy-...@googlegroups.com
I'm having a difficult time figuring out how to limit the ScatterLayout's movements to be restricted within a specific region of the parent layout. As an example, take the simplified layout below...

BoxLayout:
    orientation: 'vertical'
    Button:
        text: 'Calculate'
    ScatterLayout:
        Image:
            source: 'testing1.png'
            allow_stretch: True

When running the above, I'm able to move the image beyond the lower half of the BoxLayout. How can I restrict the Scatter to only allow movement within a specific region? For example, the bottom half of the BoxLayout. I apologize if this is a duplicate question or if it's extremely basic. I haven't been able to find an answer or work it out on my own. Thanks for your assistance!


Felipe França

unread,
Oct 24, 2014, 6:33:46 AM10/24/14
to kivy-...@googlegroups.com
Hi The Wonton,

set the scatter
property 'do_translation_y'  to False, and your image will move just on the X axis.

Take a look http://kivy.org/docs/api-kivy.uix.scatter.html

I hope it helps you.

knappador

unread,
Oct 24, 2014, 7:59:20 AM10/24/14
to kivy-...@googlegroups.com
If you override the scatter's method for transform_with_touch, you can restrict each individual type of motion in creative ways.

Because the method is so large, I would advise just to copy and paste the original and make changes to dx, dy, zoom etc to restrict movement the way you need.

The Wonton

unread,
Oct 24, 2014, 9:40:49 AM10/24/14
to kivy-...@googlegroups.com
Thank you everyone for the replies. I messed around with things a little this morning, and I think what I'd like to do is a little different than I described above. Is it possible to still zoom and move the image, but not have the image displayed beyond that boundary.
So for example, in the image above, if I zoomed in on the image, any part of the image that would overlap the button would be displayed behind (for lack of a better term) the button. The only part of the image visible would be below the button. Hopefully that makes sense. Thank you very much for your assistance!

olga.we...@gmail.com

unread,
Oct 27, 2014, 11:12:32 AM10/27/14
to kivy-...@googlegroups.com


On Friday, October 24, 2014 3:40:49 PM UTC+2, The Wonton wrote:
Thank you everyone for the replies. I messed around with things a little this morning, and I think what I'd like to do is a little different than I described above. Is it possible to still zoom and move the image, but not have the image displayed beyond that boundary.
So for example, in the image above, if I zoomed in on the image, any part of the image that would overlap the button would be displayed behind (for lack of a better term) the button. The only part of the image visible would be below the button. Hopefully that makes sense. Thank you very much for your assistance!

Maybe take a look at StencilView and put your Scatter in it?

phenotyp...@gmail.com

unread,
Nov 14, 2014, 7:19:06 PM11/14/14
to kivy-...@googlegroups.com
I have a similar problem:
I would like to allow a scatter to move only inside a Layout and stop on the borders. is that possible?
Reply all
Reply to author
Forward
0 new messages