Example #1
0
        public void Initialize(UIElement element)
        {
            localRotation     = default;
            localScale        = default;
            localPosition     = default;
            scale             = default;
            screenPosition    = default;
            pivot             = default;
            actualSize        = default;
            allocatedSize     = default;
            rotation          = default;
            border            = default;
            padding           = default;
            margin            = default;
            localMatrix       = default;
            pivotOffset       = default;
            allocatedPosition = default;
            alignedPosition   = default;
            layoutParent      = default;
            orientedBounds    = default;
            axisAlignedBounds = default;
            clipper           = default;
            isCulled          = default;
            rebuildGeometry   = default;

            this.element = element;
            this.matrix  = SVGXMatrix.identity;
        }
Example #2
0
        private void DrawElementInfo()
        {
            List <ElementAttribute> attributes = selectedElement.GetAttributes();

            if (attributes != null)
            {
                DrawAttributes(attributes);
            }

            GUI.enabled = true;
            LayoutResult layoutResult = selectedElement.layoutResult;
            float        labelWidth   = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 100;

            Rect contentRect = layoutResult.ContentRect;

            DrawLabel("Enabled", selectedElement.isEnabled.ToString());
            if (selectedElement.isEnabled)
            {
                DrawLabel("Culled", selectedElement.layoutResult.isCulled.ToString());
                DrawLabel("View", selectedElement.View.name);
                DrawLabel("Viewport", $"X: {selectedElement.View.Viewport.x}, Y: {selectedElement.View.Viewport.y}, W: {selectedElement.View.Viewport.width}, H: {selectedElement.View.Viewport.height}");
                DrawVector2Value("Local Position", layoutResult.localPosition);
                DrawVector2Value("Screen Position", layoutResult.screenPosition);
                DrawVector2Value("Scale", layoutResult.scale);
                DrawSizeValue("Allocated Size", layoutResult.allocatedSize);
                DrawSizeValue("Actual Size", layoutResult.actualSize);

                DrawLabel("Rotation", layoutResult.rotation.ToString());
                DrawLabel("Content Rect", $"X: {contentRect.x}, Y: {contentRect.y}, W: {contentRect.width}, H: {contentRect.height}");

                DrawLabel("Render Layer", selectedElement.style.RenderLayer.ToString());

                GUILayout.Space(16);

                DrawEnumWithValue <LayoutType>(selectedElement.style.GetComputedStyleProperty(StylePropertyId.LayoutType), false);
                DrawMeasurement(selectedElement.style.GetComputedStyleProperty(StylePropertyId.PreferredWidth), false);
                DrawMeasurement(selectedElement.style.GetComputedStyleProperty(StylePropertyId.PreferredHeight), false);

                DrawLabel("Block Width Provider:", selectedElement.layoutBox.GetBlockWidthProvider() + " size: " + selectedElement.layoutBox.ComputeBlockWidth(1));
                DrawLabel("Block Height Provider:", selectedElement.layoutBox.GetBlockHeightProvider() + " size: " + selectedElement.layoutBox.ComputeBlockHeight(1));

                GUILayout.Space(16);

                OffsetRect margin = selectedElement.layoutResult.margin;
                DrawLabel("Margin Top", margin.top.ToString());
                DrawLabel("Margin Right", margin.right.ToString());
                DrawLabel("Margin Bottom", margin.bottom.ToString());
                DrawLabel("Margin Left", margin.left.ToString());

                GUILayout.Space(16);

                OffsetRect border = selectedElement.layoutResult.border;

                DrawLabel("Border Top", border.top.ToString());
                DrawLabel("Border Right", border.right.ToString());
                DrawLabel("Border Bottom", border.bottom.ToString());
                DrawLabel("Border Left", border.left.ToString());

                GUILayout.Space(16);

                OffsetRect padding = selectedElement.layoutResult.padding;
                DrawLabel("Padding Top", padding.top.ToString());
                DrawLabel("Padding Right", padding.right.ToString());
                DrawLabel("Padding Bottom", padding.bottom.ToString());
                DrawLabel("Padding Left", padding.left.ToString());
            }

            EditorGUIUtility.labelWidth = labelWidth;
        }