public GtkShellDocumentViewContainerSplit(DocumentViewContainerMode mode)
 {
     this.mode = mode;
     paned     = CreatePaned();
     paned.Show();
     paned.SizeAllocated += Paned_SizeAllocated;
 }
Esempio n. 2
0
        private void SetLastMode()
        {
            var container = DocumentView as DocumentViewContainer;

            if (container != null)
            {
                s_lastMode = container.CurrentMode;
                s_lastView = ReferenceEquals(container.Views[0], container.ActiveView) ? 0 : 1;
            }
        }
Esempio n. 3
0
 void TabActivated(object s, EventArgs args)
 {
     if (hasSplit && tabstrip.ActiveTab == tabstrip.TabCount - 1)
     {
         CurrentMode = DocumentViewContainerMode.VerticalSplit;
     }
     else
     {
         var tab = (Tab)s;
         SetCurrentMode(DocumentViewContainerMode.Tabs, (GtkShellDocumentViewItem)tab.Tag);
         currentContainer.ActiveView = (GtkShellDocumentViewItem)tab.Tag;
     }
 }
        void TabActivated(object s, EventArgs args)
        {
            var tab = (Tab)s;

            if (hasSplit && tab.Tag == null)
            {
                // If Tag is null it means it's clicking on the "Split" tab
                CurrentMode = DocumentViewContainerMode.VerticalSplit;
            }
            else
            {
                SetCurrentMode(DocumentViewContainerMode.Tabs, (GtkShellDocumentViewItem)tab.Tag);
                ShowChildView((GtkShellDocumentViewItem)tab.Tag);
            }
            // Make this container is visible on its parent
            ParentContainer?.ShowChildView(this);
        }
Esempio n. 5
0
 public void SetCurrentMode(DocumentViewContainerMode currentMode)
 {
 }
 public void SetSupportedModes(DocumentViewContainerMode supportedModes)
 {
     this.supportedModes = supportedModes;
     UpdateTabstrip();
 }
        public void SetCurrentMode(DocumentViewContainerMode mode, GtkShellDocumentViewItem newActive)
        {
            if (this.currentMode == mode)
            {
                return;
            }

            // Save current split sizes
            if (currentContainer is GtkShellDocumentViewContainerSplit split)
            {
                splitSizes = split.GetRelativeSplitSizes();
            }

            this.currentMode = mode;

            GtkShellDocumentViewItem        activeView = null;
            List <GtkShellDocumentViewItem> allViews   = null;

            if (currentContainer != null)
            {
                activeView = currentContainer.ActiveView;
                currentContainer.ActiveViewChanged -= Container_ActiveViewChanged;
                allViews = currentContainer.GetAllViews().ToList();
                currentContainer.Widget.Hide();
                currentContainer.RemoveAllViews();
            }

            if (mode == DocumentViewContainerMode.Tabs)
            {
                if (tabsContainer == null)
                {
                    tabsContainer = new GtkShellDocumentViewContainerTabs();
                    rootTabsBox.PackStart(tabsContainer.Widget, true, true, 0);
                }
                currentContainer = tabsContainer;
            }
            else
            {
                if (splitContainer == null)
                {
                    splitContainer = new GtkShellDocumentViewContainerSplit(mode);
                    rootTabsBox.PackStart(splitContainer.Widget, true, true, 0);
                }
                currentContainer = splitContainer;
                if (hasSplit)
                {
                    tabstrip.ActiveTab = tabstrip.TabCount - 1;
                }
            }

            if (allViews != null)
            {
                currentContainer.AddViews(allViews);
            }

            // Restore current split sizes
            if (splitSizes != null && currentContainer is GtkShellDocumentViewContainerSplit newSplit)
            {
                newSplit.SetRelativeSplitSizes(splitSizes);
            }

            currentContainer.ActiveView         = newActive ?? activeView;
            currentContainer.ActiveViewChanged += Container_ActiveViewChanged;
            currentContainer.Widget.Show();

            if (newActive != activeView)
            {
                ActiveViewChanged?.Invoke(this, EventArgs.Empty);
            }

            CurrentModeChanged?.Invoke(this, EventArgs.Empty);
        }
        public async Task WithSplits(DocumentViewContainerMode mode)
        {
            var controller = new ContentVisibleEventWithContainerTestController();

            controller.Mode = mode;

            await controller.Initialize(new ModelDescriptor());

            var doc = await documentManager.OpenDocument(controller);

            var view = await controller.GetDocumentView();

            Assert.IsTrue(controller.View1.ContentVisible);
            Assert.IsTrue(controller.View2.ContentVisible);
            Assert.IsTrue(controller.View3.ContentVisible);

            Assert.AreEqual(1, controller.View1_VisibleChangeEvents);
            Assert.AreEqual(1, controller.View2_VisibleChangeEvents);
            Assert.AreEqual(1, controller.View3_VisibleChangeEvents);

            controller.View3.SetActive();

            Assert.IsTrue(controller.View1.ContentVisible);
            Assert.IsTrue(controller.View2.ContentVisible);
            Assert.IsTrue(controller.View3.ContentVisible);

            Assert.AreEqual(1, controller.View1_VisibleChangeEvents);
            Assert.AreEqual(1, controller.View2_VisibleChangeEvents);
            Assert.AreEqual(1, controller.View3_VisibleChangeEvents);

            controller.View1.SetActive();

            Assert.IsTrue(controller.View1.ContentVisible);
            Assert.IsTrue(controller.View2.ContentVisible);
            Assert.IsTrue(controller.View3.ContentVisible);

            Assert.AreEqual(1, controller.View1_VisibleChangeEvents);
            Assert.AreEqual(1, controller.View2_VisibleChangeEvents);
            Assert.AreEqual(1, controller.View3_VisibleChangeEvents);

            var extraView = new DocumentViewContent(() => new DummyControl());

            controller.Container.Views.Add(extraView);
            Assert.IsTrue(extraView.ContentVisible);

            controller.Container.Views.Remove(extraView);
            Assert.IsFalse(extraView.ContentVisible);

            var doc2 = await documentManager.OpenDocument(new ContentVisibleEventWithContainerTestController());

            doc2.Select();

            Assert.IsFalse(controller.View1.ContentVisible);
            Assert.IsFalse(controller.View2.ContentVisible);
            Assert.IsFalse(controller.View3.ContentVisible);

            Assert.AreEqual(2, controller.View1_VisibleChangeEvents);
            Assert.AreEqual(2, controller.View2_VisibleChangeEvents);
            Assert.AreEqual(2, controller.View3_VisibleChangeEvents);

            await doc.Close(true);

            await doc2.Close(true);
        }