*/}}
YimingWu 5 місяців тому
батько
коміт
c31b60a00b
2 змінених файлів з 16 додано та 8 видалено
  1. 2 0
      la_interface.h
  2. 14 8
      resources/la_widgets.c

+ 2 - 0
la_interface.h

@@ -1221,6 +1221,8 @@ STRUCTURE(laWidget){
 #define LA_UI_FLAGS_MOMENTARY (LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_NODE_CONTAINER)
 #define LA_UI_FLAGS_KNOB LA_UI_FLAGS_NODE_CONTAINER
 
+#define LA_UI_FLAGS_VALUE_METER LA_UI_FLAGS_CYCLE
+
 #define LA_UI_SOCKET_LABEL_N LA_TEXT_ALIGN_LEFT
 #define LA_UI_SOCKET_LABEL_S LA_TEXT_ALIGN_RIGHT
 #define LA_UI_SOCKET_LABEL_W LA_TEXT_ALIGN_CENTER

+ 14 - 8
resources/la_widgets.c

@@ -577,6 +577,7 @@ void la_IntDraw(laUiItem *ui, int h){
     int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
     int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
     int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
+    int SliderVertical = ui->Flags&LA_UI_FLAGS_VALUE_METER;
 
     if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
 
@@ -657,10 +658,11 @@ void la_IntDraw(laUiItem *ui, int h){
 
                 if (Ranged){
                     int L1 = _L;
-                    int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
+                    int R1 = SliderVertical?_R:((real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1);
+                    int U1 = SliderVertical?(_B - (real)(Data[i] - min) / (real)(max - min) * (real)(_B-_U)):_U;
                     tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
                     tnsColor4d(LA_COLOR3(color),0.3);
-                    tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
+                    tnsVertex2d(L1, U1); tnsVertex2d(R1, U1);
                     tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
                     tnsPackAs(GL_TRIANGLE_FAN);
                 }
@@ -705,6 +707,7 @@ void la_FloatDraw(laUiItem *ui, int h){
     int NoLabel=ui->Flags&LA_UI_FLAGS_NO_LABEL;
     int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
     int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
+    int SliderVertical = ui->Flags&LA_UI_FLAGS_VALUE_METER;
 
     if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
 
@@ -785,10 +788,11 @@ void la_FloatDraw(laUiItem *ui, int h){
 
                 if (Ranged){
                     int L1 = _L;
-                    int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
+                    int R1 = SliderVertical?_R:((real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1);
+                    int U1 = SliderVertical?(_B - (real)(Data[i] - min) / (real)(max - min) * (real)(_B-_U)):_U;
                     tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
                     tnsColor4d(LA_COLOR3(color),0.3);
-                    tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
+                    tnsVertex2d(L1, U1); tnsVertex2d(R1, U1);
                     tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
                     tnsPackAs(GL_TRIANGLE_FAN);
                 }
@@ -2228,7 +2232,7 @@ int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
     switch (e->type){
     case LA_INPUT:
         switch (e->Input){
-        //case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
+        case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
         case 0x7f: if(strHasSelection(se)) strClearSelection(se); else { strMoveCursor(se,0,0); strBackspace(se); } return 1;
         case 0x09: strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' '); return 1;
         case 0x1B: case 0x0D: return 0;
@@ -2242,7 +2246,9 @@ int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
         case LA_KEY_ARRRIGHT: strMoveCursor(se, 0, Select); return 1;
         case LA_KEY_ARRUP: strMoveCursorLine(se, 1, Select); return 1;
         case LA_KEY_ARRDOWN: strMoveCursorLine(se, 0, Select); return 1;
+#ifdef LAGUI_ANDROID
         case LA_KEY_BACKSPACE: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
+#endif
         }
         break;
     case LA_L_MOUSE_DOWN:
@@ -2302,7 +2308,7 @@ int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
     int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
     int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
     int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
-    int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
+    int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER || ui->Flags&LA_UI_FLAGS_VALUE_METER;
 
     if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
         ui->State = LA_UI_NORMAL;
@@ -2425,7 +2431,7 @@ int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
     int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
     int IsRad=ui->PP.LastPs->p->IsRadAngle;
     int NoTooltip=ui->Flags&LA_UI_FLAGS_NO_TOOLTIP;
-    int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER;
+    int IsKnob = ui->Flags&LA_UI_FLAGS_NODE_CONTAINER || ui->Flags&LA_UI_FLAGS_VALUE_METER;
 
     if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On && !NoTooltip){
         ui->State = LA_UI_NORMAL;
@@ -3237,7 +3243,7 @@ int OPMOD_CollectionSelector(laOperator *a, laEvent *e){
         a->ToPanel->MenuRefer ? a->ToPanel->MenuRefer : &a->ToPanel->UI;
     laUiList* uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
     if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target) {
-        //printf("%d %d EXIT\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
+        printf("%d %d EXIT\n",((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target, uil);
         return LA_FINISHED;
     }