diff -urN denemo-cvsUPDATE/denemo/include/denemo/denemo_types.h denemo-cvs/denemo/include/denemo/denemo_types.h --- denemo-cvsUPDATE/denemo/include/denemo/denemo_types.h 2007-09-23 17:24:32.000000000 +0100 +++ denemo-cvs/denemo/include/denemo/denemo_types.h 2007-09-20 21:20:22.000000000 +0100 @@ -314,14 +314,6 @@ typedef enum { - RSM_OFF = 0, - RSM_OVERLAY = 1<<0, - RSM_RHYTHM = 1<<1 - -} RhythmicSubmode; - -typedef enum -{ WOODWIND, BRASS, STRINGS, @@ -465,7 +457,7 @@ gint curmeasure_stem_directive; /* support for INPUTNORMAL sub mode RHYTMIC */ - RhythmicSubmode rhythmicsubmode; + gboolean rhythmicsubmode; GList *rhythms;/**< list of RhythmPattern s */ GList *currhythm; /**< currently in use element of rhythms */ GList *rstep; /**< step within RhythmPattern->rsteps, the current element of the current rhythm pattern */ diff -urN denemo-cvsUPDATE/denemo/src/chordops.c denemo-cvs/denemo/src/chordops.c --- denemo-cvsUPDATE/denemo/src/chordops.c 2007-09-23 17:06:05.000000000 +0100 +++ denemo-cvs/denemo/src/chordops.c 2007-09-22 21:37:33.000000000 +0100 @@ -212,21 +212,14 @@ return anote->mid_c_offset - bnote->mid_c_offset; } -/* modify the pitch of the note of a chord. - FIXME will not work for chords that have >1 notes. +/* modify the pitch of a note. + NB if the note belongs in a chord the chord may need modifying for + note order in the chord -does the containing chord hold other information that may need updating? */ -void modify_note(chord *thechord, gint mid_c_offset, gint enshift, gint dclef) { - note *thenote = (note*)(thechord->notes->data); +void modify_note(note *thenote, gint mid_c_offset, gint enshift, gint dclef) { thenote->mid_c_offset = mid_c_offset; thenote->enshift = enshift; thenote->y = calculateheight (mid_c_offset, dclef); - thechord->sum_mid_c_offset = mid_c_offset;//Damned difficult to track this down - will not work if there are >1 notes in chord - thechord->highestpitch = mid_c_offset; - thechord->highesty = - calculateheight (mid_c_offset, dclef); - thechord->lowestpitch = mid_c_offset; - thechord->lowesty = - calculateheight (mid_c_offset, dclef); } /* Allocate a new note structure initializing the fields @@ -236,9 +229,7 @@ static note *new_note(gint mid_c_offset, gint enshift, gint dclef) { note *newnote; newnote = (note *) g_malloc0 (sizeof (note)); - newnote->mid_c_offset = mid_c_offset; - newnote->enshift = enshift; - newnote->y = calculateheight (mid_c_offset, dclef); + modify_note(newnote, mid_c_offset, enshift, dclef); newnote->reversealign = FALSE; newnote->noteheadtype = DENEMO_NORMAL_NOTEHEAD; return newnote; diff -urN denemo-cvsUPDATE/denemo/src/chordops.h denemo-cvs/denemo/src/chordops.h --- denemo-cvsUPDATE/denemo/src/chordops.h 2007-09-23 17:09:53.000000000 +0100 +++ denemo-cvs/denemo/src/chordops.h 2007-09-22 21:37:33.000000000 +0100 @@ -18,7 +18,7 @@ DenemoObject *newchord (gint baseduration, gint numdots, int tied); -void modify_note (chord *thechord, gint mid_c_offset, gint enshift, gint dclef); +void modify_note (note *thenote, gint mid_c_offset, gint enshift, gint dclef); void addtone (DenemoObject * mudelaobj, gint mid_c_offset, gint enshift, gint dclef); diff -urN denemo-cvsUPDATE/denemo/src/commandfuncs.c denemo-cvs/denemo/src/commandfuncs.c --- denemo-cvsUPDATE/denemo/src/commandfuncs.c 2007-09-23 17:12:48.000000000 +0100 +++ denemo-cvs/denemo/src/commandfuncs.c 2007-09-22 21:37:33.000000000 +0100 @@ -55,7 +55,7 @@ {GdkColor thecolor; gdk_color_parse ("gray", &thecolor); - gtk_widget_modify_bg (gtk_tool_button_get_label_widget(GTK_TOOL_BUTTON(((RhythmPattern *)gui->si->currhythm->data)->button)), GTK_STATE_NORMAL, &thecolor); + gtk_widget_modify_bg (gtk_tool_button_get_label_widget(GTK_WIDGET(((RhythmPattern *)gui->si->currhythm->data)->button)), GTK_STATE_NORMAL, &thecolor); } #endif @@ -71,7 +71,7 @@ #define CURRP ((RhythmPattern *)gui->si->currhythm->data) if(((RhythmElement*)g->data)->icon) { GtkWidget *label = LABEL(CURRP->button); - gtk_label_set_markup(GTK_LABEL(label),((RhythmElement*)g->data)->icon); + gtk_label_set_markup(label,((RhythmElement*)g->data)->icon); } #if 0 gtk_widget_set_state(GTK_WIDGET(((RhythmPattern *)gui->si->currhythm->data)->button), GTK_STATE_PRELIGHT); @@ -456,41 +456,30 @@ gui->si->staffletter_y = note_value; gui->si->cursor_y = jumpcursor (gui->si->cursor_y, oldstaffletter_y, gui->si->staffletter_y); - if((gui->si->rhythmicsubmode & RSM_OVERLAY) && gui->si->currentobject) { - DenemoObject *theobj = (DenemoObject *)(gui->si->currentobject->data); - if(theobj->type == CHORD && ((chord*)theobj->object)->notes) { - DenemoStaff *curstaff = ((DenemoStaff*)gui->si->currentstaff->data); - find_leftmost_staffcontext (curstaff, gui->si); - int dclef = curstaff->leftmost_clefcontext; - int mid_c_offset = gui->si->cursor_y; - modify_note((chord*)theobj->object, mid_c_offset, gui->si->curmeasureaccs[note_value], dclef); - showwhichaccidentals ((objnode *) gui->si->currentmeasure->data, - gui->si->curmeasurekey, gui->si->curmeasureaccs); - } - } else - /* in rhythmicsubmode we insert a note using the next step of the rhythm pattern */ + + /* in rhythmicsubmode we insert a note using the next step of the rhythm pattern */ #define g (gui->si->rstep) - if(gui->si->rhythmicsubmode && g) { - GList *start = g; - GList *h; - do { - if(g) { - for(h = ((RhythmElement*)g->data)->functions;h;h=h->next) { - nextmeasure (gui->si, TRUE); - gui->si->cursoroffend = FALSE; - ((GtkFunction)h->data)(gui); - displayhelper(gui); - } - h = ((RhythmElement*)g->data)->functions; - g = g->next;/* list is circular */ + if(gui->si->rhythmicsubmode && g) { + GList *start = g; + GList *h; + do { + if(g) { + for(h = ((RhythmElement*)g->data)->functions;h;h=h->next) { + nextmeasure (gui->si, TRUE); + gui->si->cursoroffend = FALSE; + ((GtkFunction)h->data)(gui); + displayhelper(gui); } - } while(g!=start && modifier_code(h->data)); -#define CURRP ((RhythmPattern *)gui->si->currhythm->data) - if(((RhythmElement*)g->data)->icon) { - GtkWidget *label = LABEL(CURRP->button); - gtk_label_set_markup(GTK_LABEL(label),((RhythmElement*)g->data)->icon); + h = ((RhythmElement*)g->data)->functions; + g = g->next;/* list is circular */ } + } while(g!=start && modifier_code(h->data)); +#define CURRP ((RhythmPattern *)gui->si->currhythm->data) + if(((RhythmElement*)g->data)->icon) { + GtkWidget *label = LABEL(CURRP->button); + gtk_label_set_markup(label,((RhythmElement*)g->data)->icon); } + } #undef CURRP #undef g } @@ -520,9 +509,9 @@ /** * badly named and incorrectly described (below) * this is really a "find_or_create_insertion_point" function - * that is, if the current measure is full it moves into the next one provided it is empty + * that is, if the current measure is full it moves into the next one * (or creates a new one and moves into it) - * if it is not full, or if the next measure is not empty it does nothing. + * if it is not full, it does nothing. old misleading comment: * Goto the next measure * Goto the next measure in the score. A new measure will @@ -565,6 +554,7 @@ memcpy (si->curmeasureaccs, si->nextmeasureaccs, SEVENGINTS); si->curmeasureclef = si->cursorclef; } + } /** @@ -967,53 +957,6 @@ } -/** - * Delete staff from the score - * @param si pointer to the scoreinfo structure - * @param pos staff number to remove, starts at 1 - * @return none - */ -static void -deletestaff (DenemoScore * si, gint pos) -{ - if (g_list_length (si->thescore) > 1) - { - removestaff (si, pos-1, 1); - setcurrents (si); - find_xes_in_all_measures (si); - - si->haschanged = TRUE; - si->markstaffnum = 0; - } -} - - -/** - * Delete specific staff defined by callbackaction - * - * @param si pointer to the DenemoScore structure - * @param callback_action position of the staff to delete - */ -static void -delete_staff (DenemoScore * si, enum newstaffcallbackaction callback_action) -{ - g_print ("Current staff num %d, callback_action %d", si->currentstaffnum, - callback_action); - switch (callback_action) - { - case BEFORE: - if (si->currentstaffnum != 1) - deletestaff (si, si->currentstaffnum - 1); - break; - case AFTER: - deletestaff (si, si->currentstaffnum + 1); - break; - default: - deletestaff (si, si->currentstaffnum); - break; - } -/* displayhelper(si);*/ -} /** * Delete staff wrapper to delete the preceding staff @@ -1050,11 +993,56 @@ void delete_staff_current (GtkAction * action, DenemoGUI * gui) { - delete_staff (gui->si, CURRENT); + delete_staff (gui->si, 9); displayhelper (gui); } +/** + * Delete specific staff defined by callback + * + * @param si pointer to the DenemoScore structure + * @param callback_action position of the staff to delete + */ +void +delete_staff (DenemoScore * si, guint callback_action) +{ + g_print ("Current staff num %d, callback_action %d", si->currentstaffnum, + callback_action); + switch (callback_action) + { + case BEFORE: + if (si->currentstaffnum != 1) + deletestaff (si, si->currentstaffnum - 2); + break; + case AFTER: + deletestaff (si, si->currentstaffnum + 1); + break; + default: + deletestaff (si, si->currentstaffnum - 1); + break; + } +/* displayhelper(si);*/ +} + +/** + * Delete staff from the score + * @param si pointer to the scoreinfo structure + * @param pos the position in the staff list + * @return none + */ +void +deletestaff (DenemoScore * si, gint pos) +{ + if (g_list_length (si->thescore) > 1) + { + removestaff (si, pos, 1); + setcurrents (si); + find_xes_in_all_measures (si); + si->haschanged = TRUE; + si->markstaffnum = 0; + } +} /** * Delete mesasure from score diff -urN denemo-cvsUPDATE/denemo/src/commandfuncs.h denemo-cvs/denemo/src/commandfuncs.h --- denemo-cvsUPDATE/denemo/src/commandfuncs.h 2007-09-23 17:13:38.000000000 +0100 +++ denemo-cvs/denemo/src/commandfuncs.h 2007-09-22 21:37:33.000000000 +0100 @@ -5,10 +5,9 @@ * (c) 1999-2005 Matthew Hiller */ - +#include #ifndef COMMANDFUNCSH #define COMMANDFUNCSH -#include void nudgerightward (DenemoGUI *gui); @@ -78,6 +77,9 @@ appendmeasures (DenemoScore *si, gint number); void +deletestaff (DenemoScore *si, gint pos); + +void insertclone (DenemoScore *si); void @@ -126,8 +128,7 @@ void displayhelper(DenemoGUI *si); gboolean auto_save_document_timeout(DenemoScore *si); - - +void delete_staff(DenemoScore *si, guint callback_action); void delete_staff_current(GtkAction *action,DenemoGUI *gui); void delete_staff_before(GtkAction *action, DenemoGUI *gui); diff -urN denemo-cvsUPDATE/denemo/src/contexts.c denemo-cvs/denemo/src/contexts.c --- denemo-cvsUPDATE/denemo/src/contexts.c 2007-09-23 17:14:04.000000000 +0100 +++ denemo-cvs/denemo/src/contexts.c 2007-08-22 10:50:03.000000000 +0100 @@ -50,7 +50,7 @@ /** * Finds the first occurrences of the clef, keysig and timesig of the - * current staff inserting them into the passed CURSTAFFSTRUCT + * current staff * * @param curstaffstruct the current staff * @param si the scoreinfo structure diff -urN denemo-cvsUPDATE/denemo/src/denemoui.xml denemo-cvs/denemo/src/denemoui.xml --- denemo-cvsUPDATE/denemo/src/denemoui.xml 2007-09-23 17:14:22.000000000 +0100 +++ denemo-cvs/denemo/src/denemoui.xml 2007-08-22 10:50:03.000000000 +0100 @@ -55,7 +55,7 @@ - + @@ -159,8 +159,6 @@ - - diff -urN denemo-cvsUPDATE/denemo/src/figure.c denemo-cvs/denemo/src/figure.c --- denemo-cvsUPDATE/denemo/src/figure.c 2007-09-23 17:16:05.000000000 +0100 +++ denemo-cvs/denemo/src/figure.c 2007-01-24 19:44:26.000000000 +0000 @@ -113,9 +113,6 @@ DenemoObject *curObj = (DenemoObject *) si->currentobject ? (DenemoObject *) si->currentobject->data : NULL; gchar *figure = (gchar *) gtk_entry_get_text (GTK_ENTRY (cbdata->entry)); - if(strlen(figure)<1) - figure = "_";/* in case user deleted the figure to yield <> */ - if (curObj && curObj->type == CHORD) //apply_figure ((chord *) curObj->object, figure); ((chord *) curObj->object)->is_figure = TRUE; diff -urN denemo-cvsUPDATE/denemo/src/file.c denemo-cvs/denemo/src/file.c --- denemo-cvsUPDATE/denemo/src/file.c 2007-09-23 17:17:16.000000000 +0100 +++ denemo-cvs/denemo/src/file.c 2007-09-20 21:20:22.000000000 +0100 @@ -488,6 +488,7 @@ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_selection), gui->prefs->denemopath->str); } + //set_current_folder(file_selection, gui); } } /** diff -urN denemo-cvsUPDATE/denemo/src/keyresponses.c denemo-cvs/denemo/src/keyresponses.c --- denemo-cvsUPDATE/denemo/src/keyresponses.c 2007-09-23 17:18:35.000000000 +0100 +++ denemo-cvs/denemo/src/keyresponses.c 2007-09-22 21:37:34.000000000 +0100 @@ -39,27 +39,47 @@ /* in rhythmicsubmode when a duration is entered set up a singleton rhythm pattern that is just this one duration */ -#define RSM (gui->si->rhythmicsubmode) - if((RSM & RSM_RHYTHM ) && !(RSM & RSM_OVERLAY)) - if( ki->func.nocallback==(gpointer)insert_chord_0key || - ki->func.nocallback==(gpointer)insert_chord_1key || - ki->func.nocallback==(gpointer)insert_chord_2key || - ki->func.nocallback==(gpointer)insert_chord_3key || - ki->func.nocallback==(gpointer)insert_chord_4key || - ki->func.nocallback==(gpointer)insert_chord_5key || - ki->func.nocallback==(gpointer)insert_chord_6key) - { - make_singleton_rhythm(gui, (gpointer)ki->func.callback); - return 0; + if(gui->si->rhythmicsubmode) + if( + ki->func.nocallback==(gpointer)insert_chord_0key || + ki->func.nocallback==(gpointer)insert_chord_1key || + ki->func.nocallback==(gpointer)insert_chord_2key || + ki->func.nocallback==(gpointer)insert_chord_3key || + ki->func.nocallback==(gpointer)insert_chord_4key || + ki->func.nocallback==(gpointer)insert_chord_5key || + ki->func.nocallback==(gpointer)insert_chord_6key + ) + + { +#define g (gui->si->rstep) + + RhythmElement *relement = (RhythmElement*)g_malloc0(sizeof(RhythmElement)); + relement->functions = g_list_append(NULL, (gpointer)ki->func.callback); + if(gui->si->currhythm) { + unhighlight_rhythm((RhythmPattern *)gui->si->currhythm->data); + + } else if(g) { + g_list_free(((RhythmElement*)g->data)->functions); + g->next = g->prev = NULL; + g_list_free(g); } + g = g_list_append(NULL,relement); + g->next = g->prev = g; + gui->si->currhythm = NULL; /* FIXME memory leak on returning to a + rhythmic pattern on rhythm toolbar. */ + return 0; + } if (ki->callback_action == -1) ki->func.nocallback (gui); else ki->func.callback (NULL, gui); displayhelper (gui); + //gtk_signal_emit_stop_by_name(widget, "key_press_event"); + //gtk_signal_emit_stop_by_name(gui->window, "key_press_event"); gtk_widget_draw (gui->scorearea, NULL); return 1; - } +#undef g + } return 0; } diff -urN denemo-cvsUPDATE/denemo/src/pitchentry.c denemo-cvs/denemo/src/pitchentry.c --- denemo-cvsUPDATE/denemo/src/pitchentry.c 2007-09-23 17:20:02.000000000 +0100 +++ denemo-cvs/denemo/src/pitchentry.c 2007-09-20 21:20:22.000000000 +0100 @@ -145,11 +145,6 @@ static temperament *PR_temperament; /* the currently used temperament */ -static void clear_tones_currentmeasure(GtkButton *button, DenemoGUI *gui ); - -static void switch_back_to_main_window(void) { -gtk_window_present(GTK_WINDOW(PR_gui->window)); -} static void pr_display_note(DenemoGUI*gui, gchar *notename) { @@ -248,7 +243,6 @@ gchar *names = notenames(PR_temperament); gtk_label_set_markup((GtkLabel*)label, names); g_free(names); - switch_back_to_main_window(); return; } @@ -273,7 +267,6 @@ gchar *names = notenames(PR_temperament); gtk_label_set_markup((GtkLabel*)label, names); g_free(names); - switch_back_to_main_window(); return; } @@ -290,13 +283,11 @@ return NULL; } -/* apply the tones in the currentmeasure to the notes of the currentmeasure -* return TRUE if measure has enough tones for all its notes -*/ +/* apply the tones in the currentmeasure to the notes of the currentmeasure */ static gboolean apply_tones(DenemoScore *si) { gboolean ret=FALSE; - DenemoStaff* curstaff = ((DenemoStaff*)si->currentstaff->data); +#define curstaff ((DenemoStaff*)si->currentstaff->data) GList *store; gint measurenum; store = (curstaff->tone_store); @@ -308,49 +299,36 @@ if(curmeasure) { store_el = get_tones(store, measurenum); objnode *curobj = curmeasure->data; - - // start at currentobject - while(curobj!=si->currentobject) - curobj = curobj->next; - - - while (curobj) + for (; curobj && store_el; curobj = curobj->next) { tone* thetone; - //skip over invalid tones while(store_el && (thetone = (tone*)store_el->data) && !thetone->valid) store_el = store_el->next; - gboolean tone_stored = FALSE; + DenemoObject *theobj = (DenemoObject *) curobj->data; if(theobj->type == CHORD && ((chord*)theobj->object)->notes /* not a rest */) { + find_leftmost_staffcontext (curstaff, si); if(thetone==NULL || store_el==NULL) ((chord*)theobj->object)->tone_node = NULL; else { - find_leftmost_staffcontext (curstaff, si); int dclef = curstaff->leftmost_clefcontext; int mid_c_offset = thetone->step; ((chord*)theobj->object)->tone_node = store_el; - modify_note((chord*)theobj->object, mid_c_offset, thetone->enshift, dclef); - tone_stored=TRUE; + modify_note(((chord*)theobj->object)->notes->data, mid_c_offset, thetone->enshift, dclef); + ((chord *) theobj->object)->sum_mid_c_offset = mid_c_offset;//Damned difficult to track this down - will not work if there are >1 notes in chord + ((chord *) theobj->object)->highestpitch = mid_c_offset; + ((chord *) theobj->object)->highesty = + calculateheight (mid_c_offset, dclef); + ((chord *) theobj->object)->lowestpitch = mid_c_offset; + ((chord *) theobj->object)->lowesty = + calculateheight (mid_c_offset, dclef); store_el = store_el->next; }// tone available }// note available - /* skip over non notes */ - do { - curobj = curobj->next; - if(curobj) - theobj = (DenemoObject *) curobj->data; - } - while(curobj && (theobj->type != CHORD || ((chord*)theobj->object)->notes==NULL)); - - - if(tone_stored && curobj==NULL && curmeasure->next) + if(curobj->next==NULL && curmeasure->next) ret = TRUE; - - - - }// while objects in measure + }// for objects in measure if(store_el && !PR_continuous) sound_click();//extra tones in measure showwhichaccidentals ((objnode *) si->currentmeasure->data, @@ -403,14 +381,6 @@ thetone->octave = octave; thetone->valid = TRUE; #define store (((DenemoStaff*)gui->si->currentstaff->data)->tone_store) - /* if this measure has tones, but not on the currentobject then clear the tones, otherwise - the one being stored will not apply to the currentobject */ - -#if 1 - if(gui->si->currentobject && !((chord*)((DenemoObject *)gui->si->currentobject->data)->object)->tone_node && store && g_list_nth(store,gui->si->currentmeasurenum - 1) && g_list_nth(store,gui->si->currentmeasurenum - 1)->data) - clear_tones_currentmeasure(NULL, gui); -#endif - store = put_tone(store, gui->si->currentmeasurenum - 1, thetone); nextmeasure = apply_tones(gui->si); displayhelper (gui); @@ -423,13 +393,11 @@ #undef store } -/* - * clear the references to tones (ie any overlay) in the currentstaff - */ + static void clear_tone_nodes(DenemoGUI *gui ) { + // FIXME menory leak, free the curstaff->tone_store DenemoScore *si = gui->si; - DenemoStaff* curstaff = ((DenemoStaff*)si->currentstaff->data); - +#define curstaff ((DenemoStaff*)si->currentstaff->data) measurenode *curmeasure; for (curmeasure = curstaff->measures;curmeasure; curmeasure = curmeasure->next) { objnode *curobj = curmeasure->data; @@ -450,10 +418,11 @@ } } - // clear gui->si->currentstaff->data->tone_store and the references to it + // clear gui->si->currentstaff->data->tone_store static void clear_tone_store(GtkButton *button, DenemoGUI *gui ) { #define store (((DenemoStaff*)gui->si->currentstaff->data)->tone_store) - g_list_foreach (store, (GFunc)free_tones, NULL); + + g_list_foreach (store, free_tones, NULL); clear_tone_nodes(gui); g_list_free(store); store = NULL; @@ -461,33 +430,6 @@ displayhelper(gui); } -/* - * clear the references to tones (ie any overlay) in the currentmeasure - */ -static void clear_tone_nodes_currentmeasure(DenemoGUI *gui ) { - measurenode *curmeasure = gui->si->currentmeasure; - objnode *curobj = curmeasure->data; - for (; curobj; curobj = curobj->next) - { - DenemoObject *theobj = (DenemoObject *) curobj->data; - if(theobj->type == CHORD) { - ((chord*)theobj->object)->tone_node = NULL; - } - } -} - - // clear gui->si->currentstaff->data->tone_store entry for currentmeasure and the references to it -static void clear_tones_currentmeasure(GtkButton *button, DenemoGUI *gui ) { - if(gui->si->currentmeasure){ -#define store (((DenemoStaff*)gui->si->currentstaff->data)->tone_store) - GList *g = g_list_nth(store,gui->si->currentmeasurenum - 1); - free_tones(g->data); - store = g_list_delete_link(store, g); - clear_tone_nodes_currentmeasure(gui); -#undef store - displayhelper(gui); - } -} gboolean delete_tone(DenemoScore *si, chord *thechord) { GList *tone_node = thechord->tone_node; @@ -542,6 +484,8 @@ static gint last_step=-1, last_alteration, last_octave; if(PR_window==NULL) return FALSE;/* stops the timer */ + // if(GTK_WIDGET_HAS_FOCUS (gui->scorearea)) + //return TRUE; double deviation; temperament *t = (temperament*)PR_temperament; @@ -608,51 +552,42 @@ // toggle PR_continuous advance to next measure or not static void toggle_continuous(GtkButton *button, DenemoGUI *gui ) { PR_continuous = !PR_continuous; - switch_back_to_main_window(); } static void change_silence(GtkSpinButton *widget, gpointer data){ double silence = gtk_spin_button_get_value(widget); set_silence(silence); - switch_back_to_main_window(); } static void change_threshold(GtkSpinButton *widget, gpointer data){ double t = gtk_spin_button_get_value(widget); set_threshold(t); - switch_back_to_main_window(); } static void change_smoothing(GtkSpinButton *widget, gpointer data){ double m = gtk_spin_button_get_value(widget); set_smoothing(m); - switch_back_to_main_window(); } static void change_onset_detection(GtkSpinButton *widget, gpointer data){ guint m = gtk_spin_button_get_value(widget); set_onset_type(m); - switch_back_to_main_window(); } static void change_lowest_pitch(GtkSpinButton *widget, gpointer data){ lowest_pitch = gtk_spin_button_get_value(widget); - switch_back_to_main_window(); } static void change_highest_pitch(GtkSpinButton *widget, gpointer data){ highest_pitch = gtk_spin_button_get_value(widget); - switch_back_to_main_window(); } static void change_greatest_interval(GtkSpinButton *widget, gpointer data){ greatest_interval = gtk_spin_button_get_value_as_int(widget); - switch_back_to_main_window(); } static void change_transposition(GtkSpinButton *widget, gpointer data){ gdouble power = gtk_spin_button_get_value_as_int(widget); transposition_required = pow(2.0, power); - switch_back_to_main_window(); -//printf("transposing = %f 2^1/12=%f\n", transposition_required, pow(2,1.0/12.0)); + printf("transposing = %f 2^1/12=%f\n", transposition_required, pow(2,1.0/12.0)); } /* destroy PR_window, and hence terminate the pitch recog subsystem */ @@ -696,23 +631,18 @@ static void toggle_repeated_notes_allowed(){ repeated_notes_allowed = !repeated_notes_allowed; -switch_back_to_main_window(); } - - - -//eventually make this value control the loudness of a click -static void change_click_volume(GtkSpinButton *widget){ +static void change_click_volume(GtkSpinButton *widget, DenemoGUI *gui){ PR_click = (guint)gtk_spin_button_get_value(widget); - switch_back_to_main_window(); +gtk_window_present(GTK_WINDOW(gui->window)); + //eventually make this value control the loudness of a click } static void change_timer_rate(GtkSpinButton *widget, DenemoGUI *gui){ PR_time = (guint)gtk_spin_button_get_value(widget); start_pitch_recognition(gui);//FIXME do not call the whole of start_pitch_recognition, just the timer setting bit??? - switch_back_to_main_window(); } @@ -720,7 +650,7 @@ // switch the button to read Collect Notes/Insert Notes // toggle PR_insert to show where the notes detected should go PR_insert = !PR_insert; - switch_back_to_main_window(); + } @@ -789,12 +719,12 @@ GtkWidget *spinner = gtk_spin_button_new (spinner_adj, 1.0, 1); gtk_box_pack_start (GTK_BOX (hbox2), spinner, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (spinner), "value-changed", - G_CALLBACK (change_click_volume), NULL); + G_CALLBACK (change_click_volume), gui); - button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio_button), "Insert Notes"); + button = gtk_radio_button_new_with_label_from_widget(radio_button, "Insert Notes"); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);/* no need for callback */ diff -urN denemo-cvsUPDATE/denemo/src/staffops.c denemo-cvs/denemo/src/staffops.c --- denemo-cvsUPDATE/denemo/src/staffops.c 2007-09-23 17:20:51.000000000 +0100 +++ denemo-cvs/denemo/src/staffops.c 2007-09-20 21:20:22.000000000 +0100 @@ -353,7 +353,7 @@ /** * Remove a number = 1 of staffs from the score * @param si the scoreinfo structure - * @param pos the position of the staff to remove, starting a 0 + * @param pos the position of the staff to remove * @param unused numstaffs the number of staffs to remove * @return none */ @@ -367,7 +367,7 @@ data : NULL); if (curstaffstruct) { - if(g_list_length(si->thescore) < 2 || pos > g_list_length(si->thescore)-1 || pos < 0) /* FIXME do not let these happen - e.g. make DeleteStaffAfter button inactive when on last staff etc */ + if(g_list_length(si->thescore) < 2 || pos > g_list_length(si->thescore) || pos <1) /* FIXME do not let these happen - e.g. make DeleteStaffAfter button inactive when on last staff etc */ return; gboolean isprimary = ((int) curstaffstruct->voicenumber == 1) ? TRUE : FALSE; @@ -388,7 +388,7 @@ g_free (curstaffstruct); si->thescore = g_list_remove_link (si->thescore, si->currentstaff); g_list_free_1 (si->currentstaff); - if (pos < si->currentstaffnum) + if (pos <= si->currentstaffnum) { if(si->currentstaffnum>1) si->currentstaffnum--; diff -urN denemo-cvsUPDATE/denemo/src/staffops.h denemo-cvs/denemo/src/staffops.h --- denemo-cvsUPDATE/denemo/src/staffops.h 2007-09-23 18:20:36.000000000 +0100 +++ denemo-cvs/denemo/src/staffops.h 2007-07-10 01:34:43.000000000 +0100 @@ -4,16 +4,19 @@ * for Denemo, a gtk+ frontend to GNU Lilypond * (c) 1999-2005 Matthew Hiller */ +/* This function returns a staff containing n empty measures */ #ifndef __STAFFOPS_H__ #define __STAFFOPS_H__ -#include enum newstaffcallbackaction - { INITIAL, FIRST, LAST, ADDFROMLOAD, BEFORE, AFTER, CURRENT, +{ INITIAL, FIRST, LAST, ADDFROMLOAD, BEFORE, AFTER, NEWVOICE,LYRICSTAFF, FIGURESTAFF, CHORDSTAFF }; + +#include + struct newstaffinfotopass { DenemoScore *si; DenemoStaff *staff; diff -urN denemo-cvsUPDATE/denemo/src/view.c denemo-cvs/denemo/src/view.c --- denemo-cvsUPDATE/denemo/src/view.c 2007-09-23 18:32:15.000000000 +0100 +++ denemo-cvs/denemo/src/view.c 2007-09-22 21:37:34.000000000 +0100 @@ -325,7 +325,7 @@ /** * Rhythm callback select rhythm - * inserts the rhythm if pitchless + * */ void select_rhythm_pattern(GtkToolButton *toolbutton, RhythmPattern *r) { @@ -336,17 +336,15 @@ r->gui->si->currhythm = g_list_find(r->gui->si->rhythms, r); r->gui->si->rstep = r->rsteps; #define g (r->gui->si->rstep) -#define RSM (r->gui->si->rhythmicsubmode) + if(((RhythmElement*)g->data)->icon) { GtkWidget *label = LABEL(CURRP->button); gtk_label_set_markup(GTK_LABEL(label),((RhythmElement*)g->data)->icon); } highlight_rhythm(CURRP); - if( (RSM&RSM_RHYTHM) && (RSM&RSM_OVERLAY)) - insert_rhythm_pattern(r->gui); + #undef CURRP #undef g -#undef RSM } /* duration_code(gpointer function) @@ -583,33 +581,13 @@ unhighlight_rhythm((RhythmPattern *)gui->si->currhythm->data); gui->si->currhythm = g_list_last(gui->si->rhythms); highlight_rhythm((RhythmPattern *)gui->si->currhythm->data); + + //gui->si->rhythmicsubmode = (gboolean)gui->si->rhythms; g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (select_rhythm_pattern), (gpointer)r); } } } - - -void make_singleton_rhythm(DenemoGUI *gui, gpointer function) { -#define g (gui->si->rstep) - RhythmElement *relement = (RhythmElement*)g_malloc0(sizeof(RhythmElement)); - relement->functions = g_list_append(NULL, function); - if(gui->si->currhythm) { - unhighlight_rhythm((RhythmPattern *)gui->si->currhythm->data); - } else if(g) { - g_list_free(((RhythmElement*)g->data)->functions); - g->next = g->prev = NULL; - g_list_free(g); - } - g = g_list_append(NULL,relement); - g->next = g->prev = g; - gui->si->currhythm = NULL; /* FIXME memory leak on returning to a - rhythmic pattern on rhythm toolbar. */ -#undef g -} - - - /* * delete a rhythmic pattern and its button * @@ -617,8 +595,7 @@ static void delete_rhythm_cb (GtkAction * action, DenemoGUI * gui) { - - if(gui->si->rhythmicsubmode == RSM_OFF) + if(gui->si->rhythmicsubmode == FALSE) return; if(gui->si->currhythm==NULL) return; @@ -638,7 +615,7 @@ gui->si->currhythm = g_list_last(gui->si->rhythms); if(gui->si->currhythm == NULL) - gui->si->rstep = NULL; + gui->si->rstep = NULL;/* gui->si->rhythmicsubmode = FALSE */ else { highlight_rhythm(gui->si->currhythm->data); gui->si->rstep = ((RhythmPattern *)gui->si->currhythm->data)->rsteps; @@ -827,8 +804,8 @@ {"InsertQuarterNote", "denemo-quarter-note", N_("Quarter note"), NULL, N_("Quarter note"), G_CALLBACK (insert_chord_2key_cb)}, - {"InsertEighthNote", "denemo-eight-note", N_("Eighth note"), NULL, - N_("Eighth note"), + {"InsertEighthNote", "denemo-eight-note", N_("Eight note"), NULL, + N_("Eight note"), G_CALLBACK (insert_chord_3key_cb)}, {"InsertSixteenthNote", "denemo-sixteenth-note", N_("Sixteenth note"), NULL, N_("Sixteenth note"), @@ -843,17 +820,17 @@ N_("Quarter rest"), G_CALLBACK (insert_rest_2key_cb)}, {"InsertEighthRest", "denemo-eight-rest", N_("Eight rest"), NULL, - N_("Eighth rest"), + N_("Eight rest"), G_CALLBACK (insert_rest_3key_cb)}, {"InsertSixteenthRest", "denemo-sixteenth-rest", N_("Sixteenth rest"), NULL, N_("Sixteenth rest"), G_CALLBACK (insert_rest_4key_cb)}, /* Rhythm entry */ {"CreateRhythm", NULL, N_("Create a rhythm"), NULL, - N_("Create a rhythm pattern"), + N_("Create a rhythm"), G_CALLBACK (create_rhythm_cb)}, - {"DeleteRhythm", NULL, N_("Delete"), NULL, - N_("Delete the selected rhythm pattern"), + {"DeleteRhythm", NULL, N_("Delete a rhythm"), NULL, + N_("Delete a rhythm"), G_CALLBACK (delete_rhythm_cb)} }; @@ -885,14 +862,7 @@ } } -/** - * Function to toggle entry of rhythms without pitches - * - */ -static void -toggle_pitchless (GtkAction * dummy, DenemoGUI * gui) { - gui->si->rhythmicsubmode ^= RSM_OVERLAY; -} + /** * Function to toggle entry of notes by pitch recognition off/on * @@ -934,8 +904,7 @@ /** * Function to toggle whether rhythm toolbar is visible - * Sets the rhythmic submode, and turns off pitchless entry if it is being hidden. - * + * */ static void toggle_rhythm_toolbar (GtkAction * action, DenemoGUI * gui) @@ -945,14 +914,9 @@ widget = gtk_ui_manager_get_widget (gui->ui_manager, "/RhythmToolBar"); if (GTK_WIDGET_VISIBLE (widget)) { - if(gui->si->rhythmicsubmode & RSM_OVERLAY) { - GtkAction *tog = gtk_ui_manager_get_action (gui->ui_manager, "/RhythmToolBar/TogglePitchless"); -/* g_print("type is %s\n", g_type_name(G_TYPE_FROM_INSTANCE(tog))); */ - g_signal_emit_by_name(tog, "activate", NULL, gui); - } if(gui->prefs->standard_keymap) gui->prefs->the_keymap = gui->prefs->standard_keymap; - gui->si->rhythmicsubmode = RSM_OFF; + gui->si->rhythmicsubmode = FALSE; gtk_widget_hide (widget); } else @@ -964,7 +928,7 @@ } gui->prefs->the_keymap = rhythm_keymap; gtk_widget_show (widget); - gui->si->rhythmicsubmode |= (RSM_RHYTHM); + gui->si->rhythmicsubmode = TRUE;/*(gboolean)gui->si->rhythms; FIXME provide a button to set this */ } } @@ -972,20 +936,17 @@ * Toggle entries for the menus */ GtkToggleActionEntry toggle_menu_entries[] = { - {"ToggleNotationToolbar", NULL, N_("_Durations Toolbar"), NULL, N_("Enter single notes/rests of a given duration"), + {"ToggleNotationToolbar", NULL, N_("_Notation Toolbar"), NULL, NULL, G_CALLBACK (toggle_notation_toolbar), FALSE} , - {"ToggleRhythmToolbar", NULL, N_("_Rhythmic & Overlays"), NULL, N_("Enter notes using a prevailing rhythm\nOverlay with pitches"), + {"ToggleRhythmToolbar", NULL, N_("_Rhythmic Patterns"), NULL, NULL, G_CALLBACK (toggle_rhythm_toolbar), FALSE} , - {"TogglePitchRecognition", NULL, N_("_Microphone"), NULL, N_("Enable pitch entry from microphone"), + {"TogglePitchRecognition", NULL, N_("_Pitch Recognition"), NULL, NULL, G_CALLBACK (toggle_pitch_recognition), FALSE} , {"ToggleArticulationPalette", NULL, N_("_Articulation Palette"), NULL, NULL, G_CALLBACK (toggle_articulation_palette), FALSE} - , - {"TogglePitchless", NULL, N_("_Overlay"), NULL, N_("Pure rhythm entry\nAnd overlay notes with pitches"), - G_CALLBACK (toggle_pitchless), FALSE} }; @@ -1079,7 +1040,6 @@ gui->si = new_score (gui->prefs->lilyversion->str); newstaff (gui->si, INITIAL, DENEMO_NONE); - make_singleton_rhythm(gui, (gpointer)insert_chord_2key);/* start with quarter note */ gui->pixmap = NULL; /* Initialize the GUI */ @@ -1116,14 +1076,15 @@ gui->ui_manager = ui_manager; gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); accel_group = gtk_ui_manager_get_accel_group (ui_manager); - gtk_window_add_accel_group (GTK_WINDOW (gui->window), accel_group); + error = NULL; + + gtk_window_add_accel_group (GTK_WINDOW (gui->window), accel_group); data_dir = g_build_filename ( #ifndef USE_LOCAL_DENEMOUI get_data_dir (), #endif "denemoui.xml", NULL); - error = NULL; if (!gtk_ui_manager_add_ui_from_file (ui_manager, data_dir, &error)) { g_message ("building menu failed: %s", error->message); @@ -1146,6 +1107,14 @@ gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, TRUE, 0); GTK_WIDGET_UNSET_FLAGS(toolbar, GTK_CAN_FOCUS); gtk_widget_show (toolbar); +#if 0 +/* what were these for???? */ + widget = gtk_ui_manager_get_widget (ui_manager, "/ToolBar/Open"); + /*gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), TRUE); */ + + widget = gtk_ui_manager_get_widget (ui_manager, "/ToolBar/Save"); + /*gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), TRUE); */ +#endif toolbar = gtk_ui_manager_get_widget (ui_manager, "/EntryToolBar"); g_print("EntryToolbar is %p\n", toolbar); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); @@ -1156,6 +1125,9 @@ toolbar = gtk_ui_manager_get_widget (ui_manager, "/RhythmToolBar"); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT); gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, TRUE, 0); +/* GTK_WIDGET_UNSET_FLAGS(toolbar, GTK_CAN_FOCUS); */ + + score_and_scroll_hbox = gtk_hbox_new (FALSE, 1); gtk_box_pack_start (GTK_BOX (main_vbox), score_and_scroll_hbox, TRUE, TRUE, @@ -1233,7 +1205,12 @@ if (gui->prefs->articulation_palette) toggle_articulation_palette (NULL, gui); toggle_rhythm_toolbar (NULL, gui); - +#if 0 + if (!gui->prefs->rhythm_palette) + toggle_rhythm_toolbar (NULL, gui); + else + gui->si->rhythmicsubmode = (gboolean)gui->si->rhythms; +#endif if (!gui->prefs->notation_palette) { g_print ("Notation palette %d\n", gui->prefs->notation_palette); diff -urN denemo-cvsUPDATE/denemo/src/view.h denemo-cvs/denemo/src/view.h --- denemo-cvsUPDATE/denemo/src/view.h 2007-09-23 17:22:40.000000000 +0100 +++ denemo-cvs/denemo/src/view.h 2007-09-22 21:37:34.000000000 +0100 @@ -68,6 +68,6 @@ void highlight_rhythm(RhythmPattern *r); void unhighlight_rhythm(RhythmPattern *r); -void make_singleton_rhythm(DenemoGUI *gui, gpointer function); + #endif