The first example is actually what is going on in the patch there. The second example would work, but for some reason naming $0 on the scalar won't work on the top level patch, hence dynamic patching to get the $0 number instead of $0 as a literal. There is no changing of draw instructions or anything. The only thing that is created at load time is the scalar itself... which actually even works unless you call it from a text box, where it will load and then crash. I honestly cannot figure out what makes it crash exactly, but it does - every time. As far as I can see, I've patched everything properly and it should work, but alas... so close yet so far... I appreciate all the input on this patch... the main reason I was making it was an experiment to see if UI objects could be made to scale on mouse drag of the GOP square instead of creation arguments or message. With that, I can make some external/abstractions for quick WYSIWYG style editing of interfaces, whereby you can type a UI object name, get something that looks reasonable sleek and modern that functions and is somewhat customizable, and then easily drag and drop it where you want it to go on your interface, scale it etc. Having started in MAX msp, there are some features like what I am saying here that I'm sure many would love to see brought to puredata in a more modern way than what has been done so far. To me, that's really the one and only thing PD is missing. Other than that I actually prefer PD to max now... So this was just an experiment to see if I could create my idea in this manner and make some nice UI objects to contribute. I'll just have to either find another angle or figure out why my current method is unstable....
-
Drawing scalars freaks out when GOP is turned on
-
@th8a Do you want to scale individual widgets-- the way Purr Data does with iemguis?
Or are you actually talking about a responsive design where the widgets scale and pad themselves accordingly as the viewport itself changes size (e.g., when the user drags the GOP box to scale things)?
The first option is certainly doable with the
[draw]
event callbacks. Getting an actual responsive design isn't currently possible with any of the public interfaces provided by Pd or Purr Data. (At least not in a way that you can ship the patch to someone else and have the responsive design work.) -
As an experiment to see if it is possible, the latter. I actually came damn close to making it work too! if only it were stable...
-
I take that back-- you probably can do the responsive thing using
[draw g]
.I can give you a demo if you want.
-
yes please
-
@th8a Here's a quick hack:
The hack is that I currently don't have an easy way to do clipping, so I'm using grouping and opacity to work around that.
The logic for the keyboard is: when the scaling factor is large enough AND the proportions of the box are wide enough, the piano appears. Otherwise it hides itself. You could define other size/position changes for each widget based on the size of the container.
As hacky as this is, I think it's still easier to comprehend than GOP's behavior.
-
Also notice that there are only two fields to the struct: x and y. That means if you copy and paste the widget, the only data saved with the scalar are the x/y coordinates. If you wanted to be able to have multiple collections of widgets operating independently you would need an additional field in the struct for each piece of data. For example, adding xSize and ySize would allow you to save the dimensions of each scalar. (You'd also have to change the guts of the drawing routine to fetch and set those values.)
-
Hwell son'bitch! I finally got back from my folks place today and had a chance to check this out. I took your patch and made it a gop, scaled it accordingly and it woked without crashing. This method seems like a more sensible way to go for scalable scalars. Having to anticipate the number of instances by changing the struct's variables would defeat my idea to make an easily accessible abstraction to bottle and give away to the next guy, or reuse in multiple projects though... Since $0 naming is out, can you think of any other way to take this concept and make it easily called on as an independent abstraction?
-
@th8a Would you be shipping a scalable square-circle-triangle-piano, or do you want to ship a library that allows users to make arbitrary combinations of squares, circles, triangles, and pianos?
-
I suppose it would be the latter, though what i am trying to do is make a graphical abstraction, like this button here for instance... Save it as an abstraction and then use it like an object or external. I could call it multiple times in a patch and each instance would operate independantly, remembering it's size and placement. I could put the patch up on this forum, and anyone could easily use it in their patches, etc. I suppose I would want it to operate like a graphical array, in that it is a UI element that can be used allover and easily sized and customized. If I can figure out how to get that to work, then I plan a whole library of nice looking UI objects, like knobs, faders, buttons... maybe even some MAX object clones like [live.grid] etc. All easily called on and able to customize like changing size, colors, placement etc.
-
That's certainly possible. I'll show a demo when I get a chance.
The only thing missing atm is the possibility to define a "drag" event in editmode for scaling the scalar. That's why I put it in runmode on the other demo.
-
@jancsika That'll work. I'd start with that, and then it sounds like you plan to add the drag functionality in edit mode at some point, which could make it that much better, but still cool til then