Zooming in/out in code? (Display scaling and mini-display)
I’m working on a dynamic display/score system, and would like to do a couple of things, that would be sooo much easier if I could zoom in/out in code using Juce.
The first is to be able to adapt to different displays (all with the same aspect ratio). Because of moving/offset/font sizes, it would be a real pain to work out versions for different displays based on absolute pixels. If I could upscale to different displays, that would be amazing.
Additionally, part of my GUI will be a skype style mini-display of the upcoming section. Again, it would ideal if this could be a duplicate of my main display bpatcher, but scaled down.
Is it possible to access the command-plus/command-minus in code?
----------begin_max5_patcher---------- 498.3ocuT9saaCBEF+Z6mBDcWxrL33+v1U6EXR65opJbLIgJaHBHYYspu6Cv 1IKsqYnnndCxbNGe367SevyoIvV0AtAB9B3mfjjmSSRBg7ARl1m.GXGV1yLg xfs6rVkDhFSI2Mn1Y641PR7TTQWnTU6ietZtxwxr+dKe7zfsL4ZH39ozaY1k aDx0On4KsiUTjiypqVTmSQ.bENC61T0f.j7r7w0i+sSFB4QU3i8RZpeAE4TI 4+xo1YsZ4GBZ.1qXcCbiArHCG8HSlqbkRZkrgv.C+lVv5eWXbBD9exHdJj.6 mzKxmRJkVW43CsI7MEi.0A9fatk7YUux0i+MBHuEAkWABbGAyBQu1XbFOHWl GjLbAcA0wCBglUSwMkkHP4+yubrkZmRsb8CbIqsObh4WAq7FF1Z9aLSOoTCq XKsJM3Sw6lJtcto3oWEIPuZDno9xlIxs6xlcivDDFWGsQCeMzAcCHDMOPnEH PEMN6kgseVA28cuFNadAvu5Wt6G9UtraLB39+Bug1C6ExW+fcnI93mybiZmd 47QN8vD3jH63FqPxrB2q4mpo7rZ1H553gzyboSX72M5d+KGwplpHTC4CSMEQ nF7GlZJiPMEWoZFsQrsa2y0loVFDh6R5iJseaEJrUHG2F5HTy2KlquI02sWR +C.YYZtX -----------end_max5_patcher-----------
is adapted from this thread:
have zoomy fun!
Awesome! I had a look through all the help/reference looking for something like that, but it’s unsupported!
Hmm, Ben refers to some JS solution in that thread, but there doesn’t appear to be any there. The zoom seems to zoom in into random places, which makes it less useful..
I think it works well for standard objects, but ui objects/3rd party might behave erratically / unpredictably (don’t think it’s that great with cellblock for instance), so best test it first with the objects you want to use… have no idea if it works in a bpatcher either.
"Is it possible to access the command-plus/command-minus in code? "
There is the aka.keyboard external,
But I’m sure there are prettier solutions,
For example, if I want to have a shrunk version of my bpatcher, I set the zoomfactor, and move around the bpatcher, but when I reload the patch, even though the zoomfactor is correct, the bpatcher location is moved around. I suspect the zoomfactor is ‘zooming in’ to where the mouse is?
This is from a rather large patch that does exactly what you are asking for
----------begin_max5_patcher---------- 1262.3ocyZs0iZiCE9Y3WgEzGFp5jFm6Y2cdX099JsZ22ZqPlDC3JGGThYlo sp+22isIPHSBSJCfxCCQ34brOmO+ctXG9w3QSVj+LsbB52PeBMZzOFOZjdH0 .i188QSxHOmvIkZwljjmkQExIev7+jzmk5w+iGd3+VyJQkqy2xSQKnnDBmSS QedBSHoEBB+ySpzhkp0IewWu2qZLw1r7sRNUpWG6citLWHEjLpV9+rfQ3Uxu rX0BsjV0ksj8csrXm8CCSLSTMu3cCtgHSVyDqlWPSjF+OvOBzA4Z6pdfi8UO bfoG8EkN+b7X0Genm3zB8JPKZwkcNsKej8Z2s85iMVXjwdch1+3rLXA8Iv3d w9pD1T61Uvs6JNu5tmQX421PMNCPMf+Pe4xrUh0PhqKV8HH9vF4NUJIOVstS +a0JejWhl76pOl9OpOohTyHmEn1Uzx+RkH.vQJeDQDonM4kLIKWfVlWfNA2I HZvDuD4Fa4EGEaiAZWfmkaTXPfOfzXu2TjSWX1eQ3Ia4DIEslxVsV9pPU7vD p77sBr8BiCUXD9JCUOwRkqeMjJzdXhTNAV1g1A3naARUB0qnnkjDI.VJ.664 4Y5XyBJ3PfYdRxV3vDBsCr7cC7bUPXr6UABU4xJSJnTQ8.yjsEEfznrbACPz 1frfAIjEEZE565GhUPk+0FwNDe1C.yePBXAQVN3X2X70KJsD.j8o8yWBQj2q CWSOYHoyfAtvQQ0aUKJ9JhRFFUuAI7fCj7iMfj+UDjpmr2Bcm9jKpCu.Alxb zJd9BBGUlijqIPnJmkRKgyyHL0DXhOBHEhjjjWjB9.+ayZCYsGbHqqFR877t pH6udk.+3AGToU8p0J6QP0SLY+qA3GMzfpprY32V2EKkYVfCpl8ln0ijVQhf y8rmkI4lict2iqDqJQokg912CqJylCVTAc47jbwiM2NZAhUZr2J1CwPelvlO QcLv5Gy2qdoCbrUjuuWPr5FJpchVHAURAaiR2lXVq6mzTEAat9pYfzfF2uRi MzhRVojJRnu1cPbZi6lvC7th7.cwzaCMvtWzfcEGw9V3P2HmnAEMnKi6VPC7 vuYZ.tIMP2kfkoKggDIvTGON1xMv2w0aPwA5v1NSJPFE9RCB.f4yu6clhml. TzCn63TNMC4fd26wylou+tCBsqYj8R41TpCayJgZn1GgQXP8XfxfVAMHZFd1 A8ONagdFpKudzYn2iNZgdo1Grx1VtNz2rUCMtJRAzDUcU6nWPfP20.ytG0vv mAdpyLjcywQMMwCrcNSPSx2Jz6KAswcaUh5WfbG2aRE4bJn51MbZ+5wYprfs ZEsfv40U3kwr68foJn9HFeeifCNqHXSWRA5Nmhv6xW5VK58nPzpjWS44jzED wpWIFr6Y+VjBF6d4qDeTn3PJGr4.BXankGW+X2gUg3tLtaBKv9pwBtgci4zG Rvti9fsgFd78bT2n+vgDzowc4d2f6yJ0x63De575+BuYPSduK5aFLTmlz9Mc f0NvDCUUagsDaDewdeobfKnX75mW32aZvgpHu.dzKktveie1.5oSM9wXVY91 hjJitphO5nXDISPphQ9z92qbMYVyRSoh5r9TVIYAmpQV6V275q43f6i4Deyr mFKUG1S3YZOlcOxlMOpxlXlSso.b6uBGxopIsI.ew7U8LNof9HqR9nwpY6mi +ezHHMMH -----------end_max5_patcher-----------
Even if you are not using FTM it should be self explanatory. I have the original size of my bpatcher loaded in a dictionary. The screensize object gets the resolution of any computer where the patch is open and automatically re-sizes and repositions the Bpatcher object itself and zooms in the embedded patch.
Let me know if it is not clear.
The notes are pretty clear, though it’s hard to tell where the ‘meat’ is happening. Are you using zoomfactor, and the this.patcher.wind.scrollto(x,y) things?
I wish ftm was compartmentalizable. I almost want to have a dedicated ‘mess with ftm’ install of max somewhere, as I’m scared to install/use it on any of my performance machines.
I’m not using zoomfactor but presentation_rect. The logic of the patch works this way:
I use the height to determine the scale factor so that the inner bpatcher takes all vertical space. This way if the screens are different ratios the bpatcher is centered horizontally with empty space on the sides. So first:
Scale.factor = (screen.height / original bpatcher.height)
I then multiply the bpatcher’s original height and width by the scale.factor to get the size it needs to be for each computer’s resolution.
The meat is then a message:
script sendbox internal presentation_rect (($screen.width – $bpatcher.width) / 2) 0 $bpatcher.width $bpatcher.height
sent to [thispatcher] where ‘internal’ is the name of the bpatcher object (set in the inspector).
As a note, this is for a fullscreen patch and all dynamically loaded patches inside bpatcher are set to open in presentation mode.
hope this is helpful.
So presentation_rect actually scales the contents? I thought it just made the window (frame) bigger, but didn’t touch the contents.
You are right,
This thread covers it: http://cycling74.com/forums/topic.php?id=37276
Now it should work :)