summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremiah Benham <jjbenham@chicagoguitar.com>2011-02-11 16:54:11 -0600
committerJeremiah Benham <jjbenham@chicagoguitar.com>2011-02-11 16:54:11 -0600
commit278d9355b2ab265794803d4dbab183db90ad534e (patch)
tree2b8f6ba3fd84097cc000dd49d02b39d19c760d28
parent151ed69ea596de66c9311c0160b7ff9d0304f247 (diff)
parent170d37f4f649c7077c4cca3e9b6eeaf5a2d325d4 (diff)
Merge branch 'master' of git.sv.gnu.org:/srv/git/denemo
-rw-r--r--actions/menus/MainMenu/PlaybackMenu/ConvertMidiForBass78
-rw-r--r--actions/menus/ObjectMenu/Directives/Tempo28
-rw-r--r--include/denemo/denemo_types.h10
-rw-r--r--src/file.c47
-rw-r--r--src/file.h2
-rw-r--r--src/print.c136
-rw-r--r--src/view.c62
-rw-r--r--src/view.h1
8 files changed, 206 insertions, 158 deletions
diff --git a/actions/menus/MainMenu/PlaybackMenu/ConvertMidiForBass b/actions/menus/MainMenu/PlaybackMenu/ConvertMidiForBass
index 08a63456..7e003cde 100644
--- a/actions/menus/MainMenu/PlaybackMenu/ConvertMidiForBass
+++ b/actions/menus/MainMenu/PlaybackMenu/ConvertMidiForBass
@@ -35,9 +35,10 @@
(vector-set! MidiNoteStarts note tick)
(loop note tick)
)))))
- (begin ;;;;;; finished processing the notes
+ (begin ;;;;;; finished generating Notes as a list of lists each with one note struct in it
(if (&gt; (length Notes) 0)
(let ()
+;;;;;;; we have at least one note in the Notes list, define to procs to create a denemo chord and add a note to it
(define (add-note note)
(if (note? note)
(begin
@@ -55,13 +56,13 @@
;(format #t "Create note ~a ~a\n" (d-GetNoteForMidiKey name) (duration::ticks-&gt;denemo base))
(eval-string (string-append "(d-Insert" (duration::ticks-&gt;denemo base)")"))
(d-PutNoteName (d-GetNoteForMidiKey name)))))))
+;;;;;;;;;;;;;; end of defining procs
-
+;;; notes has been set up by pre-pending so it is backwards...
(set! Notes (reverse Notes))
;;;;;; take the Notes and seek out bass notes, remove them and form chords, insert chords in staff above
- (let loop ()
-
+ (let () ;;;no loop here we drive it via the loopforbasskey
;;;;;;;;;;; overlap decides if two notes should be a chord
(define (overlap n1 n2)
(if (list? n1)
@@ -72,18 +73,10 @@
;(format #t "Number of notes ~a\n" index)
;;;;;;;Step through notes in current (bass) staff, placing chords in (empty) staff above
- (d-PushPosition)
- (if (None?)
- (begin
- (d-WarningDialog "Place cursor on first Bass note/rest/tuplet marker used in recording")
- (d-PopPosition))
- (if (and (d-MoveToStaffUp) (None?))
- (begin
- (d-PopPosition) ;;;back to bass staff, there is an empty staff for chords above
+
(let loopforbasskey ()
-
-
+;;;;;;;;;;;;; copy non-notes to the empty staff above and stop with the cursor on the first bass note
(let loop ()
;;;;first copy anything that are not a bass note to the staff above
(if (or (Rest?) (Tupletmarker?))
@@ -93,16 +86,19 @@
(if (and (not (Note?)) (d-NextObject))
(loop)))))
-
- (if (Note?) ;;;;;;;;;; find the bass note in the MIDI recording
+;;;;;;;;;;;;; cursor is on the first/next bass note (if any)
+ (if (Note?)
(let ((bass-key (d-GetNoteAsMidi)) (bass-duration (d-GetDurationInTicks))) ;;;midi number and duration of current note
- ;; now loop through notes looking for the same MIDI key number, which must be at start of recording, ie before ticks move on too much... for-each or map
+ ;; now loop through the Notes list looking for a note the same MIDI key number, which should be before ticks move on too much... once found, consecutive notes are taken to make a chord or chords for the bass note, an
(define notes-belonging '());the notes belonging to the bass note
(define bass-note #f);a bass note (list) selected from Notes
-
+
+;;;;;;;;;;;;;;;;;; three procs: make-chords takes a list which has each note in a separate list and puts all the (consecutive) ones that overlap into a single list, that is it turns a sequence of list-of-note into a list-of-notes which represents a chord. It returns the list.
+
(define (make-chords notes)
(disp "make-chords with " notes "\n")
(let loop ((index 0))
+ (disp "Now looping with index " index "and notes " notes "\n")
(let ((note1 (list-ref notes index))
(note2 #f))
(if (&gt; (length notes) (+ 1 index))
@@ -111,6 +107,7 @@
(if (overlap note1 (car note2))
(begin
(list-set! notes index (cons (car note2) note1))
+ (disp "notes is" notes "\nwe will delete " note2 "\n") ;;at this point note2 is in the chord and in the list
(set! notes (delq note2 notes)) ;;so we loop with same index
(disp "notes has become" notes "\n")
)
@@ -118,12 +115,12 @@
(loop index)))))
(disp "and so we return " notes "\n")
notes)
-
+;;;;;;; insert-chord takes a list of note structs and puts a chord in the staff above with those notes.
(define (insert-chord chord duration)
(insert-note (note.name (car chord)) duration)
(for-each add-note (cdr chord)))
- ;;;note bass-duration ignored at present.
+;;;;;;; insert-chords takes a list of lists of note structs and the duration of the denemo bass note they have been assigned to. It inserts a chord for each of the lists assigning durations to fit the bass note.
(define (insert-chords notes bass-duration)
(disp "insert-chords called with " notes "\n")
(let ((chords (make-chords notes)))
@@ -142,30 +139,36 @@
(loop (+ index 1)))
(begin
(if (= (length chords) 1)
- (insert-note (note.name (car (list-ref chords 0))) (note.duration (car (list-ref chords 0))))
+ (insert-chord (list-ref chords 0) bass-duration)
(d-WarningDialog "We have no chord")))))))
-
-
+;;;;;;;;;;;;;;;;;;;;;;;;; now the actual processing to loop through Notes finding an equivalent to bass-key and processing the notes belong. These are removed from Notes and then the outer loop to move on in the bass staff is taken.
+
+;;; first loop through Notes from the start (previous chords have been deleted) and seek the bass-note
(let loopgetbassnote ((index 0))
(disp "now index " index "bass-key " bass-key "\n")
(if (&gt; (length Notes) index)
(if (= bass-key (note.name (car (list-ref Notes index))))
(begin
-
+ (disp "started " index " with " Notes "\n")
(set! bass-note (list-ref Notes index))
- (delq bass-note Notes))
+ (set! Notes (delq bass-note Notes))
+ (disp "removed " bass-note "from Notes\n")
+ (disp "now " Notes "\n")
+ )
(loopgetbassnote (+ index 1)))))
-
- (if bass-note
- (begin ;;; get the notes for this bass note
+ ;;;; if bass-note then that note should have been removed from Notes, next get chord notes
+ (set! notes-belonging '())
+ (if bass-note
(let loop ((index 0))
- (define next-note (list-ref Notes index))
- (disp "next note is " next-note "\n")
+ (if (&gt; (length Notes) index)
+ (let ( (next-note (list-ref Notes index)))
+ (disp "next note is " next-note "\n should not be" (eq? next-note bass-note) "otherwise bass note is still there at " index "\n")
(if (overlap bass-note (car next-note))
(begin
(set! notes-belonging (cons* next-note notes-belonging))
- (delq next-note Notes)
- (loop (+ index 1)))))
+ (set! Notes (delq next-note Notes))
+ (loop index)))))))
+;;;;;;;;;;;;;;;;;;; finished creating notes-belonging, all these notes are now removed from Notes
(if (&gt; (length notes-belonging) 0)
@@ -178,25 +181,24 @@
(disp "insert-chords finished\n")
(d-PopPosition)
(if (d-NextObject)
- (loopforbasskey)
+ (loopforbasskey)
(d-WarningDialog "finished bass staff")))
(begin
(d-WarningDialog "found no notes for a bass-note")
- (disp "Bass note with no accompanying chord" bass-note))))))) ;;;if there is a note in the bass clef
+ (disp "Bass note with no accompanying chord" bass-note))));;;if there is a note in the bass clef
+
+ (d-WarningDialog "No more bass notes")))))
- (d-WarningDialog "No more bass notes")))
- (begin
- (d-WarningDialog "You must have an empty staff above"))))))
(begin
(d-WarningDialog "The Notes list is empty"))))))
(format #t "No notes found in recording\n")))
-
+(DenemoConvertFromBass)
;;;;;;;;;;;;;;;;;;;;;;;;</scheme>
<label>Convert MIDI chords over Bass</label>
<tooltip>Takes a MIDI recording over a bass line and inserts the chords by matching the bass notes. Each chord must include the bass note.</tooltip>
diff --git a/actions/menus/ObjectMenu/Directives/Tempo b/actions/menus/ObjectMenu/Directives/Tempo
index 9923bc27..ed79334c 100644
--- a/actions/menus/ObjectMenu/Directives/Tempo
+++ b/actions/menus/ObjectMenu/Directives/Tempo
@@ -71,9 +71,26 @@
);define GetBPM
;see if there's already one there:
-(if (Directive?)
- (if (equal? (d-DirectiveGetTag-standalone) "TempoMark" ) (set! replace #t ))
-)
+(if (d-Directive-standalone? "TempoMark")
+(let ((choice #f))
+ (begin
+ (set! replace 'edit)
+ (set! choice (d-GetOption (string-append "Change"stop"Delete" stop "Offset the Position" stop "Set Padding" stop cue-Advanced stop)))
+ (cond
+ ((boolean? choice)
+ (d-WarningDialog "Operation cancelled"))
+ ((equal? choice "Change")
+ (set! replace #t ))
+ ((equal? choice cue-Advanced)
+ (d-DirectiveTextEdit-standalone "TempoMark"))
+ ((equal? choice "Delete")
+ (d-DirectiveDelete-standalone "TempoMark"))
+ ((equal? choice "Offset the Position")
+ (ExtraOffset "TextScript" "standalone"))
+ ((equal? choice "Set Padding")
+ (SetPadding "TextScript" "standalone"))))))
+ ; (disp "we have replace as " replace "\n")
+(if (boolean? replace) (begin
;read in the text:
(set! TempoChoice (d-GetOption (string-append "Presto" stop "Vivace" stop "Allegro" stop
"Moderato" stop "Andante" stop "Adagio" stop "Largo" stop "Lento" stop "Tempo Adjust (ritardando, etc.)" stop
@@ -173,7 +190,10 @@
(d-MoveCursorRight)
)
)
-)</scheme>
+)
+))
+
+</scheme>
<label>Tempo</label>
<tooltip>Insert tempi and/or metronome marks, printed or not</tooltip>
</row>
diff --git a/include/denemo/denemo_types.h b/include/denemo/denemo_types.h
index 25c9d2be..89a57509 100644
--- a/include/denemo/denemo_types.h
+++ b/include/denemo/denemo_types.h
@@ -843,10 +843,7 @@ typedef struct DenemoGUI
gint rights[DENEMO_MAX_SYSTEMS];/**< an array to hold the rightmeasurenum of each system in the last-drawn score, used for determining the mouse position on the music */
gint scales[DENEMO_MAX_SYSTEMS];/**< an array to hold the percent horizontal scaling of each system in the last-drawn score, used for determining the mouse position on the music */
- GtkWidget *printarea;/**< area holding a print preview */
- GtkWidget *printvscrollbar;/**< scrollbar widget for printarea */
- GtkWidget *printhscrollbar;/**< scrollbar widget for printarea */
- GdkPixbuf *pixbuf;/**< print preview pixbuf */
+
GtkWidget *buttonboxes;/**< box for boxes showing directives */
GtkWidget *buttonbox;/**< box for buttons accessing DenemoDirectives attached to the whole score */
@@ -953,6 +950,11 @@ struct DenemoRoot
GtkWidget *vscrollbar;
GtkObject *hadjustment;
GtkWidget *hscrollbar;
+
+ GtkWidget *printarea;/**< area holding a print preview */
+ GtkWidget *printvscrollbar;/**< scrollbar widget for printarea */
+ GtkWidget *printhscrollbar;/**< scrollbar widget for printarea */
+ GdkPixbuf *pixbuf;/**< print preview pixbuf */
/* window state */
gint width;
gint height;
diff --git a/src/file.c b/src/file.c
index 009870df..09446b09 100644
--- a/src/file.c
+++ b/src/file.c
@@ -276,8 +276,8 @@ open_for_real (gchar * filename, DenemoGUI * gui, DenemoSaveType template, Impor
score_status(gui, TRUE);
} else
g_string_assign (gui->filename, "");
- if(gui->printarea)
- g_object_set_data(G_OBJECT(gui->printarea), "printviewupdate", (gpointer)G_MAXUINT);
+ if(Denemo.printarea)
+ g_object_set_data(G_OBJECT(Denemo.printarea), "printviewupdate", (gpointer)G_MAXUINT);
if(!xml)
updatescoreinfo (gui);
set_rightmeasurenum (gui->si);
@@ -338,27 +338,16 @@ denemo_warning (DenemoGUI * gui, gint format_id)
}
/*
- If the filename already has a denemo file name extension use
- it regardless of the value of format_id, otherwise add the
- file name extension
+ If the filename format already has the correct extension use
+ it. otherwise add the file name extension
*/
static gchar *
-create_filename (const gchar * file_name, gint *format_id)
+create_filename (const gchar * file_name, gint format_id)
{
- gint i;
-
- if (*format_id < 0)
- return (g_strdup (file_name));
-
- for (i = 0; i < (gint) G_N_ELEMENTS (supported_export_file_formats); i++)
- {
- if (g_pattern_match_simple (FORMAT_MASK (i), file_name))
- {
- *format_id = i;
- return (g_strdup (file_name));
- }
- }
- return (g_strconcat (file_name, FORMAT_EXTENSION (*format_id), NULL));
+ if (g_pattern_match_simple (FORMAT_MASK (format_id), file_name))
+ return (g_strdup (file_name));
+ else
+ return (g_strconcat (file_name, FORMAT_EXTENSION (format_id), NULL));
}
/* Save gui in the file in format format_id to the file filename (or gui->filename
@@ -436,7 +425,7 @@ filesel_save (DenemoGUI * gui, const gchar * file_name, gint format_id, DenemoSa
// Append file extension if needed
gchar *file = NULL;
gchar *basename = NULL;
- file = create_filename(file_name, &format_id);
+ file = create_filename(file_name, format_id);
g_debug("Saving to file %s\n", file);
if(!template && format_id==DENEMO_FORMAT) {
update_file_selection_path(file);
@@ -935,10 +924,16 @@ file_import_musicxml (DenemoGUI * gui, DenemoSaveType template, ImportType type,
* saved.
*/
void
-file_saveaswrapper (GtkAction * action, gpointer param)
+file_saveaswrapper (GtkAction * action, DenemoScriptParam *param)
{
+ GET_1PARAM(action, param, filename);
DenemoGUI *gui = Denemo.gui;
- file_saveas (gui, FALSE);
+ if(filename==NULL) {
+ file_saveas (gui, FALSE);
+ } else {
+ filesel_save (gui, filename, DENEMO_FORMAT, FALSE);
+ force_lily_refresh(gui);
+ }
}
/**
@@ -1139,8 +1134,8 @@ file_newwrapper (GtkAction * action, gpointer param)
}
//open_user_default_template(REPLACE_SCORE);
load_initdotdenemo();
- if(gui->printarea)
- g_object_set_data(G_OBJECT(gui->printarea), "printviewupdate", (gpointer)G_MAXUINT);
+ if(Denemo.printarea)
+ g_object_set_data(G_OBJECT(Denemo.printarea), "printviewupdate", (gpointer)G_MAXUINT);
}
/* open_user_default_template
@@ -1225,7 +1220,7 @@ replace_existing_file_dialog (const gchar * filename,
GtkWindow * parent_window, gint format_id)
{
- gchar *file = create_filename (filename, &format_id);
+ gchar *file = create_filename (filename, format_id);
if (!g_file_test (file, G_FILE_TEST_EXISTS))
{
g_free (file);
diff --git a/src/file.h b/src/file.h
index b87ef962..fddea2dc 100644
--- a/src/file.h
+++ b/src/file.h
@@ -56,7 +56,7 @@ void
file_savewrapper (GtkAction *action, gpointer param);
void
-file_saveaswrapper (GtkAction *action, gpointer param);
+file_saveaswrapper (GtkAction *action, DenemoScriptParam *param);
void
file_newwrapper (GtkAction *action, gpointer param);
diff --git a/src/print.c b/src/print.c
index eea396b3..e83859e3 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1,4 +1,4 @@
-/* print.c
+/* Print.c
*
* printing support for GNU Denemo
* outputs to a pdf or png file
@@ -919,32 +919,32 @@ printall(void) {
static void draw_print(DenemoGUI *gui) {
gint x, y;
- GtkAdjustment * adjust = gtk_range_get_adjustment(GTK_RANGE(gui->printhscrollbar));
+ GtkAdjustment * adjust = gtk_range_get_adjustment(GTK_RANGE(Denemo.printhscrollbar));
x = (gint)adjust->value;
- adjust = gtk_range_get_adjustment(GTK_RANGE(gui->printvscrollbar));
+ adjust = gtk_range_get_adjustment(GTK_RANGE(Denemo.printvscrollbar));
y = (gint)adjust->value;
gint width, height;
- width = gdk_pixbuf_get_width( GDK_PIXBUF(gui->pixbuf)) - x;
- height = gdk_pixbuf_get_height( GDK_PIXBUF(gui->pixbuf)) - y;
+ width = gdk_pixbuf_get_width( GDK_PIXBUF(Denemo.pixbuf)) - x;
+ height = gdk_pixbuf_get_height( GDK_PIXBUF(Denemo.pixbuf)) - y;
- gdk_draw_pixbuf(gui->printarea->window, NULL, GDK_PIXBUF(gui->pixbuf),
+ gdk_draw_pixbuf(Denemo.printarea->window, NULL, GDK_PIXBUF(Denemo.pixbuf),
x,y,0,0,/* x, y in pixbuf, x,y in window */
width, height, GDK_RGB_DITHER_NONE,0,0);
if(selecting)
{gint w = ABS(markx-curx);
gint h = ABS(marky-cury);
- gdk_draw_rectangle (Denemo.gui->printarea->window,
+ gdk_draw_rectangle (Denemo.printarea->window,
gcs_bluegc(), FALSE,markx, marky, w, h);
}
if(offsetting)
{
gint w = pointx-markx;
gint h = pointy-marky;
- gdk_draw_rectangle (Denemo.gui->printarea->window,
+ gdk_draw_rectangle (Denemo.printarea->window,
gcs_graygc(), TRUE, markx, marky, w, h);
- gdk_draw_pixbuf(gui->printarea->window, NULL, GDK_PIXBUF(gui->pixbuf),
+ gdk_draw_pixbuf(Denemo.printarea->window, NULL, GDK_PIXBUF(Denemo.pixbuf),
markx+x, marky+y, curx, cury,/* x, y in pixbuf, x,y in window */
w, h, GDK_RGB_DITHER_NONE,0,0);
@@ -956,9 +956,9 @@ static void draw_print(DenemoGUI *gui) {
gint w = pointx-markx;
gint h = pointy-marky;
- gdk_draw_rectangle (Denemo.gui->printarea->window,
+ gdk_draw_rectangle (Denemo.printarea->window,
gcs_graygc(), TRUE, markx-pad/2, marky-pad/2, w+pad, h+pad);
- gdk_draw_pixbuf(gui->printarea->window, NULL, GDK_PIXBUF(gui->pixbuf),
+ gdk_draw_pixbuf(Denemo.printarea->window, NULL, GDK_PIXBUF(Denemo.pixbuf),
markx+x, marky+y, markx, marky,/* x, y in pixbuf, x,y in window */
w, h, GDK_RGB_DITHER_NONE,0,0);
@@ -970,10 +970,10 @@ static void draw_print(DenemoGUI *gui) {
static GdkCursor *busycursor;
static GdkCursor *arrowcursor;
static void busy_cursor(void) {
- gdk_window_set_cursor(Denemo.gui->printarea->window, busycursor);
+ gdk_window_set_cursor(Denemo.printarea->window, busycursor);
}
static void normal_cursor(void) {
- gdk_window_set_cursor(Denemo.gui->printarea->window, arrowcursor);
+ gdk_window_set_cursor(Denemo.printarea->window, arrowcursor);
}
static void
@@ -1002,24 +1002,24 @@ printview_finished(GPid pid, gint status, gboolean preview_only) {
process_printpreview_errors();
gchar *filename = get_printfile_pathbasename();
gchar *path = g_strconcat (filename, "_.png", NULL);
- if(gui->pixbuf)
- g_object_unref(gui->pixbuf);
- gui->pixbuf = gdk_pixbuf_new_from_file (path, &error);
+ if(Denemo.pixbuf)
+ g_object_unref(Denemo.pixbuf);
+ Denemo.pixbuf = gdk_pixbuf_new_from_file (path, &error);
if(error != NULL)
{
g_warning (_("Could not load the print preview:\n%s\n"),
error->message);
g_error_free (error);
error = NULL;
- gui->pixbuf = NULL;
+ Denemo.pixbuf = NULL;
} else {
gboolean ret;
//FIXME the parameters here are placed by trial and error - the docs indicate &ret should come at the end
//but an error message results.
- g_signal_emit_by_name(gui->printarea, "configure_event", NULL, &ret, NULL);
+ g_signal_emit_by_name(Denemo.printarea, "configure_event", NULL, &ret, NULL);
}
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "printviewupdate", (gpointer) changecount);
- gtk_widget_queue_draw (gui->printarea);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "printviewupdate", (gpointer) changecount);
+ gtk_widget_queue_draw (Denemo.printarea);
if(!preview_only)
printall();
@@ -1029,7 +1029,7 @@ void refresh_print_view (gboolean preview_only) {
DenemoGUI *gui = Denemo.gui;
GError *error = NULL;
//g_print("preview only %d\n", preview_only);
- if((changecount == Denemo.gui->changecount) && ((gint)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "printviewupdate")==Denemo.gui->changecount)) {
+ if((changecount == Denemo.gui->changecount) && ((gint)g_object_get_data(G_OBJECT(Denemo.printarea), "printviewupdate")==Denemo.gui->changecount)) {
if(confirm ("No changes since last update", "Cancel refresh of print view?"))
return;
}
@@ -1052,7 +1052,7 @@ void refresh_print_view (gboolean preview_only) {
g_remove (path);
gui->si->markstaffnum=0;//remove selection, as exportlilypond respects it - FIXME??
exportlilypond (lilyfile, gui, TRUE);
- convert_ly(lilyfile);
+ // gives an error ??? convert_ly(lilyfile);
gchar *printfile = g_strconcat (filename, "_", NULL);
gchar *resolution = "-dresolution=180";
@@ -1184,8 +1184,8 @@ printall_cb (GtkAction *action, gpointer param) {
gchar *str = g_strdup_printf("Direct printing is experimental - use print preview otherwise after setting pdf viewer in prefs (currently %s).", Denemo.prefs.pdfviewer->str);
warningdialog(str);
g_free(str);
- //g_print("changecount %d %d %d \n", changecount, Denemo.gui->changecount, (gint)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "printviewupdate"));
- if((changecount == Denemo.gui->changecount) && ((gint)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "printviewupdate")==Denemo.gui->changecount))
+ //g_print("changecount %d %d %d \n", changecount, Denemo.gui->changecount, (gint)g_object_get_data(G_OBJECT(Denemo.printarea), "printviewupdate"));
+ if((changecount == Denemo.gui->changecount) && ((gint)g_object_get_data(G_OBJECT(Denemo.printarea), "printviewupdate")==Denemo.gui->changecount))
printall();
else
refresh_print_view(FALSE);//calls printall when lilypond has finished.
@@ -1228,22 +1228,25 @@ gint
printarea_configure_event (GtkWidget * widget, GdkEventConfigure * event)
{
DenemoGUI *gui = Denemo.gui;
- if(gui->pixbuf==NULL)
- return FALSE;
+ if(Denemo.pixbuf==NULL)
+ refresh_print_view(TRUE);
+ if(Denemo.pixbuf==NULL)
+ return TRUE;
gint width, height;
- gdk_drawable_get_size (gui->printarea->window, &width, &height);
- GtkAdjustment * vadjust = gtk_range_get_adjustment(GTK_RANGE(gui->printvscrollbar));
+ gdk_drawable_get_size (Denemo.printarea->window, &width, &height);
+ GtkAdjustment * vadjust = gtk_range_get_adjustment(GTK_RANGE(Denemo.printvscrollbar));
vadjust->lower = vadjust->value = 0.0;
- vadjust->upper = (gdouble)gdk_pixbuf_get_height(gui->pixbuf);
+ vadjust->upper = (gdouble)gdk_pixbuf_get_height(Denemo.pixbuf);
vadjust->page_size = (gdouble)height;
- GtkAdjustment * hadjust = gtk_range_get_adjustment(GTK_RANGE(gui->printhscrollbar));
+ GtkAdjustment * hadjust = gtk_range_get_adjustment(GTK_RANGE(Denemo.printhscrollbar));
hadjust->lower = hadjust->value = 0.0;
- hadjust->upper = (gdouble)gdk_pixbuf_get_width(gui->pixbuf);
+ hadjust->upper = (gdouble)gdk_pixbuf_get_width(Denemo.pixbuf);
hadjust->page_size = (gdouble)width;
gtk_adjustment_changed(vadjust);
gtk_adjustment_changed(hadjust);
+
return TRUE;
}
@@ -1257,7 +1260,7 @@ printvertical_scroll (GtkAdjustment * adjust)
DenemoGUI *gui = Denemo.gui;
// g_print("vertical %d to %d\n", (int)adjust->value, (int)(adjust->value+adjust->page_size));
adjust_y=(int)adjust->value;
- gtk_widget_queue_draw (gui->printarea);
+ gtk_widget_queue_draw (Denemo.printarea);
}
static void
@@ -1266,14 +1269,14 @@ printhorizontal_scroll (GtkAdjustment * adjust)
DenemoGUI *gui = Denemo.gui;
// g_print("horizontal %d to %d\n", (int)adjust->value, (int)(adjust->value+adjust->page_size));
adjust_x=(int)adjust->value;
-gtk_widget_queue_draw (gui->printarea);
+gtk_widget_queue_draw (Denemo.printarea);
}
static gint
printarea_expose_event (GtkWidget * widget, GdkEventExpose * event)
{
DenemoGUI *gui = Denemo.gui;
- if(gui->pixbuf==NULL)
+ if(Denemo.pixbuf==NULL)
return TRUE;
draw_print(gui);
return TRUE;
@@ -1288,12 +1291,12 @@ printarea_expose_event (GtkWidget * widget, GdkEventExpose * event)
gint
printarea_motion_notify (GtkWidget * widget, GdkEventButton * event)
{
- if(Denemo.gui->pixbuf==NULL)
+ if(Denemo.pixbuf==NULL)
return TRUE;
if(padding || offsetting || selecting) {
curx = (int)event->x;
cury = (int)event->y;
- gtk_widget_queue_draw (Denemo.gui->printarea);
+ gtk_widget_queue_draw (Denemo.printarea);
}
return TRUE;
@@ -1328,7 +1331,7 @@ gint
printarea_button_press (GtkWidget * widget, GdkEventButton * event)
{
gboolean left = (event->button != 3);
- if((!left) || (Denemo.gui->pixbuf==NULL)) {
+ if((!left) || (Denemo.pixbuf==NULL)) {
popup_print_preview_menu();
return TRUE;
}
@@ -1337,9 +1340,9 @@ printarea_button_press (GtkWidget * widget, GdkEventButton * event)
offsetx = curx - markx;
offsety = cury - marky;
- GtkWidget *thedialog = g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offset-dialog");
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "offsetx", (gpointer)offsetx);
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "offsety", (gpointer)offsety);
+ GtkWidget *thedialog = g_object_get_data(G_OBJECT(Denemo.printarea), "offset-dialog");
+ g_object_set_data(G_OBJECT(Denemo.printarea), "offsetx", (gpointer)offsetx);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "offsety", (gpointer)offsety);
if(thedialog){
gtk_dialog_response(GTK_DIALOG(thedialog), 1/*DRAGGED*/);
} else {
@@ -1354,8 +1357,8 @@ printarea_button_press (GtkWidget * widget, GdkEventButton * event)
if(padding) {
gint pad = ABS(curx - markx);
- GtkWidget *thedialog = g_object_get_data(G_OBJECT(Denemo.gui->printarea), "pad-dialog");
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "padding", (gpointer)pad);
+ GtkWidget *thedialog = g_object_get_data(G_OBJECT(Denemo.printarea), "pad-dialog");
+ g_object_set_data(G_OBJECT(Denemo.printarea), "padding", (gpointer)pad);
if(thedialog){
gtk_dialog_response(GTK_DIALOG(thedialog), 1/*DRAGGED*/);
} else {
@@ -1373,7 +1376,7 @@ printarea_button_press (GtkWidget * widget, GdkEventButton * event)
// return TRUE;
// } else
selecting = TRUE;
- if(Denemo.gui->pixbuf==NULL)
+ if(Denemo.pixbuf==NULL)
return TRUE;
pointx = markx=event->x;
pointy = marky=event->y;
@@ -1390,7 +1393,7 @@ printarea_button_release (GtkWidget * widget, GdkEventButton * event)
if(!left) {
return TRUE;
}
- if(Denemo.gui->pixbuf==NULL)
+ if(Denemo.pixbuf==NULL)
return TRUE;
if(selecting) {
pointx=event->x;
@@ -1401,7 +1404,9 @@ printarea_button_release (GtkWidget * widget, GdkEventButton * event)
width = pointx-markx;
height = pointy-marky;
GtkIconFactory *icon_factory = gtk_icon_factory_new ();
- GdkPixbuf *sub_pixbuf = gdk_pixbuf_new_subpixbuf (Denemo.gui->pixbuf, markx+adjust_x, marky+adjust_y, width, height);
+ if(marky+adjust_y<0 || (marky+adjust_y + height > gdk_pixbuf_get_height(Denemo.pixbuf)))
+ return TRUE;
+ GdkPixbuf *sub_pixbuf = gdk_pixbuf_new_subpixbuf (Denemo.pixbuf, markx+adjust_x, marky+adjust_y, width, height);
GdkPixbuf *alphapixbuf = gdk_pixbuf_add_alpha (sub_pixbuf, TRUE, 255, 255, 255);
GdkPixbuf *scaledpixbuf = gdk_pixbuf_scale_simple(alphapixbuf, width, height,GDK_INTERP_BILINEAR);
@@ -1428,41 +1433,56 @@ printarea_button_release (GtkWidget * widget, GdkEventButton * event)
}
void install_printpreview(DenemoGUI *gui, GtkWidget *top_vbox){
+ if(Denemo.printarea)
+ return;
busycursor = gdk_cursor_new(GDK_WATCH);
arrowcursor = gdk_cursor_new(GDK_RIGHT_PTR);//FIXME what is the system cursor called??
+
GtkWidget *main_vbox = gtk_vbox_new (FALSE, 1);
+#if 1
+ top_vbox = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(top_vbox, "Denemo Print View");
+ gtk_widget_set_size_request(GTK_WIDGET(top_vbox), 1200, 600);
+ g_signal_connect (G_OBJECT (top_vbox), "delete-event",
+ G_CALLBACK (hide_printarea_on_delete), NULL);
+ gtk_container_add (GTK_CONTAINER (top_vbox), main_vbox);
+
+
+#else
gtk_box_pack_start (GTK_BOX (top_vbox), main_vbox, TRUE, TRUE,
0);
+
+#endif
GtkWidget *score_and_scroll_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), score_and_scroll_hbox, TRUE, TRUE,
0);
- gui->printarea = gtk_drawing_area_new ();
- gtk_box_pack_start (GTK_BOX (score_and_scroll_hbox), gui->printarea, TRUE,
+ Denemo.printarea = gtk_drawing_area_new ();
+ gtk_box_pack_start (GTK_BOX (score_and_scroll_hbox), Denemo.printarea, TRUE,
TRUE, 0);
GtkAdjustment *printvadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 1.0, 2.0, 1.0, 4.0, 1.0));
g_signal_connect (G_OBJECT (printvadjustment), "value_changed",
G_CALLBACK (printvertical_scroll), gui);
- gui->printvscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (printvadjustment));
- gtk_box_pack_start (GTK_BOX (score_and_scroll_hbox), gui->printvscrollbar, FALSE,
+ Denemo.printvscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (printvadjustment));
+ gtk_box_pack_start (GTK_BOX (score_and_scroll_hbox), Denemo.printvscrollbar, FALSE,
TRUE, 0);
GtkAdjustment *printhadjustment = GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 1.0, 2.0, 1.0, 4.0, 1.0));
g_signal_connect (G_OBJECT (printhadjustment), "value_changed",
G_CALLBACK (printhorizontal_scroll), gui);
- gui->printhscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (printhadjustment));
- gtk_box_pack_start (GTK_BOX (main_vbox), gui->printhscrollbar, FALSE, TRUE, 0);
+ Denemo.printhscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (printhadjustment));
+ gtk_box_pack_start (GTK_BOX (main_vbox), Denemo.printhscrollbar, FALSE, TRUE, 0);
- g_signal_connect (G_OBJECT (gui->printarea), "configure_event",
+ g_signal_connect (G_OBJECT (Denemo.printarea), "configure_event",
G_CALLBACK (printarea_configure_event), gui);
- g_signal_connect (G_OBJECT (gui->printarea), "expose_event",
+ g_signal_connect (G_OBJECT (Denemo.printarea), "expose_event",
G_CALLBACK (printarea_expose_event), gui);
- g_signal_connect (G_OBJECT (gui->printarea), "button_release_event",
+ g_signal_connect (G_OBJECT (Denemo.printarea), "button_release_event",
G_CALLBACK (printarea_button_release), gui);
- g_signal_connect (G_OBJECT (gui->printarea), "motion_notify_event",
+ g_signal_connect (G_OBJECT (Denemo.printarea), "motion_notify_event",
G_CALLBACK (printarea_motion_notify), gui);
- g_signal_connect (G_OBJECT (gui->printarea), "button_press_event",
+ g_signal_connect (G_OBJECT (Denemo.printarea), "button_press_event",
G_CALLBACK (printarea_button_press), gui);
- gtk_widget_add_events (gui->printarea, (GDK_EXPOSURE_MASK
+ gtk_widget_add_events (Denemo.printarea, (GDK_EXPOSURE_MASK
| GDK_POINTER_MOTION_MASK
/* | GDK_LEAVE_NOTIFY_MASK */
| GDK_BUTTON_PRESS_MASK
@@ -1470,7 +1490,7 @@ void install_printpreview(DenemoGUI *gui, GtkWidget *top_vbox){
gtk_widget_show_all(main_vbox);
- gtk_widget_hide(main_vbox);
+ gtk_widget_hide(top_vbox);
}
diff --git a/src/view.c b/src/view.c
index 30efb0a3..9af67a6b 100644
--- a/src/view.c
+++ b/src/view.c
@@ -506,6 +506,11 @@ toggle_print_view (GtkAction *action, gpointer param);
static void
toggle_scoretitles (GtkAction *action, gpointer param);
+
+gint hide_printarea_on_delete(void) {
+ activate_action("/MainMenu/ViewMenu/"TogglePrintView_STRING);
+ return TRUE;
+}
static void
toggle_page_view(void) {
@@ -597,7 +602,7 @@ void toggle_to_drawing_area(gboolean show) {
TOG2("/MainMenu", mainmenu);
TOG3(gtk_widget_get_parent(Denemo.console), console_view, "/MainMenu/ViewMenu/"ToggleConsoleView_STRING);
- TOG3(gtk_widget_get_parent(gtk_widget_get_parent(Denemo.gui->printarea)), print_view, "/MainMenu/ViewMenu/"TogglePrintView_STRING);
+ TOG3(gtk_widget_get_parent(gtk_widget_get_parent(Denemo.printarea)), print_view, "/MainMenu/ViewMenu/"TogglePrintView_STRING);
TOG3(Denemo.gui->buttonboxes, scoretitles, "/MainMenu/ViewMenu/"ToggleScoreTitles_STRING);
TOG3(Denemo.playback_control, playback_control, "/MainMenu/ViewMenu/"TogglePlaybackControls_STRING);
TOG3(Denemo.midi_in_control, midi_in_control, "/MainMenu/ViewMenu/"ToggleMidiInControls_STRING);
@@ -1780,8 +1785,8 @@ static void get_drag_offset(GtkWidget *dialog, gint response_id, GtkLabel *label
if(response_id < 0)
gtk_main_quit();
gint offsetx, offsety;
- offsetx = (intptr_t)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offsetx");
- offsety = (intptr_t)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offsety");
+ offsetx = (intptr_t)g_object_get_data(G_OBJECT(Denemo.printarea), "offsetx");
+ offsety = (intptr_t)g_object_get_data(G_OBJECT(Denemo.printarea), "offsety");
gchar *text = g_strdup_printf("Offset now %d %d. Drag again in the print window to change\nOr click OK to apply the position shift", offsetx, offsety);
gtk_label_set_text(label, text);
g_free(text);
@@ -1792,7 +1797,7 @@ static void get_drag_pad(GtkWidget *dialog, gint response_id, GtkLabel *label) {
if(response_id < 0)
gtk_main_quit();
gint padding;
- padding = (intptr_t)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "padding");
+ padding = (intptr_t)g_object_get_data(G_OBJECT(Denemo.printarea), "padding");
gchar *text = g_strdup_printf("Padding now %d. Drag again in the print window to change\nOr click OK to apply the padding to the graphical object belonging to the directive", padding);
gtk_label_set_text(label, text);
g_free(text);
@@ -1804,14 +1809,14 @@ static void get_drag_pad(GtkWidget *dialog, gint response_id, GtkLabel *label) {
or #f if no printarea or user cancels*/
SCM scheme_get_offset(void) {
SCM x, y, ret;
- if(Denemo.gui->printarea==NULL)
+ if(Denemo.printarea==NULL)
return SCM_BOOL(FALSE);
- if(g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offset-dialog")){
+ if(g_object_get_data(G_OBJECT(Denemo.printarea), "offset-dialog")){
warningdialog("Already in a padding dialog");
return SCM_BOOL_F;
}
- gint offsetx = (intptr_t)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offsetx");
- gint offsety = (intptr_t)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offsety");
+ gint offsetx = (intptr_t)g_object_get_data(G_OBJECT(Denemo.printarea), "offsetx");
+ gint offsety = (intptr_t)g_object_get_data(G_OBJECT(Denemo.printarea), "offsety");
GtkWidget *dialog = gtk_dialog_new_with_buttons ("Select Offset in Print Window",
@@ -1820,7 +1825,7 @@ SCM scheme_get_offset(void) {
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
NULL);
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "offset-dialog", (gpointer)dialog);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "offset-dialog", (gpointer)dialog);
GtkWidget *vbox = gtk_vbox_new(FALSE, 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
TRUE, TRUE, 0);
@@ -1835,10 +1840,10 @@ SCM scheme_get_offset(void) {
g_signal_connect(dialog, "response", G_CALLBACK(get_drag_offset), label);
gtk_widget_show_all(dialog);
gtk_main();
- offsetx = (intptr_t) g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offsetx");
- offsety = (intptr_t) g_object_get_data(G_OBJECT(Denemo.gui->printarea), "offsety");
+ offsetx = (intptr_t) g_object_get_data(G_OBJECT(Denemo.printarea), "offsetx");
+ offsety = (intptr_t) g_object_get_data(G_OBJECT(Denemo.printarea), "offsety");
val = (intptr_t)g_object_get_data(G_OBJECT(dialog), "offset-response");
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "offset-dialog", NULL);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "offset-dialog", NULL);
gtk_widget_destroy(dialog);
if(val == GTK_RESPONSE_ACCEPT) {
x= scm_makfrom0str (g_strdup_printf("%.1f", offsetx/10.0));
@@ -1851,9 +1856,9 @@ SCM scheme_get_offset(void) {
/* return a string representing the relative font size the user wishes to use*/
SCM scheme_get_relative_font_size(void) {
- if(Denemo.gui->printarea==NULL)
+ if(Denemo.printarea==NULL)
return SCM_BOOL(FALSE);
- gchar *value = g_object_get_data(G_OBJECT(Denemo.gui->printarea), "font-size");
+ gchar *value = g_object_get_data(G_OBJECT(Denemo.printarea), "font-size");
if(value)
g_free(value);
value = string_dialog_entry (Denemo.gui, "Font Size", "Give a value (+/-) to adjust font size by", "0");
@@ -1861,7 +1866,7 @@ SCM scheme_get_relative_font_size(void) {
value = g_strdup("0");
gchar *clean = g_strdup_printf("%d", atoi(value));
g_free(value);
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "font-size", (gpointer)clean);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "font-size", (gpointer)clean);
return scm_from_locale_stringn (clean, strlen(clean));
}
void get_clipboard(GtkAction * action, DenemoScriptParam *param);
@@ -1888,14 +1893,14 @@ SCM scheme_get_text_selection (void) {
or #f if no printarea or user cancels*/
SCM scheme_get_padding(void) {
SCM pad, ret;
- if(Denemo.gui->printarea==NULL)
+ if(Denemo.printarea==NULL)
return SCM_BOOL(FALSE);
- if(g_object_get_data(G_OBJECT(Denemo.gui->printarea), "pad-dialog")){
+ if(g_object_get_data(G_OBJECT(Denemo.printarea), "pad-dialog")){
warningdialog("Already in a padding dialog");
return SCM_BOOL_F;
}
- gint padding = (intptr_t)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "padding");
+ gint padding = (intptr_t)g_object_get_data(G_OBJECT(Denemo.printarea), "padding");
GtkWidget *dialog = gtk_dialog_new_with_buttons ("Select Padding in Print Window",
GTK_WINDOW (Denemo.window),
@@ -1903,7 +1908,7 @@ SCM scheme_get_padding(void) {
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
NULL);
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "pad-dialog", (gpointer)dialog);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "pad-dialog", (gpointer)dialog);
GtkWidget *vbox = gtk_vbox_new(FALSE, 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
TRUE, TRUE, 0);
@@ -1918,9 +1923,9 @@ SCM scheme_get_padding(void) {
g_signal_connect(dialog, "response", G_CALLBACK(get_drag_pad), label);
gtk_widget_show_all(dialog);
gtk_main();
- padding = (intptr_t) g_object_get_data(G_OBJECT(Denemo.gui->printarea), "padding");
+ padding = (intptr_t) g_object_get_data(G_OBJECT(Denemo.printarea), "padding");
val = (intptr_t)g_object_get_data(G_OBJECT(dialog), "pad-response");
- g_object_set_data(G_OBJECT(Denemo.gui->printarea), "pad-dialog", NULL);
+ g_object_set_data(G_OBJECT(Denemo.printarea), "pad-dialog", NULL);
gtk_widget_destroy(dialog);
if(val == GTK_RESPONSE_ACCEPT) {
ret = scm_makfrom0str (g_strdup_printf("%d", padding/10));
@@ -7299,12 +7304,12 @@ toggle_action_menu (GtkAction * action, gpointer param)
static void
toggle_print_view (GtkAction *action, gpointer param)
{
- GtkWidget *w = gtk_widget_get_parent(gtk_widget_get_parent(Denemo.gui->printarea));
+ GtkWidget *w = gtk_widget_get_toplevel(Denemo.printarea);
if((!action) || GTK_WIDGET_VISIBLE(w))
gtk_widget_hide(w);
else {
gtk_widget_show(w);
- if(((gint)g_object_get_data(G_OBJECT(Denemo.gui->printarea), "printviewupdate"))<Denemo.gui->changecount)
+ if(((gint)g_object_get_data(G_OBJECT(Denemo.printarea), "printviewupdate"))<Denemo.gui->changecount)
refresh_print_view(TRUE);
}
return;
@@ -8101,8 +8106,11 @@ get_data_dir (),
{
Denemo.scorearea = gtk_drawing_area_new ();
+ GtkWidget *scorearea_topbox = gtk_vbox_new(FALSE, 1);
+ gtk_box_pack_start (GTK_BOX (main_vbox), scorearea_topbox, TRUE, TRUE,
+ 0);
GtkWidget *score_and_scroll_hbox = gtk_hbox_new (FALSE, 1);
- gtk_box_pack_start (GTK_BOX (main_vbox), score_and_scroll_hbox, TRUE, TRUE,
+ gtk_box_pack_start (GTK_BOX (scorearea_topbox), score_and_scroll_hbox, TRUE, TRUE,
0);
gtk_widget_show (score_and_scroll_hbox);
@@ -8150,8 +8158,8 @@ get_data_dir (),
gtk_signal_connect (GTK_OBJECT (Denemo.hadjustment), "value_changed",
GTK_SIGNAL_FUNC (horizontal_scroll), NULL);
Denemo.hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (Denemo.hadjustment));
- gtk_box_pack_start (GTK_BOX (main_vbox), Denemo.hscrollbar, FALSE, TRUE, 0);
- gtk_widget_show (Denemo.hscrollbar);
+ gtk_box_pack_start (GTK_BOX (scorearea_topbox), Denemo.hscrollbar, FALSE, TRUE, 0);
+ gtk_widget_show_all (scorearea_topbox);
}
@@ -8293,7 +8301,7 @@ newtab (GtkAction *action, gpointer param) {
#endif
- install_printpreview(gui, top_vbox);
+ install_printpreview(gui, main_vbox);
//FIXME populate_opened_recent (gui);
diff --git a/src/view.h b/src/view.h
index 1cd5b4ee..c9b23dc3 100644
--- a/src/view.h
+++ b/src/view.h
@@ -116,4 +116,5 @@ void ToggleReduceToDrawingArea (GtkAction * action, DenemoScriptParam *param);
gchar *get_midi_control_command(guchar type, guchar value);
gchar *get_midi_pitch_bend_command(gint value);
void load_initdotdenemo(void);
+gint hide_printarea_on_delete(void);
#endif