Show dynamically created brushes

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Show dynamically created brushes

Post 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!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Show dynamically created brushes

Post 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 :)
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: Show dynamically created brushes

Post 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. :-)
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: Show dynamically created brushes

Post 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. :-/
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Show dynamically created brushes

Post 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 ;-)
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: Show dynamically created brushes

Post by Clyde »

SelectDisplay(): Yes, that did the trick, thanks a lot!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: Show dynamically created brushes

Post 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?
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
AUserLG
Posts: 16
Joined: Sun Feb 14, 2010 11:26 pm
Location: Ottendorf-Okrilla / Germany

Re: Show dynamically created brushes

Post 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 :)
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: Show dynamically created brushes

Post 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!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
AUserLG
Posts: 16
Joined: Sun Feb 14, 2010 11:26 pm
Location: Ottendorf-Okrilla / Germany

Re: Show dynamically created brushes

Post by AUserLG »

Yes, I know, but today I had some circulation problems, so my English would have been horrible.

You're welcome :)
Post Reply