fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / zoombar.C
index 9f1c95bcb0e9d596f7562176179350e226ec2fe9..2d37401413f8d429f660b778a7f5b098b353b4cc 100644 (file)
 
 #include "apatchgui.inc"
 #include "clip.h"
+#include "cwindow.h"
+#include "cwindowgui.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "keys.h"
 #include "language.h"
 #include "localsession.h"
 #include "maincursor.h"
@@ -53,14 +56,15 @@ ZoomBar::~ZoomBar()
 {
        delete sample_zoom;
        delete amp_zoom;
-       delete track_zoom;
+       delete atrack_zoom;
+       delete vtrack_zoom;
 }
 
 void ZoomBar::create_objects()
 {
-       int x = 3;
-       int y = get_h() / 2 -
-               mwindow->theme->get_image_set("zoombar_menu", 0)[0]->get_h() / 2;
+       int xs5 = xS(5), xs10 = xS(10);
+       int x = xS(3), y = get_h()/2 -
+               mwindow->theme->get_image_set("zoombar_menu", 0)[0]->get_h()/2;
 
        draw_top_background(get_parent(), 0, 0, get_w(), get_h());
        sample_zoom = new SampleZoomPanel(mwindow, this, x, y);
@@ -71,40 +75,41 @@ void ZoomBar::create_objects()
        amp_zoom->create_objects();
        amp_zoom->set_tooltip(_("Audio waveform scale"));
        x += amp_zoom->get_w();
-       track_zoom = new TrackZoomPanel(mwindow, this, x, y);
-       track_zoom->create_objects();
-       track_zoom->set_tooltip(_("Height of tracks in the timeline"));
-       x += track_zoom->get_w() + 10;
-
-       int wid = 120;
+       atrack_zoom = new ATrackZoomPanel(mwindow, this, x, y);
+       atrack_zoom->create_objects();
+       atrack_zoom->set_tooltip(_("Height of audio tracks"));
+       x += atrack_zoom->get_w() + xs10;
+       vtrack_zoom = new VTrackZoomPanel(mwindow, this, x, y);
+       vtrack_zoom->create_objects();
+       vtrack_zoom->set_tooltip(_("Height of video tracks"));
+       x += vtrack_zoom->get_w() + xs10;
+
+       int wid = xS(120);
        for( int i=AUTOGROUPTYPE_AUDIO_FADE; i<=AUTOGROUPTYPE_Y; ++i ) {
                int ww = BC_GenericButton::calculate_w(this, AutoTypeMenu::to_text(i));
                if( ww > wid ) wid = ww;
        }
        add_subwindow(auto_type = new AutoTypeMenu(mwindow, this, x, y, wid));
        auto_type->create_objects();
-       x += auto_type->get_w() + 10;
+       x += auto_type->get_w() + xs10;
 #define DEFAULT_TEXT "000.00 to 000.00"
        add_subwindow(auto_zoom = new AutoZoom(mwindow, this, x, y, 0));
        x += auto_zoom->get_w();
-       add_subwindow(auto_zoom_text = new ZoomTextBox(
-               mwindow,
-               this,
-               x,
-               y,
-               DEFAULT_TEXT));
-       x += auto_zoom_text->get_w() + 5;
+       add_subwindow(auto_zoom_text = new ZoomTextBox(mwindow, this, x, y, DEFAULT_TEXT));
+       x += auto_zoom_text->get_w() + xs5;
        add_subwindow(auto_zoom = new AutoZoom(mwindow, this, x, y, 1));
        update_autozoom();
-       x += auto_zoom->get_w() + 5;
+       x += auto_zoom->get_w() + xs5;
 
        add_subwindow(from_value = new FromTextBox(mwindow, this, x, y));
-       x += from_value->get_w() + 5;
+       x += from_value->get_w() + xs5;
        add_subwindow(length_value = new LengthTextBox(mwindow, this, x, y));
-       x += length_value->get_w() + 5;
+       x += length_value->get_w() + xs5;
        add_subwindow(to_value = new ToTextBox(mwindow, this, x, y));
-       x += to_value->get_w() + 5;
-       add_subwindow(title_alpha = new TitleBarAlpha(mwindow, this, x, y));
+       x += to_value->get_w() + xs5;
+       add_subwindow(title_alpha_bar = new TitleAlphaBar(mwindow, this, x, y));
+       x += title_alpha_bar->get_w() + xs5;
+       add_subwindow(title_alpha_text = new TitleAlphaText(mwindow, this, x, y));
 
        update_formatting(from_value);
        update_formatting(length_value);
@@ -146,9 +151,22 @@ int ZoomBar::draw()
 }
 
 void ZoomBar::update_autozoom()
+{
+       update_autozoom(mwindow->edl->local_session->zoombar_showautocolor);
+}
+
+void ZoomBar::update_autozoom(int grouptype, int color)
+{
+       mwindow->edl->local_session->zoombar_showautotype = grouptype;
+       update_autozoom(color);
+}
+
+void ZoomBar::update_autozoom(int color)
 {
        char string[BCTEXTLEN];
        int autogroup_type = mwindow->edl->local_session->zoombar_showautotype;
+       mwindow->edl->local_session->zoombar_showautocolor = color;
+       if( color < 0 ) color = get_resources()->default_text_color;
        switch( autogroup_type ) {
        case AUTOGROUPTYPE_AUDIO_FADE:
        case AUTOGROUPTYPE_VIDEO_FADE:
@@ -172,13 +190,27 @@ void ZoomBar::update_autozoom()
        auto_zoom_text->update(string);
        const char *group_name = AutoTypeMenu::to_text(autogroup_type);
        auto_type->set_text(group_name);
+       switch( autogroup_type ) {
+       case AUTOGROUPTYPE_ZOOM:
+       case AUTOGROUPTYPE_X:
+       case AUTOGROUPTYPE_Y:
+               CWindowGUI *cgui = mwindow->cwindow->gui;
+               unlock_window();
+               cgui->lock_window("ZoomBar::update_autozoom");
+               cgui->update_tool();
+               cgui->unlock_window();
+               lock_window("ZoomBar::update_autozoom");
+               break;
+       }
 }
 
+
 int ZoomBar::update()
 {
        sample_zoom->update(mwindow->edl->local_session->zoom_sample);
        amp_zoom->update(mwindow->edl->local_session->zoom_y);
-       track_zoom->update(mwindow->edl->local_session->zoom_track);
+       atrack_zoom->update(mwindow->edl->local_session->zoom_atrack);
+       vtrack_zoom->update(mwindow->edl->local_session->zoom_vtrack);
        update_autozoom();
        update_clocks();
        return 0;
@@ -193,18 +225,38 @@ int ZoomBar::update_clocks()
        return 0;
 }
 
-TitleBarAlpha::TitleBarAlpha(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
- : BC_FSlider(x, y, 0, 150, 200, 0, 1.0, mwindow->session->title_bar_alpha, 0)
+TitleAlphaBar::TitleAlphaBar(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+ : BC_FSlider(x, y, 0, xS(150), xS(200), 0, 1.0, mwindow->session->title_bar_alpha, 0)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
        set_precision(0.01);
-       set_tooltip(_("TitleBar Alpha"));
+       enable_show_value(0);
+}
+
+int TitleAlphaBar::handle_event()
+{
+       float v = get_value();
+       mwindow->session->title_bar_alpha = v;
+       zoombar->title_alpha_text->update(v);
+       mwindow->gui->draw_trackmovement();
+       mwindow->gui->flush();
+       return 1;
+}
+
+TitleAlphaText::TitleAlphaText(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+ : BC_TextBox(x, y, xS(48), 1, mwindow->session->title_bar_alpha, 0, MEDIUMFONT, 2)
+{
+       this->mwindow = mwindow;
+       this->zoombar = zoombar;
+       set_tooltip(_("Title Alpha"));
 }
 
-int TitleBarAlpha::handle_event()
+int TitleAlphaText::handle_event()
 {
-       mwindow->session->title_bar_alpha = get_value();
+       float v = atof(get_text());
+       mwindow->session->title_bar_alpha = v;
+       zoombar->title_alpha_bar->update(v);
        mwindow->gui->draw_trackmovement();
        mwindow->gui->flush();
        return 1;
@@ -313,19 +365,9 @@ int ZoomBar::set_selection(int which_one)
 }
 
 
-
-
-
-
-
-
-
-
-
-
 SampleZoomPanel::SampleZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
  : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_sample,
-               x, y, 110, MIN_ZOOM_TIME, MAX_ZOOM_TIME, ZOOM_TIME)
+               x, y, xS(130), MIN_ZOOM_TIME, MAX_ZOOM_TIME, ZOOM_TIME)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -339,7 +381,7 @@ int SampleZoomPanel::handle_event()
 
 AmpZoomPanel::AmpZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
  : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_y,
-               x, y, 80, MIN_AMP_ZOOM, MAX_AMP_ZOOM, ZOOM_LONG)
+               x, y, xS(80), MIN_AMP_ZOOM, MAX_AMP_ZOOM, ZOOM_LONG)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -350,21 +392,32 @@ int AmpZoomPanel::handle_event()
        return 1;
 }
 
-TrackZoomPanel::TrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
- : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_track,
-               x, y, 70, MIN_TRACK_ZOOM, MAX_TRACK_ZOOM, ZOOM_LONG)
+ATrackZoomPanel::ATrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+ : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_atrack,
+               x, y, xS(64), MIN_TRACK_ZOOM, MAX_TRACK_ZOOM, ZOOM_LONG)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
 }
-int TrackZoomPanel::handle_event()
+int ATrackZoomPanel::handle_event()
 {
-       mwindow->zoom_track((int64_t)get_value());
+       mwindow->zoom_atrack((int64_t)get_value());
        zoombar->amp_zoom->update(mwindow->edl->local_session->zoom_y);
        return 1;
 }
 
-
+VTrackZoomPanel::VTrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
+ : ZoomPanel(mwindow, zoombar, mwindow->edl->local_session->zoom_vtrack,
+               x, y, xS(64), MIN_TRACK_ZOOM, MAX_TRACK_ZOOM, ZOOM_LONG)
+{
+       this->mwindow = mwindow;
+       this->zoombar = zoombar;
+}
+int VTrackZoomPanel::handle_event()
+{
+       mwindow->zoom_vtrack((int64_t)get_value());
+       return 1;
+}
 
 
 AutoZoom::AutoZoom(MWindow *mwindow, ZoomBar *zoombar, int x, int y, int changemax)
@@ -404,7 +457,8 @@ int AutoZoom::handle_down_event()
 
 
 AutoTypeMenu::AutoTypeMenu(MWindow *mwindow, ZoomBar *zoombar, int x, int y, int wid)
-       : BC_PopupMenu(x, y, wid, to_text(mwindow->edl->local_session->zoombar_showautotype), 1)
+ : BC_PopupMenu(x, y, wid + xS(24),
+       to_text(mwindow->edl->local_session->zoombar_showautotype), 1, 0, 12)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -445,6 +499,20 @@ int AutoTypeMenu::from_text(char *text)
        return AUTOGROUPTYPE_INT255;
 }
 
+int AutoTypeMenu::draw_face(int dx, int color)
+{
+       BC_PopupMenu::draw_face(dx+xS(8), color);
+       color = mwindow->edl->local_session->zoombar_showautocolor;
+       if( color >= 0 ) {
+               set_color(color);
+               int margin = get_margin();
+               int mx = margin+xS(8), my = 3*margin/8;
+               int bh = get_h() - 2*my;
+               draw_box(mx,my, bh,bh);
+       }
+       return 1;
+}
+
 int AutoTypeMenu::handle_event()
 {
        mwindow->edl->local_session->zoombar_showautotype = from_text(this->get_text());
@@ -454,7 +522,7 @@ int AutoTypeMenu::handle_event()
 
 
 ZoomTextBox::ZoomTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y, const char *text)
- : BC_TextBox(x, y, 130, 1, text)
+ : BC_TextBox(x, y, xS(130), 1, text)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -514,7 +582,7 @@ int ZoomTextBox::handle_event()
 
 
 FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
- : BC_TextBox(x, y, 90, 1, "")
+ : BC_TextBox(x, y, xS(90), 1, "")
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -523,7 +591,7 @@ FromTextBox::FromTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
 
 int FromTextBox::handle_event()
 {
-       if(get_keypress() == 13)
+       if(get_keypress() == NEWLINE)
        {
                zoombar->set_selection(SET_FROM);
                return 1;
@@ -550,7 +618,7 @@ int FromTextBox::update_position(double new_position)
 
 
 LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
- : BC_TextBox(x, y, 90, 1, "")
+ : BC_TextBox(x, y, xS(90), 1, "")
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -559,7 +627,7 @@ LengthTextBox::LengthTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
 
 int LengthTextBox::handle_event()
 {
-       if(get_keypress() == 13)
+       if(get_keypress() == NEWLINE)
        {
                zoombar->set_selection(SET_LENGTH);
                return 1;
@@ -584,7 +652,7 @@ int LengthTextBox::update_position(double new_position)
 
 
 ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
- : BC_TextBox(x, y, 90, 1, "")
+ : BC_TextBox(x, y, xS(90), 1, "")
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -593,7 +661,7 @@ ToTextBox::ToTextBox(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
 
 int ToTextBox::handle_event()
 {
-       if(get_keypress() == 13)
+       if(get_keypress() == NEWLINE)
        {
                zoombar->set_selection(SET_TO);
                return 1;