Exemplo n.º 1
0
        public void Load(IPanel parent)
        {
            _parent = parent;
            var factory = _game.Factory;

            _searchBox             = factory.UI.GetTextBox("GameDebugInspectorSearchBox", 0f, parent.Height, parent, "Search...", width: parent.Width, height: 30f);
            _searchBox.RenderLayer = _layer;
            _searchBox.Border      = AGSBorders.SolidColor(Colors.Green, 2f);
            _searchBox.Tint        = Colors.Transparent;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            var height = parent.Height - _searchBox.Height;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugInspectorScrollingPanel", parent.Width, height, 0f, height, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 1f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = AGSBorders.SolidColor(Colors.Green, 2f);

            _panel             = factory.UI.GetPanel("GameDebugInspectorPanel", parent.Width, _padding, 0f, height - _padding, _scrollingPanel);
            _panel.Tint        = Colors.Transparent;
            _panel.RenderLayer = _layer;
            var treeView = _panel.AddComponent <ITreeViewComponent>();

            treeView.SkipRenderingRoot = true;
            treeView.NodeViewProvider  = new InspectorTreeNodeProvider(treeView.NodeViewProvider, _game.Factory);

            Inspector = new AGSInspector(_game.Factory, _game.Settings);
            _panel.AddComponent <IInspectorComponent>(Inspector);
            factory.UI.CreateScrollingPanel(_scrollingPanel);
            _parent.Bind <IScaleComponent>(c => c.PropertyChanged += onParentPanelScaleChanged,
                                           c => c.PropertyChanged -= onParentPanelScaleChanged);
        }
Exemplo n.º 2
0
        public void Load(IPanel parent, IForm parentForm)
        {
            _parent = parent;
            var factory = _editor.Editor.Factory;

            _searchBox             = factory.UI.GetTextBox($"{_idPrefix}_InspectorSearchBox", 0f, parent.Height, parent, "Search...", width: parent.Width, height: 30f);
            _searchBox.RenderLayer = _layer;
            _searchBox.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _searchBox.Tint        = GameViewColors.Textbox;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            var height = parent.Height - _searchBox.Height - _gutterSize;

            _scrollingPanel             = factory.UI.GetPanel($"{_idPrefix}_InspectorScrollingPanel", parent.Width - _gutterSize, height, 0f, parent.Height - _searchBox.Height, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 1f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _contentsPanel = factory.UI.CreateScrollingPanel(_scrollingPanel);

            _treePanel             = factory.UI.GetPanel($"{_idPrefix}_InspectorPanel", 0f, 0f, 0f, _contentsPanel.Height - _padding, _contentsPanel);
            _treePanel.Tint        = Colors.Transparent;
            _treePanel.RenderLayer = _layer;
            _treePanel.Pivot       = new PointF(0f, 1f);
            var treeView = _treePanel.AddComponent <ITreeViewComponent>();

            treeView.SkipRenderingRoot = true;

            Inspector = new AGSInspector(_editor.Editor.Factory, _editor.Game.Settings, _editor.Editor.Settings, _actions, _editor.Project.Model, _editor, parentForm);
            _treePanel.AddComponent <IInspectorComponent>(Inspector);
            Inspector.ScrollingContainer = _contentsPanel;

            _inspectorNodeView = new InspectorTreeNodeProvider(treeView.NodeViewProvider,
                                                               _editor.Editor.Events, _treePanel);
            _inspectorNodeView.Resize(_contentsPanel.Width);
            treeView.NodeViewProvider = _inspectorNodeView;

            _parent.Bind <IScaleComponent>(c => c.PropertyChanged += onParentPanelScaleChanged,
                                           c => c.PropertyChanged -= onParentPanelScaleChanged);
        }
Exemplo n.º 3
0
        public void CreateScrollingPanel(IPanel panel)
        {
            panel.AddComponent <ICropChildrenComponent>();
            var box = panel.AddComponent <IBoundingBoxWithChildrenComponent>();
            IScrollingComponent scroll = panel.AddComponent <IScrollingComponent>();

            var horizSlider = GetSlider($"{panel.ID}_HorizontalSlider", null, null, 0f, 0f, 0f, panel);

            horizSlider.HandleGraphics.Pivot  = new PointF(0f, 0.5f);
            horizSlider.Direction             = SliderDirection.LeftToRight;
            horizSlider.Graphics.Pivot        = new PointF(0f, 0.5f);
            horizSlider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
            horizSlider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
            HoverEffect.Add(horizSlider.Graphics, Colors.Gray, Colors.LightGray);
            HoverEffect.Add(horizSlider.HandleGraphics, Colors.DarkGray, Colors.WhiteSmoke);

            var verSlider = GetSlider($"{panel.ID}_VerticalSlider", null, null, 0f, 0f, 0f, panel);

            verSlider.HandleGraphics.Pivot  = new PointF(0.5f, 0f);
            verSlider.Direction             = SliderDirection.TopToBottom;
            verSlider.Graphics.Pivot        = new PointF(0.5f, 0f);
            verSlider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
            verSlider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
            HoverEffect.Add(verSlider.Graphics, Colors.Gray, Colors.LightGray);
            HoverEffect.Add(verSlider.HandleGraphics, Colors.DarkGray, Colors.WhiteSmoke);

            box.EntitiesToSkip.AddRange(new List <string> {
                horizSlider.ID, horizSlider.HandleGraphics.ID, horizSlider.Graphics.ID,
                verSlider.ID, verSlider.HandleGraphics.ID, verSlider.Graphics.ID
            });

            PropertyChangedEventHandler resize = (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Width) && args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                const float widthFactor  = 25f;
                const float heightFactor = 25f;
                float       widthUnit    = panel.Width / widthFactor;
                float       heightUnit   = panel.Height / heightFactor;
                horizSlider.Graphics.Image       = new EmptyImage(panel.Width - widthUnit * 2f, heightUnit / 2f);
                horizSlider.HandleGraphics.Image = new EmptyImage(widthUnit, heightUnit);
                verSlider.Graphics.Image         = new EmptyImage(widthUnit / 2f, panel.Height - heightUnit * 4f);
                verSlider.HandleGraphics.Image   = new EmptyImage(widthUnit, heightUnit);
                horizSlider.X = -panel.Width * panel.Pivot.X + widthUnit;
                horizSlider.Y = heightUnit;
                verSlider.X   = panel.Width - widthUnit;
                verSlider.Y   = heightUnit * 2f;
            };

            panel.Bind <IStackLayoutComponent>(
                c => c.EntitiesToIgnore.AddRange(new List <string> {
                verSlider.ID, horizSlider.ID
            }), _ => {});

            resize(this, new PropertyChangedEventArgs(nameof(IScaleComponent.Width)));
            scroll.HorizontalScrollBar = horizSlider;
            scroll.VerticalScrollBar   = verSlider;

            panel.Bind <IScaleComponent>(c => c.PropertyChanged += resize, c => c.PropertyChanged -= resize);
        }