Пример #1
0
        private void DrawOpenedAreaItems(int startIndex, int endIndex, float transitionAlpha)
        {
            // Draw background
            float itemsHeight = (endIndex - startIndex) * (m_comboboxItemDeltaHeight + ITEM_DRAW_DELTA);
            var minSize = m_styleDef.DropDownTexture.MinSizeGui;
            var maxSize = m_styleDef.DropDownTexture.MaxSizeGui;
            Vector2 dropdownSize = Vector2.Clamp(new Vector2(Size.X, itemsHeight + minSize.Y), minSize, maxSize);
            var topLeft = GetPositionAbsoluteTopLeft();
            m_styleDef.DropDownTexture.Draw(topLeft + m_openedArea.Position, dropdownSize,
                ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));

            // Scissor to cut off items that overflow dropdown area.
            var scissor         = m_openedItemArea;
            scissor.Position   += topLeft;
            scissor.Position.X -= m_styleDef.DropDownHighlightExtraWidth;
            scissor.Size.X     += m_styleDef.DropDownHighlightExtraWidth;
            using (MyGuiManager.UsingScissorRectangle(ref scissor))
            {
                Vector2 itemPosition = topLeft + m_openedItemArea.Position;
                for (int i = startIndex; i < endIndex; i++)
                {
                    Item item = m_items[i];

                    // Draw selected background texture
                    var font = m_styleDef.ItemFontNormal;
                    if ((item == m_preselectedMouseOver) || ((m_preselectedKeyboardIndex.HasValue) && (m_preselectedKeyboardIndex == i)))
                    {
                        MyGuiManager.DrawSpriteBatchRoundUp(m_styleDef.ItemTextureHighlight,
                            itemPosition - new Vector2(m_styleDef.DropDownHighlightExtraWidth, 0f),
                            m_selectedItemArea.Size + new Vector2(m_styleDef.DropDownHighlightExtraWidth, 0f),
                            ApplyColorMaskModifiers(Vector4.One, Enabled, transitionAlpha),
                            MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                        font = m_styleDef.ItemFontHighlight;
                    }

                    //  Draw combobox item's text
                    MyGuiManager.DrawString(font,
                        item.Value,
                        itemPosition,
                        m_textScaleWithLanguage,
                        ApplyColorMaskModifiers(m_textColor, Enabled, transitionAlpha),
                        MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    itemPosition.Y += ITEM_HEIGHT;
                }
            }
        }