Esempio n. 1
0
        private float GetVisibility(IntRect visibleRegion)
        {
            // Outside bounds
            if (visibleRegion.Top > _glyphArea.Bottom())
            {
                return(0);
            }
            if (visibleRegion.Bottom() < _glyphArea.Top)
            {
                return(0);
            }

            // Completely within bounds
            if (visibleRegion.Top < _glyphArea.Top &&
                visibleRegion.Bottom() > _glyphArea.Bottom())
            {
                return(1);
            }
            ;


            // Partially within bounds - fading out
            if (visibleRegion.Top > _glyphArea.Top)
            {
                return((_glyphArea.Bottom() - visibleRegion.Top) / (float)(_glyphArea.Bottom() - _glyphArea.Top));
            }


            // Partially within bounds - fading in
            return((float)(visibleRegion.Bottom() - _glyphArea.Top) / _glyphArea.Height);
        }
Esempio n. 2
0
        public override sealed void Update(float frameTime)
        {
            var listboxLeftBounds  = _listboxLeft.GetLocalBounds();
            var listboxMainBounds  = _listboxMain.GetLocalBounds();
            var listboxRightBounds = _listboxRight.GetLocalBounds();

            _clientAreaLeft = new IntRect(Position, new Vector2i((int)listboxLeftBounds.Width, (int)listboxLeftBounds.Height));
            _clientAreaMain = new IntRect(_clientAreaLeft.Right(), Position.Y,
                                          _width, (int)listboxMainBounds.Height);
            _clientAreaRight = new IntRect(new Vector2i(_clientAreaMain.Right(), Position.Y),
                                           new Vector2i((int)listboxRightBounds.Width, (int)listboxRightBounds.Height));
            ClientArea = new IntRect(Position,
                                     new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width,
                                                  Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height),
                                                           _clientAreaMain.Height)));
            _selectedLabel.Position = new Vector2i(_clientAreaLeft.Right(),
                                                   Position.Y + (int)(ClientArea.Height / 2f) -
                                                   (int)(_selectedLabel.Height / 2f));
            _dropDown.Position = new Vector2i(ClientArea.Left + (int)((ClientArea.Width - _dropDown.ClientArea.Width) / 2f),
                                              ClientArea.Bottom());
            _dropDown.Update(frameTime);
        }
        public override void Update(float frameTime)
        {
            if (disposing || !IsVisible())
            {
                return;
            }
            ClientArea = new IntRect(Position, new Vector2i((int)clippingRI.Width, (int)clippingRI.Height));

            if (inner_focus != null && !components.Contains((GuiComponent)inner_focus))
            {
                ClearFocus();
            }

            scrollbarH.Position = new Vector2i(ClientArea.Left, ClientArea.Bottom() - scrollbarH.ClientArea.Height);
            scrollbarV.Position = new Vector2i(ClientArea.Right() - scrollbarV.ClientArea.Width, ClientArea.Top);

            if (scrollbarV.IsVisible())
            {
                scrollbarH.size = Size.X - scrollbarV.ClientArea.Width;
            }
            else
            {
                scrollbarH.size = Size.X;
            }

            if (scrollbarH.IsVisible())
            {
                scrollbarV.size = Size.Y - scrollbarH.ClientArea.Height;
            }
            else
            {
                scrollbarV.size = Size.Y;
            }

            max_x = 0;
            max_y = 0;

            foreach (GuiComponent component in components)
            {
                if (component.Position.X + component.ClientArea.Width > max_x)
                {
                    max_x = component.Position.X + component.ClientArea.Width;
                }
                if (component.Position.Y + component.ClientArea.Height > max_y)
                {
                    max_y = component.Position.Y + component.ClientArea.Height;
                }
            }

            scrollbarH.max = (int)max_x - ClientArea.Width +
                             (max_y > clippingRI.Height ? scrollbarV.ClientArea.Width : 0);
            if (max_x > clippingRI.Height)
            {
                scrollbarH.SetVisible(true);
            }
            else
            {
                scrollbarH.SetVisible(false);
            }

            scrollbarV.max = (int)max_y - ClientArea.Height +
                             (max_x > clippingRI.Height ? scrollbarH.ClientArea.Height : 0);
            if (max_y > clippingRI.Height)
            {
                scrollbarV.SetVisible(true);
            }
            else
            {
                scrollbarV.SetVisible(false);
            }

            scrollbarH.Update(frameTime);
            scrollbarV.Update(frameTime);
        }
        public override void Update(float frameTime)
        {
            if (disposing || !IsVisible()) return;
            ClientArea = new IntRect(Position, new Vector2i((int)clippingRI.Width, (int)clippingRI.Height));

            if (inner_focus != null && !components.Contains((GuiComponent) inner_focus)) ClearFocus();

            scrollbarH.Position = new Vector2i(ClientArea.Left, ClientArea.Bottom() - scrollbarH.ClientArea.Height);
            scrollbarV.Position = new Vector2i(ClientArea.Right() - scrollbarV.ClientArea.Width, ClientArea.Top);

            if (scrollbarV.IsVisible()) scrollbarH.size = Size.X - scrollbarV.ClientArea.Width;
            else scrollbarH.size = Size.X;

            if (scrollbarH.IsVisible()) scrollbarV.size = Size.Y - scrollbarH.ClientArea.Height;
            else scrollbarV.size = Size.Y;

            max_x = 0;
            max_y = 0;

            foreach (GuiComponent component in components)
            {
                if (component.Position.X + component.ClientArea.Width > max_x)
                    max_x = component.Position.X + component.ClientArea.Width;
                if (component.Position.Y + component.ClientArea.Height > max_y)
                    max_y = component.Position.Y + component.ClientArea.Height;
            }

            scrollbarH.max = (int) max_x - ClientArea.Width +
                             (max_y > clippingRI.Height ? scrollbarV.ClientArea.Width : 0);
            if (max_x > clippingRI.Height) scrollbarH.SetVisible(true);
            else scrollbarH.SetVisible(false);

            scrollbarV.max = (int) max_y - ClientArea.Height +
                             (max_x > clippingRI.Height ? scrollbarH.ClientArea.Height : 0);
            if (max_y > clippingRI.Height) scrollbarV.SetVisible(true);
            else scrollbarV.SetVisible(false);

            scrollbarH.Update(frameTime);
            scrollbarV.Update(frameTime);
        }
Esempio n. 5
0
 public override sealed void Update(float frameTime)
 {
     var listboxLeftBounds = _listboxLeft.GetLocalBounds();
     var listboxMainBounds = _listboxMain.GetLocalBounds();
     var listboxRightBounds = _listboxRight.GetLocalBounds();
     _clientAreaLeft = new IntRect(Position, new Vector2i((int)listboxLeftBounds.Width, (int)listboxLeftBounds.Height));
     _clientAreaMain = new IntRect(_clientAreaLeft.Right(), Position.Y,
                                   _width, (int)listboxMainBounds.Height);
     _clientAreaRight = new IntRect(new Vector2i(_clientAreaMain.Right(), Position.Y),
                                      new Vector2i((int)listboxRightBounds.Width, (int)listboxRightBounds.Height));
     ClientArea = new IntRect(Position,
                                new Vector2i(_clientAreaLeft.Width + _clientAreaMain.Width + _clientAreaRight.Width,
                                         Math.Max(Math.Max(_clientAreaLeft.Height, _clientAreaRight.Height),
                                                  _clientAreaMain.Height)));
     _selectedLabel.Position = new Vector2i(_clientAreaLeft.Right(),
                                         Position.Y + (int) (ClientArea.Height/2f) -
                                         (int) (_selectedLabel.Height/2f));
     _dropDown.Position = new Vector2i(ClientArea.Left + (int) ((ClientArea.Width - _dropDown.ClientArea.Width)/2f),
                                    ClientArea.Bottom());
     _dropDown.Update(frameTime);
 }
Esempio n. 6
0
 public static Box2i Convert(this IntRect rect)
 {
     return(new Box2i(rect.Left, rect.Top, rect.Right(), rect.Bottom()));
 }
Esempio n. 7
0
        private float GetVisibility(IntRect visibleRegion)
        {
            // Outside bounds
            if (visibleRegion.Top > _glyphArea.Bottom())
                return 0;
            if (visibleRegion.Bottom() < _glyphArea.Top)
                return 0;

            // Completely within bounds
            if (visibleRegion.Top < _glyphArea.Top
                && visibleRegion.Bottom() > _glyphArea.Bottom())
                return 1;;

            // Partially within bounds - fading out
            if (visibleRegion.Top > _glyphArea.Top)
                return (_glyphArea.Bottom() - visibleRegion.Top) / (float)(_glyphArea.Bottom() - _glyphArea.Top);

            // Partially within bounds - fading in
            return (float)(visibleRegion.Bottom() - _glyphArea.Top) / _glyphArea.Height;
        }