public void Build(IGLBoundingBoxes boxes, float width, float height, IGLMatrices matrices, bool buildRenderBox, bool buildHitTestBox)
		{
			float left = 0f;
			float right = width;
			float bottom = 0f;
			float top = height;
            Vector3 bottomLeft = Vector3.Transform(new Vector3 (left, bottom, 0f), matrices.ModelMatrix);
			Vector3 topLeft = Vector3.Transform(new Vector3 (left, top, 0f), matrices.ModelMatrix);
			Vector3 bottomRight = Vector3.Transform(new Vector3 (right, bottom, 0f), matrices.ModelMatrix);
			Vector3 topRight = Vector3.Transform(new Vector3 (right, top, 0f), matrices.ModelMatrix);

			if (buildHitTestBox) buildForHitTest(boxes.HitTestBox, bottomLeft, topLeft, bottomRight, topRight);
            if (buildRenderBox)  buildForRender(boxes.RenderBox, matrices, bottomLeft, topLeft, bottomRight, topRight);            
		}
示例#2
0
 public GLImageRenderer(Dictionary <string, ITexture> textures,
                        IGLBoundingBoxBuilder boundingBoxBuilder,
                        IGLColorBuilder colorBuilder, IGLTextureRenderer renderer, IGLBoundingBoxes bgBoxes,
                        IGLViewportMatrixFactory layerViewports, IGraphicsFactory graphicsFactory, IGLUtils glUtils,
                        IBitmapLoader bitmapLoader)
 {
     _graphicsFactory    = graphicsFactory;
     _textures           = textures;
     _boundingBoxBuilder = boundingBoxBuilder;
     _colorBuilder       = colorBuilder;
     _renderer           = renderer;
     _layerViewports     = layerViewports;
     BoundingBoxes       = bgBoxes;
     _glUtils            = glUtils;
     _bitmapLoader       = bitmapLoader;
     _emptyTexture       = new Lazy <ITexture>(() => initEmptyTexture());
 }
示例#3
0
        public GLImageRenderer (Dictionary<string, ITexture> textures, 
			IGLMatrixBuilder hitTestMatrixBuilder, IGLMatrixBuilder renderMatrixBuilder, IGLBoundingBoxBuilder boundingBoxBuilder,
			IGLColorBuilder colorBuilder, IGLTextureRenderer renderer, IGLBoundingBoxes bgBoxes,
            IGLViewportMatrixFactory layerViewports, IGraphicsFactory graphicsFactory, IGLUtils glUtils)
		{
            _graphicsFactory = graphicsFactory;
			_textures = textures;
			_renderMatrixBuilder = renderMatrixBuilder;
            _hitTestMatrixBuilder = hitTestMatrixBuilder;
			_boundingBoxBuilder = boundingBoxBuilder;
			_colorBuilder = colorBuilder;
			_renderer = renderer;
			_layerViewports = layerViewports;
			BoundingBoxes = bgBoxes;
            _glUtils = glUtils;
            _emptyTexture = new Lazy<ITexture>(() => initEmptyTexture());
		}
        public void Build(IGLBoundingBoxes boxes, float width, float height, IGLMatrices matrices, bool buildRenderBox, bool buildHitTestBox)
        {
            float   left        = 0f;
            float   right       = width;
            float   bottom      = 0f;
            float   top         = height;
            Vector3 bottomLeft  = Vector3.Transform(new Vector3(left, bottom, 0f), matrices.ModelMatrix);
            Vector3 topLeft     = Vector3.Transform(new Vector3(left, top, 0f), matrices.ModelMatrix);
            Vector3 bottomRight = Vector3.Transform(new Vector3(right, bottom, 0f), matrices.ModelMatrix);
            Vector3 topRight    = Vector3.Transform(new Vector3(right, top, 0f), matrices.ModelMatrix);

            if (buildHitTestBox)
            {
                buildForHitTest(boxes.HitTestBox, bottomLeft, topLeft, bottomRight, topRight);
            }
            if (buildRenderBox)
            {
                buildForRender(boxes.RenderBox, matrices, bottomLeft, topLeft, bottomRight, topRight);
            }
        }
示例#5
0
        public GLLabelRenderer(Dictionary <string, ITexture> textures,
                               IGLBoundingBoxBuilder boundingBoxBuilder, IGLColorBuilder colorBuilder,
                               IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, IGLViewportMatrixFactory viewportMatrix,
                               IGLBoundingBoxes labelBoundingBoxes, IGLBoundingBoxes textBoundingBoxes, IGraphicsFactory graphicsFactory,
                               IGLUtils glUtils, IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IFontLoader fonts)
        {
            _glUtils            = glUtils;
            _graphics           = graphics;
            _fonts              = fonts;
            _bitmapPool         = bitmapPool;
            _viewport           = viewportMatrix;
            _textureRenderer    = textureRenderer;
            _labelBoundingBoxes = labelBoundingBoxes;
            _textBoundingBoxes  = textBoundingBoxes;
            _boundingBoxBuilder = boundingBoxBuilder;
            _bgRenderer         = new GLImageRenderer(textures,
                                                      new BoundingBoxesEmptyBuilder(), colorBuilder, _textureRenderer, _labelBoundingBoxes,
                                                      viewportMatrix, graphicsFactory, glUtils, bitmapLoader);

            _colorBuilder = colorBuilder;

            TextVisible = true;
        }
示例#6
0
 public void Build(IGLBoundingBoxes boxes, float width, float height, IGLMatrices matrices, bool buildRenderBox, bool buildHitTestBox)
 {
 }
示例#7
0
        private void updateBoundingBoxes(AutoFit autoFit, IGLMatrices textMatrices, IGLMatrices labelMatrices, PointF resolutionFactor, bool buildRenderBox, bool buildHitTestBox)
        {
            switch (autoFit)
            {
            case AutoFit.NoFitting:
                _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox);
                updateText(GLText.EmptySize, null);
                _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, _glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox);

                _usedLabelBoundingBoxes = _labelBoundingBoxes;
                _usedTextBoundingBoxes  = _textBoundingBoxes;
                break;

            case AutoFit.TextShouldWrapAndLabelShouldFitHeight:
                _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox);
                updateText(GLText.EmptySize, (int?)BaseSize.Width);
                _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, _glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox);
                _boundingBoxBuilder.Build(_labelBoundingBoxes, _glText.Width, _glText.Height, labelMatrices, buildRenderBox, buildHitTestBox);

                _usedLabelBoundingBoxes = _labelBoundingBoxes;
                _usedTextBoundingBoxes  = _textBoundingBoxes;
                break;

            case AutoFit.TextShouldFitLabel:
                _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox);
                updateText(_glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), null);

                float textWidth  = _glText.Width < BaseSize.Width ? _glText.BitmapWidth : MathUtils.Lerp(0f, 0f, _glText.Width, BaseSize.Width, _glText.BitmapWidth);
                float textHeight = _glText.Height < BaseSize.Height ? _glText.BitmapHeight : MathUtils.Lerp(0f, 0f, _glText.Height, BaseSize.Height, _glText.BitmapHeight);

                _boundingBoxBuilder.Build(_textBoundingBoxes, textWidth, textHeight, textMatrices, buildRenderBox, buildHitTestBox);

                _usedLabelBoundingBoxes = _labelBoundingBoxes;
                _usedTextBoundingBoxes  = _textBoundingBoxes;
                break;

            case AutoFit.LabelShouldFitText:
                _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, _glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox);
                _boundingBoxBuilder.Build(_labelBoundingBoxes, _glText.Width * resolutionFactor.X, _glText.Height * resolutionFactor.Y,
                                          textMatrices, buildRenderBox, buildHitTestBox);

                _usedLabelBoundingBoxes = _labelBoundingBoxes;
                _usedTextBoundingBoxes  = _textBoundingBoxes;
                break;

            case AutoFit.TextShouldCrop:
                _boundingBoxBuilder.Build(_labelBoundingBoxes, BaseSize.Width, BaseSize.Height, labelMatrices, buildRenderBox, buildHitTestBox);
                updateText(_glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), (int)BaseSize.Width, true);

                float heightOfText = _glText.Height < BaseSize.Height ? _glText.BitmapHeight : MathUtils.Lerp(0f, 0f, _glText.Height, BaseSize.Height, _glText.BitmapHeight);

                _boundingBoxBuilder.Build(_textBoundingBoxes, _glText.BitmapWidth, heightOfText, textMatrices, buildRenderBox, buildHitTestBox);

                _usedLabelBoundingBoxes = _labelBoundingBoxes;
                _usedTextBoundingBoxes  = _textBoundingBoxes;
                break;

            default:
                throw new NotSupportedException(autoFit.ToString());
            }
        }