add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / cwindow.C
index 3a65150df6c586664a0ce807ec5afd63c4edb3e0..4328162356a290db813da21f4faf84f50ef7fb80 100644 (file)
@@ -59,6 +59,10 @@ CWindow::CWindow(MWindow *mwindow)
  : Thread(1, 0, 0)
 {
        this->mwindow = mwindow;
+       this->playback_engine = 0;
+       this->playback_cursor = 0;
+       this->mask_track_id = -1;
+       this->gui = 0;
 }
 
 
@@ -75,26 +79,14 @@ CWindow::~CWindow()
 
 void CWindow::create_objects()
 {
-       destination = mwindow->defaults->get("CWINDOW_DESTINATION", 0);
-
-
        gui = new CWindowGUI(mwindow, this);
-
        gui->create_objects();
-
-
        playback_engine = new CPlayback(mwindow, this, gui->canvas);
-
-
 // Start command loop
        playback_engine->create_objects();
-
        gui->transport->set_engine(playback_engine);
-
        playback_cursor = new CTracking(mwindow, this);
-
        playback_cursor->create_objects();
-
 }
 
 
@@ -129,40 +121,39 @@ void CWindow::hide_window()
 
 Track* CWindow::calculate_affected_track()
 {
-       Track* affected_track = 0;
-       for(Track *track = mwindow->edl->tracks->first;
-               track;
-               track = track->next)
-       {
-               if(track->data_type == TRACK_VIDEO &&
-                       track->record)
-               {
-                       affected_track = track;
-                       break;
-               }
+       Track *track = mwindow->edl->tracks->first;
+       for( ; track; track=track->next ) {
+               if( track->data_type != TRACK_VIDEO ) continue;
+               if( track->record ) break;
+       }
+       return track;
+}
+
+Track* CWindow::calculate_mask_track()
+{
+       Track *track = mwindow->edl->tracks->first;
+       for( ; track; track=track->next ) {
+               if( track->data_type != TRACK_VIDEO ) continue;
+               if( track->record && track->get_id() == mask_track_id ) break;
        }
-       return affected_track;
+       return track;
 }
 
+
 Auto* CWindow::calculate_affected_auto(Autos *autos,
-       int create,
-       int *created,
-       int redraw)
+               int create, int *created, int redraw)
 {
        Auto* affected_auto = 0;
-       if(created) *created = 0;
+       if( created ) *created = 0;
 
-       if(create)
-       {
+       if( create ) {
                int total = autos->total();
-               affected_auto = autos->get_auto_for_editing();
+               affected_auto = autos->get_auto_for_editing(-1, create);
 
 // Got created
-               if(total != autos->total())
-               {
-                       if(created) *created = 1;
-                       if(redraw)
-                       {
+               if( total != autos->total() ) {
+                       if( created ) *created = 1;
+                       if( redraw ) {
 // May have to unlock CWindowGUI here.
                                mwindow->gui->lock_window("CWindow::calculate_affected_auto");
                                mwindow->gui->draw_overlays(1);
@@ -170,8 +161,7 @@ Auto* CWindow::calculate_affected_auto(Autos *autos,
                        }
                }
        }
-       else
-       {
+       else {
                affected_auto = autos->get_prev_auto(PLAY_FORWARD, affected_auto);
        }
 
@@ -180,39 +170,28 @@ Auto* CWindow::calculate_affected_auto(Autos *autos,
 
 
 
-void CWindow::calculate_affected_autos(FloatAuto **x_auto,
-       FloatAuto **y_auto,
-       FloatAuto **z_auto,
-       Track *track,
-       int use_camera,
-       int create_x,
-       int create_y,
-       int create_z)
+void CWindow::calculate_affected_autos(Track *track,
+               FloatAuto **x_auto, FloatAuto **y_auto, FloatAuto **z_auto,
+               int use_camera, int create_x, int create_y, int create_z,
+               int redraw)
 {
-       if(x_auto) (*x_auto) = 0;
-       if(y_auto) (*y_auto) = 0;
-       if(z_auto) (*z_auto) = 0;
-
-       if(!track) return;
-
-       if(use_camera)
-       {
-               if(x_auto) (*x_auto) = (FloatAuto*)calculate_affected_auto(
-                       track->automation->autos[AUTOMATION_CAMERA_X], create_x);
-               if(y_auto) (*y_auto) = (FloatAuto*)calculate_affected_auto(
-                       track->automation->autos[AUTOMATION_CAMERA_Y], create_y);
-               if(z_auto) (*z_auto) = (FloatAuto*)calculate_affected_auto(
-                       track->automation->autos[AUTOMATION_CAMERA_Z], create_z);
-       }
-       else
-       {
-               if(x_auto) (*x_auto) = (FloatAuto*)calculate_affected_auto(
-                       track->automation->autos[AUTOMATION_PROJECTOR_X], create_x);
-               if(y_auto) (*y_auto) = (FloatAuto*)calculate_affected_auto(
-                       track->automation->autos[AUTOMATION_PROJECTOR_Y], create_y);
-               if(z_auto) (*z_auto) = (FloatAuto*)calculate_affected_auto(
-                       track->automation->autos[AUTOMATION_PROJECTOR_Z], create_z);
-       }
+       if( x_auto ) *x_auto = 0;
+       if( y_auto ) *y_auto = 0;
+       if( z_auto ) *z_auto = 0;
+       if( !track ) return;
+
+       int ix = use_camera ? AUTOMATION_CAMERA_X : AUTOMATION_PROJECTOR_X, x_created = 0;
+       int iy = use_camera ? AUTOMATION_CAMERA_Y : AUTOMATION_PROJECTOR_Y, y_created = 0;
+       int iz = use_camera ? AUTOMATION_CAMERA_Z : AUTOMATION_PROJECTOR_Z, z_created = 0;
+
+       if( x_auto )
+               *x_auto = (FloatAuto*) calculate_affected_auto(track->automation->autos[ix],
+                               create_x, &x_created, redraw);
+       if( y_auto )
+               *y_auto = (FloatAuto*) calculate_affected_auto(track->automation->autos[iy],
+                               create_y, &y_created, redraw);
+       if( z_auto ) *z_auto = (FloatAuto*) calculate_affected_auto(track->automation->autos[iz],
+                               create_z, &z_created, redraw);
 }
 
 void CWindow::stop_playback(int wait)
@@ -228,47 +207,38 @@ void CWindow::run()
 void CWindow::update(int dir, int overlays, int tool_window, int operation, int timebar)
 {
 
-       if(dir)
+       if( dir )
                refresh_frame(CHANGE_NONE, dir);
 
        gui->lock_window("CWindow::update 2");
 // Create tool window
-       if(operation)
+       if( operation )
                gui->set_operation(mwindow->edl->session->cwindow_operation);
 
 // Updated by video device.
-       if(overlays && !dir)
-               gui->canvas->draw_refresh();
+       if( overlays && !dir )
+               gui->canvas->refresh(1);
 
 // Update tool parameters
 // Never updated by someone else
-       if(tool_window || dir)
+       if( tool_window || dir )
                gui->update_tool();
 
-       if(timebar)
+       if( timebar )
                gui->timebar->update(1);
 
        double zoom = !mwindow->edl->session->cwindow_scrollbars ?
-               0 :mwindow->edl->session->cwindow_zoom;
+               0 : mwindow->edl->session->cwindow_zoom;
        gui->zoom_panel->update(zoom);
 
        gui->canvas->update_zoom(mwindow->edl->session->cwindow_xscroll,
                        mwindow->edl->session->cwindow_yscroll,
                        mwindow->edl->session->cwindow_zoom);
-       gui->canvas->reposition_window(mwindow->edl,
-                       mwindow->theme->ccanvas_x,
-                       mwindow->theme->ccanvas_y,
-                       mwindow->theme->ccanvas_w,
-                       mwindow->theme->ccanvas_h);
-
-
-
+       gui->canvas->update_geometry(mwindow->edl,
+                       mwindow->theme->ccanvas_x, mwindow->theme->ccanvas_y,
+                       mwindow->theme->ccanvas_w, mwindow->theme->ccanvas_h);
 
        gui->unlock_window();
-
-
-
-
 }
 
 int CWindow::update_position(double position)
@@ -299,36 +269,42 @@ void CWindow::refresh_frame(int change_type, int dir)
        refresh_frame(change_type, mwindow->edl, dir);
 }
 
-CWindowRemoteHandler::
-CWindowRemoteHandler(RemoteControl *remote_control)
+CWindowKeyEvHandler::
+CWindowKeyEvHandler(RemoteControl *remote_control)
  : RemoteHandler(remote_control->gui, RED)
 {
+       this->remote_control = remote_control;
+       this->mwindow = remote_control->mwindow_gui->mwindow;
        last_key = -1;
+       key = -1;
 }
 
-CWindowRemoteHandler::
-~CWindowRemoteHandler()
+CWindowKeyEvHandler::
+~CWindowKeyEvHandler()
 {
 }
 
-int CWindowRemoteHandler::remote_process_key(RemoteControl *remote_control, int key)
+int CWindowKeyEvHandler::remote_key(int key)
 {
-       MWindowGUI *mwindow_gui = remote_control->mwindow_gui;
-       EDL *edl = mwindow_gui->mwindow->edl;
+       return remote_process_key(remote_control, key);
+}
+
+int CWindowKeyEvHandler::remote_process_key(RemoteControl *remote_control, int key)
+{
+       EDL *edl = mwindow->edl;
        if( !edl ) return 0;
-       PlayTransport *transport = mwindow_gui->mbuttons->transport;
+       PlayTransport *transport = mwindow->gui->mbuttons->transport;
        if( !transport->get_edl() ) return 0;
        PlaybackEngine *engine = transport->engine;
        double position = engine->get_tracking_position();
        double length = edl->tracks->total_length();
-       int next_command = -1, lastkey = last_key;
-       last_key = key;
+       int next_command = -1;
 
        switch( key ) {
        case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8':
-               if( lastkey == 'e' ) {
-                       mwindow_gui->mwindow->select_asset(key-'1', 1);
+               if( last_key == 'e' ) {
+                       mwindow->select_asset(key-'1', 1);
                        break;
                } // fall through
        case '0': case '9':
@@ -346,22 +322,14 @@ int CWindowRemoteHandler::remote_process_key(RemoteControl *remote_control, int
        case KPRECD:  next_command = SLOW_REWIND;       break;
        case KPAUSE:  next_command = SLOW_FWD;          break;
        case ' ':  next_command = NORMAL_FWD;           break;
-       case 'a':  gui->tile_windows(0);                return 1;
-       case 'b':  gui->tile_windows(1);                return 1;
-       case 'c':  gui->tile_windows(2);                return 1;
-#ifdef HAVE_DVB
-       case 'd':
-               mwindow_gui->channel_info->toggle_scan();
-               return 1;
-#endif
-       case 'e':
-               break;
+       case 'a':  remote_control->gui->tile_windows(0);  return 1;
+       case 'b':  remote_control->gui->tile_windows(1);  return 1;
+       case 'c':  remote_control->gui->tile_windows(2);  return 1;
+       case KPFSCRN:
        case 'f': {
-               Canvas *canvas = mwindow_gui->mwindow->cwindow->gui->canvas;
-               if( !canvas->get_fullscreen() )
-                       canvas->start_fullscreen();
-               else
-                       canvas->stop_fullscreen();
+               CWindowCanvas *canvas = mwindow->cwindow->gui->canvas;
+               int on = canvas->get_fullscreen() ? 0 : 1;
+               canvas->Canvas::set_fullscreen(on, 0);
                return 1; }
        default:
                return -1;
@@ -372,7 +340,7 @@ int CWindowRemoteHandler::remote_process_key(RemoteControl *remote_control, int
                transport->change_position(position);
        }
        else
-               transport->handle_transport(next_command, 0, 0);
+               transport->handle_transport(next_command);
        return 1;
 }