Пример #1
0
        private void CreateDragBehaviour(Placement placement, Widget inputWidget, Widget contentWidget)
        {
            var db = new DragBehaviour(inputWidget, contentWidget, placement);

            db.OnUndock += (positionOffset, windowPosition) => {
                var panelWindow     = (WindowWidget)contentWidget.GetRoot();
                var windowPlacement = Model.GetWindowByPlacement(placement);
                if (windowPlacement.Root.GetPanelPlacements().Count(p => !p.Hidden) > 1)
                {
                    var globalSize = placement.CalcGlobalStretch() * panelWindow.Size;
                    var wrapper    = new WindowPlacement {
                        Size = new Vector2(Mathf.Max(panelMinWidth, globalSize.X), globalSize.Y)
                    };
                    placement.Unlink();
                    windowPlacement.Root.RemoveRedundantNodes();
                    Model.AddWindow(wrapper);
                    wrapper.Placements.Add(placement);
                    wrapper.Stretches.Add(1);
#if MAC
                    wrapper.Position = windowPosition - new Vector2(0, wrapper.Size.Y);
#else
                    wrapper.Position = windowPosition;
#endif
                    RefreshWindow(windowPlacement);
                    CreateFloatingWindow(wrapper);
                    RefreshWindow(wrapper);
                }
                WindowDragBehaviour.CreateFor(placement, positionOffset);
            };
        }
Пример #2
0
        public void DockPlacementTo(Placement placement, Placement target, DockSite site, float stretch)
        {
            if (site == DockSite.Fill)
            {
                target.SwitchType(
                    targetPanelPlacement => {
                    if (placement is TabBarPlacement tabBarPlacement)
                    {
                        DockPlacementTo(tabBarPlacement, targetPanelPlacement);
                    }
                    if (placement is PanelPlacement panelPlacement)
                    {
                        DockPlacementTo(panelPlacement, targetPanelPlacement);
                    }
                },
                    targetTabBarPlacement => {
                    if (placement is TabBarPlacement tabBarPlacement)
                    {
                        DockPlacementTo(tabBarPlacement, targetTabBarPlacement);
                    }
                    if (placement is PanelPlacement panelPlacement)
                    {
                        targetTabBarPlacement.Placements.Add(panelPlacement);
                    }
                },
                    targetSplitPlacement => targetSplitPlacement.Append(placement)
                    );
                return;
            }
            if (target.Parent is TabBarPlacement)
            {
                target = target.Parent;
            }
            var parent         = (SplitPlacement)target.Parent;
            var splitPlacement = new SplitPlacement();
            var isFirst        = site == DockSite.Left || site == DockSite.Top;
            var wasFirst       = parent.FirstChild == target;

            target.Unlink();
            if (isFirst)
            {
                splitPlacement.Initialize(placement, target, site.GetSeparator(), stretch);
            }
            else
            {
                splitPlacement.Initialize(target, placement, site.GetSeparator(), 1 - stretch);
            }
            if (wasFirst)
            {
                parent.FirstChild = splitPlacement;
            }
            else
            {
                parent.SecondChild = splitPlacement;
            }
        }
Пример #3
0
        public void DockPlacementTo(Placement placement, Placement target, DockSite site, float stretch)
        {
            var windowPlacement = Model.GetWindowByPlacement(placement);

            placement.Unlink();
            Model.DockPlacementTo(placement, target, site, stretch);
            if (!windowPlacement.Root.GetDescendantPanels().Any())
            {
                Model.RemoveWindow(windowPlacement);
                CloseWindow(windowPlacement.WindowWidget.Window);
            }
            else
            {
                windowPlacement.Root.RemoveRedundantNodes();
                RefreshWindow(windowPlacement);
            }
            RefreshWindow(Model.GetWindowByPlacement(target));
        }
Пример #4
0
        public void DockPlacementTo(Placement placement, Placement target, DockSite site, float stretch)
        {
            var windowPlacement = Model.GetWindowByPlacement(placement);

            if (placement == windowPlacement)
            {
                if (windowPlacement.Placements.Count == 1)
                {
                    placement = windowPlacement.Placements[0];
                }
                else
                {
                    var linearPlacement = new LinearPlacement(windowPlacement.Direction);
                    for (var i = 0; i < windowPlacement.Placements.Count; i++)
                    {
                        linearPlacement.Placements.Add(windowPlacement.Placements[i].Clone());
                        linearPlacement.Stretches.Add(windowPlacement.Stretches[i]);
                    }
                    placement = linearPlacement;
                }
                windowPlacement.Placements.Clear();
            }
            placement.Unlink();
            Model.DockPlacementTo(placement, target, site, stretch);
            if (windowPlacement != null)
            {
                windowPlacement.Root.RemoveRedundantNodes();
                if (!windowPlacement.Root.GetPanelPlacements().Any())
                {
                    Model.RemoveWindow(windowPlacement);
                    CloseWindow(windowPlacement.WindowWidget.Window);
                }
                else
                {
                    RefreshWindow(windowPlacement);
                }
                RefreshWindow(Model.GetWindowByPlacement(target));
            }
        }