New to Reaction

17 posts / 0 new
Last post
dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
New to Reaction

New to reaction programming and I am having a bit of trouble understanding a couple concepts. One thing I am trying to do is completely control positioning of gadgets utilizing LAYOUT_NoLayout

1. Without using GIMMIEZEROZERO on the window attribute how do you get the proper metrics for the borders and other gadgets?

2. The label image class.
How do you control the size and position of label in a layout if you are using so you have manual control over placement like you can with gadgets.

Hopefully some of you can point me in right direction. I have been reading all the articles here and have gleaned much but I am really trying to wrap my head around some of the conceptual differences from other GUI APIs. ie. no child windows, labels are not gadgets etc...

Thanks
Doug

LyleHaze
LyleHaze's picture
Offline
Last seen: 2 years 1 week ago
Joined: 2011-05-26 03:58
Re: New to Reaction

Welcome!
You have chosen a challenge.
As I understand it, ReAction is all about managing the GUI in a "standard" way so the programmer does not have to. It can get a bit tricky, but choosing "complete control of position" is going to be a wrestling match at best.

Back in the pre-reaction days, programmers had complete control over the GUI, and all those gadgets and such are still available. Reading any early AmigaDOS Intuition references would be the quickest way to get there.

As far as ReAction goes, there were some early macros that have since been deprecated. One unfortunate result is that a lot of the examples out there are not as useful, nor as clear as they ought to be.

Trixie took a trip through all of this, and wrote a really excellent guide to ReAction programming. It is hosted on this site, titled "Beginner's Guide to Programming ReAction". It is the best reference on what to do, and what to avoid doing, that I have seen yet.

I am no expert, but I started by absorbing as much from his guide as I could, and I continue to add to my abilities as need arises.

Good Luck!
LyleHaze

LyleHaze

jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 2013-05-30 00:53
Re: New to Reaction

What kind of (ReAction) GUI have you in mind to create? Maybe you can post here a sketch of your GUI designed or part of code.

I will suggest start with
http://www.os4depot.net/share/development/example/reaction_examples.lha
and with
http://www.os4depot.net/share/development/example/reaction_dn.lha

and as LyleHaze http://www.os4depot.net/share/document/development/reactionguide.lha

There are some small programs I made on os4depot that have sources and you can see the GUI/Reaction code (POff, DateTime, KeymapSwitcher,...) and maybe inside the SDK there are other examples.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
Re: New to Reaction

Hi,
Thanks for feedback been reading through all those documents but non really document enough of behaviors and interactions of the various options.

The UI is not a specific design. I am working on porting a GUI API like (WxWidget but not that) to support the Amiga and trying to deal with the complexities of mapping the functionality of the generic API to Amiga Widgets. I was hoping to be able to use the high level constructs of Reaction with out having to dive deeper into intuition. The API wants to control alignment/layout hence my completely disabling the layout control. My challenge is understanding labels in unlike most other platforms they are a widget too. I can move gadgets around fine but not labels.
Thanks
Doug

DStastny

jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 2013-05-30 00:53
Re: New to Reaction

If you mean labels as the text that shows (normally) before the gadget (sorry for poor/ASCII art):

Label [ @ | options ]

Label: [string_gadget]

Label [  x ]
[ x ] Label

You can "make" the label a button without bevel (BUTTON_BevelStyle,BVS_NONE) and transparency (BUTTON_Transparent,TRUE) so it looks like a normal label.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
Re: New to Reaction

@jabirulo
That is a great idea!

Thank you

DStastny

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: New to Reaction


New to Reaction
New to reaction programming and I am having a bit of trouble understanding a couple concepts. One thing I am trying to do is completely control positioning of gadgets utilizing LAYOUT_NoLayout

You probably shouldn't? The whole point of layout gadget is that is lays out stuff. Using LAYOUT_NoLayout is for extreme exceptions.

I've used it exactly once in my SnakeEyes.py image view when I needed to place a bitmap image so it centred in the display window.

I don't if this will give you a clue or not as it's python code , for my ProAction GUIServer, which is a fairly thin wrapper arround the underlying BOOPSI code.

  1. def RelayoutImage(guiKey):
  2. global layouts
  3. global needrefresh
  4. layouts += 1
  5. SetWindowBusy(guiKey,1)
  6.  
  7. # Get the various attributes we need
  8. (rc,rc2,bmWidth) = SendGUICmd("GETATTR GUIID " + guiKey + " OBJECTID " + gadgets['bitmapImageID'] + " TAGNAME \"BITMAP_Width\"")
  9. (rc,rc2,bmHeight) = SendGUICmd("GETATTR GUIID " + guiKey + " OBJECTID " + gadgets['bitmapImageID'] + " TAGNAME \"BITMAP_Height\"")
  10.  
  11. (rc,rc2,layWidth) = SendGUICmd("GETATTR GUIID " + guiKey + " OBJECTID " + gadgets['imageLayoutID'] + " TAGNAME \"GA_Width\"")
  12. (rc,rc2,layHeight) = SendGUICmd("GETATTR GUIID " + guiKey + " OBJECTID " + gadgets['imageLayoutID'] + " TAGNAME \"GA_Height\"")
  13. (rc,rc2,layTop) = SendGUICmd("GETATTR GUIID " + guiKey + " OBJECTID " + gadgets['imageLayoutID'] + " TAGNAME \"GA_Top\"")
  14. (rc,rc2,layLeft) = SendGUICmd("GETATTR GUIID " + guiKey + " OBJECTID " + gadgets['imageLayoutID'] + " TAGNAME \"GA_Left\"")
  15.  
  16. # note at this point all the attributes are strings!
  17.  
  18. laspect = float(layWidth)/float(layHeight)
  19. baspect = float(bmWidth)/float(bmHeight)
  20.  
  21. if baspect > laspect:
  22. mwidth = int(layWidth)
  23. mheight = int(float(layWidth) / baspect)
  24. mleft = int(layLeft)
  25. mtop = int(layTop) + (int(layHeight) - mheight)/2
  26.  
  27. else:
  28. mheight = int(layHeight)
  29. mwidth = int(float(layHeight) * baspect)
  30. mleft = int(layLeft) + (int(layWidth) - mwidth) /2
  31. mtop = int(layTop)
  32.  
  33. # layout our bitmap manually
  34. bitmapSetTags = ""
  35. bitmapSetTags += "IA_Left," + str(mleft) + ","
  36. bitmapSetTags += "IA_Top," + str(mtop) + ","
  37. bitmapSetTags += "IA_Width," + str(mwidth) + ","
  38. bitmapSetTags += "IA_Height," + str(mheight) + ","
  39. bitmapSetTags += "TAG_DONE"
  40.  
  41. (rc,rc2,dummy) = SendGUICmd("SETATTRS GUIID " + guiKey + " OBJECTID " + gadgets['bitmapImageID'] + " TAGSTRING " + bitmapSetTags)
  42.  
  43. SetWindowBusy(guiKey, -1)
  44. needrefresh = 1

Notice I get the bounds of the parent layout by querying it's GA_Top/GA_Left/GA_height/GA_Width parameters, calculate the image parameters accordingly and set the IA_Left,IA_Top etc

It works but is quite clunky and when I came to working on MultiViewer I used a custom image display gadget to disply the images using compositing or manual scaling.

The full script is here: http://os4depot.net/index.php?function=showfile&file=graphics/viewer/snakeeyes.lha

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: New to Reaction


The UI is not a specific design. I am working on porting a GUI API like (WxWidget but not that) to support the Amiga and trying to deal with the complexities of mapping the functionality of the generic API to Amiga Widgets. I was hoping to be able to use the high level constructs of Reaction with out having to dive deeper into intuition. The API wants to control alignment/layout hence my completely disabling the layout control. My challenge is understanding labels in unlike most other platforms they are a widget too. I can move gadgets around fine but not labels.

Lables are BOOPIS objects just like Gadgets, but they are based in imageclass not gadgetclass. There is quite a lot in common between the two, but images don't accept input.

Sounds to me like you may need to devise you own layout gadget if the standard one doesn't map well to the alien GUI. That will require lowlevl BOOPSI class coding and is ot a trivial undertaking for someone new the concepts.

It doesn't that there is a fair amount of private stuff going on between window.class and the layout gadgets.

You might need to drop window.class and use a plain Intuition window.

dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
Re: New to Reaction

Sounds to me like you may need to devise you own layout gadget if the standard one doesn't map well to the alien GUI. That will require lowlevl BOOPSI class coding and is ot a trivial undertaking for someone new the concepts.

I have considered this approach but as you point out that is bigger under taking. I am starting to consider not supporting the foreign GUI API and providing an Amiga specific implementation. I will work on getting my github repo up so you guys can see more clearly what I am attempting.

Thanks for feedback
Doug

DStastny

hypex
hypex's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2011-09-09 16:20
Re: New to Reaction

Hi dbstastny. Just wanted to add some comments. As belated as I am. :-)

I tend to agree with LyleHaze here. If you need more control then Intuition is one way to go about it. As that will give you control over position and size. And also images which is useful. Which, if you wanted, could be used to customise your font rendering.

But how much control do you need? Do you also need to render custom border images and fonts? Or can you leave it up to the GUI engine?

If you wanted full control you could use Intuition. However, if all you really need is the ability to specify size and position, then you should consider GadTools. This uses the building blocks of Intuition to create the gadgets but simplifies the creation process and also generates a standard look. It doesn't layout for you but does allow you to specify position and size. You just need to calculate the width of any text inside so size fits. Which is easy enough.

Under the shadow of ReAction, with no gadget auto layout, GadTools has been relegated to being a menu generator. Since it allows fairly simple menu generation. In fact, one thing it does layout is menus, so it left a funny legacy there. :-)

dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
Re: New to Reaction

I know this is quite old as I had been working getting my Blitzmax compiler issues PPC ABI sorted out and writing AHI sound driver interfacing with MiniGL. I got back to looking at this. And dumb as it was I figured it out. Not sure if its a bug with image derived objects like labels but when under NOLAYOUT layout(Say that fast) it does not respect initial coordinates. After creating the window I can move and control the image objects no problem location wise. So on to implementing a BlitzMax GUI. Just a little more effort on my part dealing with labels. Is there any sort of RTF control or am I going to have to write a texteditor that has colors as I cant seem to make a Textcontrol work at all respecting escape codes regardless of what the Documentation says.

Regard
Doug

DStastny

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: New to Reaction

And dumb as it was I figured it out. Not sure if its a bug with image derived objects like labels but when under NOLAYOUT layout(Say that fast) it does not respect initial coordinates.

LAYOUT_NoLayout means exatly that, you have to do all the work yuourself. Images don't behave like gadgets, the don't really have specific location, the same image can be drawn in different places in the GUI (and so shared between gadgets).

Is there any sort of RTF control or am I going to have to write a texteditor that has colors as I cant seem to make a Textcontrol work at all respecting escape codes regardless of what the Documentation says.

If you are refering o texteditor.gadget then no there is no full colour support. Even the escape code approach was pretty minimal, and less so in the AmigaOS 4 version.

Highlighting certain lines is the limit (see AutDoc Viewer as an example. of what I mean).

There is richeditor.gadget in use by codebench, but the API is not public. Not sure if there is any plans for it to be.

Do you need the colours for syntax highlighting?

dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
Re: New to Reaction

@Broadblues Yes I am looking at syntax highlighting. As for reason for no layout is BlitzMax GUI has a Layout mechanism built into its API for cross platform development. So if I can fulfill the various contracts of the maxguidriver. As for coloring of editor yes it is for syntax highlighting. I need a rudimentary html control as well I know there is a datatype but don't think its supports any hyperlinking. I have idea of some code that I can use to maybe build out support for hmtl control. Not full browser but good enough for help files.

Regards,
Doug

DStastny

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: New to Reaction

If by datatype you mean the simpleHTML.datatype refered in the other thread, yes it supports hyperlinks, but only file based ones , there's no http(s) .

As to syntax highlighting, even if the colours worked as advertised in texteditor.gadget it would not be suitable for syntax uses. You'll probably have to build your own.

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
Re: New to Reaction

AFAICT it should be possible to position images in a LAYOUT_NoLayout layout by using the LeftEdge/TopEdge fields of the image (IA_Left/IA_Top for BOOPSI images).

There might be some implementation differences between image classes though, making it not work correctly with some of them.

dbstastny
dbstastny's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2017-02-04 00:01
Re: New to Reaction

@salass00,

Yes sir that is how I got it to work but I found it did not respect the coordinates when I create the object. I had to set them after I open the window. If curious I will post a simple example of what works and what didnt.

Regards
Doug

DStastny

tiffers
tiffers's picture
Offline
Last seen: 5 years 12 months ago
Joined: 2018-11-12 13:35
Re: New to Reaction

Thread Necro! Was this Beginner's Guide the one Jim Tubbs wrote, which Trixie followed up with "No don't do that. This is the best way" blog?

Never done any multi-tasking/GUI stuff before, so I need to learn a lot. I'm especially lost with how Wait() works. I have many questions, but want to learn as much as I can by reading docs/code before I start asking a torrent of questions.

Log in or register to post comments