diff --git a/src/+gui_tabs/add_tab.m b/src/+gui_tabs/add_tab.m index 37ecfb1337bc78f8f943e6e2ce3938c085ebd41c..106282a63300479ee694c77fca60e9fd3c3d1016 100644 --- a/src/+gui_tabs/add_tab.m +++ b/src/+gui_tabs/add_tab.m @@ -34,17 +34,7 @@ function [newTab, created] = add_tab(hObject, title) handles = guidata(hObject); if isfield(handles, 'tabGroup') == 0 - - hTabGroup = uitabgroup(handles.figure1,'Position',[0 0 1 1]); %, 'SelectionChangeFcn', {@selection_tab_changed}); - panel = handles.uipanel_welcome; - set(panel,'Visible','off'); - - drawnow; - handles.tabGroup = hTabGroup; - setappdata(0,'tabGroup', hTabGroup); - - % Update handles structure - guidata(hObject, handles); + handles = createTabGroup(handles, hObject); end created = 1; @@ -55,10 +45,11 @@ tab = checkIfExistsTab(tabGroup, title); if ~isempty(tab) % close existing tab so that it'll be redrawn gui_tabs.delete_tab(tab); -% set(handles.tabGroup, 'SelectedTab' , tab); -% newTab = tab; -% created = 0; -% return; + tabGroup = getappdata(0, 'tabGroup'); + if isempty(tabGroup) + handles = createTabGroup(handles, hObject); + tabGroup = getappdata(0, 'tabGroup'); + end end newTab = uitab(handles.tabGroup, 'Title', title); @@ -80,3 +71,16 @@ setappdata(0, 'tabGroup', tabGroup); end end end + +function handles = createTabGroup(handles, hObject) + hTabGroup = uitabgroup(handles.figure1,'Position',[0 0 1 1]); %, 'SelectionChangeFcn', {@selection_tab_changed}); + panel = handles.uipanel_welcome; + set(panel,'Visible','off'); + + drawnow; + handles.tabGroup = hTabGroup; + setappdata(0,'tabGroup', hTabGroup); + + % Update handles structure + guidata(hObject, handles); +end \ No newline at end of file