|  | @@ -437,7 +437,7 @@ int laGetReady(){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //tns_RegisterResourcesForSoftwareRender();
 | 
	
		
			
				|  |  |      la_RegisterGeneralProps();
 | 
	
		
			
				|  |  | -    la_RegisterInternalTemplates();
 | 
	
		
			
				|  |  | +    la_RegisterBuiltinTemplates();
 | 
	
		
			
				|  |  |      la_RegisterMainThemes();
 | 
	
		
			
				|  |  |      la_RegisterMainOperators();
 | 
	
		
			
				|  |  |      la_RegisterMainUiTypes();
 | 
	
	
		
			
				|  | @@ -466,6 +466,7 @@ int laGetReady(){
 | 
	
		
			
				|  |  |      laSaveProp("la.input_mapping");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      logPrint("Initialization Completed\n");
 | 
	
		
			
				|  |  | +    MAIN.InitDone=1;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void laShutoff(){
 | 
	
	
		
			
				|  | @@ -3296,17 +3297,6 @@ laUiList *laAddTabPage(laUiItem *ui, const char *Name){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      return uil;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -laUiList *laAddTabPageInternal(laUiItem *ui, const char *Name){
 | 
	
		
			
				|  |  | -    laUiList *uil = memAcquireSimple(sizeof(laUiList));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    if (!ui->Page) ui->Page = uil;
 | 
	
		
			
				|  |  | -    lstAppendItem(&ui->Subs, uil);
 | 
	
		
			
				|  |  | -    strSafeSet(&uil->TabName, Name);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    //laFirstColumn(uil);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    return uil;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  |  laUiList *la_AddInstancePage(laUiItem *ui, void *Instance, laWidget* Widget){
 | 
	
		
			
				|  |  |      laUiList *uil = memAcquireSimple(sizeof(laUiList));
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -3819,6 +3809,9 @@ laUiTemplate *laFindUiTemplate(char *Identifier){
 | 
	
		
			
				|  |  |      for (uit = MAIN.PanelTemplates.pFirst; uit; uit = uit->Item.pNext){
 | 
	
		
			
				|  |  |          if (!strcmp(uit->Identifier->Ptr, Identifier)) return uit;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    for (uit = MAIN.InitPanelTemplates.pFirst; uit; uit = uit->Item.pNext){
 | 
	
		
			
				|  |  | +        if (!strcmp(uit->Identifier->Ptr, Identifier)) return uit;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      return 0;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -3833,14 +3826,15 @@ void la_DestroyCanvasTemplate(laCanvasTemplate* uit){
 | 
	
		
			
				|  |  |      laKeyMapItem* kmi; while(kmi=lstPopItem(&uit->KeyMapper.Items)){ la_FreeKeyMapItem(kmi); }
 | 
	
		
			
				|  |  |      memFree(uit);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -laUiTemplate *laRegisterUiTemplate(char *Identifier, char* Title, laUiDefineFunc func,laPanelDetachedPropFunc PropFunc, laUiDefineFunc header){
 | 
	
		
			
				|  |  | +laUiTemplate *laRegisterUiTemplate(char *Identifier, char* Title, laUiDefineFunc func,laPanelDetachedPropFunc PropFunc, laUiDefineFunc header, char* NewCategory){
 | 
	
		
			
				|  |  |      laUiTemplate *uit = memAcquire(sizeof(laUiTemplate));
 | 
	
		
			
				|  |  |      strSafeSet(&uit->Identifier, Identifier);
 | 
	
		
			
				|  |  |      strSafeSet(&uit->Title, Title);
 | 
	
		
			
				|  |  | +    strSafeSet(&uit->CategoryName, NewCategory);
 | 
	
		
			
				|  |  |      uit->Define = func;
 | 
	
		
			
				|  |  |      uit->Header = header;
 | 
	
		
			
				|  |  |      uit->PropFunc = PropFunc;
 | 
	
		
			
				|  |  | -    lstAppendItem(&MAIN.PanelTemplates, uit);
 | 
	
		
			
				|  |  | +    if(MAIN.InitDone) lstAppendItem(&MAIN.PanelTemplates, uit); else lstAppendItem(&MAIN.InitPanelTemplates, uit);
 | 
	
		
			
				|  |  |      la_UDFAppendSharedTypePointer(Identifier, uit);
 | 
	
		
			
				|  |  |      return uit;
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -4326,8 +4320,8 @@ int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast
 | 
	
		
			
				|  |  |                  real ElementWidth = ElementLimit ? 1.0f / ElementLimit : 1.0;
 | 
	
		
			
				|  |  |                  int MaxB = ElementB;
 | 
	
		
			
				|  |  |                  int CanGetTheme = laCanGetTheme(ui->PP.LastPs->p);laTheme* OriginalTheme=MAIN.CurrentTheme;
 | 
	
		
			
				|  |  | -                int CanGetGap= laCanGetGap(ui->PP.LastPs->p);
 | 
	
		
			
				|  |  | -                int Gap=0;
 | 
	
		
			
				|  |  | +                int CanGetGap= laCanGetGap(ui->PP.LastPs->p); int Gap=0;
 | 
	
		
			
				|  |  | +                int CanGetCategory= laCanGetCategory(ui->PP.LastPs->p); char _cat[256]; char* cat=_cat; int GotCategory=0;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (!ElementLimit) RowPriority = 0;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -4352,6 +4346,15 @@ int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast
 | 
	
		
			
				|  |  |                          int g=laGetUiGap(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, ui->PP.EndInstance); g=g<0?0:g;
 | 
	
		
			
				|  |  |                          Gap=g*LA_RH;
 | 
	
		
			
				|  |  |                      }else Gap=0;
 | 
	
		
			
				|  |  | +                    if(CanGetCategory){ _cat[0]=0; cat=_cat; GotCategory=0;
 | 
	
		
			
				|  |  | +                        laGetCategory(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, ui->PP.EndInstance, _cat, &cat); if(cat[0]) GotCategory=1;
 | 
	
		
			
				|  |  | +                    }else GotCategory=0;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    if(GotCategory){ Begin+=LA_RH*1.5+bt->TM; 
 | 
	
		
			
				|  |  | +                        if (RowPriority){
 | 
	
		
			
				|  |  | +                            Row += 1; Col=0; Begin = ElementB+bt->TM+LA_RH*1.5+bt->TM;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      if (ElementLimit){
 | 
	
		
			
				|  |  |                          EL = tnsInterpolate(ui->TL, ui->TR, (Col)*ElementWidth);
 | 
	
	
		
			
				|  | @@ -4370,14 +4373,14 @@ int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast
 | 
	
		
			
				|  |  |                          if(FoundUil=la_GiveExistingPage(&TempPages, TInstance)){ lstAppendItem(&ui->Subs, FoundUil); iuil = FoundUil; }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      if (!iuil){
 | 
	
		
			
				|  |  | -                            la_AddInstancePage(ui, TInstance, 0);
 | 
	
		
			
				|  |  | +                            la_AddInstancePage(ui, TInstance, 0); if(GotCategory){ strSafeSet(&ui->Page->TabName,cat); }
 | 
	
		
			
				|  |  |                              la_CalcUiTopInfluence(&uil->Columns, ui);
 | 
	
		
			
				|  |  |                              if (Template) laMakeUiListFromTemplate(ui->Page, Template, &ParentPanel->PP, &ParentPanel->PropLinkPP, &ui->PP, 0, &uil->Columns, ui->TemplateContext);
 | 
	
		
			
				|  |  |                              SubB = la_UpdateUiListRecursive(ui->Page, Gap+Begin+(NoDecal?0:bt->TM), EL+(NoDecal?0:bt->LM), ER-(NoDecal?0:bt->RM), B, Fast, ParentPanel) +(NoDecal?0:bt->TM);
 | 
	
		
			
				|  |  |                              ElementB = RowPriority ? (SubB > ElementB ? SubB : ElementB) : SubB;
 | 
	
		
			
				|  |  |                              iuil = ui->Page->Item.pNext;
 | 
	
		
			
				|  |  |                      }else{
 | 
	
		
			
				|  |  | -                        la_CalcUiTopInfluence(&uil->Columns, ui);
 | 
	
		
			
				|  |  | +                        la_CalcUiTopInfluence(&uil->Columns, ui); if(GotCategory){ strSafeSet(&iuil->TabName,cat); }
 | 
	
		
			
				|  |  |                          SubB = la_UpdateUiListRecursive(iuil, Gap+Begin+(NoDecal?0:bt->TM), EL+(NoDecal?0:bt->LM), ER-(NoDecal?0:bt->RM), B, Fast, ParentPanel) + (NoDecal?0:bt->TM);
 | 
	
		
			
				|  |  |                          ElementB = RowPriority ? (SubB > ElementB ? SubB : ElementB) : SubB;
 | 
	
		
			
				|  |  |                          la_CalcUiItemInfluence(&uil->Columns, ui);
 | 
	
	
		
			
				|  | @@ -4968,6 +4971,11 @@ int la_DrawUiListRecursive(laUiListDraw *uild, laUiList *uil, int L, int R, int
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                    if(sub->TabName && sub->TabName->Ptr){
 | 
	
		
			
				|  |  | +                        tnsDrawStringAuto(sub->TabName->Ptr,laThemeColor(bt,LA_BT_DISABLED|LA_BT_TEXT),ui->L+bt->LM+bt->LP,ui->R,sub->U-LA_RH,LA_TEXT_MONO);
 | 
	
		
			
				|  |  | +                        tnsFlush();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                      if(CanGetTheme){
 | 
	
		
			
				|  |  |                          laTheme* t=laGetUiTheme(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, ui->PP.EndInstance);
 | 
	
		
			
				|  |  |                          la_SwitchThemeQuick(t, OriginalTheme);
 | 
	
	
		
			
				|  | @@ -6454,6 +6462,14 @@ int la_DrawWindow(laWindow *w){
 | 
	
		
			
				|  |  |      MAIN.CurrentWindow = w;
 | 
	
		
			
				|  |  |      la_WindowDefDraw(w, 0);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +int laFinalize(){
 | 
	
		
			
				|  |  | +    if(!laValidateProperties()){ laShutoff(); return 0; }
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    laUiTemplate* uit;
 | 
	
		
			
				|  |  | +    while(uit=lstPopItem(&MAIN.InitPanelTemplates)) lstAppendItem(&MAIN.PanelTemplates,uit);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    return 1;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  void laMainLoop(){
 | 
	
		
			
				|  |  |      laWindow *w = MAIN.Windows.pFirst, *NextW;
 | 
	
		
			
				|  |  |      laTimeRecorder FrameStartTime, FrameEndTime;
 | 
	
	
		
			
				|  | @@ -6461,12 +6477,10 @@ void laMainLoop(){
 | 
	
		
			
				|  |  |      real TimeInterval, Pause, TimeAccum = 0, FrameInterval;
 | 
	
		
			
				|  |  |      static int a = 0;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if(!laValidateProperties()){ laShutoff(); return; }
 | 
	
		
			
				|  |  | +    if(!laFinalize()) return;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      MAIN.DelayTriggered=1;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    laCopyToClipboard("Hello clipboard!");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      while (1){
 | 
	
		
			
				|  |  |          laRecordTime(&FrameStartTime);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -6511,4 +6525,4 @@ void laMainLoop(){
 | 
	
		
			
				|  |  |          MAIN.TimeAccum += (MAIN.LastFrameTime = Pause+TimeInterval);
 | 
	
		
			
				|  |  |          FrameInterval = 1.0 / MAIN.Animation.FrameRate;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +}
 |