resizing lcd inside bpatcher
I found a few posts on this and it doesn't seem possible. But I thought I should ask. Maybe I'll get lucky :)
So I have a lcd inside a bpatcher. when I create the bpatcher and resize it I want the lcd inside it to take up the whole bpatcher.
It would also be extremely useful to know if I could keep a constant aspect ratio.
Any ideas?
Thanks
Not 100% sure, but I think it's not easily possible right now. Many times I've thought about requesting a feature for bpatcher to be alerted whenever the bpatcher is resized. It would be extremely useful for making GUI abstractions.
Right now the only thing I think you can do is regularly poll a javascript to find out the size of the containing patch. But that would be quite inefficient. Better to have some mechanism built into bpatcher. Like a special object (thisbpatcher?) that could output info about the bpatcher whenever it changes.
If someone knows a better way, please let us know.
That's what I thought... unfortunately I also know nothing about javascript....
when I resize the bpatcher I get the delta for width and height as well as overall width and height as a "help" message (see attachment). Is there any way I can access that information from within the bpatcher or access it period?
Here's a javascript that will output the [bpatcher] position and dimensions. You can use this by patching in a [prepend patcher_rect 0 0] between the left outlet and the object you want to have follow the [bpatcher] size (assuming it is located in the top left corner of the [bpatcher]). Unfortunately it doesn't work automatically, you have to send it a bang to get the values. I hope it helps.
lh
outlets=2;
function bang()
{
if(this.patcher.box){
corners=this.patcher.box.rect
l=corners[0]
t=corners[1]
r=corners[2]
b=corners[3]
width=r-l
height=b-t
outlet(1, corners);
outlet(0, width, height);
}
}
a first quick test works like a charm. thanks so much...
Quote: thereishopeforus@hotmail.com wrote on Sat, 03 January 2009 18:41
----------------------------------------------------
> Unfortunately it doesn't work automatically, you have to send it a bang to get the values.
That's my issue with this approach. If you want it to work automatically, you'd have to setup some sort of polling with a metro banging this javascript. If you have a lot of copies of a bpatcher that seems like a waste of CPU.
The Max environment knows exactly what's going on, so if there was an new object like [thisbpatcher], it could automatically output the current size only when a resize occurred. [jsui] has an onresize() method for exactly this purpose. Bpatcher needs one... is it a reasonable feature request?
For now, the best compromise might be to put a little resize button in the corner of a bpatcher, and when you click that button then the bpatcher could bang the javascript and resize itself. That's not too bad of a solution.
Any way to use thispatcher and script the bpatch size programatically for your needs? Maybe you've looked into this, there's no js in this case. The example is super-simple and only has an empty bpatch, with a scripting name. Use the numbers to change the size, which can keep any aspect ratio you want, plus you can then use the same numbers to size the lcd in the bpatch (thru an inlet or a send, the script size command to the thispatcher within the bpatch). This doesn't answer the question of being able to access the (delta) etc. info when resizing in edit mode, but on the other hand, you can give resizing capabilities to the end user...or preset and forget it!
Quote: seejayjames wrote on Sun, 04 January 2009 16:01
----------------------------------------------------
> Any way to use thispatcher and script the bpatch size programatically for your needs?
I don't really think that helps in my case.
I decided to work through this and come up with the best solution that seems to be possible right now. Put the attached folder on your Max file path and check out bpatcher-resize-example.maxpat
There's resize handle in the lower right that you can use to resize the bpatcher. It uses some mousestate polling and javascript to resize all the GUI objects inside the bpatcher. I think this is basically what the OP was asking for too.
My issue is I don't want that resize handle, and I don't want things to be resizable when the patcher is locked. I want to make some reusable GUI components with bpatchers, and resize the bpatcher like usual while editing and have it act like this resize handle. I really don't think this is possible right now unless you constantly poll the javascript object, which is horribly inefficient.
I keep thinking this would be easily solved by the addition of a new object for this purpose...
Quote: stefantiedje wrote on Mon, 12 January 2009 01:33
----------------------------------------------------
> My long time solution, I can happily live with, is to get the
> position/size with a mynamber (has a position output), then resize
> according to that.
> Instead of a useless polling, I would just need to delete the bpatcher
> after a resize and immediately undo, or send it a bang.
>
> This is demonstrated with my latest St.ools for example with St.Level~.
Nice!
Yes, this seems to be the best possible solution right now. I think I will start doing things this way too. Thanks.
BUT... I can't help feel spoiled by Max 5's great GUI features: all these objects that are stretchable and resolution independent and you can see the changes as you resize and very easily put together nice interfaces in such an interactive way. It's really one of the things I like best about Max, GUI building is a joy compared to text-based languages.
So I still request a thisbpatcher object be added that could output the bpatcher's dimensions when the size changes, so I can do this on the fly as the object resizes with no delete/undo. It will make the workflow smoother, and it's generally so smooth in Max 5 I want to keep the workflow as good as possible. I want my bpatcher abstractions to be as close to a "real" or jsui object as possible in terms of resizing behavior.
I realize this is pretty nitpicky and it won't be a priority. Anyway, I've put the idea out there so I'll shutup for now and use Stefan's solution.
> I guess the only way to do that is to let Max monitor what's going on,
> and send a message to the object to notify it. A bit like a debugging
> state.
----------------------------------------------------
I second that, and add this: since Max obviously knows what's going on when you resize (the numbers show up), and it knows where you're moving things (though these numbers don't actually show up), if there's a way to intercept these numbers that would be great. Perhaps it would only print out when you've released the mouse, and it would give the final values, thus filtering out all the intermediate states of moving/resizing (in case you're recording the messages into a coll or something). Perhaps a way to get the patcher coords/rectangles from the JSON patch file, automatically finding the values based upon the unique object name?
Along those lines, a way to easily see what's printed in the Max window right in your patch would be helpful :: like a "print" but instead of going to the Max window, it would come out and you could see it in a message box. The object might be called "max_messages" or something, and you could track everything that goes to the max window right in your patch. Just a thought.
CJ
Where is the "attached folder" to which Adam refers a few entries up?
I would really like to be able to resize a bpatcher when I instantiate it and have the items inside be resized.
it could be that in max 6 it work right out of the box.
i regulary solve such things by "max; refresh" to the main window as there are various
drawing problems with bpatchers in max 4 and max5.
Is it me, or is there no such thing as bpatcher in presentation mode? Anytime I make bpatcher, the subpatch stays in patchmode no matter what mode the parent is in.
I use bpatcher in presentation mode all the time.
ok, maybe I'm doing it wrong? How can I do this?
Thanks
Joe
Since I don't know what you're doing, it's kind of hard to say what you're doing wrong. I presume that you have added the bpatcher to the presentation layer and that you have the patchers inside set to open in presentation mode
yea, not "open in present mode. I thought if I set it to present via bottom menu it would stay that way.
So, this actually is possible... with some js patcher scripting to invisibly move your bpatcher's contents around, and a max external to listen for and report when the parent bpatcher's view box changes. The good news is that the external has already been written, and is in fact one of the examples in the Max SDK... it is called "windowwatcher". I have just successfully built that example external, loaded it inside a bpatcher, and used the messages from its outlet which report changes to the patcher view's box to bang a js which resizes the other ui elements inside the bpatcher. it works like a charm. - vic
G'day Victor,
Awesome! If you have time, could you please post a dummy example of a working patch as you describe?
- Joe
Hi Victor, is there any chance of sharing this?
You can do it simply by using pattr
this is whats in the bpatcher: