_screen is only valid between show/hide.
[AROS.git] / rom / intuition / scrollwindowraster.c
blob6c2fa9670a1bccac857984e4ff1966ba89c75906
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <intuition/gadgetclass.h>
8 #include <proto/graphics.h>
9 #include <proto/layers.h>
10 #include <stdlib.h>
11 #include "intuition_intern.h"
12 #include "inputhandler.h"
13 #include "inputhandler_actions.h"
14 #include "inputhandler_support.h"
16 #ifdef __MORPHOS__
17 # include "mosmisc.h"
18 #endif
20 struct ScrollWindowRasterMsg
22 struct IntuiActionMsg msg;
23 struct Window *window;
26 static VOID int_scrollwindowraster(struct ScrollWindowRasterMsg *msg,
27 struct IntuitionBase *IntuitionBase);
29 /*****************************************************************************
31 NAME */
32 #include <proto/intuition.h>
34 AROS_LH7(void, ScrollWindowRaster,
36 /* SYNOPSIS */
37 AROS_LHA(struct Window *, win , A1),
38 AROS_LHA(WORD , dx , D0),
39 AROS_LHA(WORD , dy , D1),
40 AROS_LHA(WORD , xmin, D2),
41 AROS_LHA(WORD , ymin, D3),
42 AROS_LHA(WORD , xmax, D4),
43 AROS_LHA(WORD , ymax, D5),
45 /* LOCATION */
46 struct IntuitionBase *, IntuitionBase, 133, Intuition)
48 /* FUNCTION
49 Scrolls the content of the rectangle defined by (xmin,ymin)-
50 (xmax,ymax) by (dx,dy) towards (0,0). This function calls
51 ScrollRasterBF().
52 The advantage of this function over calling ScrollRasterBF() is
53 that the window will be informed about damages. A damage happens
54 if in a simple window parts from concelealed areas are scrolled
55 to visible areas. The visible areas will be blank as simple
56 windows store no data for concealed areas.
57 The blank parts that appear due to the scroll will be filled
58 with EraseRect() and are not considered damaged areas.
60 INPUTS
61 win - pointer to window in which to scroll
62 dx,dy - scroll by (dx,dy) towards (0,0)
63 xmin,ymin - upper left corner of the rectangle that will be
64 affected by the scroll
65 xmax,ymax - lower rigfht corner of the rectangle that will be
66 affected by the scroll
68 RESULT
70 NOTES
72 EXAMPLE
74 BUGS
76 SEE ALSO
78 INTERNALS
80 *****************************************************************************/
82 AROS_LIBFUNC_INIT
84 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
85 DEBUG_SCROLLWINDOWRASTER(dprintf("ScrollWindowRaster: window 0x%lx dx %d dy %d (%d,%d)-(%d,%d)\n",
86 win, dx, dy, xmin, ymin, xmax, ymax));
88 SANITY_CHECK(win)
90 #ifdef __MORPHOS__
91 LockLayers(&win->WScreen->LayerInfo);
92 #endif
94 ScrollRasterBF(win->RPort,
95 dx,
96 dy,
97 xmin,
98 ymin,
99 xmax,
100 ymax);
102 /* Has there been damage to the layer? */
103 if (WLAYER(win)->Flags & LAYERREFRESH)
106 Send a refresh message to the window if it doesn't already
107 have one.
110 struct ScrollWindowRasterMsg msg;
111 msg.window = win;
113 #ifdef DAMAGECACHE
114 RecordDamage(win->WScreen,IntuitionBase);
115 #endif
117 #ifdef __MORPHOS
118 UnlockLayers(&win->WScreen->LayerInfo);
119 #endif
121 DoASyncAction((APTR)int_scrollwindowraster, &msg.msg, sizeof(msg), IntuitionBase);
123 else
125 #ifdef __MORPHOS__
126 UnlockLayers(&win->WScreen->LayerInfo);
127 #endif
130 AROS_LIBFUNC_EXIT
131 } /* ScrollWindowRaster */
133 /*****************************************************************************
135 NAME */
136 #include <proto/intuition.h>
138 AROS_LH7(void, ScrollWindowRasterNoFill,
140 /* SYNOPSIS */
141 AROS_LHA(struct Window *, win , A1),
142 AROS_LHA(WORD , dx , D0),
143 AROS_LHA(WORD , dy , D1),
144 AROS_LHA(WORD , xmin, D2),
145 AROS_LHA(WORD , ymin, D3),
146 AROS_LHA(WORD , xmax, D4),
147 AROS_LHA(WORD , ymax, D5),
149 /* LOCATION */
150 struct IntuitionBase *, IntuitionBase, 159, Intuition)
152 /* FUNCTION
153 Scrolls the content of the rectangle defined by (xmin,ymin)-
154 (xmax,ymax) by (dx,dy) towards (0,0). This function calls
155 ScrollRasterBF().
156 The advantage of this function over calling ScrollRasterBF() is
157 that the window will be informed about damages. A damage happens
158 if in a simple window parts from concelealed areas are scrolled
159 to visible areas. The visible areas will be blank as simple
160 windows store no data for concealed areas.
161 The blank parts that appear due to the scroll will be filled
162 with EraseRect() and are not considered damaged areas.
164 INPUTS
165 win - pointer to window in which to scroll
166 dx,dy - scroll by (dx,dy) towards (0,0)
167 xmin,ymin - upper left corner of the rectangle that will be
168 affected by the scroll
169 xmax,ymax - lower rigfht corner of the rectangle that will be
170 affected by the scroll
172 RESULT
173 None.
175 NOTES
176 This function is compatible with MorphOS.
178 EXAMPLE
180 BUGS
182 SEE ALSO
184 INTERNALS
186 *****************************************************************************/
189 AROS_LIBFUNC_INIT
191 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
192 DEBUG_SCROLLWINDOWRASTER(dprintf("ScrollWindowRaster: window 0x%lx dx %d dy %d (%d,%d)-(%d,%d)\n",
193 win, dx, dy, xmin, ymin, xmax, ymax));
195 SANITY_CHECK(win)
197 #ifdef __MORPHOS__
198 LockLayers(&win->WScreen->LayerInfo);
199 #endif
202 WORD adx = abs(dx);
203 WORD ady = abs(dy);
204 WORD width = xmax - xmin + 1;
205 WORD height = ymax - ymin + 1;
206 BOOL scroll = TRUE;
208 if (adx<width && ady<height)
210 WORD cw = width - adx;
211 WORD ch = height - ady;
212 WORD x1 = xmin;
213 WORD x2 = xmin;
214 WORD y1 = ymin;
215 WORD y2 = ymin;
217 if (dx>=0) x1 += dx;
218 else x2 -= dx;
220 if (dy>=0) y1 += dy;
221 else y2 -= dy;
223 ClipBlit(win->RPort,x1,y1,win->RPort,x2,y2,cw,ch,0xc0);
226 if (!(WLAYER(win)->Flags & LAYERREFRESH))
228 struct Rectangle rect;
229 struct ClipRect *cr;
231 rect.MinX = WLAYER(win)->bounds.MinX + xmin;
232 rect.MinY = WLAYER(win)->bounds.MinY + ymin;
233 rect.MaxX = WLAYER(win)->bounds.MinX + xmax;
234 rect.MaxY = WLAYER(win)->bounds.MinY + ymax;
236 for (cr=WLAYER(win)->ClipRect;cr;cr=cr->Next)
238 if (rect.MinX < cr->bounds.MinX) continue;
239 if (rect.MaxX > cr->bounds.MaxX) continue;
240 if (rect.MinY < cr->bounds.MinY) continue;
241 if (rect.MaxY > cr->bounds.MaxY) continue;
242 scroll = FALSE;
243 break;
247 if (scroll)
249 ULONG mask = win->RPort->Mask;
250 win->RPort->Mask = 0;
251 ScrollRaster(win->RPort,dx,dy,xmin,ymin,xmax,ymax);
252 win->RPort->Mask = mask;
256 /* Has there been damage to the layer? */
257 if (WLAYER(win)->Flags & LAYERREFRESH)
260 Send a refresh message to the window if it doesn't already
261 have one.
264 struct ScrollWindowRasterMsg msg;
265 msg.window = win;
267 #ifdef DAMAGECACHE
268 RecordDamage(win->WScreen,IntuitionBase);
269 #endif
271 #ifdef __MORPHOS__
272 UnlockLayers(&win->WScreen->LayerInfo);
273 #endif
274 DoASyncAction((APTR)int_scrollwindowraster, &msg.msg, sizeof(msg), IntuitionBase);
276 else
278 #ifdef __MORPHOS__
279 UnlockLayers(&win->WScreen->LayerInfo);
280 #endif
283 AROS_LIBFUNC_EXIT
284 } /* ScrollWindowRaster */
286 static VOID int_scrollwindowraster(struct ScrollWindowRasterMsg *msg,
287 struct IntuitionBase *IntuitionBase)
289 struct LayersBase *LayersBase = GetPrivIBase(IntuitionBase)->LayersBase;
290 struct Window *window = msg->window;
292 LOCK_REFRESH(window->WScreen);
294 if (WLAYER(window)->Flags & LAYERREFRESH)
295 WindowNeedsRefresh(window, IntuitionBase);
297 UNLOCK_REFRESH(window->WScreen);