just kick off another build
[moon.git] / src / layoutinformation.cpp
blob4d3d70c9589b91619a4e7e18fd4a0efe2d733e17
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * layoutinformation.cpp
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
10 #include "frameworkelement.h"
11 #include "geometry.h"
12 #include "rect.h"
13 #include "point.h"
15 Geometry *
16 LayoutInformation::GetClip (FrameworkElement *item)
18 FrameworkElement *element = item;
19 Point offset = Point (0,0);
20 Rect composite (0,0,INFINITY, INFINITY);
22 while (element) {
23 Point *local_offset = GetVisualOffset (element);
25 if (!local_offset)
26 break;
28 Rect relative = *GetLayoutSlot (element);
29 offset = offset + *local_offset;
30 relative.x -= offset.x;
31 relative.y -= offset.y;
32 relative = relative.GrowBy (-*element->GetMargin ());
34 composite = composite.Intersection (relative);
36 if (element != item)
37 break;
39 element = (FrameworkElement *)element->GetVisualParent ();
41 if (element && (element->Is (Type::CANVAS) || element->Is (Type::USERCONTROL)))
42 break;
45 if (isinf (composite.width))
46 return NULL;
48 RectangleGeometry *geom = new RectangleGeometry ();
49 geom->SetRect (&composite);
51 return geom;