Doing some layout class, part2: I have wrong looknfeel on buttons...
For some purpose I extends layout class, where:
- I do NewObject() to create my child gadgets and add them with LAYOUT_AddChild internally.
then with GM_layout, I set each children gadgets TopEdge, LeftEdge, width, Height. then I let the original GM_RENDER and all original methods from the layout superclass.
This approach works so far, but I noted the looknfeel of the children Buttons is not correct: flatter and with color0 background. Other buttons layouted with the real layout class in the same window have the correct looknfeel.
Noteworthy: If I iconify my app, then uniconify it, All buttons have then the correct looknfeel at this moment. Then after this, If I add new buttons again from my inherited layout, the new buttons have wrong looknfeel again.
So I guess: the original GM_LAYOUT of the layout class must do something more to object than settings TopEdge, LeftEdge, width, Height to children gadgets. Any idea ?
Note: RefreshLayout() is of no help, passing GA_DrawInfo with object created from screen also no help, only iconify / uniconify, gives the correct looknfeel to all buttons.
Re-Note: This may lead to other questions I have about how you could have a private class drawing with GM_RENDER, that would apply what is set in sys:prefs/reaction about the background , fonts, etc... I mean if I draw a graph and I need to draw text upon the graph, I'm supposed to use the font from the system generic preferences that are applied by the gadgets, and I can't find an information about this anywhere.
Online Status
Once again, I finaly found a bit of informations about this, so It may help:
- The font set for the Boopsi windows may be:
In the DrawInfo you create with GetScreenDrawInfo(app->lockedscreen) and pass to the boopsi window as GA_DrawInfo, the main font may be struct TextFont *dri_Font, ready to used by graphics SetFont() and Text().
- The background image pattern you may have configured in sys:prefs/reaction , is actually passed as a "BackFill Hook". Hooks are struct with a function pointer and data, and "BackFill Hooks" have a special function signature which is described in layers.library docs.
Apparently Gadgets pass magically BackFill Hooks with property GA_BackFill... or ... no , it's look like it's attached to the layer. I don't known, this is automatic magic. And If you may render it apparently it's just the very simple EraseRect(): https://developer.amigaos3.net/autodocs/graphics.library/EraseRect.html
Edit again a thrid time after I goit it right: Correct, EraseRect() can use the "Backfill hook" that draw the background pattern image from the prefs.
But GA_BackFill atttribute which holds the "struct Hook *" has to be caught in SetAttribs(), if you GetAttr(GA_BackFill) it doesnt work (or maybe I did that too soon ?)
Then in a GM_RENDER you have to explicitly do, if I get it right :
struct Hook *oldHook = InstallLayerHook( rp->Layer , gdata->_backfillHook );
EraseRect(rp, ...); // draw the back pattern image
InstallLayerHook( rp->Layer , oldHook );
(It doesn't help my buttons with wrong look btw.)