English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 29 July 2023, 11:18   #1
Wrangler
Registered User
 
Join Date: Sep 2015
Location: London, UK
Posts: 419
Clearing a window under AmigaOS

A real noob question but what is the easiest (and quickest if that is different) to clear a window under AmigaOS?

Situation is that I've opened a window with OpenWindowTags, which includes some gadgets. I've used the window and now I want to clear the contents.

Code:
SetRast(win->RPort,0);
clears the window contents and the gadgets but I want to preserve them

I can't find a command like:
Code:
ClearWindow(win);
Wrangler is offline  
Old 29 July 2023, 12:43   #2
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,643
Easiest is probably to clear the bitmap contents (e.g. with SetRast), then refresh/redraw the gadgets - intuition/gadtools has functions for this.
hooverphonique is offline  
Old 29 July 2023, 13:18   #3
Wrangler
Registered User
 
Join Date: Sep 2015
Location: London, UK
Posts: 419
That works, but only up a point - the gadgets are refreshed but not the window borders. Anyway to refresh them too?

(I'm only using system gadgets and RefreshGadgets)
Wrangler is offline  
Old 29 July 2023, 13:28   #4
No.3
Registered User
 
Join Date: Sep 2022
Location: Switzerland
Posts: 120
RectFill is your friend.
No.3 is offline  
Old 29 July 2023, 13:45   #5
Wrangler
Registered User
 
Join Date: Sep 2015
Location: London, UK
Posts: 419
Awesome, that does it!
Wrangler is offline  
Old 29 July 2023, 20:23   #6
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,319
Quote:
Originally Posted by Wrangler View Post
A real noob question but what is the easiest (and quickest if that is different) to clear a window under AmigaOS?
You find the border sizes in the window structure, and you also find the window size there. So subtract border sizes from the window to get the dimension of the rectangle to fill, and add the size of the top and left border. Then perform a RectFill().


Alternatively, use a GIMMEZEROZERO window, and then the interior of the window has a separate layer, and you can use SetRast.


Yet alternatively, install a cliprect to the window rast port that clips to the interior window area, then use SetRast.
Thomas Richter is offline  
Old 30 July 2023, 16:16   #7
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 537
Quote:
Originally Posted by Thomas Richter View Post
Alternatively, use a GIMMEZEROZERO window, and then the interior of the window has a separate layer, and you can use SetRast.
I reckon that this aspect is what gave this feature its name. The operating system documentation always states its name, but never how it got its name.

By default the window border elements and the portion inside the border share the same rendering surface (the Window->RastPort). Which means that you need your own code to watch where it plays and what it is permitted to paint over.

You need to offset your rendering origin by the size of the left and top borders, and the size of the rendering area is also reduced by the size of the right and bottom borders. This means that the rendering origin coordinates are no longer at (0, 0) but might be a (10, 5), for example.

If you request a GIMMEZEROZERO window, rendering into Window->RastPort always starts at the (0, 0) origin (literally zero zero) and its area you render into is always clipped so that it never overwrites the window border area.

There are plenty of reasons to use an alternative to the GIMMEZEROZERO option because it makes rendering inside Intuition a lot more complex than it has any right to. The 3rd edition "RKM Libraries" even covers the many options you have if you do not want to use a GIMMEZEROZERO window.
Olaf Barthel is offline  
Old 30 July 2023, 17:54   #8
aros-sg
Registered User
 
Join Date: Nov 2015
Location: Italy
Posts: 192
Quote:
Originally Posted by Thomas Richter View Post
Yet alternatively, install a cliprect to the window rast port that clips to the interior window area, then use SetRast.
Only AROS can do that (*). Everything else can only install clipregion into layer, not rastport as well. And even if you do that you usually have the problem of async Intutition window resizing so you still can end up rendering into window border and then need to refresh the window frame to make sure that the "trash" is repaired.

For the origin thing one can (ab)use layer's Scroll_x, Scroll_y.

(*) Can install one additional cliprect (not region) into rastport where right/bottom of the cliprect can be relative to the layer size.
aros-sg is offline  
Old 31 July 2023, 13:03   #9
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,319
Quote:
Originally Posted by aros-sg View Post
Only AROS can do that (*).
No, that's really one of the easiest exercises in graphics and layers. I really wonder why GZZ windows are realized in such a complicated way, they even create a lot more overhead when moving - after all two layers have to be moved.
Thomas Richter is offline  
Old 31 July 2023, 19:47   #10
aros-sg
Registered User
 
Join Date: Nov 2015
Location: Italy
Posts: 192
Quote:
Originally Posted by Thomas Richter View Post
No, ...

So you added this? RPTAG_DrawBounds? In standard/old AOS 3.1 it's a get-only attribute.


Quote:
I really wonder why GZZ windows are realized in such a complicated way.
Yes, can be done with one additional AndRectRect() and some coordinate shifting when traversing cliprects.
aros-sg is offline  
Old 31 July 2023, 20:03   #11
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,319
Quote:
Originally Posted by aros-sg View Post
So you added this? RPTAG_DrawBounds? In standard/old AOS 3.1 it's a get-only attribute.
There is absolutely nothing to add. Everything you need for this functionality is already there. Create a new region, add a rectangle that describes the inner area of the window, or the region to the rectangle, then call InstallClipRegion(), then adjust the scroll offset of the window rastport. There is nothing "new" required.



Quote:
Originally Posted by aros-sg View Post

Yes, can be done with one additional AndRectRect() and some coordinate shifting when traversing cliprects.
Again, all the functionality to clip to window internals is already there, and it works perfectly fine with the existing intuition system.
Thomas Richter is offline  
Old 31 July 2023, 20:11   #12
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,319
Here is a little bit of code how to do that. To make things a little bit more entertaining, it is this time in Pascal. The WindowInfo structure is something internal in this little project, just disregard, it is only for housekeeping.

Code:
PROCEDURE InstallOffset(w : WindowPtr; x,y : SHORT);
VAR
        winfo   :       WindowInfoPtr;
BEGIN
        winfo:=InfoOf_W(w);

        WITH w^.WLayer^ DO BEGIN
                Scroll_X:=-x;
                Scroll_Y:=-y;
        END;
        WITH winfo^ DO BEGIN
                Offset_X:=x;
                Offset_Y:=y;
        END;
END;

PROCEDURE InstallClip(w : WindowPtr; x1,y1,x2,y2 : SHORT);
VAR
        region  :       RegionPtr;
        winfo   :       WindowInfoPtr;
BEGIN

        winfo:=InfoOf_W(w);
        region:=NewRegion();
        IF region=NIL THEN
                failexit("Unable to create new clip region");

        SortCoords(x1,y1,x2,y2);
        WITH rectptr^ DO BEGIN
                MinX:=x1;
                MinY:=y1;
                MaxX:=x2;
                MaxY:=y2;
        END;

        IF NOT OrRectRegion(region,rectptr) THEN
                failexit("Unable to create clip recangle");

        winfo^.ClipRegion:=region;
        region:=InstallClipRegion(w^.WLayer,region);
        IF region<>NIL THEN
                DisposeRegion(region);

END;

PROCEDURE InstallStdClip(w : WindowPtr);
VAR
        xmin,ymin       :       SHORT;
        xmax,ymax       :       SHORT;
BEGIN
        Forbid;
        WITH w^ DO BEGIN
                xmin    :=      BorderLeft;
                ymin    :=      BorderTop;
                xmax    :=      Width-1-BorderRight;
                ymax    :=      Height-1-BorderBottom;
        END;
        Permit;

        InstallClip(w,xmin,ymin,xmax,ymax);
        InstallOffset(w,xmin,ymin);

END;
Thomas Richter is offline  
Old 31 July 2023, 20:48   #13
aros-sg
Registered User
 
Join Date: Nov 2015
Location: Italy
Posts: 192
Quote:
Originally Posted by Thomas Richter View Post
all the functionality to clip to window internals is already there, and it works perfectly fine with the existing intuition system.

No, you cannot get 100 % gzz like behaviour with InstallClipRegion() alone, because of async resizing of windows, as said. Program can still end up rendering into window border, without further "hacks" like trying to prevent window size change during rendering with LockLayerInfo() which can cause other unwanted behaviour/side effects.


A clip region installed into a layer (not rastport as you said, that's why I said "only AROS can do that", where "that" is "installing a cliprect into a rastport") contains only cliprects with absolute coordinates, nothing relative to layer width/height which "only AROS can do" because in addition to the standard "install clipregion into layer" functionality has - as said - functionality to install additonal cliprect into a rastport where cliprect coordinates can be relative to layer width/height.
aros-sg 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
vbcc bss clearing issue dalton Coders. C/C++ 3 02 December 2017 22:50
Clearing the X-bit oRBIT Coders. Asm / Hardware 6 22 April 2012 02:52
Clearing out some spares on Amibay! fitzsteve MarketPlace 7 10 January 2012 16:59
Clearing out classic system Stokey MarketPlace 6 09 January 2010 22:34
Clearing A1200 + 500+ ericmark MarketPlace 11 27 May 2009 00:50

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

Top

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