private bool SetStyleValue(StylePropertyId id, StyleBackground inlineValue, StyleBackground sharedValue) { var sv = new StyleValue(); if (TryGetStyleValue(id, ref sv)) { var vectorImage = sv.resource.IsAllocated ? sv.resource.Target as VectorImage : null; var texture = sv.resource.IsAllocated ? sv.resource.Target as Texture2D : null; if ((vectorImage == inlineValue.value.vectorImage && texture == inlineValue.value.texture) && sv.keyword == inlineValue.keyword) { return(false); } if (sv.resource.IsAllocated) { sv.resource.Free(); } } else if (inlineValue.keyword == StyleKeyword.Null) { return(false); } sv.id = id; sv.keyword = inlineValue.keyword; if (inlineValue.value.vectorImage != null) { sv.resource = GCHandle.Alloc(inlineValue.value.vectorImage); } else if (inlineValue.value.texture != null) { sv.resource = GCHandle.Alloc(inlineValue.value.texture); } else { sv.resource = new GCHandle(); } SetStyleValue(sv); if (inlineValue.keyword == StyleKeyword.Null) { sv.keyword = sharedValue.keyword; if (sharedValue.value.texture != null) { sv.resource = GCHandle.Alloc(sharedValue.value.texture); } else if (sharedValue.value.vectorImage != null) { sv.resource = GCHandle.Alloc(sharedValue.value.vectorImage); } else { sv.resource = new GCHandle(); } } ApplyStyleValue(sv); return(true); }
private bool SetStyleValue(StylePropertyId id, StyleFloat inlineValue, StyleFloat sharedValue) { var sv = new StyleValue(); if (TryGetStyleValue(id, ref sv)) { if (sv.number == inlineValue.value && sv.keyword == inlineValue.keyword) { return(false); } } else if (inlineValue.keyword == StyleKeyword.Null) { return(false); } sv.id = id; sv.keyword = inlineValue.keyword; sv.number = inlineValue.value; SetStyleValue(sv); if (inlineValue.keyword == StyleKeyword.Null) { sv.keyword = sharedValue.keyword; sv.number = sharedValue.value; } ApplyStyleValue(sv); return(true); }
private bool SetStyleValue(StylePropertyID id, StyleLength inlineValue, StyleLength sharedValue) { var sv = new StyleValue(); if (TryGetStyleValue(id, ref sv)) { if (sv.length == inlineValue.value && sv.keyword == inlineValue.keyword) { return(false); } } sv.id = id; sv.keyword = inlineValue.keyword; sv.length = inlineValue.value; SetStyleValue(sv); int specificity = StyleValueExtensions.InlineSpecificity; if (inlineValue.keyword == StyleKeyword.Null) { specificity = sharedValue.specificity; sv.keyword = sharedValue.keyword; sv.length = sharedValue.value; } ApplyStyleValue(sv, specificity); return(true); }
private bool SetStyleValue <T>(StylePropertyId id, StyleEnum <T> inlineValue, StyleEnum <T> sharedValue) where T : struct, IConvertible { var sv = new StyleValue(); int intValue = UnsafeUtility.EnumToInt(inlineValue.value); if (TryGetStyleValue(id, ref sv)) { if (sv.number == intValue && sv.keyword == inlineValue.keyword) { return(false); } } else if (inlineValue.keyword == StyleKeyword.Null) { return(false); } sv.id = id; sv.keyword = inlineValue.keyword; sv.number = intValue; SetStyleValue(sv); if (inlineValue.keyword == StyleKeyword.Null) { sv.keyword = sharedValue.keyword; sv.number = sharedValue.value.ToInt32(CultureInfo.InvariantCulture); } ApplyStyleValue(sv); return(true); }
void HandleResizeFromTopLeft(MouseMoveEvent mouseMoveEvent) { if (!m_Dragging) { return; } Vector2 relativeMousePosition = mouseMoveEvent.mousePosition - m_ResizeBeginMousePosition; // Set anchor points for positioning m_Container.style.positionTop = StyleValue <float> .Create(float.NaN); m_Container.style.positionBottom = StyleValue <float> .Create(m_Container.parent.layout.height - m_Container.layout.yMax); m_Container.style.positionLeft = StyleValue <float> .Create(float.NaN); m_Container.style.positionRight = StyleValue <float> .Create(m_Container.parent.layout.width - m_Container.layout.xMax); float newWidth = Mathf.Max(0f, m_ResizeBeginLayout.width - relativeMousePosition.x); float newHeight = Mathf.Max(0f, m_ResizeBeginLayout.height - relativeMousePosition.y); if (maintainAspectRatio) { newWidth = newHeight = Mathf.Min(newWidth, newHeight); } m_ResizeTarget.style.width = StyleValue <float> .Create(newWidth); m_ResizeTarget.style.height = StyleValue <float> .Create(newHeight); mouseMoveEvent.StopPropagation(); }
private bool SetStyleValue <T>(StylePropertyID id, StyleEnum <T> inlineValue, StyleInt sharedValue) where T : struct, IConvertible { var sv = new StyleValue(); int intValue = inlineValue.value.ToInt32(CultureInfo.InvariantCulture); if (TryGetStyleValue(id, ref sv)) { if (sv.number == intValue && sv.keyword == inlineValue.keyword) { return(false); } } sv.id = id; sv.keyword = inlineValue.keyword; sv.number = intValue; SetStyleValue(sv); int specificity = StyleValueExtensions.InlineSpecificity; if (inlineValue.keyword == StyleKeyword.Null) { specificity = sharedValue.specificity; sv.keyword = sharedValue.keyword; sv.number = sharedValue.value; } ApplyStyleValue(sv, specificity); return(true); }
void OnParentGeometryChanged(GeometryChangedEvent geometryChangedEvent) { // Check if the parent window can no longer contain the target window. // If the window is out of bounds, make one edge clamp to the border of the // parent window. if (target.layout.xMin < 0f) { target.style.positionLeft = StyleValue <float> .Create(0f); target.style.positionRight = StyleValue <float> .Create(float.NaN); } if (target.layout.xMax > geometryChangedEvent.newRect.width) { target.style.positionLeft = StyleValue <float> .Create(float.NaN); target.style.positionRight = StyleValue <float> .Create(0f); } if (target.layout.yMax > geometryChangedEvent.newRect.height) { target.style.positionTop = StyleValue <float> .Create(float.NaN); target.style.positionBottom = StyleValue <float> .Create(0f); } if (target.layout.yMin < 0f) { target.style.positionTop = StyleValue <float> .Create(0f); target.style.positionBottom = StyleValue <float> .Create(float.NaN); } }
public StyleBackground GetStyleBackground(StylePropertyId id) { var inline = new StyleValue(); if (TryGetStyleValue(id, ref inline)) { var texture = inline.resource.IsAllocated ? inline.resource.Target as Texture2D : null; if (texture != null) { return(new StyleBackground(texture, inline.keyword)); } var sprite = inline.resource.IsAllocated ? inline.resource.Target as Sprite : null; if (sprite != null) { return(new StyleBackground(sprite, inline.keyword)); } var vectorImage = inline.resource.IsAllocated ? inline.resource.Target as VectorImage : null; if (vectorImage != null) { return(new StyleBackground(vectorImage, inline.keyword)); } } return(StyleKeyword.Null); }
private bool SetStyleValue(StylePropertyId id, StyleFontDefinition inlineValue, FontDefinition sharedValue) { var sv = new StyleValue(); if (TryGetStyleValue(id, ref sv)) { var font = sv.resource.IsAllocated ? sv.resource.Target as Font : null; var obj = sv.resource.Target as Object; var fontAsset = sv.resource.IsAllocated && TextDelegates.IsFontAssetSafe(obj) ? obj : null; if ((font == inlineValue.value.font && fontAsset == inlineValue.value.fontAsset) && sv.keyword == inlineValue.keyword) { return(false); } if (sv.resource.IsAllocated) { sv.resource.Free(); } } else if (inlineValue.keyword == StyleKeyword.Null) { return(false); } sv.id = id; sv.keyword = inlineValue.keyword; if (inlineValue.value.font != null) { sv.resource = GCHandle.Alloc(inlineValue.value.font); } else if (inlineValue.value.fontAsset != null) { sv.resource = GCHandle.Alloc(inlineValue.value.fontAsset); } else { sv.resource = new GCHandle(); } SetStyleValue(sv); if (inlineValue.keyword == StyleKeyword.Null) { if (sharedValue.font != null) { sv.resource = GCHandle.Alloc(sharedValue.font); } else if (sharedValue.fontAsset != null) { sv.resource = GCHandle.Alloc(sharedValue.fontAsset); } else { sv.resource = new GCHandle(); } } ApplyStyleValue(sv); return(true); }
private bool SetStyleValue(StylePropertyId id, StyleLength inlineValue, Length sharedValue) { var sv = new StyleValue(); if (TryGetStyleValue(id, ref sv)) { if (sv.length == inlineValue.value && sv.keyword == inlineValue.keyword) { return(false); } } else if (inlineValue.keyword == StyleKeyword.Null) { return(false); } sv.id = id; sv.keyword = inlineValue.keyword; sv.length = inlineValue.ToLength(); SetStyleValue(sv); if (inlineValue.keyword == StyleKeyword.Null) { sv.length = sharedValue; } ApplyStyleValue(sv); return(true); }
internal static void AddTooltip(this VisualElement e, string tooltip) { if (string.IsNullOrEmpty(tooltip)) { e.RemoveTooltip(); } else { TooltipElement tooltipElement = e.Query().Children <TooltipElement>(null, null); if (tooltipElement == null) { tooltipElement = new TooltipElement(); } tooltipElement.style.positionType = PositionType.Absolute; IStyle arg_85_0 = tooltipElement.style; StyleValue <float> styleValue = 0f; tooltipElement.style.positionBottom = styleValue; styleValue = styleValue; tooltipElement.style.positionTop = styleValue; styleValue = styleValue; tooltipElement.style.positionRight = styleValue; arg_85_0.positionLeft = styleValue; tooltipElement.tooltip = tooltip; e.Add(tooltipElement); } }
internal void SetValue(StylePropertyId id, float value) { StyleValue styleValue = default(StyleValue); styleValue.id = id; styleValue.number = value; this.Values().SetStyleValue(styleValue); }
internal void SetValue(StylePropertyId id, float value) { var sv = new StyleValue(); sv.id = id; sv.number = value; Values().SetStyleValue(sv); }
internal void SetValue(StylePropertyId id, Color value) { var sv = new StyleValue(); sv.id = id; sv.color = value; Values().SetStyleValue(sv); }
protected override void OnStyleResolved(ICustomStyle style) { base.OnStyleResolved(style); float left = depth * 12; var paddingLeft = new StyleValue <float>(left); this.style.paddingLeft = paddingLeft; }
internal void SetValue(StylePropertyId id, Color value) { StyleValue styleValue = default(StyleValue); styleValue.id = id; styleValue.color = value; this.Values().SetStyleValue(styleValue); }
public void ResetLayer() { int value = this.m_Layer.value; this.m_Layer = StyleValue <int> .nil; base.effectiveStyle.ApplyCustomProperty("layer", ref this.m_Layer); this.UpdateLayer(value); }
public void ResetLayer() { int prevLayer = m_Layer.value; m_Layer = StyleValue <int> .nil; effectiveStyle.ApplyCustomProperty(k_LayerProperty, ref m_Layer); UpdateLayer(prevLayer); }
public NodeView() { AddStyleSheetPath("NodeView_style"); SetSize(new Vector2(1280, 720)); style.alignItems = StyleValue <Align> .Create(Align.FlexStart); SetupSobelExample(transform.position); }
public override Boolean IsEmpty(Boolean includeFormats) { if (includeFormats && !StyleValue.Equals(Worksheet.StyleValue)) { return(false); } return(base.IsEmpty(includeFormats)); }
private bool ApplyGlobalKeyword(StyleValue sv, ComputedStyle parentStyle) { if (sv.keyword == StyleKeyword.Initial) { ApplyInitialValue(sv.id); return(true); } return(false); }
Image CreatePreview(Texture texture) { var image = new Image { name = "preview", image = StyleValue <Texture> .Create(m_PreviewRenderHandle.texture ?? texture) }; image.AddManipulator(new Draggable(OnMouseDragPreviewMesh, true)); image.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action <ContextualMenuPopulateEvent>)BuildContextualMenu)); return(image); }
private StyleColor GetInlineStyleColor(StylePropertyID id) { var inline = new StyleValue(); if (TryGetInlineStyleValue(id, ref inline)) { return(new StyleColor(inline.color, inline.keyword)); } return(StyleKeyword.Null); }
public StyleFloat GetStyleFloat(StylePropertyId id) { var inline = new StyleValue(); if (TryGetStyleValue(id, ref inline)) { return(new StyleFloat(inline.number, inline.keyword)); } return(StyleKeyword.Null); }
private StyleInt GetInlineStyleInt(StylePropertyID id) { var inline = new StyleValue(); if (TryGetInlineStyleValue(id, ref inline)) { return(new StyleInt((int)inline.number, inline.keyword)); } return(StyleKeyword.Null); }
public StyleLength GetStyleLength(StylePropertyId id) { var inline = new StyleValue(); if (TryGetStyleValue(id, ref inline)) { return(new StyleLength(inline.length, inline.keyword)); } return(StyleKeyword.Null); }
public override Boolean IsEmpty(XLCellsUsedOptions options) { if (options.HasFlag(XLCellsUsedOptions.NormalFormats) && !StyleValue.Equals(Worksheet.StyleValue)) { return(false); } return(base.IsEmpty(options)); }
private StyleFont GetInlineStyleFont(StylePropertyID id) { var inline = new StyleValue(); if (TryGetInlineStyleValue(id, ref inline)) { var font = inline.resource.IsAllocated ? inline.resource.Target as Font : null; return(new StyleFont(font, inline.keyword)); } return(StyleKeyword.Null); }
private StyleBackground GetInlineStyleBackground(StylePropertyID id) { var inline = new StyleValue(); if (TryGetInlineStyleValue(id, ref inline)) { var texture = inline.resource.IsAllocated ? inline.resource.Target as Texture2D : null; return(new StyleBackground(texture, inline.keyword)); } return(StyleKeyword.Null); }
public StyleFontDefinition GetStyleFontDefinition(StylePropertyId id) { var inline = new StyleValue(); if (TryGetStyleValue(id, ref inline)) { var font = inline.resource.IsAllocated ? inline.resource.Target as object : null; return(new StyleFontDefinition(font, inline.keyword)); } return(StyleKeyword.Null); }
public ConstantExpression(ITree tree) { var val = tree.GetChild(0).Text; var node = tree.GetChild(1); if (val.StartsWith("#")) { Value = new StyleColor(val); } else { Value = new StyleNumber(Convert.ToDecimal(val), node != null ? node.Text : ""); } }
public StyleState(StyleState parent) { m_IsUnderlined = parent.m_IsUnderlined; IsBold = parent.IsBold; IsItalic = parent.IsItalic; IsOutlined = parent.IsOutlined; Font = parent.Font; Color = parent.Color; ColorHue = parent.ColorHue; ActiveColorHue = parent.ActiveColorHue; HoverColorHue = parent.HoverColorHue; HREF = parent.HREF; }
public StyleState(StyleState parent) { m_IsUnderlined = parent.m_IsUnderlined; IsBold = parent.IsBold; IsItalic = parent.IsItalic; IsOutlined = parent.IsOutlined; Font = parent.Font; Alignment = parent.Alignment; Color = parent.Color; HREF = parent.HREF; ElementWidth = parent.ElementWidth; ElementHeight = parent.ElementHeight; GumpImgSrc = parent.GumpImgSrc; GumpImgSrcOver = parent.GumpImgSrcOver; GumpImgSrcDown = parent.GumpImgSrcDown; }
public ConstantExpression(StyleValue value) { Value = value; }