Пример #1
0
        Picture _buildPicture(_InspectorOverlayRenderState state)
        {
            PictureRecorder recorder = new PictureRecorder();
            Canvas          canvas   = new RecorderCanvas(recorder);
            Size            size     = state.overlayRect.size;

            var fillPaint = new Paint()
            {
                color = _kHighlightedRenderObjectFillColor
            };
            var borderPaint = new Paint()
            {
                color       = _kHighlightedRenderObjectBorderColor, style = PaintingStyle.stroke,
                strokeWidth = 1
            };
            Rect selectedPaintRect = state.selected.rect.deflate(0.5f);

            canvas.save();
            canvas.setMatrix(state.selected.transform);
            canvas.drawRect(selectedPaintRect, fillPaint);
            canvas.drawRect(selectedPaintRect, borderPaint);
            canvas.restore();

            foreach (var transformedRect in state.candidates)
            {
                canvas.save();
                canvas.setMatrix(transformedRect.transform);
                canvas.drawRect(transformedRect.rect.deflate(0.5f), borderPaint);
                canvas.restore();
            }

            // todo paint descipion
            return(recorder.endRecording());
        }
Пример #2
0
        // public  TextPainter _textPainter;
        // public double _textPainterMaxWidth;


        public override void addToScene(SceneBuilder builder, Offset layerOffset)
        {
            if (!this.selection.active)
            {
                return;
            }

            RenderObject            selected   = this.selection.current;
            List <_TransformedRect> candidates = new List <_TransformedRect>();

            foreach (RenderObject candidate in this.selection.candidates)
            {
                if (candidate == selected || !candidate.attached)
                {
                    continue;
                }

                candidates.Add(new _TransformedRect(candidate));
            }

            _InspectorOverlayRenderState state = new _InspectorOverlayRenderState(this.overlayRect,
                                                                                  new _TransformedRect(selected),
                                                                                  candidates, this.selection.currentElement.toStringShort(),
                                                                                  TextDirection.ltr
                                                                                  );

            if (state != this._lastState)
            {
                this._lastState = state;
                this._picture   = this._buildPicture(state);
            }

            builder.addPicture(layerOffset, this._picture);
        }