add new boxblur plugin, mods to videoscope, fix segv for menu btns kfrm-tweak/kfrm...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / zwindowgui.C
index b6cccd03f82352ce4f285a98ccc267bf754f644e..515d41ba047d55ade72ef7f8b3ff53f82e9bb478 100644 (file)
@@ -47,6 +47,7 @@ ZWindowGUI::ZWindowGUI(MWindow *mwindow, ZWindow *zwindow, Mixer *mixer)
        canvas = 0;
        playback_engine = 0;
        highlighted = 0;
+       playable = zwindow->playable;
 }
 
 ZWindowGUI::~ZWindowGUI()
@@ -85,7 +86,7 @@ int ZWindowGUI::translation_event()
 
 int ZWindowGUI::close_event()
 {
-       set_done(0);
+       set_done(1);
        return 1;
 }
 
@@ -183,14 +184,64 @@ int ZWindowGUI::draw_overlays()
 {
        BC_WindowBase *cvs = canvas->get_canvas();
        if( !cvs || cvs->get_video_on() ) return 0;
-       if( highlighted != zwindow->highlighted ) {
-               highlighted = zwindow->highlighted;
-               cvs->set_color(WHITE);
-               cvs->set_inverse();
-               cvs->draw_rectangle(0, 0, cvs->get_w(), cvs->get_h());
-               cvs->draw_rectangle(1, 1, cvs->get_w() - 2, cvs->get_h() - 2);
-               cvs->set_opaque();
-       }
+       set_highlighted(zwindow->highlighted);
+       if( !playable ) set_playable(-1);
+       return 1;
+}
+
+void ZWindowGUI::set_highlighted(int v)
+{
+       if( highlighted == v ) return;
+       highlighted = v;
+       BC_WindowBase *cvs = canvas->get_canvas();
+       cvs->set_color(WHITE);
+       cvs->set_inverse();
+       cvs->draw_rectangle(0, 0, cvs->get_w(), cvs->get_h());
+       cvs->draw_rectangle(1, 1, cvs->get_w() - 2, cvs->get_h() - 2);
+       cvs->set_opaque();
+}
+
+void ZWindowGUI::set_playable(int v)
+{
+       if( playable == v ) return;
+       playable = v>0 ? 1 : 0;
+       zwindow->playable = playable;
+       BC_WindowBase *cvs = canvas->get_canvas();
+       cvs->set_color(WHITE);
+       cvs->set_inverse();
+       int dx = cvs->get_w()/16+1, dy = cvs->get_h()/16+1;
+       int x = xS(5), y = yS(5), lw = (dx + dy)/16+1;
+       cvs->set_line_width(lw);
+       cvs->draw_line(x, y, x+dx, y+dy);
+       cvs->draw_line(x, y+dy, x+dx, y);
+       cvs->set_opaque();
+       cvs->set_line_width(1);
+}
+
+
+ZWindowCanvasTileMixers::ZWindowCanvasTileMixers(ZWindowCanvas *canvas)
+ : BC_MenuItem(_("Tile Mixers"))
+{
+       this->canvas = canvas;
+}
+int ZWindowCanvasTileMixers::handle_event()
+{
+       canvas->mwindow->tile_mixers();
+       return 1;
+}
+
+ZWindowCanvasPlayable::ZWindowCanvasPlayable(ZWindowCanvas *canvas)
+ : BC_MenuItem(_("Playable"))
+{
+       this->canvas = canvas;
+       set_checked(canvas->gui->zwindow->playable);
+}
+int ZWindowCanvasPlayable::handle_event()
+{
+       int v = !get_checked() ? 1 : 0;
+       set_checked(v);
+       canvas->gui->set_playable(v);
+       canvas->get_canvas()->flash(1);
        return 1;
 }
 
@@ -202,6 +253,13 @@ ZWindowCanvas::ZWindowCanvas(MWindow *mwindow, ZWindowGUI *gui,
        this->gui = gui;
 }
 
+void ZWindowCanvas::create_objects(EDL *edl)
+{
+       Canvas::create_objects(edl);
+       canvas_menu->add_item(new ZWindowCanvasTileMixers(this));
+       canvas_menu->add_item(new ZWindowCanvasPlayable(this));
+}
+
 void ZWindowCanvas::close_source()
 {
        gui->unlock_window();
@@ -214,7 +272,6 @@ void ZWindowCanvas::close_source()
        }
 }
 
-
 void ZWindowCanvas::draw_refresh(int flush)
 {
        EDL *edl = gui->zwindow->edl;
@@ -240,7 +297,6 @@ void ZWindowCanvas::draw_refresh(int flush)
        
        if( gui->draw_overlays() )
                dirty = 1;
-
        if( dirty )
                cvs->flash(flush);
 }
@@ -259,3 +315,34 @@ float ZWindowCanvas::get_auto_zoom()
        return zoom_x < zoom_y ? zoom_x : zoom_y;
 }
 
+float ZWindowCanvas::get_zoom()
+{
+        return gui->zwindow->zoom;
+}
+void ZWindowCanvas::update_zoom(int x, int y, float zoom)
+{
+        gui->zwindow->zoom = zoom;
+}
+
+void ZWindowCanvas::zoom_auto()
+{
+       EDL *edl = gui->zwindow->edl;
+       if( !edl ) edl = mwindow->edl;
+        set_zoom(edl, 0);
+}
+
+void ZWindowCanvas::zoom_resize_window(float zoom)
+{
+       if( !zoom ) zoom = get_auto_zoom();
+       EDL *edl = gui->zwindow->edl;
+       if( !edl ) edl = mwindow->edl;
+       int ow = edl->session->output_w, oh = edl->session->output_h;
+       int canvas_w, canvas_h;
+       calculate_sizes(mwindow->edl->get_aspect_ratio(), ow, oh,
+               zoom, canvas_w, canvas_h);
+       int new_w = canvas_w + xS(20);
+       int new_h = canvas_h + yS(20);
+       gui->resize_window(new_w, new_h);
+       gui->resize_event(new_w, new_h);
+}
+