2010-08-11 19:40:51 -04:00
/*
2019-08-02 17:26:43 -04:00
* Copyright ( C ) 2015 - 2016 Colin Fletcher < colin . m . fletcher @ googlemail . com >
* Copyright ( C ) 2016 - 2018 Paul Davis < paul @ linuxaudiosystems . com >
* Copyright ( C ) 2016 Ben Loftis < ben @ harrisonconsoles . com >
*
* 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 . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
*/
2010-08-11 19:40:51 -04:00
# include <gtkmm/table.h>
# include <gtkmm/comboboxtext.h>
# include <gtkmm/stock.h>
2010-08-11 20:19:06 -04:00
# include <gtkmm/alignment.h>
2015-06-16 06:23:50 -04:00
# include "insert_remove_time_dialog.h"
2010-08-11 19:40:51 -04:00
# include "audio_clock.h"
2016-10-20 15:53:34 -04:00
# include "ardour_ui.h"
# include "main_clock.h"
2016-07-14 14:44:52 -04:00
# include "pbd/i18n.h"
2010-08-11 19:40:51 -04:00
using namespace Gtk ;
using namespace Editing ;
2016-10-20 15:53:34 -04:00
using namespace ARDOUR ;
2010-08-11 19:40:51 -04:00
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : InsertRemoveTimeDialog ( PublicEditor & e , bool remove )
: ArdourDialog ( remove ? _ ( " Remove Time " ) : _ ( " Insert Time " ) )
2010-08-11 19:40:51 -04:00
, _editor ( e )
2016-10-20 15:53:34 -04:00
, duration_clock ( " insertTimeClock " , true , " " ,
2015-06-16 11:20:26 -04:00
true , // editable
false , // follows_playhead
true , // duration
false , // with_info
true // accept_on_focus_out
)
2016-10-20 15:53:34 -04:00
, position_clock ( " insertPosTimeClock " , true , " " ,
true , // editable
false , // follows_playhead
false , // duration
false , // with_info
true // accept_on_focus_out
)
2010-08-11 19:40:51 -04:00
{
set_session ( _editor . session ( ) ) ;
2011-06-01 13:00:29 -04:00
2010-08-11 19:40:51 -04:00
get_vbox ( ) - > set_border_width ( 12 ) ;
get_vbox ( ) - > set_spacing ( 4 ) ;
2016-10-20 15:53:34 -04:00
Table * table = manage ( new Table ( 2 , 3 ) ) ;
2010-08-11 19:40:51 -04:00
table - > set_spacings ( 4 ) ;
2016-10-20 15:53:34 -04:00
Label * time_label = manage ( new Label ( remove ? _ ( " Remove Time starting at: " ) : _ ( " Insert Time starting at: " ) ) ) ;
2010-08-11 19:40:51 -04:00
time_label - > set_alignment ( 1 , 0.5 ) ;
table - > attach ( * time_label , 0 , 1 , 0 , 1 , FILL | EXPAND ) ;
2016-10-20 15:53:34 -04:00
position_clock . set_session ( _session ) ;
2018-10-10 11:47:05 -04:00
position_clock . set_mode ( ARDOUR_UI : : instance ( ) - > primary_clock - > mode ( ) ) ;
2016-10-20 15:53:34 -04:00
table - > attach ( position_clock , 1 , 2 , 0 , 1 ) ;
2010-08-11 19:40:51 -04:00
2016-10-20 15:53:34 -04:00
time_label = manage ( new Label ( remove ? _ ( " Time to remove: " ) : _ ( " Time to insert: " ) ) ) ;
time_label - > set_alignment ( 1 , 0.5 ) ;
table - > attach ( * time_label , 0 , 1 , 1 , 2 , FILL | EXPAND ) ;
duration_clock . set_session ( _session ) ;
2018-10-10 11:47:05 -04:00
duration_clock . set_mode ( ARDOUR_UI : : instance ( ) - > primary_clock - > mode ( ) ) ;
2016-10-20 15:53:34 -04:00
table - > attach ( duration_clock , 1 , 2 , 1 , 2 ) ;
2022-10-20 16:04:43 -04:00
//if a Range is selected, assume the user wants to insert/remove the length of the range //if a Range is selected, assume the user wants to insert/remove the length of the range
if ( ! _editor . get_selection ( ) . time . length ( ) . is_zero ( ) ) {
2022-10-25 20:26:55 -04:00
position_clock . set ( _editor . get_selection ( ) . time . start_time ( ) , true ) ;
2022-10-20 16:04:43 -04:00
duration_clock . set_duration ( _editor . get_selection ( ) . time . length ( ) , true ) ;
2016-10-20 15:53:34 -04:00
} else {
2020-10-19 14:37:54 -04:00
timepos_t const pos = _editor . get_preferred_edit_position ( EDIT_IGNORE_MOUSE ) ;
2022-10-25 20:26:55 -04:00
position_clock . set ( pos , true ) ;
duration_clock . set_duration ( timecnt_t ( pos ) , true ) ;
2016-10-20 15:53:34 -04:00
}
2020-10-19 14:37:54 -04:00
2015-06-16 06:23:50 -04:00
if ( ! remove ) {
2015-06-16 06:28:43 -04:00
Label * intersected_label = manage ( new Label ( _ ( " Intersected regions should: " ) ) ) ;
intersected_label - > set_alignment ( 1 , 0.5 ) ;
2016-10-20 15:53:34 -04:00
table - > attach ( * intersected_label , 0 , 1 , 2 , 3 , FILL | EXPAND ) ;
2022-01-26 15:11:15 -05:00
_intersected_combo . append ( _ ( " stay in position " ) ) ;
_intersected_combo . append ( _ ( " move " ) ) ;
_intersected_combo . append ( _ ( " be split " ) ) ;
2015-06-16 06:28:43 -04:00
_intersected_combo . set_active ( 0 ) ;
2016-10-20 15:53:34 -04:00
table - > attach ( _intersected_combo , 1 , 2 , 2 , 3 ) ;
2015-06-16 06:28:43 -04:00
}
2010-08-11 19:40:51 -04:00
get_vbox ( ) - > pack_start ( * table ) ;
2020-01-10 12:59:09 -05:00
_all_playlists . set_label ( _ ( " Apply to all playlists of the selected track(s) " ) ) ;
2011-09-05 19:38:18 -04:00
get_vbox ( ) - > pack_start ( _all_playlists ) ;
2016-10-20 17:18:19 -04:00
_move_glued . set_label ( _ ( " Move glued-to-musical-time regions (MIDI regions) " ) ) ;
2016-10-20 15:59:48 -04:00
_move_glued . set_active ( ) ;
2010-08-11 19:40:51 -04:00
get_vbox ( ) - > pack_start ( _move_glued ) ;
_move_markers . set_label ( _ ( " Move markers " ) ) ;
get_vbox ( ) - > pack_start ( _move_markers ) ;
2015-06-16 06:23:50 -04:00
_move_markers . signal_toggled ( ) . connect ( sigc : : mem_fun ( * this , & InsertRemoveTimeDialog : : move_markers_toggled ) ) ;
2016-10-20 17:18:19 -04:00
_move_glued_markers . set_label ( _ ( " Move glued-to-musical-time markers " ) ) ;
2016-10-20 15:59:48 -04:00
_move_glued_markers . set_active ( ) ;
2010-08-11 20:19:06 -04:00
Alignment * indent = manage ( new Alignment ) ;
indent - > set_padding ( 0 , 0 , 12 , 0 ) ;
indent - > add ( _move_glued_markers ) ;
get_vbox ( ) - > pack_start ( * indent ) ;
2010-08-11 19:41:26 -04:00
_move_locked_markers . set_label ( _ ( " Move locked markers " ) ) ;
2010-08-11 20:19:06 -04:00
indent = manage ( new Alignment ) ;
indent - > set_padding ( 0 , 0 , 12 , 0 ) ;
indent - > add ( _move_locked_markers ) ;
get_vbox ( ) - > pack_start ( * indent ) ;
2022-04-06 12:20:54 -04:00
tempo_label . set_markup ( _ ( " Move tempo and time signature changes \n <i>(may cause oddities in the tempo map)</i> " ) ) ;
2011-12-28 16:02:31 -05:00
HBox * tempo_box = manage ( new HBox ) ;
tempo_box - > set_spacing ( 6 ) ;
tempo_box - > pack_start ( _move_tempos , false , false ) ;
tempo_box - > pack_start ( tempo_label , false , false ) ;
get_vbox ( ) - > pack_start ( * tempo_box ) ;
2010-08-11 19:40:51 -04:00
add_button ( Gtk : : Stock : : CANCEL , Gtk : : RESPONSE_CANCEL ) ;
2016-01-19 14:34:41 -05:00
Gtk : : Button * btn = manage ( new Gtk : : Button ( remove ? _ ( " Remove time " ) : _ ( " Insert time " ) ) ) ;
btn - > signal_clicked ( ) . connect ( sigc : : mem_fun ( * this , & InsertRemoveTimeDialog : : doit ) ) ;
get_action_area ( ) - > pack_start ( * btn ) ;
2010-08-11 19:40:51 -04:00
show_all ( ) ;
2010-08-11 19:41:26 -04:00
move_markers_toggled ( ) ;
2010-08-11 19:40:51 -04:00
}
InsertTimeOption
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : intersected_region_action ( )
2010-08-11 19:40:51 -04:00
{
/* only setting this to keep GCC quiet */
InsertTimeOption opt = LeaveIntersected ;
switch ( _intersected_combo . get_active_row_number ( ) ) {
case 0 :
opt = LeaveIntersected ;
break ;
case 1 :
opt = MoveIntersected ;
break ;
case 2 :
opt = SplitIntersected ;
break ;
}
return opt ;
}
2011-09-05 19:38:18 -04:00
bool
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : all_playlists ( ) const
2011-09-05 19:38:18 -04:00
{
return _all_playlists . get_active ( ) ;
}
2010-08-11 19:40:51 -04:00
bool
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : move_glued ( ) const
2010-08-11 19:40:51 -04:00
{
return _move_glued . get_active ( ) ;
}
bool
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : move_tempos ( ) const
2010-08-11 19:40:51 -04:00
{
return _move_tempos . get_active ( ) ;
}
bool
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : move_markers ( ) const
2010-08-11 19:40:51 -04:00
{
return _move_markers . get_active ( ) ;
}
2010-08-11 19:41:26 -04:00
bool
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : move_glued_markers ( ) const
2010-08-11 19:41:26 -04:00
{
return _move_glued_markers . get_active ( ) ;
}
bool
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : move_locked_markers ( ) const
2010-08-11 19:41:26 -04:00
{
return _move_locked_markers . get_active ( ) ;
}
2020-10-19 14:37:54 -04:00
timepos_t
2016-10-20 15:53:34 -04:00
InsertRemoveTimeDialog : : position ( ) const
{
return position_clock . current_time ( ) ;
}
2020-10-19 14:37:54 -04:00
timecnt_t
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : distance ( ) const
2010-08-11 19:40:51 -04:00
{
2020-10-19 14:37:54 -04:00
return duration_clock . current_duration ( position_clock . current_time ( ) ) ;
2010-08-11 19:40:51 -04:00
}
2010-08-11 19:41:26 -04:00
2016-01-19 14:34:41 -05:00
void
InsertRemoveTimeDialog : : doit ( )
{
if ( distance ( ) = = 0 ) {
Gtk : : MessageDialog msg ( * this , _ ( " Invalid or zero duration entered. Please enter a valid duration " ) ) ;
msg . run ( ) ;
return ;
}
response ( RESPONSE_OK ) ;
}
2010-08-11 19:41:26 -04:00
void
2015-06-16 06:23:50 -04:00
InsertRemoveTimeDialog : : move_markers_toggled ( )
2010-08-11 19:41:26 -04:00
{
_move_glued_markers . set_sensitive ( _move_markers . get_active ( ) ) ;
_move_locked_markers . set_sensitive ( _move_markers . get_active ( ) ) ;
}