*/}}
Bladeren bron

Signal processing

YimingWu 11 maanden geleden
bovenliggende
commit
bdd744577c
2 gewijzigde bestanden met toevoegingen van 38 en 2 verwijderingen
  1. 28 2
      ouroperations.c
  2. 10 0
      ourpaint.h

+ 28 - 2
ouroperations.c

@@ -751,6 +751,23 @@ int ourextramod_Canvas(laOperator *a, laEvent *e){
         ocd->Base.OnX=e->x-offx; ocd->Base.OnY=e->y-offy;
         laRedrawCurrentPanel(); Our->EventHasTwist=e->HasTwist; Our->EventTwistAngle=e->Twist;
     }
+
+    if(e->type==LA_SIGNAL_EVENT){
+        switch(e->key){
+        case OUR_SIGNAL_BRUSH_SMALLER: 
+            laInvoke(a,"OUR_brush_resize",e,0,"direction=smaller",0);
+            break;
+        case OUR_SIGNAL_BRUSH_BIGGER:
+            laInvoke(a,"OUR_brush_resize",e,0,"direction=bigger",0);
+            break;
+        case OUR_SIGNAL_ZOOM_IN: 
+            laInvoke(a,"LA_2d_view_zoom",e,&ui->ExtraPP,"direction=in",0);
+            break;
+        case OUR_SIGNAL_ZOOM_OUT:
+            laInvoke(a,"LA_2d_view_zoom",e,&ui->ExtraPP,"direction=out",0);
+            break;
+        }
+    }
     return LA_RUNNING_PASS;
 }
 
@@ -1665,8 +1682,8 @@ void our_LayerGetRange(OurLayer* ol, int* rowmin,int* rowmax, int* colmin, int*
         if(*rowmin==INT_MAX){ *rowmin = row; }
         *rowmax=row;
         for(int col=0;col<OUR_TILES_PER_ROW;col++){ if(!ol->TexTiles[row][col]) continue;
-            if(*colmin==INT_MAX){ *colmin = col; }
             if(col > *colmax){ *colmax=col; }
+            if(col < *colmin){ *colmin = col; }
         }
     }
 }
@@ -1694,7 +1711,7 @@ int our_MoveLayer(OurLayer* ol, int dx, int dy, int* movedx, int* movedy){
     }
     for(int row=rowmin;row<=rowmax;row++){ if(!ol->TexTiles[row]) continue;
         for(int col=colmin;col<=colmax;col++){
-            OurTexTile* t0=copy[row][col]; if(!t0){ continue; }
+            OurTexTile* t0=copy[row][col]; if(!t0){continue; }
             t0->l+=dx*OUR_TILE_W; t0->r+=dx*OUR_TILE_W;
             t0->u+=dy*OUR_TILE_W; t0->b+=dy*OUR_TILE_W;
             if(!ol->TexTiles[row+dy]){
@@ -2770,6 +2787,15 @@ void ourRegisterEverything(){
     laAssignNewKey(km, 0, "OUR_toggle_erasing", 0, 0, LA_KEY_DOWN, 'e', 0);
     laAssignNewKey(km, 0, "OUR_cycle_sketch", 0, 0, LA_KEY_DOWN, 's', 0);
 
+    laNewCustomSignal("our.pick",OUR_SIGNAL_PICK);
+    laNewCustomSignal("our.move",OUR_SIGNAL_MOVE);
+    laNewCustomSignal("our.toggle_erasing",OUR_SIGNAL_TOGGLE_ERASING);
+    laNewCustomSignal("our.toggle_sketch",OUR_SIGNAL_TOGGLE_SKETCH);
+    laNewCustomSignal("our.zoom_in",OUR_SIGNAL_ZOOM_IN);
+    laNewCustomSignal("our.zoom_out",OUR_SIGNAL_ZOOM_OUT);
+    laNewCustomSignal("our.bursh_bigger",OUR_SIGNAL_BRUSH_BIGGER);
+    laNewCustomSignal("our.brush_smaller",OUR_SIGNAL_BRUSH_SMALLER);
+
     laAssignNewKey(km, 0, "LA_undo", 0, LA_KEY_CTRL, LA_KEY_DOWN, ']', 0);
     laAssignNewKey(km, 0, "LA_redo", 0, LA_KEY_CTRL, LA_KEY_DOWN, '[', 0);
 

+ 10 - 0
ourpaint.h

@@ -55,6 +55,16 @@ extern const char OUR_COMPOSITION_SHADER[];
 
 #define OUR_PAINT_NAME_STRING "Our Paint v0.2"
 
+#define OUR_SIGNAL_PICK 1
+#define OUR_SIGNAL_MOVE 2
+#define OUR_SIGNAL_PICK 3
+#define OUR_SIGNAL_TOGGLE_ERASING 4
+#define OUR_SIGNAL_ZOOM_IN 5
+#define OUR_SIGNAL_ZOOM_OUT 6
+#define OUR_SIGNAL_BRUSH_BIGGER 7
+#define OUR_SIGNAL_BRUSH_SMALLER 8
+#define OUR_SIGNAL_TOGGLE_SKETCH 9
+
 STRUCTURE(OurCanvasDraw){
     laCanvasExtra Base;
     int HideBrushCircle;