public void Parse(CompileContext context, Stack<Token> stream) { Token token = stream.Pop(); if (token.TokenId != TokenId.LeftBracket) { stream.Push(token); throw new ParseException("Expected '(' to begin vector."); } // We parse first scalar. ASTScalar scalar1 = new ASTScalar(), scalar2 = new ASTScalar(); scalar1.Parse(context, stream); // We expect comma. token = stream.Pop(); if (token.TokenId != TokenId.Comma) { stream.Push(token); throw new ParseException("Expected ',' seperating two scalars."); } // We parse the second. scalar2.Parse(context, stream); // We need right bracket. token = stream.Pop(); if (token.TokenId != TokenId.RightBracket) { stream.Push(token); throw new ParseException("Expecting ')' to end vector."); } // We apply them. data = new GuiVector2(scalar1.Scalar, scalar2.Scalar); }
/// <summary> /// Constructor with preferred size. /// </summary> /// <param name="preferredSize"></param> public Area(GuiVector2 preferredSize, GuiVector2 minSize, GuiVector2 maxSize, Style style) : this(preferredSize, minSize, maxSize) { if (!IsStyleCompatible(style)) { throw new ArgumentException("Style is not compatible with area."); } this.style = style; }
public void Parse(CompileContext context, System.Xml.XmlNode node) { ASTScalar width = null, height = null; if (node.Attributes["Width"] != null) { width = new ASTScalar(); width.Parse(context, Token.StackForm(Token.Tokenize(node.Attributes["Width"].InnerText))); } if (node.Attributes["X"] != null) { if (width != null) { throw new ParseException("Could not combine X and Width, same meaning in terms of vector."); } width = new ASTScalar(); width.Parse(context, Token.StackForm(Token.Tokenize(node.Attributes["X"].InnerText))); } if (node.Attributes["Height"] != null) { height = new ASTScalar(); height.Parse(context, Token.StackForm(Token.Tokenize(node.Attributes["Height"].InnerText))); } if (node.Attributes["Y"] != null) { if (height != null) { throw new ParseException("Could not combine Y and Height, same meaning in terms of vector."); } height = new ASTScalar(); height.Parse(context, Token.StackForm(Token.Tokenize(node.Attributes["Y"].InnerText))); } // Default to zero if (width == null) { width = new ASTScalar(); width.Scalar = new GuiScalar(0.0f); } if (height == null) { height = new ASTScalar(); height.Scalar = new GuiScalar(0.0f); } data = new GuiVector2(width.Scalar, height.Scalar); }
/// <summary> /// Constructor with preferred size. /// </summary> /// <param name="preferredSize"></param> public Area(GuiVector2 preferredSize, GuiVector2 minSize, GuiVector2 maxSize) : this(preferredSize) { this.minSize = minSize; this.maxSize = maxSize; }
/// <summary> /// Constructor with preferred size. /// </summary> /// <param name="preferredSize"></param> public Area(GuiVector2 preferredSize) { this.preferredSize = preferredSize; }
protected Area(SerializationInfo info, StreamingContext context) { serializationOptions = (WidgetSerialization)info.GetValue("SerializeOptions", typeof(WidgetSerialization)); zOrder = info.GetUInt32("ZOrder"); parent = (IWidget)info.GetValue("Parent", typeof(IWidget)); description = info.GetString("Description"); containedDescriptionShowUpTime = info.GetSingle("ContainedDescriptionShowUpTime"); containedDescriptionPositioning = (LayoutAnchor)info.GetValue("ContainedDescriptionPositioning", typeof(LayoutAnchor)); containedDescriptionObject = (IDisplayObject)info.GetValue("ContainedDescriptionObject", typeof(IDisplayObject)); anchor = (LayoutAnchor)info.GetValue("Anchor", typeof(LayoutAnchor)); minSize = (GuiVector2)info.GetValue("MinSize", typeof(GuiVector2)); maxSize = (GuiVector2)info.GetValue("MaxSize", typeof(GuiVector2)); preferredSize = (GuiVector2)info.GetValue("PreferredSize", typeof(GuiVector2)); preserveRatio = info.GetBoolean("PreserveRatio"); preferredRect = (GuiRect)info.GetValue("PreferredRect", typeof(GuiRect)); marginLeft = (GuiScalar)info.GetValue("MarginLeft", typeof(GuiScalar)); marginRight = (GuiScalar)info.GetValue("MarginRight", typeof(GuiScalar)); marginTop = (GuiScalar)info.GetValue("MarginTop", typeof(GuiScalar)); marginBottom = (GuiScalar)info.GetValue("MarginBottom", typeof(GuiScalar)); if ((serializationOptions & WidgetSerialization.PersistAllStyles) > 0) { style = (Style)info.GetValue("Style", typeof(Style)); } else if ((serializationOptions & WidgetSerialization.PersistNonThemeStyles) > 0) { style = (Style)info.GetValue("Style", typeof(Style)); } if ((serializationOptions & WidgetSerialization.PersistRenderer) > 0) { renderer = (Themes.IGuiRenderer)info.GetValue("Renderer", typeof(Themes.IGuiRenderer)); } if ((serializationOptions & WidgetSerialization.PersistState) > 0) { isVisible = info.GetBoolean("IsVisible"); } if ((serializationOptions & WidgetSerialization.PersistAnimations) > 0) { animationState = (StyleAnimationController)info.GetValue("StyleAnimationController", typeof(StyleAnimationController)); activeAnimations = (List <AnimationProcess>)info.GetValue("ActiveAnimations", typeof(List <AnimationProcess>)); } if ((serializationOptions & WidgetSerialization.PersistEventBindings) > 0) { onChange = (Action <IPreChangeNotifier>)info.GetValue("OnChange", typeof(Action <IPreChangeNotifier>)); onMouseOver = (Action2 <Area, IPointer>)info.GetValue("OnMouseOver", typeof(Action2 <Area, IPointer>)); onMouseLeave = (Action2 <Area, IPointer>)info.GetValue("OnMouseLeave", typeof(Action2 <Area, IPointer>)); onMousePressed = (Action4 <Area, IPointer, uint, InputEventModifier>)info.GetValue("OnMousePressed", typeof(Action4 <Area, IPointer, uint, InputEventModifier>)); onMouseReleased = (Action3 <Area, IPointer, uint>)info.GetValue("OnMouseReleased", typeof(Action3 <Area, IPointer, uint>)); onWheel = (Action3 <Area, IPointer, float>)info.GetValue("OnWheel", typeof(Action3 <Area, IPointer, float>)); onMouseMove = (Action3 <Area, IPointer, Vector2f>)info.GetValue("OnMouseMove", typeof(Action3 <Area, IPointer, Vector2f>)); onFocusGain = (Action <Area>)info.GetValue("OnFocusGain", typeof(Action <Area>)); onFocusLost = (Action <Area>)info.GetValue("OnFocusLost", typeof(Action <Area>)); onKeyPressed = (Action5 <Area, IPointer, KeyCodes, KeyboardModifiers, InputEventModifier>)info.GetValue( "OnKeyPressed", typeof(Action5 <Area, IPointer, KeyCodes, KeyboardModifiers, InputEventModifier>)); onKeyReleased = (Action4 <Area, IPointer, KeyCodes, KeyboardModifiers>)info.GetValue("OnKeyReleased", typeof(Action4 <Area, IPointer, KeyCodes, KeyboardModifiers>)); onDescriptionShow = (Action2 <Area, IWidget>)info.GetValue("OnDescriptionShow", typeof(Action2 <Area, IWidget>)); onDescriptionHide = (Action2 <Area, IWidget>)info.GetValue("OnDescriptionHide", typeof(Action2 <Area, IWidget>)); onStyleStateChange = (Action3 <Area, StyleState, StyleState>)info.GetValue("OnStyleStateChange", typeof(Action3 <Area, StyleState, StyleState>)); } }
/// <summary> /// Pointer sensitivity constructor. /// </summary> /// <param name="mouseSensitivity"></param> /// <param name="wheelSensitivity"></param> /// <param name="repeatKeyPressFirstTime"></param> /// <param name="repeatKeyPress"></param> public Sensitivity(GuiVector2 mouseSensitivity, GuiScalar wheelSensitivity) { this.mouseSensitivity = mouseSensitivity; this.wheelSensitivity = wheelSensitivity; }