add bound test to dragchkbox
authorGood Guy <good1.2guy@gmail.com>
Sat, 14 Apr 2018 21:00:03 +0000 (15:00 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sat, 14 Apr 2018 21:00:03 +0000 (15:00 -0600)
cinelerra-5.1/cinelerra/dragcheckbox.C
cinelerra-5.1/cinelerra/dragcheckbox.h
cinelerra-5.1/plugins/findobj/findobjwindow.C

index 4db99b919546662e6c6c1346cec29ce4d15b7bf7..c38963997c96a100988a8092784d17488022dd63 100644 (file)
@@ -233,6 +233,20 @@ int DragCheckBox::grab_event(XEvent *event)
        return 1;
 }
 
+
+void DragCheckBox::bound()
+{
+       Track *track = get_drag_track();
+       int trk_w = track->track_w, trk_h = track->track_h;
+       float x1 = drag_x, x2 = x1 + drag_w;
+       float y1 = drag_y, y2 = y1 + drag_h;
+       bclamp(x1, 0, trk_w);  bclamp(x2, 0, trk_w);
+       bclamp(y1, 0, trk_h);  bclamp(y2, 0, trk_h);
+       if( x1 >= x2 ) { if( x2 > 0 ) x1 = x2-1; else x2 = (x1=0)+1; }
+       if( y1 >= y2 ) { if( x2 > 0 ) y1 = y2-1; else y2 = (y1=0)+1; }
+       drag_x = x1;  drag_y = y1;  drag_w = x2-x1;  drag_h = y2-y1;
+}
+
 void DragCheckBox::draw_boundary(VFrame *out,
        int x, int y, int w, int h)
 {
index 5628b3e6420fef5988dfe6430832a44a02dbbabd..aaa165546b86ddcf46f8b2f7abe237b80857557c 100644 (file)
@@ -15,6 +15,7 @@ public:
        virtual int64_t get_drag_position() = 0;
        virtual void update_gui() { return; };
        void create_objects();
+       void bound();
        static void draw_boundary(VFrame *out, int x, int y, int w, int h);
 
        int check_pending();
index 5ccec7689c18474c033ba3d5f4e7a0b90dc51140..e9efbc0f573e4515c4c86f130154dd54846842cd 100644 (file)
@@ -520,6 +520,7 @@ int64_t FindObjDragScene::get_drag_position()
 }
 void FindObjDragScene::update_gui()
 {
+       bound();
        Track *track = get_drag_track();
        int trk_w = track->track_w, trk_h = track->track_h;
        float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
@@ -559,6 +560,7 @@ int64_t FindObjDragObject::get_drag_position()
 }
 void FindObjDragObject::update_gui()
 {
+       bound();
        Track *track = get_drag_track();
        int trk_w = track->track_w, trk_h = track->track_h;
        float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
@@ -598,6 +600,7 @@ int64_t FindObjDragReplace::get_drag_position()
 }
 void FindObjDragReplace::update_gui()
 {
+       bound();
        Track *track = get_drag_track();
        int trk_w = track->track_w, trk_h = track->track_h;
        float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;