Weightbar resize BOOPSI gadget

10 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2014-04-21 21:15
Weightbar resize BOOPSI gadget

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.

Massi
Massi's picture
Offline
Last seen: 4 years 7 months ago
Joined: 2012-03-28 17:16
@mritter0 I guess you are

@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)?

mritter0
mritter0's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2014-04-21 21:15
The window is resizable, but

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.

trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Weightbar resize BOOPSI gadget

@mritter0

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?

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

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
That won't change anything.

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.

mritter0
mritter0's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2014-04-21 21:15
I came to the same conclusion

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.

trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Weightbar resize BOOPSI gadget

@Thomas

That won't change anything. The size of your gadget is set by the surrounding layout group.

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

broadblues
broadblues's picture
Offline
Last seen: 4 years 10 months ago
Joined: 2012-05-02 21:48
Intesrtesting to come across

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.

mritter0
mritter0's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2014-04-21 21:15
I also asked about signals

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.

broadblues
broadblues's picture
Offline
Last seen: 4 years 10 months ago
Joined: 2012-05-02 21:48
I have a partial solution,

I have a partial solution, though it is a bit appliacation specific, and relies on my custom gadget being contanined in a layout.gadget.

  1. -----------------------OUTER LAYOUT---------|
  2. | | | |-----OUTER LAYOUT-------| |
  3. | | B | | |--------------------- | |
  4. | | A | | | GADGET | | |
  5. | | R | | | | | |
  6. | | | | |--------------------- | |
  7. | | | |------------------------| |
  8. --------------------------------------------|

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.

Log in or register to post comments