Example #1
0
        public static GeneralUnitType ConvertToGeneralUnit(PositionUnitType unitType)
        {
            switch (unitType)
            {
            case PositionUnitType.PercentageHeight:
            case PositionUnitType.PercentageWidth:
                return(GeneralUnitType.Percentage);

            case PositionUnitType.PixelsFromLeft:
            case PositionUnitType.PixelsFromTop:
                return(GeneralUnitType.PixelsFromSmall);

            case PositionUnitType.PixelsFromRight:
            case PositionUnitType.PixelsFromBottom:
                return(GeneralUnitType.PixelsFromLarge);

            case PositionUnitType.PixelsFromCenterX:
                return(GeneralUnitType.PixelsFromMiddle);

            case PositionUnitType.PixelsFromCenterY:
                return(GeneralUnitType.PixelsFromMiddle);

            case PositionUnitType.PixelsFromCenterYInverted:
                return(GeneralUnitType.PixelsFromMiddleInverted);

            case PositionUnitType.PixelsFromBaseline:
                return(GeneralUnitType.PixelsFromBaseline);

            default:
                throw new NotImplementedException();
            }
        }
Example #2
0
        public static GeneralUnitType ConvertToGeneralUnit(object specificUnit)
        {
            if (specificUnit is PositionUnitType)
            {
                PositionUnitType asPut = (PositionUnitType)specificUnit;

                switch (asPut)
                {
                case PositionUnitType.PercentageHeight:
                case PositionUnitType.PercentageWidth:
                    return(GeneralUnitType.Percentage);

                case PositionUnitType.PixelsFromLeft:
                case PositionUnitType.PixelsFromTop:
                    return(GeneralUnitType.PixelsFromSmall);

                case PositionUnitType.PixelsFromRight:
                case PositionUnitType.PixelsFromBottom:
                    return(GeneralUnitType.PixelsFromLarge);

                case PositionUnitType.PixelsFromCenterX:
                    return(GeneralUnitType.PixelsFromMiddle);

                case PositionUnitType.PixelsFromCenterY:
                    return(GeneralUnitType.PixelsFromMiddle);

                default:
                    throw new NotImplementedException();
                }
            }

            else if (specificUnit is DimensionUnitType)
            {
                DimensionUnitType asDut = (DimensionUnitType)specificUnit;

                switch (asDut)
                {
                case DimensionUnitType.Absolute:
                    return(GeneralUnitType.PixelsFromSmall);

                case DimensionUnitType.Percentage:
                    return(GeneralUnitType.Percentage);

                case DimensionUnitType.RelativeToContainer:
                    return(GeneralUnitType.PixelsFromLarge);

                case DimensionUnitType.PercentageOfSourceFile:
                    return(GeneralUnitType.PercentageOfFile);

                default:
                    throw new NotImplementedException();
                }
            }

            throw new NotImplementedException();
        }
Example #3
0
        private void SetYValues(global::RenderingLibrary.Graphics.VerticalAlignment alignment, PositionUnitType yUnits)
        {
            var state = CurrentState;

            SetAndCallReact("Y", 0.0f, "float");
            SetAndCallReact("Y Origin",
                            alignment, typeof(global::RenderingLibrary.Graphics.VerticalAlignment).Name);
            SetAndCallReact("Y Units",
                            yUnits, typeof(PositionUnitType).Name);

            if (SelectedState.Self.SelectedInstance?.BaseType == "Text")
            {
                SetAndCallReact("VerticalAlignment", alignment, "VerticalAlignment");
            }
        }
Example #4
0
        private void SetXValues(global::RenderingLibrary.Graphics.HorizontalAlignment alignment, PositionUnitType xUnits)
        {
            SetAndCallReact("X", 0.0f, "float");
            SetAndCallReact("X Origin",
                            alignment, "HorizontalAlignment");
            SetAndCallReact("X Units",
                            xUnits, typeof(Gum.Managers.PositionUnitType).Name);

            if (SelectedState.Self.SelectedInstance?.BaseType == "Text")
            {
                SetAndCallReact("HorizontalAlignment", alignment, "HorizontalAlignment");
            }
        }
Example #5
0
        private void SetYValues(global::RenderingLibrary.Graphics.VerticalAlignment alignment, PositionUnitType yUnits)
        {
            var    state  = CurrentState;
            string prefix = GetVariablePrefix();

            state.SetValue(prefix + "Y", 0.0f, "float");
            state.SetValue(prefix + "Y Origin",
                           alignment, typeof(global::RenderingLibrary.Graphics.VerticalAlignment).Name);
            state.SetValue(prefix + "Y Units",
                           yUnits, typeof(PositionUnitType).Name);

            if (SelectedState.Self.SelectedInstance?.BaseType == "Text")
            {
                state.SetValue(prefix + "VerticalAlignment", alignment, "VerticalAlignment");
            }
        }
Example #6
0
        private void SetXValues(global::RenderingLibrary.Graphics.HorizontalAlignment alignment, PositionUnitType xUnits)
        {
            var    state  = CurrentState;
            string prefix = GetVariablePrefix();

            state.SetValue(prefix + "X", 0.0f, "float");
            state.SetValue(prefix + "X Origin",
                           alignment, "HorizontalAlignment");
            state.SetValue(prefix + "X Units",
                           xUnits, typeof(Gum.Managers.PositionUnitType).Name);

            if (SelectedState.Self.SelectedInstance?.BaseType == "Text")
            {
                state.SetValue(prefix + "HorizontalAlignment", alignment, "HorizontalAlignment");
            }
        }
Example #7
0
        private void SetPositionValuesOn(Glue.SaveClasses.NamedObjectSave nos, InstanceSave instance)
        {
            RecursiveVariableFinder rvf = new RecursiveVariableFinder(instance, instance.ParentContainer);
            float x = rvf.GetValue <float>("X");
            float y = rvf.GetValue <float>("Y");

            #region Adjust values according to object origin

            float effectiveWidth  = GetEffectiveWidth(instance);
            float effectiveHeight = GetEffectiveHeight(instance);

            HorizontalAlignment horizontalOrigin = rvf.GetValue <HorizontalAlignment>("X Origin");
            VerticalAlignment   verticalOrigin   = rvf.GetValue <VerticalAlignment>("Y Origin");

            switch (horizontalOrigin)
            {
            case HorizontalAlignment.Left:
                x += effectiveWidth / 2.0f;
                break;

            case HorizontalAlignment.Right:
                x -= effectiveWidth / 2.0f;
                break;
            }

            switch (verticalOrigin)
            {
            case VerticalAlignment.Top:
                y += effectiveHeight / 2.0f;
                break;

            case VerticalAlignment.Bottom:
                y -= effectiveHeight / 2.0f;
                break;
            }

            #endregion

            #region Adjust values according to alignment

            float parentWidth  = GetParentWidth(instance);
            float parentHeight = GetParentHeight(instance);

            PositionUnitType xUnits = rvf.GetValue <PositionUnitType>("X Units");
            PositionUnitType yUnits = rvf.GetValue <PositionUnitType>("Y Units");

            switch (xUnits)
            {
            case PositionUnitType.PixelsFromLeft:

                x -= parentWidth / 2.0f;

                break;

            case PositionUnitType.PixelsFromCenterX:
                // do nothing
                break;

            default:
                throw new NotImplementedException();
                break;
            }

            switch (yUnits)
            {
            case PositionUnitType.PixelsFromTop:
                y -= parentHeight / 2.0f;
                break;

            case PositionUnitType.PixelsFromCenterY:
                // do nothing
                break;

            default:

                break;
            }

            #endregion

            nos.SetPropertyValue("X", x);
            // Invert Y because FRB uses positive Y is up
            nos.SetPropertyValue("Y", -y);
        }
Example #8
0
 public static GeneralUnitType ConvertToGeneralUnit(PositionUnitType unitType)
 {
     switch (unitType)
     {
         case PositionUnitType.PercentageHeight:
         case PositionUnitType.PercentageWidth:
             return GeneralUnitType.Percentage;
         case PositionUnitType.PixelsFromLeft:
         case PositionUnitType.PixelsFromTop:
             return GeneralUnitType.PixelsFromSmall;
         case PositionUnitType.PixelsFromRight:
         case PositionUnitType.PixelsFromBottom:
             return GeneralUnitType.PixelsFromLarge;
         case PositionUnitType.PixelsFromCenterX:
             return GeneralUnitType.PixelsFromMiddle;
         case PositionUnitType.PixelsFromCenterY:
             return GeneralUnitType.PixelsFromMiddle;
         case PositionUnitType.PixelsFromCenterYInverted:
             return GeneralUnitType.PixelsFromMiddleInverted;
         default:
             throw new NotImplementedException();
     }
 }