rework histogram_bezier, init wm icon set_icon(gg), update de.po+msg/txt
[goodguy/history.git] / cinelerra-5.1 / cinelerra / cpanel.C
index e6c5cff575997abb1fc635944ee535f883e31cc2..87e753cd04e390b79c3f13ce9d37a6515d1b777c 100644 (file)
  *
  */
 
+#include "automation.h"
 #include "cpanel.h"
+#include "cwindow.h"
 #include "cwindowgui.h"
 #include "cwindowtool.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "floatauto.h"
 #include "language.h"
 #include "mbuttons.h"
 #include "mwindow.h"
+#include "mwindowgui.h"
 #include "theme.h"
+#include "track.h"
 
 
 
@@ -73,18 +78,27 @@ void CPanel::create_objects()
        subwindow->add_subwindow(operation[CWINDOW_TOOL_WINDOW] = new CPanelToolWindow(mwindow, this, x, y));
        y += operation[CWINDOW_TOOL_WINDOW]->get_h();
        subwindow->add_subwindow(operation[CWINDOW_TITLESAFE] = new CPanelTitleSafe(mwindow, this, x, y));
+       y += operation[CWINDOW_TITLESAFE]->get_h();
+       x += (w - BC_Slider::get_span(1)) / 2;  y += 15;
+       subwindow->add_subwindow(cpanel_zoom = new CPanelZoom(mwindow, this, x, y, h-y-20));
 }
 
-void CPanel::reposition_buttons(int x, int y)
+void CPanel::reposition_buttons(int x, int y, int h)
 {
        this->x = x;
        this->y = y;
+       this->h = h;
 
        for(int i = 0; i < CPANEL_OPERATIONS; i++)
        {
                operation[i]->reposition_window(x, y);
                y += operation[i]->get_h();
        }
+       x += (w - BC_Slider::get_span(1)) / 2;
+       y += 15;
+       h = this->h - this->y;
+       cpanel_zoom->reposition_window(x, y, w, h-y-20);
+       cpanel_zoom->set_pointer_motion_range(h);
 }
 
 
@@ -114,6 +128,13 @@ void CPanel::set_operation(int value)
                                operation[i]->update(1);
                }
        }
+       if( operation[CWINDOW_ZOOM]->get_value() ||
+           operation[CWINDOW_CAMERA]->get_value() ||
+           operation[CWINDOW_PROJECTOR]->get_value() ) {
+               cpanel_zoom->set_shown(1);
+       }
+       else
+               cpanel_zoom->set_shown(0);
 }
 
 
@@ -128,7 +149,7 @@ CPanelProtect::CPanelProtect(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Protect video from changes"));
+       set_tooltip(_("Protect video from changes (F1)"));
 }
 CPanelProtect::~CPanelProtect()
 {
@@ -152,7 +173,7 @@ CPanelMask::CPanelMask(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Edit mask"));
+       set_tooltip(_("Edit mask (F3)"));
 }
 CPanelMask::~CPanelMask()
 {
@@ -174,7 +195,7 @@ CPanelRuler::CPanelRuler(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Ruler"));
+       set_tooltip(_("Ruler (F4)"));
 }
 CPanelRuler::~CPanelRuler()
 {
@@ -196,7 +217,7 @@ CPanelMagnify::CPanelMagnify(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Zoom view"));
+       set_tooltip(_("Zoom view (F2)"));
 }
 CPanelMagnify::~CPanelMagnify()
 {
@@ -216,7 +237,7 @@ CPanelCamera::CPanelCamera(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Adjust camera automation"));
+       set_tooltip(_("Adjust camera automation (F5)"));
 }
 CPanelCamera::~CPanelCamera()
 {
@@ -236,7 +257,7 @@ CPanelProj::CPanelProj(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Adjust projector automation"));
+       set_tooltip(_("Adjust projector automation (F6)"));
 }
 CPanelProj::~CPanelProj()
 {
@@ -256,7 +277,7 @@ CPanelCrop::CPanelCrop(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Crop a layer or output"));
+       set_tooltip(_("Crop a layer or output (F7)"));
 }
 
 CPanelCrop::~CPanelCrop()
@@ -280,7 +301,7 @@ CPanelEyedrop::CPanelEyedrop(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Get color"));
+       set_tooltip(_("Get color (F8)"));
 }
 
 CPanelEyedrop::~CPanelEyedrop()
@@ -304,7 +325,7 @@ CPanelToolWindow::CPanelToolWindow(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Show tool info"));
+       set_tooltip(_("Show tool info (F9)"));
 }
 
 CPanelToolWindow::~CPanelToolWindow()
@@ -335,7 +356,7 @@ CPanelTitleSafe::CPanelTitleSafe(MWindow *mwindow, CPanel *gui, int x, int y)
 {
        this->mwindow = mwindow;
        this->gui = gui;
-       set_tooltip(_("Show safe regions"));
+       set_tooltip(_("Show safe regions (F10)"));
 }
 CPanelTitleSafe::~CPanelTitleSafe()
 {
@@ -347,3 +368,77 @@ int CPanelTitleSafe::handle_event()
        return 1;
 }
 
+CPanelZoom::CPanelZoom(MWindow *mwindow, CPanel *gui, int x, int y, int h)
+ : BC_FSlider(x, y, 1, h, h, -2., 2., 0, 0)
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+       set_precision(0.001);
+       set_tooltip(_("Zoom"));
+}
+CPanelZoom::~CPanelZoom()
+{
+}
+int CPanelZoom::handle_event()
+{
+       FloatAuto *z_auto = 0;
+       int aidx = -1;
+       float value = get_value();
+       BC_FSlider::update(value);
+       double zoom = pow(10.,value);
+       switch( mwindow->edl->session->cwindow_operation ) {
+       case CWINDOW_ZOOM:
+               gui->subwindow->zoom_canvas(zoom, 1);
+               break;
+       case CWINDOW_CAMERA:
+               aidx = AUTOMATION_CAMERA_Z;
+               break;
+       case CWINDOW_PROJECTOR:
+               aidx = AUTOMATION_PROJECTOR_Z;
+               break;
+       }
+       if( aidx < 0 ) return 1;
+       Track *track = mwindow->cwindow->calculate_affected_track();
+       if( !track ) return 1;
+       z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
+                       track->automation->autos[aidx], 1);
+       if( !z_auto ) return 1;
+       z_auto->set_value(zoom);
+       gui->subwindow->update_tool();
+       mwindow->gui->lock_window("CPanelZoom::handle_event 1");
+       mwindow->gui->draw_overlays(1);
+       mwindow->gui->unlock_window();
+       mwindow->sync_parameters(CHANGE_PARAMS);
+       return 1;
+}
+
+int CPanelZoom::set_shown(int shown)
+{
+       if( shown ) {
+               show();
+               update(gui->subwindow->canvas->get_zoom());
+       }
+       else
+               hide();
+       return 1;
+}
+
+char *CPanelZoom::get_caption()
+{
+       double value = get_value();
+       int frac = value >= 0. ? 1 : value >= -1. ? 2 : 3;
+       double zoom = pow(10., value);
+       char *caption = BC_Slider::get_caption();
+       sprintf(caption, "%.*f", frac, zoom);
+       return caption;
+}
+
+void CPanelZoom::update(float zoom)
+{
+       if( !is_hidden() ) {
+               if( zoom < 0.01 ) zoom = 0.01;
+               float value = log10f(zoom);
+               BC_FSlider::update(value);
+       }
+}
+