internal override void Layout(LayoutBox box, Renderman renderer) { // Get the top left inner corner (inside margin and border): float width = box.PaddedWidth; float height = box.PaddedHeight; float top = box.Y + box.Border.Top; float left = box.X + box.Border.Left; // Is it clipped? if (renderer.IsInvisible(left, top, width, height)) { // Totally not visible. return; } // Ensure we have a batch (doesn't change graphics or font thus both nulls): renderer.SetupBatch(this, null, null); // Get the transform: Transformation transform = renderer.Transform; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { // Add it: MeshBlock block = Add(renderer); // Set the UV to that of the solid block colour pixel: block.SetSolidColourUV(); // Set the colour - here we set it unevenly to trigger gradients. // block.SetColour(BackingColour * renderer.ColorOverlay); // BoxRegion clipZone=new BoxRegion(left,top,width,height); // Set the verts too: // block.SetClipped(renderer.ClippingBoundary,clipZone,renderer,box.ZIndex-0.006f); block.Done(transform); } } }
internal override void Layout(LayoutBox box, Renderman renderer) { // Does the boxes text region overlap our selected range? if (box.TextEnd <= StartIndex || EndIndex <= box.TextStart) { return; } // It overlaps! We need to figure out which section we're selecting (and how large it is). // Get the top left inner corner (inside margin and border): // Assume we've selected the whole thing; we remove from the start and remove from the end if needed. float width = box.PaddedWidth; float height = box.PaddedHeight; float top = box.Y + box.Border.Top; float left = box.X + box.Border.Left; float fs = Text.FontSize; // If the selected indices totally contain the box.. if (StartIndex > box.TextStart) { // Trim the start. We need to chop off the width of these characters. float characterWidth = 0f; int max = StartIndex; if (max > Text.Characters.Length) { max = Text.Characters.Length; } for (int i = box.TextStart; i < max; i++) { InfiniText.Glyph character = Text.Characters[i]; if (character == null) { continue; } // Advance over the glyph: if (Text.Kerning != null) { characterWidth += Text.Kerning[i] * fs; } characterWidth += (character.AdvanceWidth * fs) + Text.LetterSpacing; if (character.Charcode == (int)' ') { characterWidth += Text.WordSpacing; } } // Chop it off: left += characterWidth; width -= characterWidth; } if (EndIndex < box.TextEnd) { // Trim the end. We need to chop off the width of these characters. float characterWidth = 0f; int max = box.TextEnd; if (max > Text.Characters.Length) { max = Text.Characters.Length; } for (int i = EndIndex; i < max; i++) { InfiniText.Glyph character = Text.Characters[i]; if (character == null) { continue; } // Advance over the glyph: if (Text.Kerning != null) { characterWidth += Text.Kerning[i] * fs; } characterWidth += (character.AdvanceWidth * fs) + Text.LetterSpacing; if (character.Charcode == (int)' ') { characterWidth += Text.WordSpacing; } } // Chop it off: width -= characterWidth; } // Is it clipped? if (renderer.IsInvisible(left, top, width, height)) { // Totally not visible. return; } // Ensure we have a batch (doesn't change graphics or font thus both nulls): renderer.SetupBatch(this, null, null); // Allocate the block: MeshBlock block = Add(renderer); // Using firstblock as our block here. // Set the UV to that of the solid block colour pixel: block.SetSolidColourUV(); // Set the colour: block.SetColour(BaseColour); // And finally sort out the verts: block.SetClipped(renderer.ClippingBoundary, new BoxRegion(left, top, width, height), renderer, RenderData.computedStyle.ZIndex - 0.004f); // Flush it: block.Done(renderer.Transform); }
internal override void Layout(LayoutBox box, Renderman renderer) { float width; float height; float top; float left; bool clip = true; if (renderer.ViewportBackground) { // Applying to whole background: BoxRegion viewport = renderer.Viewport; top = viewport.Y; left = viewport.X; width = viewport.Width; height = viewport.Height; renderer.ViewportBackground = false; clip = false; } else { // Get the top left inner corner (inside margin and border): width = box.PaddedWidth; height = box.PaddedHeight; top = box.Y + box.Border.Top; left = box.X + box.Border.Left; // Is it clipped? if (renderer.IsInvisible(left, top, width, height)) { // Totally not visible. return; } } // Ensure we have a batch (doesn't change graphics or font thus both nulls): renderer.SetupBatch(this, null, null); // Allocate the block: MeshBlock block = Add(renderer); // Using firstblock as our block here. // Set the UV to that of the solid block colour pixel: block.SetSolidColourUV(); // Set the (overlay) colour: block.SetColour(BaseColour * renderer.ColorOverlay); // And finally sort out the verts: if (clip) { block.SetClipped(renderer.ClippingBoundary, new BoxRegion(left, top, width, height), renderer, RenderData.computedStyle.ZIndex - 0.006f); } else { block.ApplyVertices(new BoxRegion(left, top, width, height), renderer, RenderData.computedStyle.ZIndex - 0.006f); } // Flush it: block.Done(renderer.Transform); }