コード例 #1
0
        public MyGuiControlBlockProperty(String title, String tooltip, MyGuiControlBase propertyControl,
                                         MyGuiControlBlockPropertyLayoutEnum layout = MyGuiControlBlockPropertyLayoutEnum.Vertical, bool showExtraInfo = true)
            : base(toolTip: tooltip, canHaveFocus: true, isActiveControl: false, allowFocusingElements: true)
        {
            const float LABEL_TEXT_SCALE = MyGuiConstants.DEFAULT_TEXT_SCALE * 0.95f;

            m_title = new MyGuiControlLabel(text: title, textScale: LABEL_TEXT_SCALE);
            if (title.Length > 0)
            {
                Elements.Add(m_title);
            }

            m_extraInfo = new MyGuiControlLabel(textScale: LABEL_TEXT_SCALE);
            if (showExtraInfo)
            {
                Elements.Add(m_extraInfo);
            }

            m_propertyControl = propertyControl;
            Elements.Add(m_propertyControl);

            titleHeight = title.Length > 0 || showExtraInfo ? m_title.Size.Y : 0;

            m_layout = layout;
            switch (layout)
            {
            case MyGuiControlBlockPropertyLayoutEnum.Horizontal:
                MinSize = new Vector2(m_propertyControl.Size.X + m_title.Size.X * 1.1f, Math.Max(m_propertyControl.Size.Y, 2.1f * titleHeight));
                Size    = MinSize;

                m_title.OriginAlign           = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                m_propertyControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                m_extraInfo.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                break;

            case MyGuiControlBlockPropertyLayoutEnum.Vertical:
                MinSize = new Vector2(Math.Max(m_propertyControl.Size.X, m_title.Size.X), m_propertyControl.Size.Y + titleHeight * 1.1f);
                Size    = MinSize;

                m_title.OriginAlign           = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                m_propertyControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                m_extraInfo.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                break;
            }

            RefreshPositionsAndSizes();

            m_extraInfo.Text    = "";
            m_extraInfo.Visible = false;
        }
コード例 #2
0
        public MyGuiControlBlockProperty(String title, String tooltip, MyGuiControlBase propertyControl,
            MyGuiControlBlockPropertyLayoutEnum layout = MyGuiControlBlockPropertyLayoutEnum.Vertical, bool showExtraInfo = true)
            : base(toolTip: tooltip, canHaveFocus: true, isActiveControl: false, allowFocusingElements: true)
        {
            const float LABEL_TEXT_SCALE = MyGuiConstants.DEFAULT_TEXT_SCALE * 0.95f;
            m_title = new MyGuiControlLabel(text: title, textScale: LABEL_TEXT_SCALE);
            if (title.Length > 0)
            {
                Elements.Add(m_title);
            }
            
            m_extraInfo = new MyGuiControlLabel(textScale: LABEL_TEXT_SCALE);
            if (showExtraInfo)
            {
                Elements.Add(m_extraInfo);
            }

            m_propertyControl = propertyControl;
            Elements.Add(m_propertyControl);

            titleHeight = title.Length > 0 || showExtraInfo ? m_title.Size.Y : 0;

            m_layout = layout;
            switch (layout)
            {
                case MyGuiControlBlockPropertyLayoutEnum.Horizontal:                    
                    MinSize = new Vector2(m_propertyControl.Size.X + m_title.Size.X * 1.1f, Math.Max(m_propertyControl.Size.Y, 2.1f * titleHeight));
                    Size = MinSize;

                    m_title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                    m_propertyControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                    m_extraInfo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                    break;
                case MyGuiControlBlockPropertyLayoutEnum.Vertical:
                    MinSize = new Vector2(Math.Max(m_propertyControl.Size.X, m_title.Size.X), m_propertyControl.Size.Y + titleHeight * 1.1f);
                    Size = MinSize;

                    m_title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                    m_propertyControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                    m_extraInfo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                    break;
            }

            RefreshPositionsAndSizes();

            m_extraInfo.Text = "";
            m_extraInfo.Visible = false;
        }