29 July 2023, 11:18 | #1 |
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); I can't find a command like: Code:
ClearWindow(win); |
29 July 2023, 12:43 | #2 |
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.
|
29 July 2023, 13:18 | #3 |
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) |
29 July 2023, 13:28 | #4 |
Registered User
Join Date: Sep 2022
Location: Switzerland
Posts: 120
|
RectFill is your friend.
|
29 July 2023, 13:45 | #5 |
Registered User
Join Date: Sep 2015
Location: London, UK
Posts: 419
|
Awesome, that does it!
|
29 July 2023, 20:23 | #6 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,319
|
Quote:
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. |
|
30 July 2023, 16:16 | #7 | |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 537
|
Quote:
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. |
|
30 July 2023, 17:54 | #8 | |
Registered User
Join Date: Nov 2015
Location: Italy
Posts: 192
|
Quote:
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. |
|
31 July 2023, 13:03 | #9 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,319
|
|
31 July 2023, 19:47 | #10 | |
Registered User
Join Date: Nov 2015
Location: Italy
Posts: 192
|
So you added this? RPTAG_DrawBounds? In standard/old AOS 3.1 it's a get-only attribute. Quote:
|
|
31 July 2023, 20:03 | #11 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,319
|
Quote:
Again, all the functionality to clip to window internals is already there, and it works perfectly fine with the existing intuition system. |
|
31 July 2023, 20:11 | #12 |
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; |
31 July 2023, 20:48 | #13 | |
Registered User
Join Date: Nov 2015
Location: Italy
Posts: 192
|
Quote:
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. |
|
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 |
|
|