X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fvicon.C;h=f9978b26ebf0e917b1d7f6852a26b72dbf670c6d;hb=HEAD;hp=2bfedd9277b9a1465091361adafa7e1c757689a0;hpb=3ad39dda113124e7e1bb11a808541e6311417863;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/vicon.C b/cinelerra-5.1/guicast/vicon.C index 2bfedd92..f9978b26 100644 --- a/cinelerra-5.1/guicast/vicon.C +++ b/cinelerra-5.1/guicast/vicon.C @@ -41,9 +41,29 @@ add_image(VFrame *frm, int ww, int hh, int vcmdl) } void VIcon:: -draw_vframe(BC_WindowBase *wdw, int x, int y) +draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y) { - wdw->draw_vframe(frame(), x,y, vw,vh); + VFrame *vfrm = frame(); + if( !vfrm ) return; + int sx0 = 0, sx1 = sx0 + vt->view_w; + int sy0 = 0, sy1 = sy0 + vt->view_h; + int dx0 = x, dx1 = dx0 + vw; + int dy0 = y, dy1 = dy0 + vh; + if( (x=vt->draw_x0-dx0) > 0 ) { sx0 += (x*vt->view_w)/vw; dx0 = vt->draw_x0; } + if( (x=dx1-vt->draw_x1) > 0 ) { sx1 -= (x*vt->view_w)/vw; dx1 = vt->draw_x1; } + if( (y=vt->draw_y0-dy0) > 0 ) { sy0 += (y*vt->view_h)/vh; dy0 = vt->draw_y0; } + if( (y=dy1-vt->draw_y1) > 0 ) { sy1 -= (y*vt->view_h)/vh; dy1 = vt->draw_y1; } + int sw = sx1 - sx0, sh = sy1 - sy0; + int dw = dx1 - dx0, dh = dy1 - dy0; + if( dw > 0 && dh > 0 && sw > 0 && sh > 0 ) + wdw->draw_vframe(vfrm, dx0,dy0, dw,dh, sx0,sy0, sw,sh); +} + +void VIconThread:: +set_drawing_area(int x0, int y0, int x1, int y1) +{ + draw_x0 = x0; draw_y0 = y0; + draw_x1 = x1; draw_y1 = y1; } VIcon *VIconThread::low_vicon() @@ -78,11 +98,14 @@ VIconThread(BC_WindowBase *wdw, int vw, int vh) this->view_win = 0; this->vicon = 0; this->view_w = vw; this->view_h = vh; this->viewing = 0; + this->draw_x0 = 0; this->draw_x1 = wdw->get_w(); + this->draw_y0 = 0; this->draw_y1 = wdw->get_h(); draw_lock = new Condition(0, "VIconThread::draw_lock", 1); timer = new Timer(); this->refresh_rate = VICON_RATE; done = 0; interrupted = -1; + stop_age = 0; } VIconThread:: @@ -108,6 +131,8 @@ start_drawing() wdw->set_active_subwindow(view_win); if( interrupted < 0 ) draw_lock->unlock(); + timer->update(); + timer->subtract(-stop_age); interrupted = 0; wdw->unlock_window(); } @@ -119,6 +144,7 @@ stop_drawing() set_view_popup(0); if( !interrupted ) interrupted = 1; + stop_age = timer->get_difference(); wdw->unlock_window(); } @@ -129,26 +155,14 @@ int VIconThread::keypress_event(int key) return 1; } -int ViewPopup::button_press_event() -{ - vt->set_view_popup(0); - return 1; -} - bool VIconThread:: visible(VIcon *vicon, int x, int y) { if( vicon->hidden ) return false; - int y0 = 0; - int my = y + vicon->vh; - if( my <= y0 ) return false; - int y1 = y0 + wdw->get_h(); - if( y >= y1 ) return false; - int x0 = 0; - int mx = x + vicon->vw; - if( mx <= x0 ) return false; - int x1 = x0 + wdw->get_w(); - if( x >= x1 ) return false; + if( y+vicon->vh <= draw_y0 ) return false; + if( y >= draw_y1 ) return false; + if( x+vicon->vw <= draw_x0 ) return false; + if( x >= draw_x1 ) return false; return true; } @@ -157,6 +171,7 @@ int ViewPopup::keypress_event() int key = get_keypress(); return vt->keypress_event(key); } + ViewPopup::ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h) : BC_Popup(vt->wdw, x, y, w, h, BLACK) { @@ -170,6 +185,7 @@ ViewPopup::~ViewPopup() void ViewPopup::draw_vframe(VFrame *frame) { + if( !frame ) return; BC_WindowBase::draw_vframe(frame, 0,0, get_w(),get_h()); } @@ -218,14 +234,13 @@ int VIconThread::del_vicon(VIcon *&vicon) void VIconThread::set_view_popup(VIcon *vicon) { - if( !vicon && this->vicon ) - this->vicon->stop_audio(); this->vicon = vicon; } int VIconThread:: update_view() { + if( viewing ) viewing->stop_audio(); delete view_win; view_win = 0; if( (viewing=vicon) != 0 ) { VFrame *frame = viewing->frame(); @@ -263,7 +278,7 @@ draw(VIcon *vicon) if( !draw_img && !draw_win ) return 0; if( !vicon->frame() ) return 0; if( draw_img ) { - vicon->draw_vframe(wdw, x, y); + vicon->draw_vframe(this, wdw, x, y); img_dirty = 1; } if( draw_win ) { @@ -273,6 +288,14 @@ draw(VIcon *vicon) return 1; } +void VIconThread::hide_vicons(int v) +{ + for( int i=0; ihidden = v; + t_heap[i]->age = 0; + } +} + void VIconThread:: run() {