From 9fbfcb7a07ad3908627db4e4a332639944335e47 Mon Sep 17 00:00:00 2001 From: Joseph Battelle Date: Mon, 1 Feb 2021 17:02:22 -0800 Subject: [PATCH] Per-window SourceViewPanel and Tab visitors In order to fix an issue with closing secondary windows with changed, inactive 'SourceViewPanel's we need a way to visit the tabs of just a specific Window. The current 'SecondaryAllowClose' logic that relies on checking 'mWidgetWindow' is broken. This commit just introduces the needed utility methods and refactors the all-window methods to use them. --- IDE/src/IDEApp.bf | 92 +++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index e2b03a36..f86ba07a 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -5560,30 +5560,32 @@ namespace IDE }); } - public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func) - { - for (int32 windowIdx = 0; windowIdx < mWindows.Count; windowIdx++) - { - var window = mWindows[windowIdx]; - var widgetWindow = window as WidgetWindow; - if (widgetWindow != null) - { - var darkDockingFrame = widgetWindow.mRootWidget as DarkDockingFrame; - if (widgetWindow == mMainWindow) - darkDockingFrame = mDockingFrame; + public void WithDocumentTabbedViewsOf(BFWindow window, delegate void(DarkTabbedView) func) + { + var widgetWindow = window as WidgetWindow; + if (widgetWindow != null) + { + var darkDockingFrame = widgetWindow.mRootWidget as DarkDockingFrame; + if (widgetWindow == mMainWindow) + darkDockingFrame = mDockingFrame; - if (darkDockingFrame != null) - { - darkDockingFrame.WithAllDockedWidgets(scope (dockedWidget) => - { - var tabbedView = dockedWidget as DarkTabbedView; - if (tabbedView != null) - func(tabbedView); - }); - } - } - } - } + if (darkDockingFrame != null) + { + darkDockingFrame.WithAllDockedWidgets(scope (dockedWidget) => + { + var tabbedView = dockedWidget as DarkTabbedView; + if (tabbedView != null) + func(tabbedView); + }); + } + } + } + + public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func) + { + for (let window in mWindows) + WithDocumentTabbedViewsOf(window, func); + } public void EnsureDocumentArea() { @@ -5682,13 +5684,19 @@ namespace IDE return null; } - public void WithTabs(delegate void(TabbedView.TabButton) func) - { - WithDocumentTabbedViews(scope (documentTabbedView) => - { - documentTabbedView.WithTabs(func); - }); - } + public void WithTabsOf(BFWindow window, delegate void(TabbedView.TabButton) func) + { + WithDocumentTabbedViewsOf(window, scope (documentTabbedView) => + { + documentTabbedView.WithTabs(func); + }); + } + + public void WithTabs(delegate void(TabbedView.TabButton) func) + { + for (let window in mWindows) + WithTabsOf(window, func); + } public TabbedView.TabButton GetTab(Widget content) { @@ -5701,15 +5709,21 @@ namespace IDE return tab; } - public void WithSourceViewPanels(delegate void(SourceViewPanel) func) - { - WithTabs(scope (tab) => - { - var sourceViewPanel = tab.mContent as SourceViewPanel; - if (sourceViewPanel != null) - func(sourceViewPanel); - }); - } + public void WithSourceViewPanelsOf(BFWindow window, delegate void(SourceViewPanel) func) + { + WithTabsOf(window, scope (tab) => + { + var sourceViewPanel = tab.mContent as SourceViewPanel; + if (sourceViewPanel != null) + func(sourceViewPanel); + }); + } + + public void WithSourceViewPanels(delegate void(SourceViewPanel) func) + { + for (let window in mWindows) + WithSourceViewPanelsOf(window, func); + } TabbedView.TabButton SetupTab(TabbedView tabView, String name, float width, Widget content, bool ownsContent) // 2 {