repeat play, in/out <> shortcuts, append to proj wording, cleanup
[goodguy/history.git] / cinelerra-5.1 / cinelerra / cwindowgui.C
index 6d431550d156b1617a0e3a6d8a2e16a6f4317e03..da38d010ef2d36baea86effe871926a2d64d371f 100644 (file)
@@ -92,23 +92,28 @@ CWindowGUI::CWindowGUI(MWindow *mwindow, CWindow *cwindow)
        this->mwindow = mwindow;
        this->cwindow = cwindow;
        affected_track = 0;
-       affected_x = 0;
-       affected_y = 0;
-       affected_z = 0;
+       affected_x = affected_y = affected_z = 0;
        mask_keyframe = 0;
        orig_mask_keyframe = new MaskAuto(0, 0);
        affected_point = 0;
-       x_offset = 0;
-       y_offset = 0;
-       x_origin = 0;
-       y_origin = 0;
+       x_offset = y_offset = 0;
+       x_origin = y_origin = 0;
        current_operation = CWINDOW_NONE;
        tool_panel = 0;
-       translating_zoom = 0;
        active = 0;
        inactive = 0;
-       crop_translate = 0;
+       crop_handle = -1; crop_translate = 0;
+       crop_origin_x = crop_origin_y = 0;
+       crop_origin_x1 = crop_origin_y1 = 0;
+       crop_origin_x2 = crop_origin_y2 = 0;
        eyedrop_visible = 0;
+       eyedrop_x = eyedrop_y = 0;
+       ruler_origin_x = ruler_origin_y = 0;
+       ruler_handle = -1; ruler_translate = 0;
+       center_x = center_y = center_z = 0;
+       control_in_x = control_in_y = 0;
+       control_out_x = control_out_y = 0;
+       translating_zoom = 0;
        highlighted = 0;
 }
 
@@ -245,7 +250,7 @@ int CWindowGUI::resize_event(int w, int h)
        flash(0);
 
        composite_panel->reposition_buttons(mwindow->theme->ccomposite_x,
-               mwindow->theme->ccomposite_y);
+               mwindow->theme->ccomposite_y, mwindow->theme->ccomposite_h);
 
        canvas->reposition_window(mwindow->edl,
                mwindow->theme->ccanvas_x,
@@ -381,7 +386,7 @@ void CWindowGUI::zoom_canvas(double value, int update_menu)
                x = output_x - cx / zoom;
                y = output_y - cy / zoom;
        }
-       canvas->update_zoom((int)x, (int)y, zoom);
+       canvas->update_zoom((int)(x+0.5), (int)(y+0.5), zoom);
 
        if( update_menu )
                zoom_panel->update(value);
@@ -468,58 +473,34 @@ int CWindowGUI::keypress_event()
                        lock_window("CWindowGUI::keypress_event 4");
                        break;
                case LEFT:
-                       if(!ctrl_down())
-                       {
-                               if (alt_down())
-                               {
-                                       int shift_down = this->shift_down();
-                                       unlock_window();
-                                       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                       if( !ctrl_down() ) {
+                               int alt_down = this->alt_down();
+                               int shift_down = this->shift_down();
+                               unlock_window();
+                               stop_transport(0);
+                               mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                               if( alt_down )
                                        mwindow->prev_edit_handle(shift_down);
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 1");
-                               }
                                else
-                               {
-                                       unlock_window();
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 3");
                                        mwindow->move_left();
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 2");
-                               }
+                               mwindow->gui->unlock_window();
+                               lock_window("CWindowGUI::keypress_event 2");
                                result = 1;
                        }
                        break;
                case RIGHT:
-                       if(!ctrl_down())
-                       {
-                               if (alt_down())
-                               {
-                                       int shift_down = this->shift_down();
-                                       unlock_window();
-                                       mwindow->gui->mbuttons->transport->handle_transport(STOP, 1, 0, 0);
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                       if( !ctrl_down() ) {
+                               int alt_down = this->alt_down();
+                               int shift_down = this->shift_down();
+                               unlock_window();
+                               stop_transport(0);
+                               mwindow->gui->lock_window("CWindowGUI::keypress_event 2");
+                               if( alt_down )
                                        mwindow->next_edit_handle(shift_down);
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 2");
-                               }
                                else
-                               {
-                                       unlock_window();
-
-                                       mwindow->gui->lock_window("CWindowGUI::keypress_event 4");
                                        mwindow->move_right();
-                                       mwindow->gui->unlock_window();
-
-                                       lock_window("CWindowGUI::keypress_event 3");
-                               }
+                               mwindow->gui->unlock_window();
+                               lock_window("CWindowGUI::keypress_event 2");
                                result = 1;
                        }
                        break;
@@ -671,6 +652,13 @@ void CWindowGUI::update_meters()
        }
 }
 
+void CWindowGUI::stop_transport(const char *lock_msg)
+{
+       if( lock_msg ) unlock_window();
+       mwindow->stop_transport();
+       if( lock_msg ) lock_window(lock_msg);
+}
+
 
 CWindowEditing::CWindowEditing(MWindow *mwindow, CWindow *cwindow)
  : EditPanel(mwindow,
@@ -711,15 +699,17 @@ CWrapper(splice_selection)
 CWrapper(overwrite_selection)
 CWrapper(set_inpoint)
 CWrapper(set_outpoint)
-CWrapper(clear_inpoint)
-CWrapper(clear_outpoint)
-CWrapper(to_clip)
+CWrapper(unset_inoutpoint)
 CWrapper(toggle_label)
 CWrapper(prev_label)
 CWrapper(next_label)
 CWrapper(prev_edit)
 CWrapper(next_edit)
 
+void CWindowEditing::to_clip()
+{
+        mwindow->to_clip(mwindow->edl, _("composer window: "));
+}
 
 
 CWindowMeters::CWindowMeters(MWindow *mwindow,
@@ -821,7 +811,7 @@ int CWindowSlider::handle_event()
 
 void CWindowSlider::set_position()
 {
-       double new_length = mwindow->edl->tracks->total_playable_length();
+       double new_length = mwindow->edl->tracks->total_length();
 //     if(mwindow->edl->local_session->preview_end <= 0 ||
 //             mwindow->edl->local_session->preview_end > new_length)
 //             mwindow->edl->local_session->preview_end = new_length;
@@ -2159,15 +2149,24 @@ int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw)
        float blue = (float)*row++ / max; \
        if(do_yuv) \
        { \
-               mwindow->edl->local_session->red += red + V_TO_R * (blue - 0.5); \
-               mwindow->edl->local_session->green += red + U_TO_G * (green - 0.5) + V_TO_G * (blue - 0.5); \
-               mwindow->edl->local_session->blue += red + U_TO_B * (green - 0.5); \
+               float r = red + V_TO_R * (blue - 0.5); \
+               float g = red + U_TO_G * (green - 0.5) + V_TO_G * (blue - 0.5); \
+               float b = red + U_TO_B * (green - 0.5); \
+               mwindow->edl->local_session->red += r; \
+               mwindow->edl->local_session->green += g; \
+               mwindow->edl->local_session->blue += b; \
+               if(r > mwindow->edl->local_session->red_max) mwindow->edl->local_session->red_max = r; \
+               if(g > mwindow->edl->local_session->green_max) mwindow->edl->local_session->green_max = g; \
+               if(b > mwindow->edl->local_session->blue_max) mwindow->edl->local_session->blue_max = b; \
        } \
        else \
        { \
                mwindow->edl->local_session->red += red; \
                mwindow->edl->local_session->green += green; \
                mwindow->edl->local_session->blue += blue; \
+               if(red > mwindow->edl->local_session->red_max) mwindow->edl->local_session->red_max = red; \
+               if(green > mwindow->edl->local_session->green_max) mwindow->edl->local_session->green_max = green; \
+               if(blue > mwindow->edl->local_session->blue_max) mwindow->edl->local_session->blue_max = blue; \
        } \
 }
 
@@ -2176,6 +2175,9 @@ int CWindowCanvas::do_eyedrop(int &rerender, int button_press, int draw)
                        mwindow->edl->local_session->red = 0;
                        mwindow->edl->local_session->green = 0;
                        mwindow->edl->local_session->blue = 0;
+                       mwindow->edl->local_session->red_max = 0;
+                       mwindow->edl->local_session->green_max = 0;
+                       mwindow->edl->local_session->blue_max = 0;
                        for(int i = row1; i < row2; i++)
                        {
                                for(int j = column1; j < column2; j++)
@@ -3158,10 +3160,7 @@ int CWindowCanvas::cursor_motion_event()
                gui->unlock_window();
                mwindow->restart_brender();
                mwindow->sync_parameters(CHANGE_PARAMS);
-               gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
-                       CHANGE_NONE,
-                       mwindow->edl,
-                       1);
+               mwindow->cwindow->refresh_frame(CHANGE_NONE);
                if(!redraw) gui->update_tool();
                gui->lock_window("CWindowCanvas::cursor_motion_event 2");
        }
@@ -3250,10 +3249,7 @@ int CWindowCanvas::button_press_event()
 
                mwindow->restart_brender();
                mwindow->sync_parameters(CHANGE_PARAMS);
-               gui->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
-                       CHANGE_NONE,
-                       mwindow->edl,
-                       1);
+               mwindow->cwindow->refresh_frame(CHANGE_NONE);
                if(!redraw) gui->update_tool();
                gui->lock_window("CWindowCanvas::button_press_event 2");
        }