remove whitespace at eol
[goodguy/history.git] / cinelerra-5.1 / cinelerra / zoombar.C
index 7730d918bc675df3403a1bfcc917bbdad55c95cd..401898c7122645c675cbf1924b3f730f025d4193 100644 (file)
@@ -2,21 +2,21 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- * 
+ *
  */
 
 #include "apatchgui.inc"
@@ -45,7 +45,7 @@ ZoomBar::ZoomBar(MWindow *mwindow, MWindowGUI *gui)
  : BC_SubWindow(mwindow->theme->mzoom_x,
        mwindow->theme->mzoom_y,
        mwindow->theme->mzoom_w,
-       mwindow->theme->mzoom_h) 
+       mwindow->theme->mzoom_h)
 {
        this->gui = gui;
        this->mwindow = mwindow;
@@ -62,7 +62,7 @@ ZoomBar::~ZoomBar()
 void ZoomBar::create_objects()
 {
        int x = 3;
-       int y = get_h() / 2 - 
+       int 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());
@@ -88,16 +88,21 @@ void ZoomBar::create_objects()
        track_zoom->zoom_tumbler->set_tooltip(_("Height of tracks in the timeline"));
        x += track_zoom->get_w() + 10;
 
-       add_subwindow(auto_type = new AutoTypeMenu(mwindow, this, x, y));
+       int wid = 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;
 #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, 
+               mwindow,
+               this,
+               x,
                y,
                DEFAULT_TEXT));
        x += auto_zoom_text->get_w() + 5;
@@ -171,26 +176,30 @@ int ZoomBar::draw()
 void ZoomBar::update_autozoom()
 {
        char string[BCTEXTLEN];
-       switch (mwindow->edl->local_session->zoombar_showautotype) {
+       int autogroup_type = mwindow->edl->local_session->zoombar_showautotype;
+       switch( autogroup_type ) {
        case AUTOGROUPTYPE_AUDIO_FADE:
        case AUTOGROUPTYPE_VIDEO_FADE:
-               sprintf(string, "%0.01f to %0.01f\n", 
-                       mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype],
-                       mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype]);
+               sprintf(string, "%0.01f to %0.01f\n",
+                       mwindow->edl->local_session->automation_mins[autogroup_type],
+                       mwindow->edl->local_session->automation_maxs[autogroup_type]);
                break;
        case AUTOGROUPTYPE_ZOOM:
-               sprintf(string, "%0.03f to %0.03f\n", 
-                       mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype],
-                       mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype]);
+       case AUTOGROUPTYPE_SPEED:
+               sprintf(string, "%0.03f to %0.03f\n",
+                       mwindow->edl->local_session->automation_mins[autogroup_type],
+                       mwindow->edl->local_session->automation_maxs[autogroup_type]);
                break;
        case AUTOGROUPTYPE_X:
        case AUTOGROUPTYPE_Y:
-               sprintf(string, "%0.0f to %.0f\n", 
-                       mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype],
-                       mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype]);
+               sprintf(string, "%0.0f to %.0f\n",
+                       mwindow->edl->local_session->automation_mins[autogroup_type],
+                       mwindow->edl->local_session->automation_maxs[autogroup_type]);
                break;
        }
        auto_zoom_text->update(string);
+       const char *group_name = AutoTypeMenu::to_text(autogroup_type);
+       auto_type->set_text(group_name);
 }
 
 int ZoomBar::update()
@@ -206,7 +215,7 @@ int ZoomBar::update()
 int ZoomBar::update_clocks()
 {
        from_value->update_position(mwindow->edl->local_session->get_selectionstart(1));
-       length_value->update_position(mwindow->edl->local_session->get_selectionend(1) - 
+       length_value->update_position(mwindow->edl->local_session->get_selectionend(1) -
                mwindow->edl->local_session->get_selectionstart(1));
        to_value->update_position(mwindow->edl->local_session->get_selectionend(1));
        return 0;
@@ -216,10 +225,10 @@ int ZoomBar::update_playback(int64_t new_position)
 {
        if(new_position != old_position)
        {
-               Units::totext(string, 
-                               new_position, 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+               Units::totext(string,
+                               new_position,
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
                playback_value->update(string);
@@ -253,14 +262,14 @@ int ZoomBar::set_selection(int which_one)
        switch(which_one)
        {
                case SET_LENGTH:
-                       start_position = Units::text_to_seconds(from_value->get_text(), 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+                       start_position = Units::text_to_seconds(from_value->get_text(),
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
-                       length = Units::text_to_seconds(length_value->get_text(), 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+                       length = Units::text_to_seconds(length_value->get_text(),
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
                        end_position = start_position + length;
@@ -274,14 +283,14 @@ int ZoomBar::set_selection(int which_one)
                        break;
 
                case SET_FROM:
-                       start_position = Units::text_to_seconds(from_value->get_text(), 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+                       start_position = Units::text_to_seconds(from_value->get_text(),
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
-                       end_position = Units::text_to_seconds(to_value->get_text(), 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+                       end_position = Units::text_to_seconds(to_value->get_text(),
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
 
@@ -294,14 +303,14 @@ int ZoomBar::set_selection(int which_one)
                        break;
 
                case SET_TO:
-                       start_position = Units::text_to_seconds(from_value->get_text(), 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+                       start_position = Units::text_to_seconds(from_value->get_text(),
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
-                       end_position = Units::text_to_seconds(to_value->get_text(), 
-                               mwindow->edl->session->sample_rate, 
-                               mwindow->edl->session->time_format, 
+                       end_position = Units::text_to_seconds(to_value->get_text(),
+                               mwindow->edl->session->sample_rate,
+                               mwindow->edl->session->time_format,
                                mwindow->edl->session->frame_rate,
                                mwindow->edl->session->frames_per_foot);
 
@@ -341,18 +350,18 @@ int ZoomBar::set_selection(int which_one)
 
 
 
-SampleZoomPanel::SampleZoomPanel(MWindow *mwindow, 
-       ZoomBar *zoombar, 
-       int x, 
+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, 
+ : ZoomPanel(mwindow,
+       zoombar,
+       mwindow->edl->local_session->zoom_sample,
+       x,
+       y,
+       110,
+       MIN_ZOOM_TIME,
+       MAX_ZOOM_TIME,
        ZOOM_TIME)
 {
        this->mwindow = mwindow;
@@ -366,14 +375,14 @@ 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, 
+ : ZoomPanel(mwindow,
+       zoombar,
+       mwindow->edl->local_session->zoom_y,
+       x,
+       y,
        80,
-       MIN_AMP_ZOOM, 
-       MAX_AMP_ZOOM, 
+       MIN_AMP_ZOOM,
+       MAX_AMP_ZOOM,
        ZOOM_LONG)
 {
        this->mwindow = mwindow;
@@ -386,14 +395,14 @@ int AmpZoomPanel::handle_event()
 }
 
 TrackZoomPanel::TrackZoomPanel(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
- : ZoomPanel(mwindow, 
-       zoombar, 
-       mwindow->edl->local_session->zoom_track, 
-       x, 
-       y, 
+ : ZoomPanel(mwindow,
+       zoombar,
+       mwindow->edl->local_session->zoom_track,
+       x,
+       y,
        70,
-       MIN_TRACK_ZOOM, 
-       MAX_TRACK_ZOOM, 
+       MIN_TRACK_ZOOM,
+       MAX_TRACK_ZOOM,
        ZOOM_LONG)
 {
        this->mwindow = mwindow;
@@ -447,8 +456,8 @@ int AutoZoom::handle_down_event()
 
 
 
-AutoTypeMenu::AutoTypeMenu(MWindow *mwindow, ZoomBar *zoombar, int x, int y)
-       : BC_PopupMenu(x, y, 120,to_text(mwindow->edl->local_session->zoombar_showautotype), 1)
+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)
 {
        this->mwindow = mwindow;
        this->zoombar = zoombar;
@@ -460,6 +469,7 @@ void AutoTypeMenu::create_objects()
        add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_AUDIO_FADE)));
        add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_VIDEO_FADE)));
        add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_ZOOM)));
+       add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_SPEED)));
        add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_X)));
        add_item(new BC_MenuItem(to_text(AUTOGROUPTYPE_Y)));
 }
@@ -470,6 +480,7 @@ const char* AutoTypeMenu::to_text(int mode)
        case AUTOGROUPTYPE_AUDIO_FADE: return _("Audio Fade:");
        case AUTOGROUPTYPE_VIDEO_FADE: return _("Video Fade:");
        case AUTOGROUPTYPE_ZOOM: return _("Zoom:");
+       case AUTOGROUPTYPE_SPEED: return _("Speed:");
        case AUTOGROUPTYPE_X: return "X:";
        case AUTOGROUPTYPE_Y: return "Y:";
        }
@@ -478,16 +489,12 @@ const char* AutoTypeMenu::to_text(int mode)
 
 int AutoTypeMenu::from_text(char *text)
 {
-       if(!strcmp(text, to_text(AUTOGROUPTYPE_AUDIO_FADE)))
-               return AUTOGROUPTYPE_AUDIO_FADE;
-       if(!strcmp(text, to_text(AUTOGROUPTYPE_VIDEO_FADE)))
-               return AUTOGROUPTYPE_VIDEO_FADE;
-       if(!strcmp(text, to_text(AUTOGROUPTYPE_ZOOM)))
-               return AUTOGROUPTYPE_ZOOM;
-       if(!strcmp(text, to_text(AUTOGROUPTYPE_X)))
-               return AUTOGROUPTYPE_X;
-       if(!strcmp(text, to_text(AUTOGROUPTYPE_Y)))
-               return AUTOGROUPTYPE_Y;
+       if(!strcmp(text, to_text(AUTOGROUPTYPE_AUDIO_FADE))) return AUTOGROUPTYPE_AUDIO_FADE;
+       if(!strcmp(text, to_text(AUTOGROUPTYPE_VIDEO_FADE))) return AUTOGROUPTYPE_VIDEO_FADE;
+       if(!strcmp(text, to_text(AUTOGROUPTYPE_ZOOM))) return AUTOGROUPTYPE_ZOOM;
+       if(!strcmp(text, to_text(AUTOGROUPTYPE_SPEED))) return AUTOGROUPTYPE_SPEED;
+       if(!strcmp(text, to_text(AUTOGROUPTYPE_X))) return AUTOGROUPTYPE_X;
+       if(!strcmp(text, to_text(AUTOGROUPTYPE_Y))) return AUTOGROUPTYPE_Y;
        return AUTOGROUPTYPE_INT255;
 }
 
@@ -541,7 +548,7 @@ int ZoomTextBox::handle_event()
        {
                AUTOMATIONVIEWCLAMPS(min, mwindow->edl->local_session->zoombar_showautotype);
                AUTOMATIONVIEWCLAMPS(max, mwindow->edl->local_session->zoombar_showautotype);
-               if (max > min) 
+               if (max > min)
                {
                        mwindow->edl->local_session->automation_mins[mwindow->edl->local_session->zoombar_showautotype] = min;
                        mwindow->edl->local_session->automation_maxs[mwindow->edl->local_session->zoombar_showautotype] = max;
@@ -579,12 +586,12 @@ int FromTextBox::handle_event()
 
 int FromTextBox::update_position(double new_position)
 {
-       new_position += mwindow->edl->session->get_frame_offset() / 
+       new_position += mwindow->edl->session->get_frame_offset() /
                                                 mwindow->edl->session->frame_rate;;
-       Units::totext(string, 
-               new_position, 
-               mwindow->edl->session->time_format, 
-               mwindow->edl->session->sample_rate, 
+       Units::totext(string,
+               new_position,
+               mwindow->edl->session->time_format,
+               mwindow->edl->session->sample_rate,
                mwindow->edl->session->frame_rate,
                mwindow->edl->session->frames_per_foot);
 //printf("FromTextBox::update_position %f %s\n", new_position, string);
@@ -617,10 +624,10 @@ int LengthTextBox::handle_event()
 
 int LengthTextBox::update_position(double new_position)
 {
-       Units::totext(string, 
-               new_position, 
-               mwindow->edl->session->time_format, 
-               mwindow->edl->session->sample_rate, 
+       Units::totext(string,
+               new_position,
+               mwindow->edl->session->time_format,
+               mwindow->edl->session->sample_rate,
                mwindow->edl->session->frame_rate,
                mwindow->edl->session->frames_per_foot);
        update(string);
@@ -653,10 +660,10 @@ int ToTextBox::update_position(double new_position)
 {
        new_position += mwindow->edl->session->get_frame_offset() /
                                                 mwindow->edl->session->frame_rate;
-       Units::totext(string, 
-               new_position, 
-               mwindow->edl->session->time_format, 
-               mwindow->edl->session->sample_rate, 
+       Units::totext(string,
+               new_position,
+               mwindow->edl->session->time_format,
+               mwindow->edl->session->sample_rate,
                mwindow->edl->session->frame_rate,
                mwindow->edl->session->frames_per_foot);
        update(string);