diff -urN denemo/include/denemo/denemo_types.h ../denemo-cvs/denemo/include/denemo/denemo_types.h --- denemo/include/denemo/denemo_types.h 2007-10-05 07:32:20.000000000 +0100 +++ ../denemo-cvs/denemo/include/denemo/denemo_types.h 2007-10-04 19:44:40.000000000 +0100 @@ -89,15 +89,11 @@ * Enumeration for Denemo's input mode */ typedef enum input_mode { -#define MODE_MASK (~(RSM_OFF|RSM_OVERLAY|RSM_RHYTHM)) - RSM_OFF = 0, /* classic mode */ - RSM_OVERLAY = 1<<0, /* edit mode */ - RSM_RHYTHM = 1<<1, /* insert mode */ -#define ENTRY_TYPE_MASK (~(INPUTNORMAL|INPUTREST|INPUTBLANK)) - INPUTNORMAL = 1<<2, /* entry type notes */ - INPUTREST = 1<<3, /* entry type rests */ - INPUTBLANK = 1<<4,/* entry type non-printing rests */ - TRAVERSE = 1<<5 /* read-only */ + INPUTNORMAL, + INPUTREST, + INPUTBLANK, + REPLACE, + TRAVERSE }input_mode; /** @@ -273,8 +269,8 @@ gboolean lilyentrystyle; gboolean createclones; gboolean articulation_palette; /**< This switch makes the articulation pallete visable */ - gboolean notation_palette; /**< This switch makes the duration toolbar visable */ - gboolean rhythm_palette; /**< This option makes the rhythm toolbar visable */ + gboolean notation_palette; /**< This switch makes the notation pallete visable */ + gboolean rhythm_palette; /**< This option makes the rhythm pallete visable */ gboolean saveparts; /**< Automatically save parts*/ gboolean autosave; /**< Auto save data */ gint autosave_timeout; @@ -316,6 +312,13 @@ }LilypondHeaderInfo; +typedef enum +{ + RSM_OFF = 0, + RSM_OVERLAY = 1<<0, + RSM_RHYTHM = 1<<1 + +} RhythmicSubmode; typedef enum { @@ -461,7 +464,8 @@ * operation */ gint curmeasure_stem_directive; - /* support for rhythm patterns */ + /* support for INPUTNORMAL sub mode RHYTMIC */ + RhythmicSubmode 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/src/commandfuncs.c ../denemo-cvs/denemo/src/commandfuncs.c --- denemo/src/commandfuncs.c 2007-10-04 20:01:27.000000000 +0100 +++ ../denemo-cvs/denemo/src/commandfuncs.c 2007-10-04 19:44:40.000000000 +0100 @@ -43,7 +43,7 @@ * is easy to alternate rhythms. */ void nextrhythm(DenemoGUI *gui) { - if(!(gui->mode&(RSM_RHYTHM|RSM_OVERLAY))) + if(!gui->si->rhythmicsubmode) return; if(!gui->si->rhythms) return; @@ -456,8 +456,7 @@ gui->si->staffletter_y = note_value; gui->si->cursor_y = jumpcursor (gui->si->cursor_y, oldstaffletter_y, gui->si->staffletter_y); - /* in RSM_OVERLAY edit the current note name */ - if((gui->mode & RSM_OVERLAY) && gui->si->currentobject) { + 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); @@ -469,9 +468,9 @@ gui->si->curmeasurekey, gui->si->curmeasureaccs); } } else - /* in INSERT or EDIT mode 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->mode&(RSM_RHYTHM|RSM_OVERLAY)) && g) { + if(gui->si->rhythmicsubmode && g) { GList *start = g; GList *h; do { @@ -496,23 +495,18 @@ #undef g } - void insert_rhythm_pattern(DenemoGUI *gui) { #define g (gui->si->rstep) - if((gui->mode&(RSM_RHYTHM|RSM_OVERLAY)) && g) { + 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; - if(!code_is_a_duration(modifier_code(h->data))) - cursorleft(gui); + gui->si->cursoroffend = FALSE; ((GtkFunction)h->data)(gui); - if(!code_is_a_duration(modifier_code(h->data))) - cursorright(gui); displayhelper(gui); } h = ((RhythmElement*)g->data)->functions; @@ -589,12 +583,6 @@ int prognum; DenemoStaff *curstaffstruct; - if((mode & RSM_OVERLAY) && !si->cursor_appending) { - changeduration(si, duration); - return; - } - - /* First, check to see if the insertion'll cause the cursor to * jump to the next measure. (Denemo will implicitly create it * if it doesn't exist already.) */ @@ -606,13 +594,13 @@ /* Now actually create the chord */ mudela_obj_new = newchord (duration, 0, 0); - if ( (mode & INPUTBLANK) && (rest != TRUE)) + if (mode == INPUTBLANK && (rest != TRUE)) { addtone (mudela_obj_new, si->cursor_y, si->cursoraccs[si->staffletter_y], si->cursorclef); mudela_obj_new->isinvisible = TRUE; } - else if ((mode & INPUTNORMAL) && (rest != TRUE)) + else if (mode == INPUTNORMAL && (rest != TRUE)) addtone (mudela_obj_new, si->cursor_y, si->cursoraccs[si->staffletter_y], si->cursorclef); @@ -726,11 +714,11 @@ } /** - * If REMOVE delete the note closest to si->cursor_y in a ~si->currentobject - * else add a tone at si->cursor_y to the ~si->currentobject - * FIXME ~si->currentobject in this comment means the thing gotten by the macro declaremudelaobj. This macro is a horrible hack induced by trying to be clever with tuplets - enforcing pairing of begin/end. tonechange + * Change a tone either in a chord or individual note + * alternatively remove it from a chord + * * @param si pointer to the scoreinfo structure - * @param remove whether to remove note or not + * @param remove whether to remove tone or not */ void tonechange (DenemoScore * si, gboolean remove) diff -urN denemo/src/denemoui.xml ../denemo-cvs/denemo/src/denemoui.xml --- denemo/src/denemoui.xml 2007-10-06 17:11:43.000000000 +0100 +++ ../denemo-cvs/denemo/src/denemoui.xml 2007-10-04 19:44:40.000000000 +0100 @@ -10,7 +10,6 @@ - @@ -45,20 +44,17 @@ --> - + - - + - - - - + + @@ -164,7 +160,7 @@ - + diff -urN denemo/src/drawcursor.c ../denemo-cvs/denemo/src/drawcursor.c --- denemo/src/drawcursor.c 2007-10-04 20:09:17.000000000 +0100 +++ ../denemo-cvs/denemo/src/drawcursor.c 2007-01-24 19:44:26.000000000 +0000 @@ -42,9 +42,9 @@ purplegc = gcs_purplegc (); } - paintgc = (mode & INPUTREST) ? graygc : - (mode & INPUTBLANK) ? bluegc : - (mode & RSM_OVERLAY) ? purplegc : si->cursoroffend ? redgc : greengc; + paintgc = (mode == INPUTREST) ? graygc : + (mode == INPUTBLANK) ? bluegc : + (mode == REPLACE) ? purplegc : si->cursoroffend ? redgc : greengc; gdk_draw_rectangle (pixmap, paintgc, TRUE, xx, height + y - CURSOR_MINUS, CURSOR_WIDTH, CURSOR_HEIGHT); diff -urN denemo/src/keyresponses.c ../denemo-cvs/denemo/src/keyresponses.c --- denemo/src/keyresponses.c 2007-10-06 17:13:21.000000000 +0100 +++ ../denemo-cvs/denemo/src/keyresponses.c 2007-10-04 19:44:40.000000000 +0100 @@ -37,9 +37,9 @@ event->state))) { - /* in rhythmic mode when a duration is entered set up a singleton rhythm pattern that + /* in rhythmicsubmode when a duration is entered set up a singleton rhythm pattern that is just this one duration */ -#define RSM (gui->mode) +#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 || @@ -194,10 +194,10 @@ void octave_up_key (DenemoGUI * gui) { - if(gui->mode&(RSM_RHYTHM|RSM_OVERLAY)) + if(gui->si->rhythmicsubmode) tonechange(gui->si, TRUE); gui->si->cursor_y += 7; - if(gui->mode&(RSM_RHYTHM|RSM_OVERLAY)) + if(gui->si->rhythmicsubmode) tonechange(gui->si, FALSE); } @@ -207,10 +207,10 @@ void octave_down_key (DenemoGUI * gui) { - if(gui->mode&(RSM_RHYTHM|RSM_OVERLAY)) + if(gui->si->rhythmicsubmode) tonechange(gui->si, TRUE); gui->si->cursor_y -= 7; - if(gui->mode&(RSM_RHYTHM|RSM_OVERLAY)) + if(gui->si->rhythmicsubmode) tonechange(gui->si, FALSE); } @@ -221,17 +221,55 @@ void default_mode (GtkAction * action, DenemoGUI * gui) { - - gui->mode ^= TRAVERSE; - if(gui->mode & TRAVERSE) - gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, - "Read Only"); + if (gui->mode != TRAVERSE) + gui->mode = TRAVERSE; + gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, + "Default"); g_print ("Mode %d\n", gui->mode); displayhelper (gui); + } +/** + * Change to insert mode + * + */ +void +insert_mode (GtkAction * action, DenemoGUI * gui) +{ + if (gui->mode != INPUTNORMAL) + gui->mode = INPUTNORMAL; + gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, + "Insert"); + displayhelper (gui); +} +/** + * Change to replace mode + * + */ +void +replace_mode (GtkAction * action, DenemoGUI * gui) +{ + if (gui->mode != REPLACE) + gui->mode = REPLACE; + gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, + "Replace"); + displayhelper (gui); +} +/** + * Change to blank mode i.e. insert invisible notes + */ +void +blank_mode (GtkAction * action, DenemoGUI * gui) +{ + if (gui->mode != INPUTBLANK) + gui->mode = INPUTBLANK; + gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, + "Blank"); + displayhelper (gui); +} /** * Toggle into rest mode @@ -240,26 +278,27 @@ void rest_toggle_key (GtkAction * action, DenemoGUI * gui) { - - gui->mode ^= INPUTREST; - if(gui->mode & INPUTREST) - gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, - "Rest Mode"); + if (gui->mode != INPUTREST) + gui->mode = INPUTREST; + gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, + "Rest Mode"); displayhelper (gui); } /** - * Toggle blank mode FIXME bitfields!!! + * Toggle blank mode * */ void toggle_blank (DenemoGUI * gui) { - gui->mode ^= INPUTBLANK; - if(gui->mode & INPUTBLANK) - gtk_statusbar_push (GTK_STATUSBAR (gui->statusbar), gui->status_context_id, - "Non-Printing Rest Mode"); - displayhelper (gui); + if (gui->mode == INPUTNORMAL) + gui->mode = INPUTBLANK; + else if (gui->mode == INPUTBLANK) + gui->mode = INPUTNORMAL; + else + gui->mode = INPUTREST; + } /** @@ -290,7 +329,9 @@ void insert_chord_0key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 0, gui->mode, FALSE); } @@ -298,42 +339,54 @@ void insert_chord_1key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 1, gui->mode, FALSE); } void insert_chord_2key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 2, gui->mode, FALSE); } void insert_chord_3key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 3, gui->mode, FALSE); } void insert_chord_4key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 4, gui->mode, FALSE); } void insert_chord_5key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 5, gui->mode, FALSE); } void insert_chord_6key (DenemoGUI * gui) { - + if (gui->mode == REPLACE) + change_pitch (gui); + else if (gui->mode == INPUTNORMAL || gui->mode == INPUTREST) dnm_insertchord (gui->si, 6, gui->mode, FALSE); } @@ -528,7 +581,7 @@ } /* if you are following a rhythmic pattern then backup the pattern */ #define g (gui->si->rstep) - if((gui->mode&(RSM_RHYTHM|RSM_OVERLAY)) && g) + if(gui->si->rhythmicsubmode && g) { #define CURRP ((RhythmPattern *)gui->si->currhythm->data) g = g->prev; /* list is circular - should we stop at beginning? */ @@ -832,7 +885,7 @@ void change_pitch (DenemoGUI * gui) { - if (gui->mode & RSM_OVERLAY) + if (gui->mode == REPLACE) { //DenemoObject *theobj = // si->currentobject ? (DenemoObject *) si->currentobject->data : NULL; diff -urN denemo/src/pitchentry.c ../denemo-cvs/denemo/src/pitchentry.c --- denemo/src/pitchentry.c 2007-10-04 20:12:03.000000000 +0100 +++ ../denemo-cvs/denemo/src/pitchentry.c 2007-10-04 19:44:40.000000000 +0100 @@ -302,16 +302,18 @@ store = (curstaff->tone_store); measurenode *curmeasure = curstaff->measures; GList *store_el = NULL; - // move cursor to start of current measure - si->currentobject = (objnode *) si->currentmeasure->data; - si->cursor_x = 0; - si->cursor_appending = !(gboolean)si->currentobject; - //calcmarkboundaries (si); + measurenum = si->currentmeasurenum - 1; curmeasure = si->currentmeasure; if(curmeasure) { store_el = get_tones(store, measurenum); objnode *curobj = curmeasure->data; + + // start at currentobject + while(curobj!=si->currentobject) + curobj = curobj->next; + + while (curobj) { tone* thetone; @@ -331,10 +333,7 @@ ((chord*)theobj->object)->tone_node = store_el; modify_note((chord*)theobj->object, mid_c_offset, thetone->enshift, dclef); tone_stored=TRUE; - if(!si->cursor_appending) - cursorright(PR_gui); store_el = store_el->next; - }// tone available }// note available /* skip over non notes */ @@ -342,10 +341,15 @@ curobj = curobj->next; if(curobj) theobj = (DenemoObject *) curobj->data; - } while(curobj && - (theobj->type != CHORD || ((chord*)theobj->object)->notes==NULL)); + } + while(curobj && (theobj->type != CHORD || ((chord*)theobj->object)->notes==NULL)); + + if(tone_stored && curobj==NULL && curmeasure->next) ret = TRUE; + + + }// while objects in measure if(store_el && !PR_continuous) sound_click();//extra tones in measure @@ -399,13 +403,19 @@ 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(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); store = put_tone(store, gui->si->currentmeasurenum - 1, thetone); nextmeasure = apply_tones(gui->si); displayhelper (gui); if(PR_continuous && nextmeasure) { sound_click(); measureright(gui); - } + } + + /* gtk_widget_draw(gui->scorearea, NULL); */ #undef store } @@ -415,6 +425,7 @@ static void clear_tone_nodes(DenemoGUI *gui ) { DenemoScore *si = gui->si; DenemoStaff* curstaff = ((DenemoStaff*)si->currentstaff->data); + measurenode *curmeasure; for (curmeasure = curstaff->measures;curmeasure; curmeasure = curmeasure->next) { objnode *curobj = curmeasure->data; @@ -444,7 +455,6 @@ store = NULL; #undef store displayhelper(gui); - switch_back_to_main_window(); } /* @@ -479,16 +489,23 @@ GList *tone_node = thechord->tone_node; if(tone_node) { ((tone*)tone_node->data)->valid = FALSE; - objnode *keep = si->currentobject; - gint keepx = si->cursor_x; - gboolean keepa = si->cursor_appending; + thechord->tone_node = NULL; + /* move cursor back to where tone overlay starts, so that the overlay is placed on the same notes as before */ + gint leftshifts = 0; + while(si->currentobject->prev) { + cursorleft(PR_gui); + leftshifts++; + DenemoObject *theobj = (DenemoObject *)si->currentobject->data; + if((theobj->type == CHORD) && (((chord*)theobj->object)->notes!=NULL) && (((chord*)theobj->object)->tone_node == NULL)) { + cursorright(PR_gui); + leftshifts--; + break; + } + } apply_tones(si); /*restore the position of the cursor before the delete of the tone */ - si->currentobject = keep; - si->cursor_x = keepx; - si->cursor_appending = keepa; - calcmarkboundaries (si); - + while(leftshifts--) + cursorright(PR_gui); displayhelper (PR_gui); return TRUE; } else { @@ -709,11 +726,10 @@ switch_back_to_main_window(); } - // toggle PR_insert to show where the notes detected should go, and start correct entry mode -static void toggle_insert(GtkButton *button, DenemoGUI *gui) { - GtkAction *action; - action = gtk_ui_manager_get_action (gui->ui_manager, PR_insert?"/MainMenu/EntryMenu/TogglePitchless": "/MainMenu/EntryMenu/Replace"); - gtk_action_activate(action); + +static void toggle_insert(GtkButton *button) { + // 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(); } @@ -757,7 +773,7 @@ gtk_box_pack_start (GTK_BOX (hbox2), radio_button, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (toggle_insert), gui); + G_CALLBACK (toggle_insert), NULL); button = gtk_button_new_with_label("Clear"); gtk_box_pack_start (GTK_BOX (hbox2), button, @@ -785,6 +801,10 @@ 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); + + + + button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio_button), "Insert Notes"); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);/* no need for callback */ diff -urN denemo/src/prefdialog.c ../denemo-cvs/denemo/src/prefdialog.c --- denemo/src/prefdialog.c 2007-10-04 20:02:44.000000000 +0100 +++ ../denemo-cvs/denemo/src/prefdialog.c 2007-01-24 19:44:26.000000000 +0000 @@ -30,7 +30,6 @@ GtkWidget *checkclone; GtkWidget *checkautosave; GtkWidget *checknotationpalette; - GtkWidget *checkrhythmpalette; GtkWidget *checkarticulationpalette; GtkWidget *autosaveentry; GtkWidget *browserentry; @@ -134,9 +133,6 @@ prefs->notation_palette = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cbdata->checknotationpalette)); - prefs->rhythm_palette = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (cbdata->checkrhythmpalette)); prefs->saveparts = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (cbdata->checkautosaveparts)); @@ -165,7 +161,6 @@ GtkWidget *texteditor; GtkWidget *denemopath; GtkWidget *checknotationpalette; - GtkWidget *checkrhythmpalette; GtkWidget *checkarticulationpalette; GtkWidget *notebook; GtkWidget *hbox; @@ -196,7 +191,7 @@ /* * Note entry settings */ - table = gtk_table_new (13, 2, FALSE); + table = gtk_table_new (9, 2, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table), 12); gtk_table_set_row_spacings (GTK_TABLE (table), 8); gtk_table_set_col_spacings (GTK_TABLE (table), 8); @@ -235,7 +230,7 @@ (GtkAttachOptions) (0), 0, 0); checknotationpalette = - gtk_check_button_new_with_label (_("Display durations toolbar")); + gtk_check_button_new_with_label (_("Display notataion toolbar")); gtk_widget_set_sensitive (checknotationpalette, TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checknotationpalette), gui->prefs->notation_palette); @@ -252,22 +247,8 @@ (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); - - checkrhythmpalette = - gtk_check_button_new_with_label (_("Display rhythm pattern toolbar")); - gtk_widget_set_sensitive (checkrhythmpalette, TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkrhythmpalette), - gui->prefs->rhythm_palette); - gtk_table_attach (GTK_TABLE (table), checkrhythmpalette, 0, 2, 8, 9, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - - - - hbox = gtk_hbox_new (FALSE, 8); - gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 10, 11, + gtk_table_attach (GTK_TABLE (table), hbox, 0, 2, 7, 8, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); @@ -292,7 +273,7 @@ gtk_widget_set_sensitive (checkarticulationpalette, FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkautosaveparts), gui->prefs->saveparts); - gtk_table_attach(GTK_TABLE(table), checkautosaveparts, 0,2, 11,12, + gtk_table_attach(GTK_TABLE(table), checkautosaveparts, 0,2, 8,9, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0,0); /* @@ -459,7 +440,6 @@ cbdata.checkautosaveparts = checkautosaveparts; cbdata.checkarticulationpalette = checkarticulationpalette; cbdata.checknotationpalette = checknotationpalette; - cbdata.checkrhythmpalette = checkrhythmpalette; cbdata.checkclone = checkclone; cbdata.checkautosave = checkautosave; cbdata.autosaveentry = autosaveentry; diff -urN denemo/src/prefops.c ../denemo-cvs/denemo/src/prefops.c --- denemo/src/prefops.c 2007-10-04 20:03:13.000000000 +0100 +++ ../denemo-cvs/denemo/src/prefops.c 2007-08-22 10:50:05.000000000 +0100 @@ -111,9 +111,8 @@ ret->createclones = FALSE; ret->autosave = TRUE; ret->autosave_timeout = 5; - ret->notation_palette = TRUE; - ret->articulation_palette = TRUE; - ret->rhythm_palette = TRUE; + ret->notation_palette = FALSE; + ret->articulation_palette = FALSE; ret->history = g_queue_new (); /* Read values from systemwide preferences file */ @@ -333,16 +332,6 @@ xmlFree (tmp); } } - else if (0 == - xmlStrcmp (cur->name, (const xmlChar *) "rhythmpalette")) - { - xmlChar *tmp = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); - if(tmp) - { - prefs->rhythm_palette = atoi ((gchar *) tmp); - xmlFree (tmp); - } - } else if (0 == xmlStrcmp (cur->name, (const xmlChar *) "lilyversion")) { xmlChar *tmp = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1); @@ -567,8 +556,6 @@ prefs->notation_palette); newXMLIntChild (child, (xmlChar *) "articulationpalette", prefs->articulation_palette); - newXMLIntChild (child, (xmlChar *) "rhythmpalette", - prefs->rhythm_palette); if (prefs->browser) xmlNewChild (child, NULL, (xmlChar *) "browser", (xmlChar *) prefs->browser->str); diff -urN denemo/src/view.c ../denemo-cvs/denemo/src/view.c --- denemo/src/view.c 2007-10-06 17:14:19.000000000 +0100 +++ ../denemo-cvs/denemo/src/view.c 2007-10-04 19:44:40.000000000 +0100 @@ -92,7 +92,7 @@ { GList *display = NULL; - stop_pitch_recognition(); + DenemoScore *si = gui->si; //Iterate through the views list if more than one is open if (g_list_length (displays) > 1) @@ -336,7 +336,7 @@ 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->mode) +#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); @@ -368,7 +368,7 @@ * return an ascii code to indicate what modifier (if any) function gives. * '0x0' means not a valid modifier for a rhythmic duration * char '.' means a dotted note, '(' and ')' mean start and end slur - * r to z are rests + * r to x are rests * others to be defined * */ @@ -387,9 +387,6 @@ fn==(gpointer)insert_rest_6key ? 'x':0; } -gboolean code_is_a_duration(gchar code) { - return code==0 || (code>='r' && code<='z'); -} /** * Callback to translate keypresses into rhythm elements @@ -621,7 +618,7 @@ delete_rhythm_cb (GtkAction * action, DenemoGUI * gui) { - if(gui->mode&(RSM_RHYTHM|RSM_OVERLAY) == 0) + if(gui->si->rhythmicsubmode == RSM_OFF) return; if(gui->si->currhythm==NULL) return; @@ -716,11 +713,14 @@ "List Available Plugins", G_CALLBACK (list_available_plugins)}, {"ViewMenu", NULL, N_("_View")}, {"EntryMenu", NULL, N_("Mo_de")}, - - - - - + {"Insert", NULL, N_("_Insert"), "Insert", "Insert Mode", + G_CALLBACK (insert_mode)}, + {"Replace", NULL, N_("_Replace"), NULL, "Replace Mode", + G_CALLBACK (replace_mode)}, + {"Blank", NULL, N_("_Blank"), NULL, "Blank Mode", G_CALLBACK (blank_mode)}, + {"Rest", NULL, N_("_Rest"), "r", "Rest Mode", G_CALLBACK (rest_toggle_key)}, + {"Default", NULL, N_("_Default"), "Escape", "Default Mode", + G_CALLBACK (default_mode)}, {"StaffMenu", NULL, N_("_Staff")}, {"AddBefore", NULL, N_("Add _Before Current Staff..."), NULL, NULL, G_CALLBACK (newstaffbefore)}, @@ -886,60 +886,13 @@ } /** - * callback changing mode gui->mode - * - */ -static void -change_mode (GtkRadioAction * action, GtkRadioAction * current, DenemoGUI * gui) { -gint val = gtk_radio_action_get_current_value (action); - switch(val) { -#define SET_MODE(m) (gui->mode=((gui->mode&MODE_MASK)|m)) - case RSM_OFF: - SET_MODE(RSM_OFF); - break; - case RSM_RHYTHM: - SET_MODE(RSM_RHYTHM); - break; - case RSM_OVERLAY: - SET_MODE(RSM_RHYTHM|RSM_OVERLAY); - break; -#undef SET_MODE - } - //g_print("Mode is %x for val=%x for %p %p other is %x\n", gui->mode, val, action, current, gtk_radio_action_get_current_value (current)); -} - - -/** - * callback changing type of entry, switches mode to Classic mode for entering rests and to Insert for entering notes. FIXME could switch to prefs value. + * Function to toggle entry of rhythms without pitches * */ static void -change_entry_type (GtkRadioAction * action, GtkRadioAction * current, DenemoGUI * gui) { - GtkAction *a; -gint val = gtk_radio_action_get_current_value (action); - switch(val) { -#define SET_MODE(m) (gui->mode=((gui->mode&ENTRY_TYPE_MASK)|m)) - case INPUTREST: - SET_MODE(INPUTREST); - a = gtk_ui_manager_get_action (gui->ui_manager, "/MainMenu/EntryMenu/Classic"); - gtk_action_activate(a); - break; - case INPUTNORMAL: - SET_MODE(INPUTNORMAL); - a = gtk_ui_manager_get_action (gui->ui_manager, "/MainMenu/EntryMenu/Replace"); - gtk_action_activate(a); - break; - case INPUTBLANK: - SET_MODE(INPUTBLANK); - a = gtk_ui_manager_get_action (gui->ui_manager, "/MainMenu/EntryMenu/Classic"); - gtk_action_activate(a); - break; - } -#undef SET_MODE - //g_print("Mode is %x masks %x %x\n",ENTRY_TYPE_MASK, MODE_MASK, gui->mode); +toggle_pitchless (GtkAction * dummy, DenemoGUI * gui) { + gui->si->rhythmicsubmode ^= RSM_OVERLAY; } - - /** * Function to toggle entry of notes by pitch recognition off/on * @@ -961,31 +914,27 @@ } } /* then turn on/off */ - if(gui->pitch_recognition) { stop_pitch_recognition(); } else { start_pitch_recognition(gui);// FIXME different guis - - } gui->pitch_recognition = !gui->pitch_recognition; /* always turn rhythm mode on with pitch recognition, since otherwise the cursor just bobs about uselessly, while the accidentals in the notes affect the previous note */ - GtkAction *mode = gtk_ui_manager_get_action (gui->ui_manager, gui->pitch_recognition?"/MainMenu/EntryMenu/Replace": "/MainMenu/EntryMenu/TogglePitchless"); - //g_print("PRIOR The %s action is %p is sen\n",gui->pitch_recognition?"/MainMenu/EntryMenu/Replace": "/MainMenu/EntryMenu/TogglePitchless", mode, gtk_action_get_sensitive(mode) ); - gtk_action_activate(mode); - // g_print("The %s action is %p \n",gui->pitch_recognition?"/MainMenu/EntryMenu/Replace": "/MainMenu/EntryMenu/TogglePitchless", mode); -mode = gtk_ui_manager_get_action (gui->ui_manager, "/MainMenu/EntryMenu/Note"); - gtk_action_activate(mode); - // g_print("Note action is %p is sensitive %x\n", mode, gtk_action_get_sensitive(mode)); + + GtkWidget *widget = gtk_ui_manager_get_widget (gui->ui_manager, "/MainMenu/EntryMenu/ToggleRhythmToolbar"); + GtkWidget *toolbar = gtk_ui_manager_get_widget (gui->ui_manager, "/RhythmToolBar"); + if (!GTK_WIDGET_VISIBLE (toolbar)) + g_signal_emit_by_name(widget, "activate", action, gui); + } /** * Function to toggle whether rhythm toolbar is visible - * switches keymap to Rhythm.keymaprc when toolbar is on back to standard when off. + * Sets the rhythmic submode, and turns off pitchless entry if it is being hidden. * */ static void @@ -994,27 +943,28 @@ static keymap *rhythm_keymap;// special keymap in rhythm submode GtkWidget *widget; widget = gtk_ui_manager_get_widget (gui->ui_manager, "/RhythmToolBar"); - // g_print("Callback for %s\n", g_type_name(G_TYPE_FROM_INSTANCE(widget))); 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; gtk_widget_hide (widget); } else { if(rhythm_keymap==NULL){ + rhythm_keymap = create_keymap ("Rhythm.keymaprc"); //printf("CREATED keymap\n"); } gui->prefs->the_keymap = rhythm_keymap; gtk_widget_show (widget); -#if 0 - GtkAction *mode = gtk_ui_manager_get_action (gui->ui_manager, "/MainMenu/EntryMenu/Replace"); -#else - GtkAction *mode = gtk_ui_manager_get_action (gui->ui_manager, "/MainMenu/EntryMenu/Note"); -#endif - gtk_action_activate(mode);//FIXME does not work + gui->si->rhythmicsubmode |= (RSM_RHYTHM); } } @@ -1025,39 +975,21 @@ {"ToggleNotationToolbar", NULL, N_("_Durations Toolbar"), NULL, N_("Enter single notes/rests of a given duration"), G_CALLBACK (toggle_notation_toolbar), FALSE} , - {"ToggleRhythmToolbar", NULL, N_("Rhythms & Overlays"), NULL, N_("Enter notes using a prevailing rhythm\nOverlay with pitches"), + {"ToggleRhythmToolbar", NULL, N_("_Rhythmic & Overlays"), NULL, N_("Enter notes using a prevailing rhythm\nOverlay with pitches"), G_CALLBACK (toggle_rhythm_toolbar), FALSE} , {"TogglePitchRecognition", NULL, N_("_Microphone"), NULL, N_("Enable pitch entry from microphone"), G_CALLBACK (toggle_pitch_recognition), FALSE} , {"ToggleArticulationPalette", NULL, N_("_Articulation Palette"), NULL, NULL, - G_CALLBACK (toggle_articulation_palette), FALSE}, - - {"ReadOnly", NULL, N_("Read Only"), NULL, "Make score read only", - G_CALLBACK (default_mode), FALSE} -}; - -/** - * Radio entries for the menus - */ -static GtkRadioActionEntry radio_menu_entries[] = { - {"Classic", NULL, N_("Classic"), NULL, "Denemo Classic note entry mode", - RSM_OFF}, - {"Replace", NULL, N_("Insert"), NULL, N_("Insert notes"), - RSM_RHYTHM}, - {"TogglePitchless", NULL, N_("Edit"), NULL, N_("Edit notes/Enter pure rhythms"), - RSM_OVERLAY} + 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} }; -static GtkRadioActionEntry type_menu_entries[] = { - {"Note", NULL, N_("Note"), NULL, N_("Normal Mode"), INPUTNORMAL}, - {"Rest", NULL, N_("Rest"), NULL, N_("Rest Mode"), INPUTREST}, - {"Blank", NULL, N_("Non printing rests"), NULL, N_("Ghost rests"), INPUTBLANK} -}; - struct cbdata { DenemoGUI *gui; @@ -1072,7 +1004,7 @@ openrecent (GtkWidget * widget, gpointer data) { struct cbdata *cdata = (struct cbdata *) data; - // g_print ("actioned\n"); + g_print ("actioned\n"); open_for_real (cdata->filename, cdata->gui); } @@ -1180,22 +1112,6 @@ toggle_menu_entries, G_N_ELEMENTS (toggle_menu_entries), gui); - gtk_action_group_add_radio_actions (action_group, - radio_menu_entries, - G_N_ELEMENTS (radio_menu_entries), - RSM_RHYTHM/* initial value */, - G_CALLBACK(change_mode), gui); - - - gtk_action_group_add_radio_actions (action_group, - type_menu_entries, - G_N_ELEMENTS (type_menu_entries), - INPUTNORMAL/* initial value */, - G_CALLBACK(change_entry_type), gui); - - - - ui_manager = gtk_ui_manager_new (); gui->ui_manager = ui_manager; gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); @@ -1231,7 +1147,7 @@ GTK_WIDGET_UNSET_FLAGS(toolbar, GTK_CAN_FOCUS); gtk_widget_show (toolbar); toolbar = gtk_ui_manager_get_widget (ui_manager, "/EntryToolBar"); - //g_print("EntryToolbar is %p\n", toolbar); + g_print("EntryToolbar is %p\n", toolbar); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, TRUE, 0); GTK_WIDGET_UNSET_FLAGS(toolbar, GTK_CAN_FOCUS); @@ -1314,37 +1230,24 @@ /* Now that the window's shown, initialize the gcs */ gcs_init (gui->window->window); + if (gui->prefs->articulation_palette) + toggle_articulation_palette (NULL, gui); + toggle_rhythm_toolbar (NULL, gui); + if (!gui->prefs->notation_palette) + { + g_print ("Notation palette %d\n", gui->prefs->notation_palette); + toggle_notation_toolbar (NULL, gui); + } /* Similarly, the keymap should be initialized after the only once si->window is shown, as it may pop up an advisory dialog. */ gui->prefs->standard_keymap = gui->prefs->the_keymap = init_keymap (); displays = g_list_append (displays, gui); - //g_print ("No of Displays %d\n", g_list_length (displays)); + g_print ("No of Displays %d\n", g_list_length (displays)); if (gui->prefs->autosave) g_timeout_add (gui->prefs->autosave_timeout * 1000 * 60, (GSourceFunc) auto_save_document_timeout, gui->si); - if (gui->prefs->articulation_palette) - toggle_articulation_palette (NULL, gui); - - /* we have to do this properly, because it introduces a keymap */ - if (gui->prefs->rhythm_palette) { - GtkWidget *widget = gtk_ui_manager_get_widget (gui->ui_manager, "/RhythmToolBar"); - if (GTK_WIDGET_VISIBLE (widget)) - g_print("hiding tool bar\n"), gtk_widget_hide(widget);// I do not understand why this is visible - there is no gtk_widget_show(all) in the hierarchy - widget = gtk_ui_manager_get_widget (gui->ui_manager, "/MainMenu/ViewMenu/ToggleRhythmToolbar"); - g_signal_emit_by_name(widget, "activate", NULL, gui); - g_print("type is %s\n", g_type_name(G_TYPE_FROM_INSTANCE(widget))); - } - // A cheap way of doing activating this toolbar, note it is called variously notation toolbar, duration toolbar and EntryToolBar FIXME - if (!gui->prefs->notation_palette) - { - //g_print ("Notation palette %d\n", gui->prefs->notation_palette); - toggle_notation_toolbar (NULL, gui); - } - g_print("Turning on the modes\n"); - - gui->mode = RSM_RHYTHM | INPUTNORMAL; g_free (error);