Example #1
0
        private void CreateRenderGeometry(ListView listView)
        {
            var itemsArea = GetViewRenderArea();
            var itemPos   = _itemViewRenderer.GetItemRenderStartPosition(listView, itemsArea);

            for (var i = 0; i < listView.GetItems().Count; ++i)
            {
                var item           = listView.GetItems()[i];
                var renderedString = item.d_string;
                var size           = item.d_size;

                size.Width = Math.Max(itemsArea.Width, size.Width);

                var itemRect = new Rectf(itemPos, size);

                if (!string.IsNullOrEmpty(item.d_icon))
                {
                    var img = ImageManager.GetSingleton().Get(item.d_icon);

                    var iconRect = itemRect;
                    iconRect.Width  = size.Height;
                    iconRect.Height = size.Height;

                    var iconClipper = iconRect.GetIntersection(itemsArea);

                    var renderSettings = new ImageRenderSettings(iconRect, iconClipper, true, ICON_COLOUR_RECT, 1.0f);
                    var imgGeomBuffers = img.CreateRenderGeometry(renderSettings);

                    if (item.d_isSelected)
                    {
                        renderSettings = new ImageRenderSettings(iconRect, iconClipper, true, listView.GetSelectionColourRect());
                        var brushGeomBuffers = listView.GetSelectionBrushImage().CreateRenderGeometry(renderSettings);
                        listView.AppendGeometryBuffers(brushGeomBuffers);
                    }

                    listView.AppendGeometryBuffers(imgGeomBuffers);

                    itemRect.Left = itemRect.Left + iconRect.Width;
                }

                var itemClipper = itemRect.GetIntersection(itemsArea);

                _itemViewRenderer.CreateRenderGeometryAndAddToItemView(listView, renderedString, itemRect,
                                                                       listView.GetFont(), itemClipper,
                                                                       item.d_isSelected);

                itemPos.Y += size.Height;
            }
        }