示例#1
0
        // overriden from ListboxWindowRenderer
        public override void CreateRenderGeometry()
        {
            var lb = (Listbox)Window;

            // render frame and stuff before we handle the items
            CacheListboxBaseImagery();

            //
            // Render list items
            //
            Lunatics.Mathematics.Vector3 itemPos;
            var itemRect = new Rectf();
            var widest   = lb.GetWidestItemWidth();

            // calculate position of area we have to render into
            var itemsArea = GetListRenderArea();

            // set up some initial positional details for items
            itemPos.X = itemsArea.Left - lb.GetHorzScrollbar().GetScrollPosition();
            itemPos.Y = itemsArea.Top - lb.GetVertScrollbar().GetScrollPosition();
            itemPos.Z = 0.0f;

            var alpha = lb.GetEffectiveAlpha();

            // loop through the items
            var itemCount = lb.GetItemCount();

            for (var i = 0; i < itemCount; ++i)
            {
                var   listItem = lb.GetListboxItemFromIndex(i);
                Sizef itemSize;
                itemSize.Height = listItem.GetPixelSize().Height;

                // allow item to have full width of box if this is wider than items
                itemSize.Width = Math.Max(itemsArea.Width, widest);

                // calculate destination area for this item.
                itemRect.Left = itemPos.X;
                itemRect.Top  = itemPos.Y;
                itemRect.Size = itemSize;
                var itemClipper = itemRect.GetIntersection(itemsArea);

                // skip this item if totally clipped
                if (Math.Abs(itemClipper.Width - 0) < float.Epsilon)
                {
                    itemPos.Y += itemSize.Height;
                    continue;
                }

                // draw this item
                Window.AppendGeometryBuffers(listItem.CreateRenderGeometry(itemRect, alpha, itemClipper));

                // update position ready for next item
                itemPos.Y += itemSize.Height;
            }
        }
示例#2
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;
            }
        }
示例#3
0
        protected internal override void OnCursorPressHold(CursorInputEventArgs e)
        {
            // Base class processing
            base.OnCursorPressHold(e);

            if (e.Source == CursorInputSource.Left)
            {
                if ((d_parent != null) && _dragEnabled)
                {
                    // we want all cursor inputs from now on
                    if (CaptureInput())
                    {
                        // initialise the dragging state
                        _dragging  = true;
                        _dragPoint = CoordConverter.ScreenToWindow(this, e.Position);

                        // store old constraint area
                        _oldCursorArea = GetGUIContext().GetCursor().GetConstraintArea();

                        // setup new constraint area to be the intersection of the old area and our grand-parent's clipped inner-area
                        Rectf constrainArea;

                        if ((d_parent == null) || (GetParent().GetParent() == null))
                        {
                            var screen = new Rectf(Lunatics.Mathematics.Vector2.Zero, GetRootContainerSize());
                            constrainArea = screen.GetIntersection(_oldCursorArea);
                        }
                        else
                        {
                            constrainArea = GetParent().GetParent().GetInnerRectClipper().GetIntersection(_oldCursorArea);
                        }

                        GetGUIContext().GetCursor().SetConstraintArea(constrainArea);
                    }
                }

                ++e.handled;
            }
        }
示例#4
0
        // overridden from base class.
        public override void CreateRenderGeometry()
        {
            var w             = (MultiColumnList)Window;
            var header        = w.GetListHeader();
            var vertScrollbar = w.GetVertScrollbar();
            var horzScrollbar = w.GetHorzScrollbar();

            // render general stuff before we handle the items
            CacheListboxBaseImagery();

            //
            // Render list items
            //
            Lunatics.Mathematics.Vector3 itemPos;
            var itemRect = new Rectf();

            // calculate position of area we have to render into
            var itemsArea = GetListRenderArea();

            // set up initial positional details for items
            itemPos.Y = itemsArea.Top - vertScrollbar.GetScrollPosition();
            itemPos.Z = 0.0f;

            var alpha = w.GetEffectiveAlpha();

            // loop through the items
            for (var i = 0; i < w.GetRowCount(); ++i)
            {
                // set initial x position for this row.
                itemPos.X = itemsArea.Left - horzScrollbar.GetScrollPosition();

                // calculate height for this row.
                Sizef itemSize;
                itemSize.Height = w.GetHighestRowItemHeight(i);

                // loop through the columns in this row
                for (var j = 0; j < w.GetColumnCount(); ++j)
                {
                    // allow item to use full width of the column
                    itemSize.Width = CoordConverter.AsAbsolute(header.GetColumnWidth(j), header.GetPixelSize().Width);

                    var item = w.GetItemAtGridReference(new MCLGridRef(i, j));

                    // is the item for this column set?
                    if (item != null)
                    {
                        // calculate destination area for this item.
                        itemRect.Left = itemPos.X;
                        itemRect.Top  = itemPos.Y;
                        itemRect.Size = itemSize;
                        var itemClipper = itemRect.GetIntersection(itemsArea);

                        // skip this item if totally clipped
                        if (itemClipper.Width == 0f)
                        {
                            itemPos.X += itemSize.Width;
                            continue;
                        }

                        // draw this item
                        item.CreateRenderGeometry(itemRect, alpha, itemClipper);
                    }

                    // update position for next column.
                    itemPos.X += itemSize.Width;
                }

                // update position ready for next row
                itemPos.Y += itemSize.Height;
            }
        }