private static void UpdateAbsBottom(GLControl control, GLControl parent) { control.absBottom = parent.absBottom + control.bottom; foreach (var item in control.Children) { UpdateAbsBottom(item, control); } }
private static void UpdateAbsLeft(GLControl control, GLControl parent) { control.absLeft = parent.absLeft + control.left; foreach (var item in control.Children) { UpdateAbsLeft(item, control); } }
void winCanvas_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { GUIMouseEventArgs args = e.Translate(); if (this.mouseDownControl != null) { this.mouseDownControl.InvokeEvent(EventType.MouseUp, args); this.mouseDownControl = null; } }
/// <summary> /// /// </summary> /// <param name="control"></param> public override void Render(GLControl control) { var ctrl = control as CtrlImage; if (ctrl != null) { GL.Instance.Scissor(ctrl.Left, ctrl.Bottom, ctrl.Width, ctrl.Height); GL.Instance.Viewport(ctrl.Left, ctrl.Bottom, ctrl.Width, ctrl.Height); this.RenderUnit.Methods[0].Render(); } }
void winCanvas_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { int x = e.X, y = this.BindingCanvas.Height - e.Y - 1; GLControl control = GetControlAt(x, y, this); this.currentControl = control; if (control != null) { GLMouseEventArgs args = e.Translate(); control.InvokeEvent(EventType.MouseDown, args); } }
private static void Layout(GLControl control) { if (control != null) { control.Layout(); foreach (var item in control.Children) { GUILayoutAction.Layout(item); } } }
/// <summary> /// Update absolution location for <paramref name="control"/> and its children. /// </summary> /// <param name="control"></param> /// <param name="parent"><paramref name="control"/>'s parent.</param> internal static void UpdateAbsLocation(GLControl control, GLControl parent) { { control.absLeft = parent.absLeft + control.left; control.absBottom = parent.absBottom + control.bottom; } foreach (var child in control.Children) { UpdateAbsLocation(child, control); } }
private static void LayoutAfterXChanged(GLControl parent, GLControl control) { GUIAnchorStyles anchor = control.Anchor; if ((anchor & rightAnchor) == rightAnchor) { control.Width = parent.width - control.left - control.right; } else { control.right = parent.width - control.left - control.width; } }
private static void LayoutAfterYChanged(GLControl parent, GLControl control) { GUIAnchorStyles anchor = control.Anchor; if ((anchor & topAnchor) == topAnchor) { control.Height = parent.height - control.bottom - control.top; } else { control.top = parent.height - control.bottom - control.height; } }
/// <summary> /// /// </summary> /// <param name="control"></param> public override void Render(GLControl control) { var ctrl = control as CtrlImage; if (ctrl != null) { ctrl.Scissor(); ctrl.Viewport(); RenderMethod method = this.RenderUnit.Methods[0]; method.Render(); } }
void winCanvas_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { GUIMouseEventArgs args = e.Translate(); foreach (var item in this.Children) { int x = e.X, y = this.BindingCanvas.Height - e.Y; if (item.ContainsPoint(x, y)) { this.mouseDownControl = item; item.InvokeEvent(EventType.MouseDown, args); } } }
/// <summary> /// Layout for this control. /// </summary> public virtual void UpdateAbsoluteLocation() { GLControl parent = this.Parent; if (parent != null) { this.absLeft = parent.absLeft + this.x; this.absBottom = parent.absBottom + this.y; } else { this.absLeft = this.x; this.absBottom = this.y; } }
/// <summary> /// Layout for this control. /// </summary> public virtual void Layout() { GLControl parent = this.Parent; if (parent != null) { this.absLeft = parent.Left + this.Left; this.absBottom = parent.Bottom + this.Bottom; } else { this.absLeft = this.Left; this.absBottom = this.Bottom; } }
private static void Render(GLControl control) { if (control != null) { GLControlRendererBase renderer = control.Renderer; if (renderer != null) { renderer.Render(control); } foreach (var item in control.Children) { GUIRenderAction.Render(item); } } }
internal static void LayoutAfterAddChild(GLControl control, GLControl parent) { GUIAnchorStyles anchor = control.Anchor; if ((anchor & leftRightAnchor) == leftRightAnchor) { control.Width = parent.width - control.left - control.right; } else if ((anchor & leftAnchor) == leftAnchor) { control.right = parent.width - control.left - control.width; } else if ((anchor & rightAnchor) == rightAnchor) { control.left = parent.width - control.width - control.right; } else // if ((anchor & noneAnchor) == nonAnchor) { int diff = parent.width - control.left - control.width - control.right; int halfDiff = diff / 2; int otherHalfDiff = diff - halfDiff; control.left += halfDiff; control.right += otherHalfDiff; } if ((anchor & bottomTopAnchor) == bottomTopAnchor) { control.Height = parent.height - control.bottom - control.top; } else if ((anchor & bottomAnchor) == bottomAnchor) { control.top = parent.height - control.bottom - control.height; } else if ((anchor & topAnchor) == topAnchor) { control.bottom = parent.height - control.height - control.top; } else // if ((anchor & noneAnchor) == nonAnchor) { int diff = parent.height - control.bottom - control.height - control.top; int halfDiff = diff / 2; int otherHalfDiff = diff - halfDiff; control.bottom += halfDiff; control.top += otherHalfDiff; } }
private static void LayoutAfterWidthChanged(GLControl parent, GLControlChildren glControlChildren) { foreach (var control in glControlChildren) { if (control.parent != parent) { throw new Exception("Parent info not matching!"); } GUIAnchorStyles anchor = control.Anchor; if ((anchor & leftRightAnchor) == leftRightAnchor) { control.Width = parent.width - control.left - control.right; } else if ((anchor & leftAnchor) == leftAnchor) { control.right = parent.width - control.left - control.width; } else if ((anchor & rightAnchor) == rightAnchor) { control.left = parent.width - control.right - control.width; control.absLeft = parent.absLeft + control.left; foreach (var item in control.Children) { UpdateAbsLeft(control, item); } } else // if ((anchor & noneAnchor) == noneAnchor) { int diff = parent.width - control.left - control.width - control.right; int halfDiff = diff / 2; int OtherHalfDiff = diff - halfDiff; control.left += halfDiff; control.absLeft = parent.absLeft + control.left; control.right += OtherHalfDiff; foreach (var item in control.Children) { UpdateAbsLeft(control, item); } } } }
private static void LayoutAfterHeightChanged(GLControl parent, GLControlChildren glControlChildren) { foreach (var control in glControlChildren) { GUIAnchorStyles anchor = control.Anchor; if ((anchor & bottomTopAnchor) == bottomTopAnchor) { control.Height = parent.height - control.bottom - control.top; } else if ((anchor & bottomAnchor) == bottomAnchor) { control.top = parent.height - control.bottom - control.height; } else if ((anchor & topAnchor) == topAnchor) { control.bottom = parent.height - control.top - control.height; control.absBottom = parent.absBottom + control.bottom; foreach (var item in control.Children) { UpdateAbsBottom(control, item); } } else // if ((anchor & noneAnchor) == noneAnchor) { int diff = parent.height - control.top - control.height - control.bottom; int halfDiff = diff / 2; int OtherHalfDiff = diff - halfDiff; control.bottom += halfDiff; control.absBottom = parent.absBottom + control.bottom; control.top += OtherHalfDiff; foreach (var item in control.Children) { UpdateAbsBottom(control, item); } } } }
/// <summary> /// Get the control at specified position. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="control"></param> /// <returns></returns> private GLControl GetControlAt(int x, int y, GLControl control) { GLControl result = null; if (control.ContainsPoint(x, y)) { if (control.AcceptPicking) { result = control; } foreach (var item in control.Children) { GLControl child = GetControlAt(x, y, item); if (child != null) { result = child; break; } } } return(result); }
/// <summary> /// Updates <paramref name="currentNode"/>'s location and size according to its state and parent's information. /// </summary> /// <param name="currentNode"></param> /// <param name="parent"></param> private static void NonRootNodeLayout(GLControl currentNode, GLControl parent) { int x, y, width, height; if ((currentNode.Anchor & leftRightAnchor) == leftRightAnchor) { width = parent.width - currentNode.parentLastWidth + currentNode.width; if (width < 0) { width = 0; } } else { width = currentNode.width; } if ((currentNode.Anchor & topBottomAnchor) == topBottomAnchor) { height = parent.height - currentNode.parentLastHeight + currentNode.height; if (height < 0) { height = 0; } } else { height = currentNode.height; } if ((currentNode.Anchor & leftRightAnchor) == GUIAnchorStyles.None) { int diff = parent.width - currentNode.parentLastWidth; x = currentNode.x + diff / 2; } else if ((currentNode.Anchor & leftRightAnchor) == GUIAnchorStyles.Left) { x = currentNode.x; } else if ((currentNode.Anchor & leftRightAnchor) == GUIAnchorStyles.Right) { int diff = parent.width - currentNode.parentLastWidth; x = currentNode.x + diff; } else if ((currentNode.Anchor & leftRightAnchor) == leftRightAnchor) { x = currentNode.x; } else { throw new Exception(string.Format("Not expected Anchor:[{0}]!", currentNode.Anchor)); } if ((currentNode.Anchor & topBottomAnchor) == GUIAnchorStyles.None) { int diff = parent.height - currentNode.parentLastHeight; y = currentNode.y + diff / 2; } else if ((currentNode.Anchor & topBottomAnchor) == GUIAnchorStyles.Bottom) { y = currentNode.y; } else if ((currentNode.Anchor & topBottomAnchor) == GUIAnchorStyles.Top) { int diff = parent.height - currentNode.parentLastHeight; y = currentNode.y + diff; } else if ((currentNode.Anchor & topBottomAnchor) == topBottomAnchor) { y = currentNode.y; } else { throw new Exception(string.Format("Not expected Anchor:[{0}]!", currentNode.Anchor)); } currentNode.x = x; currentNode.y = y; currentNode.width = width; currentNode.height = height; }
/// <summary> /// /// </summary> /// <param name="param"></param> public override void Act(ActionParams param) { GLControl.Layout(this.Scene.RootControl); }
/// <summary> /// /// </summary> public override void Act() { GLControl.Layout(this.Scene.RootControl); }
/// <summary> /// Render <see cref="GLControl"/> objects. /// </summary> /// <param name="rootControl"></param> /// <param name="camera"></param> public GUIRenderAction(GLControl rootControl) { this.rootControl = rootControl; }
/// <summary> /// Render <see cref="GLControl"/> objects. /// </summary> /// <param name="rootControl"></param> public GUILayoutAction(GLControl rootControl) { this.rootControl = rootControl; }
/// <summary> /// /// </summary> /// <param name="control"></param> public abstract void Render(GLControl control);