Пример #1
0
 ImmutableRelation(ITupleAdapter <TupleType> proj, byte dim, byte level, object liquidToken)
 {
     _proj        = proj;
     _dim         = dim;
     _level       = level;
     _liquidToken = liquidToken;
 }
Пример #2
0
        public override void CollectViews()
        {
            base.CollectViews();

            Adapter = root.GetComponent(typeof(ITupleAdapter)) as ITupleAdapter;
            root.GetComponentAtPath("IndexText", out _IndexText);
        }
Пример #3
0
 internal bool Matches(TupleType tuple, int dim, ITupleAdapter <TupleType> proj)
 {
     if (_any)
     {
         return(true);
     }
     return(proj.ItemEquals(tuple, _item, dim));
 }
Пример #4
0
        ImmutableRelation(
            ImmutableRelation <TupleType> other,
            byte dim, byte level,
            object liquidToken)
        {
            _bucket0 = other._bucket0;
            _bucket1 = other._bucket1;
            _bucket2 = other._bucket2;
            _bucket3 = other._bucket3;
            _bucket4 = other._bucket4;
            _bucket5 = other._bucket5;
            _bucket6 = other._bucket6;
            _bucket7 = other._bucket7;

            _proj  = other._proj;
            _count = other._count;

            _dim         = dim;
            _level       = level;
            _liquidToken = liquidToken;
        }
Пример #5
0
        void ITupleAdapterSizeHandler.RequestChangeTransversalSize(ITupleAdapter adapter, double size)
        {
            var vh = GetItemViewsHolderIfVisible(adapter.TupleParameters.ScrollViewRT);

            if (vh == null)
            {
                throw new OSAException("Tuple adapter requests size change, but it can't be found among visible children?");
            }

            Vector2 prevVelocity = Velocity;
            bool    endStat;
            var     resizeMode     = adapter.TupleParameters.ResizingMode;
            bool    isFitToContent = resizeMode == TableResizingMode.AUTO_FIT_TUPLE_CONTENT;
            bool    cutVelocity    = false;

            if (isFitToContent)
            {
                float abstrVelocity = prevVelocity[_InternalState.hor0_vert1] * _InternalState.hor1_vertMinus1;
                endStat = abstrVelocity != 0f && Mathf.Sign(abstrVelocity) == 1;
            }
            else
            {
                endStat     = false;
                cutVelocity = resizeMode == TableResizingMode.MANUAL_TUPLES ||
                              resizeMode == TableResizingMode.MANUAL_COLUMNS ||
                              resizeMode == TableResizingMode.MANUAL_COLUMNS_AND_TUPLES;

                if (cutVelocity)
                {
                    // If the actual size didn't change, don't cut velocity, because nothing was affected
                    double knownSize  = _ItemsDesc[vh.itemIndexInView];
                    double difference = Math.Abs(knownSize - size);
                    cutVelocity = difference > 1d;
                }
            }
            bool computeVisibility = false;
            bool correctPos        = true;

            RequestChangeItemSizeAndUpdateLayout(vh, (float)size, endStat, computeVisibility, correctPos, !cutVelocity);
        }
Пример #6
0
 internal int GetKeyHash(int dim, ITupleAdapter <TupleType> proj)
 {
     return(proj.GetItemHash(_item, dim));
 }
Пример #7
0
        // Returns if prefab needs to be rebuilt
        bool InitResizingNeeded(ITupleAdapter tupleAdapter)
        {
            var tupleParams = tupleAdapter.TupleParameters;
            var valuePrefab = tupleParams.ItemPrefab;

            var csf         = valuePrefab.GetComponent <ContentSizeFitter>();
            var layoutGroup = valuePrefab.GetComponent <LayoutGroup>();

            if (ResizingMode == TableResizingMode.AUTO_FIT_TUPLE_CONTENT)
            {
                if (EdgeDragger && EdgeDragger.gameObject.activeSelf)
                {
                    EdgeDragger.gameObject.SetActive(false);
                }

                if (tupleParams.ItemTransversalSize != -1f)
                {
                    Debug.Log(
                        typeof(TupleParams).Name + ": ItemTransversalSize needs to be -1, " +
                        "because ResizingMode is " + ResizingMode +
                        ". To avoid this message, manually set it in inspector"
                        );
                    tupleParams.ItemTransversalSize = -1f;
                }

                if (!csf)
                {
                    //Debug.Log(
                    //	typeof(TupleParams).Name + ": ResizingMode is " + TableResizingMode.AUTO_FIT_TUPLE_CONTENT +
                    //	", but no ContentSizeFitter found on tuple's value prefab. Adding one..."
                    //);
                    csf = valuePrefab.gameObject.AddComponent <ContentSizeFitter>();
                }
                var prefr    = ContentSizeFitter.FitMode.PreferredSize;
                var unconstr = ContentSizeFitter.FitMode.Unconstrained;
                csf.horizontalFit = tupleAdapter.IsHorizontal ? unconstr : prefr;
                csf.verticalFit   = tupleAdapter.IsHorizontal ? prefr : unconstr;

                // Update: will be manually enabled when needed;
                //csf.enabled = true;
                csf.enabled = false;

                //var valPrefabLayG = valuePrefab.GetComponent<LayoutGroup>();
                //HorizontalLayoutGroup valPrefabLayGHor;
                //if (valPrefabLayG)
                //{
                //	valPrefabLayGHor = valPrefabLayG as HorizontalLayoutGroup;
                //	if (!valPrefabLayGHor)
                //		throw new OSAException(
                //			typeof(TupleParams).Name + ": Only " + typeof(HorizontalLayoutGroup).Name +
                //			" is allowed on value prefab ATM when using ResizingMode " + TableResizingMode.AUTO_FIT_TUPLE_CONTENT
                //		);
                //}
                //else
                //	valPrefabLayGHor = valuePrefab.gameObject.AddComponent<HorizontalLayoutGroup>();

                //if (IsHorizontal)
                //	_PrefabStandardPaddingTransvEnd = valPrefabLayGHor.padding.bottom;
                //else
                //	_PrefabStandardPaddingTransvEnd = valPrefabLayGHor.padding.right;

                //valPrefabLayG.childAlignment = TextAnchor.UpperLeft;
                //valPrefabLayGHor.childControlHeight = valPrefabLayGHor.childControlWidth = true;
                //valPrefabLayGHor.childForceExpandHeight = valPrefabLayGHor.childForceExpandWidth = false;

                //// Make sure the value prefab has the same size as the tuple
                //SetPaddingTransvEndToAchieveTansvSizeFor(valuePrefab, valPrefabLayG, ScrollViewRT.rect.size[IsHorizontal ? 1 : 0]);

                //return true;
            }
            else
            {
                if (EdgeDragger && !EdgeDragger.gameObject.activeSelf)
                {
                    EdgeDragger.gameObject.SetActive(true);
                }

                if (tupleParams.ItemTransversalSize == -1f)
                {
                    Debug.Log(
                        typeof(TupleParams).Name + ": ItemTransversalSize set to -1 is not supported, " +
                        "because ResizingMode is not " + TableResizingMode.AUTO_FIT_TUPLE_CONTENT +
                        ". To avoid this message, manually set it to something else in inspector"
                        );
                    tupleParams.ItemTransversalSize = 0f;
                }

                if (csf && csf.enabled)
                {
                    Debug.Log(typeof(TupleParams).Name + ": Found enabled ContentSizeFitter on tuple's value prefab, but ResizingMode is not "
                              + TableResizingMode.AUTO_FIT_TUPLE_CONTENT + ". Disabling ContentSizeFitter...");
                    csf.enabled = false;
                }

                if (ResizingMode == TableResizingMode.NONE)
                {
                }
                else
                {
                }
            }

            // Layout components are disabled when no resizing is available. You
            // should rely on anchoring to properly size the views in this case
            if (ResizingMode == TableResizingMode.NONE)
            {
                if (layoutGroup && layoutGroup.enabled)
                {
                    layoutGroup.enabled = false;
                    Debug.Log(typeof(TupleParams).Name + ": Found enabled LayoutGroup on tuple's value prefab, but ResizingMode is " + ResizingMode +
                              ". Disabling LayoutGroup...");
                }

                foreach (RectTransform rt in valuePrefab)
                {
                    var l = rt.GetComponent <LayoutGroup>();
                    if (l)
                    {
                        l.enabled = false;
                    }

                    var le = rt.GetComponent <LayoutElement>();
                    if (le)
                    {
                        le.enabled = false;
                    }
                }
            }
            else
            {
                if (layoutGroup && !layoutGroup.enabled)
                {
                    layoutGroup.enabled = true;
                }

                foreach (RectTransform rt in valuePrefab)
                {
                    var l = rt.GetComponent <LayoutGroup>();
                    if (l)
                    {
                        l.enabled = true;
                    }

                    var le = rt.GetComponent <LayoutElement>();
                    if (le)
                    {
                        le.enabled = true;
                    }
                }
            }

            return(false);
        }
Пример #8
0
 ImmutableRelation(ITupleAdapter <TupleType> proj)
 {
     _proj = proj;
 }
Пример #9
0
 public static ImmutableRelation <TupleType> Create(ITupleAdapter <TupleType> proj)
 {
     return(new ImmutableRelation <TupleType>(proj ?? throw new ArgumentNullException(nameof(proj))));
 }