English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 21 October 2020, 16:32   #1
Warty
Registered User

 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 95
GadTools Scrollbars in Window Frame...?

I'm working on a program for 3.1.4. I'm looking forward to redoing it with Reaction gadgets in 3.2, but in the meantime, I'm just plodding ahead with what's available. I don't want to do MUI.

I know the 1.x style of gadgets. Lots of busy work, but they work fine.

I'm trying to get gadtools style gadgets working, but I'm not finding much in the way of examples, at least as far as scrollbars. I'm stuck at a basic point: are these things supposed to be able to render in the windows bottom and right borders, or not? I see the note in the auto docs about relative positioning not being available. For the life of me though, I can't position them to open in the borders. Is that maybe not even possible with GadTools for some reason? (seems to make the SCROLLER_KIND rather pointless).

--
GadTools gadgets may not be made relative sized or relative positioned.
This means that the gadget flags GFLG_RELWIDTH, GFLG_RELHEIGHT,
GFLG_RELBOTTOM and GFLG_RELRIGHT may not be specified.
--
http://amigadev.elowar.com/read/ADCD.../node0276.html
Warty is offline  
Old 21 October 2020, 18:12   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 991
If you are looking specifically for prop gadgets that go into the right or bottom border of a window, then gadtools is the wrong choice. The gadgets workbench (and other programs such as ViNCEd) use are intuition boopsis, namely instances of the "propclass".
Thomas Richter is offline  
Old 22 October 2020, 03:12   #3
Warty
Registered User

 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 95
Ok, thanks Thomas. I'll go BOOPSI myself then. Why C= would introduce a new gadget system WITH a scrollbar gadget that doesn't support scrollbars-in-windows... grumble, grumble...
Warty is offline  
Old 22 October 2020, 09:57   #4
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 103
I had a similar question some years ago. The answer I got back then contained the example file 'scroller2.c' which shows how to use boopsi gadgets in window borders.

Last edited by thyslo; 22 October 2020 at 10:39.
thyslo is offline  
Old 25 October 2020, 06:41   #5
Warty
Registered User

 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 95
Thanks Thyslo, that was helpful. I had found a very similar example in the demo code here:
https://www.codewiz.org/projects/amiga/boopsi/BLV.html

But the scroller2.c example is more limited in scope, and better for anyone coming along looking for this info in the future.

I do have a couple of follow-up questions:
1) What's a good strategy for hiding a scrollbar when not needed? eg, content is bigger than window, so scrollbar needed, but user deletes 2-3 lines, and now content fits in window. I tried a few things, but didn't have much luck. I didn't try removing the gadget and adding it back when needed, that seemed like a pain.
2) what's the general idea for creating a basic bevel button with BOOPSI? I couldn't find any examples of that. Looking at the ROM Kernal reference, I came up with an idea, but it's not super successful. This is basically using the buttonfrclass with an frameiclass image. It "works" as as button, in terms of sending messages, but when you click on it, the text basically disappears. Anybody have an example to point to?

Code:
if ( (the_surface->gadgets_[GADGET_BUTTON_SORT_SIZE] = NewObject (NULL, (STRPTR)FRBUTTONCLASS,
	GA_ID,		GADGET_BUTTON_SORT_SIZE,
	GA_Previous,	the_surface->gadgets_[GADGET_BUTTON_SORT_TYPE],
	GA_Top,		scr->WBorTop + scr->Font->ta_YSize + 2,
	GA_Left,	GADGET_BUTTON_SORT_SIZE_LEFT,
	GA_Width,	GADGET_BUTTON_SORT_SIZE_WIDTH,
	GA_Height,	GADGET_ICONBAR_HEIGHT,
	GA_DrawInfo,	the_surface->draw_info_,
	GA_Image,	NewObject(NULL, (STRPTR)"frameiclass",
		IA_Recessed,    TRUE,
		IA_EdgesOnly,   TRUE,
		IA_FrameType,   FRAME_BUTTON,
		//IA_Top,	the_surface->icon_font_baseline_ + 10,
		//IA_Left,	GADGET_BUTTON_SORT_SIZE_LEFT,
		IA_Width,	GADGET_BUTTON_SORT_SIZE_WIDTH + 0,
		IA_Height,	GADGET_ICONBAR_HEIGHT,
		TAG_END),
	GA_Text,	"by Size",
	ICA_TARGET,	ICTARGET_IDCMP,
	ICA_MAP,	NULL,
	TAG_DONE)) != NULL)
Warty is offline  
Old 25 October 2020, 09:35   #6
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,193
Quote:
Originally Posted by Warty View Post
1) What's a good strategy for hiding a scrollbar when not needed?
Don't hide it. Just make the knob as large as the scroll area so that it cannot be moved. Use Workbench as example.


Quote:
2) what's the general idea for creating a basic bevel button with BOOPSI?
You should supply a DrawInfo to the image and the gadget, otherwise they do not know how to render properly.

And you have to remember the image pointer. It won't be freed automatically, you have to manually dispose it.

You do not need to set the size of the frame. The button will tell the image how big it is. Create the button first with the image attached but without size. Then use SetAttrs to set the button position and size. The frame will adjust itself.

If you make multiple buttons they can share the same frame image. You don't need to make a separate image for each button.
thomas is offline  
Old 25 October 2020, 18:45   #7
Warty
Registered User

 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 95
1: on scrollbar - I have it 'full' when there's nothing for it to do, I just wanted to hide it when not needed so it's one less thing for the user to worry about. I'll give up on that for now.

2: on the button - that helped, thanks! Now they are sizing correctly. The weirdness I was seeing about how they rendered when the mouse clicked on them was due to setting IA_EdgesOnly to TRUE (well, copying out of some example somewhere and not paying attention).

If anyone looking for bevel buttons in the future, this is an example framework (but don't forget to free the image, as Thomas points out):

Code:
struct Image * the_bevel_button_image = NewObject(NULL, (STRPTR)"frameiclass",
	IA_Recessed,    FALSE,
	IA_EdgesOnly,   FALSE,
	IA_FrameType,   FRAME_BUTTON,
	GA_DrawInfo,	the_surface->draw_info_,
	TAG_END);

<blah blah blah>

if ( (the_surface->gadgets_[GADGET_BUTTON_SORT_SIZE] = NewObject (NULL, (STRPTR)FRBUTTONCLASS,
	GA_ID,		GADGET_BUTTON_SORT_SIZE,
	GA_Previous,	the_surface->gadgets_[GADGET_BUTTON_SORT_TYPE],
	GA_Top,		scr->WBorTop + scr->Font->ta_YSize + 2,
	GA_Left,	GADGET_BUTTON_SORT_SIZE_LEFT,
	GA_DrawInfo,	the_surface->draw_info_,
	GA_Image,	the_bevel_button_image,
	GA_Text,		"by Size",
	ICA_TARGET,	ICTARGET_IDCMP,
	ICA_MAP,	NULL,
	TAG_DONE)) != NULL)
{

	// set size of buttons. this needs to happen after creation, so that each button's image gets the info.
	// https://eab.abime.net/showthread.php?t=104415
	SetGadgetAttrs (
	  the_surface->gadgets_[GADGET_BUTTON_SORT_SIZE], the_surface->window_, NULL,
	  GA_Width,   GADGET_BUTTON_SORT_SIZE_WIDTH,
	  GA_Height,  GADGET_ICONBAR_HEIGHT,
	TAG_END);
If I could ask maybe one more clarification: how does it work that you can get an "Object" back for an image, if you declare it as struct Image? It works. I see examples with both (scroller2.c declares its sizer image as an Object, LVDemo declares the same sizer image as struct Image, and both are allocated via NewObject(). I don't get how that works, because struct Image is pretty different:

Code:
struct Image
{
       WORD LeftEdge;
       WORD TopEdge;
       WORD Height;
       WORD Depth;
       UWORD *ImageData;
       UBYTE PlanePick, PlaneOnOff;
       struct Image Next Image;~
};
Warty 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
Step frame-by-frame? pushead support.WinUAE 2 06 June 2020 08:46
Pause emu and move frame by frame? hexaae support.WinUAE 3 27 October 2019 02:18
How to remove/hide any gadget from window (gadtools) peceha Coders. System 9 18 September 2019 09:45
How do you get scrollbars to work in C? chocsplease Coders. C/C++ 4 01 November 2017 13:56
gadtools zharn Coders. C/C++ 6 21 February 2014 21:26

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 12:12.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.07035 seconds with 15 queries