*/}}
Browse Source

multi brush for one shortcut

YimingWu 8 months ago
parent
commit
aa3e0396cf
1 changed files with 9 additions and 2 deletions
  1. 9 2
      ouroperations.c

+ 9 - 2
ouroperations.c

@@ -2034,10 +2034,17 @@ int ourinv_MoveBrush(laOperator* a, laEvent* e){
 int ourinv_BrushQuickSwitch(laOperator* a, laEvent* e){
     char* id=strGetArgumentString(a->ExtraInstructionsP,"binding"); if(!id){ return LA_CANCELED; }
     int num; int ret=sscanf(id,"%d",&num); if(ret>9||ret<0){ return LA_CANCELED; }
+    OurBrush* found=0,*first=0; int set=0;
     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(!first){ first=b; }
+            if(found){ ourset_CurrentBrush(Our,b); set=1; laNotifyUsers("our.tools.brushes"); break; }
+            elif(b == Our->CurrentBrush){ found = b; }
+        }
+    }
+    if(!found || (found && !set)){ found = first; }
+    if(!set && found){
+         ourset_CurrentBrush(Our,found); laNotifyUsers("our.tools.brushes");
     }
     return LA_FINISHED;
 }