protected override void LayoutItemWidgets() { // get render area var renderRect = GetItemRenderArea(); // get starting position var x0 = CoordConverter.AlignToPixels(renderRect.d_min.X); var y0 = CoordConverter.AlignToPixels(renderRect.d_min.Y); var sz = new UVector2(UDim.Absolute(CoordConverter.AlignToPixels(renderRect.Width)), UDim.Absolute(0)); // set item width // iterate through all items attached to this window foreach (var item in ListItems) { // get the "optimal" height of the item and use that! sz.d_y.d_offset = CoordConverter.AlignToPixels(item.GetItemPixelSize().Height); // rounding errors ? // set destination rect var rect = new URect { Position = new UVector2(UDim.Absolute(x0), UDim.Absolute(y0)), Size = new USize(sz.d_x, sz.d_y) }; // todo: vector vs size item.SetArea(rect); // next position y0 += CoordConverter.AlignToPixels(sz.d_y.d_offset + ItemSpacing); } }
public override void CreateRenderGeometry() { // get WidgetLookFeel for the assigned look. var wlf = GetLookNFeel(); // try and get imagery for our current state var imagery = wlf.GetStateImagery(Window.IsEffectiveDisabled() ? "Disabled" : "Enabled"); // peform the rendering operation. imagery.Render(Window); // get imagery for actual progress rendering imagery = wlf.GetStateImagery(Window.IsEffectiveDisabled() ? "DisabledProgress" : "EnabledProgress"); // get target rect for this imagery var progressRect = wlf.GetNamedArea("ProgressArea").GetArea().GetPixelRect(Window); // calculate a clipper according to the current progress. var progressClipper = progressRect; var w = (ProgressBar)Window; if (_vertical) { float height = CoordConverter.AlignToPixels(progressClipper.Height * w.GetProgress()); if (_reversed) { progressClipper.Height = height; } else { progressClipper.Top = progressClipper.Bottom - height; } } else { var width = CoordConverter.AlignToPixels(progressClipper.Width * w.GetProgress()); if (_reversed) { progressClipper.Left = progressClipper.Right - width; } else { progressClipper.Width = width; } } // peform the rendering operation. imagery.Render(Window, progressRect, null, progressClipper); }
public override Sizef GetTextSize() { var w = (Tooltip)Window; var sz = w.GetTextSizeImpl(); // get WidgetLookFeel for the assigned look. var wlf = GetLookNFeel(); var textArea = wlf.GetNamedArea("TextArea").GetArea().GetPixelRect(w); var wndArea = CoordConverter.AsAbsolute(w.GetArea(), w.GetParentPixelSize()); sz.Width = CoordConverter.AlignToPixels(sz.Width + wndArea.Width - textArea.Width); sz.Height = CoordConverter.AlignToPixels(sz.Height + wndArea.Height - textArea.Height); return(sz); }
public void CreateRenderGeometryAndAddToItemView(ItemView view, RenderedString renderedString, Rectf drawRect, Font font, Rectf?itemClipper, bool isSelected) { if (view.GetSelectionBrushImage() != null && isSelected) { var renderSettings = new ImageRenderSettings(drawRect, itemClipper, true, view.GetSelectionColourRect()); var brushGeomBuffers = view.GetSelectionBrushImage().CreateRenderGeometry(renderSettings); view.AppendGeometryBuffers(brushGeomBuffers); } var drawPos = drawRect.Position; for (var i = 0; i < renderedString.GetLineCount(); ++i) { drawPos.Y += CoordConverter.AlignToPixels((font.GetLineSpacing() - font.GetFontHeight()) * 0.5f); var stringGeomBuffers = renderedString.CreateRenderGeometry(view, i, drawPos, null, itemClipper, 0.0f); view.AppendGeometryBuffers(stringGeomBuffers); drawPos.Y += renderedString.GetPixelSize(view, i).Height; } }
/// <summary> /// Setup size and position for the item widgets attached to this Menubar /// </summary> protected override void LayoutItemWidgets() { var renderRect = GetItemRenderArea(); var x0 = CoordConverter.AlignToPixels(renderRect.Left); foreach (var item in ListItems) { var optimal = item.GetItemPixelSize(); item.SetVerticalAlignment(VerticalAlignment.Centre); var rect = new URect { Position = new UVector2(UDim.Absolute(x0), UDim.Absolute(0)), Size = new USize(UDim.Absolute(CoordConverter.AlignToPixels(optimal.Width)), UDim.Absolute(CoordConverter.AlignToPixels(optimal.Height))) }; item.SetArea(rect); x0 += optimal.Width + ItemSpacing; } }
// Implement CEGUI::Image interface public override List <GeometryBuffer> CreateRenderGeometry(ImageRenderSettings renderSettings) { var dest = renderSettings.DestArea; // apply rendering offset to the destination Rect dest.Offset(d_scaledOffset); var clipArea = renderSettings.ClipArea; // Calculate the actual (clipped) area to which we want to render to var finalRect = clipArea.HasValue ? dest.GetIntersection(clipArea.Value) : dest; // check if our Image is totally clipped and return if it is if ((Math.Abs(finalRect.Width) < float.Epsilon) || (Math.Abs(finalRect.Height) < float.Epsilon)) { return(new List <GeometryBuffer>()); } // Calculate the scale factor for our Image which is the scaling of the Image // area to the destination area of our render call var scaleFactor = new Vector2(dest.Width / d_imageArea.Width, dest.Height / d_imageArea.Height); // URGENT FIXME: Shouldn't this be in the hands of the user? finalRect.d_min.X = CoordConverter.AlignToPixels(finalRect.d_min.X); finalRect.d_min.Y = CoordConverter.AlignToPixels(finalRect.d_min.Y); finalRect.d_max.X = CoordConverter.AlignToPixels(finalRect.d_max.X); finalRect.d_max.Y = CoordConverter.AlignToPixels(finalRect.d_max.Y); var svgRenderSettings = new SvgImageRenderSettings(renderSettings, scaleFactor, d_useGeometryAntialiasing); var geometryBuffers = new List <GeometryBuffer>(); foreach (var shape in d_svgData.getShapes()) { geometryBuffers.AddRange(shape.CreateRenderGeometry(svgRenderSettings)); } return(geometryBuffers); }
public override List <GeometryBuffer> CreateRenderGeometry(Rectf targetRect, float alpha, Rectf?clipper) { var geomBuffers = new List <GeometryBuffer>(); if (Selected && SelectBrush != null) { var imgRenderSettings = new ImageRenderSettings(targetRect, clipper, true, SelectCols, alpha); geomBuffers.AddRange(SelectBrush.CreateRenderGeometry(imgRenderSettings)); } var font = GetFont(); if (font == null) { return(geomBuffers); } var drawPos = targetRect.Position; drawPos.Y += CoordConverter.AlignToPixels((font.GetLineSpacing() - font.GetFontHeight()) * 0.5f); if (!_renderedStringValid) { ParseTextString(); } var finalColours = new ColourRect(0xFFFFFFFF); for (var i = 0; i < _renderedString.GetLineCount(); ++i) { geomBuffers.AddRange(_renderedString.CreateRenderGeometry(Owner, i, drawPos, finalColours, clipper, 0.0f)); drawPos.Y += _renderedString.GetPixelSize(Owner, i).Height; } return(geomBuffers); }
/// <summary> /// Adds the render geometry for scrolled text to the Window /// </summary> protected void AddScrolledTextRenderGeometry() { UpdateFormatting(); // get destination area for the text. var clipper = GetTextRenderArea(); var absarea = clipper; if (!_formatValid) { UpdateFormatting(clipper.Size); } // see if we may need to adjust horizontal position var horzScrollbar = GetHorzScrollbar(); if (horzScrollbar.IsEffectiveVisible()) { var range = horzScrollbar.GetDocumentSize() - horzScrollbar.GetPageSize(); switch (_horzFormatting /*TODO:GetActualHorizontalFormatting()*/) { case HorizontalTextFormatting.LeftAligned: case HorizontalTextFormatting.WordWrapLeftAligned: case HorizontalTextFormatting.Justified: case HorizontalTextFormatting.WordWrapJustified: absarea.Offset(new Lunatics.Mathematics.Vector2(-horzScrollbar.GetScrollPosition(), 0)); break; case HorizontalTextFormatting.CentreAligned: case HorizontalTextFormatting.WordWrapCentreAligned: absarea.Width = horzScrollbar.GetDocumentSize(); absarea.Offset(new Lunatics.Mathematics.Vector2(range / 2 - horzScrollbar.GetScrollPosition(), 0)); break; case HorizontalTextFormatting.RightAligned: case HorizontalTextFormatting.WordWrapRightAligned: absarea.Offset(new Lunatics.Mathematics.Vector2(range - horzScrollbar.GetScrollPosition(), 0)); break; default: throw new InvalidRequestException("Invalid actual horizontal formatting."); } } // adjust y positioning according to formatting option var textHeight = _formattedRenderedString.GetVerticalExtent(Window); var vertScrollbar = GetVertScrollbar(); var vertScrollPosition = vertScrollbar.GetScrollPosition(); // if scroll bar is in use, position according to that. if (vertScrollbar.IsEffectiveVisible()) { absarea.d_min.Y -= vertScrollPosition; } else { // no scrollbar, so adjust position according to formatting set. switch (_vertFormatting /*TODO:GetActualVerticalFormatting()*/) { case VerticalTextFormatting.CentreAligned: absarea.d_min.Y += CoordConverter.AlignToPixels((absarea.Height - textHeight) * 0.5f); break; case VerticalTextFormatting.BottomAligned: absarea.d_min.Y = absarea.d_max.Y - textHeight; break; case VerticalTextFormatting.TopAligned: break; default: throw new InvalidRequestException("Invalid actual vertical formatting."); } } // calculate final colours var finalCols = _textCols; finalCols.ModulateAlpha(Window.GetEffectiveAlpha()); // cache the text for rendering. var geomBuffers = _formattedRenderedString.CreateRenderGeometry(Window, absarea.Position, finalCols, clipper); Window.AppendGeometryBuffers(geomBuffers); }