English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 29 April 2023, 17:46   #1
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
[Commodity] handling commodity window/interface

Hi,
I am not sure how to handle commodity window/interface.

Commodity can have its window that can be show/hide
In the Exchange app.
Should I create and open new window
When the Commodity is created and then just
Show/hide it?

Or the window should be created/closed
Each time the user clicks show/hide in the Exchange app.?
mateusz_s is offline  
Old 29 April 2023, 19:36   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,026
When the user chooses hide, you should close the window and ideally release all GUI-related resources.

The reason is that while the GUI is hidden, the user expects to be able to close the Workbench screen (for example for a screen mode change). This is not possible if you keep the window open and only hide it.

Also the new functions HideWindow and ShowWindow are only available in OS 3.2+. So if you don't want to reach only half or less of the community, you should avoid these functions.

While the GUI is hidden it should not consume any resources, so if possible you should close all external libraries, classes and so on.
thomas is offline  
Old 29 April 2023, 20:15   #3
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,062
Quote:
Originally Posted by thomas View Post
While the GUI is hidden it should not consume any resources, so if possible you should close all external libraries, classes and so on.
What an outdated approach. You should always statically link all boost and cef libraries at a minimum, and don't forget denuvo (it's not for games only!1!11!). If they can't handle it, they should buy new hardware.
a/b is offline  
Old 29 April 2023, 20:16   #4
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by thomas View Post
When the user chooses hide, you should close the window and ideally release all GUI-related resources.

The reason is that while the GUI is hidden, the user expects to be able to close the Workbench screen (for example for a screen mode change). This is not possible if you keep the window open and only hide it.

Also the new functions HideWindow and ShowWindow are only available in OS 3.2+. So if you don't want to reach only half or less of the community, you should avoid these functions.

While the GUI is hidden it should not consume any resources, so if possible you should close all external libraries, classes and so on.
@thomas thank you for answer - Yes that makes sense.
mateusz_s is offline  
Old 02 May 2023, 01:06   #5
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
I forgot to ask one more question.

The commodity has its own main loop that process messages in it.
If I want to create and show the window - its also need to have its own
message loop?

I am not sure how to combine that two loops?
Maybe you have some examples in C?

In my case - my commodity checks something each couple of seconds and stores the result.
But optionally I would also update that result in the window.
mateusz_s is offline  
Old 02 May 2023, 09:06   #6
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,026
You should build your program around one main loop with one Wait() instruction which waits for events from all parts of your app.

It could look like this:
Code:
BOOL cont = TRUE;

do	{
	ULONG winsig   = 1L << win->UserPort->mp_SigBit;
	ULONG timersig = 1L << timereq->tr_node.io_Message.mn_ReplyPort->mp_SigBit;
	ULONG cxsig    = 1L << cxport->mp_SigBit;

	ULONG sigs_received = Wait (winsig | timersig | cxsig | SIGBREAKF_CTRL_C);

	if (sigs_received & SIGBREAKF_CTRL_C)
		{
		cont = FALSE;
		}

	if (sigs_received & timersig)
		{
		WaitIO (timereq);
		...
		timereq->tr_node.io_Command = TR_ADDREQUEST;
		SendIO (timereq);
		}

	if (sigs_received & winsig)
		{
		struct IntuiMessage *imsg;
		while ((imsg = GetMsg (win->UserPort)))
			{
			switch (imsg->Class)
				{
				...
				}
			ReplyMsg (imsg);
			}
		}


	if (sigs_received & cxsig)
		{
		CxMsg *cxmsg;
		while ((cxmsg = GetMsg (cxport)))
			{
			switch (CxMsgType (cxmsg))
				{
				...
				}
			ReplyMsg (cxmsg);
			}
		}
	}
while (cont);

You can safely set one of the signals to 0 if that part of your app is currently not active.

For example if you change the code to

Code:
ULONG winsig   = (win != NULL ? 1L << win->UserPort->mp_SigBit : 0);
then the window handling code will not be executed if the window is closed. You only have to take care that you set the window pointer (win) to NULL when you close the window.

Last edited by thomas; 02 May 2023 at 09:14.
thomas is offline  
Old 02 May 2023, 14:25   #7
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by thomas View Post
You should build your program around one main loop with one Wait() instruction which waits for events from all parts of your app.

It could look like this:
Code:
BOOL cont = TRUE;

do	{
	ULONG winsig   = 1L << win->UserPort->mp_SigBit;
	ULONG timersig = 1L << timereq->tr_node.io_Message.mn_ReplyPort->mp_SigBit;
	ULONG cxsig    = 1L << cxport->mp_SigBit;

	ULONG sigs_received = Wait (winsig | timersig | cxsig | SIGBREAKF_CTRL_C);

	if (sigs_received & SIGBREAKF_CTRL_C)
		{
		cont = FALSE;
		}

	if (sigs_received & timersig)
		{
		WaitIO (timereq);
		...
		timereq->tr_node.io_Command = TR_ADDREQUEST;
		SendIO (timereq);
		}

	if (sigs_received & winsig)
		{
		struct IntuiMessage *imsg;
		while ((imsg = GetMsg (win->UserPort)))
			{
			switch (imsg->Class)
				{
				...
				}
			ReplyMsg (imsg);
			}
		}


	if (sigs_received & cxsig)
		{
		CxMsg *cxmsg;
		while ((cxmsg = GetMsg (cxport)))
			{
			switch (CxMsgType (cxmsg))
				{
				...
				}
			ReplyMsg (cxmsg);
			}
		}
	}
while (cont);

You can safely set one of the signals to 0 if that part of your app is currently not active.

For example if you change the code to

Code:
ULONG winsig   = (win != NULL ? 1L << win->UserPort->mp_SigBit : 0);
then the window handling code will not be executed if the window is closed. You only have to take care that you set the window pointer (win) to NULL when you close the window.
Great - many thanks @thomas again -
mateusz_s 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
[Commodity] Commodity that monitors status - code review request mateusz_s Coders. System 6 29 April 2023 03:17
Can this application be a Commodity? mateusz_s Coders. System 2 19 December 2021 01:54
Making a commodity - some questions peceha Coders. Blitz Basic 14 11 March 2018 18:41
Helpful commodity idrougge Coders. Blitz Basic 0 14 December 2015 19:51
Looking for Caps2Ctrl commodity kolla support.Apps 7 24 October 2009 17:14

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 11:44.

Top

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