1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 14:24:10 +02:00

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.
This commit is contained in:
Joseph Battelle 2021-02-01 17:02:22 -08:00
parent e33ca41fd0
commit 9fbfcb7a07

View file

@ -5560,30 +5560,32 @@ namespace IDE
}); });
} }
public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func) public void WithDocumentTabbedViewsOf(BFWindow window, delegate void(DarkTabbedView) func)
{ {
for (int32 windowIdx = 0; windowIdx < mWindows.Count; windowIdx++) var widgetWindow = window as WidgetWindow;
{ if (widgetWindow != null)
var window = mWindows[windowIdx]; {
var widgetWindow = window as WidgetWindow; var darkDockingFrame = widgetWindow.mRootWidget as DarkDockingFrame;
if (widgetWindow != null) if (widgetWindow == mMainWindow)
{ darkDockingFrame = mDockingFrame;
var darkDockingFrame = widgetWindow.mRootWidget as DarkDockingFrame;
if (widgetWindow == mMainWindow)
darkDockingFrame = mDockingFrame;
if (darkDockingFrame != null) if (darkDockingFrame != null)
{ {
darkDockingFrame.WithAllDockedWidgets(scope (dockedWidget) => darkDockingFrame.WithAllDockedWidgets(scope (dockedWidget) =>
{ {
var tabbedView = dockedWidget as DarkTabbedView; var tabbedView = dockedWidget as DarkTabbedView;
if (tabbedView != null) if (tabbedView != null)
func(tabbedView); func(tabbedView);
}); });
} }
} }
} }
}
public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func)
{
for (let window in mWindows)
WithDocumentTabbedViewsOf(window, func);
}
public void EnsureDocumentArea() public void EnsureDocumentArea()
{ {
@ -5682,13 +5684,19 @@ namespace IDE
return null; return null;
} }
public void WithTabs(delegate void(TabbedView.TabButton) func) public void WithTabsOf(BFWindow window, delegate void(TabbedView.TabButton) func)
{ {
WithDocumentTabbedViews(scope (documentTabbedView) => WithDocumentTabbedViewsOf(window, scope (documentTabbedView) =>
{ {
documentTabbedView.WithTabs(func); 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) public TabbedView.TabButton GetTab(Widget content)
{ {
@ -5701,15 +5709,21 @@ namespace IDE
return tab; return tab;
} }
public void WithSourceViewPanels(delegate void(SourceViewPanel) func) public void WithSourceViewPanelsOf(BFWindow window, delegate void(SourceViewPanel) func)
{ {
WithTabs(scope (tab) => WithTabsOf(window, scope (tab) =>
{ {
var sourceViewPanel = tab.mContent as SourceViewPanel; var sourceViewPanel = tab.mContent as SourceViewPanel;
if (sourceViewPanel != null) if (sourceViewPanel != null)
func(sourceViewPanel); 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 TabbedView.TabButton SetupTab(TabbedView tabView, String name, float width, Widget content, bool ownsContent) // 2
{ {