diff -uN seq24-0.8.7/src/globals.h seq24-0.8.7-olivier/src/globals.h --- seq24-0.8.7/src/globals.h 2006-05-30 15:42:18.000000000 +0200 +++ seq24-0.8.7-olivier/src/globals.h 2007-07-01 10:39:42.000000000 +0200 @@ -27,10 +27,12 @@ #include #include +#define printstack(f) printf("DEBUG: %s(%d)->%s\n",__FILE__,__LINE__,f) + using namespace std; /* 16 per screen */ -const int c_mainwnd_rows = 4; +const int c_mainwnd_rows = 5; const int c_mainwnd_cols = 8; const int c_seqs_in_set = c_mainwnd_rows * c_mainwnd_cols; const int c_max_sets = 32; @@ -55,7 +57,8 @@ const int c_seqarea_x = c_text_x * 15; const int c_seqarea_y = c_text_y * 5; -const int c_mainwid_border = 0; +const int c_mainwid_border = 2; +const int c_mainwid_activator = 16; const int c_mainwid_spacing = 2; const int c_control_height = 0; @@ -63,7 +66,7 @@ const int c_mainwid_x = ((c_seqarea_x + c_mainwid_spacing ) * c_mainwnd_cols - c_mainwid_spacing - + c_mainwid_border * 2 ); + + c_mainwid_border * 2 + c_mainwid_activator); const int c_mainwid_y = ((c_seqarea_y + c_mainwid_spacing ) * c_mainwnd_rows + c_mainwid_border * 2 @@ -149,7 +152,7 @@ const int c_paste = 2; /* redraw when recording ms */ -const int c_redraw_ms = 40; +const int c_redraw_ms = 100; diff -uN seq24-0.8.7/src/mainwid.cpp seq24-0.8.7-olivier/src/mainwid.cpp --- seq24-0.8.7/src/mainwid.cpp 2006-05-18 03:31:23.000000000 +0200 +++ seq24-0.8.7-olivier/src/mainwid.cpp 2007-07-04 23:37:24.000000000 +0200 @@ -70,7 +70,14 @@ m_button_down = false; m_moving = false; + // init queued play (0==off, 1==on, -1==nothing) + for (int i=0;i<(c_mainwnd_rows * c_mainwnd_cols);i++) + m_queued_to_play[i]=-1; + set_double_buffered( false ); + + m_cursor_move=Gdk::Cursor(get_display (), Gdk::HAND1); + } @@ -97,8 +104,9 @@ -1 ); fill_background_window(); + draw_activator_on_pixmap(); draw_sequences_on_pixmap(); - + } @@ -115,6 +123,44 @@ } + +void +mainwid::draw_activator_on_pixmap(){ + int base_y; + + for (int i=0;iset_foreground(m_black); + m_pixmap->draw_rectangle(m_gc, true, + m_window_x-c_mainwid_activator, + c_mainwid_border+base_y-2, + c_mainwid_activator-2, c_seqarea_y-1); + m_gc->set_foreground((m_lines_activator[i])?m_black:m_white); + m_pixmap->draw_rectangle(m_gc, true, + m_window_x-c_mainwid_activator+1, + c_mainwid_border+base_y-1, + c_mainwid_activator-4, c_seqarea_y-3); + } + + +} + +void +mainwid::draw_activator_pixmap_on_window( int act ) +{ + int base_y = (c_mainwid_border + + (c_seqarea_y + c_mainwid_spacing) * act); + + m_window->draw_drawable(m_gc, + m_pixmap, + m_window_x-c_mainwid_activator, + base_y, + m_window_x-c_mainwid_activator, + base_y, + c_mainwid_activator, + c_seqarea_y ); +} + // updates background void mainwid::fill_background_window() @@ -168,17 +214,16 @@ if ( seq->get_playing() ){ m_last_playing[a_seq] = true; - m_background = m_black; + m_background = (m_queued_to_play[a_seq]!=-1)?m_grey:m_black; m_foreground = m_white; - } else { - + } else{ m_last_playing[a_seq] = false; m_background = m_white; - m_foreground = m_black; + m_foreground = (m_queued_to_play[a_seq]!=-1)?m_grey:m_black; } - m_gc->set_foreground(m_background); + m_gc->set_foreground(m_background); m_pixmap->draw_rectangle(m_gc,true, base_x + 1, base_y + 1, @@ -186,6 +231,7 @@ c_seqarea_y - 2 ); +// m_gc->set_background(m_background); m_gc->set_foreground(m_foreground); char name[20]; sprintf( name, "%.13s", seq->get_name() ); @@ -193,10 +239,10 @@ font::Color col = font::BLACK;; - if ( m_foreground == m_black ){ + if ( m_foreground == m_black){ col = font::BLACK; } - if ( m_foreground == m_white ){ + if ( m_foreground == m_white && m_background != m_grey){ col = font::WHITE; } @@ -310,6 +356,9 @@ } } + + + void mainwid::draw_sequence_pixmap_on_window( int a_seq ) { @@ -331,10 +380,8 @@ base_x, base_y, c_seqarea_x, - c_seqarea_y ); } - - - + c_seqarea_y ); + } } void @@ -435,7 +482,7 @@ void mainwid::draw_pixmap_on_window() { - queue_draw(); + queue_draw(); } @@ -454,9 +501,32 @@ return true; } +// Translates XY corridinates to a activator number +int +mainwid::activator_from_xy( int a_x, int a_y ){ + /* adjust for border */ + int x = a_x - c_mainwid_border; + int y = a_y - c_mainwid_border; + if (!m_mainperf->is_running()) + return -1; + + if (x>m_window_x-c_mainwid_activator && x<= m_window_x){ + y /= (c_seqarea_y + c_mainwid_spacing); + m_lines_activator[y]=!m_lines_activator[y]; + draw_activator_on_pixmap(); + draw_activator_pixmap_on_window(y); + return y; + } + return -1; +} + // Translates XY corridinates to a sequence number +// I splitted sequence on two part, one small on the top +// to get a fast access to the editor, and one part to toggle the play +// it's really ugly but it works ;) + int -mainwid::seq_from_xy( int a_x, int a_y ) +mainwid::seq_from_xy( int a_x, int a_y , bool& top) { /* adjust for border */ int x = a_x - c_mainwid_border; @@ -476,11 +546,11 @@ int box_test_y = y % (c_seqarea_y + c_mainwid_spacing); /* right inactive side of area */ - if ( box_test_x > c_seqarea_x - || box_test_y > c_seqarea_y ){ - - return -1; + if ( box_test_x > c_seqarea_x || box_test_y > c_seqarea_y ){ + return -1; } + /* top area of seq (in fact for edit action) */ + top =( box_test_y <= (c_text_y+4)); x /= (c_seqarea_x + c_mainwid_spacing); y /= (c_seqarea_y + c_mainwid_spacing); @@ -499,64 +569,97 @@ mainwid::on_button_press_event(GdkEventButton* a_p0) { grab_focus(); + bool top=false; - m_current_seq = seq_from_xy( (int) a_p0->x, (int) a_p0->y ); + m_current_seq = seq_from_xy( (int) a_p0->x, (int) a_p0->y ,top); if ( m_current_seq != -1 && a_p0->button == 1 ){ m_button_down = true; } + + return true; } +void +mainwid::toggle_queued_sequences(){ + for (int i=0;isequence_playing_on(i); + else if (m_queued_to_play[i]==0) + m_mainperf->sequence_playing_off(i); + + if (m_queued_to_play[i]!=-1){ + draw_sequence_on_pixmap( i); + draw_sequence_pixmap_on_window( i); + } + m_queued_to_play[i]=-1; + } + +} bool mainwid::on_button_release_event(GdkEventButton* a_p0) { - - m_current_seq = seq_from_xy( (int) a_p0->x, (int) a_p0->y ); + bool top=false; + m_current_seq = seq_from_xy( (int) a_p0->x, (int) a_p0->y , top); m_button_down = false; + int act_line=activator_from_xy( (int) a_p0->x, (int) a_p0->y ); + if (act_line!=-1 && a_p0->button == 1 && !m_moving){ + for (int i=0;iis_active( i*c_mainwnd_rows+act_line )){ + m_queued_to_play[i*c_mainwnd_rows+act_line]=m_lines_activator[act_line]; + if (m_lines_activator[act_line]) + m_queued_to_play[ i*c_mainwnd_rows+act_line ]=1; + else + m_queued_to_play[ i*c_mainwnd_rows+act_line ]=0; + draw_sequence_on_pixmap( i*c_mainwnd_rows+act_line ); + draw_sequence_pixmap_on_window( i*c_mainwnd_rows+act_line); + } + } + }else if ( m_current_seq != -1 && top && a_p0->button == 1 && + !m_moving && m_mainperf->is_active(m_current_seq)){ /* it hit a sequence ? */ - // toggle play mode of sequence (left button) + // fast edit access + seq_edit(); + - if ( m_current_seq != -1 && a_p0->button == 1 && !m_moving ){ + }else if ( m_current_seq != -1 && a_p0->button == 1 && !m_moving ){ + /* it hit a sequence ? */ + // toggle play mode of sequence (left button) if ( m_mainperf->is_active( m_current_seq )){ - //sequence *seq = m_mainperf->get_sequence( m_current_seq ); - //seq->set_playing( !seq->get_playing() ); - - m_mainperf->sequence_playing_toggle( m_current_seq ); + sequence *seq = m_mainperf->get_sequence( m_current_seq ); + if (!m_mainperf->is_running()) + m_mainperf->sequence_playing_toggle( m_current_seq ); + else + m_queued_to_play[m_current_seq]=(seq->get_playing())?0:1; draw_sequence_on_pixmap( m_current_seq ); draw_sequence_pixmap_on_window( m_current_seq); } } + if ( a_p0->button == 1 && m_moving ){ + get_window()->set_cursor(); m_moving = false; - if ( ! m_mainperf->is_active( m_current_seq ) && m_current_seq != -1 - && !m_mainperf->is_sequence_in_edit( m_current_seq ) ){ - - m_mainperf->new_sequence( m_current_seq ); - *(m_mainperf->get_sequence( m_current_seq )) = m_moving_seq; + if ( ! m_mainperf->is_active( m_current_seq ) && m_current_seq != -1){ + m_mainperf->mov_sequence(m_old_seq,m_current_seq); + draw_sequence_on_pixmap( m_old_seq ); + draw_sequence_pixmap_on_window( m_old_seq ); draw_sequence_on_pixmap( m_current_seq ); draw_sequence_pixmap_on_window( m_current_seq ); - } else { - - m_mainperf->new_sequence( m_old_seq ); - *(m_mainperf->get_sequence( m_old_seq )) = m_moving_seq; - - draw_sequence_on_pixmap( m_old_seq ); - draw_sequence_pixmap_on_window( m_old_seq ); - } + } } @@ -572,24 +675,20 @@ bool mainwid::on_motion_notify_event(GdkEventMotion* a_p0) { - int seq = seq_from_xy( (int) a_p0->x, (int) a_p0->y ); + bool top=false; + int seq = seq_from_xy( (int) a_p0->x, (int) a_p0->y ,top); if ( m_button_down ){ + if ( seq != m_current_seq && !m_moving ){ - if ( seq != m_current_seq && !m_moving && - !m_mainperf->is_sequence_in_edit( m_current_seq ) ){ - - if ( m_mainperf->is_active( m_current_seq )){ + if ( m_mainperf->is_active( m_current_seq )){ - m_old_seq = m_current_seq; - m_moving = true; - - m_moving_seq = *(m_mainperf->get_sequence( m_current_seq )); - m_mainperf->delete_sequence( m_current_seq ); - draw_sequence_on_pixmap( m_current_seq ); - draw_sequence_pixmap_on_window( m_current_seq ); - } - } + m_old_seq = m_current_seq; + m_moving = true; + get_window()->set_cursor(m_cursor_move); + + } + } } return true; diff -uN seq24-0.8.7/src/mainwid.h seq24-0.8.7-olivier/src/mainwid.h --- seq24-0.8.7/src/mainwid.h 2006-03-28 06:36:59.000000000 +0200 +++ seq24-0.8.7-olivier/src/mainwid.h 2007-07-04 23:34:30.000000000 +0200 @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -68,6 +69,8 @@ GdkRectangle m_old; GdkRectangle m_selected; + int m_lines_activator[c_mainwnd_rows]; + int m_screenset; perform *m_mainperf; @@ -81,6 +84,7 @@ bool m_button_down; bool m_moving; + Gdk::Cursor m_cursor_move; /* when highlighting a bunch of events */ /* where the dragging started */ @@ -90,6 +94,8 @@ int m_current_y; int m_old_seq; + + int m_queued_to_play[c_mainwnd_rows * c_mainwnd_cols]; long m_last_tick_x[c_max_sequence]; bool m_last_playing[c_max_sequence]; @@ -109,9 +115,12 @@ void fill_background_window(); void draw_pixmap_on_window(); + void draw_activator_on_pixmap(); + void draw_activator_pixmap_on_window(int act); void draw_sequence_pixmap_on_window( int a_seq ); - int seq_from_xy( int a_x, int a_y ); + int activator_from_xy( int a_x, int a_y ); + int seq_from_xy( int a_x, int a_y ,bool&); int timeout( void ); @@ -132,6 +141,7 @@ void update_markers( int a_ticks ); void draw_marker_on_sequence( int a_seq, int a_tick ); + void toggle_queued_sequences(); }; diff -uN seq24-0.8.7/src/mainwnd.cpp seq24-0.8.7-olivier/src/mainwnd.cpp --- seq24-0.8.7/src/mainwnd.cpp 2006-08-13 22:44:32.000000000 +0200 +++ seq24-0.8.7-olivier/src/mainwnd.cpp 2007-07-04 21:50:27.000000000 +0200 @@ -21,14 +21,52 @@ #include "perform.h" #include "midifile.h" #include "perfedit.h" - +#include "seqedit.h" #include "play2.xpm" #include "stop.xpm" #include "perfedit.xpm" #include "seq24.xpm" +#include +#include "gtkmm/expander.h" + + +static mainwnd* __mainwnd=NULL; + +mainwnd* mainwnd::get_instance(){ + return __mainwnd; +} + +void +mainwnd::display_sequence(seqedit* seq){ + + int nb_seq=m_notebook_seq->page_num(*seq); + if (nb_seq==-1){ + m_notebook_seq->append_page(* ((seq)), seq->get_sequence()->get_name()); + nb_seq=m_notebook_seq->get_n_pages()-1; + seq->link_to_notebook(m_notebook_seq); + } + m_notebook_seq->set_current_page(nb_seq); + +} + +void +mainwnd::dispose_sequedit(sequence *seq){ + seqedit* m_seqedit; + for (int i=0;iget_n_pages();i++){ + m_seqedit=(seqedit*)m_notebook_seq->get_nth_page(i); + if(m_seqedit->get_sequence()==seq){ + m_notebook_seq->remove_page(i); + seq->set_editing(false); + printstack("FIXME:dispose_sequedit() Segmentation fault when delete m_seqedit "); + } + } +} + + mainwnd::mainwnd(perform *a_p) { + __mainwnd=this; /* set the performance */ @@ -40,6 +78,11 @@ m_main_wid = manage( new mainwid( m_mainperf )); m_main_time = manage( new maintime( )); + m_notebook_seq = manage(new Notebook()); + m_notebook_seq->set_border_width(0); + m_notebook_seq->set_show_tabs(false); + + m_menubar = manage(new MenuBar()); m_menu_file = manage(new Menu()); m_menu_control = manage( new Menu()); @@ -106,24 +149,38 @@ hbox->pack_start( *m_entry_notes, true, true ); /* 2nd hbox */ - HBox *hbox2 = manage( new HBox( false, 0 ) ); - hbox2->pack_start( *manage( new Image(Gdk::Pixbuf::create_from_xpm_data( seq24_xpm ))), false, false ); - hbox2->pack_end( *m_main_time, false, false ); + HBox *hbox_top = manage( new HBox( false, 0 ) ); + hbox_top->pack_start( *manage( new Image(Gdk::Pixbuf::create_from_xpm_data( seq24_xpm ))), false, false ); + hbox_top->pack_end( *m_main_time, false, false ); /* set up a vbox, put the menu in it, and add it */ VBox *vbox = new VBox(); + m_expand_seqedit=manage(new Expander("View sequences")); + m_expand_seqedit->set_expanded(true); + m_expand_seqedit->property_expanded().signal_changed().connect( + sigc::mem_fun(*this, &mainwnd::on_expander_changed) + ); + m_expand_seqedit->add(*m_notebook_seq); vbox->set_border_width( 10 ); - vbox->pack_start(*hbox2, false, false ); + vbox->pack_start(*hbox_top, false, false); vbox->pack_start(*m_main_wid, true, true, 10 ); - vbox->pack_start(*hbox, false, false ); + vbox->pack_start(*m_expand_seqedit, false, true, 10 ); + + /* put all in vertical scrollwindow*/ + ScrolledWindow* vscroll=manage(new ScrolledWindow()); + vscroll->set_policy(Gtk::POLICY_NEVER,Gtk::POLICY_AUTOMATIC); + vscroll->add (*vbox); + vscroll->set_size_request(c_mainwid_x+40, c_mainwid_y+180); //border+the size of empty expander VBox *ovbox = new VBox(); ovbox->pack_start(*m_menubar, false, false ); - ovbox->pack_start( *vbox ); + ovbox->pack_start( *vscroll ); + ovbox->pack_start(*hbox, false, false ); /* add box */ + this->add (*ovbox); /* show everything */ @@ -133,7 +190,7 @@ m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad( m_mainperf->get_screenset() )); - m_timeout_connect = Glib::signal_timeout().connect(mem_fun(*this,&mainwnd::timer_callback), 25); + m_timeout_connect = Glib::signal_timeout().connect(mem_fun(*this,&mainwnd::timer_callback), 10); m_quit = false; @@ -142,6 +199,16 @@ } +void +mainwnd::on_expander_changed(){ + + static int w=0,h=0; + resize_children (); + if(!m_expand_seqedit->get_expanded()) +// resize (w,h); +// else + get_size(w,h); +} mainwnd::~mainwnd() { @@ -161,7 +228,13 @@ m_main_time->idle_progress( ticks ); m_main_wid->update_markers( ticks ); - + if (!ticks || ((ticks+5) % (c_ppqn*4))>6){ + return true; + } + m_main_wid->toggle_queued_sequences(); +// printf("auto start seqs on(%d)\n",(ticks % c_ppqn)) ; + + if ( m_adjust_bpm->get_value() != m_mainperf->get_bpm()){ m_adjust_bpm->set_value( m_mainperf->get_bpm()); } @@ -273,12 +346,14 @@ } } - void mainwnd::file_saveas_dialog( void ) { - FileSelection dialog( "Save As..." ); +// FileSelection dialog( "Save As..." ); + FileChooserDialog dialog( "Save As..." , FILE_CHOOSER_ACTION_SAVE); + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button("Save", Gtk::RESPONSE_OK); int result = dialog.run(); //Handle the response: @@ -323,7 +398,10 @@ void mainwnd::file_open_dialog( void ) { - FileSelection dialog( "Open..." ); +// FileSelection dialog( "Open..." ); + FileChooserDialog dialog( "Open..." , FILE_CHOOSER_ACTION_OPEN); + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button("Select", Gtk::RESPONSE_OK); int result = dialog.run(); //Handle the response: @@ -374,10 +452,12 @@ mainwnd::file_import_dialog( void ) { - FileSelection dialog( "Import..." ); +// FileSelection dialog( "Import..." ); + FileChooserDialog dialog( "Import..." , FILE_CHOOSER_ACTION_OPEN); + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button("Select", Gtk::RESPONSE_OK); - - HBox *abox = dialog.get_action_area(); + HBox *abox = (HBox *)dialog.get_action_area(); HBox hbox( false, 2 ); m_adjust_load_offset = manage( new Adjustment( 0, -(c_max_sets - 1) , c_max_sets - 1, 1 )); @@ -566,79 +646,73 @@ bool mainwnd::on_key_press_event(GdkEventKey* a_ev) { + if(Gtk::Window::on_key_press_event(a_ev)) + return true; - if( m_entry_notes->has_focus()){ - m_entry_notes->event( (GdkEvent*) a_ev ); - return false; - } - else - { - if ( a_ev->type == GDK_KEY_PRESS ){ + if ( a_ev->type == GDK_KEY_PRESS ){ - if ( global_print_keys ){ - printf( "key_press[%d]\n", a_ev->keyval ); - } - - if ( a_ev->keyval == m_mainperf->m_key_bpm_dn ){ - m_mainperf->set_bpm( m_mainperf->get_bpm() - 1 ); - m_adjust_bpm->set_value( m_mainperf->get_bpm() ); - } - - if ( a_ev->keyval == m_mainperf->m_key_bpm_up ){ - m_mainperf->set_bpm( m_mainperf->get_bpm() + 1 ); - m_adjust_bpm->set_value( m_mainperf->get_bpm() ); - } - - if ( a_ev->keyval == m_mainperf->m_key_replace ) - { - m_mainperf->set_sequence_control_status( c_status_replace ); - } - - if (a_ev->keyval == m_mainperf->m_key_queue ) - { - m_mainperf->set_sequence_control_status( c_status_queue ); - } - - if ( a_ev->keyval == m_mainperf->m_key_snapshot_1 || - a_ev->keyval == m_mainperf->m_key_snapshot_2 ) - { - m_mainperf->set_sequence_control_status( c_status_snapshot ); - } - - if ( a_ev->keyval == m_mainperf->m_key_screenset_dn ){ + if ( global_print_keys ){ + printf( "key_press[%d]\n", a_ev->keyval ); + } + + if ( a_ev->keyval == m_mainperf->m_key_bpm_dn ){ + m_mainperf->set_bpm( m_mainperf->get_bpm() - 1 ); + m_adjust_bpm->set_value( m_mainperf->get_bpm() ); + } + + if ( a_ev->keyval == m_mainperf->m_key_bpm_up ){ + m_mainperf->set_bpm( m_mainperf->get_bpm() + 1 ); + m_adjust_bpm->set_value( m_mainperf->get_bpm() ); + } + + if ( a_ev->keyval == m_mainperf->m_key_replace ) + { + m_mainperf->set_sequence_control_status( c_status_replace ); + } + + if (a_ev->keyval == m_mainperf->m_key_queue ) + { + m_mainperf->set_sequence_control_status( c_status_queue ); + } + + if ( a_ev->keyval == m_mainperf->m_key_snapshot_1 || + a_ev->keyval == m_mainperf->m_key_snapshot_2 ) + { + m_mainperf->set_sequence_control_status( c_status_snapshot ); + } + + if ( a_ev->keyval == m_mainperf->m_key_screenset_dn ){ - m_mainperf->set_screenset( m_mainperf->get_screenset() - 1 ); - m_main_wid->set_screenset( m_mainperf->get_screenset() ); - m_adjust_ss->set_value( m_mainperf->get_screenset() ); - m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad(m_mainperf->get_screenset() )); - } - - if ( a_ev->keyval == m_mainperf->m_key_screenset_up ){ + m_mainperf->set_screenset( m_mainperf->get_screenset() - 1 ); + m_main_wid->set_screenset( m_mainperf->get_screenset() ); + m_adjust_ss->set_value( m_mainperf->get_screenset() ); + m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad(m_mainperf->get_screenset() )); + } + + if ( a_ev->keyval == m_mainperf->m_key_screenset_up ){ - m_mainperf->set_screenset( m_mainperf->get_screenset() + 1 ); - m_main_wid->set_screenset( m_mainperf->get_screenset() ); - m_adjust_ss->set_value( m_mainperf->get_screenset() ); - m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad(m_mainperf->get_screenset() )); - } - - if ( a_ev->keyval == m_mainperf->m_key_start ) - { - start_playing(); - } + m_mainperf->set_screenset( m_mainperf->get_screenset() + 1 ); + m_main_wid->set_screenset( m_mainperf->get_screenset() ); + m_adjust_ss->set_value( m_mainperf->get_screenset() ); + m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad(m_mainperf->get_screenset() )); + } + + if ( a_ev->keyval == m_mainperf->m_key_start ) + { + start_playing(); + } - if ( a_ev->keyval == m_mainperf->m_key_stop ) - { - stop_playing(); - } + if ( a_ev->keyval == m_mainperf->m_key_stop ) + { + stop_playing(); + } - if( m_mainperf->get_key_events()->count( a_ev->keyval) != 0 ){ - - sequence_key( (*m_mainperf->get_key_events())[a_ev->keyval] ); - } + if( m_mainperf->get_key_events()->count( a_ev->keyval) != 0 ){ + + sequence_key( (*m_mainperf->get_key_events())[a_ev->keyval] ); } } - return false; } diff -uN seq24-0.8.7/src/mainwnd.h seq24-0.8.7-olivier/src/mainwnd.h --- seq24-0.8.7/src/mainwnd.h 2006-03-28 06:36:59.000000000 +0200 +++ seq24-0.8.7-olivier/src/mainwnd.h 2007-07-04 16:45:05.000000000 +0200 @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -54,6 +54,8 @@ #include #include #include +#include +#include #include #include #include @@ -69,6 +71,7 @@ using namespace Menu_Helpers; +class maintime; class mainwnd : public Gtk::Window { @@ -106,6 +109,10 @@ SpinButton *m_spinbutton_load_offset; Adjustment *m_adjust_load_offset; + + Notebook *m_notebook_seq; + + Expander *m_expand_seqedit; Entry *m_entry_notes; @@ -138,6 +145,7 @@ void sequence_key( int a_seq ); void set_window_title_filename( std::string a_file ); + void on_expander_changed(); public: @@ -147,6 +155,9 @@ bool on_delete_event(GdkEventAny *a_e); bool on_key_press_event(GdkEventKey* a_ev); bool on_key_release_event(GdkEventKey* a_ev); + void display_sequence(seqedit*); + void dispose_sequedit(sequence *seq); + static mainwnd* get_instance(); }; diff -uN seq24-0.8.7/src/perform.cpp seq24-0.8.7-olivier/src/perform.cpp --- seq24-0.8.7/src/perform.cpp 2006-08-13 22:42:38.000000000 +0200 +++ seq24-0.8.7-olivier/src/perform.cpp 2007-07-04 23:05:34.000000000 +0200 @@ -536,6 +536,13 @@ } +void +perform::mov_sequence( int seq_ori, int seq_dest ){ + set_active(seq_ori, false); + m_seqs[ seq_dest ]=m_seqs[ seq_ori ];m_seqs[ seq_ori ]=NULL; + set_active(seq_dest, true); +} + bool perform::is_sequence_in_edit( int a_num ) { @@ -554,6 +561,7 @@ } + midi_control * perform::get_midi_control_toggle( unsigned int a_seq ) { @@ -865,6 +873,7 @@ } + void perform::inner_start( bool a_state ) { diff -uN seq24-0.8.7/src/perform.h seq24-0.8.7-olivier/src/perform.h --- seq24-0.8.7/src/perform.h 2006-08-13 22:37:42.000000000 +0200 +++ seq24-0.8.7-olivier/src/perform.h 2007-07-04 15:03:34.000000000 +0200 @@ -107,7 +107,6 @@ long m_tick; void set_running( bool a_running ); - bool is_running(); void set_playback_mode( bool a_playback_mode ); @@ -216,6 +215,7 @@ void start_jack(); void stop_jack(); void position_jack( bool a_state ); + bool is_running(); void off_sequences( void ); @@ -228,6 +228,7 @@ bool is_dirty_names (int a_sequence); void new_sequence( int a_sequence ); + void mov_sequence( int seq_ori, int seq_dest ); /* plays all notes to Curent tick */ void play( long a_tick ); diff -uN seq24-0.8.7/src/q_rec.xpm seq24-0.8.7-olivier/src/q_rec.xpm --- seq24-0.8.7/src/q_rec.xpm 2007-07-01 21:49:59.000000000 +0200 +++ seq24-0.8.7-olivier/src/q_rec.xpm 1970-01-01 01:00:00.000000000 +0100 @@ -1,24 +0,0 @@ -/* XPM */ -static char * q_rec_xpm[] = { -"36 14 7 1", -" c None", -". c #000000", -"+ c #FFFFFF", -"@ c #9E9E9E", -"# c #FFBABA", -"$ c #FF5454", -"% c #B51E1E", -" ...... ", -" ...+..+... ", -" ..+++@@+++.. . .... ", -" .++++++++++. .. .. .. ", -"..++++++++++.. .#. .. .. ", -".++++++++++++. ......#$. .. .. ", -".+..++++++..+. .#####$$$. .. .. ", -".+@.++++++.@+. .$$$$$$$%. .. .. ", -".++++++++++++. ......$%. .. .. ", -"..+..++++..+.. .%. .. . .. ", -" .+@.+..+.@+. .. .. ... ", -" ..+++..+++.. . ..... ", -" ...++++... . ", -" ...... "}; diff -uN seq24-0.8.7/src/quanize.xpm seq24-0.8.7-olivier/src/quanize.xpm --- seq24-0.8.7/src/quanize.xpm 2007-07-01 21:49:59.000000000 +0200 +++ seq24-0.8.7-olivier/src/quanize.xpm 1970-01-01 01:00:00.000000000 +0100 @@ -1,19 +0,0 @@ -/* XPM */ -static char * quanize_xpm[] = { -"16 14 2 1", -" c None", -". c #000000", -" ", -" ", -" .... ", -" .. .. ", -" .. .. ", -" .. .. ", -" .. .. ", -" .. .. ", -" .. .. ", -" .. . .. ", -" .. ... ", -" ..... ", -" . ", -" "}; diff -uN seq24-0.8.7/src/seqdata.cpp seq24-0.8.7-olivier/src/seqdata.cpp --- seq24-0.8.7/src/seqdata.cpp 2006-05-18 06:40:15.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqdata.cpp 2007-07-01 10:51:27.000000000 +0200 @@ -58,12 +58,14 @@ m_scroll_offset_ticks = 0; m_scroll_offset_x = 0; + + } void seqdata::update_sizes() { - if( is_realized() ) { + if(is_realized() && check_is_drawable() ) { /* create pixmaps with window dimentions */ m_pixmap = Gdk::Pixmap::create( m_window, @@ -84,9 +86,12 @@ } + void seqdata::redraw() { + if (!check_is_drawable()) + return; update_pixmap(); queue_draw(); } @@ -177,6 +182,9 @@ void seqdata::draw_events_on( Glib::RefPtr a_draw ) { + if(!check_is_drawable()) + return; + long tick; unsigned char d0,d1; @@ -189,9 +197,8 @@ int start_tick = m_scroll_offset_ticks ; int end_tick = (m_window_x * m_zoom) + m_scroll_offset_ticks; - - //printf( "draw_events_on\n" ); - + + m_gc->set_foreground( m_white ); a_draw->draw_rectangle(m_gc,true, 0, @@ -267,17 +274,19 @@ int seqdata::idle_redraw() { - /* no flicker, redraw */ - if ( !m_dragging ){ - draw_events_on( m_window ); - draw_events_on( m_pixmap ); - } + /* no flicker, redraw */ + if ( !m_dragging ){ + draw_events_on( m_window ); + draw_events_on( m_pixmap ); + } return true; } bool seqdata::on_expose_event(GdkEventExpose* a_e) { + if(!check_is_drawable()) + return true; m_window->draw_drawable(m_gc, m_pixmap, a_e->area.x, @@ -462,6 +471,9 @@ seqdata::draw_line_on_window( void ) { int x,y,w,h; + if(!check_is_drawable()) + return; + m_gc->set_foreground( m_black ); m_gc->set_line_attributes( 1, Gdk::LINE_SOLID, @@ -517,8 +529,9 @@ void seqdata::on_size_allocate(Gtk::Allocation& a_r ) { - Gtk::DrawingArea::on_size_allocate( a_r ); - + + Gtk::DrawingArea::on_size_allocate( a_r ); + m_window_x = a_r.get_width(); m_window_y = a_r.get_height(); @@ -530,7 +543,10 @@ void seqdata::force_draw(void ) { - m_window->draw_drawable(m_gc, + if(!check_is_drawable()) + return; + + m_window->draw_drawable(m_gc, m_pixmap, 0, 0, @@ -539,3 +555,24 @@ m_window_x, m_window_y ); } + + +bool +seqdata::check_is_drawable(){ + if (!is_drawable()||!is_realized()) + return false; + + if (!m_gc){ + m_window = get_window(); + m_gc = Gdk::GC::create( m_window ); + } + if(!m_window_x){ + m_window_x=m_window_y=10; + } + + if(!m_gc){ + printstack("check_is_drawable() : could not create GC"); + return false; + } + return true; +} diff -uN seq24-0.8.7/src/seqdata.h seq24-0.8.7-olivier/src/seqdata.h --- seq24-0.8.7/src/seqdata.h 2006-03-28 06:36:59.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqdata.h 2007-07-01 10:20:41.000000000 +0200 @@ -110,7 +110,8 @@ void change_horz( void ); void force_draw( void ); - + bool check_is_drawable(); + public: seqdata( sequence *a_seq, int a_zoom, Gtk::Adjustment *a_hadjust ); diff -uN seq24-0.8.7/src/seqedit.cpp seq24-0.8.7-olivier/src/seqedit.cpp --- seq24-0.8.7/src/seqedit.cpp 2006-05-30 16:04:52.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqedit.cpp 2007-07-01 17:31:55.000000000 +0200 @@ -25,6 +25,7 @@ #include "event.h" #include "options.h" +#include "mainwnd.h" #include "play.xpm" #include "rec.xpm" @@ -76,12 +77,15 @@ -seqedit::seqedit( sequence *a_seq, - perform *a_perf, - // mainwid *a_mainwid, - int a_pos ) +//constructor +seqedit::seqedit( sequence *a_seq, perform *a_perf, /* mainwid *a_mainwid, */ int a_pos ) + :ScrolledWindow() { + set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC); + + + /* set the performance */ m_seq = a_seq; @@ -97,9 +101,10 @@ m_pos = a_pos; /* main window */ - set_title ( m_seq->get_name()); - set_size_request(700, 500); + set_size_request(250, 500); + set_border_width (0); + m_seq->set_editing( true ); /* scroll bars */ @@ -179,7 +184,7 @@ /* fill table */ m_table->attach( *m_seqkeys_wid, 0, 1, 1, 2, Gtk::SHRINK, Gtk::FILL ); - + m_table->attach( *m_seqtime_wid, 1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK ); m_table->attach( *m_seqroll_wid , 1, 2, 1, 2, Gtk::FILL | Gtk::SHRINK, @@ -269,12 +274,9 @@ set_scale( m_scale ); set_key( m_key ); set_key( m_key ); - } - - void seqedit::create_menus( void ) { @@ -557,7 +559,7 @@ m_entry_name = manage( new Entry( )); m_entry_name->set_max_length(26); - m_entry_name->set_width_chars(26); + m_entry_name->set_width_chars(20); m_entry_name->set_text( m_seq->get_name()); m_entry_name->select_region(0,0); m_entry_name->set_position(0); @@ -621,11 +623,11 @@ m_entry_bus = manage( new Entry()); m_entry_bus->set_max_length(60); - m_entry_bus->set_width_chars(60); + m_entry_bus->set_width_chars(30); m_entry_bus->set_editable( false ); m_hbox->pack_start( *m_button_bus , false, false ); - m_hbox->pack_start( *m_entry_bus , true, true ); + m_hbox->pack_start( *m_entry_bus , false, false ); /* midi channel */ m_button_channel = manage( new Button()); @@ -1194,6 +1196,8 @@ seqedit::name_change_callback( void ) { m_seq->set_name( m_entry_name->get_text()); + if (m_notebook) + m_notebook->set_tab_label_text(*this,(m_entry_name->get_text())); // m_mainwid->update_sequence_on_window( m_pos ); } @@ -1285,12 +1289,12 @@ } - void seqedit::on_realize() { + // we need to do the default realize - Gtk::Window::on_realize(); + Gtk::ScrolledWindow::on_realize(); Glib::signal_timeout().connect(mem_fun(*this,&seqedit::timeout ), c_redraw_ms); @@ -1299,11 +1303,10 @@ bool seqedit::timeout( void ) { - if (m_seq->get_raise()) { m_seq->set_raise(false); - raise(); + mainwnd::get_instance()->display_sequence(this); } if (m_seq->is_dirty_edit() ){ @@ -1328,7 +1331,6 @@ bool seqedit::on_delete_event(GdkEventAny *a_event) { - //printf( "seqedit::on_delete_event()\n" ); m_seq->set_recording( false ); m_mainperf->get_master_midi_bus()->set_sequence_input( false, NULL ); m_seq->set_editing( false ); @@ -1337,3 +1339,15 @@ return false; } + + +void +seqedit::link_to_notebook(Notebook* tabs){ + m_notebook=tabs; +} + +sequence* +seqedit::get_sequence(){ + return m_seq; +} + diff -uN seq24-0.8.7/src/seqedit.h seq24-0.8.7-olivier/src/seqedit.h --- seq24-0.8.7/src/seqedit.h 2006-05-30 08:24:11.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqedit.h 2007-06-30 17:11:50.000000000 +0200 @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,10 @@ #include #include #include +#include +#include +#include +#include #include @@ -66,13 +69,25 @@ using namespace Gtk; +class seqtime; +class seqroll; +class seqkeys; +class seqevent; /* has a seqroll and paino roll */ -class seqedit : public Gtk::Window +class seqedit : public Gtk::ScrolledWindow { - +/* + protected: + virtual void on_size_request(Gtk::Requisition* requisition); + virtual void forall_vfunc(gboolean include_internals, GtkCallback callback, gpointer callback_data); + + virtual void on_add(Gtk::Widget* child); + virtual void on_remove(Gtk::Widget* child); + virtual GtkType child_type_vfunc() const; +*/ private: - + ScrolledWindow *content; MenuBar *m_menubar; Menu *m_menu_tools; @@ -171,6 +186,8 @@ Entry *m_entry_name; + Notebook *m_notebook; + /* the zoom 0 1 2 3 4 1, 2, 4, 8, 16 */ int m_zoom; @@ -251,7 +268,6 @@ void mouse_action( mouse_action_e a_action ); public: - seqedit( sequence *a_seq, perform *a_perf, // mainwid *a_mainwid, @@ -259,8 +275,9 @@ ~seqedit( ); - + sequence* get_sequence(); + void link_to_notebook(Notebook* tabs); bool on_delete_event(GdkEventAny *a_event); }; diff -uN seq24-0.8.7/src/seqevent.cpp seq24-0.8.7-olivier/src/seqevent.cpp --- seq24-0.8.7/src/seqevent.cpp 2006-05-29 07:19:55.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqevent.cpp 2007-07-01 10:52:23.000000000 +0200 @@ -135,8 +135,10 @@ void seqevent::update_sizes() { + if(!check_is_drawable()) + return; - if( is_realized() ) { + if( is_realized()) { /* create pixmaps with window dimentions */ //printf( "update_sizes() m_window_x[%d] m_window_y[%d]\n", @@ -168,6 +170,8 @@ void seqevent::redraw() { + if(!check_is_drawable()) + return; m_scroll_offset_ticks = (int) m_hadjust->get_value(); m_scroll_offset_x = m_scroll_offset_ticks / m_zoom; @@ -180,8 +184,9 @@ void seqevent::draw_background() { - //printf ("draw_background()\n" ); - + if(!check_is_drawable()) + return; + /* clear background */ m_gc->set_foreground(m_white); m_pixmap->draw_rectangle(m_gc,true, @@ -328,8 +333,9 @@ unsigned char d0,d1; bool selected; - - + if(!check_is_drawable()) + return; + /* draw boxes from sequence */ m_gc->set_foreground( m_black ); @@ -412,11 +418,12 @@ void seqevent::draw_selection_on_window() { + if(!check_is_drawable()) + return; int x,w; int y = (c_eventarea_y - c_eventevent_y)/2; int h = c_eventevent_y; - m_gc->set_line_attributes( 1, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, @@ -470,6 +477,9 @@ bool seqevent::on_expose_event(GdkEventExpose* e) { + if(!check_is_drawable()) + return true; + m_window->draw_drawable(m_gc, m_pixmap, e->area.x, @@ -957,3 +967,24 @@ return false; } + + +bool +seqevent::check_is_drawable(){ + if (!is_drawable()||!is_realized()) + return false; + + if (!m_gc){ + m_window = get_window(); + m_gc = Gdk::GC::create( m_window ); + } + if(!m_window_x){ + m_window_x=m_window_y=10; + } + + if(!m_gc){ + printstack("check_is_drawable() : could not create GC"); + return false; + } + return true; +} diff -uN seq24-0.8.7/src/seqevent.h seq24-0.8.7-olivier/src/seqevent.h --- seq24-0.8.7/src/seqevent.h 2006-05-26 12:34:19.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqevent.h 2007-07-01 10:43:46.000000000 +0200 @@ -125,7 +125,8 @@ void change_horz( void ); void force_draw( void ); - + bool check_is_drawable(); + public: seqevent( sequence *a_seq, diff -uN seq24-0.8.7/src/seqkeys.cpp seq24-0.8.7-olivier/src/seqkeys.cpp --- seq24-0.8.7/src/seqkeys.cpp 2006-05-18 06:40:15.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqkeys.cpp 2007-07-01 11:02:51.000000000 +0200 @@ -122,6 +122,7 @@ void seqkeys::update_pixmap() { + m_gc->set_foreground(m_black); m_pixmap->draw_rectangle(m_gc,true, 0, diff -uN seq24-0.8.7/src/seqmenu.cpp seq24-0.8.7-olivier/src/seqmenu.cpp --- seq24-0.8.7/src/seqmenu.cpp 2006-05-30 15:12:05.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqmenu.cpp 2007-07-04 21:42:38.000000000 +0200 @@ -22,6 +22,7 @@ #include "seqedit.h" #include "font.h" +#include "mainwnd.h" // Constructor @@ -144,6 +145,8 @@ m_mainperf, m_current_seq ); + mainwnd::get_instance()->display_sequence(manage(seq_edit)); + } else { m_mainperf->get_sequence( m_current_seq )->set_raise(true); @@ -155,6 +158,7 @@ m_mainperf, m_current_seq ); + mainwnd::get_instance()->display_sequence(manage(seq_edit)); } } @@ -182,8 +186,10 @@ void seqmenu::seq_cut(){ - if ( m_mainperf->is_active( m_current_seq ) && - !m_mainperf->is_sequence_in_edit( m_current_seq ) ){ + if ( m_mainperf->is_active( m_current_seq ) ){ + + if(m_mainperf->is_sequence_in_edit( m_current_seq )) + mainwnd::get_instance()->dispose_sequedit(m_mainperf->get_sequence( m_current_seq )); m_clipboard = *(m_mainperf->get_sequence( m_current_seq )); m_mainperf->delete_sequence( m_current_seq ); diff -uN seq24-0.8.7/src/seqmenu.h seq24-0.8.7-olivier/src/seqmenu.h --- seq24-0.8.7/src/seqmenu.h 2006-05-18 06:39:58.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqmenu.h 2007-07-03 22:27:59.000000000 +0200 @@ -59,7 +59,6 @@ void on_realize(); - void seq_edit(); void seq_new(); void seq_copy(); @@ -77,6 +76,7 @@ int m_current_seq; void popup_menu(); + void seq_edit(); public: diff -uN seq24-0.8.7/src/seqroll.cpp seq24-0.8.7-olivier/src/seqroll.cpp --- seq24-0.8.7/src/seqroll.cpp 2006-05-29 06:58:37.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqroll.cpp 2007-07-01 10:53:46.000000000 +0200 @@ -260,7 +260,8 @@ void seqroll::draw_background() { - + if(!is_drawable() || !m_gc) + return; //printf ("draw_background()\n" ); /* clear background */ @@ -447,6 +448,8 @@ void seqroll::draw_progress_on_window() { + if(!is_drawable()) + return; m_window->draw_drawable(m_gc, m_pixmap, m_old_progress_x, @@ -473,6 +476,8 @@ void seqroll::draw_events_on( Glib::RefPtr a_draw ) { + if(!is_drawable()) + return; long tick_s; @@ -489,7 +494,6 @@ int velocity; draw_type dt; - int start_tick = m_scroll_offset_ticks ; @@ -620,6 +624,8 @@ seqroll::draw_selection_on_window() { int x,y,w,h; + if(!is_drawable()) + return; if ( m_selecting || m_moving || m_paste || m_growing ){ @@ -721,7 +727,9 @@ bool seqroll::on_expose_event(GdkEventExpose* e) { - + if(!is_drawable()) + return true; + m_window->draw_drawable(m_gc, m_pixmap, e->area.x, @@ -739,6 +747,9 @@ void seqroll::force_draw(void ) { + if(!is_drawable()) + return; + m_window->draw_drawable(m_gc, m_pixmap, 0, diff -uN seq24-0.8.7/src/seqtime.cpp seq24-0.8.7-olivier/src/seqtime.cpp --- seq24-0.8.7/src/seqtime.cpp 2006-03-28 06:36:59.000000000 +0200 +++ seq24-0.8.7-olivier/src/seqtime.cpp 2007-07-01 16:56:48.000000000 +0200 @@ -23,8 +23,11 @@ seqtime::seqtime(sequence *a_seq, int a_zoom, - Gtk::Adjustment *a_hadjust): DrawingArea() + Gtk::Adjustment *a_hadjust): DrawingArea() { + m_window_x = 40; + m_window_y = 40; + m_seq = a_seq; m_zoom = a_zoom; @@ -54,6 +57,7 @@ set_double_buffered( false ); + } @@ -64,7 +68,7 @@ /* set these for later */ if( is_realized() ) { - + m_pixmap = Gdk::Pixmap::create( m_window, m_window_x, m_window_y, -1 ); @@ -83,8 +87,6 @@ //Gtk::Main::idle.connect(mem_fun(this,&seqtime::idleProgress)); Glib::signal_timeout().connect(mem_fun(*this,&seqtime::idle_progress), 50); - - // Now we can allocate any additional resources we need m_window = get_window(); @@ -117,8 +119,7 @@ m_window_x = a_r.get_width(); m_window_y = a_r.get_height(); - update_sizes(); - + update_sizes(); } @@ -169,7 +170,9 @@ { - + if(!is_drawable()) + return; + /* clear background */ m_gc->set_foreground(m_white); m_pixmap->draw_rectangle(m_gc,true, @@ -275,6 +278,8 @@ void seqtime::draw_pixmap_on_window() { + if(!is_drawable()) + return; m_window->draw_drawable(m_gc, m_pixmap, 0,0, @@ -286,6 +291,8 @@ bool seqtime::on_expose_event(GdkEventExpose* a_e) { + if(!is_drawable()) + return true; m_window->draw_drawable(m_gc, m_pixmap, a_e->area.x, @@ -300,6 +307,8 @@ void seqtime::force_draw( void ) { + if(!is_drawable()) + return; m_window->draw_drawable(m_gc, m_pixmap, 0,0, diff -uN seq24-0.8.7/src/sequence.cpp seq24-0.8.7-olivier/src/sequence.cpp --- seq24-0.8.7/src/sequence.cpp 2006-05-30 03:44:51.000000000 +0200 +++ seq24-0.8.7-olivier/src/sequence.cpp 2007-07-04 17:06:57.000000000 +0200 @@ -18,7 +18,7 @@ // //----------------------------------------------------------------------------- #include "sequence.h" -#include "seqedit.h" +#include "mainwnd.h" #include list < event > sequence::m_list_clipboard; @@ -179,7 +179,6 @@ sequence::~sequence() { - } /* adds event in sorted manner */ @@ -2873,7 +2872,6 @@ sequence::put_event_on_bus( event *a_e ) { lock(); - unsigned char note = a_e->get_note(); bool skip = false;