2 #include <proto/exec.h>
4 #include <proto/muimaster.h>
5 #include <proto/utility.h>
6 #include <proto/intuition.h>
7 #include <proto/graphics.h>
8 #include <clib/alib_protos.h>
13 #include <private/vapor/vapor.h>
14 #include "lay_class.h"
20 int n
; /* number of children */
21 int w
; /* width of children */
22 int h
; /* height of children */
23 int hs
; /* horiz spacing */
24 int vs
; /* vert spacing */
35 MUI_HOOK(layoutfunc
, APTR grp
, struct MUI_LayoutMsg
*lm
)
37 struct IClass
*cl
= (struct IClass
*)(h
->h_Data
);
38 struct Data
*data
= INST_DATA(cl
, grp
);
39 float vgpos
= (float)xget(grp
, MUIA_Virtgroup_Top
) / xget(grp
, MUIA_Virtgroup_Height
);
45 register Object
*child
;
47 unsigned int n
, done
= FALSE
;
49 // look for first visible child dimensions (reference)
51 for (n
= 0, cstate
= (Object
*)lm
->lm_Children
->mlh_Head
; (child
= NextObject(&cstate
)); n
++)
55 get(child
,MUIA_ShowMe
,&sm
);
60 data
->w
= _minwidth(child
);
61 data
->h
= _minheight(child
);
69 lm
->lm_MinMax
.MinWidth
= data
->w
;
70 lm
->lm_MinMax
.MinHeight
= data
->h
;
71 lm
->lm_MinMax
.DefWidth
= data
->w
;
72 lm
->lm_MinMax
.DefHeight
= data
->h
;
73 lm
->lm_MinMax
.MaxWidth
= MUI_MAXMAX
;
74 lm
->lm_MinMax
.MaxHeight
= MUI_MAXMAX
;
81 register Object
*child
;
83 int il
, it
, ir
, ib
, w
, h
, c
, r
, x
, y
, n
, nd
, wd
, hd
, hsd
, vsd
;
88 get(grp
, MUIA_InnerLeft
, &il
);
89 get(grp
, MUIA_InnerTop
, &it
);
90 get(grp
, MUIA_InnerRight
, &ir
);
91 get(grp
, MUIA_InnerBottom
, &ib
);
93 il
= it
= ir
= ib
= 0;
95 get(grp
, MUIA_Width
, &w
);
96 get(grp
, MUIA_Height
, &h
);
109 x
= il
+hsd
*(c
-1)+c
*wd
+ir
;
126 hborder
= ( w
- ( c
- 1 ) * hsd
- c
* wd
) / 2;
134 height
= it
+r
*hd
+vsd
*(r
-1)+ib
;
136 /* keep focus on same entry */
140 nfset(grp
, MUIA_Virtgroup_Top
, (int)(height
* vgpos
));
141 data
->keeppos
= FALSE
;
144 for (n
= 0, cstate
= (Object
*)lm
->lm_Children
->mlh_Head
; (child
= NextObject(&cstate
)); )
148 //get(child,MUIA_ShowMe,&sm);
151 if (!MUI_Layout(child
,x
+ hborder
,y
,wd
,hd
,0))
170 lm
->lm_Layout
.Width
= il
+c
*wd
+hsd
*(c
-1)+ir
;
171 lm
->lm_Layout
.Height
= height
;
174 data
->vertdist
= hd
+ vsd
;
175 data
->childcount
= count
;
181 return MUILM_UNKNOWN
;
186 obj
= DoSuperNew(cl
,obj
,
187 MUIA_Group_LayoutHook
, (ULONG
)&layoutfunc_hook
,
188 MUIA_CustomBackfill
, TRUE
,
189 MUIA_Group_SameSize
, TRUE
,
192 layoutfunc_hook
.h_Data
= cl
;
198 data
->hs
= GetTagData(MUIA_Lay_HorizSpacing
, 4, INITTAGS
);
199 data
->vs
= GetTagData(MUIA_Lay_VertSpacing
, 4, INITTAGS
);
200 data
->center
= GetTagData(MUIA_Lay_Center
, TRUE
, INITTAGS
);
208 void kprintf(char *fmt
, ...);
210 #define min(a,b) ((a)<(b)?(a):(b))
213 static void *buildregionfromicons(struct Data
*data
, Object
*obj
, int x1
, int y1
, int x2
, int y2
)
215 struct Region
*clipregion
= NewRegion();
217 if (clipregion
!= NULL
)
219 int vpos
= xget(obj
, MUIA_Virtgroup_Top
);
220 int vtop
= _top(obj
) + vpos
;
222 int columns
= data
->columns
;
224 int cwidth
= 0, cheight
= 0;
228 int count
= data
->childcount
;
230 void *first
= (void*)DoMethod(obj
, MUIM_Group_GetChild
, MUIV_Group_GetChild_First
);
238 OrRectRegion(clipregion
, &r
);
240 /* first child position */
244 ctop
= xget(first
, MUIA_TopEdge
) + vpos
;
245 cleft
= _left(first
);
246 cwidth
= _width(first
);
247 cheight
= _height(first
);
257 /* skip entries which are avobe top */
259 skip
= (vtop
- ctop
) / (data
->vertdist
);
260 ctop
+= skip
* data
->vertdist
;
261 count
-= columns
* skip
;
263 /* calculate number of remaining entries we need to process */
265 count
= min(count
, columns
* ( 1 + ceil((float)xget(obj
, MUIA_Height
) / data
->vertdist
)));
268 for(i
= 0; i
<count
; i
++)
272 ctop
+= data
->vertdist
;
273 cleft
= _left(first
);
278 r
.MinY
= ctop
- vpos
;
279 r
.MaxX
= r
.MinX
+ cwidth
- 1;
280 r
.MaxY
= ctop
+ cheight
- 1 - vpos
;
282 /* remove the area */
283 ClearRectRegion(clipregion
, &r
);
285 cleft
+= cwidth
+ data
->hs
;
295 struct RegionRectangle
*rr
= clipregion
->RegionRectangle
;
302 kprintf("Number of regions:%d for blit:%d,%d,%d,%d\n", i
, x1
, y1
, x2
, y2
);
314 APTR cliphandle
= NULL
;
315 struct Region
*clipregion
= NULL
;
317 if (msg
->bottom
< msg
->top
)
319 if (msg
->right
< msg
->left
)
323 if (muiRenderInfo(obj
) != NULL
&& (data
->width
!= _width(obj
) || data
->height
!= _height(obj
) || (msg
->right
- msg
->left
+ 1 == _mwidth(obj
) && msg
->bottom
- msg
->top
+ 1 == _mheight(obj
)) ))
326 * Iterate through thumbs and mask them from backfill.
329 data
->width
= _width(obj
);
330 data
->height
= _height(obj
);
331 clipregion
= buildregionfromicons(data
, obj
, msg
->left
, msg
->top
, msg
->right
, msg
->bottom
);
333 if (clipregion
!= NULL
)
335 cliphandle
= MUI_AddClipRegion(muiRenderInfo(obj
), clipregion
);
343 if (clipregion
!= NULL
)
345 MUI_RemoveClipRegion(muiRenderInfo(obj
), cliphandle
); /* DisposeRegion() is done by MUI */
358 case MUIA_Lay_KeepPosition
:
359 data
->keeppos
= tag
->ti_Data
;
373 DECSUBCLASS_NC(MUIC_Virtgroup
, LayClass
)