protected MyGuiControlBase(
            Vector2?position  = null,
            Vector2?size      = null,
            Vector4?colorMask = null,
            String toolTip    = null,
            MyGuiCompositeTexture backgroundTexture = null,
            bool isActiveControl       = true,
            bool canHaveFocus          = false,
            bool allowFocusingElements = false,
            MyGuiControlHighlightType highlightType = MyGuiControlHighlightType.WHEN_ACTIVE,
            MyGuiDrawAlignEnum originAlign          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
        {
            Name                  = GetType().Name;
            Visible               = true;
            m_enabled             = true;
            m_position            = position ?? Vector2.Zero;
            m_canHaveFocus        = canHaveFocus;
            m_size                = size ?? Vector2.One;
            m_colorMask           = colorMask ?? Vector4.One;
            BackgroundTexture     = backgroundTexture;
            IsActiveControl       = isActiveControl;
            HighlightType         = highlightType;
            m_originAlign         = originAlign;
            BorderSize            = 1;
            BorderColor           = Vector4.One;
            BorderEnabled         = false;
            DrawWhilePaused       = true;
            Elements              = new MyGuiControls(this);
            AllowFocusingElements = allowFocusingElements;

            if (toolTip != null)
            {
                m_toolTip = new MyToolTips(toolTip);
            }
        }
 // Image without text constructor and with custom mouse cursor textures
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor,
                           MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, StringBuilder tooltip,
                           OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl,
                           MyGuiControlHighlightType highlightType, MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture /*,
                                                                                                                                                * System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/)
     : this(parent, position, size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, onButtonClick, canHandleKeyboardInput, align, tooltip, implementedFeature,
            canHandleKeyboardActiveControl, highlightType, mouseCursorHoverTexture, mouseCursorPressedTexture /*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
 }
 public MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4?backgroundColor, StringBuilder toolTip,
                         MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl, MyGuiControlHighlightType highlightType,
                         MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture /*,
                                                                                                     * System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/) :
     this(parent, position, backgroundColor, toolTip, controlTexture, hoverTexture, pressedTexture, isActiveControl, mouseCursorHoverTexture, mouseCursorPressedTexture /*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
     m_size          = size;
     m_highlightType = highlightType;
 }
Example #4
0
        public MyGuiControlButton(
            Vector2?position = null,
            MyGuiControlButtonStyleEnum visualStyle = MyGuiControlButtonStyleEnum.Default,
            Vector2?size      = null,
            Vector4?colorMask = null,
            MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            String toolTip     = null,
            StringBuilder text = null,
            float textScale    = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlignment        = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            MyGuiControlHighlightType highlightType = MyGuiControlHighlightType.WHEN_ACTIVE,
            bool implementedFeature = true,
            Action <MyGuiControlButton> onButtonClick = null,
            GuiSounds cueEnum           = GuiSounds.MouseClick,
            float buttonScale           = 1.0f,
            int?buttonIndex             = null,
            bool activateOnMouseRelease = false)
            : base(position :        position ?? Vector2.Zero,
                   size :            size,
                   colorMask :       colorMask ?? MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                   toolTip :         toolTip,
                   highlightType :   highlightType,
                   originAlign :     originAlign,
                   canHaveFocus :    implementedFeature)
        {
            Name                 = "Button";
            ButtonClicked        = onButtonClick;
            Index                = buttonIndex ?? 0;
            m_implementedFeature = implementedFeature;
            UpdateText();

            m_drawText.Clear().Append(text);
            TextScale     = textScale;
            TextAlignment = textAlignment;

            VisualStyle = visualStyle;
            m_cueEnum   = cueEnum;
            m_activateOnMouseRelease = activateOnMouseRelease;

            ButtonScale = buttonScale;

            Size *= ButtonScale;
        }
        public MyGuiControlButton(
            Vector2? position                         = null,
            MyGuiControlButtonStyleEnum visualStyle   = MyGuiControlButtonStyleEnum.Default,
            Vector2? size                             = null,
            Vector4? colorMask                        = null,
            MyGuiDrawAlignEnum originAlign            = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            String toolTip                     = null,
            StringBuilder text                        = null,
            float textScale                           = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlignment          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            MyGuiControlHighlightType highlightType   = MyGuiControlHighlightType.WHEN_ACTIVE,
            bool implementedFeature                   = true,
            Action<MyGuiControlButton> onButtonClick  = null,
            GuiSounds cueEnum                   = GuiSounds.MouseClick,
            float buttonScale                         = 1.0f,
            int? buttonIndex = null,
            bool activateOnMouseRelease               = false)
            : base( position:        position ?? Vector2.Zero,
                    size:            size,
                    colorMask:       colorMask ?? MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                    toolTip:         toolTip,
                    highlightType:   highlightType,
                    originAlign:     originAlign,
                    canHaveFocus:    implementedFeature)
        {
            Name                             = "Button";
            ButtonClicked                    = onButtonClick;
            Index                            = buttonIndex ?? 0;
            m_implementedFeature             = implementedFeature;
            UpdateText();

            m_drawText.Clear().Append(text);
            TextScale = textScale;
            TextAlignment = textAlignment;

            VisualStyle = visualStyle;
            m_cueEnum = cueEnum;
            m_activateOnMouseRelease = activateOnMouseRelease;

            ButtonScale = buttonScale;

            Size *= ButtonScale;
        }
 public void SetHightlightType(MyGuiControlHighlightType hightlightType)
 {
     m_highlightType = hightlightType;
 }
 //  Base constructor
 private MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4 backgroundColor, MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture,
     OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, StringBuilder tooltip, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType,
     MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture/*,
     System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/)
     : base(parent, MyGuiManager.GetAlignedCoordinate(position, size.Value, align) + new Vector2(size.Value.X / 2.0f, size.Value.Y / 2.0f), size, backgroundColor, tooltip,
      buttonTexture, hoverButtonTexture, pressedButtonTexture, true, highlightType, mouseCursorHoverTexture, mouseCursorPressedTexture/*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
     m_canHandleKeyboardActiveControl = canHandleKeyboardActiveControl && implementedFeature;
     m_onButtonClick = onButtonClick;
     m_canHandleKeyboardInput = canHandleKeyboardInput && implementedFeature;
     m_implementedFeature = implementedFeature;
 }
 //  Image constructor
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4 backgroundColor, MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, 
     MyTextsWrapperEnum textEnum, Vector4 textColor, float textScale, MyGuiControlButtonTextAlignment textAlignment,
     OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType)
     : this(parent, position, size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, onButtonClick, canHandleKeyboardInput, align, null, implementedFeature, canHandleKeyboardActiveControl, highlightType, null, null/*, null, null*/)
 {
     Text = MyTextsWrapper.Get(textEnum);
     m_textColor = textColor;
     m_textAlignment = textAlignment;
     m_textScale = textScale;
 }        
        // Image without text constructor and with custom mouse cursor textures
        public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4 backgroundColor,
            MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, StringBuilder tooltip,
            OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl, 
            MyGuiControlHighlightType highlightType, MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture/*,
            System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/)
            : this(parent, position, size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, onButtonClick, canHandleKeyboardInput, align, tooltip, implementedFeature,
            canHandleKeyboardActiveControl, highlightType, mouseCursorHoverTexture, mouseCursorPressedTexture/*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
        {

        }
Example #10
0
 public MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4? backgroundColor, StringBuilder toolTip,
     MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl, MyGuiControlHighlightType highlightType) :
     this(parent, position, size, backgroundColor, toolTip, controlTexture, hoverTexture, pressedTexture, isActiveControl, highlightType, null, null/*, null, null*/)
 {            
 }
 public MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4?backgroundColor, StringBuilder toolTip,
                         MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl, MyGuiControlHighlightType highlightType) :
     this(parent, position, size, backgroundColor, toolTip, controlTexture, hoverTexture, pressedTexture, isActiveControl, highlightType, null, null /*, null, null*/)
 {
 }
 public void SetHightlightType(MyGuiControlHighlightType hightlightType)
 {
     m_highlightType = hightlightType;
 }
 //  Base constructor
 private MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture,
                            OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, StringBuilder tooltip, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType,
                            MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture /*,
                                                                                                        * System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/)
     : base(parent, MyGuiManager.GetAlignedCoordinate(position, size.Value, align) + new Vector2(size.Value.X / 2.0f, size.Value.Y / 2.0f), size, backgroundColor, tooltip,
            buttonTexture, hoverButtonTexture, pressedButtonTexture, true, highlightType, mouseCursorHoverTexture, mouseCursorPressedTexture /*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
     m_canHandleKeyboardActiveControl = canHandleKeyboardActiveControl && implementedFeature;
     m_onButtonClick          = onButtonClick;
     m_canHandleKeyboardInput = canHandleKeyboardInput && implementedFeature;
     m_implementedFeature     = implementedFeature;
 }
 //  Image constructor
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor, MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture,
                           MyTextsWrapperEnum textEnum, Vector4 textColor, float textScale, MyGuiControlButtonTextAlignment textAlignment,
                           OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType)
     : this(parent, position, size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, onButtonClick, canHandleKeyboardInput, align, null, implementedFeature, canHandleKeyboardActiveControl, highlightType, null, null /*, null, null*/)
 {
     Text            = MyTextsWrapper.Get(textEnum);
     m_textColor     = textColor;
     m_textAlignment = textAlignment;
     m_textScale     = textScale;
 }
        public MyGuiControlImageButton(
            string name = "Button",
            Vector2? position = null,
            Vector2? size = null,
            Vector4? colorMask = null,
            MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            String toolTip = null,
            StringBuilder text = null,
            float textScale = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            MyGuiControlHighlightType highlightType = MyGuiControlHighlightType.WHEN_ACTIVE,
            Action<MyGuiControlImageButton> onButtonClick = null,
            GuiSounds cueEnum = GuiSounds.MouseClick,
            float buttonScale = 1.0f,
            int? buttonIndex = null,
            bool activateOnMouseRelease = false)
            : base(position: position ?? Vector2.Zero,
                    size: size,
                    colorMask: colorMask ?? MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                    toolTip: toolTip,
                    highlightType: highlightType,
                    originAlign: originAlign,
                    canHaveFocus: true)
        {
            m_styleDefinition = new StyleDefinition()
            {
                Active = new StateDefinition() { Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL },
                Disabled = new StateDefinition() { Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL },
                Normal = new StateDefinition() { Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL },
                Highlight = new StateDefinition() { Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT },
                ActiveHighlight = new StateDefinition() { Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT },
            };

            Name = name ?? "Button";
            ButtonClicked = onButtonClick;
            Index = buttonIndex ?? 0;
            UpdateText();

            m_drawText.Clear().Append(text);
            TextScale = textScale;
            TextAlignment = textAlignment;

            m_cueEnum = cueEnum;
            m_activateOnMouseRelease = activateOnMouseRelease;

            ButtonScale = buttonScale;

            Size *= ButtonScale;
        }
Example #16
0
        public MyGuiControlImageButton(
            string name       = "Button",
            Vector2?position  = null,
            Vector2?size      = null,
            Vector4?colorMask = null,
            MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            String toolTip     = null,
            StringBuilder text = null,
            float textScale    = MyGuiConstants.DEFAULT_TEXT_SCALE,
            MyGuiDrawAlignEnum textAlignment               = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            MyGuiControlHighlightType highlightType        = MyGuiControlHighlightType.WHEN_ACTIVE,
            Action <MyGuiControlImageButton> onButtonClick = null,
            GuiSounds cueEnum           = GuiSounds.MouseClick,
            float buttonScale           = 1.0f,
            int?buttonIndex             = null,
            bool activateOnMouseRelease = false)
            : base(position : position ?? Vector2.Zero,
                   size : size,
                   colorMask : colorMask ?? MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                   toolTip : toolTip,
                   highlightType : highlightType,
                   originAlign : originAlign,
                   canHaveFocus : true)
        {
            m_styleDefinition = new StyleDefinition()
            {
                Active = new StateDefinition()
                {
                    Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL
                },
                Disabled = new StateDefinition()
                {
                    Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL
                },
                Normal = new StateDefinition()
                {
                    Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_NORMAL
                },
                Highlight = new StateDefinition()
                {
                    Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT
                },
                ActiveHighlight = new StateDefinition()
                {
                    Texture = MyGuiConstants.TEXTURE_BUTTON_DEFAULT_HIGHLIGHT
                },
            };

            Name          = name ?? "Button";
            ButtonClicked = onButtonClick;
            Index         = buttonIndex ?? 0;
            UpdateText();

            m_drawText.Clear().Append(text);
            TextScale     = textScale;
            TextAlignment = textAlignment;

            m_cueEnum = cueEnum;
            m_activateOnMouseRelease = activateOnMouseRelease;

            ButtonScale = buttonScale;

            Size *= ButtonScale;
        }
Example #17
0
 public MyGuiControlBase(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4? backgroundColor, StringBuilder toolTip,
     MyTexture2D controlTexture, MyTexture2D hoverTexture, MyTexture2D pressedTexture, bool isActiveControl, MyGuiControlHighlightType highlightType,
     MyTexture2D mouseCursorHoverTexture, MyTexture2D mouseCursorPressedTexture/*,
     System.Drawing.Bitmap mouseCursorHoverBitmap, System.Drawing.Bitmap mouseCursorPressedBitmap*/) :
     this(parent, position, backgroundColor, toolTip, controlTexture, hoverTexture, pressedTexture, isActiveControl, mouseCursorHoverTexture, mouseCursorPressedTexture/*, mouseCursorHoverBitmap, mouseCursorPressedBitmap*/)
 {
     m_size = size;
     m_highlightType = highlightType;
 }
 // Image without text constructor
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2? size, Vector4 backgroundColor, 
     MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, StringBuilder tooltip,
     OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType)
     : this(parent, position,
     size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, tooltip, onButtonClick, canHandleKeyboardInput, align, implementedFeature, 
     canHandleKeyboardActiveControl, highlightType, null, null/*, null, null*/)
 {
     
 }
 // Image without text constructor
 public MyGuiControlButton(IMyGuiControlsParent parent, Vector2 position, Vector2?size, Vector4 backgroundColor,
                           MyTexture2D buttonTexture, MyTexture2D hoverButtonTexture, MyTexture2D pressedButtonTexture, StringBuilder tooltip,
                           OnButtonClick onButtonClick, bool canHandleKeyboardInput, MyGuiDrawAlignEnum align, bool implementedFeature, bool canHandleKeyboardActiveControl, MyGuiControlHighlightType highlightType)
     : this(parent, position,
            size, backgroundColor, buttonTexture, hoverButtonTexture, pressedButtonTexture, tooltip, onButtonClick, canHandleKeyboardInput, align, implementedFeature,
            canHandleKeyboardActiveControl, highlightType, null, null /*, null, null*/)
 {
 }