AGI Components with Insight3D Alpha 2008 r8
Panel Overlay

Panel overlays are used to form hierarchies of overlays, which is useful for creating UI elements, such as toolbars. The panel overlay supports the full range of methods and properties provided by the IAgGxOverlay interface. For a general introduction to overlays, see the texture overlay overview.

Topic Description
Basics Adding overlays to a panel overlay is analogous to adding an overlay to the overlay manager.
Padding Padding sets positional offsets for child overlays from their parents edges.
Clipping When part of a child overlay is positioned outside the edges of its parent, it is clipped during rendering.
Basics

Panel overlays are overlays that can contain other overlays. Like the overlay manager, panel overlays provide an interface for adding, removing, and changing the z-order of contained overlays. The overlay manager can be thought of as a panel overlay who's size and location is tied to the screen. When adding an overlay to a panel overlay, the sizing and positioning of the child overlay is always relative to its parent. A panel overlay can also be assigned a texture with the BackgroundTexture property. The following example adds a texture overlay to a panel overlay's collection, and then adds that panel to another panel.

CopyC#
IAgGxOverlayPanel overlayPanel = new AgGxOverlayPanel();
overlayPanel.Initialize(200, AgGxUnit.UnitPixels, 200, AgGxUnit.UnitPixels);
overlayPanel.Position.Set(10, 10);
overlayPanel.Anchor = AgGxAnchorStyle.AnchorStyleTopRight;
overlayPanel.Color = (uint)System.Drawing.ColorTranslator.ToOle(
   System.Drawing.Color.LightSteelBlue);
overlayPanel.BorderSize = 1;

IAgGxOverlayPanel childPanel = new AgGxOverlayPanel();
childPanel.Initialize(.5, AgGxUnit.UnitFraction, .5, AgGxUnit.UnitFraction);
childPanel.Anchor = AgGxAnchorStyle.AnchorStyleCenter;
childPanel.Color = (uint)System.Drawing.ColorTranslator.ToOle(
   System.Drawing.Color.SteelBlue);
childPanel.BorderSize = 1;

IAgGxOverlayTexture childPanelChild = new AgGxOverlayTexture();
childPanelChild.Initialize(.5, AgGxUnit.UnitFraction, .5, AgGxUnit.UnitFraction);
childPanelChild.Anchor = AgGxAnchorStyle.AnchorStyleBottomRight;
childPanelChild.Color = (uint)System.Drawing.ColorTranslator.ToOle(
   System.Drawing.Color.Green);
childPanelChild.BorderSize = 1;

childPanel.Overlays.Add(childPanelChild);
overlayPanel.Overlays.Add(childPanel);
sceneManager.Overlays.Add(overlayPanel);

When an overlay is added to an overlay collection, its Parent property returns the overlay panel that contains it, or, if the overlay was added to the overlay manager, the manager is returned by the Parent property. The IAgGxOverlayContainer interface is implemented by both the overlay manager and overlay panels, and can be cast to the appropriate interface, as seen below.

CopyC#
IAgGxOverlayPanel overlayPanel = new AgGxOverlayPanel();
overlayPanel.Initialize(200, AgGxUnit.UnitPixels, 200, AgGxUnit.UnitPixels);
IAgGxOverlayTexture childOverlay = new AgGxOverlayTexture();
childOverlay.Initialize(.5, AgGxUnit.UnitFraction, .5, AgGxUnit.UnitFraction);

overlayPanel.Overlays.Add(childOverlay);
sceneManager.Overlays.Add(overlayPanel);

IAgGxOverlayPanel panel = childOverlay.Parent as IAgGxOverlayPanel;
IAgGxOverlayManager manager = panel.Parent as IAgGxOverlayManager;
Padding

Like the overlay manager, panel overlays have a Padding property which specifies how child overlays will be offset from the bounds of the parent when being positioned. In the example below, a 10 pixel padding is applied to each edge of the manager and panel overlay.

CopyC#
sceneManager.Overlays.Padding.Set(10, 10, 10, 10);

IAgGxOverlayPanel overlayPanel = new AgGxOverlayPanel();
overlayPanel.Initialize(200, AgGxUnit.UnitPixels, 200, AgGxUnit.UnitPixels);
overlayPanel.Padding.Set(10, 10, 10, 10);
overlayPanel.Color = (uint)System.Drawing.ColorTranslator.ToOle(
   System.Drawing.Color.LightSteelBlue);
overlayPanel.BorderSize = 1;

IAgGxOverlayTexture overlayPanelChild = new AgGxOverlayTexture();
overlayPanelChild.Initialize(1, AgGxUnit.UnitFraction, 1, AgGxUnit.UnitFraction);
overlayPanelChild.Color = (uint)System.Drawing.ColorTranslator.ToOle(
   System.Drawing.Color.Green);
overlayPanelChild.Anchor = AgGxAnchorStyle.AnchorStyleTopRight;
overlayPanelChild.BorderSize = 1;

overlayPanel.Overlays.Add(overlayPanelChild);
sceneManager.Overlays.Add(overlayPanel);

Clipping

If an overlay panel contains an overlay which is positioned and sized in such a way that it extends past the bounds of the parent, the extruding portions of the child overlay will be clipped during rendering.

CopyC#
IAgGxOverlayTexture secondChildOverlay = new AgGxOverlayTexture();
secondChildOverlay.Initialize(128, AgGxUnit.UnitPixels, 128, AgGxUnit.UnitPixels);
secondChildOverlay.Anchor = AgGxAnchorStyle.AnchorStyleTopRight;
secondChildOverlay.SetTranslation(-36, -18);
secondChildOverlay.Texture = Texture2D;

To prevent clipping on a child overlay, set the overlay's ClippingEnabled property to false, as seen in the example below.

CopyC#
IAgGxOverlayTexture secondChildOverlay = new AgGxOverlayTexture();
secondChildOverlay.Initialize(128, AgGxUnit.UnitPixels, 128, AgGxUnit.UnitPixels);
secondChildOverlay.Anchor = AgGxAnchorStyle.AnchorStyleTopRight;
secondChildOverlay.SetTranslation(-36, -18);
secondChildOverlay.ClippingEnabled = false;
secondChildOverlay.Texture = Texture2D;