User code in paint?


#1

Hi all, is it possible to put user code in paint() when using the jucer ?

Because each time I modify the paint code, I’m loosing it when juicing it later.


#2

Can everyone please try to spell “lose” correctly! It worries me when almost every time I see the word, it’s spelt wrong - makes me wonder if it’s actually me that’s losing it…

Anyway… yes I can add a user code section there, no problem.


#3

Hmm - I just looked, and there’s already a user code section in paint()… If you stick your code in the right place it should be fine.


#4

It’s just that “to loose” is an exception, and unlike other verb, its continuous form is not base + ing, but “modified” base + ing.

However the ‘o’ in ‘losing’ still sounds like oo (or is it just me haven’t noticed it yet?).

So, sorry for the spelling mistake, I’ll try to enhance my grammar.

Concerning the user code, I’ve seen the section, but if I move all code from the paint code to the user paint code, each time I reuse the juicer, the code is back in the bad section.

What I’m trying to do is to place a rectangle at (Xoffset + PercentOfWidth, …)
The Juice can do a (PercentOfWidth, …) or (Xoffset, …) but not both, hence the component doesn’t resize correctly.
So each time I use the jucer, I have to manually change the code produced by the Jucer, which is a pain.
I can’t keep the previous changes as the distance might have changed, etc…

I don’t know if it’s possible to add a sort of “diff” when importing a component, and apply the same “diff” when exporting.


#5

“loose” is a particularly bad one - you even see a lot of native english speakers getting it wrong, and I just worry that eventually so many people might get it wrong that it actually becomes accepted. But I am a bit obsessive about grammar and punctuation…

All the code outside the user sections gets regenerated every time you save, and it could be different each time, so I don’t think there’s any way you could get it to cope with changes - it’d need to be able to parse and understand what you’ve done to the code.

I’ve thought about allowing very basic expressions to be used for positions, so you could do more complex things like this - I’ve also found times when I’ve needed to do stuff like that. But the problem is that you can no longer drag or resize the object, because it wouldn’t know how to adjust the equation.


#6

why not doing this in the resized user section?

I do some manual rescaling there, and let the Jucer generated code do the rest in paint.


#7

mdsp: Because we are speaking of path/rectangle stuff, and not components.

Jules: Is it possible to change the templates in the Juicer then ?


#8

[quote=“X-Ryl669”]
Jules: Is it possible to change the templates in the Juicer then ?[/quote]

Of course. Or change the jucer itself if you need it to do something special - that’s the beauty of open-source…


#9

[quote=“X-Ryl669”]mdsp: Because we are speaking of path/rectangle stuff, and not components.

Jules: Is it possible to change the templates in the Juicer then ?[/quote]

well you could have a local variable that is assigned a value based on the dimensions of the component in the resized function [e.g. 10% of the width] and use that in the paint function. That’d not be too complex.


#10