English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 07 February 2024, 04:20   #1
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Best way to implement dynamic resizing of gadgets/windows

Hi all!

If you've followed my previous threads, you'll know I'm writing a Reaction app in assembler. So far I've managed to workaround, or figure out all my issues, however I've got a question I'd like to throw out there. My app contains a button gadget (Reaction class) that renders an image in it (it's actually the image from an arbitrary .info file, so an icon). It renders fine; all good. However, sometimes the icon's width/height exceed the size of the button gadget and it's rendered outside the bounds, resizing the window to make it bigger fixes this. How should I best handle this scenario? 1. Detect that the gadget is too small and issue ChangeWindowBox() to scale the window by some factor; or 2. just scale the image so it fits in the gadget.

The layout class is a little primitive I feel, at least I haven't figured out a way that would have the gadget auto-resized (I've tried calling SetGadgetAttrs to modify the dimensions of the button, but the layout itself prevents it from resizing). Appreciate any feedback folks may have on this!

Cheers,
-Matt

I've attached screenshots showing what I'm talking about!
Attached Thumbnails
Click image for larger version

Name:	iconix1.png
Views:	80
Size:	186.4 KB
ID:	81579   Click image for larger version

Name:	iconix2.png
Views:	68
Size:	177.4 KB
ID:	81580  

Last edited by Mafi; 07 February 2024 at 06:40.
Mafi is offline  
Old 07 February 2024, 07:23   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
You use SetAttrs() to tell the button about the new GA_Image and then call WM_RETHINK on the window object. The window will resize itself if required.
thomas is offline  
Old 07 February 2024, 07:38   #3
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Thanks Thomas - will try this when I get home!
Mafi is offline  
Old 07 February 2024, 08:21   #4
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Ok, I used SetAttrsA to update GA_Image (this works) of the button; but sending WM_RETHINK to the window object doesn't appear to do anything

-M
Mafi is offline  
Old 07 February 2024, 13:58   #5
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Check out this example. It does almost the same as your program.

First argument is path to directory with pictures.
Attached Files
File Type: lha raimglist.lha (10.0 KB, 25 views)
thomas is offline  
Old 07 February 2024, 22:43   #6
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Quote:
Originally Posted by thomas View Post
Check out this example. It does almost the same as your program.

First argument is path to directory with pictures.
Thanks Thomas, yes this is what I had in mind. The only difference I can see is that in your code GA_Image is a pointer to a bitmap class object whereas mine is a pointer to the bitmap at do_Gadget->gg_GadgetRender. I wouldn’t have thought that would matter though?
Mafi is offline  
Old 08 February 2024, 16:24   #7
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Well, I changed the example to use icons rather than bitmaps and it still works for me.
Attached Files
File Type: lha raiconlist.lha (9.4 KB, 26 views)
thomas is offline  
Old 09 February 2024, 21:38   #8
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Quote:
Originally Posted by thomas View Post
Well, I changed the example to use icons rather than bitmaps and it still works for me.
Ok, fixed. I had CHILD_MinWidth and CHILD_MinHeight set. Even though some bitmaps were larger than that, the button wouldn’t resize after WM_RETHINK. I removed these and now it’s working perfectly.

Thanks again.
-M
Mafi is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I implement locks? Sim085 Coders. C/C++ 2 28 October 2022 00:07
AGA Palette... how to implement Steve Coders. Asm / Hardware 23 25 November 2018 22:26
implement others 68000 machines ? turrican3 support.WinUAE 28 23 November 2017 00:54
[REQUEST] implement Windows variables paths hexaae support.WinUAE 4 28 June 2016 21:40
Resizing windows wont save using ClassicWB_ADVSP kipper2k project.ClassicWB 7 14 March 2009 00:23

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:09.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07701 seconds with 14 queries