I have a BOOPSI gadget class that is just a box. Above it is a weightbar that can grow/shrink my gadget's height. Is there a way to make the width grow with it to keep an "aspect ratio" of sorts?
Height increased by 2, width increased by 4.
My gadget is the left most. There are other gadgets to the right of it. They would have to shrink in width while the main one grows in width. The other gadget heights do not change.
@mritter0
I guess you are using a resizable window.
Did you try to add those gadgets expected to change size to a "layout.gadget" object (layout_gc.doc)?
The window is resizable, but the weightbar is what resizes my gadget. Yes, it is laid out with Layout class.
To make it a little more clear: I have the source code to the BOOPSI class so I can control it. While my class is getting "signals" to update itself because the height is being changed, at that point can I have also change the width?
I don't want to have to put another weightbar to increase the width. I want it automatic.
@mritter0
That would be my guess. Modify your class code so that when the object receives a GM_RENDER, you update both the width and the height, and redraw the gadget.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
That won't change anything. The size of your gadget is set by the surrounding layout group. If you change the size from inside your class code, it would be ignored. In the worst case you would get graphics corruptions because you render outside the area reserved for your gadget.
All you can do is to render your contents centered in the area you get. But you cannot change the size of the area. This can only be done by the parent layout.
I came to the same conclusion as Thomas. There is no place to tell what size to make the gadget, the layout engine tells it what size.
@Thomas
Oh it sits in a layout, how could I have overlooked that? (Teaches me for skim-reading.)
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
Intesrtesting to come across this topic as I have so similar questions.
But to take your question first.
There are two approaches you might investigate:
1. From inside the gadget
The important thing here is that gadget need not be as big as the pace allocated to it. What do I mean by this? In the simplest case the gadget is a box
gadget->LeftEdge;
gadget->TopEdge;
gadget->Width;
gadget->height;
but there is not reason you have to use all of that space. When you respond to the GM_HITTEST method you maye use any alogorthm you like to determine the shape within that rectangle, so your gadget may be any shape within it.
Ofcourse this leaves space arround that gadget which you may not want.
2 From the application:
Create some kind of scaling method for your gadget.
When your window is resized call that method appriopriatly, and rethink the window / layout.
(this is my approach in the current application I'm working on)
What *I* need to know is how to tell if the Weight Bar I just added to my GUI has been moved? So that I may reinvoke my scaling method, and also reset my scroll bars to suit the current layout.
I also asked about signals from weightbars; can't get them directly. I feel it would be a benefit to programmers to even just get a gadget up signal. Then we can look at the gadget sizes manually to act upon the change.
Another post
If you come up with "system friendly" method, please let me know.
I have a partial solution, though it is a bit appliacation specific, and relies on my custom gadget being contanined in a layout.gadget.
When the bar is moved the layout is relaid out, causing the inner layout to change size.
My custom gadget has a link back to the it's parent layout (INNER LAYOUT) so when INNER LAYOUT get relaid out by the movement of the bar in the OUTER LAYOUT
First GM_DOMAIN is invoked on the custom gadget. The gadget then does a GET_Width and Get_Height on the containing layout to find out is potrntially avaiable space. It then calculates its domain from that. returning appriate values for nominal and maximum.
Next GM_LAYOUT is invoked and I can do my real scaling of the gadget content here, scaling to the size allocated by the containing layout. If my domain asked to be smaller than the container, this ends up being the size I asked for if larger then as I set DOMAIN_MINIMUM very small it fills the conrainer completely (and I activate scroll bars). Note no rendering is done till the GM_RENDER method is called.
This works for me as I *want * the cutsom gadget centred in the area controled by the drag bar and I just need to know when the area chnaged to rescale it's content.