*/}}
Bladeren bron

tab and margin fix.

YimingWu 1 jaar geleden
bovenliggende
commit
02e9a1bd01
4 gewijzigde bestanden met toevoegingen van 61 en 77 verwijderingen
  1. 23 19
      la_kernel.c
  2. 1 1
      resources/la_operators.c
  3. 8 6
      resources/la_templates.c
  4. 29 51
      resources/la_widgets.c

+ 23 - 19
la_kernel.c

@@ -1702,9 +1702,11 @@ void laEnsurePanelInBound(laPanel *p, laUiList *uil){
     }else{
         if (p->X+p->W < LA_RH*5) p->X = LA_RH*5-+p->W;
         if (p->Y < 0) p->Y = 0;
-        if (p->X > cw-LA_RH*2) p->X = cw-LA_RH*2;
-        if (p->Y > ch-LA_RH*2) p->Y = ch-LA_RH;
-        if (p->W > cw){ p->W = cw; } if (p->H > ch){ p->H = ch; }
+        if ((!p->Block)&&(!p->IsMenuPanel)){
+            int cw2=cw-LA_RH*2,ch2=ch-LA_RH*2;
+            if (p->X > cw2){ p->X = cw2; } if (p->Y > ch2){ p->Y = ch2; }
+            if (p->W > cw2){ p->W = cw2; } if (p->H > ch2){ p->H = ch2; }
+        }
     }
 
     if((!p->IsMenuPanel) && (p->Mode!=LA_PANEL_FLOATING_PASSIVE)){
@@ -1723,6 +1725,15 @@ void laEnsurePanelInBound(laPanel *p, laUiList *uil){
 
     if (p->OffScr){ tnsEnsureOffscreenStatus(p->OffScr, p->W,p->H); }
 }
+void laPlacePanelForCreation(laPanel *p){
+    int cw = MAIN.CurrentWindow->CW; int ch = MAIN.CurrentWindow->CH; int PH = p->TH;
+    if ((!p->Block)&&(!p->IsMenuPanel)&&(!p->Parent)){
+        if (p->X+p->W > cw-LA_RH){ p->X = cw-LA_RH-p->W; }
+        if (p->Y+p->H > ch-LA_RH){ p->Y = ch-LA_RH-p->H; }
+        if (p->X < LA_RH){ p->X = LA_RH; } if (p->Y < LA_RH){ p->Y = LA_RH; }
+        p->TX=p->X; p->TY=p->Y;
+    }
+}
 void la_SetPanelMatrix(laPanel *p, laBoxedTheme *bt){
     tnsDrawToOffscreen(p->OffScr, 1, 0);
     tnsViewportWithScissor(0, 0, p->W, p->H);
@@ -2668,15 +2679,11 @@ laPanel *la_NewPanel(laUiTemplate* uit, int X, int Y, int W, int H, int MaxW, in
     p->W = p->TW = (W < 0 ? CW + W - p->X : W);
     p->H = p->TH = (H < 0 ? CH + H - p->Y : H);
 
-    p->MaxW = MaxW;
-    p->MaxH = MaxH;
-    p->MinW = MinW;
-    p->MinH = MinH;
+    p->MaxW = MaxW; p->MaxH = MaxH;
+    p->MinW = MinW; p->MinH = MinH;
 
-    p->SL = SnapL;
-    p->ST = SnapT;
-    p->SR = SnapR;
-    p->SB = SnapB;
+    p->SL = SnapL; p->ST = SnapT;
+    p->SR = SnapR; p->SB = SnapB;
 
     if (p->SR) p->X = CW - p->W - p->SR;
     if (p->SB) p->Y = CH - p->H - p->SB;
@@ -2722,12 +2729,8 @@ laPanel *laCreatePanelT(laBlock *b, laUiTemplate* uit){
 
     p->TitleWidth = tnsStringGetWidth(transLate(p->Title->Ptr), 0, 0);
 
-    while (b->B1){
-        b = b->B1;
-    }
-    lstPushItem(&b->Panels, p);
-    p->Block = b;
-    b->CurrentPanel = p;
+    while (b->B1){ b = b->B1; } lstPushItem(&b->Panels, p);
+    p->Block = b; b->CurrentPanel = p;
 
     if(uit->PropFunc){ uit->PropFunc(p); }
     uit->Define(&p->UI, &p->PP, &p->PropLinkPP, 0, 0);
@@ -2746,6 +2749,8 @@ laPanel *laCreateTopPanel(laWindow *w, char *template_id, int X, int Y, int W, i
     laPanel *p = la_NewPanel(uit, X, Y, W, H, MaxW, MaxH, MinW, MinH, SnapL, SnapR, SnapT, SnapB);
     p->Mode = LA_PANEL_FLOATING_TOP;
 
+    laPlacePanelForCreation(p);
+
     if(uit){
         laui_DefaultPanelTitleBar(&p->TitleBar, &p->PP, &p->PropLinkPP, p->PanelTemplate->Header);
     }
@@ -2755,8 +2760,7 @@ laPanel *laCreateTopPanel(laWindow *w, char *template_id, int X, int Y, int W, i
     return p;
 }
 void laShowPanel(laPanel *p){
-    p->Show = 1;
-    laNotifyUsers("la.windows.panels_hidden");
+    p->Show = 1; laNotifyUsers("la.windows.panels_hidden");
 }
 void laShowPanelWithDropDownEffect(laPanel *p){
     laShowPanel(p);

+ 1 - 1
resources/la_operators.c

@@ -1625,7 +1625,7 @@ int la_ScrollPanel(laGeneralUiExtraData*ex, laPanel*p, laEvent* e){
                                 uuil->U, upui->B-(*upui->Type->Theme)->BM-(uuil->ScrollerShownH?(LA_SCROLL_W+(*p->BT)->BM):0)))) break; }
                     lip=lip->Item.pPrev; uuil=lip->uil;  upui=lip->Item.pPrev?((laUiListRecord*)lip->Item.pPrev)->pui:0; 
                 }
-                if(!ran) laPanUiListAuto(p->MenuRefer?p->MenuRefer:&p->UI, 0, dir*MAIN.ScrollingSpeed*LA_RH, 0, p->W, p->TitleBar.B, p->H-(*p->BT)->BM);
+                if(!ran) laPanUiListAuto(p->MenuRefer?p->MenuRefer:&p->UI, 0, dir*MAIN.ScrollingSpeed*LA_RH, 0, p->W, p->TitleBar.B+(*p->BT)->TM, p->H-(*p->BT)->BM);
                 laRedrawCurrentPanel();
                 ret= 1;
             }

+ 8 - 6
resources/la_templates.c

@@ -1280,12 +1280,14 @@ void laui_UserPreference(laUiList *uil, laPropPack *Base, laPropPack *OperatorIn
             laShowItemFull(muil, mcr, 0, "LA_refresh_controllers",0,"text=Refresh",0,0);
 #endif
         }
-        muil = laAddTabPage(bracket, "Audio");{
-            mc = laFirstColumn(muil); laSplitColumn(muil, mc, 0.5);
-            mcl = laLeftColumn(mc, 0); mcr = laRightColumn(mc, 0);
-            laShowLabel(muil,mc,"Audio Device:",0,0);
-            laShowItemFull(muil,mcl,0,"la.audio.current_audio_device",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
-            laShowItem(muil,mcr,0,"LA_refresh_audio_devices");
+        if(MAIN.InitArgs.HasAudio){
+            muil = laAddTabPage(bracket, "Audio");{
+                mc = laFirstColumn(muil); laSplitColumn(muil, mc, 0.5);
+                mcl = laLeftColumn(mc, 0); mcr = laRightColumn(mc, 0);
+                laShowLabel(muil,mc,"Audio Device:",0,0);
+                laShowItemFull(muil,mcl,0,"la.audio.current_audio_device",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
+                laShowItem(muil,mcr,0,"LA_refresh_audio_devices");
+            }
         }
 
         muil = laAddTabPage(bracket, "Resource");{

+ 29 - 51
resources/la_widgets.c

@@ -445,63 +445,45 @@ void la_GroupDraw(laUiItem *ui, int h){
 void la_TabDraw(laUiItem *ui, int h){
     char temp[128] = {0};
     laBoxedTheme *bt = (*ui->Type->Theme);
-    laUiList *uil;
-    int count = 0;
-    int w; // = (ui->R - ui->L) / count;
-    int page = 0;
-    int l = ui->L;
-
-    for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
-        count++;
-    }
+    laUiList *uil; int count = 0, page = 0;real w, l = ui->L;
 
-    w = (ui->R - ui->L) / (count == 0 ? 1 : count);
+    for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
+    w = (real)(ui->R - ui->L) / (count == 0 ? 1 : count);
 
+    real* bkg=laThemeColor(bt,LA_BT_NORMAL);
     int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
     if(!NoDecal){
         tnsUseNoTexture();
-        tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
-        tnsVertex2d(ui->L, ui->U);
-        tnsVertex2d(ui->R, ui->U);
-        tnsVertex2d(ui->R, ui->B);
-        tnsVertex2d(ui->L, ui->B);
+        tnsColor4d(LA_COLOR3(bkg),bkg[3]*0.7);
+        tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
+        tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
         tnsPackAs(GL_TRIANGLE_FAN);
-        tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
-        tnsVertex2d(ui->L, ui->U + h);
-        tnsVertex2d(ui->L, ui->B);
-        tnsVertex2d(ui->R, ui->B);
-        tnsVertex2d(ui->R, ui->U + h);
-        tnsPackAs(GL_LINE_LOOP);
+        real* bc=laThemeColor(bt,LA_BT_BORDER); real bcolor[24];
+        tnsVectorCopy4d(bc,bcolor); tnsVectorSet4(&bcolor[4],bc[0],bc[1],bc[2],bc[3]*0.6);
+        tnsVectorCopy4d(&bcolor[4],&bcolor[8]);
+        tnsVectorCopy4d(&bcolor[4],&bcolor[12]);
+        tnsVectorCopy4d(&bcolor[4],&bcolor[16]);
+        tnsVectorCopy4d(bcolor,&bcolor[20]);
+        tnsVertex2d(ui->L, ui->U + h); tnsVertex2d(ui->L, TNS_MIN2(ui->U+h*3,ui->B)); tnsVertex2d(ui->L, ui->B);
+        tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->R, TNS_MIN2(ui->U+h*3,ui->B)); tnsVertex2d(ui->R, ui->U + h);
+        tnsColorArray4d(bcolor,6);
+        tnsPackAs(GL_LINE_STRIP);
     }
 
     for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
-        l = page * w;
-        if (uil != ui->Page){
-            tnsUseNoTexture();
+        l = page*w; int IsThisPage=(uil==ui->Page);
+        tnsUseNoTexture();
+        if(!IsThisPage){
             tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
-            tnsVertex2d(ui->L + l, ui->U);
-            tnsVertex2d(ui->L + l + w, ui->U);
-            tnsVertex2d(ui->L + l + w, ui->U + h);
-            tnsVertex2d(ui->L + l, ui->U + h);
-            tnsPackAs(GL_TRIANGLE_FAN);
-            tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
-            tnsVertex2d(ui->L + l, ui->U + h);
-            tnsVertex2d(ui->L + l, ui->U);
-            tnsVertex2d(ui->L + l + w, ui->U);
-            tnsVertex2d(ui->L + l + w, ui->U + h);
-            tnsPackAs(GL_LINE_STRIP);
-            tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,LA_BT_TEXT), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
-        }else{
-            tnsUseNoTexture();
-            tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
-            tnsVertex2d(ui->L + l, ui->U);
-            tnsVertex2d(ui->L + l + w, ui->U);
-            tnsVertex2d(ui->L + l + w, ui->U + h);
-            tnsVertex2d(ui->L + l, ui->U + h);
+            tnsVertex2d(ui->L + l, ui->U); tnsVertex2d(ui->L + l + w, ui->U);
+            tnsVertex2d(ui->L + l + w, ui->U + h); tnsVertex2d(ui->L + l, ui->U + h);
             tnsPackAs(GL_TRIANGLE_FAN);
-            tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,LA_BT_TEXT_ACTIVE), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
         }
-
+        tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
+        tnsVertex2d(ui->L + l, ui->U + h); tnsVertex2d(ui->L + l, ui->U);
+        tnsVertex2d(ui->L + l + w, ui->U); tnsVertex2d(ui->L + l + w, ui->U + h);
+        tnsPackAs(IsThisPage?GL_LINE_STRIP:GL_LINE_LOOP);
+        tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,IsThisPage?LA_BT_BORDER:LA_BT_TEXT), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
         page++;
     }
     tnsFlush();
@@ -2705,15 +2687,11 @@ int OPMOD_TabSelector(laOperator *a, laEvent *e){
     int it = 0;
     int page;
 
-    if (!laIsInUiItem(ui, e->x, e->y) || (!laIsInBound(e->x, e->y, ui->L, ui->R, ui->U, ui->U+LA_RH))){
-        return LA_FINISHED;
-    }
+    if (!laIsInBound(e->x, e->y, ui->L, ui->R, ui->U, ui->U+LA_RH)){ return LA_FINISHED; }
 
     if (e->Type == LA_L_MOUSE_DOWN){
         if (ui->Page->HeightCoeff && ui->R - e->x < LA_RH + bt->RM) return LA_RUNNING_PASS;
-        for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
-            count++;
-        }
+        for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){ count++; }
         page = la_DetectColumn(ui, e->x, count);
         for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
             if (it == page){