removed debug rect
[retroray] / src / scr_mod.c
index 5a33e45..834c1c0 100644 (file)
@@ -69,6 +69,7 @@ enum {
 static rtk_widget *tools[NUM_TOOLS];
 
 static int vpdirty;
+static rtk_rect totalrend;
 
 
 static int mdl_init(void);
@@ -90,8 +91,6 @@ static void act_settool(int tidx);
 static void act_addobj(void);
 static void act_rmobj(void);
 
-static void fix_rect(rtk_rect *rect);
-static void draw_rband(void);
 static void moveobj(struct object *obj, int px0, int py0, int px1, int py1);
 
 static void inval_vport(void);
@@ -259,10 +258,6 @@ static void mdl_display(void)
 
        /* GUI */
        rtk_draw_widget(toolbar);
-
-       if(rband_valid) {
-               draw_rband();
-       }
 }
 
 static void draw_object(struct object *obj)
@@ -335,6 +330,8 @@ static void mdl_reshape(int x, int y)
        cgm_minverse(proj_matrix_inv);
 
        rtk_resize(toolbar, win_width, TOOLBAR_HEIGHT);
+
+       inval_vport();
 }
 
 static void mdl_keyb(int key, int press)
@@ -391,18 +388,24 @@ static void mdl_mouse(int bn, int press, int x, int y)
 
                if(rband_valid) {
                        rband_valid = 0;
+                       app_rband(0, 0, 0, 0);
 
                        if(cur_tool == TOOL_REND_AREA) {
-                               if(prev_tool >= 0) {
-                                       act_settool(prev_tool);
+                               if(rband.width && rband.height) {
+                                       rendering = 1;
+                                       rend_size(win_width, win_height);
+                                       rtk_fix_rect(&rband);
+                                       rendrect = rband;
+                                       rend_begin(rband.x, rband.y, rband.width, rband.height);
+                                       app_redisplay(rband.x, rband.y, rband.width, rband.height);
+
+                                       if(totalrend.width) {
+                                               rtk_rect_union(&totalrend, &rband);
+                                       } else {
+                                               totalrend = rband;
+                                       }
                                }
-                               rendering = 1;
-                               rend_size(win_width, win_height);
-                               fix_rect(&rband);
-                               rendrect = rband;
-                               rend_begin(rband.x, rband.y, rband.width, rband.height);
                        }
-                       app_redisplay(rband.x, rband.y, rband.width, rband.height);
 
                } else if(bn == 0 && x == rband.x && y == rband.y) {
                        primray(&pickray, x, y);
@@ -457,6 +460,7 @@ static void mdl_motion(int x, int y)
                                        rband.width = x - rband.x;
                                        rband.height = y - rband.y;
                                        rband_valid = 1;
+                                       app_rband(rband.x, rband.y, rband.width, rband.height);
                                }
                                break;
 
@@ -489,6 +493,11 @@ static void tbn_callback(rtk_widget *w, void *cls)
        int id = (intptr_t)cls;
 
        switch(id) {
+       case TBN_NEW:
+               scn_clear(scn);
+               inval_vport();
+               break;
+
        case TBN_SEL:
        case TBN_MOVE:
        case TBN_ROT:
@@ -522,6 +531,14 @@ static void act_settool(int tidx)
        int i;
        rtk_rect r;
 
+       if(tidx == cur_tool) return;
+
+       if(cur_tool == TOOL_REND_AREA) {
+               totalrend.width = 0;
+               app_redisplay(totalrend.x, totalrend.y, totalrend.width, totalrend.height);
+               inval_vport();
+       }
+
        prev_tool = cur_tool;
        cur_tool = tidx;
        for(i=0; i<NUM_TOOLS; i++) {
@@ -557,32 +574,6 @@ static void act_rmobj(void)
        }
 }
 
-static void fix_rect(rtk_rect *rect)
-{
-       int x, y, w, h;
-
-       x = rband.x;
-       y = rband.y;
-
-       if(rband.width < 0) {
-               w = -rband.width;
-               x += rband.width;
-       } else {
-               w = rband.width;
-       }
-       if(rband.height < 0) {
-               h = -rband.height;
-               y += rband.height;
-       } else {
-               h = rband.height;
-       }
-
-       rect->x = x;
-       rect->y = y;
-       rect->width = w;
-       rect->height = h;
-}
-
 
 void primray(cgm_ray *ray, int x, int y)
 {