Picasso96 PIP windows

This forum is for general developer support questions.
Post Reply
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Picasso96 PIP windows

Post by softwarefailure »

Is there a way to create PIP windows which are automatically moved when their "parent" is moved? I want to create a borderless PIP window that is part of a parent window. Whenever the user moves this parent window, the PIP window should be moved as well. Is there a convenient way to achieve this or do I have to move the PIP window manually whenever I get an IDCMP_CHANGEWINDOW message for the parent? But this would probably a very ugly solution...
User avatar
samo79
Posts: 582
Joined: Sat Jun 18, 2011 12:13 am
Location: Italy

Re: Picasso96 PIP windows

Post by samo79 »

Just for fun i've asked ChatGPT and here is the answer:

1. The "Parenting" Problem

In the classic AmigaOS API, windows are independent. Even if you use the RTG extensions for PIP, the system doesn't know that the video window "belongs" to the GUI window. If you move the parent window, the coordinate of the PIP overlay remains fixed relative to the screen (or the graphics card bitmap).

2. The solution (the only possible one)

You actually have to manually manage the movement, but there are ways to make it less "ugly":

IDCMP_CHANGEWINDOW: This is the correct event to monitor. Every time the main window is moved, you must recalculate the PIP coordinates and call the PIP layer update function (usually via driver-specific functions or p96PIP_SetAttrs).

Silent Refresh: Although it may seem inelegant, if the code is optimized and the JIT (Petunia) or native PPC code is fast, the movement appears smooth. The visual "delay" between the window and the video is minimal on Radeon 9xxx cards.

In summary for your case (Radeon 9xxx):
Yes, you must manually handle the IDCMP_CHANGEWINDOW message.
To minimize the "jerking" effect, be sure to:
Disable hard GUI refresh during navigation.
Update the PIP coordinates at the exact moment you receive the position change message.

Here's a conceptual example in C for AmigaOS 4.1. Since the system doesn't offer automatic parenting for PIP (Picture-in-Picture) layers on Radeon 9xxx, the only way is to intercept the main window's move event and update the PIP coordinates accordingly.

The example assumes you're using the Picasso96 (P96) API, which handles PIP on OS4

-----
#include <proto/intuition.h>
#include <proto/p96.h>
#include <libraries/p96.h>

/* Supponiamo che tu abbia già aperto la finestra 'mainWin'
e creato l'oggetto PIP 'pipObj' */

struct Window *mainWin;
struct P96PIP *pipObj; // Oggetto PIP creato con p96PIP_OpenTagList

void HandleEvents() {
struct IntuiMessage *msg;
uint32 sigMask = (1L << mainWin->UserPort->mp_SigBit);
BOOL running = TRUE;

while (running) {
Wait(sigMask);

while ((msg = (struct IntuiMessage *)GetMsg(mainWin->UserPort))) {
uint32 class = msg->Class;

switch (class) {
case IDCMP_CLOSEWINDOW:
running = FALSE;
break;

case IDCMP_CHANGEWINDOW:
case IDCMP_MOUSEMOVE:
/*
Quando la finestra genitore si muove, ricalcoliamo
la posizione del PIP basandoci sulle nuove coordinate
LeftEdge e TopEdge della finestra.
*/
if (pipObj) {
// Offset relativo (es: il video sta a 10px dal bordo)
int32 newX = mainWin->LeftEdge + 10;
int32 newY = mainWin->TopEdge + 20;

// Aggiorna la posizione del layer PIP in tempo reale
p96PIP_SetAttrs(pipObj,
P96PIP_Left, newX,
P96PIP_Top, newY,
TAG_DONE);
}
break;
}
ReplyMsg((struct Message *)msg);
}
}
}

-----

Implementation Key Points:

IDCMP_CHANGEWINDOW: This is the fundamental signal. It is sent when the user releases the window or during movement (if opaque drag is active).

p96PIP_SetAttrs: This function is very efficient. On a Radeon 9250 with AmigaOS 4.1, moving the hardware overlay is almost instantaneous.

Relative Coordinates: The PIP lives in screen space (Screen coordinates), while your GUI lives inside the window. You should always add mainWin->LeftEdge and mainWin->TopEdge to maintain alignment.

Synchronization: If you notice lag (the video follows the window with a delay), make sure your window has the WFLG_REPORTMOUSE flag enabled to receive more frequent updates during dragging.
Post Reply