コード例 #1
0
ファイル: SelectBoxList.cs プロジェクト: v-karpov/Nez
        public void Hide()
        {
            if (!ListBox.IsTouchable() || !HasParent())
            {
                return;
            }

            ListBox.SetTouchable(Touchable.Disabled);

            if (stage != null)
            {
                if (_previousScrollFocus != null && _previousScrollFocus.GetStage() == null)
                {
                    _previousScrollFocus = null;
                }
            }

            _selectBox.OnHide(this);
        }
コード例 #2
0
        void SetContainerPosition(float x, float y)
        {
            var stage = _targetElement.GetStage();

            if (stage == null)
            {
                return;
            }

            _container.Pack();
            float offsetX = _manager.OffsetX, offsetY = _manager.OffsetY, dist = _manager.EdgeDistance;
            var   point = _targetElement.LocalToStageCoordinates(new System.Numerics.Vector2(x + offsetX - _container.GetWidth() / 2,
                                                                                             y - offsetY - _container.GetHeight()));

            if (point.Y < dist)
            {
                point = _targetElement.LocalToStageCoordinates(new System.Numerics.Vector2(x + offsetX, y + offsetY));
            }
            if (point.X < dist)
            {
                point.X = dist;
            }
            if (point.X + _container.GetWidth() > stage.GetWidth() - dist)
            {
                point.X = stage.GetWidth() - dist - _container.GetWidth();
            }
            if (point.Y + _container.GetHeight() > stage.GetHeight() - dist)
            {
                point.Y = stage.GetHeight() - dist - _container.GetHeight();
            }
            _container.SetPosition(point.X, point.Y);

            point = _targetElement.LocalToStageCoordinates(new System.Numerics.Vector2(_targetElement.GetWidth() / 2,
                                                                                       _targetElement.GetHeight() / 2));
            point -= new System.Numerics.Vector2(_container.GetX(), _container.GetY());
            _container.SetOrigin(point.X, point.Y);
        }