From: Good Guy Date: Sat, 14 Apr 2018 21:00:03 +0000 (-0600) Subject: add bound test to dragchkbox X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=commitdiff_plain;h=17061ff8d289bfa96bef2da5bac789762f631d4a add bound test to dragchkbox --- diff --git a/cinelerra-5.1/cinelerra/dragcheckbox.C b/cinelerra-5.1/cinelerra/dragcheckbox.C index 4db99b91..c3896399 100644 --- a/cinelerra-5.1/cinelerra/dragcheckbox.C +++ b/cinelerra-5.1/cinelerra/dragcheckbox.C @@ -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) { diff --git a/cinelerra-5.1/cinelerra/dragcheckbox.h b/cinelerra-5.1/cinelerra/dragcheckbox.h index 5628b3e6..aaa16554 100644 --- a/cinelerra-5.1/cinelerra/dragcheckbox.h +++ b/cinelerra-5.1/cinelerra/dragcheckbox.h @@ -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(); diff --git a/cinelerra-5.1/plugins/findobj/findobjwindow.C b/cinelerra-5.1/plugins/findobj/findobjwindow.C index 5ccec768..e9efbc0f 100644 --- a/cinelerra-5.1/plugins/findobj/findobjwindow.C +++ b/cinelerra-5.1/plugins/findobj/findobjwindow.C @@ -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;