Page 1 of 1

Show dynamically created brushes

Posted: Mon Jun 03, 2019 2:27 pm
by Clyde
Hi there,

yesterday I started to look into RapaGUI (which really looks super cool!). I did the tutorial and wanted to extend it to show a brush. It was no problem to add and show a brush that I load via

Code: Select all

@BRUSH
and define the brush tag in the xml file, like:

Code: Select all

<image brush="1"/>
Now I have two questions which may be feature requests:

1. I know I can create elements dynamically in code with

Code: Select all

moai.CreateObject([[<brush id="mybrush" brush="1"/>]])
(see chapter 3.7). But then I also have to run some lines to add it to the proper elements which seems to be not hazzle free at all times. But it would be nice(r) if I could declare the brush tag in the xml file, too, but without specifying a brush id (because I get it a runtime and don't know it yet when defining in the xml) or mark the id as "you will get it later", eg.

Code: Select all

<image id="mybrush" brush="Nil"/>
. Basically see this as a kind of placeholder in the xml.
So later I could just use in code:

Code: Select all

moai.Set("mybrush", "brush", 42)
2. This belongs to the above question: Generally I don't want to use fixed IDs (for my brushes) but want to use automatic ID selection:

Code: Select all

Local myBrushID = CreateBrush(Nil, ...)
But it seems that it is not possible to use such an ID for the moai.Set() command (just in brushes?). So, doing this will fail (with sth like "third argument as be a number" or so):

Code: Select all

moai.Set("mybrush", "brush", myBrushID)
So is this something that can already be done or is it possible to add these things to a new version of RapaGUI? Thanks in advanve!

Re: Show dynamically created brushes

Posted: Mon Jun 03, 2019 7:36 pm
by airsoftsoftwair
This can't be done currently. But of course you could just create a Hollywood object instead of an Image object and then just draw the brush to the Hollywood display and it will automatically appear in the object. This also allows you to use dynamic brush IDs :)

Re: Show dynamically created brushes

Posted: Tue Jun 04, 2019 10:43 am
by Clyde
Great, thanks a lot for showing my that path. I will try that. Impressive, that this is possible.

Still, your "currently" let's me hope that you could implement the two things I mentioned later? Because the "placeholder" approach would lead to more clean code/no boilerplate code and would help to create layouts independently (e.g. in a teamwork with GUI designers).

Man, it is really insane, what you do, Andreas. It is a shame that you don't get the praise (and money) you do for your work, in the Amiga community as well outside our market. One guy at a1k wrote to c't after your Hollywood 8 release, but they didn't see the potential and so didn't want to do an article or news flash. :-(

Thanks a lot for all you do! And yeah, my Hollywood 8 upgrade order will soon be placed. :-)

Re: Show dynamically created brushes

Posted: Wed Jun 05, 2019 12:02 am
by Clyde
Ok, I did a test with one hollywood display integrated into the GUI, which works.

Now I want to display two brushes in two displays, but this does not seem to work. Only one brush is displayed (the one that is included last). I created a simple example which you can find here: https://1drv.ms/u/s!AvRgnk1wjp43loBLm58 ... A?e=5vTpcL

If you change the order of the includes in main.hws you see how the other brush is displayed on the left. The right display keeps being black.

I am quite sure I did some kind of newbie error again, but I don't know what I did wrong. :-/

Re: Show dynamically created brushes

Posted: Wed Jun 05, 2019 4:35 pm
by airsoftsoftwair
Clyde wrote: Tue Jun 04, 2019 10:43 am Still, your "currently" let's me hope that you could implement the two things I mentioned later? Because the "placeholder" approach would lead to more clean code/no boilerplate code and would help to create layouts independently (e.g. in a teamwork with GUI designers).
Never say never ;-)
Clyde wrote: Wed Jun 05, 2019 12:02 am I am quite sure I did some kind of newbie error again, but I don't know what I did wrong. :-/
Looks like you didn't use SelectDisplay() to tell Hollywood where to draw to. If you don't use that, everything will be drawn to display 1.
Thanks a lot for all you do! And yeah, my Hollywood 8 upgrade order will soon be placed. :-)
Sounds good ;-)

Re: Show dynamically created brushes

Posted: Wed Jun 05, 2019 9:53 pm
by Clyde
SelectDisplay(): Yes, that did the trick, thanks a lot!

Re: Show dynamically created brushes

Posted: Fri Jun 07, 2019 12:02 am
by Clyde
Andreas, I updated the code of the zip file on OneDrive slightly.

I want to get the coordinates of the mouse position when I click on the brush (see

Code: Select all

brushDisplay1.hws
) (the relative coordinates to the brush canvas):

Code: Select all

Function p_HandleMouseUp(msg)
    Local mousePosX = MouseX()
    Local mousePosY = MouseY()
    DebugPrint("mousePosX, mousePosY", mousePosX, mousePosY)
EndFunction

...

InstallEventHandler({OnMouseUp = p_HandleMouseUp})
If you start the main.hws and therefore use RapaGUI the coordinates are strange. On the one hand if I move the mouse and click elsewhere the values are not updated and the seem to be messed up somehow. If you now click on the other, right brush and then click on the left brush again the coord values have changed, but still look strange and additional clicks over different positions won't change the values.

If you now uncomment the event loop in the file

Code: Select all

brushDisplay1.hws
and just run this file, the coordinates are printed properly.

What am I doing wrong?

Re: Show dynamically created brushes

Posted: Fri Jun 07, 2019 10:22 am
by AUserLG
Mahlzeit Michael :)

Wenn du noch ein SelectDisplay(id), also hier 1, in die Funktion reinsetzt, wird es aktualisiert.

Code: Select all

...
Function p_HandleMouseUp(msg)
	SelectDisplay(1)
	Local mousePosX = MouseX()
	Local mousePosY = MouseY()
	DebugPrint("mousePosX, mousePosY", mousePosX, mousePosY)
EndFunction
...
Grüße :)

Re: Show dynamically created brushes

Posted: Fri Jun 07, 2019 11:01 pm
by Clyde
Moinsen Lars :-),

thanks a lot for your (German) help :-) but we should stay English so others can participate.

Oh boy, yeah, that totaly makes sense. Now I see my mistake. Thanks a lot!

Cheers!

Re: Show dynamically created brushes

Posted: Fri Jun 07, 2019 11:55 pm
by AUserLG
Yes, I know, but today I had some circulation problems, so my English would have been horrible.

You're welcome :)