*/}}

2 Commits 9e7f5f1044 ... 76a3420a29

Author SHA1 Message Date
  YimingWu 76a3420a29 Eraser restore 2 weeks ago
  YimingWu 9bef298139 Depletion water button 2 weeks ago
2 changed files with 26 additions and 24 deletions
  1. 25 23
      ouroperations.c
  2. 1 1
      ourpaint.h

+ 25 - 23
ouroperations.c

@@ -1626,6 +1626,7 @@ void our_ColorPadDraw(laUiItem *ui, int h){
 int ourmod_PigmentLoader(laOperator* a, laEvent* e){
     laUiItem *ui = a->Instance;
     laBoxedTheme *bt = (*ui->Type->Theme);
+    laGeneralUiExtraData* ex=ui->Extra;
 
     if (!laIsInUiItem(ui, a, e->x, e->y) && ui->State==LA_UI_NORMAL){
         return LA_FINISHED_PASS;
@@ -1634,10 +1635,12 @@ int ourmod_PigmentLoader(laOperator* a, laEvent* e){
     OurBrush*b=ui->PP.LastPs?ui->PP.LastPs->UseInstance:0;
     if(!b){ return LA_RUNNING; }
 
-    if(e->type==LA_L_MOUSE_DOWN){ ui->State=LA_UI_ACTIVE; }
+    if(e->type==LA_L_MOUSE_DOWN){ ui->State=LA_UI_ACTIVE; ex->On=((e->x-ui->L)>TNS_MIN2(LA_RH,(ui->R-ui->L)/2))?0:1; }
     if(ui->State==LA_UI_ACTIVE && (e->type&LA_MOUSE_EVENT)){
         if(e->type==LA_L_MOUSE_UP || e->type==LA_R_MOUSE_DOWN){ ui->State=LA_UI_NORMAL; laRedrawCurrentPanel(); return LA_RUNNING; }
-        real fac=(1.0f-OUR_MIXING_SPEED*e->Pressure); b->PigmentLoading=1.0f-(1.0f-b->PigmentLoading)*fac; laNotifyUsersPP(&ui->PP);
+        real fac=(1.0f-OUR_MIXING_SPEED*e->Pressure); 
+        if(ex->On==0){ b->PigmentLoading=1.0f-(1.0f-b->PigmentLoading)*fac; } else { b->PigmentLoading=b->PigmentLoading*fac; }
+        laNotifyUsersPP(&ui->PP);
     }
 
     return LA_RUNNING;
@@ -1651,18 +1654,23 @@ void our_PigmentLoaderDraw(laUiItem *ui, int h){
     else{ color=Our->CurrentColor; } tnsVectorSet3v(UseColor,color);
     
     int L=ui->L,R=ui->R,U=ui->U,B=ui->B;
+    int BW=TNS_MIN2((R-L)/2,LA_RH);
 
     int sw=la_GetBoxOffset(bt,ui->State);
     tnsUseNoTexture();
     la_DrawBoxAutoFill(ui->L,ui->R,ui->U,ui->B,bt,ui->State,UseColor);
 
+    tnsColor4dv(laThemeColor(bt,ui->State));
+    la_DrawBox(L,L+BW,U,B);
+    tnsDrawIcon(U'💦',laThemeColor(bt,LA_BT_TEXT|ui->State),L,L+LA_RH,U,LA_TEXT_SHADOW);
+
     if (b){
-        tnsDrawStringAuto("Depleted",laThemeColor(bt,LA_BT_TEXT|LA_BT_DISABLED),L+LA_M,R-LA_M,U,LA_TEXT_SHADOW);
+        tnsDrawStringAuto(transLate("Depleted"),laThemeColor(bt,LA_BT_TEXT|LA_BT_DISABLED),L+LA_M+BW,R-LA_M,U,LA_TEXT_SHADOW);
         tnsUseNoTexture();
-        int R1=tnsInterpolate(L,R,b->PigmentLoading);
+        int R1=tnsInterpolate(L+BW,R,b->PigmentLoading);
         tnsColor4d(LA_COLOR3(color),1.0);
-        tnsVertex2d(L-sw, U-sw); tnsVertex2d(R1-sw, U-sw);
-        tnsVertex2d(R1-sw, B-sw); tnsVertex2d(L-sw, B-sw);
+        tnsVertex2d(L+BW-sw, U-sw); tnsVertex2d(R1-sw, U-sw);
+        tnsVertex2d(R1-sw, B-sw); tnsVertex2d(L+BW-sw, B-sw);
         tnsPackAs(GL_TRIANGLE_FAN);
         tnsVertex2d(R1-sw, U-sw); tnsVertex2d(R1-sw, B-sw);
         tnsColor4d(1,1,1,1);tnsPackAs(GL_LINES);
@@ -1670,7 +1678,7 @@ void our_PigmentLoaderDraw(laUiItem *ui, int h){
         tnsColor4d(0,0,0,1);tnsPackAs(GL_LINES);
     }
 
-    la_DrawBoxAutoBorder(ui->L,ui->R,ui->U,ui->B,bt,ui->State);
+    la_DrawBoxAutoBorder(L,R,U,B,bt,ui->State);
 
 }
 
@@ -3257,18 +3265,14 @@ void our_PaintDoDabsWithSmudgeSegments(OurLayer* l,int tl, int tr, int tu, int t
 void ourset_CurrentBrush(void* unused, OurBrush* b);
 void our_EnsureEraser(int EventIsEraser){
     if(EventIsEraser==Our->EventErasing){ return; }
-    printf("ev e %d %d\n", Our->EventErasing, Our->Erasing);
+    //printf("ev e %d %d\n", Our->EventErasing, Our->Erasing);
     int erasing=Our->Erasing; int num=0;
-    if(EventIsEraser && (!Our->EventErasing)){ num=TNS_MAX2(Our->EraserID,num);
-        for(OurBrush* b=Our->Brushes.pFirst;b;b=b->Item.pNext){
-            if(b->Binding==num){ ourset_CurrentBrush(Our,b); laNotifyUsers("our.tools.brushes"); break; }
-        }
+    if(EventIsEraser && (!Our->EventErasing)){ 
+        if(Our->EraserBrush){ ourset_CurrentBrush(Our,Our->EraserBrush); laNotifyUsers("our.tools.brushes"); }
         Our->Erasing=1; Our->EventErasing=1; laNotifyUsers("our.erasing");
     }
-    elif((!EventIsEraser) && Our->EventErasing){ num=TNS_MAX2(Our->PenID,num);
-        for(OurBrush* b=Our->Brushes.pFirst;b;b=b->Item.pNext){
-            if(b->Binding==num){ ourset_CurrentBrush(Our,b); laNotifyUsers("our.tools.brushes"); break; }
-        }
+    elif((!EventIsEraser) && Our->EventErasing){ 
+        if(Our->PenBrush){ ourset_CurrentBrush(Our,Our->PenBrush); laNotifyUsers("our.tools.brushes"); }
         Our->Erasing=0; Our->EventErasing=0; laNotifyUsers("our.erasing");
     }
 }
@@ -4610,16 +4614,16 @@ void ourpropagate_Tools(OurPaint* p, laUDF* udf, int force){
 }
 void ourset_CurrentBrush(void* unused, OurBrush* b){
     real r;
-    OurBrush* ob=Our->CurrentBrush;
+    OurBrush* ob=Our->CurrentBrush; int CurrentIsEraser=ob&&ob->DefaultAsEraser;
     if(ob){
         if(ob->DefaultAsEraser){ Our->SaveEraserSize=Our->BrushSize; }else{ Our->SaveBrushSize=Our->BrushSize; }
     }
     memAssignRef(Our,&Our->CurrentBrush,b);
     if(b){
-        if(b->DefaultAsEraser){ Our->Erasing=1; Our->EraserID=b->Binding; if(Our->SaveEraserSize)Our->BrushSize=Our->SaveEraserSize; }
-        else{ Our->Erasing=0; Our->PenID=b->Binding; if(Our->SaveBrushSize)Our->BrushSize=Our->SaveBrushSize; }
+        if(b->DefaultAsEraser){ Our->Erasing=1; memAssignRef(Our,&Our->EraserBrush,b); if(Our->SaveEraserSize)Our->BrushSize=Our->SaveEraserSize; }
+        else{ Our->Erasing=0; memAssignRef(Our,&Our->PenBrush,b); if(Our->SaveBrushSize)Our->BrushSize=Our->SaveBrushSize; }
     }
-    Our->ShowBrushName = 1; Our->ShowBrushNumber=1; b->PigmentLoading=1;
+    Our->ShowBrushName = 1; Our->ShowBrushNumber=1; b->PigmentLoading=CurrentIsEraser?b->PigmentLoading:1;
     laNotifyUsers("our.tools.current_brush"); laNotifyUsers("our.erasing"); laGraphRequestRebuild();
 }
 void ourset_CurrentPigment(void* unused, OurPigment* p){
@@ -5538,7 +5542,7 @@ void ourRegisterEverything(){
     OUR_WIDGET_PIGMENT_PREVIEW->Type=
     _OUR_UI_PIGMENT_PREVIEW = la_RegisterUiType("OUR_UI_pigment_preview", 0, 0, &_LA_THEME_VALUATOR, our_PigmentPreviewDraw, 0, 0, 0);
     OUR_WIDGET_PIGMENT_LOADER->Type=
-    _OUR_UI_PIGMENT_LOADER = la_RegisterUiType("OUR_UI_pigment_loader", 0, "OUR_UIOP_pigment_loader", &_LA_THEME_VALUATOR, our_PigmentLoaderDraw, 0, 0, 0);
+    _OUR_UI_PIGMENT_LOADER = la_RegisterUiType("OUR_UI_pigment_loader", 0, "OUR_UIOP_pigment_loader", &_LA_THEME_VALUATOR, our_PigmentLoaderDraw, 0,  la_GeneralUiInit, la_GeneralUiDestroy);
     OUR_WIDGET_COLOR_PAD->Type=
     _OUR_UI_COLOR_PAD = la_RegisterUiType("OUR_UI_color_pad", 0, "OUR_UIOP_color_pad", &_LA_THEME_VALUATOR, our_ColorPadDraw, 0, 0, 0);
 
@@ -5882,8 +5886,6 @@ int ourInit(){
     Our->AllowNonPressure=1;
     Our->BadEventsLimit=7;
 
-    Our->PenID=-1;
-    Our->EraserID=-1;
     Our->BrushNumber=3;
 
     Our->RefAlpha=0.75;

+ 1 - 1
ourpaint.h

@@ -554,7 +554,7 @@ STRUCTURE(OurPaint){
     int BackgroundType;
     int BackgroundRandom;
     real BackgroundFactor;
-    int PenID,EraserID;
+    OurBrush* PenBrush,*EraserBrush; real LastPigmentLoading;
     int X,Y,W,H; //border
     real BorderFadeWidth;
     int ColorInterpretation;