@@ -24,6 +24,8 @@ BarReplaceDialog::BarReplaceDialog(hui::Window *parent, Song *_song, const Array
2424 duration += song->bars [i]->length ;
2525
2626 new_bar = song->bars [sel[0 ]]->pattern ();
27+ if (song->bars [sel[0 ]]->is_pause ())
28+ new_bar = BarPattern (duration, 4 , 1 );
2729
2830 set_int (" number" , sel.num );
2931 set_int (" beats" , new_bar.beats .num );
@@ -36,10 +38,13 @@ BarReplaceDialog::BarReplaceDialog(hui::Window *parent, Song *_song, const Array
3638 check (" complex" , !new_bar.is_uniform ());
3739 hide_control (" beats" , !new_bar.is_uniform ());
3840 hide_control (" pattern" , new_bar.is_uniform ());
41+ set_string (" result_duration" , song->get_time_str_long (duration));
42+ check (" type:bars" , true );
3943 check (" shift-data" , bar_dialog_move_data);
4044 check (" scale-audio" , bar_dialog_scale_audio);
4145 enable (" scale-audio" , bar_dialog_move_data);
4246
47+ on_type (Type::Bars);
4348 update_result_bpm ();
4449
4550 event (" ok" , [this ] { on_ok (); });
@@ -51,30 +56,27 @@ BarReplaceDialog::BarReplaceDialog(hui::Window *parent, Song *_song, const Array
5156 event (" number" , [this ] { on_number (); });
5257 event (" complex" , [this ] { on_complex (); });
5358 event (" shift-data" , [this ] { on_shift_data (); });
59+ event (" type:bars" , [this ] { on_type (Type::Bars); });
60+ event (" type:pause" , [this ] { on_type (Type::Pause); });
5461}
5562
5663void BarReplaceDialog::on_ok () {
5764 song->begin_action_group (" replace bars" );
5865
5966 int number = get_int (" number" );
6067
61- // if (number != sel.num) {
68+ if (type == Type::Bars) {
6269 foreachb (int i, sel)
6370 song->delete_bar (i, false );
6471 new_bar.length = duration / number;
6572 for (int i=0 ; i<number; i++)
6673 song->add_bar (sel[0 ], new_bar, BarEditMode::Ignore);
67- /* }else{
68- foreachb(int i, sel){
69- BarPattern b = *song->bars[i];
70- b.num_beats = new_bar.num_beats;
71- b.num_sub_beats = new_bar.num_sub_beats;
72- //set_bar_pattern(b, get_string("pattern"));
73- b.set_pattern(new_bar.pattern);
74- b.length = duration / number;
75- song->edit_bar(i, b, Bar::EditMode::IGNORE);
76- }
77- }*/
74+ } else {
75+ foreachb (int i, sel)
76+ song->delete_bar (i, false );
77+ new_bar = BarPattern (duration, 0 , 1 );
78+ song->add_bar (sel[0 ], new_bar, BarEditMode::Ignore);
79+ }
7880 song->end_action_group ();
7981
8082 request_destroy ();
@@ -121,4 +123,16 @@ void BarReplaceDialog::on_shift_data() {
121123 enable (" scale-audio" , is_checked (" " ));
122124}
123125
126+ void BarReplaceDialog::on_type (Type _type) {
127+ type = _type;
128+ enable (" number" , type == Type::Bars);
129+ enable (" beats" , type == Type::Bars);
130+ enable (" pattern" , type == Type::Bars);
131+ enable (" complex" , type == Type::Bars);
132+ enable (" divisor" , type == Type::Bars);
133+ enable (" result_bpm" , type == Type::Bars);
134+ enable (" result_duration" , type == Type::Pause);
135+ }
136+
137+
124138}
0 commit comments