nted-1.10.18/ 0000775 0010410 0000764 00000000000 11520270234 007610 5 0000000 0000000 nted-1.10.18/page.cpp 0000664 0010410 0000764 00000145013 11520267230 011156 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include
#include
#include "page.h"
#include "system.h"
#include "mainwindow.h"
#include "clipboard.h"
#include "staff.h"
#include "deletesystemcommand.h"
#include "appendsystemcommand.h"
#include "movesystemcommand.h"
#include "removepagecommand.h"
#include "insertfreeplaceablecommand.h"
#include "getsystemfromnextpagecmmand.h"
#include "commandhistory.h"
#include "commandlist.h"
#include "chordorrest.h"
#include "volumesign.h"
#include "temposign.h"
#include "scoreinfodialog.h"
#include "slurpoint.h"
#include "slur.h"
#include "linepoint.h"
#include "crescendo.h"
#include "linesdialog.h"
#include "octavation.h"
#include "acceleration.h"
#include "freesign.h"
#include "freechord.h"
#include "freespacer.h"
#include "pangocairotext.h"
#include "freechordname.h"
#define X_POS_INVERS(p) ((leftx + (p) / current_scale) / zoom_factor - m_xpos)
#define Y_POS_INVERS(p) ((topy + (p) / current_scale) / zoom_factor)
#define X_POS_INVERS_PAGE_REL(p) (((leftx + (p) / current_scale) / zoom_factor - getContentXpos()))
#define X_POS(p) (((p) + m_xpos) * zoom_factor - leftx)
#define Y_POS(p) ((p) * zoom_factor - topy)
#define X_POS_PAGE_REL(p) (((p) + getContentXpos()) * zoom_factor - leftx)
#define DEFAULT_SYSTEM_DIST (2 * 5 * LINE_DIST)
NedPage::NedPage(NedMainWindow *main_window, double width, double height, int nr, unsigned int start_measure_number, bool start) :
m_systems(NULL), m_xpos(nr * (width + DEFAULT_BORDER)),
m_width(width), m_height(height), default_border(DEFAULT_BORDER), m_page_number(nr), m_main_window(main_window)
{
int i;
double system_pos = TOP_BOTTOM_BORDER;
NedSystem *system;
if (start) {
i = 0;
m_system_diff = 100.0;
m_systems = g_list_append(m_systems, system = new NedSystem(this, system_pos,
m_width - 2 * (LEFT_RIGHT_BORDER - DEFAULT_BORDER), i, start_measure_number, TRUE));
placeStaffs(0);
/*
do {
m_systems = g_list_append(m_systems, system = new NedSystem(this, system_pos,
m_width - 2 * (LEFT_RIGHT_BORDER - DEFAULT_BORDER), i, start_measure_number, TRUE));
system_pos += system->getHeight() + DEFAULT_SYSTEM_DIST;
i++;
placeStaffs(0);
}
while (m_system_diff > MIN_SYSTEM_Y_DIST);
if (g_list_length(m_systems) > 1) {
lptr = g_list_last(m_systems);
delete ((NedSystem *) lptr->data);
m_systems = g_list_delete_link(m_systems, lptr);
placeStaffs(0);
}
*/
}
}
NedPage::~NedPage() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
delete ((NedSystem *) lptr->data);
}
g_list_free(m_systems);
m_systems = NULL;
}
NedPage *NedPage::clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedMainWindow *p_main_window, bool *staves) {
GList *lptr;
NedPage *page = new NedPage(p_main_window, m_width, m_height, m_page_number, ((NedSystem *)g_list_first(m_systems)->data)->getNumberOfFirstMeasure(), false);
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
page->m_systems = g_list_append(page->m_systems, ((NedSystem *) lptr->data)->clone(addrlist, slurlist, page, staves));
}
return page;
}
void NedPage::adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->adjust_pointers(addrlist, slurlist);
}
}
#ifdef XXX
void NedPage::removeAllBeams() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->removeAllBeams();
}
}
#endif
double NedPage::getTopPos() {return (2 * default_border + m_height) * m_main_window->getCurrentZoomFactor();}
double NedPage::getLeftPos() {return (( m_xpos + 2*default_border + m_width)) * m_main_window->getCurrentZoomFactor();}
NedSystem *NedPage::appendSystem() {
int system_nr;
NedSystem *system;
system_nr = g_list_length(m_systems);
m_systems = g_list_append(m_systems, system = new NedSystem(this, 0,
m_width - 2 * (LEFT_RIGHT_BORDER - DEFAULT_BORDER), system_nr, 1, TRUE));
placeStaffs(0);
return system;
}
void NedPage::insertSystem(NedSystem *system) {
m_systems = g_list_prepend(m_systems, system);
system->changePageInfo(this);
}
void NedPage::removeSystem(NedSystem *system) {
GList *lptr;
int system_nr;
if ((lptr = g_list_find(m_systems, system)) == NULL) {
NedResource::Abort("NedPage::removeSystem");
}
m_systems = g_list_delete_link(m_systems, lptr);
for (system_nr = 0, lptr = g_list_first(m_systems); lptr; system_nr++, lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->setSystemNumber(system_nr);
}
}
void NedPage::appendSystem(NedCommandList *command_list) {
NedAppendSystemCommand *append_sys_cmd = new NedAppendSystemCommand(this);
append_sys_cmd->execute();
command_list->addCommand(append_sys_cmd);
}
bool NedPage::isPageOverflow() {
if (g_list_length(m_systems) < 2) return false;
do_place_staffs(0.0);
return m_system_diff <= MIN_SYSTEM_Y_DIST;
}
unsigned int NedPage::getNumberOfLastMeasure() {
GList *lptr;
lptr = g_list_last(m_systems);
if (lptr == NULL) {
NedResource::Abort("NedPage::getNumberOfLastMeasure");
}
return ((NedSystem *) g_list_last(m_systems)->data)->getNumberOfLastMeasure();
}
int NedPage::getSorting(NedStaff *this_staff, NedSystem *this_system, NedStaff *other_staff, NedSystem *other_system) {
int pos0, pos1;
if (this_staff->getStaffNumber() != other_staff->getStaffNumber()) {
return SORTING_NONE;
}
if ((pos0 = g_list_index(m_systems, this_system)) < 0) {
NedResource::Warning("NedPage::getSorting: didn't foind system 0");
return SORTING_NONE;
}
if ((pos1 = g_list_index(m_systems, other_system)) < 0) {
NedResource::Warning("dNedPage::getSorting: idn't foind system 1");
return SORTING_NONE;
}
if (pos0 + 1 == pos1) {
return SORTING_GREAT;
}
if (pos1 + 1 == pos0) {
return SORTING_LESS;
}
return SORTING_NONE;
}
bool NedPage::isFirst(NedSystem *system) {
GList *lptr;
if ((lptr = g_list_find(m_systems, system)) == NULL) {
NedResource::Abort("NedPage::isFirst");
}
return (lptr == g_list_first(m_systems));
}
bool NedPage::isLast(NedSystem *system) {
GList *lptr;
if ((lptr = g_list_find(m_systems, system)) == NULL) {
NedResource::Abort("NedPage::isLast");
}
return (lptr == g_list_last(m_systems));
}
NedSystem *NedPage::getLastSystem() {
return (NedSystem *) g_list_last(m_systems)->data;
}
bool NedPage::find_staff_and_line(int x, int y, NedStaff **last_staff, int *last_line) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double current_scale = m_main_window->getCurrentScale();
double leftx = m_main_window->getLeftX();
double bottom;
double xl = X_POS_INVERS(x);
double yl2;
if (xl < 0.0 || xl > m_width) return false;
return findLine(x, y, &yl2, last_line, &bottom, last_staff);
}
void NedPage::draw(cairo_t *cr, bool show_measure_numbers, double main_width, double main_height) {
double leftx = m_main_window->getLeftX();
double topy = m_main_window->getTopY();
double zoom_factor = m_main_window->getCurrentZoomFactor();
double scale = m_main_window->getCurrentScale();
ScoreInfo *score_info = NULL;
double xp, yp;
bool first = true;
bool freetext_or_lyrics_present;
cairo_scale(cr, m_main_window->getCurrentScale(), m_main_window->getCurrentScale());
if (!m_main_window->doDrawPostscript()) {
if ((m_xpos * zoom_factor - leftx) * scale > main_width) {cairo_identity_matrix(cr); return;}
if (((m_xpos + (DEFAULT_BORDER + m_width)) * zoom_factor - leftx) * scale < 0) {cairo_identity_matrix(cr); return;}
cairo_set_source_rgb (cr, 0.3, 0.3, 0.3);
cairo_rectangle (cr, m_xpos * zoom_factor - leftx, -topy,
(2 * DEFAULT_BORDER + m_width) * zoom_factor,
(2 * DEFAULT_BORDER + m_height) * zoom_factor);
cairo_fill(cr);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, (m_xpos + DEFAULT_BORDER) * zoom_factor -leftx,
DEFAULT_BORDER * zoom_factor - topy,
m_width * zoom_factor, m_height * zoom_factor);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
xp = m_xpos;
}
else {
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, (DEFAULT_BORDER) * zoom_factor,
DEFAULT_BORDER * zoom_factor,
m_width * zoom_factor, m_height * zoom_factor);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
xp = 0.0;
}
if (m_page_number == 0) {
cairo_identity_matrix(cr);
yp = 0.0;
score_info = getMainWindow()->getScoreInfo();
if (m_main_window->getScoreInfo()->title != NULL) {
score_info->title->draw(cr, ((xp + DEFAULT_BORDER + (m_width - score_info->title_extends.width) / 2.0) * zoom_factor -leftx ) * scale,
(STAFF_TOP_DIST + score_info->title_extends.height) * zoom_factor - topy, zoom_factor, scale);
yp += score_info->title_extends.height + 4.0 * SCORE_INFO_EXTRA_DIST;
}
if (m_main_window->getScoreInfo()->subject != NULL) {
score_info->subject->draw(cr, ((xp + DEFAULT_BORDER + (m_width - score_info->subject_extends.width) / 2.0) * zoom_factor -leftx) * scale,
(STAFF_TOP_DIST + yp + score_info->subject_extends.height) * zoom_factor - topy, zoom_factor, scale);
yp += score_info->subject_extends.height;
}
if (m_main_window->getScoreInfo()->composer != NULL) {
score_info->composer->draw(cr, ((xp + DEFAULT_BORDER + (m_width - score_info->composer_extends.width - DEFAULT_BORDER - LEFT_RIGHT_BORDER)) * zoom_factor -leftx) * scale,
(STAFF_TOP_DIST + yp + score_info->composer_extends.height) * zoom_factor - topy, zoom_factor, scale);
yp += score_info->composer_extends.height + SCORE_INFO_EXTRA_DIST;
}
if (m_main_window->getScoreInfo()->arranger != NULL) {
score_info->arranger->draw(cr, ((xp + DEFAULT_BORDER + (m_width - score_info->arranger_extends.width - DEFAULT_BORDER - LEFT_RIGHT_BORDER)) * zoom_factor -leftx) * scale,
(STAFF_TOP_DIST + yp + score_info->arranger_extends.height) * zoom_factor - topy, zoom_factor, scale);
yp += score_info->arranger_extends.height + SCORE_INFO_EXTRA_DIST;
}
if (m_main_window->getScoreInfo()->copyright != NULL) {
score_info->copyright->draw(cr, ((xp + DEFAULT_BORDER + (m_width - score_info->copyright_extends.width - DEFAULT_BORDER - LEFT_RIGHT_BORDER)) * zoom_factor -leftx) * scale,
(STAFF_TOP_DIST + yp + score_info->copyright_extends.height) * zoom_factor - topy, zoom_factor, scale);
}
cairo_scale(cr, m_main_window->getCurrentScale(), m_main_window->getCurrentScale());
}
GList *lptr;
freetext_or_lyrics_present = false;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->draw(cr, m_page_number == 0 && first, show_measure_numbers, &freetext_or_lyrics_present);
first = false;
}
cairo_identity_matrix(cr);
if (freetext_or_lyrics_present) {
first = true;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->drawTexts(cr, m_page_number == 0 && first, scale);
first = false;
}
}
cairo_show_page(cr);
};
int NedPage::getNumberOfStaffs() {
return ((NedSystem *) g_list_first(m_systems)->data)->getNumberOfStaffs();
}
double NedPage::getContentXpos() {
if (m_main_window->doDrawPostscript()) {
return LEFT_RIGHT_BORDER;
}
return m_xpos + LEFT_RIGHT_BORDER;
}
bool NedPage::isLastPage() {
return m_main_window->getLastPage() == this;
}
bool NedPage::isLastSystem(NedSystem *system) {
GList *lptr;
if (m_main_window->getLastPage() != this) return false;
if ((lptr = g_list_last(m_systems)) == NULL) {
NedResource::Abort("NedPage::isLastSystem");
}
return (((NedSystem *) lptr->data) == system);
}
void NedPage::setAndUpdateClefTypeAndKeySig(int *clef_and_key_array, bool first) {
GList *lptr;
double indent = first ? m_main_window->getFirstSystemIndent() : m_main_window->get2ndSystemIndent();
if ((lptr = g_list_first(m_systems)) == NULL) return;
((NedSystem *) lptr->data)->setAndUpdateClefTypeAndKeySig(clef_and_key_array, indent, first);
indent = m_main_window->get2ndSystemIndent();
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->setAndUpdateClefTypeAndKeySig(clef_and_key_array, indent, false);
}
}
void NedPage::determineTempoInverse(NedChordOrRest *element, NedSystem* system, double *tempoinverse, bool *found) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if ((NedSystem *) lptr->data == system) {
((NedSystem *) lptr->data)->determineTempoInverse(element, element->getMidiTime(), tempoinverse, found);
break;
}
((NedSystem *) lptr->data)->determineTempoInverse(NULL, element->getMidiTime(), tempoinverse, found);
}
}
void NedPage::detectVoices(int staff_nr, unsigned int *voice_mask, NedSystem **last_system, unsigned long long *end_time) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->detectVoices(staff_nr, voice_mask, last_system, end_time);
}
}
void NedPage::cutEmptyVoices() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->cutEmptyVoices();
}
}
void NedPage::handleEmptyMeasures() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->handleEmptyMeasures();
}
}
bool NedPage::hasOnlyRests() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if (!((NedSystem *) lptr->data)->hasOnlyRests()) return false;
}
return true;
}
void NedPage::setAllUnpositioned() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->m_is_positioned = false;
}
}
void NedPage::zoomFreeReplaceables(double zoom, double scale) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->zoomFreeReplaceables(zoom, scale);
}
}
void NedPage::recomputeFreeReplaceables() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->recomputeFreeReplaceables();
}
}
void NedPage::testTies() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->testTies();
}
}
bool NedPage::exportLilyPond(FILE *fp, int staff_nr, int voice_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, NedSlur **lily_slur, unsigned int *lyrics_map,
bool with_break, bool *guitar_chordnames, bool *chordnames, int *breath_script, bool keep_beams) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->exportLilyPond(fp, staff_nr, voice_nr, last_line, midi_len, last_system,
end_time, in_alternative, lily_slur, lyrics_map, with_break, guitar_chordnames, chordnames, breath_script, keep_beams);
if ((NedSystem *) lptr->data == last_system) return false;
}
return true;
}
bool NedPage::exportLilyGuitarChordnames(FILE *fp, int staff_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, bool with_break) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->exportLilyGuitarChordnames(fp, staff_nr, last_line, midi_len, last_system, end_time, in_alternative, with_break);
if ((NedSystem *) lptr->data == last_system) return false;
}
return true;
}
bool NedPage::exportLilyFreeChordName(FILE *fp, int staff_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, bool with_break) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->exportLilyFreeChordName(fp, staff_nr, last_line, midi_len, last_system, end_time, in_alternative, with_break);
if ((NedSystem *) lptr->data == last_system) return false;
}
return true;
}
bool NedPage::exportLilyLyrics(FILE *fp, int staff_nr, int voice_nr, int line_nr, NedSystem *last_system, unsigned long long end_time, int *sil_count) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->exportLilyLyrics(fp, ((NedSystem *) lptr->data) == last_system, staff_nr, voice_nr, line_nr, end_time, sil_count);
if (((NedSystem *) lptr->data) == last_system) return false;
}
return true;
}
void NedPage::collectLyrics(NedLyricsEditor *leditor, int staff_nr) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->collectLyrics(leditor, staff_nr);
}
}
void NedPage::setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor, int staff_nr) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->setLyrics(command_list, leditor, staff_nr);
}
}
void NedPage::copyDataOfWholeStaff(int staff_nr) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->copyDataOfWholeStaff(staff_nr);
}
}
void NedPage::handleStaffElements() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->handleStaffElements();
}
}
void NedPage::setInternalPitches() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->setInternalPitches();
}
}
void NedPage::adjustAccidentals(int staff_nr) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->adjustAccidentals(staff_nr);
}
}
void NedPage::changeAccidentals(NedCommandList *command_list, int preferred_offs, bool *staff_list, GList *selected_group) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->changeAccidentals(command_list, preferred_offs, staff_list, selected_group);
}
}
void NedPage::transpose(int pitchdist, bool *staff_list, GList *selected_group) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->transpose(pitchdist, staff_list, selected_group);
}
}
void NedPage::hideRests(NedCommandList *command_list, bool unhide, int staff_nr, int voice_nr) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->hideRests(command_list, unhide, staff_nr, voice_nr);
}
}
bool NedPage::shiftNotes(unsigned long long start_time, int linedist, NedSystem *start_system, int staff_number) {
GList *lptr;
if (start_system == 0) {
lptr = g_list_first(m_systems);
}
else {
if ((lptr = g_list_find(m_systems, start_system)) == NULL) {
NedResource::Abort("NedPage::shiftNotes");
}
}
for (; lptr; lptr = g_list_next(lptr)) {
if (!((NedSystem *) lptr->data)->shiftNotes(start_time, linedist, staff_number)) {
return false;
}
}
return true;
}
void NedPage::removeUnneededAccidentals(int staff_nr /* = -1 */) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->removeUnneededAccidentals(staff_nr);
}
}
void NedPage::prepareReplay(bool with_keysig /* = false */) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->prepareReplay(with_keysig);
NedResource::increaseSystemStartTime(((NedSystem *) lptr->data)->getSystemEndTime());
}
}
void NedPage::reconfig_paper(double width, double height) {
GList *lptr;
m_xpos = m_page_number * (width + DEFAULT_BORDER) * m_main_window->getCurrentScale();
m_width = width; m_height = height;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->setWidth(m_width - 2 * (LEFT_RIGHT_BORDER - DEFAULT_BORDER));
}
}
void NedPage::getLinePoints(NedStaff *start_staff, NedStaff *end_staff, GList **staves) {
GList *lptr;
NedStaff *staff;
NedPage *next_page;
int staff_nr = start_staff->getStaffNumber();
int i;
if (start_staff->getPage() != this) {
if ((next_page = m_main_window->getNextPage(this)) == NULL) {
NedResource::Abort("NedPage::getLinePoints: error 1");
}
if ((lptr = g_list_find(next_page->m_systems, start_staff->getSystem())) == NULL) {
NedResource::Abort("NedPage::getLinePoints: error 2");
}
}
else {
if ((lptr = g_list_find(m_systems, start_staff->getSystem())) == NULL) {
NedResource::Abort("NedPage::getLinePoints: error 3");
}
}
for (i = 0; i < 2; i++) {
for (; lptr; lptr = g_list_next(lptr)) {
if ((staff = ((NedSystem *) lptr->data)->getStaff(staff_nr)) == NULL) {
NedResource::Abort("NedPage::getLinePoints: error 4");
}
*staves = g_list_append(*staves, staff);
if (staff == end_staff) return;
}
if ((next_page = end_staff->getPage()) == NULL) {
NedResource::Abort("NedPage::getLinePoints: error 6");
}
if ((lptr = g_list_first(next_page->m_systems)) == NULL) {
NedResource::Abort("NedPage::getLinePoints: error 7");
}
}
NedResource::DbgMsg(DBG_CRITICAL, "gesucht wurde in staff %d\n", staff_nr);
NedResource::Abort("NedPage::getLinePoints: error 8");
}
void NedPage::savePage(FILE *fp) {
GList *lptr;
fprintf(fp, "PAGE %d\n", m_page_number);
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->saveSystem(fp);
}
}
void NedPage::restorePage(FILE *fp) {
int i, system_nr;
char buffer[128];
NedSystem *system;
double system_pos = TOP_BOTTOM_BORDER;
i = 0;
do {
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "(1)SYSTEM or PAGE expected";
return;
}
if (strcmp(buffer, "SYSTEM")) {
if (!strcmp(buffer, "PAGE")) {
NedResource::unreadWord(buffer);
return;
}
NedResource::DbgMsg(DBG_CRITICAL, "buffer = %s\n", buffer);
NedResource::m_error_message = "(2)SYSTEM or PAGE expected";
return;
}
if (!NedResource::readInt(fp, &system_nr)) {
NedResource::m_error_message = "SYSTEM number expected";
return;
}
/*
if (system_nr != i) {
NedResource::m_error_message = "bad system_nr";
return;
}
*/
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": expected";
return;
}
system = new NedSystem(this, system_pos, m_width - 2 * (LEFT_RIGHT_BORDER - DEFAULT_BORDER), system_nr, 0 /* dummy is reset during "renumberMeasures()" at the end of "reposit()" */, FALSE);
m_systems = g_list_append(m_systems, system);
system->restoreSystem(fp);
i++;
system_pos += system->getHeight() + DEFAULT_SYSTEM_DIST;
}
while (NedResource::m_error_message == NULL);
}
bool NedPage::tryChangeLength(NedChordOrRest *chord_or_rest) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if (((NedSystem *) lptr->data)->tryChangeLength(chord_or_rest)) {
return TRUE;
}
}
return FALSE;
}
bool NedPage::trySelect(double x, double y, bool only_free_placeables /* = false */) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double leftx = m_main_window->getLeftX();
double current_scale = m_main_window->getCurrentScale();
double xl = X_POS_INVERS(x);
if (xl < 0.0 || xl > m_width) return false;
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if (((NedSystem *) lptr->data)->trySelect(x, y, only_free_placeables)) {
return true;
}
}
return false;
}
NedChordOrRest *NedPage::findNearestElement(int staff_nr, double x, double y, NedStaff *oldstaff, double *ydist) {
double mindist = 10000000.0;
NedChordOrRest *nearestElement = NULL, *element;
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if ((element = ((NedSystem *) lptr->data)->findNearestElement(staff_nr, x, y, oldstaff, &mindist, ydist)) != NULL) {
nearestElement = element;
}
}
return nearestElement;
}
bool NedPage::findTimeOfMeasure(int meas_num, unsigned long long *meas_time, unsigned long long *system_offs) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if (((NedSystem *) lptr->data)->findTimeOfMeasure(meas_num, meas_time)) {
return true;
}
*system_offs += ((NedSystem *) lptr->data)->getSystemEndTime();
}
return false;
}
void NedPage::collectSelectionRectangleElements(NedBbox *sel_rect, GList **sel_group, NedSystem *first_selected_system, NedSystem *last_selected_system,
NedPage *first_selected_page, NedPage *last_selected_page) {
double xp = sel_rect->x - m_xpos;
if (xp + sel_rect->width < 0.0 || m_width < xp) return;
GList *lptr;
xp -= LEFT_RIGHT_BORDER;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->collectSelectionRectangleElements(xp, sel_rect, sel_group, first_selected_system, last_selected_system,
first_selected_page == this, last_selected_page == this);
}
}
void NedPage::findSelectedFirstsLasts(NedBbox *sel_rect, int *number_of_first_selected_staff, int *number_of_last_selected_staff,
NedSystem **first_selected_system, NedSystem **last_selected_system, NedPage **first_selected_page, NedPage **last_selected_page) {
double xp = sel_rect->x - m_xpos;
if (xp + sel_rect->width < 0.0 || m_width < xp) return;
GList *lptr;
xp -= LEFT_RIGHT_BORDER;
if (*first_selected_page == NULL) {
*first_selected_page = *last_selected_page = this;
}
else {
*last_selected_page = this;
}
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->findSelectedSystems(sel_rect, number_of_first_selected_staff, number_of_last_selected_staff, first_selected_system, last_selected_system);
}
}
void NedPage::findFromTo(GList *clipboard, NedPage **min_page, NedPage **max_page, NedSystem **min_sys, NedSystem **max_sys) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if (((NedSystem *) lptr->data)->findFromTo(clipboard, min_sys, max_sys)) {
if (*min_page == NULL) {
*min_page = *max_page = this;
}
else {
*max_page = this;
}
}
}
}
void NedPage::deleteItemsFromTo(NedCommandList *command_list, bool is_first_page, bool is_last_page,
NedSystem *min_sys, NedSystem *max_sys, unsigned long long start_midi, unsigned long long end_midi) {
NedSystem *system;
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
system = (NedSystem *) lptr->data;
if (is_first_page && system->getSystemNumber() < min_sys->getSystemNumber()) continue;
if (is_last_page && system->getSystemNumber() > max_sys->getSystemNumber()) break;
system->deleteItemsFromTo(command_list, system == min_sys, system == max_sys, start_midi, end_midi);
}
}
void NedPage::removeNotesFromTo(NedCommandList *command_list, GList *items, bool is_first_page, bool is_last_page,
NedSystem *min_sys, NedSystem *max_sys) {
GList *lptr;
NedSystem *system;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
system = (NedSystem *) lptr->data;
if (is_first_page && system->getSystemNumber() < min_sys->getSystemNumber()) continue;
if (is_last_page && system->getSystemNumber() > max_sys->getSystemNumber()) break;
system->removeNotesFromTo(command_list, items, system == min_sys, system == max_sys);
}
}
void NedPage::testForPageBackwardTies(NedCommandList *command_list) {
((NedSystem *) g_list_first(m_systems)->data)->testForPageBackwardTies(command_list);
}
void NedPage::checkForElementsToSplit(NedCommandList *command_list, int *measure_number) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->checkForElementsToSplit(command_list, measure_number);
}
}
NedStaff *NedPage::findStaff(double x, double y, NedMeasure **measure) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double current_scale = m_main_window->getCurrentScale();
double leftx = m_main_window->getLeftX();
NedStaff *staff;
double xl = X_POS_INVERS(x);
if (xl < 0.0 || xl > m_width) return NULL;
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
if ((staff = ((NedSystem *) lptr->data)->findStaff(xl + m_xpos, y, measure)) != NULL) {
return staff;
}
}
return NULL;
}
double NedPage::convertX(double xpos) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double leftx = m_main_window->getLeftX();
return m_main_window->getCurrentScale() * X_POS_PAGE_REL(xpos);
}
bool NedPage::isXOnPage(double x) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double current_scale = m_main_window->getCurrentScale();
double leftx = m_main_window->getLeftX();
double xl = X_POS_INVERS(x);
if (xl < 0.0 || xl > m_width) return false;
return true;
}
bool NedPage::tryInsertOrErease(double x, double y, int num_midi_input_notes, int *midi_input_chord /* given if insert from midikeyboard */, NedChordOrRest **newObj /* = NULL */, bool force_rest /* = false */) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double current_scale = m_main_window->getCurrentScale();
double leftx = m_main_window->getLeftX();
NedChordOrRest *element;
NedChordName *chordname;
double dummy, dummy0;
double topy, xx, yy;
double xx2, yy2;
unsigned int kind, tempo;
NedCommandList *command_list;
NedLinePoint *lp0, *lp1, *lp2;
if (newObj != NULL) {
*newObj = NULL;
}
double xl = X_POS_INVERS(x);
#define LINE_START_X_DIST 2.0
#define SLUR_START_X_DIST 1.0
#define SLUR_START_Y_DIST ( 2 * LINE_DIST )
if (xl < 0.0 || xl > m_width) return FALSE;
GList *lptr;
double mindist, d;
if (midi_input_chord == NULL) { // x, y given
switch(m_main_window->getSpecialType()) {
case TYPE_DYNAMIC:
case TYPE_TEMPO:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
yy = Y_POS_INVERS(y);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
command_list = new NedCommandList(m_main_window);
if (m_main_window->getSpecialType() == TYPE_DYNAMIC) {
command_list->addCommand(new NedInsertFreePlaceableCommand(new NedVolumeSign(m_main_window->getSpecialSubTypeInt()), element, xx, yy));
}
else {
kind = (m_main_window->getSpecialSubTypeInt() & 0xffff) * FACTOR;
tempo = ((m_main_window->getSpecialSubTypeInt() >> 16) & 0xffff);
command_list->addCommand(new NedInsertFreePlaceableCommand(new NedTempoSign(kind, tempo), element, xx, yy));
}
command_list->execute();
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
return TRUE;
case TYPE_SIGN:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
yy = Y_POS_INVERS(y);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
command_list = new NedCommandList(m_main_window);
command_list->addCommand(new NedInsertFreePlaceableCommand(new NedFreeSign(m_main_window->getSpecialSubTypeInt()), element, xx, yy));
command_list->execute();
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
return TRUE;
case TYPE_GUITAR_CHORD:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
yy = Y_POS_INVERS(y);
#define CHOR_NAME_Y_DIST 0.4
#define CHOR_NAME_X_DIST 0.4
element = findNearestElement(-1, xx, yy, NULL, &dummy);
xx2 = element->getXPos() - CHOR_NAME_X_DIST;
yy2 = element->getSystem()->getYPos() + element->getStaff()->getTopPos() - CHOR_NAME_Y_DIST;
command_list = new NedCommandList(m_main_window);
command_list->addCommand(new NedInsertFreePlaceableCommand(new NedFreeChord(m_main_window->getSpecialSubTypeChordInfo().chord_ptr,
m_main_window->getSpecialSubTypeChordInfo().chord_name_num,
m_main_window->getSpecialSubTypeChordInfo().status, m_main_window), element, xx2, yy2));
command_list->execute();
m_main_window->setAllUnpositioned();
m_main_window->reposit(command_list);
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
return TRUE;
case TYPE_SPACER:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
yy = Y_POS_INVERS(y);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
command_list = new NedCommandList(m_main_window);
command_list->addCommand(new NedInsertFreePlaceableCommand(new NedFreeSpacer(m_main_window), element, xx, yy));
command_list->execute();
m_main_window->setAllUnpositioned();
m_main_window->reposit(command_list);
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
return TRUE;
case TYPE_CHORDNAME:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
yy = Y_POS_INVERS(y);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
xx2 = element->getXPos() - CHOR_NAME_X_DIST;
yy2 = element->getSystem()->getYPos() + element->getStaff()->getTopPos() - m_main_window->getSpecialSubTypeChordNameInfo().ydist;
command_list = new NedCommandList(m_main_window);
command_list->addCommand(new NedInsertFreePlaceableCommand(chordname = new NedChordName(m_main_window->getDrawingArea(),m_main_window->getSpecialSubTypeChordNameInfo().root_name,
m_main_window->getSpecialSubTypeChordNameInfo().up_name,m_main_window->getSpecialSubTypeChordNameInfo().down_name, m_main_window->getSpecialSubTypeChordNameInfo().fontsize), element, xx2, yy2));
chordname->setZoom(zoom_factor, current_scale);
command_list->execute();
m_main_window->setAllUnpositioned();
m_main_window->reposit(command_list);
m_main_window->getCommandHistory()->addCommandList(command_list);
//m_main_window->resetSpecialType();
return TRUE;
case TYPE_FREE_TEXT:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
yy = Y_POS_INVERS(y);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
command_list = new NedCommandList(m_main_window);
command_list->addCommand(new NedInsertFreePlaceableCommand(m_main_window->m_freetext, element, xx, yy));
m_main_window->m_freetext->setZoom(zoom_factor, current_scale);
command_list->execute();
m_main_window->m_freetext = NULL;
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
return TRUE;
case TYPE_LINE:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
if (xx > m_width / 2.0) xx -= 2 * SLUR_START_X_DIST;
yy = Y_POS_INVERS(y);
command_list = new NedCommandList(m_main_window);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(lp0 = new NedLinePoint(NULL, 0), element, xx, yy));
dummy0 = 10000000.0;
element = element->getStaff()->findNearestElement(xx + LINE_START_X_DIST, yy, NULL, &dummy0, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(lp1 = new NedLinePoint(NULL, 1), element, xx + LINE_START_X_DIST, yy));
command_list->execute();
switch (m_main_window->getSpecialSubTypeInt()) {
case LINE_CRESCENDO:
case LINE_DECRESCENDO:
new NedCrescendo(lp0, lp1, m_main_window->getSpecialSubTypeInt() == LINE_DECRESCENDO);
break;
case LINE_OCTAVATION1:
case LINE_OCTAVATION_1:
case LINE_OCTAVATION2:
case LINE_OCTAVATION_2:
new NedOctavation(lp0, lp1, m_main_window->getSpecialSubTypeInt());
break;
}
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
m_main_window->m_selected_free_replaceable = lp0;
return TRUE;
case TYPE_LINE3:
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(x);
//if (xx > m_width / 2.0) xx -= 3 * SLUR_START_X_DIST;
yy = Y_POS_INVERS(y);
command_list = new NedCommandList(m_main_window);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(lp0 = new NedLinePoint(NULL, 0), element, xx, yy));
dummy0 = 10000000.0;
element = element->getStaff()->findNearestElement(xx + LINE_START_X_DIST, yy, NULL, &dummy0, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(lp1 = new NedLinePoint(NULL, 1), element, xx + LINE_START_X_DIST, yy));
dummy0 = 10000000.0;
element = element->getStaff()->findNearestElement(xx + 2 * LINE_START_X_DIST, yy, NULL, &dummy0, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(lp2 = new NedLinePoint(NULL, 1), element, xx + 2 * LINE_START_X_DIST, yy));
command_list->execute();
new NedAcceleration(lp0, lp1, lp2, m_main_window->getSpecialSubTypeInt() == LINE_RITARDANDO);
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
m_main_window->m_selected_free_replaceable = lp0;
return TRUE;
}
}
lptr = g_list_first(m_systems);
NedSystem *nearest_system = (NedSystem *) lptr->data;
mindist = nearest_system->computeMidDist(y);
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if ((d = ((NedSystem *) lptr->data)->computeMidDist(y)) < mindist) {
nearest_system = (NedSystem *) lptr->data;
mindist = d;
}
}
if (nearest_system->tryInsertOrErease(x, y, num_midi_input_notes, midi_input_chord, newObj, force_rest)) {
return true;
}
return false;
}
void NedPage::insertSlur(GdkRectangle *selection_rect) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double current_scale = m_main_window->getCurrentScale();
double leftx = m_main_window->getLeftX();
double topy, xx, yy, yyy;
double xx0, yy0, xx1, yy1, xx2, yy2;
double xdist, ydist, dist;
double dummy, dummy0;
int dir, l, mid;
NedSlurPoint *sp[3];
GList *lptr;
NedChordOrRest *element, *element0, *element1, *element2;
NedCommandList *command_list = new NedCommandList(m_main_window);
if (NedResource::m_main_clip_board == NULL) {
//printf("Paramater vom Rect\n"); fflush(stdout);
topy = m_main_window->getTopY();
xx = X_POS_INVERS_PAGE_REL(selection_rect->x);
if (xx > m_width / 2.0) xx -= (3 * SLUR_START_X_DIST) / zoom_factor;
yy = Y_POS_INVERS(selection_rect->y);
command_list = new NedCommandList(m_main_window);
element = findNearestElement(-1, xx, yy, NULL, &dummy);
yyy = element->getSystem()->getYPos() + element->getStaff()->getMidPos();
command_list->addCommand(new NedInsertFreePlaceableCommand(sp[0] = new NedSlurPoint(NULL, 0), element, xx, yyy));
dummy0 = 10000000.0;
element1 = element->getStaff()->findNearestElement(xx + SLUR_START_X_DIST, yyy - SLUR_START_Y_DIST, NULL, &dummy0, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(sp[1] = new NedSlurPoint(NULL, 1), element1, xx + SLUR_START_X_DIST, yyy - SLUR_START_Y_DIST));
dummy0 = 10000000.0;
element2 = element->getStaff()->findNearestElement(xx + 2 * SLUR_START_X_DIST, yyy - SLUR_START_Y_DIST / 2, NULL, &dummy0, &dummy);
command_list->addCommand(new NedInsertFreePlaceableCommand(sp[2] = new NedSlurPoint(NULL, 2), element2, xx + 2 * SLUR_START_X_DIST, yyy - SLUR_START_Y_DIST / 2));
}
else {
//printf("Paramater von Elementen\n"); fflush(stdout);
dir = 0;
l = g_list_length(NedResource::m_main_clip_board);
if (l < 2) {
NedResource::Abort("l > 2");
}
mid = l / 2;
lptr = g_list_last(NedResource::m_main_clip_board);
dir += ((NedChordOrRest *) lptr->data)->hasUpDir() ? 1 : -1;
element2 = (NedChordOrRest *) lptr->data;
lptr = g_list_first(NedResource::m_main_clip_board);
dir += ((NedChordOrRest *) lptr->data)->hasUpDir() ? 1 : -1;
element0 = (NedChordOrRest *) lptr->data;
#define SLUR_X_DIST_PROLONG (LINE_DIST * 0.5)
xx2 = element2->getXPos() + element2->getBBox()->width_netto + element2->getBBox()->x + SLUR_X_DIST_PROLONG;
yy2 = element2->getStaff()->getTopPos() + element2->getSystem()->getYPos() + element2->getStemBottom();
lptr = g_list_nth(NedResource::m_main_clip_board, mid);
dir += ((NedChordOrRest *) lptr->data)->hasUpDir() ? 1 : -1;
element1 = (NedChordOrRest *) lptr->data;
/*
xx1 = element1->getXPos();
yy1 = element1->getStaff()->getTopPos() + element1->getSystem()->getYPos() + element1->getStemBottom();
*/
dir = (dir > 0.0) ? 1.0 : -1.0;
#define SLUR_MIDDLE_DIST (LINE_DIST * 1.8)
#define SLUR_Y_DIST_UP (LINE_DIST * 1.0)
#define SLUR_Y_DIST_DOWN (LINE_DIST * 2.0)
xx0 = element0->getXPos() + element2->getBBox()->x - SLUR_X_DIST_PROLONG;
yy0 = element0->getStaff()->getTopPos() + element0->getSystem()->getYPos() + element0->getStemBottom();
yy2 += dir * ((dir > 0) ? SLUR_Y_DIST_DOWN : SLUR_Y_DIST_UP);
yy0 += dir * ((dir > 0) ? SLUR_Y_DIST_DOWN : SLUR_Y_DIST_UP);
command_list->addCommand(new NedInsertFreePlaceableCommand(sp[0] = new NedSlurPoint(NULL, 0), element2, xx2, yy2));
command_list->addCommand(new NedInsertFreePlaceableCommand(sp[2] = new NedSlurPoint(NULL, 0), element0, xx0, yy0));
xdist = xx2 - xx0;
ydist = yy2 - yy0;
xx1 = xx0 + xdist / 2.0;
yy1 = yy0 + ydist / 2.0;
dist = sqrt(xdist * xdist + ydist * ydist);
xdist /= dist;
ydist /= dist;
xx1 -= ydist * dir * SLUR_MIDDLE_DIST;
yy1 += xdist * dir * SLUR_MIDDLE_DIST;
command_list->addCommand(new NedInsertFreePlaceableCommand(sp[1] = new NedSlurPoint(NULL, 0), element1, xx1, yy1));
}
command_list->execute();
new NedSlur(sp);
m_main_window->getCommandHistory()->addCommandList(command_list);
m_main_window->resetSpecialType();
m_main_window->m_selected_free_replaceable = sp[2];
}
bool NedPage::findLine(double x, double y, double *ypos, int *line, double *bottom, NedStaff **staff) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double leftx = m_main_window->getLeftX();
double current_scale = m_main_window->getCurrentScale();
double xl = X_POS_INVERS(x);
if (xl < 0.0 || xl > m_width) return FALSE;
GList *lptr;
double mindist, d;
lptr = g_list_first(m_systems);
if (lptr == NULL) {
return FALSE; // don't know in which case this happens; concerns mainly MIDI import
}
NedSystem *nearest_system = (NedSystem *) lptr->data;
mindist = nearest_system->computeMidDist(y);
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if ((d = ((NedSystem *) lptr->data)->computeMidDist(y)) < mindist) {
nearest_system = (NedSystem *) lptr->data;
mindist = d;
}
}
if (nearest_system->findLine(x, y, ypos, line, bottom, staff)) {
return TRUE;
}
return FALSE;
}
bool NedPage::findXposInOtherMeasure(guint keyval, double x, double y, double *newx, double *newy) {
double zoom_factor = m_main_window->getCurrentZoomFactor();
double current_scale = m_main_window->getCurrentScale();
double leftx = m_main_window->getLeftX();
NedChordOrRest *element;
NedStaff *staff;
NedSystem *system;
double xl = X_POS_INVERS(x);
*newy = y;
if (xl < 0.0 || xl > m_width) return false;
GList *lptr;
double mindist, d;
lptr = g_list_first(m_systems);
NedSystem *nearest_system = (NedSystem *) lptr->data;
mindist = nearest_system->computeMidDist(y);
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if ((d = ((NedSystem *) lptr->data)->computeMidDist(y)) < mindist) {
nearest_system = (NedSystem *) lptr->data;
mindist = d;
}
}
if (nearest_system->findElement(keyval, x, y, &element, &staff)) {
m_main_window->setVisible(element);
leftx = m_main_window->getLeftX();
*newx = X_POS_PAGE_REL(element->getXPos());
return true;
}
else {
if ((lptr = g_list_find(m_systems, nearest_system)) == NULL) {
NedResource::Abort("NedPage::findXposInOtherMeasure");
}
switch (keyval) {
case GDK_Right: lptr = g_list_next(lptr);
if (lptr == NULL) return false;
system = (NedSystem *) lptr->data;
lptr = system->getFirstChordOrRest(staff->getStaffNumber(), 0, 0, false, false);
if (lptr == NULL) return false;
element = (NedChordOrRest *) lptr->data;
m_main_window->setVisible(element);
*newx = X_POS_PAGE_REL(element->getXPos());
*newy = element->getStaff()->getRealYPosOfLine(-3);
return true;
case GDK_Left: lptr = g_list_previous(lptr);
if (lptr == NULL) return false;
system = (NedSystem *) lptr->data;
lptr = system->getLastChordOrRest(staff->getStaffNumber(), 0, 0, false, false);
if (lptr == NULL) return false;
element = (NedChordOrRest *) lptr->data;
m_main_window->setVisible(element);
*newx = X_POS_PAGE_REL(element->getXPos());
*newy = element->getStaff()->getRealYPosOfLine(-3);
return true;
}
}
return false;
}
void NedPage::renumberSystems() {
int i;
GList *lptr;
for (i = 0, lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr), i++) {
((NedSystem *) lptr->data)->setSystemNumber(i);
}
}
void NedPage::resetActiveFlags() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->resetActiveFlags();
}
}
NedPage *NedPage::getNextPage() {
return m_main_window->getNextPage(this);
}
NedPage *NedPage::getPreviousPage() {
return m_main_window->getPreviousPage(this);
}
bool NedPage::placeStaffs(int pass, NedCommandList *command_list /* = NULL */) {
GList *lptr;
NedPage *other_page;
double offs = STAFF_TOP_DIST;
do_place_staffs(offs);
bool changed = FALSE;
if (m_page_number == 0) {
offs += getMainWindow()->getFirstPageYOffs() / getMainWindow()->getCurrentScale();
}
if (pass == 0) m_ping_pong = false;
do_place_staffs(offs);
if (pass == 0 && m_system_diff < 0) {
if (command_list != NULL && g_list_length(m_systems) > 1) {
lptr = g_list_last(m_systems);
if (m_main_window->getLastPage() && hasOnlyRests()) {
NedDeleteSystemCommand *del_system_command = new NedDeleteSystemCommand((NedSystem *) lptr->data);
del_system_command->execute();
command_list->addCommand(del_system_command);
}
else {
other_page = m_main_window->getNextPage(this, command_list);
NedMoveSystemCommand *move_system_command = new NedMoveSystemCommand(this, (NedSystem *) lptr->data, other_page);
move_system_command->execute(); // the commandlist is not executed
command_list->addCommand(move_system_command);
}
changed = TRUE;
do_place_staffs(offs);
}
}
#define MAX_Y_BORDER 1.0
if (pass == 1 && !isEmpty() && !m_ping_pong && command_list != NULL && m_system_diff > MAX_Y_BORDER) {
other_page = m_main_window->getNextPage(this);
if (other_page == NULL) return FALSE;
if ((lptr = g_list_first(other_page->m_systems)) == NULL) {
NedRemovePageCommand *rem_page_command = new NedRemovePageCommand(m_main_window, other_page);
rem_page_command->execute();
command_list->addCommand(rem_page_command);
return FALSE;
}
NedGetSystemFromNextPageCommand *get_system_from_next_page_command =
new NedGetSystemFromNextPageCommand(lptr, this, other_page);
get_system_from_next_page_command->execute(); // the commandlist is not executed; performs placeStaffs()
if (m_system_diff < MIN_SYSTEM_Y_DIST) {
m_ping_pong = TRUE;
get_system_from_next_page_command->unexecute();
delete get_system_from_next_page_command;
}
else {
command_list->addCommand(get_system_from_next_page_command);
changed = TRUE;
}
if (!isEmpty()) {
do_place_staffs(offs);
}
}
return changed;
}
void NedPage::computeTuplets() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->computeTuplets();
}
}
int NedPage::getSystemCount() {
return g_list_length(m_systems);
}
void NedPage::do_place_staffs(double offs) {
GList *lptr;
double staffpos = TOP_BOTTOM_BORDER + offs;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
staffpos = ((NedSystem *) lptr->data)->placeStaffs(staffpos);
}
m_system_diff = m_height - staffpos;
}
NedSystem *NedPage::getNextSystem(NedSystem *system, NedCommandList *command_list /* = NULL */) {
GList *lptr;
NedAppendSystemCommand *app_sys_cmd;
NedSystem *system_on_next_page;
bool append_system_if_necessary = ((m_main_window->getLastPage() == this) && (system == ((NedSystem *) g_list_last(m_systems)->data)));
if (isEmpty()) return NULL;
if ((lptr = g_list_find(m_systems, system)) == NULL) {
printf("gesucht war: 0x%p\n", system); fflush(stdout);
NedResource::Abort("NedPage::getNextSystem");
}
if ((lptr = g_list_next(lptr)) == NULL) {
system_on_next_page = m_main_window->getNextSystem(this, NULL);
if (system_on_next_page == NULL) {
if (command_list != NULL && append_system_if_necessary) {
app_sys_cmd = new NedAppendSystemCommand(this);
app_sys_cmd->execute();
command_list->addCommand(app_sys_cmd);
return app_sys_cmd->getSystem();
}
return NULL;
}
return system_on_next_page;
}
return (NedSystem *) lptr->data;
}
NedSystem *NedPage::getPreviousSystem(NedSystem *system) {
GList *lptr;
if ((lptr = g_list_find(m_systems, system)) == NULL) {
NedResource::Abort("NedPage::getPreviousSystem");
}
if ((lptr = g_list_previous(lptr)) == NULL) {
return NULL;
}
return (NedSystem *) lptr->data;
}
NedSystem *NedPage::getFirstSystem() {
GList *lptr;
if ((lptr = g_list_first(m_systems)) == NULL) {
NedResource::Abort("NedPage::getFirstSystem");
}
return (NedSystem *) lptr->data;
}
void NedPage::appendStaff(NedCommandList *command_list, int p_staff_nr /* = -1 */) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->appendStaff(command_list, p_staff_nr);
}
}
void NedPage::removeLastStaff() {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->removeLastStaff();
}
}
void NedPage::deleteStaff(int staff_number) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->deleteStaff(staff_number);
}
}
void NedPage::restoreStaff(int staff_number) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->restoreStaff(staff_number);
}
}
void NedPage::shiftStaff(int staff_number, int position) {
GList *lptr;
for (lptr = g_list_first(m_systems); lptr; lptr = g_list_next(lptr)) {
((NedSystem *) lptr->data)->shiftStaff(staff_number, position);
}
}
nted-1.10.18/slur.h 0000664 0010410 0000764 00000003631 11520267230 010673 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SLUR_H
#define SLUR_H
#include
class NedSlurPoint;
class NedSlur {
public:
NedSlur(NedSlurPoint *points[3]);
void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level);
void computeParams();
bool isActive();
NedSlurPoint **getSlurPoints() {return m_slur_points;}
private:
NedSlurPoint *m_slur_points[3];
double m_xpos0, m_ypos0;
double m_xpos1, m_ypos1;
double m_xpos2, m_ypos2;
double m_xpos11, m_xpos12, m_ypos11, m_ypos12;
double m_xpos11_l, m_xpos12_l, m_ypos11_l, m_ypos12_l;
double m_xpos11_r, m_xpos12_r, m_ypos11_r, m_ypos12_r;
double m_midx1_0, m_midy1_0, m_midx1_1, m_midy1_1;
bool m_distributed;
friend class NedSlurPoint;
};
#endif /* SLUR_H */
nted-1.10.18/chordorrest.h 0000664 0010410 0000764 00000032654 11520267230 012253 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef CHORD_OR_REST_H
#define CHORD_OR_REST_H
#include "config.h"
#include "resource.h"
#include "beam.h"
#include
#include
#define LAST_TUPLET_FLAG (1 << 24)
#define TUPLET_VAR_MASK (0xfff)
#define BREAK_TIE_FORWARD (1 << 0)
#define BREAK_TIE_BACKWARD (1 << 1)
#define TYPE_REST (1 << 0)
#define TYPE_CHORD (1 << 1)
#define TYPE_CLEF (1 << 2)
#define TYPE_KEYSIG (1 << 3)
#define TYPE_STAFF_SIGN (1 << 5) // otherwise conflic with CLEFS : -((
#define TYPE_GRACE (1 << 4)
#define TYPE_DYNAMIC (1 << 6)
#define TYPE_TEMPO (1 << 7)
#define TYPE_SLUR (1 << 8)
#define TYPE_LINE (1 << 9)
#define TYPE_LINE3 (1 << 10)
#define TYPE_FREE_TEXT (1 << 11)
#define TYPE_SIGN (1 << 12)
#define TYPE_GUITAR_CHORD (1 << 13)
#define TYPE_SPACER (1 << 14)
#define TYPE_CHORDNAME (1 << 15)
#define LYR_CURSOR_LEFT -1
#define LYR_CURSOR_RIGHT 1
#define LYR_CURSOR_START -2
#define LYR_CURSOR_END 2
#define MAX_ARTICULATIONS 10
#define WRITTEN_SLANT_NORMAL 0
#define WRITTEN_SLANT_ITALIC 1
#define WRITTEN_SLANT_OBLIQUE 2
#define WRITTEN_WEIGHT_NORMAL 0
#define WRITTEN_WEIGHT_BOLD 1
#define UNSET_STEM_HEIGHT -10000.0
#define UNSET_SLOPE_OFFS -1000
class NedMainWindow;
class NedPage;
class NedSystem;
class NedStaff;
class NedVoice;
class NedTuplet;
class BBox;
class NedCommandList;
class NedNote;
class NedFreeReplaceable;
class NedLyricsEditor;
class NedSlur;
class NedMeasure;
class NedPangoCairoText;
class VolumeChange {
public:
VolumeChange(int vol, unsigned long long time) : m_volume(vol), m_midi_time(time) {}
int m_volume;
unsigned long long m_midi_time;
static int compare(VolumeChange *v1, VolumeChange *v2) {
if (v1->m_midi_time < v2->m_midi_time) return -1;
if (v1->m_midi_time > v2->m_midi_time) return 1;
return 0;
}
};
class NedChordOrRest {
public:
NedChordOrRest(NedVoice *voice, int type, bool is_hidden, int line, int dot_count, unsigned int length, int head, unsigned int status, unsigned long long time);
NedChordOrRest(NedVoice *voice, int type, unsigned int clef_number, int octave_shift, unsigned long long time, bool dummy); // clef
NedChordOrRest(NedVoice *voice, int type, int keysig, int last_keysig, unsigned long long time); // key signature
NedChordOrRest(NedVoice *voice, int type, int sub_type, unsigned long long time); // sign
~NedChordOrRest();
NedChordOrRest *clone(struct addr_ref_str **addrlist, bool keep_beam = false);
NedChordOrRest *clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedVoice *p_voice);
void setActive();
void setForceBeamFlag() {m_status &= (~(STAT_BREAK_BEAM)); m_status |= STAT_FORCE_BEAM;}
void setBreakBeamFlag() {m_status &= (~(STAT_FORCE_BEAM)); m_status |= STAT_BREAK_BEAM;}
bool hasUpDir();
void flipStem(NedCommandList *command_list);
void print();
void draw(cairo_t *cr, bool *freetexts_or_lyrics_present);
void drawTexts(cairo_t *cr, double scale, double last_left_bbox_edge, bool last);
double getRealXpos() {return m_xpos;}
double getXPos() {/* if (m_tmp_xpos < 0.0) */return m_xpos; /* return m_tmp_xpos; */}
double getLeftBboxEdge() {return m_xpos + m_bbox.x;}
double getXPosAndMicroshifts() {if (m_tmp_xpos < 0.0) return m_xpos + m_micro_shift; return m_tmp_xpos + m_micro_shift;}
void insertNoteAt(NedNote *note, bool echo = FALSE);
bool removeNoteAt(int line);
bool noConflict(int line);
void testTies();
void tryTieBackward();
void reConfigure();
NedMeasure *m_measure;
NedNote *getFirstNote();
int getLineOfLowestNote();
int getLineOfFirstNote();
NedMainWindow *getMainWindow();
NedPage *getPage();
NedSystem *getSystem();
NedStaff *getStaff();
int getPosition();
int lengthForFlagCountComputation();
int numberOfFlagSigns();
int numberOfTremoloSigns();
NedVoice *getVoice() {return m_voice;}
void createLyrics(int line, char *text);
void setLyrics(int line, char *text);
void setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor);
void setLyricsFromOldContext(NedMainWindow *main_window, int line, char *text);
void appendToLyrics(NedCommandList *command_list, int line, const char *text);
bool deleteLyricsLetter(NedCommandList *command_list, int line);
bool setLyricsCursor(int line, int pos);
void selectNextChord(int line, bool lyrics_required);
void selectPreviousChord(int line, bool lyrics_required);
void setVoice(NedVoice *voice) {m_voice = voice;}
void removeUnneededAccidentals(int clef, int keysig, int octave_shift);
void setToRest(bool toRest);
int getType() {return m_type;}
bool isRest() {return (m_type == TYPE_REST);}
bool isHidden() {return m_is_hidden || (m_status & STAT_USER_HIDDEN_REST);}
void setHidden() {m_is_hidden = true;}
void setTime(unsigned int time) {m_time = time;}
unsigned int getStatus() {return m_status;}
void setStatus(unsigned int status);
unsigned int getLength() {return m_length;}
void setLength(int length);
bool trySelect (double x, double y, bool only_free_placeables);
bool hitStemEnd(double x, double y);
double computeDistFrom(double x, double y, double factor, double *ydist);
bool tryErease (double x, double y, bool *removed);
void ereaseNote(NedNote *note);
bool testXShift(double x);
void moveToLine(int line);
bool scaleStem(double y, double old_ypos);
void fixIntermediateValues();
double getCurrentStemLen() {return m_stem_height;}
double getOldStemLen() {return m_stemheight_copy;}
bool ReleaseTmpValue();
static int compareMidiTimes(NedChordOrRest *c1, NedChordOrRest *c2);
static int compareMidiTimesAndTypes(NedChordOrRest *c1, NedChordOrRest *c2);
unsigned int getTime() {return m_time;}
unsigned int getDuration(unsigned int measure_duration = -1);
double determineTempoInverse();
void recomputeFreeReplaceables();
void zoomFreeReplaceables(double zoom, double scale);
void determineTempoInverse(double *tempoinverse);
void setXPos(double pos);
void setXPos2(double pos);
void shiftX(double x);
void shiftY(double y);
void setRestsY(double y);
void setXPosAccordingBBox(double pos) {m_xpos = pos - m_bbox.x;}
unsigned int getStopTime();
void setBeam(NedBeam *beam) {m_beam = beam;}
NedBeam *getBeam() {return m_beam;}
void reposit(unsigned int pos);
void xPositNotes();
void collectNotesWithAccidentals(unsigned int *num_notes_with_accidentals, NedNote **note_field);
void sortNotes();
double getBeamXPos();
double getStemTop();
double getStemBottom();
int getStemDir();
void resetYPos();
double getStemYStart();
void getTopBotY(int *lyrics_lines, double *topy , double *boty/* , bool *topFix, bool *botFix */);
double getTopOfChordOrRest();
double getBottomOfChordOrRest();
bool testForTiesToDelete(NedCommandList *command_list, unsigned int dir = BREAK_TIE_BACKWARD, bool execute = false);
void testForFreeReplaceablesToDelete(NedCommandList *command_list, GList **already_deleted, bool execute = false);
void testForDeleteableConstraints(NedCommandList *command_list);
void tieAllNotes(NedChordOrRest *other_chord);
static void handleOpenTies(NedCommandList *command_list, GList *pool);
bool isTied();
void tieCompleteTo(NedChordOrRest *other_chord, bool check_pitch);
int getDotCount() {return m_dot_count;}
void setDotCount(int dot_count) {m_dot_count = dot_count;}
NedBbox *getBBox() {return &m_bbox;}
void computeBbox();
void computeTies();
double getNeededSpace();
bool testMeasureSpread(int dir);
void setMidiTime(unsigned long long time);
void incrMidiTime(unsigned long long incr) {m_midi_time += incr;}
void decrMidiTime(unsigned long long incr); // {m_midi_time -= incr;}
unsigned long long getMidiTime() {return m_midi_time;}
bool isDown() {return m_beam ? !m_beam->isBeamUp() : !(m_status & STAT_UP);}
int getSorting(NedChordOrRest *other_chord);
void changeDuration(unsigned int new_duration, int tuplet_val);
NedChordOrRest *cloneWithDifferentLength(unsigned int newlen, int dotcount);
static unsigned int computeDuration(unsigned int length, int dotcount, int tuplet_val);
static void compute_fitting_duration(unsigned int sum, unsigned int *length, int *dot_count);
static NedChordOrRest *restoreChordOrRest(FILE *fp, NedVoice *voice);
NedChordOrRest *getNextChordOrRest();
NedChordOrRest *getPreviousChordOrRest();
NedChordOrRest *getFirstObjectInNextSystem();
int m_position;
int getStemDirectionOfTheMeasure(int staff_voice_offs);
double computeStemDist(bool thisup, NedChordOrRest *other_chord, bool otherup);
double getBeamOffset() {return m_beam_y_offs;}
int getSlopeOffset() {return m_slope_offs;}
void setStemHeight(double stem_height) {m_stem_height = stem_height;}
void setBeamYOffset(double beam_offset) {m_beam_y_offs = beam_offset;}
void setBeamSlopeOffset(int beam_slope_offs) {m_slope_offs = beam_slope_offs;}
void saveChordOrRest(FILE *fp);
void changeStemDir(int dir);
void saveTies(FILE *fp, bool *ties_written);
void saveFreePlaceables(FILE *fp, bool *free_placeables_written);
void prepareMutedReplay();
void resetActiveFlags();
void prepareReplay(int clef, int keysig, int octave_shift, int voice_idx, unsigned int grace_time);
void setOffset(char offs_array[115]);
int getPitchOfFirstNote();
void setInternalPitch(int pitchdist);
void hideRest(NedCommandList *command_list, bool unhide);
void shiftNotes(int linedist);
void adjustAccidentals();
void changeAccidentals(NedCommandList *command_list, int preferred_offs);
void resetMicroshift() {m_micro_shift = 0.0;}
double compute_microshift(NedChordOrRest *right_chord, int mnum, int pos);
double compute_y_shift(NedChordOrRest *other_chord, int dir);
bool hasLastTupletFlag() {return (m_tuplet_val & LAST_TUPLET_FLAG);}
void setLastTupletFlag(bool on) {if (on) m_tuplet_val |= LAST_TUPLET_FLAG; else m_tuplet_val &= (~(LAST_TUPLET_FLAG));}
void correctTiesForward();
void removeAllBackwardTies();
bool tieBackward(NedChordOrRest *prev, NedNote *note);
void setTupletVal(int tuplet_val) {m_tuplet_val = tuplet_val;}
void setTupletPtr(NedTuplet *tuplet_ptr) {m_tuplet_ptr = tuplet_ptr;}
NedTuplet *getTupletPtr() {return m_tuplet_ptr;}
int getTupletVal() {return m_tuplet_val & TUPLET_VAR_MASK;}
int getTupletValRaw() {return m_tuplet_val;}
bool isUp();
int getLine() {return m_line;}
void adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist);
char *getLyrics(int line);
void exportLilyPond(FILE *fp, int *last_line, unsigned int *midi_len, NedSlur **lily_slur, unsigned int *lyrics_map,
bool *guitar_chordnames, bool *chordname, int *breath_script, bool keep_beams);
void exportLilyGuitarChordnames(FILE *fp, int *last_line, unsigned int *midi_len);
void exportLilyFreeChordName(FILE *fp, int *last_line, unsigned int *midi_len);
void exportLilyLyrics(FILE *fp, int line_nr, int *sil_count);
void collectLyrics(NedLyricsEditor *leditor);
private:
void removeFreeDisplaceable(NedFreeReplaceable *freedisplaceable);
void addFreeDislaceable(NedFreeReplaceable *freedisplaceable);
void exportLilyAccents(FILE *fp);
void exportLilyFreePlaceablesBefore(FILE *fp);
void exportLilyFreePlaceablesAfter(FILE *fp, NedSlur **lily_slur, bool *guitar_chordnames, bool *chordnames);
GList *m_notes;
NedBeam *m_beam;
NedTuplet *m_tuplet_ptr;
int m_tuplet_val;
int m_type;
bool m_is_hidden;
unsigned int m_length;
double m_xpos, m_ypos;
unsigned int m_time;
int m_dot_count;
unsigned int m_status;
int m_line;
NedVoice *m_voice;
NedBbox m_bbox;
unsigned long long m_midi_time;
double m_tmp_xpos;
bool m_all_shifted;
double m_art_up_y_pos[MAX_ARTICULATIONS];
double m_art_down_y_pos[MAX_ARTICULATIONS];
int m_up_art_count, m_down_art_count;
NedPangoCairoText *m_lyrics[MAX_LYRICS_LINES];
GList *m_freedisp;
bool m_active;
double m_stem_end_xpos, m_stem_end_ypos;
double m_stem_height, m_stemheight_copy;
double m_beam_y_offs;
int m_slope_offs;
double m_beam_y_offs_copy;
double m_micro_shift;
int m_slope_offs_copy;
unsigned int m_status_copy;
bool m_free_texts_present, m_lyrics_present;
bool m_has_open_highhat, m_has_closed_highhat;
friend class NedNewLyricsCommand;
friend class NedDeleteLyricsCommand;
friend class NedFreeReplaceable;
friend class NedFixIntermediateCommand;
friend class NedMoveNoteRelativeCommand;
friend class NedFlipValuesCommand;
friend class NedRemoveConstraintsCommand;
friend class NedChangeLyricsCommand;
};
#endif /* CHORD_OR_REST_H */
nted-1.10.18/measure.h 0000664 0010410 0000764 00000006472 11520267230 011355 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef MEASURE_H
#define MEASURE_H
#include "config.h"
#include
#include
#include
#include "positionarray.h"
class SpecialMeasure;
class NedSystem;
class NedMainWindow;
#define SPECIAL_POSITION_NONE 0
#define SPECIAL_POSITION_START 1
#define SPECIAL_POSITION_END 2
class NedMeasure {
public:
NedMeasure();
void setSystem(NedSystem *system) {m_system = system;}
void setMeasureNumber(int num, GList *special_measures, bool force = false);
unsigned int getMeasureDuration() {return (unsigned int) (midi_end - midi_start);}
double m_staff_elements_width; // width of leading keysigs and timesigs
bool m_measure_has_only_staff_members;
int position;
int getSpecial();
void setSpecial(int type);
bool barRequiresHideFollowing();
unsigned long long midi_start, midi_end;
double start, end;
char *getNumberString() {return m_measure_number_str;}
int getMeasureNumber() {return m_measure_number;}
void draw(cairo_t *cr, int special_position, double xpos, double content_x_pos, double sys_y_pos, double top,
double bottom, double bottom_ori, double leftx, double topy, double staff_border_dist, double zoom_factor, int zoom_level, bool rep_line_needed, int spec_measure_at_end, bool out);
double getNeededSpaceBefore();
double getNeededSpaceAfter();
double shiftXpos(double extra_space_divided, double shift, bool out);
double computeAndSetPositions(double start_position, int *num_elements, double *extra_space_for_accidentals, bool *measure_has_only_staff_members /* means keysig */, bool out);
bool isNearStart(double x);
bool isNearEnd(double x);
bool nearRepeatElement(double x, double y);
unsigned int getStoredStaffCount();
void setNewStaffCount(int newstaffcount);
NedPositionArray m_position_array;
int getStemDirectionOfTheMeasure(int staff_voice_offs) {return m_position_array.getStemDirectionOfTheMeasure(staff_voice_offs);}
double m_spread_fac;
bool m_special_spread;
bool m_hide_following;
private:
int m_measure_number;
char m_measure_number_str[8];
SpecialMeasure *m_special_descr;
NedSystem *m_system;
friend class NedMainWindow;
};
#endif /* MEASURE_H */
nted-1.10.18/midiimporter.cpp 0000664 0010410 0000764 00000030711 11520267230 012744 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "midiimporter.h"
#include "idiotseditor.h"
#include "resource.h"
#include
#define NOTE_OFF 0x80
#define NOTE_ON 0x90
#define META_EVENT 0xFF
#define SYS_EXCLUSIVE_MESSAGE1 0xF0
#define SYS_EXCLUSIVE_MESSAGE2 0xF7
#define PGM_CHANGE 0xC0
#define AFTER_TOUCH 0xA0
#define CTRL_CHANGE 0xB0
#define CHANNEL_PRESSURE 0xD0
#define PITCH_BEND 0xE0
#define SONG_POS_PTR 0xF2
#define SONG_SELECT 0xF3
#define TUNE_REQU 0xF6
#define META_TEXT 0x01
#define META_TRACK_NAME 0x03
#define META_TIMESIG 0x58
#define META_KEYSIG 0x59
#define META_TEMPO 0x51
NedMidiImporter::NedMidiImporter(bool with_triplets, int tempo_change_density, int volume_change_density, bool force_piano, bool sort_instruments, bool dont_split, bool use_id_ed) :
NedImporter(), m_error_string(NULL), m_current_time(0), m_last_event_time(0), m_with_triplets(with_triplets), m_use_id_ed(use_id_ed)
{
m_idiots_editor = new NedIdiotsEditor(tempo_change_density, volume_change_density, force_piano, sort_instruments, dont_split, use_id_ed);
for (int i = 0; i < 16; m_current_midi_instrument[i++] = 0);
}
bool NedMidiImporter::import() {
int track_nr;
read_header(m_FILE);
for (track_nr = 0; track_nr < m_ntracks; track_nr++) {
readTrack(m_FILE, track_nr, 0);
if (m_current_time > m_last_event_time) m_last_event_time = m_current_time;
if (m_error_string != NULL) break;
}
if (m_error_string != NULL) {
NedResource::DbgMsg(DBG_TESTING, "%s\n", m_error_string);
return false;
}
m_idiots_editor->setLastTime(m_last_event_time);
return true;
}
bool NedMidiImporter::convertToScore() {
int i, j;
char *cptr;
m_idiots_editor->computeTimeSigMeasureNumbers(m_main_window);
m_idiots_editor->computeTempo();
m_idiots_editor->computeVolumes();
m_idiots_editor->snapStartOfNotes();
if (m_with_triplets) {
m_idiots_editor->recognizeTriplets();
}
m_idiots_editor->trySplitInstruments();
m_tempo_inverse = m_idiots_editor->m_tempo_inverse;
m_upbeat_inverse = 0;
m_partcount = m_idiots_editor->getPartCount();
for (i = 0; i < m_partcount; i++) {
m_parts[i].voices[0] = m_idiots_editor->convertToNtEdNotes(i, 0);
for (j = 1; j < VOICE_COUNT; j++) {
m_parts[i].voices[j] = m_idiots_editor->convertToNtEdNotes(i, j);
}
strcpy(m_parts[i].id, "part1");
cptr = m_idiots_editor->getInstrumentName(i);
if (cptr == NULL) {
m_parts[i].name[0] = '\0';
}
else {
if (*cptr == '\0') {
m_parts[i].name[0] = '\0';
}
else {
strcpy(m_parts[i].name, cptr);
}
}
m_parts[i].clef = m_idiots_editor->getClef(i);
m_parts[i].clef_octave = m_idiots_editor->getOctaveShift(i);
m_parts[i].key_signature = m_idiots_editor->getKeySig(i);
m_parts[i].numerator = m_idiots_editor->getNumerator();
m_parts[i].denominator = m_idiots_editor->getDenominator();
m_parts[i].midi_pgm = m_idiots_editor->getMidiPgm(i);
m_parts[i].midi_channel = m_idiots_editor->getChannel(i);
m_parts[i].volume = m_idiots_editor->getVolume(i);
}
return true;
}
NedMidiImporter::~NedMidiImporter() {
//printf("NedMidiImporter::~NedMidiImporter\n"); fflush(stdout);
delete m_idiots_editor;
}
void NedMidiImporter::read_header(FILE *fp) {
char buffer[1024];
int len;
if (fread(buffer, 1, 4, fp) != 4) {
m_error_string = "error in fread";
return;
}
buffer[4] = '\0';
if (strcmp(buffer, "MThd")) {
if (!strcmp(buffer, "RIFF")) {
if (fread(buffer, 1, 16, fp) != 16) {
m_error_string = "unexpected EOF(0)";
return;
}
if (fread(buffer, 1, 4, fp) != 4) {
m_error_string = "unexpected EOF(1)";
return;
}
buffer[4] = '\0';
if (strcmp(buffer, "MThd")) {
m_error_string = "No MIDI file";
return;
}
}
else {
m_error_string = "No MIDI file";
return;
}
}
if (!readdword(fp, &len)) {
m_error_string = "cannot read len";
return;
}
if (len != 6) {
m_error_string = "bad header length";
return;
}
if (!readword(fp, &m_format)) {
m_error_string = "cannot read format";
return;
}
if (!readword(fp, &m_ntracks)) {
m_error_string = "cannot read ntracks";
return;
}
if (!readword(fp, &m_division)) {
m_error_string = "cannot read division";
return;
}
if (m_division < 0) {
m_error_string = "cannot deal with negative divisions";
return;
}
}
void NedMidiImporter::readTrack(FILE *fp, int track_nr, int pass) {
char buffer[1024];
int len;
unsigned int tempo;
unsigned long long time_dist;
char type;
unsigned int meta_len;
unsigned char status_byte, last_status;
char sbyte, data1, data2;
int num, denom;
unsigned int chan;
struct {
long long time;
int key;
int state;
#define KEYSIG_INVALID 0
#define KEYSIG_SET 1
#define KEYSIG_NOT_RELEVANT 2
} first_keysig;
first_keysig.state = KEYSIG_INVALID;
first_keysig.time = 0;
first_keysig.key = 0;
if (fread(buffer, 1, 4, fp) != 4) {
m_error_string = "unexpected EOF(2)";
return;
}
buffer[4] = '\0';
if (strcmp(buffer, "MTrk")) {
m_error_string = "No MIDI track";
return;
}
if (!readdword(fp, &len)) {
m_error_string = "cannot read track len";
return;
}
last_status = 0;
m_current_time = 0;
while (len > 0) {
time_dist = read_val_var(fp, &len);
m_current_time += time_dist * NOTE_4 / m_division;
sbyte = getc(fp);
status_byte = sbyte;
if ((status_byte & 0x80) == 0) {
ungetc(status_byte, fp);
status_byte = last_status;
}
else {
last_status = status_byte;
len--;
}
if (status_byte == META_EVENT) {
if ((type = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(3)";
return;
}
meta_len = read_val_var(fp, &len);
if (fread(buffer, 1, meta_len, fp) != meta_len) {
m_error_string = "unexpected EOF(4)";
return;
}
len -= meta_len + 1;
switch (type) {
case META_TRACK_NAME:
buffer[meta_len] = '\0';
m_idiots_editor->setInstrumentName(buffer);
break;
case META_TIMESIG:
num = buffer[0];
switch(buffer[1]) {
case 0: denom = 1; break;
case 1: denom = 2; break;
case 2: denom = 4; break;
case 3: denom = 8; break;
default: denom =16; break;
}
NedResource::DbgMsg(DBG_TESTING, "TIMESIG: %llu(%llu): num = %d, dmon = %d\n",
m_current_time, m_current_time / NOTE_64, num, denom);
m_idiots_editor->addTimeSigChange(m_current_time, num, denom);
break;
case META_TEMPO: tempo = ((0xff & buffer[0]) << 16) | ((0xff & buffer[1]) << 8) | (0xff & buffer[2]);
m_idiots_editor->addTempoChange(m_current_time, (int) (60000000.0 / (double) tempo));
break;
case META_KEYSIG:
if (track_nr > 0 && first_keysig.state == KEYSIG_INVALID) { // avoid keysigs of empry tracks
first_keysig.time = m_current_time;
first_keysig.key = buffer[0];
first_keysig.state = KEYSIG_SET;
break;
}
m_idiots_editor->addKeySig(m_current_time, 0, buffer[0]);
break;
}
}
else if (status_byte == SYS_EXCLUSIVE_MESSAGE1 || status_byte == SYS_EXCLUSIVE_MESSAGE2) {
meta_len = read_val_var(fp, &len);
if (fread(buffer, 1, meta_len, fp) != meta_len) {
m_error_string = "unexpected EOF(5)";
return;
}
len -= meta_len;
}
else if ((status_byte & 0xf0) == NOTE_ON) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(6)";
return;
}
if ((data2 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(7)";
return;
}
len -= 2;
chan = status_byte & 0x0f;
if (chan == 9) {
m_current_midi_instrument[chan] = -1;
}
if (pass == 0) {
if (data2 == 0) {
m_idiots_editor->closeNote(data1, m_current_time, m_current_midi_instrument[chan], chan);
}
else {
/*
note = new NedTableNote(m_current_time, 0, data1, data2);
m_idiots_editor->addNote(note, m_current_midi_instrument[chan]);
*/
if (first_keysig.state == KEYSIG_SET) {
m_idiots_editor->addKeySig(first_keysig.time, 0, first_keysig.key);
first_keysig.state = KEYSIG_NOT_RELEVANT;
}
m_idiots_editor->addNote(data1, data2, m_current_time, m_current_midi_instrument[chan], chan);
}
}
}
else if ((status_byte & 0xf0) == NOTE_OFF) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(8)";
return;
}
if ((data2 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(9)";
return;
}
len -= 2;
chan = status_byte & 0x0f;
if (pass == 0) {
m_idiots_editor->closeNote(data1, m_current_time, m_current_midi_instrument[chan], chan);
}
}
else if ((status_byte & 0xf0) == AFTER_TOUCH) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(14)";
return;
}
if ((data2 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(15)";
return;
}
len -= 2;
}
else if ((status_byte & 0xf0) == CTRL_CHANGE) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(16)";
return;
}
if ((data2 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(17)";
return;
}
len -= 2;
}
else if ((status_byte & 0xf0) == PGM_CHANGE) {
chan = status_byte & 0x0f;
if ((m_current_midi_instrument[chan] = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(18)";
return;
}
if (chan == 9) {
m_current_midi_instrument[chan] = -1;
}
len -= 1;
}
else if ((status_byte & 0xf0) == CHANNEL_PRESSURE) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(19)";
return;
}
len -= 1;
}
else if ((status_byte & 0xf0) == PITCH_BEND) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(20)";
return;
}
if ((data2 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(21)";
return;
}
len -= 2;
}
else if ((status_byte & 0xF8) == 0xF8) {
}
else if (status_byte == SONG_POS_PTR) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(22)";
return;
}
if ((data2 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(23)";
return;
}
len -= 2;
}
else if (status_byte == SONG_SELECT) {
if ((data1 = getc(fp)) == EOF) {
m_error_string = "unexpected EOF(24)";
return;
}
len -= 1;
}
else if (status_byte == 0xF1) {
}
else if (status_byte == 0xF4) {
}
else if (status_byte == 0xF5) {
}
else if (status_byte == TUNE_REQU) {
}
if (len < 0) {
m_error_string = "length error";
return;
}
}
}
unsigned long NedMidiImporter::read_val_var(FILE *fp, int *len) {
unsigned long the_val;
char c;
if (*len < 0) {
m_error_string = "bad length in val(1)";
return 0;
}
(*len)--;
if ((the_val = getc(fp)) & 0x80) {
the_val &= 0x7F;
do {
if (*len < 0) {
m_error_string = "bad len in val(2)";
return 0;
}
(*len)--;
the_val = (the_val << 7) + ((c = getc(fp)) & 0x7F);
}
while (c & 0x80);
}
return the_val;
}
int NedMidiImporter::readdword(FILE *fp, int *data) {
char c[4];
int i;
for (i = 0; i < 4; i++) {
if (feof(fp)) return 0;
c[i] = getc(fp);
}
*data = (c[3] & 0xff) | ((c[2] & 0xff) << 8) |
((c[1] & 0xff) << 16)| ((c[0] & 0xff) << 24);
return 1;
}
int NedMidiImporter::readword(FILE *fp, short *data) {
char c[2];
int i;
for (i = 0; i < 2; i++) {
if (feof(fp)) return 0;
c[i] = getc(fp);
}
*data = ((c[1] & 0xff) << 0)| ((c[0] & 0xff) << 8);
return 1;
}
nted-1.10.18/chordorrest.cpp 0000664 0010410 0000764 00000474577 11520267230 012624 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include
#include "chordorrest.h"
#include "voice.h"
#include "note.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#include "tuplet.h"
#include "system.h"
#include "mainwindow.h"
#include "commandlist.h"
#include "commandhistory.h"
#include "ereasechordorrestcommand.h"
#include "changechordorreststatus.h"
#include "ereasenotecommand.h"
#include "deletechordcommand.h"
#include "flipvaluescommand.h"
#include "removeconstraintscommand.h"
#include "removefreeplaceablecommand.h"
#include "changelyricscommand.h"
#include "newlyricscommand.h"
#include "volumesign.h"
#include "temposign.h"
#include "deletelyricscommand.h"
#include "tienotescommand.h"
#include "slurpoint.h"
#include "slur.h"
#include "linepoint.h"
#include "line.h"
#include "crescendo.h"
#include "octavation.h"
#include "acceleration.h"
#include "freetext.h"
#include "freesign.h"
#include "freechord.h"
#include "chordpainter.h"
#include "chordstruct.h"
#include "freespacer.h"
#include "freechordname.h"
#include "pangocairotext.h"
#include "scoreinfodialog.h"
#include "lyricseditor.h"
#define X_POS_PAGE_REL(p) ((getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_STAFF_REL(p) (((p) + getSystem()->getYPos() + getStaff()->getBottomPos()) * zoom_factor - topy)
#define X_POS_INVERS_PAGE_REL(p) ((leftx + (p) / current_scale) / zoom_factor - getPage()->getContentXpos())
#define Y_POS_INVERS_ABS(p) ((topy + (p) / current_scale) / zoom_factor)
#define Y_POS_INVERSE_STAFF_REL(p) (((p) / current_scale + topy) / zoom_factor - getSystem()->getYPos() - getStaff()->getBottomPos())
NedChordOrRest::NedChordOrRest(NedVoice *voice, int type, bool is_hidden, int line, int dot_count, unsigned int length, int head, unsigned int status, unsigned long long time) :
m_measure(NULL), m_notes(NULL), m_beam(NULL), m_tuplet_ptr(NULL), m_tuplet_val(0), m_type(type), m_is_hidden(is_hidden), m_length(length), m_xpos(0.0), m_ypos(0.0), m_time(time), m_dot_count(dot_count), m_status(status), m_line(line), m_voice(voice), m_midi_time(time),
m_tmp_xpos(-1.0), m_all_shifted(FALSE), m_up_art_count(0), m_down_art_count(0),
m_freedisp(NULL), m_active(false), m_stem_end_xpos(0.0), m_stem_end_ypos(0.0),
m_stem_height(STEM_DEFAULT_HEIGHT), m_stemheight_copy(UNSET_STEM_HEIGHT - 10.0), m_beam_y_offs(0.0), m_slope_offs(0),
m_beam_y_offs_copy(UNSET_STEM_HEIGHT - 10.0), m_micro_shift(0.0), m_slope_offs_copy(UNSET_SLOPE_OFFS),
m_has_open_highhat(false), m_has_closed_highhat(false)
{
m_bbox.width = -0.1;
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
m_lyrics[i] = NULL;
}
if (m_length < NOTE_64) {
m_type = TYPE_GRACE;
m_dot_count = 0;
m_status = 0;
}
if (m_type == TYPE_REST) {
m_status &= (STAT_FERMATA | STAT_USER_HIDDEN_REST | STAT_USER_PLACED_REST);
m_line = 3;
m_ypos = -m_line * LINE_DIST/2.0;
if (m_length == WHOLE_NOTE) {
if (m_voice != NULL && m_voice->getVoiceNumber() > 0) {
m_is_hidden = TRUE;
}
}
}
else {
if (head == GUITAR_NOTE_STEM || head == GUITAR_NOTE_NO_STEM) {
m_line = 5;
}
NedNote *note = new NedNote(this, m_line, head, m_status);
m_notes = g_list_append(m_notes, note);
//#define OOO
#ifdef OOO
#define TTT
#ifdef TTT
static int zz;
zz++;
if (m_type == TYPE_CHORD && (zz % 3) == 0) {
//createLyrics(0, "Хěвел-");
createLyrics(0, "aaa");
}
else if (m_type == TYPE_CHORD && (zz % 3) == 1) {
//createLyrics(0, "ухăç");
createLyrics(0, "aaa");
}
else if (m_type == TYPE_CHORD) {
//createLyrics(0, "округě");
//createLyrics(0, "Ärger");
createLyrics(0, "aaa");
}
#else
static int zz;
zz++;
if ((zz % 4) == 0) {
createLyrics(0, "תדמיתה");
}
else if ((zz % 4) == 1) {
createLyrics(0, "פעילות");
}
else if ((zz % 4) == 2) {
createLyrics(0, "Хěвел-");
}
else {
//createLyrics(0, "округě");
createLyrics(0, "Ärger");
}
#endif
#endif
if (m_voice != NULL) {
reConfigure();
}
xPositNotes();
m_ypos = 0.0;
}
if (m_voice != NULL) {
computeBbox();
}
//#define VVV
#ifdef VVV
static int zz = 2;
static NedSlurPoint *slur_points[3];
if (zz >= 0 && m_type == TYPE_CHORD) {
NedSlur *slur;
//m_freedisp = g_list_append(m_freedisp, new NedVolumeSign(zz + 1, this, 0.8, 0.0, true));
slur_points[2-zz] = new NedSlurPoint(NULL, 2 - zz, this, 0.8, 0.0, true);
m_freedisp = g_list_append(m_freedisp, slur_points[2-zz]);
if (zz == 0) {
slur = new NedSlur(slur_points);
slur_points[0]->setSlur(slur);
slur_points[1]->setSlur(slur);
slur_points[2]->setSlur(slur);
}
zz--;
}
#endif
}
NedChordOrRest::NedChordOrRest(NedVoice *voice, int type, unsigned int clef_number, int octave_shift, unsigned long long time, bool dummy) : // clef
m_measure(NULL), m_notes(NULL), m_beam(NULL), m_tuplet_ptr(NULL), m_tuplet_val(0), m_type(type), m_is_hidden(false), m_length(clef_number), m_xpos(0.0), m_ypos(0.0), m_time(time), m_dot_count(octave_shift), m_status(0), m_line(3), m_voice(voice), m_midi_time(time),
m_tmp_xpos(-1.0), m_all_shifted(FALSE), m_freedisp(NULL), m_stem_end_xpos(0.0), m_stem_end_ypos(0.0),
m_stem_height(STEM_DEFAULT_HEIGHT), m_stemheight_copy(UNSET_STEM_HEIGHT - 10.0), m_beam_y_offs(0.0), m_slope_offs(0),
m_beam_y_offs_copy(UNSET_STEM_HEIGHT - 10.0), m_micro_shift(0.0), m_slope_offs_copy(UNSET_SLOPE_OFFS),
m_has_open_highhat(false), m_has_closed_highhat(false)
{
m_bbox.width = -0.1;
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
m_lyrics[i] = NULL;
}
if (m_voice != NULL) {
computeBbox();
}
}
NedChordOrRest::NedChordOrRest(NedVoice *voice, int type, int keysig, int last_keysig, unsigned long long time) : // keysig
m_measure(NULL), m_notes(NULL), m_beam(NULL), m_tuplet_ptr(NULL), m_tuplet_val(0), m_type(type), m_is_hidden(false), m_length(keysig), m_xpos(0.0), m_ypos(0.0), m_time(time), m_dot_count(last_keysig), m_status(0), m_line(3), m_voice(voice), m_midi_time(time),
m_tmp_xpos(-1.0), m_all_shifted(FALSE), m_freedisp(NULL), m_stem_end_xpos(0.0), m_stem_end_ypos(0.0),
m_stem_height(STEM_DEFAULT_HEIGHT), m_stemheight_copy(UNSET_STEM_HEIGHT - 10.0), m_beam_y_offs(0.0), m_slope_offs(0),
m_beam_y_offs_copy(UNSET_STEM_HEIGHT - 10.0), m_micro_shift(0.0), m_slope_offs_copy(UNSET_SLOPE_OFFS),
m_has_open_highhat(false), m_has_closed_highhat(false)
{
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
m_lyrics[i] = NULL;
}
if (m_voice != NULL) {
computeBbox();
}
}
NedChordOrRest::NedChordOrRest(NedVoice *voice, int type, int sub_type, unsigned long long time) : //staff sign
m_measure(NULL), m_notes(NULL), m_beam(NULL), m_tuplet_ptr(NULL), m_tuplet_val(0), m_type(type), m_is_hidden(false), m_length(0), m_ypos(0.0), m_time(time), m_dot_count(sub_type), m_status(0), m_line(3), m_voice(voice), m_midi_time(time),
m_tmp_xpos(-1.0), m_all_shifted(FALSE), m_freedisp(NULL), m_stem_end_xpos(0.0), m_stem_end_ypos(0.0),
m_stem_height(STEM_DEFAULT_HEIGHT), m_stemheight_copy(UNSET_STEM_HEIGHT - 10.0), m_beam_y_offs(0.0), m_slope_offs(0),
m_beam_y_offs_copy(UNSET_STEM_HEIGHT - 10.0), m_micro_shift(0.0), m_slope_offs_copy(UNSET_SLOPE_OFFS)
{
m_bbox.width = -0.1;
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
m_lyrics[i] = NULL;
}
if (m_voice != NULL) {
computeBbox();
}
}
NedChordOrRest::~NedChordOrRest() {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
delete ((NedNote *) lptr->data);
}
g_list_free(m_notes);
m_notes = NULL;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
delete (NedFreeReplaceable *) lptr->data;
}
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
delete m_lyrics[i];
}
}
g_list_free(m_freedisp);
m_freedisp = NULL;
}
NedChordOrRest *NedChordOrRest::clone(struct addr_ref_str **addrlist, bool keep_beam /* = false */) {
GList *lptr;
NedChordOrRest *cl = new NedChordOrRest(*this);
NedNote *note;
int i;
struct addr_ref_str *adr_ptr;
cl->m_notes = NULL;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
note = new NedNote(*((NedNote *) lptr->data));
note->setChord(cl);
if ((adr_ptr = (struct addr_ref_str *) g_try_malloc(sizeof(struct addr_ref_str))) == NULL) {
NedResource::Abort("NedChordOrRest::clone");
}
adr_ptr->ori = lptr->data;
adr_ptr->copy = (void *) note;
adr_ptr->next = *addrlist;
*addrlist = adr_ptr;
cl->m_notes = g_list_append(cl->m_notes, note);
if (!keep_beam) {
cl->m_beam = NULL;
}
}
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
cl->m_lyrics[i] = m_lyrics[i]->clone();
}
}
cl->m_freedisp = NULL;
/*
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_TEXT) {
((NedFreeReplaceable *) lptr->data)->clone(slurlist, cl, getMainWindow()->getDrawingArea(), getMainWindow());
continue;
}
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_SLUR_POINT | FREE_PLACEABLE_LINE_POINT)) == 0) continue;
((NedFreeReplaceable *) lptr->data)->clone(slurlist, cl);
}
*/
return cl;
}
int NedChordOrRest::getPosition() {
return m_voice->getPosition(this);
}
NedChordOrRest *NedChordOrRest::clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedVoice *p_voice) {
GList *lptr;
NedChordOrRest *cl = new NedChordOrRest(*this);
NedNote *note;
struct addr_ref_str *adr_ptr;
int i;
cl->m_notes = NULL;
cl->m_voice = p_voice;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
note = new NedNote(*((NedNote *) lptr->data));
note->setChord(cl);
if ((adr_ptr = (struct addr_ref_str *) g_try_malloc(sizeof(struct addr_ref_str))) == NULL) {
NedResource::Abort("NedChordOrRest::clone");
}
adr_ptr->ori = lptr->data;
adr_ptr->copy = (void *) note;
adr_ptr->next = *addrlist;
*addrlist = adr_ptr;
cl->m_notes = g_list_append(cl->m_notes, note);
cl->m_beam = NULL;
}
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
cl->m_lyrics[i] = m_lyrics[i]->clone();
}
}
cl->m_freedisp = NULL;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_TEXT) {
((NedFreeReplaceable *) lptr->data)->clone(slurlist, cl, getMainWindow()->getDrawingArea(), getMainWindow());
continue;
}
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_SLUR_POINT | FREE_PLACEABLE_LINE_POINT)) == 0) continue;
((NedFreeReplaceable *) lptr->data)->clone(slurlist, cl);
}
return cl;
}
char * NedChordOrRest::getLyrics(int line) {
if (m_lyrics[line] == NULL) return NULL;
return m_lyrics[line]->getText();
}
void NedChordOrRest::adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist) {
GList *lptr;
GList *newlist = NULL;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (lptr->data == NULL) continue;
newlist = g_list_append(newlist, lptr->data);
}
g_list_free(m_freedisp);
m_freedisp = newlist;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_SLUR_POINT)) == 0) continue;
((NedFreeReplaceable *) lptr->data)->adjust_pointers(slurlist);
}
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->adjust_pointers(addrlist);
}
}
void NedChordOrRest::setLyrics(int line, char *text) {
if (text == 0 || strlen(text) < 1) return;
if (g_utf8_strlen(text, -1) > MAX_TEXT_LENGTH) return;
m_lyrics[line] = new NedPangoCairoText(getMainWindow()->getDrawingArea()->window, text,
LYRICS_FONT, LYRICS_FONT_SLANT, LYRICS_FONT_WEIGHT, LYRICS_FONT_SIZE,
getMainWindow()->getCurrentZoomFactor(), getMainWindow()->getCurrentScale(), true);
}
void NedChordOrRest::setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor) {
GList *lptr;
char *text;
bool has_tie;
int line;
NedPangoCairoText *new_pango_text;
NedChangeLyricsCommand *change_lyrics_cmd;
if (m_type != TYPE_CHORD) return;
has_tie = false;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getTieBackward() != NULL) {
has_tie = true;
}
}
if (has_tie) {
return;
}
for (line = 0; line < MAX_LYRICS_LINES; line++) {
new_pango_text = NULL;
if (leditor->m_newchar[line]) {
text = leditor->getNextWord(line);
if (text != NULL) {
if (*text != '.' || *(text + 1) != '\0') {
if (g_utf8_strlen(text, -1) <= MAX_TEXT_LENGTH) {
if (m_lyrics[line] != NULL && !strcmp(m_lyrics[line]->getText(), text)) continue;
new_pango_text = new NedPangoCairoText(getMainWindow()->getDrawingArea()->window, text,
LYRICS_FONT, LYRICS_FONT_SLANT, LYRICS_FONT_WEIGHT, LYRICS_FONT_SIZE,
getMainWindow()->getCurrentZoomFactor(), getMainWindow()->getCurrentScale(), true);
}
}
}
}
if (m_lyrics[line] == NULL && new_pango_text == NULL) continue;
change_lyrics_cmd = new NedChangeLyricsCommand(this, line, new_pango_text);
change_lyrics_cmd->execute();
command_list->addCommand(change_lyrics_cmd);
}
}
void NedChordOrRest::setLyricsFromOldContext(NedMainWindow *main_window, int line, char *text) {
if (text == 0 || strlen(text) < 1) return;
if (g_utf8_strlen(text, -1) > MAX_TEXT_LENGTH) return;
m_lyrics[line] = new NedPangoCairoText(main_window->getDrawingArea()->window, text,
LYRICS_FONT, LYRICS_FONT_SLANT, LYRICS_FONT_WEIGHT, LYRICS_FONT_SIZE,
main_window->getCurrentZoomFactor(), main_window->getCurrentScale(), true);
}
void NedChordOrRest::createLyrics(int line, char *text) {
if (line < 0 || line >= MAX_LYRICS_LINES) {
NedResource::Abort("NedChordOrRest::createLyrics(1)");
}
if (m_type != TYPE_CHORD) return;
if (m_voice->getVoiceNumber() > 0) return;
if (text == 0 || strlen(text) < 1) return;
m_lyrics[line] = new NedPangoCairoText(getMainWindow()->getDrawingArea()->window, text,
LYRICS_FONT, LYRICS_FONT_SLANT, LYRICS_FONT_WEIGHT, LYRICS_FONT_SIZE,
getMainWindow()->getCurrentZoomFactor(), getMainWindow()->getCurrentScale(), true);
}
void NedChordOrRest::appendToLyrics(NedCommandList *command_list, int line, const char *text) {
if (line < 0 || line >= MAX_LYRICS_LINES) {
NedResource::Abort("NedChordOrRest::appendToLyrics(1)");
}
//#define RTL_TEST2
#ifdef RTL_TEST2
printf("appendToLyrics(a): string = %s : ", text);
for (unsigned int i = 0; i < strlen(text); i++) {
printf("s[%u] = 0x%x, ", i, 0xff & text[i]);
}
putchar('\n'); fflush(stdout);
#endif
if (m_voice->getVoiceNumber() > 0) return;
#ifdef RTL_TEST2
printf("appendToLyrics(b): string = %s : ", text);
for (unsigned int i = 0; i < strlen(text); i++) {
printf("s[%u] = 0x%x, ", i, 0xff & text[i]);
}
putchar('\n'); fflush(stdout);
#endif
if (m_type != TYPE_CHORD) return;
#ifdef RTL_TEST2
printf("appendToLyrics(c): string = %s : ", text);
for (unsigned int i = 0; i < strlen(text); i++) {
printf("s[%u] = 0x%x, ", i, 0xff & text[i]);
}
putchar('\n'); fflush(stdout);
#endif
if (text == NULL || strlen(text) < 1) return;
#ifdef RTL_TEST2
printf("appendToLyrics(d): string = %s : ", text);
for (unsigned int i = 0; i < strlen(text); i++) {
printf("s[%u] = 0x%x, ", i, 0xff & text[i]);
}
putchar('\n'); fflush(stdout);
#endif
//#define RTL_TEST
#ifdef RTL_TEST
static int zz = 0;
if (text[0] != '-') {
switch (zz++ % 6) {
case 0: text = "פ"; break;
case 1: text = "×¢"; break;
case 2: text = "×™"; break;
case 3: text = "ל"; break;
case 4: text = "ו"; break;
case 5: text = "ת"; break;
}
}
#endif
if (m_lyrics[line] == NULL) {
if (text == NULL || strlen(text) < 1) return;
m_lyrics[line] = new NedPangoCairoText(getMainWindow()->getDrawingArea()->window, text,
LYRICS_FONT, LYRICS_FONT_SLANT, LYRICS_FONT_WEIGHT, LYRICS_FONT_SIZE,
getMainWindow()->getCurrentZoomFactor(), getMainWindow()->getCurrentScale(), true);
command_list->addCommand(new NedNewLyricsCommand(this, line));
}
else {
m_lyrics[line]->insertAtCursorPosition( text, getMainWindow()->getCurrentZoomFactor());
}
computeBbox();
}
bool NedChordOrRest::deleteLyricsLetter(NedCommandList *command_list, int line) {
if (line < 0 || line >= MAX_LYRICS_LINES) {
NedResource::Abort("NedChordOrRest::deleteLyricsLetter(1)");
}
if (m_type != TYPE_CHORD || m_lyrics[line] == NULL) return TRUE;
if (!m_lyrics[line]->removeAtCursorPosition(getMainWindow()->getCurrentZoomFactor())) {
delete m_lyrics[line];
m_lyrics[line] = NULL;
return false;
}
computeBbox();
return true;
}
bool NedChordOrRest::setLyricsCursor(int line, int pos) {
if (line < 0 || line >= MAX_LYRICS_LINES) {
NedResource::Abort("NedChordOrRest::setLyricsCursor");
}
switch(pos) {
case LYR_CURSOR_RIGHT:
if (m_lyrics[line] == NULL) return false;
return m_lyrics[line]->moveCursor(1);
break;
case LYR_CURSOR_LEFT:
if (m_lyrics[line] == NULL) return false;
return m_lyrics[line]->moveCursor(-1);
break;
case LYR_CURSOR_END:
if (m_lyrics[line] == NULL) return false;
m_lyrics[line]->setCursorToLastPos();
break;
case LYR_CURSOR_START:
if (m_lyrics[line] == NULL) return false;
m_lyrics[line]->setCursorToFirstPos();
break;
}
return true;
}
void NedChordOrRest::setXPos2(double pos) {
m_xpos = pos;
computeBbox();
}
void NedChordOrRest::selectNextChord(int line, bool lyrics_required) {
return m_voice->selectNextChord(this, line, lyrics_required);
}
void NedChordOrRest::selectPreviousChord(int line, bool lyrics_required) {
return m_voice->selectPreviousChord(this, line, lyrics_required);
}
NedMainWindow *NedChordOrRest::getMainWindow() {return m_voice->getStaff()->getSystem()->getPage()->getMainWindow();}
NedPage *NedChordOrRest::getPage() {return m_voice->getStaff()->getSystem()->getPage();}
NedSystem *NedChordOrRest::getSystem() {return m_voice->getStaff()->getSystem();}
NedStaff *NedChordOrRest::getStaff() {return m_voice->getStaff();}
void NedChordOrRest::setToRest(bool toRest) {
if (m_type != TYPE_REST && toRest) {
if (m_beam != NULL) {
delete m_beam; // includes unbeaming other notes and unregister on voice
}
}
if (toRest) {
m_type = TYPE_REST;
}
else {
m_type = TYPE_CHORD;
}
if (m_type == TYPE_REST) {
m_ypos = - 3 * LINE_DIST/2.0;
}
else {
m_ypos = 0.0;
reConfigure();
xPositNotes();
}
computeBbox();
}
void NedChordOrRest::reposit(unsigned int pos) {
m_xpos = 1.0 + 1.0 * pos;
}
int NedChordOrRest::getPitchOfFirstNote() {
int clef, keysig, octave_shift;
bool dummy;
getStaff()->getCurrentClefAndKeysig(m_midi_time, &clef, &keysig, &octave_shift);
return ((NedNote *) g_list_first(m_notes)->data)->getPitch(clef, keysig, octave_shift, 0, &dummy, true);
}
void NedChordOrRest::setInternalPitch(int pitchdist) {
int clef, keysig, octave_shift;
GList *lptr;
getStaff()->getCurrentClefAndKeysig(m_midi_time, &clef, &keysig, &octave_shift);
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->setInternalPitch(pitchdist, clef, keysig, octave_shift);
}
}
void NedChordOrRest::hideRest(NedCommandList *command_list, bool unhide) {
if (m_type != TYPE_REST) return;
if (m_is_hidden) return;
NedChangeChordOrRestStatusCommand *chordstatus;
unsigned int newstatus = m_status;
if (unhide) {
newstatus = m_status & (~(STAT_USER_HIDDEN_REST));
}
else {
newstatus = m_status | STAT_USER_HIDDEN_REST;
}
chordstatus = new NedChangeChordOrRestStatusCommand(this, newstatus);
command_list->addCommand(chordstatus);
chordstatus->execute();
}
void NedChordOrRest::shiftNotes(int linedist) {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->shiftNoteLine(linedist);
}
reConfigure();
xPositNotes();
computeBbox();
}
void NedChordOrRest::adjustAccidentals() {
int clef, keysig, octave_shift;
GList *lptr;
getStaff()->getCurrentClefAndKeysig(m_midi_time, &clef, &keysig, &octave_shift);
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->adjustAccidental(clef, keysig, octave_shift);
}
reConfigure();
xPositNotes();
computeBbox();
}
void NedChordOrRest::changeAccidentals(NedCommandList *command_list, int preferred_offs) {
int clef, keysig, octave_shift;
GList *lptr;
getStaff()->getCurrentClefAndKeysig(m_midi_time, &clef, &keysig, &octave_shift);
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->changeAccidental(command_list, preferred_offs, clef, keysig, octave_shift);
}
reConfigure();
xPositNotes();
computeBbox();
}
void NedChordOrRest::insertNoteAt(NedNote *note, bool echo /* = FALSE */) {
staff_context_str *context;
bool dummy;
int clef, keysig, octave_shift;
int pitch;
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->isTheSame(note)) return;
}
note->setChord(this);
if (m_voice != NULL) {
context = &(getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()]);
getStaff()->getCurrentClefAndKeysig(m_midi_time, &clef, &keysig, &octave_shift);
if (echo && NedResource::m_midi_echo) {
pitch = note->getPitch(clef, keysig, octave_shift, 0, &dummy, true);
NedResource::playImmediately(context->m_midi_channel, context->voices[0].m_midi_program, 1, &pitch, context->voices[0].m_midi_volume);
}
xPositNotes();
}
m_notes = g_list_insert_sorted(m_notes, note, (gint (*)(const void*, const void*)) NedNote::compare);
}
bool NedChordOrRest::removeNoteAt(int line) {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getLine() == line) {
m_notes = g_list_delete_link(m_notes, lptr);
xPositNotes();
return g_list_length(m_notes) > 0;
}
}
NedResource::Abort("NedChordOrRest::removeNoteAt");
return FALSE;
}
NedChordOrRest *NedChordOrRest::cloneWithDifferentLength(unsigned int newlen, int dotcount) {
int line, head;
GList *lptr;
if (m_type == TYPE_REST) {
line = 3;
}
else {
NedNote *note = (NedNote *) g_list_first(m_notes)->data;
line = note->getLine();
}
if (m_notes != NULL) {
head = ((NedNote *) g_list_first(m_notes)->data)->getNoteHead();
}
else {
head = NORMAL_NOTE;
}
NedChordOrRest *newChord = new NedChordOrRest(m_voice, m_type, FALSE /* m_is_hidden */ , line, dotcount, newlen, head, m_status, 0);
if (m_type != TYPE_REST) {
lptr = g_list_first(m_notes);
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
newChord->m_notes = g_list_append(newChord->m_notes, new NedNote(newChord, ((NedNote *) lptr->data)->getLine(), ((NedNote *) lptr->data)->getNoteHead(), 0));
}
}
/* not correct, because it will be a new NedChordOrRest
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_SLUR_POINT | FREE_PLACEABLE_LINE_POINT)) != 0) continue;
((NedFreeReplaceable *) lptr->data)->clone(NULL, newChord);
}
*/
return newChord;
}
void NedChordOrRest::print() {
GList *lptr;
NedResource::DbgMsg(DBG_TESTING, "len = %u(%u) time = %llu(%llu) lines = ", m_length, m_length / NOTE_64, m_midi_time, m_midi_time /NOTE_64);
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
NedResource::DbgMsg(DBG_TESTING, " %d, ", ((NedNote *) lptr->data)->getLine());
}
}
bool NedChordOrRest::isTied() {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getTieBackward() != NULL) {
return true;
}
}
return false;
}
void NedChordOrRest::testTies() {
GList *lptr;
NedNote *n, *c;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
n = (NedNote *) lptr->data;
c = n->getTieBackward();
if (c != NULL) {
if (c->getVoice()->getVoiceNumber() != m_voice->getVoiceNumber()) {
n->removeBackwardTie();
}
}
c = n->getTieForward();
if (c != NULL ) {
if (c->getVoice()->getVoiceNumber() != m_voice->getVoiceNumber()) {
n->removeForwardTie();
}
}
}
}
void NedChordOrRest::removeAllBackwardTies() {
GList *lptr;
if (m_type == TYPE_REST) return;
for (lptr= g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->removeBackwardTie();
}
}
bool NedChordOrRest::tieBackward(NedChordOrRest *prev, NedNote *note) {
GList *lptr;
int line = note->getLine();
if (g_list_find(m_notes, note) == NULL) {
NedResource::Abort("NedChordOrRest::tieBackward");
}
for (lptr = g_list_first(prev->m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getLine() == line) {
((NedNote *) lptr->data)->setTies((NedNote *) lptr->data, note);
return true;
}
}
return false;
}
void NedChordOrRest::handleOpenTies(NedCommandList *command_list, GList *pool) {
GList *chord_ptr1, *chord_ptr2;
GList *note_ptr1, *note_ptr2;
bool check;
for (chord_ptr1 = g_list_first(pool); chord_ptr1; chord_ptr1 = g_list_next(chord_ptr1)) {
if (((NedChordOrRest *) chord_ptr1->data)->getType() != TYPE_CHORD) continue;
for (note_ptr1 = g_list_first(((NedChordOrRest *) chord_ptr1->data)->m_notes); note_ptr1; note_ptr1 = g_list_next(note_ptr1)) {
if (((NedNote *) note_ptr1->data)->getTieForward() != NULL) {
check = false;
for (chord_ptr2 = g_list_first(pool); chord_ptr2; chord_ptr2 = g_list_next(chord_ptr2)) {
if (chord_ptr1->data == chord_ptr2->data) continue;
if (((NedChordOrRest *) chord_ptr2->data)->getType() != TYPE_CHORD) continue;
for (note_ptr2 = g_list_first(((NedChordOrRest *) chord_ptr2->data)->m_notes); note_ptr2; note_ptr2 = g_list_next(note_ptr2)) {
if (((NedNote *) note_ptr1->data)->getTieForward() == (NedNote *) note_ptr2) {
check = true;
break;
}
}
}
if (!check) {
((NedNote *) note_ptr1->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD, true);
}
}
if (((NedNote *) note_ptr1->data)->getTieBackward() != NULL) {
check = false;
for (chord_ptr2 = g_list_first(pool); chord_ptr2; chord_ptr2 = g_list_next(chord_ptr2)) {
if (chord_ptr1->data == chord_ptr2->data) continue;
if (((NedChordOrRest *) chord_ptr2->data)->getType() != TYPE_CHORD) continue;
for (note_ptr2 = g_list_first(((NedChordOrRest *) chord_ptr2->data)->m_notes); note_ptr2; note_ptr2 = g_list_next(note_ptr2)) {
if (((NedNote *) note_ptr1->data)->getTieBackward() == (NedNote *) note_ptr2) {
check = true;
break;
}
}
}
if (!check) {
((NedNote *) note_ptr1->data)->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD, true);
}
}
}
}
}
bool NedChordOrRest::testForTiesToDelete(NedCommandList *command_list, unsigned int dir /* = BREAK_TIE_BACKWARD */, bool execute /* = false */) {
bool deleted_ties = FALSE, delties;
for (GList *lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
delties = ((NedNote *) lptr->data)->testForTiesToDelete(command_list, dir, execute);
deleted_ties = deleted_ties || delties;
}
return deleted_ties;
}
void NedChordOrRest::testForFreeReplaceablesToDelete(NedCommandList *command_list, GList **already_deleted, bool execute /* = false */) {
NedSlurPoint **sp;
NedLinePoint *startp, *endp, *midp;
GList *lptr;
NedFreeReplaceable * freereplaceable;
NedRemoveFreePlaceableCommand *rem_displaceable;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
switch (((NedFreeReplaceable *) lptr->data)->getType()) {
case FREE_PLACEABLE_SLUR_POINT:
sp = ((NedSlurPoint *) lptr->data)->getSlurPoints();
if (g_list_find(*already_deleted, sp[0]) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(sp[0]);
*already_deleted = g_list_append(*already_deleted, sp[0]);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
if (g_list_find(*already_deleted, sp[1]) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(sp[1]);
*already_deleted = g_list_append(*already_deleted, sp[1]);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
if (g_list_find(*already_deleted, sp[2]) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(sp[2]);
*already_deleted = g_list_append(*already_deleted, sp[2]);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
break;
case FREE_PLACEABLE_LINE_POINT:
startp = ((NedLinePoint *) lptr->data)->getLineStartPoint();
endp = ((NedLinePoint *) lptr->data)->getLineEndPoint();
if (g_list_find(*already_deleted, startp) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(startp);
*already_deleted = g_list_append(*already_deleted, startp);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
if (g_list_find(*already_deleted, endp) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(endp);
*already_deleted = g_list_append(*already_deleted, endp);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
if ((((NedLinePoint *) lptr->data)->getLine()->getLineType() & LINE_TEMPO_CHANGE) != 0) {
midp = ((NedLine3 *) ((NedLinePoint *) lptr->data)->getLine())->getLineMidPoint();
if (g_list_find(*already_deleted, midp) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(midp);
*already_deleted = g_list_append(*already_deleted, midp);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
}
break;
default:
freereplaceable = (NedFreeReplaceable *) lptr->data;
if (g_list_find(*already_deleted, freereplaceable) == NULL) {
rem_displaceable = new NedRemoveFreePlaceableCommand(freereplaceable);
*already_deleted = g_list_append(*already_deleted, freereplaceable);
command_list->addCommand(rem_displaceable);
if (execute) rem_displaceable->execute();
}
break;
}
}
}
void NedChordOrRest::testForDeleteableConstraints(NedCommandList *command_list) {
bool constraint = false;
NedRemoveConstraintsCommand *rem_constr_cmd;
NedChordOrRest *other_chord = NULL;
constraint = ((m_status & STAT_USER_STEMDIR) != 0);
constraint = constraint || (m_stem_height != STEM_DEFAULT_HEIGHT);
constraint = constraint || (m_beam_y_offs != 0.0);
constraint = constraint || (m_slope_offs != 0);
if (constraint) {
rem_constr_cmd = new NedRemoveConstraintsCommand(this);
rem_constr_cmd->execute();
command_list->addCommand(rem_constr_cmd);
}
if (m_beam == NULL) return;
if (m_beam->isFirstInBeam(this)) {
other_chord = m_beam->getLast();
}
else if (m_beam->isLastInBeam(this)) {
other_chord = m_beam->getFirst();
}
if (other_chord == NULL) return;
constraint = ((other_chord->m_status & STAT_USER_STEMDIR) != 0);
constraint = constraint || (other_chord->m_stem_height != STEM_DEFAULT_HEIGHT);
constraint = constraint || (other_chord->m_beam_y_offs != 0.0);
constraint = constraint || (other_chord->m_slope_offs != 0);
if (constraint) {
rem_constr_cmd = new NedRemoveConstraintsCommand(other_chord);
rem_constr_cmd->execute();
command_list->addCommand(rem_constr_cmd);
}
}
void NedChordOrRest::tryTieBackward() {
NedChordOrRest *previousChord = getPreviousChordOrRest();
if (previousChord == NULL) return;
if (previousChord->getType() != TYPE_CHORD) return;
previousChord->tieAllNotes(this);
}
void NedChordOrRest::correctTiesForward() {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->correctTieForward();
}
}
void NedChordOrRest::tieAllNotes(NedChordOrRest *other_chord) {
NedCommandList *command_list = NULL;
GList *lptr1, *lptr2;
for (lptr1 = g_list_first(m_notes); lptr1; lptr1 = g_list_next(lptr1)) {
for (lptr2 = g_list_first(other_chord->m_notes); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedNote *) lptr1->data)->isTheSame((NedNote *) lptr2->data)) {
NedTieNotesCommand *cmd = new NedTieNotesCommand((NedNote *) lptr1->data, (NedNote *) lptr2->data);
if (command_list == NULL) {
command_list = new NedCommandList(getMainWindow(), getSystem());
}
command_list->addCommand(cmd);
}
}
}
if (command_list != NULL) {
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
}
}
void NedChordOrRest::tieCompleteTo(NedChordOrRest *other_chord, bool check_pitch) {
GList *lptr1, *lptr2;
for (lptr1 = g_list_first(m_notes); lptr1; lptr1 = g_list_next(lptr1)) {
for (lptr2 = g_list_first(other_chord->m_notes); lptr2; lptr2 = g_list_next(lptr2)) {
((NedNote *) lptr1->data)->setTieIfSamePitch((NedNote *) lptr2->data, check_pitch);
}
}
}
void NedChordOrRest::computeTies() {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->computeTie();
}
}
bool NedChordOrRest::noConflict(int line) {
if (m_type == TYPE_REST) {
NedResource::Abort("NedChordOrRest::noConflict");
}
if (((NedNote *) g_list_first(m_notes)->data)->getNoteHead() == GUITAR_NOTE_STEM) return false;
if (((NedNote *) g_list_first(m_notes)->data)->getNoteHead() == GUITAR_NOTE_NO_STEM) return false;
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getLine() == line) {
return false;
}
}
return true;
}
int NedChordOrRest::getSorting(NedChordOrRest *other_chord) {
NedVoice *other_voice;
NedChordOrRest *c0, *c1;
int sorting;
if (other_chord == this) return SORTING_NONE;
if (getPage() != other_chord->getPage()) {
sorting = getMainWindow()->getSorting(getPage(), getStaff(), other_chord->getPage(), other_chord->getStaff());
switch (sorting) {
case SORTING_NONE: return SORTING_NONE;
case SORTING_LESS: c0 = other_chord; c1 = this; break;
default: c0 = this; c1 = other_chord; break;
}
if (!c0->getPage()->isLast(c0->getSystem())) return SORTING_NONE;
if (!c1->getPage()->isFirst(c1->getSystem())) return SORTING_NONE;
if (!c0->m_voice->isLast(c0)) return SORTING_NONE;
if (!c1->m_voice->isFirst(c1)) return SORTING_NONE;
return sorting;
}
other_voice = other_chord->m_voice;
if (m_voice != other_voice) {
sorting = getPage()->getSorting(getStaff(), getSystem(), other_chord->getStaff(), other_chord->getSystem());
switch (sorting) {
case SORTING_NONE: return SORTING_NONE;
case SORTING_LESS: c0 = other_chord; c1 = this; break;
default: c0 = this; c1 = other_chord; break;
}
if (!c0->m_voice->isLast(c0)) return SORTING_NONE;
if (!c1->m_voice->isFirst(c1)) return SORTING_NONE;
return sorting;
}
return m_voice->getSorting(this, other_chord);
}
void NedChordOrRest::reConfigure() {
int line_sum = 0;
unsigned int oldstemdir;
if (m_type == TYPE_REST) {
if (getStemDir() == STEM_DIR_NONE && !(m_status & STAT_USER_PLACED_REST)) {
m_ypos = - 3 * LINE_DIST/2.0;
}
return;
}
m_notes = g_list_sort(m_notes, (gint (*)(const void*, const void*)) NedNote::compare);
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
line_sum += ((NedNote *) lptr->data)->getLine();
}
if ((m_status & STAT_USER_STEMDIR) == 0) {
oldstemdir = (m_status & STAT_UP);
switch (getStemDir()) {
case STEM_DIR_UP: m_status |= STAT_UP; if (!oldstemdir) {xPositNotes(); computeBbox();} break;
case STEM_DIR_DOWN: m_status &= (~(STAT_UP)); if (oldstemdir) {xPositNotes(); computeBbox();} break;
default:
int c = 4 * g_list_length(m_notes);
if (line_sum < c || m_length == WHOLE_NOTE) {
m_status |= STAT_UP;
if (!oldstemdir) {
xPositNotes();
computeBbox();
}
}
else {
m_status &= (~(STAT_UP));
if (oldstemdir) {
xPositNotes();
computeBbox();
}
}
break;
}
}
if (m_beam != NULL) {
if (m_length >= NOTE_4) {
m_beam->removeChord(this);
m_beam = NULL;
}
else {
m_beam->computeBeam(getStemDir());
}
}
}
void NedChordOrRest::flipStem(NedCommandList *command_list) {
NedChangeChordOrRestStatusCommand *notestatus;
NedFlipValuesCommand *flipbeamvaluecmd1, *flipbeamvaluecmd2;
NedChordOrRest *other_chord;
unsigned int newstatus;
if (m_beam == NULL) {
newstatus = m_status;
newstatus |= STAT_USER_STEMDIR;
if ((m_status & STAT_UP) == 0) {
newstatus |= STAT_UP;
}
else {
newstatus &= (~(STAT_UP));
}
notestatus = new NedChangeChordOrRestStatusCommand(this, newstatus);
command_list->addCommand(notestatus);
notestatus->execute();
}
else if (m_beam->isFirstInBeam(this)) {
newstatus = m_status;
newstatus |= STAT_USER_STEMDIR;
if ((m_status & STAT_UP) == 0) {
newstatus |= STAT_UP;
}
else {
newstatus &= (~(STAT_UP));
}
notestatus = new NedChangeChordOrRestStatusCommand(this, newstatus);
command_list->addCommand(notestatus);
other_chord = m_beam->getLast();
if ((((newstatus & STAT_UP) == 0) && m_beam->isBeamUp()) || (((newstatus & STAT_UP) != 0) && !m_beam->isBeamUp())) {
flipbeamvaluecmd1 = new NedFlipValuesCommand(this);
command_list->addCommand(flipbeamvaluecmd1);
flipbeamvaluecmd2 = new NedFlipValuesCommand(other_chord);
command_list->addCommand(flipbeamvaluecmd2);
notestatus->execute();
flipbeamvaluecmd1->execute();
flipbeamvaluecmd2->execute();
}
else {
notestatus->execute();
}
}
else if (m_beam->isLastInBeam(this)) {
other_chord = m_beam->getFirst();
newstatus = other_chord->m_status;
newstatus |= STAT_USER_STEMDIR;
if ((newstatus & STAT_UP) == 0) {
newstatus |= STAT_UP;
}
else {
newstatus &= (~(STAT_UP));
}
notestatus = new NedChangeChordOrRestStatusCommand(other_chord, newstatus);
command_list->addCommand(notestatus);
if ((((newstatus & STAT_UP) == 0) && other_chord->m_beam->isBeamUp()) || (((newstatus & STAT_UP) != 0) && !other_chord->m_beam->isBeamUp())) {
flipbeamvaluecmd1 = new NedFlipValuesCommand(this);
command_list->addCommand(flipbeamvaluecmd1);
flipbeamvaluecmd2 = new NedFlipValuesCommand(other_chord);
command_list->addCommand(flipbeamvaluecmd2);
notestatus->execute();
flipbeamvaluecmd1->execute();
flipbeamvaluecmd2->execute();
}
else {
notestatus->execute();
}
}
}
void NedChordOrRest::setLength(int length) {
m_length = length;
unsigned int upbeat;
unsigned int measure_length;
if (m_length == WHOLE_NOTE) {
if (m_voice->getVoiceNumber() > 0) {
m_is_hidden = TRUE;
}
}
else if (m_midi_time == 0 && getMainWindow()->getUpBeatInverse() > 0) {
measure_length = getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
upbeat = measure_length - getMainWindow()->getUpBeatInverse();
if (m_voice->getVoiceNumber() > 0 && getDuration() == measure_length) {
m_is_hidden = TRUE;
}
}
}
bool NedChordOrRest::ReleaseTmpValue() {
if (m_tmp_xpos < 0.0) return FALSE;
bool ret = m_voice->setNewXpos(this, m_tmp_xpos);
m_tmp_xpos = -1.0;
if (!ret) {
getMainWindow()->reposit(NULL, getPage());
}
return ret;
}
void NedChordOrRest::changeDuration(unsigned int new_duration, int tuplet_val) {
if (m_tuplet_val != 0) {
new_duration *= tuplet_val;
new_duration /= (tuplet_val - 1);
}
compute_fitting_duration(new_duration, &m_length, &m_dot_count);
}
void NedChordOrRest::compute_fitting_duration(unsigned int sum, unsigned int *length, int *dot_count) {
unsigned int dur = NOTE_64;
while (dur <= sum && dur <= WHOLE_NOTE) {
dur <<= 1;
}
dur >>= 1;
*length = dur;
*dot_count = (*length / 2 * 3 <= sum) ? 1 : 0;
}
bool NedChordOrRest::testXShift(double x) {
double leftx = getMainWindow()->getLeftX();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
double current_scale = getMainWindow()->getCurrentScale();
double xx = X_POS_INVERS_PAGE_REL(x);
double xxdiff = xx - m_xpos;
if (xxdiff < 0.0) xxdiff = -xxdiff;
if (xxdiff > MIN_SHIFT_X_DIFF) {
m_tmp_xpos = xx;
return TRUE;
}
return FALSE;
}
void NedChordOrRest::moveToLine(int line) {
if (m_type != TYPE_REST) return;
m_line = line;
m_ypos = -m_line * LINE_DIST/2.0;
m_status |= STAT_USER_PLACED_REST;
}
void NedChordOrRest::computeBbox() {
double minx = 10000.0, miny = 10000.0;
double maxx = -10000.0, maxy = -10000.0;
double zoom_factor;
int zoom_level;
cairo_text_extents_t *extention = NULL;
NedNote *stem_start_note;
int dir, i;
double yy;
int fac, ll, lll;
double extry_y_offs = 0, off1;
double maxlyricslength;
switch (m_type) {
case TYPE_CLEF:
zoom_factor = getMainWindow()->getCurrentZoomFactor();
zoom_level = getMainWindow()->getCurrentZoomLevel();
extention = &(NedResource::fontextentions[zoom_level][3]);
m_bbox.x = extention->x_bearing / zoom_factor;
m_bbox.y = (extention->y_bearing) / zoom_factor + (m_ypos -3 * LINE_DIST/2.0);
m_bbox.width_netto = m_bbox.width = extention->width / zoom_factor;
m_bbox.height = extention->height / zoom_factor;
break;
case TYPE_KEYSIG:
lll = m_dot_count; // keysig so far
if (lll < 0) lll = -lll;
ll = (int) m_length; // "new" keysig
off1 = (ll > 0) ? (0.5 * LINE_DIST) : 0.0;
if (ll < 0) ll = -ll;
m_bbox.x = 0.0;
m_bbox.y = - 6 * LINE_DIST;
m_bbox.width_netto = m_bbox.width = (ll + lll) * (SIG_X_SHIFT /* + EXTRA_KEY_OFF */ ) + off1;
m_bbox.height = 7 * LINE_DIST;
break;
case TYPE_STAFF_SIGN:
#define BREATH_WIDTH 0.4
#define BREATH_HEIGHT (2.0 * LINE_DIST)
#define STAFF_SIGN_Y_OFFS (5.0 * LINE_DIST)
m_bbox.x = -BREATH_WIDTH / 2.0;
m_bbox.y = -STAFF_SIGN_Y_OFFS - 0.5 * BREATH_HEIGHT;
m_bbox.width_netto = m_bbox.width = BREATH_WIDTH;
m_bbox.height = BREATH_HEIGHT;
break;
case TYPE_REST:
zoom_factor = getMainWindow()->getCurrentZoomFactor();
zoom_level = getMainWindow()->getCurrentZoomLevel();
switch(m_length) {
case WHOLE_NOTE:
extry_y_offs = WHOLE_NOTE_Y_OFFS;
extention = &(NedResource::fontextentions[zoom_level][9]); break;
break;
case NOTE_2:
extry_y_offs = HALF_NOTE_Y_OFFS;
extention = &(NedResource::fontextentions[zoom_level][10]);
break;
case NOTE_4:
extention = &(NedResource::fontextentions[zoom_level][11]); break;
case NOTE_8:
extention = &(NedResource::fontextentions[zoom_level][12]); break;
case NOTE_16:
extention = &(NedResource::fontextentions[zoom_level][13]); break;
case NOTE_32:
extention = &(NedResource::fontextentions[zoom_level][14]); break;
case NOTE_64:
extention = &(NedResource::fontextentions[zoom_level][15]); break;
}
switch(m_length) {
case NOTE_2:
m_bbox.x = (extention->x_bearing - 3.2) / zoom_factor; // half rests are too close to others
m_bbox.width_netto = m_bbox.width = (extention->width + 6.4) / zoom_factor;
break;
default:
m_bbox.x = extention->x_bearing / zoom_factor;
m_bbox.width_netto = m_bbox.width = extention->width / zoom_factor;
break;
}
m_bbox.y = (extention->y_bearing) / zoom_factor + m_ypos;
m_bbox.height = extention->height / zoom_factor;
switch (m_dot_count) {
case 1: m_bbox.width_netto = (m_bbox.width += m_dot_count * HEAD_THICK + DOT1POS + extry_y_offs); break;
case 2: m_bbox.width_netto = (m_bbox.width += m_dot_count * HEAD_THICK + DOT2POS + extry_y_offs); break;
}
break;
case TYPE_CHORD:
zoom_factor = getMainWindow()->getCurrentZoomFactor();
zoom_level = getMainWindow()->getCurrentZoomLevel();
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->computeBounds(m_length, &minx, &miny, &maxx, &maxy);
}
if (m_length < NOTE_4 && m_beam == NULL && (m_status & STAT_UP)) {
if (NedResource::getFlagWidth() > maxx) maxx = NedResource::getFlagWidth();
}
if (m_beam != NULL) {
if (m_beam->isBeamUp()) {
dir = -1;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
}
else {
dir = 1;
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
}
fac = 0;
}
else {
dir = (m_status & STAT_UP) ? -1 : 1;
if (m_status & STAT_UP) {
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
}
else {
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
}
switch(m_length) {
case NOTE_32:
fac = 1; break;
case NOTE_64:
fac = 2; break;
default: fac = 0; break;
}
}
#define ARPEGGIO_X_DIST -0.4
#define ARPEGGIO_THICK 0.4
#define ARPEGGO_Y_SEGMENT_LENGTH 0.2
#define ARPEGG_EXTRA 0.2
#define ARPEGGIO_MIDI_DIST NOTE_32
if (m_length < WHOLE_NOTE) {
yy = stem_start_note->getYpos() + dir * (m_stem_height + fac * FLAG_DIST);
if (yy > maxy) maxy = yy;
if (yy < miny) miny = yy;
}
if (m_status & STAT_ARPEGGIO) {
minx += ARPEGGIO_X_DIST /* + (m_all_shifted ? HEAD_THICK : 0.0) */ + 0.1;
}
#define TREMOLO_WIDTH (LINE_DIST)
#define REAL_TREMOLO_WIDTH ( 0.7 * LINE_DIST)
#define TREMOLO_SHIFT (1.2 * LINE_DIST)
#define TREMOLO_BEAM_SHIFT (0.4 * LINE_DIST)
#define TREMOLO_THICK (0.5 * LINE_DIST)
if (m_length < WHOLE_NOTE && (m_status & TREMOLO_MASK)) {
if (dir < 0) {
if (maxx < TREMOLO_WIDTH) maxx = TREMOLO_WIDTH;
if (minx > -TREMOLO_WIDTH) minx = -TREMOLO_WIDTH;
}
else {
if (minx > -2 * TREMOLO_WIDTH) minx = -2 * TREMOLO_WIDTH;
}
}
m_bbox.x = minx; m_bbox.y = miny;
m_bbox.width_netto /* width without lyrics */ = m_bbox.width = maxx - minx;
maxlyricslength = 0.0;
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
if (m_lyrics[i]->getWidth() / getMainWindow()->getCurrentZoomFactor() / getMainWindow()->getCurrentScale() > maxlyricslength) {
maxlyricslength = m_lyrics[i]->getWidth() / getMainWindow()->getCurrentZoomFactor() / getMainWindow()->getCurrentScale();
}
}
}
#define HYPHEN_LONG 0.2
if (maxlyricslength > 0.0) {
if (maxlyricslength + HYPHEN_LONG > m_bbox.width) {
m_bbox.width = maxlyricslength + HYPHEN_LONG;
m_bbox.x = -m_bbox.width / 2.0;
m_bbox.width_netto += m_bbox.width / 2.0 - HYPHEN_LONG;
}
}
m_bbox.height = maxy - miny;
break;
case TYPE_GRACE:
zoom_factor = getMainWindow()->getCurrentZoomFactor();
zoom_level = getMainWindow()->getCurrentZoomLevel();
extention = &(NedResource::fontextentions[zoom_level][18]);
m_bbox.x = extention->x_bearing / zoom_factor;
m_bbox.y = (extention->y_bearing) / zoom_factor - ((NedNote *) g_list_first(m_notes)->data)->getLine() * LINE_DIST / 2.0;
m_bbox.width_netto = m_bbox.width = extention->width / zoom_factor;
m_bbox.height = extention->height / zoom_factor;
break;
}
}
double NedChordOrRest::compute_microshift(NedChordOrRest *right_chord, int mnum, int pos) {
//int line1, line2, dir1, dir2;
GList *lptr1, *lptr2;
double new_micro_shift;
int linedist;
bool no_conflict;
right_chord->m_micro_shift = m_micro_shift;
/* ignore the beams because they can be wrong at this moment */
/*
if (m_status & STAT_UP) {
dir1 = -1;
line1 = ((NedNote *) g_list_first(m_notes)->data)->getLine();
}
else {
dir1 = 1;
line1 = ((NedNote *) g_list_last(m_notes)->data)->getLine();
}
if (right_chord->m_status & STAT_UP) {
dir2 = -1;
line2 = ((NedNote *) g_list_first(right_chord->m_notes)->data)->getLine();
}
else {
dir2 = 1;
line2 = ((NedNote *) g_list_last(right_chord->m_notes)->data)->getLine();
}
if (dir1 * dir2 < 0 && line1 == line2) return m_micro_shift;
if (dir1 < 0 && dir2 > 0) {
if (line1 - line2 > 1) return m_micro_shift;
}
if (dir1 > 0 && dir2 < 0) {
if (line2 - line1 > 1) return m_micro_shift;
}
if (right_chord->m_bbox.y > m_bbox.y + m_bbox.height) return m_micro_shift;
if (m_bbox.y > right_chord->m_bbox.y + right_chord->m_bbox.height) return m_micro_shift;
if (right_chord->m_xpos + right_chord->m_bbox.x > m_xpos + m_bbox.x + m_bbox.width) return m_micro_shift;
if (right_chord->m_xpos + right_chord->m_bbox.x + right_chord->m_bbox.width < m_xpos + m_bbox.x) return m_micro_shift;
*/
no_conflict = true;
for (lptr1 = g_list_first(right_chord->m_notes); lptr1 && no_conflict; lptr1 = g_list_next(lptr1)) {
for (lptr2 = g_list_first(m_notes); lptr2 && no_conflict; lptr2 = g_list_next(lptr2)) {
linedist = ((NedNote *) lptr1->data)->getLine() - ((NedNote *) lptr2->data)->getLine();
if (linedist < 0) linedist = -linedist;
if (linedist > 0 && linedist < 2) no_conflict = false;
}
}
if (no_conflict) return m_micro_shift;
new_micro_shift = m_micro_shift + m_bbox.x + m_bbox.width_netto /* width without lyrics */ - (right_chord->m_bbox.x);
if (new_micro_shift > right_chord->m_micro_shift) {
right_chord->m_micro_shift = new_micro_shift;
}
return right_chord->m_micro_shift;
}
double NedChordOrRest::compute_y_shift(NedChordOrRest *other_chord, int dir) {
if (other_chord->m_bbox.y > MIN_REST_Y_VOICE_DIST + m_bbox.y + m_bbox.height) return -1.0;
if (m_bbox.y > MIN_REST_Y_VOICE_DIST + other_chord->m_bbox.y + other_chord->m_bbox.height) return -1.0;
if (other_chord->m_xpos + other_chord->m_bbox.x > m_xpos + m_bbox.x + m_bbox.width) return -1.0;
if (other_chord->m_xpos + other_chord->m_bbox.x + other_chord->m_bbox.width < m_xpos + m_bbox.x) return -1.0;
if (dir == STEM_DIR_DOWN) {
return m_bbox.y + m_bbox.height - other_chord->m_bbox.y + MIN_REST_Y_VOICE_DIST;
}
return other_chord->m_bbox.y + other_chord->m_bbox.height - m_bbox.y + MIN_REST_Y_VOICE_DIST;
}
void NedChordOrRest::sortNotes() {
m_notes = g_list_sort(m_notes, (gint (*)(const void*, const void*)) NedNote::compare);
}
void NedChordOrRest::setMidiTime(unsigned long long time) {
m_midi_time = time;
if (m_type == TYPE_REST) {
computeBbox();
}
}
void NedChordOrRest::resetYPos() {
if (m_status & STAT_USER_PLACED_REST) return;
m_ypos = - 3 * LINE_DIST/2.0;
computeBbox();
}
bool NedChordOrRest::hasUpDir() {
if (m_beam != NULL) {
return m_beam->isBeamUp();
}
return ((m_status & STAT_UP) != 0);
}
int NedChordOrRest::lengthForFlagCountComputation() {
unsigned int effective_length = m_length;
if (m_length < WHOLE_NOTE && (m_status & TREMOLO_MASK)) {
switch (m_status & TREMOLO_MASK) {
case STAT_TREMOLO1: if (m_length > NOTE_8) effective_length = NOTE_8; break;
case STAT_TREMOLO2: if (m_length > NOTE_16) effective_length = NOTE_16;break;
case STAT_TREMOLO3: if (m_length > NOTE_32) effective_length = NOTE_32;break;
case STAT_TREMOLO4: if (m_length > NOTE_64) effective_length = NOTE_64;break;
}
}
return effective_length;
}
int NedChordOrRest::numberOfFlagSigns() {
switch(m_length) {
case NOTE_8: return 1;
case NOTE_16: return 2;
case NOTE_32: return 3;
case NOTE_64: return 4;
}
return 0;
}
int NedChordOrRest::numberOfTremoloSigns() {
switch (m_status & TREMOLO_MASK) {
case STAT_TREMOLO1: return 1;
case STAT_TREMOLO2: return 2;
case STAT_TREMOLO3: return 3;
case STAT_TREMOLO4: return 4;
}
return 0;
}
void NedChordOrRest::draw(cairo_t *cr, bool *freetexts_or_lyrics_present) {
cairo_glyph_t glyph;
double leftx = getMainWindow()->getLeftX();
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
int zoom_level = getMainWindow()->getCurrentZoomLevel();
int dir, i, ll;
double sig_xpos, yl;
int flag_glyph = 0, tremolo_glyph = 0, clef_type, keysig_type, octave_shift;
double real_xpos = m_tmp_xpos < 0.0 ? m_xpos : m_tmp_xpos;
double y_start, y_stem_start, ydist;
double oct_shift_y_offs = 0.0, oct_shift_x_offs = 0.0;
double clef_y_offs = 0.0;
bool oct_shift = false;
int up_art_nr = 0, down_art_nr = 0;
double art_y_pos;
int noteline, line;
bool user_hidden_rest;
int arpeg_parts;
//#define SHOW_HIDDEN
#ifdef SHOW_HIDDEN
bool is_hidden = false;
#endif
GList *lptr;
real_xpos += m_micro_shift;
m_free_texts_present = m_lyrics_present = false;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_TEXT|FREE_PLACEABLE_CHORDNAME)) != 0) {m_free_texts_present = true; continue;}
((NedFreeReplaceable *) lptr->data)->draw(cr, leftx, topy, zoom_factor, zoom_level, getMainWindow()->getCurrentScale());
}
if (m_free_texts_present) *freetexts_or_lyrics_present = true;
switch (m_type) {
case TYPE_CLEF:
switch (m_length) { // kind
case TREBLE_CLEF: glyph.index = BASE + 2;
switch (m_dot_count) { // octave shift
case 12: oct_shift_y_offs = OCTUP_Y_TREBLE_DIST_UP; oct_shift = true; break;
case -12: oct_shift_y_offs = OCTUP_Y_TREBLE_DIST_DOWN; oct_shift = true; break;
}
break;
case ALTO_CLEF: glyph.index = BASE + 1;
switch (m_dot_count) {
case 12: oct_shift_y_offs = OCTUP_Y_ALTO_DIST_UP;
oct_shift_x_offs = OCTUP_X_ALTO_DIST;
oct_shift = true; break;
case -12: oct_shift_y_offs = OCTUP_Y_ALTO_DIST_DOWN;
oct_shift_x_offs = OCTUP_X_ALTO_DIST;
oct_shift = true; break;
}
break;
case SOPRAN_CLEF: glyph.index = BASE + 1;
switch (m_dot_count) {
case 12: oct_shift_y_offs = OCTUP_Y_ALTO_DIST_UP;
oct_shift_x_offs = OCTUP_X_ALTO_DIST;
oct_shift = true; break;
case -12: oct_shift_y_offs = OCTUP_Y_ALTO_DIST_DOWN;
oct_shift_x_offs = OCTUP_X_ALTO_DIST;
oct_shift = true; break;
}
clef_y_offs = 2 * LINE_DIST;
break;
case TENOR_CLEF: glyph.index = BASE + 1;
switch (m_dot_count) {
case 12: oct_shift_y_offs = OCTUP_Y_ALTO_DIST_UP;
oct_shift_x_offs = OCTUP_X_ALTO_DIST;
oct_shift = true; break;
case -12: oct_shift_y_offs = OCTUP_Y_ALTO_DIST_DOWN;
oct_shift_x_offs = OCTUP_X_ALTO_DIST;
oct_shift = true; break;
}
clef_y_offs = -LINE_DIST;break;
case NEUTRAL_CLEF1:
case NEUTRAL_CLEF2:
case NEUTRAL_CLEF3: glyph.index = BASE + 27;
break;
default: glyph.index = BASE + 3;
switch (m_dot_count) {
case 12: oct_shift_y_offs = OCTUP_Y_BASS_DIST_UP; oct_shift = true; break;
case -12: oct_shift_y_offs = OCTUP_Y_BASS_DIST_DOWN; oct_shift = true; break;
}
break;
}
#define CLEF_ADDITIONAL_OFFS 0.1
glyph.x = X_POS_PAGE_REL(real_xpos + CLEF_ADDITIONAL_OFFS);
glyph.y = Y_POS_STAFF_REL(m_ypos + clef_y_offs + -3 * LINE_DIST/2.0);
if (getMainWindow()->m_selected_chord_or_rest == this) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
cairo_show_glyphs(cr, &glyph, 1);
if (oct_shift) {
glyph.index = BASE + 28;
glyph.x = X_POS_PAGE_REL(real_xpos + oct_shift_x_offs + CLEF_ADDITIONAL_OFFS);
glyph.y = Y_POS_STAFF_REL(m_ypos -3 * LINE_DIST/2.0 + clef_y_offs + oct_shift_y_offs);
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_stroke(cr);
if (getMainWindow()->m_selected_chord_or_rest == this) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
break;
case TYPE_STAFF_SIGN:
switch (m_dot_count) { // sub type
case SIGN_BREATH1: glyph.index = BASE + 58; break;
case SIGN_BREATH2: glyph.index = BASE + 59; break;
}
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(m_ypos-STAFF_SIGN_Y_OFFS);
if (getMainWindow()->m_selected_chord_or_rest == this) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
cairo_show_glyphs(cr, &glyph, 1);
cairo_stroke(cr);
if (getMainWindow()->m_selected_chord_or_rest == this) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
break;
case TYPE_KEYSIG:
#define KEYSIG_ADITIONAL_X_OFFS -0.2
ll = m_dot_count;
getStaff()->getCurrentClefAndKeysig(m_time, &clef_type, &keysig_type, &octave_shift);
sig_xpos = real_xpos + KEYSIG_ADITIONAL_X_OFFS;
if (getMainWindow()->m_selected_chord_or_rest == this) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
if (ll > 0) { // keysig type so far
cairo_new_path(cr);
glyph.index = BASE + 17;
for (i = 0; i < ll; i++) {
glyph.x = X_POS_PAGE_REL(sig_xpos);
glyph.y = Y_POS_STAFF_REL(-NedStaff::m_sharpPos[clef_type][i] * LINE_DIST/2.0);
sig_xpos += SIG_X_SHIFT;
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_stroke(cr);
}
else if (ll < 0) {
cairo_new_path(cr);
glyph.index = BASE + 17;
for (i = 0; i > ll; i--) {
glyph.x = X_POS_PAGE_REL(sig_xpos);
glyph.y = Y_POS_STAFF_REL(-NedStaff::m_flatPos[clef_type][-i] * LINE_DIST/2.0);
sig_xpos += SIG_X_SHIFT;
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_stroke(cr);
}
ll = (int) m_length;
if (ll > 0) { // keysig type
cairo_new_path(cr);
glyph.index = BASE - 1;
for (i = 0; i < ll; i++) {
glyph.x = X_POS_PAGE_REL(sig_xpos);
glyph.y = Y_POS_STAFF_REL(-NedStaff::m_sharpPos[clef_type][i] * LINE_DIST/2.0);
sig_xpos += SIG_X_SHIFT;
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_stroke(cr);
}
else if (ll < 0) {
cairo_new_path(cr);
glyph.index = BASE + 16;
for (i = 0; i > ll; i--) {
glyph.x = X_POS_PAGE_REL(sig_xpos);
glyph.y = Y_POS_STAFF_REL(-NedStaff::m_flatPos[clef_type][-i] * LINE_DIST/2.0);
sig_xpos += SIG_X_SHIFT;
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_stroke(cr);
}
if (getMainWindow()->m_selected_chord_or_rest == this) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
break;
case TYPE_REST:
#ifndef SHOW_HIDDEN
if (m_is_hidden) return;
#endif
user_hidden_rest = false;
if (m_status & STAT_USER_HIDDEN_REST) {
if (getMainWindow()->getShowHidden()) {
user_hidden_rest = true;
cairo_set_source_rgb (cr, HIDD_RED, HIDD_GREEN, HIDD_BLUE);
}
else break;
}
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(m_ypos);
#ifdef SHOW_HIDDEN
if (m_is_hidden) {
m_is_hidden = true;
glyph.y = Y_POS_STAFF_REL(m_ypos + LINE_DIST / 2 * m_voice->getVoiceNumber());
}
#endif
if (m_active) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
#ifdef SHOW_HIDDEN
/*
else if (m_is_hidden) {
cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
}
*/
#endif
switch(m_length) {
case WHOLE_NOTE:
glyph.index = BASE + 9; break;
case NOTE_2:
glyph.index = BASE + 10; break;
case NOTE_4:
glyph.index = BASE + 11; break;
case NOTE_8:
glyph.index = BASE + 12; break;
case NOTE_16:
glyph.index = BASE + 13; break;
case NOTE_32:
glyph.index = BASE + 14; break;
case NOTE_64:
glyph.index = BASE + 15; break;
}
if (getMainWindow()->m_selected_chord_or_rest == this) {
if (getMainWindow()->doPaintColored()) {
switch(getVoice()->getVoiceNumber()) {
case 0: cairo_set_source_rgb (cr, DSCOLOR(V1RED), DSCOLOR(V1GREEN), DSCOLOR(V1BLUE)); break;
case 1: cairo_set_source_rgb (cr, DSCOLOR(V2RED), DSCOLOR(V2GREEN), DSCOLOR(V2BLUE)); break;
case 2: cairo_set_source_rgb (cr, DSCOLOR(V3RED), DSCOLOR(V3GREEN), DSCOLOR(V3BLUE)); break;
default: cairo_set_source_rgb (cr, DSCOLOR(V4RED), DSCOLOR(V4GREEN), DSCOLOR(V4BLUE)); break;
}
}
else {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
}
else if (!user_hidden_rest && getMainWindow()->doPaintColored()) {
switch(getVoice()->getVoiceNumber()) {
case 0: cairo_set_source_rgb (cr, DCOLOR(V1RED), DCOLOR(V1GREEN), DCOLOR(V1BLUE)); break;
case 1: cairo_set_source_rgb (cr, DCOLOR(V2RED), DCOLOR(V2GREEN), DCOLOR(V2BLUE)); break;
case 2: cairo_set_source_rgb (cr, DCOLOR(V3RED), DCOLOR(V3GREEN), DCOLOR(V3BLUE)); break;
default: cairo_set_source_rgb (cr, DCOLOR(V4RED), DCOLOR(V4GREEN), DCOLOR(V4BLUE)); break;
}
}
cairo_show_glyphs(cr, &glyph, 1);
if (m_dot_count > 0) {
double extra_x_offs, extry_y_offs;
switch (m_length) {
case WHOLE_NOTE: extra_x_offs = WHOLE_NOTE_X_OFFS;
extry_y_offs = WHOLE_NOTE_Y_OFFS;
break;
case NOTE_2: extra_x_offs = HALF_NOTE_X_OFFS;
extry_y_offs = HALF_NOTE_Y_OFFS;
break;
default: extra_x_offs = 0;
extry_y_offs = 0;
break;
}
cairo_new_path(cr);
cairo_arc(cr, X_POS_PAGE_REL(real_xpos + DOT1_REST_POS + extra_x_offs), Y_POS_STAFF_REL(m_ypos + extry_y_offs),
zoom_factor * DOT_RAD, 0, 2.0 * M_PI);
cairo_fill(cr);
if (m_dot_count > 1) {
cairo_arc(cr, X_POS_PAGE_REL(real_xpos + DOT2_REST_POS + extra_x_offs), Y_POS_STAFF_REL(m_ypos + extry_y_offs),
zoom_factor * DOT_RAD, 0, 2.0 * M_PI);
cairo_fill(cr);
}
}
if (m_status & STAT_FERMATA) {
#define REST_FERMATA_DIST -0.2
glyph.index = BASE + 45;
glyph.x = X_POS_PAGE_REL(real_xpos + REST_FERMATA_DIST);
glyph.y = Y_POS_STAFF_REL(-5 * LINE_DIST);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_active || getMainWindow()->m_selected_chord_or_rest == this || getMainWindow()->doPaintColored()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
if (user_hidden_rest) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
#ifdef SHOW_HIDDEN
if (m_is_hidden) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
#endif
break;
case TYPE_CHORD:
NedNote *start_note, *stem_start_note;
if (m_beam != NULL) {
if (m_beam->isBeamUp()) {
dir = -1;
start_note = (NedNote *) g_list_first(m_notes)->data;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
}
else {
dir = 1;
if (m_all_shifted) {
real_xpos -= HEAD_THICK;
}
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
start_note = (NedNote *) g_list_last(m_notes)->data;
}
}
else {
tremolo_glyph = BASE + 63;
dir = (m_status & STAT_UP) ? -1 : 1;
flag_glyph = (m_status & STAT_UP) ? BASE + 5 : BASE + 8;
if (m_status & STAT_UP) {
start_note = (NedNote *) g_list_first(m_notes)->data;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
}
else {
if (m_all_shifted) {
real_xpos -= HEAD_THICK;
}
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
start_note = (NedNote *) g_list_last(m_notes)->data;
}
}
y_start = start_note->getYpos();
y_stem_start = stem_start_note->getYpos();
if (((NedNote *) g_list_first(m_notes)->data)->getNoteHead() != GUITAR_NOTE_NO_STEM) {
if (m_beam == NULL) {
switch(lengthForFlagCountComputation()) {
case NOTE_2:
case NOTE_4:
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos), Y_POS_STAFF_REL(y_start));
cairo_line_to(cr, X_POS_PAGE_REL(m_stem_end_xpos = real_xpos), Y_POS_STAFF_REL(m_stem_end_ypos = (y_stem_start + dir * m_stem_height)));
cairo_stroke(cr);
break;
case NOTE_8:
glyph.index = (m_length > NOTE_8) ? tremolo_glyph : flag_glyph;
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height - ((m_length > NOTE_8) ? TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos), Y_POS_STAFF_REL(y_start));
cairo_line_to(cr, X_POS_PAGE_REL(m_stem_end_xpos = real_xpos), Y_POS_STAFF_REL(m_stem_end_ypos = (y_stem_start + dir * m_stem_height)));
cairo_stroke(cr);
break;
case NOTE_16:
glyph.index = (m_length > NOTE_8) ? tremolo_glyph : flag_glyph;
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height - ((m_length > NOTE_8) ? TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
glyph.index = (m_length > NOTE_16) ? tremolo_glyph : flag_glyph;
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height - FLAG_DIST + ((m_length > NOTE_16) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos), Y_POS_STAFF_REL(y_start));
cairo_line_to(cr, X_POS_PAGE_REL(m_stem_end_xpos = real_xpos), Y_POS_STAFF_REL(m_stem_end_ypos = (y_stem_start + dir * m_stem_height)));
cairo_stroke(cr);
break;
case NOTE_32:
glyph.index = (m_length > NOTE_8) ? tremolo_glyph : flag_glyph;
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height + FLAG_DIST + ((m_length > NOTE_8) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
glyph.index = (m_length > NOTE_16) ? tremolo_glyph : flag_glyph;
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height + ((m_length > NOTE_16) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
glyph.index = (m_length > NOTE_32) ? tremolo_glyph : flag_glyph;
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height - FLAG_DIST + ((m_length > NOTE_32) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos), Y_POS_STAFF_REL(y_start));
cairo_line_to(cr, X_POS_PAGE_REL(m_stem_end_xpos = real_xpos), Y_POS_STAFF_REL(m_stem_end_ypos = (y_stem_start + dir * (m_stem_height + FLAG_DIST))));
cairo_stroke(cr);
break;
case NOTE_64:
glyph.index = (m_length > NOTE_8) ? tremolo_glyph : flag_glyph;
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height + 2 * FLAG_DIST + ((m_length > NOTE_8) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height + FLAG_DIST + ((m_length > NOTE_16) ? -TREMOLO_SHIFT : 0)));
glyph.index = (m_length > NOTE_16) ? tremolo_glyph : flag_glyph;
cairo_show_glyphs(cr, &glyph, 1);
glyph.index = (m_length > NOTE_32) ? tremolo_glyph : flag_glyph;
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height + ((m_length > NOTE_32) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
glyph.index = (m_length > NOTE_64) ? tremolo_glyph : flag_glyph;
glyph.y = Y_POS_STAFF_REL(y_stem_start + dir * (m_stem_height - FLAG_DIST + ((m_length > NOTE_64) ? -TREMOLO_SHIFT : 0)));
cairo_show_glyphs(cr, &glyph, 1);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos), Y_POS_STAFF_REL(y_start));
cairo_line_to(cr, X_POS_PAGE_REL(m_stem_end_xpos = real_xpos), Y_POS_STAFF_REL(m_stem_end_ypos = (y_stem_start + dir * (m_stem_height + 2 * FLAG_DIST))));
cairo_stroke(cr);
break;
}
if (getMainWindow()->m_selected_chord_or_rest == this && ((getMainWindow()->getMainWindowStatus() & INSERT_EREASE_MODE) == 0)) {
if (getMainWindow()->m_selected_stem == this) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
else {
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
}
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_rectangle (cr, X_POS_PAGE_REL(m_stem_end_xpos - STEM_TOP_DIST), Y_POS_STAFF_REL(m_stem_end_ypos - STEM_TOP_DIST),
zoom_factor * 2 * STEM_TOP_DIST, zoom_factor * 2 * STEM_TOP_DIST);
cairo_stroke(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
}
else {
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos), Y_POS_STAFF_REL(y_start));
cairo_line_to(cr, X_POS_PAGE_REL(m_stem_end_xpos = real_xpos), Y_POS_STAFF_REL(m_stem_end_ypos = m_beam->getYPosAt(real_xpos)));
cairo_stroke(cr);
if (m_status & TREMOLO_MASK) {
ydist = REAL_TREMOLO_WIDTH * m_beam->getSlope();
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * TREMOLO_THICK);
for (i = numberOfFlagSigns(); i < numberOfTremoloSigns(); i++) {
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos - REAL_TREMOLO_WIDTH), Y_POS_STAFF_REL(m_stem_end_ypos + ydist - dir * (TREMOLO_BEAM_SHIFT + i * FLAG_DIST)));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + REAL_TREMOLO_WIDTH), Y_POS_STAFF_REL(m_stem_end_ypos - ydist - dir * (TREMOLO_BEAM_SHIFT + i * FLAG_DIST)));
}
cairo_stroke(cr);
}
if (getMainWindow()->m_selected_chord_or_rest == this && ((getMainWindow()->getMainWindowStatus() & INSERT_EREASE_MODE) == 0) &&
(m_beam->isFirstInBeam(this) || m_beam->isLastInBeam(this))) {
if (getMainWindow()->m_selected_stem == this) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
else {
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
}
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_rectangle (cr, X_POS_PAGE_REL(m_stem_end_xpos - STEM_TOP_DIST), Y_POS_STAFF_REL(m_stem_end_ypos - STEM_TOP_DIST),
zoom_factor * 2 * STEM_TOP_DIST, zoom_factor * 2 * STEM_TOP_DIST);
cairo_stroke(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
}
} // "notehead" != GUITAR_NOTE_NO_STEM
if (m_status & STAT_ARPEGGIO) {
cairo_new_path(cr);
glyph.index = BASE + 46;
glyph.x = X_POS_PAGE_REL(m_xpos + m_bbox.x /* + (m_all_shifted ? HEAD_THICK : 0.0) */ + 0.15);
glyph.y = Y_POS_STAFF_REL(y_start);
arpeg_parts = (int) ( (dir * (y_stem_start - y_start) + ARPEGG_EXTRA) / ARPEGGO_Y_SEGMENT_LENGTH);
cairo_show_glyphs(cr, &glyph, 1);
for (i = 1; i < arpeg_parts; i++) {
glyph.y = Y_POS_STAFF_REL(y_start + dir * i * ARPEGGO_Y_SEGMENT_LENGTH);
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_stroke(cr);
}
#define STACC_DOT_X_DIST 0.13
if (m_status & STAT_STACC) {
cairo_new_path(cr);
art_y_pos = (dir < 0) ? m_art_down_y_pos[down_art_nr++] : m_art_up_y_pos[up_art_nr++];
cairo_arc(cr, X_POS_PAGE_REL(real_xpos + dir * STACC_DOT_X_DIST), Y_POS_STAFF_REL(art_y_pos),
zoom_factor * DOT_RAD, 0, 2.0 * M_PI);
cairo_fill(cr);
}
if (m_status & STAT_STACCATISSIMO) {
cairo_new_path(cr);
art_y_pos = (dir < 0) ? m_art_down_y_pos[down_art_nr++] : m_art_up_y_pos[up_art_nr++];
#define STR_STACC_X_ARC_OFFS 0.13
#define STR_STACC_X_ARC_DIST 0.052
#define STR_STACC_Y_ARC_OFFS 0.08
#define STR_STACC_X_CONE_DIST 0.016
#define STR_STACC_HEIGHT 0.24
art_y_pos -= dir * STR_STACC_HEIGHT;
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS - STR_STACC_X_ARC_DIST),
Y_POS_STAFF_REL(art_y_pos + dir * STR_STACC_Y_ARC_OFFS));
cairo_curve_to(cr, X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS - STR_STACC_X_ARC_DIST),
Y_POS_STAFF_REL(art_y_pos + dir * STR_STACC_Y_ARC_OFFS),
X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS), Y_POS_STAFF_REL(art_y_pos),
X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS + STR_STACC_X_ARC_DIST),
Y_POS_STAFF_REL(art_y_pos + dir * STR_STACC_Y_ARC_OFFS));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS + STR_STACC_X_CONE_DIST), Y_POS_STAFF_REL(art_y_pos + dir * STR_STACC_HEIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS - STR_STACC_X_CONE_DIST), Y_POS_STAFF_REL(art_y_pos + dir * STR_STACC_HEIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * STR_STACC_X_ARC_OFFS - STR_STACC_X_ARC_DIST),
Y_POS_STAFF_REL(art_y_pos + dir * STR_STACC_Y_ARC_OFFS));
cairo_fill(cr);
}
#define TENUTO_X_DIST 0.13
#define TENUTO_LONG 0.2
#define TENUTO_LONG_2 (TENUTO_LONG / 2.0)
#define TENUTO_THICK 0.04
if (m_status & STAT_TENUTO) {
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * TENUTO_THICK);
art_y_pos = (dir < 0) ? m_art_down_y_pos[down_art_nr++] : m_art_up_y_pos[up_art_nr++];
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * TENUTO_X_DIST - TENUTO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * TENUTO_X_DIST + TENUTO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_stroke(cr);
}
if (m_status & STAT_SFORZANDO) {
#define SFORZANDO_X_DIST 0.13
#define SFORZANDO_LONG 0.2
#define SFORZANDO_LONG_2 (SFORZANDO_LONG / 2.0)
#define SFORZANDO_HIGHT 0.15
#define SFORZANDO_HIGHT_2 (SFORZANDO_HIGHT / 2.0)
#define SFORZANDO_THICK 0.04
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * SFORZANDO_THICK);
art_y_pos = (dir < 0) ? m_art_down_y_pos[down_art_nr++] : m_art_up_y_pos[up_art_nr++];
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZANDO_X_DIST - SFORZANDO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZANDO_X_DIST + SFORZANDO_LONG_2), Y_POS_STAFF_REL(art_y_pos - dir * SFORZANDO_HIGHT_2));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZANDO_X_DIST - SFORZANDO_LONG_2), Y_POS_STAFF_REL(art_y_pos - dir * SFORZANDO_HIGHT));
cairo_stroke(cr);
}
if (m_status & STAT_SFORZATO) {
#define SFORZATO_X_DIST 0.13
#define SFORZATO_LONG 0.15
#define SFORZATO_LONG_2 (SFORZATO_LONG / 2.0)
#define SFORZATO_HIGHT 0.2
#define SFORZATO_THICK1 0.08
#define SFORZATO_THICK2 0.04
cairo_new_path(cr);
if (dir > 0) {
cairo_set_line_width(cr, zoom_factor * SFORZATO_THICK1);
art_y_pos = m_art_up_y_pos[up_art_nr++];
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST - SFORZATO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST), Y_POS_STAFF_REL(art_y_pos - SFORZATO_HIGHT));
cairo_stroke(cr);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * SFORZATO_THICK2);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST), Y_POS_STAFF_REL(art_y_pos - SFORZATO_HIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST + SFORZATO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_stroke(cr);
}
else {
cairo_set_line_width(cr, zoom_factor * SFORZATO_THICK2);
art_y_pos = m_art_down_y_pos[down_art_nr++];
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST - SFORZATO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST), Y_POS_STAFF_REL(art_y_pos + SFORZATO_HIGHT));
cairo_stroke(cr);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * SFORZATO_THICK1);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST), Y_POS_STAFF_REL(art_y_pos + SFORZATO_HIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * SFORZATO_X_DIST + SFORZATO_LONG_2), Y_POS_STAFF_REL(art_y_pos));
cairo_stroke(cr);
}
}
if (m_status & STAT_BOW_UP) {
#define BOW_UP_X_DIST 0.13
#define BOW_UP_LONG 0.2
#define BOW_UP_HIGHT 0.3
#define BOW_UP_LONG_2 (BOW_UP_LONG / 2.0)
#define BOW_UP_THICK 0.04
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * BOW_UP_THICK);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_UP_X_DIST - BOW_UP_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr] - BOW_UP_HIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_UP_X_DIST), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr]));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_UP_X_DIST + BOW_UP_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++] - BOW_UP_HIGHT));
cairo_stroke(cr);
}
if (m_status & STAT_BOW_DOWN) {
#define BOW_DOWN_X_DIST 0.13
#define BOW_DOWN_LONG 0.25
#define BOW_DOWN_HIGHT 0.2
#define BOW_DOWN_UNDER 0.07
#define BOW_DOWN_LONG_2 (BOW_DOWN_LONG / 2.0)
#define BOW_DOWN_THICK1 0.04
#define BOW_DOWN_THICK2 0.08
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * BOW_DOWN_THICK1);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_DOWN_X_DIST - BOW_DOWN_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr] + BOW_DOWN_UNDER));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_DOWN_X_DIST - BOW_DOWN_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr] - BOW_DOWN_HIGHT + BOW_DOWN_UNDER));
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_DOWN_X_DIST + BOW_DOWN_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr] + BOW_DOWN_UNDER));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_DOWN_X_DIST + BOW_DOWN_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr] - BOW_DOWN_HIGHT + BOW_DOWN_UNDER));
cairo_stroke(cr);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * BOW_DOWN_THICK2);
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_DOWN_X_DIST - BOW_DOWN_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr] - BOW_DOWN_HIGHT + BOW_DOWN_UNDER));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + dir * BOW_DOWN_X_DIST + BOW_DOWN_LONG_2), Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++] - BOW_DOWN_HIGHT + BOW_DOWN_UNDER));
cairo_stroke(cr);
}
if (m_status & STAT_TRILL) {
#define PEDAL_OFF_X_DIST 0.13
#define PEDAL_ON_X_DIST 0.13
glyph.index = BASE + 33;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_has_open_highhat) {
glyph.index = BASE + 34;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_has_closed_highhat) {
glyph.index = BASE + 60;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_PRALL) {
glyph.index = BASE + 35;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_MORDENT) {
glyph.index = BASE + 36;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_TURN) {
glyph.index = BASE + 61;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_REV_TURN) {
glyph.index = BASE + 62;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_FERMATA) {
glyph.index = BASE + 45;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_up_y_pos[up_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_PED_ON) {
glyph.index = BASE + 31;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_ON_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_down_y_pos[down_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_status & STAT_PED_OFF) {
glyph.index = BASE + 32;
glyph.x = X_POS_PAGE_REL(real_xpos + dir * PEDAL_OFF_X_DIST);
glyph.y = Y_POS_STAFF_REL(m_art_down_y_pos[down_art_nr++]);
cairo_show_glyphs(cr, &glyph, 1);
}
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->draw(cr);
}
for (i = 0; !(m_lyrics_present) && i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) m_lyrics_present = true;
}
if (m_lyrics_present) *freetexts_or_lyrics_present = true;
break;
case TYPE_GRACE:
if (getMainWindow()->m_selected_chord_or_rest == this) {
if (getMainWindow()->doPaintColored()) {
switch(getVoice()->getVoiceNumber()) {
case 0: cairo_set_source_rgb (cr, DSCOLOR(V1RED), DSCOLOR(V1GREEN), DSCOLOR(V1BLUE)); break;
case 1: cairo_set_source_rgb (cr, DSCOLOR(V2RED), DSCOLOR(V2GREEN), DSCOLOR(V2BLUE)); break;
case 2: cairo_set_source_rgb (cr, DSCOLOR(V3RED), DSCOLOR(V3GREEN), DSCOLOR(V3BLUE)); break;
default: cairo_set_source_rgb (cr, DSCOLOR(V4RED), DSCOLOR(V4GREEN), DSCOLOR(V4BLUE)); break;
}
}
else {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
}
else if (getMainWindow()->doPaintColored()) {
switch(getVoice()->getVoiceNumber()) {
case 0: cairo_set_source_rgb (cr, DCOLOR(V1RED), DCOLOR(V1GREEN), DCOLOR(V1BLUE)); break;
case 1: cairo_set_source_rgb (cr, DCOLOR(V2RED), DCOLOR(V2GREEN), DCOLOR(V2BLUE)); break;
case 2: cairo_set_source_rgb (cr, DCOLOR(V3RED), DCOLOR(V3GREEN), DCOLOR(V3BLUE)); break;
default: cairo_set_source_rgb (cr, DCOLOR(V4RED), DCOLOR(V4GREEN), DCOLOR(V4BLUE)); break;
}
}
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
y_stem_start = stem_start_note->getYpos();
switch(m_length) {
case STROKEN_GRACE: glyph.index = BASE + 18; break;
case GRACE_8:
case GRACE_16: glyph.index = BASE + 19; break;
}
glyph.x = X_POS_PAGE_REL(real_xpos);
glyph.y = Y_POS_STAFF_REL(y_stem_start);
cairo_show_glyphs(cr, &glyph, 1);
if (m_beam == NULL) {
switch(m_length) {
case GRACE_16: glyph.index = BASE + 20;
glyph.y = Y_POS_STAFF_REL(y_stem_start + GRACE_HEIGHT2);
cairo_show_glyphs(cr, &glyph, 1);
case GRACE_8: glyph.index = BASE + 20;
glyph.y = Y_POS_STAFF_REL(y_stem_start + GRACE_HEIGHT1);
cairo_show_glyphs(cr, &glyph, 1);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * GRACE_STEM_THICK);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + GRACE_HEAD_THICK_HALF), Y_POS_STAFF_REL(y_stem_start));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + GRACE_HEAD_THICK_HALF), Y_POS_STAFF_REL(y_stem_start - GRACE_HEIGHT3));
cairo_stroke(cr);
break;
}
}
else {
cairo_set_line_width(cr, zoom_factor * GRACE_STEM_THICK);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(real_xpos + GRACE_HEAD_THICK_HALF), Y_POS_STAFF_REL(y_stem_start));
cairo_line_to(cr, X_POS_PAGE_REL(real_xpos + GRACE_HEAD_THICK_HALF), Y_POS_STAFF_REL(m_beam->getYPosAt(real_xpos + GRACE_HEAD_THICK_HALF)));
cairo_stroke(cr);
}
if (getMainWindow()->m_selected_chord_or_rest == this || getMainWindow()->doPaintColored()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
noteline = ((NedNote *) g_list_first(m_notes)->data)->getLine();
if (noteline < -1) {
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * AUX_LINE_THICK);
line = noteline / 2;
line *= 2;
for (; line < -1; line += 2) {
yl = - line * LINE_DIST/2.0;
cairo_move_to(cr, X_POS_PAGE_REL(m_xpos + m_micro_shift - HEAD_THICK_2 / 2.0 - AUX_LINE_OVER),
Y_POS_STAFF_REL(yl));
cairo_line_to(cr, X_POS_PAGE_REL(m_xpos + m_micro_shift + HEAD_THICK_2 / 2.0 + AUX_LINE_OVER),
Y_POS_STAFF_REL(yl));
}
cairo_stroke(cr);
}
if (noteline > 9) {
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * AUX_LINE_THICK);
line = noteline / 2;
line *= 2;
for (; line > 9; line -= 2) {
yl = - line * LINE_DIST/2.0;
cairo_move_to(cr, X_POS_PAGE_REL(m_xpos + m_micro_shift - HEAD_THICK_2 / 2.0 - AUX_LINE_OVER),
Y_POS_STAFF_REL(yl));
cairo_line_to(cr, X_POS_PAGE_REL(m_xpos + m_micro_shift + HEAD_THICK_2 / 2.0 + AUX_LINE_OVER),
Y_POS_STAFF_REL(yl));
}
cairo_stroke(cr);
}
break;
}
//#define SHOW_BBOX
#ifdef SHOW_BBOX
cairo_set_source_rgb (cr, 1.0, 0.0, 1.0);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_rectangle (cr, X_POS_PAGE_REL(m_xpos + m_micro_shift + m_bbox.x), Y_POS_STAFF_REL(m_bbox.y), zoom_factor * (m_bbox.width), zoom_factor * m_bbox.height);
cairo_stroke(cr);
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
cairo_move_to(cr, X_POS_PAGE_REL(m_xpos + m_micro_shift), Y_POS_STAFF_REL(m_bbox.y));
cairo_line_to(cr, X_POS_PAGE_REL(m_xpos + m_micro_shift), Y_POS_STAFF_REL(m_bbox.y + m_bbox.height));
cairo_stroke(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
#endif
}
void NedChordOrRest::drawTexts(cairo_t *cr, double scale, double last_left_bbox_edge, bool last) {
GList *lptr;
int line, i;
double dist;
double leftx = getMainWindow()->getLeftX();
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
if (m_free_texts_present) {
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_TEXT|FREE_PLACEABLE_CHORDNAME)) == 0) continue;
((NedFreeReplaceable *) lptr->data)->draw(cr, leftx, topy, zoom_factor, getMainWindow()->getCurrentZoomLevel(), getMainWindow()->getCurrentScale());
}
}
if (m_type != TYPE_CHORD) return;
if (!m_lyrics_present) return;
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
m_lyrics_present = true;
if (last_left_bbox_edge >= 0.0 && m_lyrics[i]->hasHiddenHyphen()) {
dist = (last_left_bbox_edge - (m_xpos + m_bbox.x + m_bbox.width - 1.5 * HYPHEN_LONG)) / 2.0;
if (dist < 0.0) dist = 0.0;
cairo_new_path(cr);
#define HYPHEN_WIDTH 0.10
#define HYPHEN_HEIGHT 0.03
#define HYPHEN_Y_OFFS (TEXT_Y_OFFS + 0.02)
cairo_rectangle(cr, X_POS_PAGE_REL(last_left_bbox_edge - dist - 0.25 * HYPHEN_LONG) * scale, Y_POS_STAFF_REL(getStaff()->getBottomYBorder() +
HYPHEN_Y_OFFS + i * LYRICS_HEIGHT) * scale,
HYPHEN_WIDTH * zoom_factor * scale, HYPHEN_HEIGHT * zoom_factor * scale);
cairo_fill(cr);
}
else if (last && m_lyrics[i]->hasHiddenHyphen()) {
cairo_new_path(cr);
cairo_rectangle(cr, X_POS_PAGE_REL(m_xpos + m_bbox.x + m_bbox.width) * scale, Y_POS_STAFF_REL(getStaff()->getBottomYBorder() +
HYPHEN_Y_OFFS + i * LYRICS_HEIGHT) * scale,
HYPHEN_WIDTH * zoom_factor * scale, HYPHEN_HEIGHT * zoom_factor * scale);
cairo_fill(cr);
}
m_lyrics[i]->draw(cr, X_POS_PAGE_REL(m_xpos + m_bbox.x) * scale, Y_POS_STAFF_REL(getStaff()->getBottomYBorder() + TEXT_Y_OFFS + i * LYRICS_HEIGHT) * scale, zoom_factor, scale);
}
}
if (!getMainWindow()->doDrawPostscript() && m_lyrics_present && ((line = getMainWindow()->getLyricsMode()) != -1) && getMainWindow()->m_selected_chord_or_rest == this) {
if (m_lyrics[line] != NULL) {
cairo_stroke(cr);
m_lyrics[line]->drawCursor(cr, scale * X_POS_PAGE_REL(m_xpos - m_bbox.width / 2.0),
scale * Y_POS_STAFF_REL(getStaff()->getBottomYBorder() + TEXT_Y_OFFS + line * LYRICS_HEIGHT), zoom_factor);
}
}
}
void NedChordOrRest::xPositNotes() {
int line_num, last_line_num;
bool shifted = false;
GList *lptr;
int dir;
double y_stem_end, up_art_offs = 0.0, down_art_offs = 0.0;
int art_line;
int i = 0, j;
m_up_art_count = m_down_art_count = 0;
NedNote *start_note, *stem_start_note;
static unsigned int freePosArticulations[] = { STAT_STACC, STAT_STACCATISSIMO, STAT_TENUTO, STAT_SFORZANDO, STAT_SFORZATO, 0};
static unsigned int upPosArticulations[] = { STAT_BOW_UP, STAT_BOW_DOWN, STAT_TRILL, STAT_OPEN, STAT_PRALL, STAT_MORDENT, STAT_TURN, STAT_REV_TURN, STAT_FERMATA, 0 };
static unsigned int downPosArticulations[] = { STAT_PED_ON, STAT_PED_OFF, 0 };
if (m_beam) {
dir = m_beam->isBeamUp() ? -1 : 1;
}
else {
dir = ((m_status & STAT_UP) != 0) ? -1 : 1;
}
m_has_open_highhat = m_has_closed_highhat = false;
if (dir < 0) {
last_line_num = -100;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr), i++) {
if (((NedNote *) lptr->data)->getNoteHead() == OPEN_HIGH_HAT) {
m_has_open_highhat = true;
}
if (((NedNote *) lptr->data)->getNoteHead() == CLOSED_HIGH_HAT) {
m_has_closed_highhat = true;
}
line_num = ((NedNote *) lptr->data)->getLine();
if (!shifted && line_num - last_line_num < 2) {
((NedNote *) lptr->data)->shiftNote(true);
shifted = true;
}
else {
((NedNote *) lptr->data)->shiftNote(false);
m_all_shifted = false;
shifted = false;
}
last_line_num = line_num;
}
start_note = (NedNote *) g_list_first(m_notes)->data;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
}
else {
m_all_shifted = true;
last_line_num = 100;
i = g_list_length(m_notes) - 1;
for (lptr = g_list_last(m_notes); lptr; lptr = g_list_previous(lptr), i--) {
if (((NedNote *) lptr->data)->getNoteHead() == OPEN_HIGH_HAT) {
m_has_open_highhat = true;
}
if (((NedNote *) lptr->data)->getNoteHead() == CLOSED_HIGH_HAT) {
m_has_closed_highhat = true;
}
line_num = ((NedNote *) lptr->data)->getLine();
if (!shifted && last_line_num - line_num < 2) {
((NedNote *) lptr->data)->shiftNote(false);
shifted = true;
m_all_shifted = false;
}
else {
((NedNote *) lptr->data)->shiftNote(true);
shifted = false;
}
last_line_num = line_num;
}
if (m_all_shifted) {
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->shiftNote(false);
}
}
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
start_note = (NedNote *) g_list_last(m_notes)->data;
}
#ifdef XXX
acc_places[0] = acc_places[1] = acc_places[2] = acc_places[3] = -10000;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->placeAccidental(FALSE /*all_shifted*/, acc_places);
}
#endif
if (m_beam) {
y_stem_end = m_beam->getYPosAt(m_xpos + m_micro_shift);
}
else if (m_length == WHOLE_NOTE || m_type == TYPE_REST) {
y_stem_end = stem_start_note->getYpos();
}
else {
y_stem_end = stem_start_note->getYpos() + dir * m_stem_height;
}
for (j = 0; freePosArticulations[j]; j++) {
if (m_status & freePosArticulations[j]) {
art_line = start_note->getLine() + 2 * dir;
switch (art_line) {
case 0: case 2: case 4: case 6: case 8: art_line += dir; break;
}
if (dir < 0) {
m_art_down_y_pos[m_down_art_count++] = -art_line * LINE_DIST/2.0 + down_art_offs;
down_art_offs += LINE_DIST;
}
else {
m_art_up_y_pos[m_up_art_count++] = -art_line * LINE_DIST/2.0 - up_art_offs;
up_art_offs += LINE_DIST;
}
}
}
for (j = 0; upPosArticulations[j]; j++) {
if (j == 3 && (m_has_open_highhat || m_has_closed_highhat)) {
if (dir < 0) {
m_art_up_y_pos[m_up_art_count] = y_stem_end - LINE_DIST;
}
else {
art_line = start_note->getLine() + 2 * dir;
m_art_up_y_pos[m_up_art_count] = -art_line * LINE_DIST/2.0;
}
if (m_art_up_y_pos[m_up_art_count] > -5 * LINE_DIST) m_art_up_y_pos[m_up_art_count] = -5 * LINE_DIST;
m_up_art_count++;
continue;
}
if (m_status & upPosArticulations[j]) {
if (dir < 0) {
m_art_up_y_pos[m_up_art_count] = y_stem_end - LINE_DIST;
}
else {
art_line = start_note->getLine() + 2 * dir;
m_art_up_y_pos[m_up_art_count] = -art_line * LINE_DIST/2.0;
}
if (m_art_up_y_pos[m_up_art_count] > -5 * LINE_DIST) m_art_up_y_pos[m_up_art_count] = -5 * LINE_DIST;
m_art_up_y_pos[m_up_art_count] -= up_art_offs;
if (upPosArticulations[j] & (STAT_BOW_UP | STAT_BOW_DOWN)) {
up_art_offs += 2.5*LINE_DIST;
}
else if (upPosArticulations[j] & (STAT_FERMATA)) {
up_art_offs += 2.8*LINE_DIST;
}
else {
up_art_offs += 2 * LINE_DIST;
}
m_up_art_count++;
}
}
for (j = 0; downPosArticulations[j]; j++) {
if (m_status & downPosArticulations[j]) {
if (dir < 0) {
art_line = start_note->getLine() + 2 * dir;
m_art_down_y_pos[m_down_art_count] = -art_line * LINE_DIST/2.0;
}
else {
m_art_down_y_pos[m_down_art_count] = y_stem_end + LINE_DIST;
}
if (m_art_down_y_pos[m_down_art_count] < LINE_DIST) m_art_down_y_pos[m_down_art_count] = LINE_DIST;
m_art_down_y_pos[m_down_art_count] += down_art_offs;
down_art_offs += 2 * LINE_DIST;
m_down_art_count++;
}
}
}
bool NedChordOrRest::testMeasureSpread(int dir) {
if (m_measure == NULL) return false;
if (m_measure->m_spread_fac + dir * MEASURE_SPREAD_STEP > MEASURE_MAX_SPREAD) return false;
if (m_measure->m_spread_fac + dir * MEASURE_SPREAD_STEP < MEASURE_MIN_SPREAD) return false;
return true;
}
void NedChordOrRest::collectNotesWithAccidentals(unsigned int *num_notes_with_accidentals, NedNote **note_field) {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->collectNotesWithAccidentals(num_notes_with_accidentals, note_field);
}
}
double NedChordOrRest::getBeamXPos() {
if (m_type == TYPE_GRACE) return m_xpos + m_micro_shift + GRACE_HEAD_THICK_HALF;
if (m_all_shifted) return m_xpos + m_micro_shift - HEAD_THICK;
return m_xpos + m_micro_shift;
}
double NedChordOrRest::getStemTop() {
NedNote *stem_start_note;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
double y_stem_start = stem_start_note->getYpos();
if (m_type == TYPE_GRACE) {
return y_stem_start - GRACE_HEIGHT3;
}
switch(lengthForFlagCountComputation()) {
case NOTE_32:
return y_stem_start - m_stem_height - FLAG_DIST;
case NOTE_64:
return y_stem_start - m_stem_height - 2 * FLAG_DIST;
}
return y_stem_start - m_stem_height;
}
double NedChordOrRest::getTopOfChordOrRest() {
if (m_type == TYPE_REST) {
return -3 * LINE_DIST / 2.0;
}
NedNote *stem_start_note;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
double y_stem_start = stem_start_note->getYpos();
if (!(m_status & STAT_UP)) {
return y_stem_start - 0.1;
}
if (m_beam != NULL) {
return m_beam->getTopOfBeam();
}
switch(lengthForFlagCountComputation()) {
case NOTE_32:
return y_stem_start - m_stem_height - FLAG_DIST;
case NOTE_64:
return y_stem_start - m_stem_height - 2 * FLAG_DIST;
}
return y_stem_start - m_stem_height;
}
double NedChordOrRest::getBottomOfChordOrRest() {
if (m_type == TYPE_REST) {
return -3 * LINE_DIST / 2.0;
}
NedNote *stem_start_note;
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
double y_stem_start = stem_start_note->getYpos();
if (m_status & STAT_UP) {
return y_stem_start + 0.1;
}
if (m_beam != NULL) {
return m_beam->getBottomOfBeam();
}
switch(lengthForFlagCountComputation()) {
case NOTE_32:
return y_stem_start + m_stem_height + FLAG_DIST;
case NOTE_64:
return y_stem_start + m_stem_height + 2 * FLAG_DIST;
}
return y_stem_start + m_stem_height;
}
double NedChordOrRest::getStemBottom() {
NedNote *stem_start_note;
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
double y_stem_start = stem_start_note->getYpos();
switch(lengthForFlagCountComputation()) {
case NOTE_32:
return y_stem_start + m_stem_height + FLAG_DIST;
case NOTE_64:
return y_stem_start + m_stem_height + 2 * FLAG_DIST;
}
return y_stem_start + m_stem_height;
}
int NedChordOrRest::getStemDir() {
if (m_measure == NULL) return STEM_DIR_NONE;
return m_measure->getStemDirectionOfTheMeasure(
getStaff()->getStaffNumber() * VOICE_COUNT + m_voice->getVoiceNumber());
}
/*
double getTopPos() {
if (m_status & STAT_UP) {
return getStemTop();
}
return getStemBottom();
}
*/
double NedChordOrRest::getStemYStart() {
NedNote *start_note;
if (m_status & STAT_UP) {
start_note = (NedNote *) g_list_first(m_notes)->data;
}
else {
start_note = (NedNote *) g_list_last(m_notes)->data;
}
return start_note->getYpos();
}
void NedChordOrRest::getTopBotY(int *lyrics_lines, double *topy, double *boty/* , bool *topFix, bool *botFix*/) {
int dir;
NedNote *start_note, *stem_start_note;
double endposoffs = 0.0;
double y_start;
double freetop;
int i;
GList *lptr;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if ((((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_CHORD | FREE_PLACEABLE_SPACER | FREE_PLACEABLE_CHORDNAME)) == 0) continue;
freetop = ((NedFreeReplaceable *) lptr->data)->getTop();
//if (!*topFix) {
if (freetop < *topy) {
*topy = freetop;
//if (((NedFreeReplaceable *) lptr->data)->getType() & FREE_PLACEABLE_SPACER) {
//*topFix = true;
//}
}
//}
if (((NedFreeReplaceable *) lptr->data)->getType() & FREE_PLACEABLE_CHORD) return;
//if (!*botFix) {
if (freetop + 4 * LINE_DIST > *boty) {
*boty = freetop + 4 * LINE_DIST;
//*botFix = true;
}
//}
return;
}
if (m_type == TYPE_REST) {
if (m_is_hidden) {
*topy = *boty = 3 * LINE_DIST / 2.0;
}
else {
*topy = m_bbox.y + 4 * LINE_DIST;
*boty = m_bbox.y + m_bbox.height + 4 * LINE_DIST;
}
return;
}
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL && *lyrics_lines < (i + 1)) {
*lyrics_lines = (i + 1);
}
}
if (m_beam != NULL) {
if (m_beam->isBeamUp()) {
dir = -1;
}
else {
dir = 1;
}
}
else {
dir = (m_status & STAT_UP) ? -1 : 1;
}
if (dir == -1) {
start_note = (NedNote *) g_list_first(m_notes)->data;
stem_start_note = (NedNote *) g_list_last(m_notes)->data;
y_start = start_note->getYpos() + HEAD_THICK_HALF;
}
else {
stem_start_note = (NedNote *) g_list_first(m_notes)->data;
start_note = (NedNote *) g_list_last(m_notes)->data;
y_start = start_note->getYpos() - HEAD_THICK_HALF;
}
if (m_length > NOTE_2) {
*boty = 4 * LINE_DIST + y_start;
*topy = 4 * LINE_DIST + stem_start_note->getYpos();
}
else if (m_beam != NULL) {
if (dir == -1) {
*boty = 4 * LINE_DIST + y_start;
*topy = 4 * LINE_DIST + m_beam->getYPosAt(m_xpos + m_micro_shift);
}
else {
*topy = 4 * LINE_DIST + y_start;
*boty = 4 * LINE_DIST + m_beam->getYPosAt(m_xpos + m_micro_shift);
}
/*
*topy = 4 * LINE_DIST + m_beam->getTopOfBeam();
*boty = 4 * LINE_DIST + m_beam->getBottomOfBeam();
*/
}
else {
switch(lengthForFlagCountComputation()) {
case NOTE_2:
case NOTE_4:
case NOTE_8:
case NOTE_16:
endposoffs = m_stem_height;
break;
case NOTE_32:
endposoffs = m_stem_height + FLAG_DIST;
break;
case NOTE_64:
endposoffs = m_stem_height + 2 * FLAG_DIST;
break;
}
}
double y_stem_start = stem_start_note->getYpos();
if (dir == -1) {
if (m_beam == NULL) {
*topy = 4 * LINE_DIST + y_stem_start - endposoffs;
*boty = 4 * LINE_DIST + y_start;
}
if (m_up_art_count > 0 && m_art_up_y_pos[m_up_art_count-1] + 3 * LINE_DIST < *topy) *topy = m_art_up_y_pos[m_up_art_count-1] + 3 * LINE_DIST;
if (m_down_art_count > 0 && m_art_down_y_pos[m_down_art_count-1] + 5 * LINE_DIST > *boty) *boty = m_art_down_y_pos[m_down_art_count-1] + 5 * LINE_DIST ;
}
else {
if (m_beam == NULL) {
*boty = 4 * LINE_DIST + (y_stem_start + endposoffs);
*topy = 4 * LINE_DIST + y_start;
}
if (m_up_art_count > 0 && m_art_up_y_pos[m_up_art_count-1] + 3 * LINE_DIST < *topy)
*topy = m_art_up_y_pos[m_up_art_count-1] + 3 * LINE_DIST;
if (m_down_art_count > 0 && m_art_down_y_pos[m_down_art_count-1] + 5 * LINE_DIST > *boty) *boty = m_art_down_y_pos[m_down_art_count-1] + 5 * LINE_DIST ;
}
}
bool NedChordOrRest::isUp() {
if (m_beam != NULL) {
return m_beam->isBeamUp();
}
return (m_status & STAT_UP);
}
double NedChordOrRest::computeStemDist(bool thisup, NedChordOrRest *other_chord, bool otherup) {
double d, dist = 0.0;
int dir;
double thisypos, otherypos;
NedNote *this_stem_start_note, *other_stem_start_note;
if (m_type == TYPE_REST || other_chord->m_type == TYPE_REST) return 0.0;
dir = thisup ? 1 : -1;
if (dir > 0) {
this_stem_start_note = (NedNote *) g_list_first(m_notes)->data;
}
else {
this_stem_start_note = (NedNote *) g_list_last(m_notes)->data;
}
thisypos = this_stem_start_note->getYpos() + dir * m_stem_height;
dir = otherup ? 1 : -1;
if (dir > 0) {
other_stem_start_note = (NedNote *) g_list_first(other_chord->m_notes)->data;
}
else {
other_stem_start_note = (NedNote *) g_list_last(other_chord->m_notes)->data;
}
otherypos = other_stem_start_note->getYpos() + dir * m_stem_height;
d = otherypos - this_stem_start_note->getYpos();
if (d < 0.0) d = -d;
dist += d;
d = thisypos - other_stem_start_note->getYpos();
if (d < 0.0) d = -d;
dist += d;
return dist;
}
int NedChordOrRest::getLineOfLowestNote() {
if ((m_type & TYPE_CHORD) == 0) return 0;
return ((NedNote *) g_list_first(m_notes)->data)->getLine();
}
int NedChordOrRest::getLineOfFirstNote() {
if ((m_type & TYPE_CHORD) == 0) return 0;
if (m_beam) {
if (m_beam->isBeamUp()) {
return ((NedNote *) g_list_first(m_notes)->data)->getLine();
}
return ((NedNote *) g_list_last(m_notes)->data)->getLine();
}
if (m_status & STAT_UP) {
return ((NedNote *) g_list_first(m_notes)->data)->getLine();
}
return ((NedNote *) g_list_last(m_notes)->data)->getLine();
}
int NedChordOrRest::compareMidiTimes(NedChordOrRest *c1, NedChordOrRest *c2) {
if (c1->m_midi_time < c2->m_midi_time) return -1;
if (c1->m_midi_time == c2->m_midi_time) return 0;
return 1;
}
int NedChordOrRest::compareMidiTimesAndTypes(NedChordOrRest *c1, NedChordOrRest *c2) {
if (c1->m_midi_time < c2->m_midi_time) return -1;
if (c1->m_midi_time > c2->m_midi_time) return 1;
if (c1->getType() == c2->getType()) return 0;
if (c1->getType() < c2->getType()) return -1; // TYPE_CLEF < TYPE_KEYSIG
return 1;
}
void NedChordOrRest::shiftY(double y) {
m_ypos += y;
computeBbox();
}
void NedChordOrRest::setRestsY(double y) {
if (m_status & STAT_USER_PLACED_REST) return;
m_ypos = - 3 * LINE_DIST/2.0 + y;
computeBbox();
}
void NedChordOrRest::setXPos(double pos) {
m_xpos = pos;
}
void NedChordOrRest::shiftX(double x) {
m_xpos += x;
}
void NedChordOrRest::recomputeFreeReplaceables() {
GList *lptr;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
((NedFreeReplaceable *) lptr->data)->recompute();
}
}
void NedChordOrRest::changeStemDir(int dir) {
unsigned int upbeat;
unsigned int measure_length;
if (m_type == TYPE_REST) {
if (m_length != WHOLE_NOTE) {
if (getSystem()->getSystemNumber() > 0) {
m_is_hidden = FALSE;
return;
}
if (getMainWindow()->getUpBeatInverse() == 0) {
m_is_hidden = FALSE;
return;
}
if (m_midi_time != getMainWindow()->getUpBeatInverse()) {
m_is_hidden = FALSE;
return;
}
measure_length = getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
upbeat = measure_length - getMainWindow()->getUpBeatInverse();
if (getDuration() != upbeat) {
m_is_hidden = FALSE;
}
}
return;
}
if (m_status & STAT_USER_STEMDIR) return;
bool changed = FALSE;
switch(dir) {
case STEM_DIR_UP: if (m_status & STAT_UP) break; changed = TRUE; m_status |= STAT_UP; break;
case STEM_DIR_DOWN: if (!(m_status & STAT_UP)) break; changed = TRUE; m_status &= (~(STAT_UP)); break;
default: reConfigure(); changed = TRUE; break;
}
if (changed) {
xPositNotes();
computeBbox();
}
}
void NedChordOrRest::setStatus(unsigned int status) {
if (m_type == TYPE_REST) {
status &= (STAT_FERMATA | STAT_USER_HIDDEN_REST | STAT_USER_PLACED_REST);
m_status = status;
}
else if (m_type != TYPE_CHORD) return;
m_status = status;
}
bool NedChordOrRest::trySelect(double x, double y, bool only_free_placeables) {
int zoom_level;
double leftx, topy;
double zoom_factor;
double current_scale = getMainWindow()->getCurrentScale();
double xl, yl;
GList *lptr;
cairo_text_extents_t *extention = NULL;
if (m_freedisp) {
leftx = getMainWindow()->getLeftX();
topy = getMainWindow()->getTopY();
zoom_factor = getMainWindow()->getCurrentZoomFactor();
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->trySelect(x, y, zoom_factor, current_scale, leftx, topy)) {
return TRUE;
}
}
}
if (only_free_placeables) return FALSE;
switch (m_type) {
case TYPE_CLEF:
zoom_level = getMainWindow()->getCurrentZoomLevel();
leftx = getMainWindow()->getLeftX();
topy = getMainWindow()->getTopY();
zoom_factor = getMainWindow()->getCurrentZoomFactor();
xl = X_POS_INVERS_PAGE_REL(x);
yl = Y_POS_INVERS_ABS(y);
switch (m_length) {
case TREBLE_CLEF:
extention = &(NedResource::fontextentions[zoom_level][2]); break;
case BASS_CLEF:
extention = &(NedResource::fontextentions[zoom_level][3]); break;
case ALTO_CLEF:
case SOPRAN_CLEF:
case TENOR_CLEF:
extention = &(NedResource::fontextentions[zoom_level][1]); break;
case NEUTRAL_CLEF1:
case NEUTRAL_CLEF2:
case NEUTRAL_CLEF3:
extention = &(NedResource::fontextentions[zoom_level][27]); break;
}
if (getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos + extention->y_bearing / zoom_factor < yl &&
getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos + (extention->y_bearing + extention->height) / zoom_factor > yl &&
m_xpos + extention->x_bearing / zoom_factor < xl &&
m_xpos + (extention->x_bearing + extention->width) / zoom_factor > xl) {
getMainWindow()->m_selected_chord_or_rest = this;
return TRUE;
}
return FALSE;
case TYPE_STAFF_SIGN:
leftx = getMainWindow()->getLeftX();
zoom_factor = getMainWindow()->getCurrentZoomFactor();
topy = getMainWindow()->getTopY();
xl = X_POS_INVERS_PAGE_REL(x);
yl = Y_POS_INVERS_ABS(y);
if (getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos + m_bbox.y < yl &&
getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos + (m_bbox.y + m_bbox.height) > yl &&
m_xpos + m_bbox.x < xl &&
m_xpos + m_bbox.x + m_bbox.width > xl) {
getMainWindow()->m_selected_chord_or_rest = this;
return TRUE;
}
return FALSE;
case TYPE_KEYSIG:
zoom_level = getMainWindow()->getCurrentZoomLevel();
leftx = getMainWindow()->getLeftX();
topy = getMainWindow()->getTopY();
zoom_factor = getMainWindow()->getCurrentZoomFactor();
xl = X_POS_INVERS_PAGE_REL(x);
yl = Y_POS_INVERS_ABS(y);
if (getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos - m_bbox.height < yl && getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos > yl &&
m_xpos < xl && m_xpos + m_bbox.width > xl) {
getMainWindow()->m_selected_chord_or_rest = this;
return TRUE;
}
return FALSE;
case TYPE_REST:
zoom_level = getMainWindow()->getCurrentZoomLevel();
leftx = getMainWindow()->getLeftX();
topy = getMainWindow()->getTopY();
zoom_factor = getMainWindow()->getCurrentZoomFactor();
xl = X_POS_INVERS_PAGE_REL(x);
yl = Y_POS_INVERS_ABS(y);
switch(m_length) {
case WHOLE_NOTE:
extention = &(NedResource::fontextentions[zoom_level][9]); break;
case NOTE_2:
extention = &(NedResource::fontextentions[zoom_level][10]); break;
case NOTE_4:
extention = &(NedResource::fontextentions[zoom_level][11]); break;
case NOTE_8:
extention = &(NedResource::fontextentions[zoom_level][12]); break;
case NOTE_16:
extention = &(NedResource::fontextentions[zoom_level][13]); break;
case NOTE_32:
extention = &(NedResource::fontextentions[zoom_level][14]); break;
case NOTE_64:
extention = &(NedResource::fontextentions[zoom_level][15]); break;
}
if (getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos + extention->y_bearing / zoom_factor < yl &&
getSystem()->getYPos() + getStaff()->getBottomPos() + m_ypos + (extention->y_bearing + extention->height) / zoom_factor > yl &&
m_xpos + extention->x_bearing / zoom_factor < xl &&
m_xpos + (extention->x_bearing + extention->width) / zoom_factor > xl) {
getMainWindow()->m_selected_chord_or_rest = this;
return TRUE;
}
return FALSE;
case TYPE_GRACE:
zoom_level = getMainWindow()->getCurrentZoomLevel();
leftx = getMainWindow()->getLeftX();
topy = getMainWindow()->getTopY();
zoom_factor = getMainWindow()->getCurrentZoomFactor();
xl = X_POS_INVERS_PAGE_REL(x);
yl = Y_POS_INVERS_ABS(y);
if (getSystem()->getYPos() + getStaff()->getBottomPos() + m_bbox.y < yl && getSystem()->getYPos() + getStaff()->getBottomPos() + m_bbox.y + m_bbox.height > yl &&
m_xpos + m_bbox.x < xl && m_xpos + m_bbox.x + m_bbox.width > xl) {
getMainWindow()->m_selected_chord_or_rest = this;
getMainWindow()->m_selected_note = (NedNote *) g_list_first(m_notes)->data;
return TRUE;
}
return FALSE;
default:
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->trySelect(x, y)) {
getMainWindow()->m_selected_chord_or_rest = this;
return TRUE;
}
}
return FALSE;
}
}
bool NedChordOrRest::hitStemEnd(double x, double y) {
double xd, yd;
double leftx = getMainWindow()->getLeftX();
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
double current_scale = getMainWindow()->getCurrentScale();
double xl = X_POS_INVERS_PAGE_REL(x);
double yl = Y_POS_INVERSE_STAFF_REL(y);
if (m_beam == NULL) {
xd = xl - m_stem_end_xpos;
yd = yl - m_stem_end_ypos;
if (xd < 0.0) xd = -xd;
if (yd < 0.0) yd = -yd;
if (xd < STEM_TOP_DIST && yd < STEM_TOP_DIST) {
return true;
}
}
else if (m_beam->isFirstInBeam(this) || m_beam->isLastInBeam(this)) {
xd = xl - m_stem_end_xpos;
yd = yl - m_stem_end_ypos;
if (xd < 0.0) xd = -xd;
if (yd < 0.0) yd = -yd;
if (xd < STEM_TOP_DIST && yd < STEM_TOP_DIST) {
return true;
}
}
return false;
}
bool NedChordOrRest::scaleStem(double y, double old_ypos) {
double yd;
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
double current_scale = getMainWindow()->getCurrentScale();
double yl = Y_POS_INVERSE_STAFF_REL(y);
bool ret = false;
m_status_copy = m_status;
if (m_beam == NULL) {
if (m_stemheight_copy < UNSET_STEM_HEIGHT) {
m_stemheight_copy = m_stem_height;
}
yd = yl - m_stem_end_ypos;
if (m_status & STAT_UP) {
m_stem_height -= yd;
}
else {
m_stem_height += yd;
}
if (m_stem_height > 3 * STEM_DEFAULT_HEIGHT) m_stem_height = 3 * STEM_DEFAULT_HEIGHT;
if (m_stem_height < 0.4 * STEM_DEFAULT_HEIGHT) m_stem_height = 0.4 * STEM_DEFAULT_HEIGHT;
}
else if (m_beam->isFirstInBeam(this)) {
m_status |= STAT_USER_STEMDIR;
if (m_beam->isBeamUp()) {
m_status |= STAT_UP;
}
else {
m_status &= (~(STAT_UP));
}
if (m_beam_y_offs_copy < UNSET_STEM_HEIGHT) {
m_beam_y_offs_copy = m_beam_y_offs;
}
yd = yl - m_stem_end_ypos;
m_beam_y_offs += yd;
if (m_beam->isBeamUp()) {
if (m_beam_y_offs < -2 * STEM_DEFAULT_HEIGHT) m_beam_y_offs = -2 * STEM_DEFAULT_HEIGHT;
if (m_beam_y_offs > 0.4 * STEM_DEFAULT_HEIGHT) m_beam_y_offs = 0.4 * STEM_DEFAULT_HEIGHT;
}
else {
if (m_beam_y_offs > 2 * STEM_DEFAULT_HEIGHT) m_beam_y_offs = 2 * STEM_DEFAULT_HEIGHT;
if (m_beam_y_offs < -0.4 * STEM_DEFAULT_HEIGHT) m_beam_y_offs = -0.4 * STEM_DEFAULT_HEIGHT;
}
m_beam->computeBeam(getStaff()->getStaffNumber() * VOICE_COUNT + m_voice->getVoiceNumber());
}
#define MIN_SLOPE_CHANGE_DIST 0.09
else if (m_beam->isLastInBeam(this)) {
m_status |= STAT_USER_STEMDIR;
if (m_beam->isBeamUp()) {
m_status |= STAT_UP;
}
else {
m_status &= (~(STAT_UP));
}
double yl_old = Y_POS_INVERSE_STAFF_REL(old_ypos);
double motion_dist = yl - yl_old;
if (m_slope_offs_copy == UNSET_SLOPE_OFFS) {
m_slope_offs_copy = m_slope_offs;
}
if (motion_dist > MIN_SLOPE_CHANGE_DIST * m_beam->getBeamLength()) {
m_slope_offs--;
ret = true;
}
else if (motion_dist < -MIN_SLOPE_CHANGE_DIST * m_beam->getBeamLength()) {
m_slope_offs++;
ret = true;
}
if (m_slope_offs < -SLOPE_COUNT) m_slope_offs = -SLOPE_COUNT;
if (m_slope_offs > SLOPE_COUNT) m_slope_offs = SLOPE_COUNT;
m_beam->computeBeam(getStaff()->getStaffNumber() * VOICE_COUNT + m_voice->getVoiceNumber());
}
return ret;
}
double NedChordOrRest::computeDistFrom(double x, double y, double factor, double *ydist) {
double xdist;
switch (m_type) {
case TYPE_CLEF:
case TYPE_STAFF_SIGN:
case TYPE_KEYSIG:
case TYPE_GRACE:
return 100000000.0;
default:
xdist = m_xpos - x;
*ydist = getSystem()->getYPos() + getStaff()->getMidPos() - y;
return xdist * xdist + (*ydist * factor) * (*ydist * factor);
}
}
void NedChordOrRest::setActive() {
switch (m_type) {
case TYPE_CHORD:
((NedNote *) g_list_first(m_notes)->data)->m_active = true;
break;
default:
m_active = true;
break;
}
}
void NedChordOrRest::decrMidiTime(unsigned long long incr) {
if (incr > m_midi_time) {
NedResource::DbgMsg(DBG_CRITICAL, "this = 0x%x, m_type = 0x%x, m_midi_time = %llu, incr = %llu\n", this, m_type, m_midi_time, incr) ;
NedResource::Abort("NedChordOrRest::decrMidiTime, incr > m_midi_time");
}
m_midi_time -= incr;
}
int NedChordOrRest::getStemDirectionOfTheMeasure(int staff_voice_offs) {
//NedMeasure *measure = getSystem()->getMeasure(m_midi_time);
//return measure->getStemDirectionOfTheMeasure(staff_voice_offs);
return m_measure->getStemDirectionOfTheMeasure(staff_voice_offs);
}
#ifdef AAA
unsigned int NedChordOrRest::getDuration(unsigned int measure_duration /* = -1 */) {
int denom;
if (m_type & (TYPE_STAFF_SIGN | TYPE_CLEF | TYPE_KEYSIG | TYPE_GRACE)) return 0;
if (m_type == TYPE_REST && m_length == WHOLE_NOTE) {
if ((signed int) measure_duration != -1) {
return measure_duration;
}
if (m_measure == NULL) {
return getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
}
denom = getMainWindow()->getDenominator(m_measure->getMeasureNumber());
if (denom == 0) {
return getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
}
return getMainWindow()->getNumerator(m_measure->getMeasureNumber()) * WHOLE_NOTE / denom;
}
return computeDuration(m_length, m_dot_count, m_tuplet_val);
}
#else
unsigned int NedChordOrRest::getDuration(unsigned int measure_duration /* = -1 */) {
int denom;
if (m_type & (TYPE_CLEF | TYPE_STAFF_SIGN | TYPE_KEYSIG | TYPE_GRACE | TYPE_KEYSIG /* can happen during import_from_other */)) return 0;
if (m_type == TYPE_REST && m_length == WHOLE_NOTE) {
if ((signed int) measure_duration != -1) {
return measure_duration;
}
NedMeasure *measure = getSystem()->getMeasure(m_midi_time);
if (measure == NULL) {
return getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
}
denom = getMainWindow()->getDenominator(measure->getMeasureNumber());
if (denom == 0) {
return getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
}
return getMainWindow()->getNumerator(measure->getMeasureNumber()) * WHOLE_NOTE / denom;
}
return computeDuration(m_length, m_dot_count, m_tuplet_val);
}
#endif
unsigned int NedChordOrRest::computeDuration(unsigned int length, int dotcount, int tuplet_val) {
unsigned int ret;
if (dotcount == 1) {
ret = length / 2 * 3;
if (tuplet_val != 0) {
ret = ret * NedResource::m_tuplet_tab[tuplet_val & TUPLET_VAR_MASK];
return ret / (tuplet_val & TUPLET_VAR_MASK);
}
return ret;
}
if (dotcount == 2) {
ret = length / 4 * 7;
if (tuplet_val != 0) {
ret = ret * NedResource::m_tuplet_tab[tuplet_val & TUPLET_VAR_MASK];
return ret / (tuplet_val & TUPLET_VAR_MASK);
}
return ret;
}
if (tuplet_val != 0) {
ret = length * NedResource::m_tuplet_tab[tuplet_val & TUPLET_VAR_MASK];
return ret / (tuplet_val & TUPLET_VAR_MASK);
}
return length;
}
bool NedChordOrRest::tryErease(double x, double y, bool *removed) {
NedCommandList *command_list;
GList *lptr;
*removed = false;
if (m_type == TYPE_REST) return FALSE;
if (g_list_length(m_notes) < 2) {
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->trySelect(x, y)) {
*removed = true;
return TRUE;
}
}
}
else {
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->trySelect(x, y)) {
command_list = new NedCommandList(getMainWindow(), getSystem());
((NedNote *) lptr->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
command_list->addCommand(new NedEreaseNoteCommand(&m_notes, lptr));
getMainWindow()->getCommandHistory()->addCommandList(command_list);
command_list->execute();
*removed = true;
return FALSE;
}
}
return FALSE;
}
return FALSE;
}
void NedChordOrRest::ereaseNote(NedNote *note) {
GList *lptr;
NedCommandList *command_list;
if (m_type == TYPE_REST) return;
if (g_list_length(m_notes) < 2) {
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
command_list->addCommand(new NedDeleteChordCommand(this));
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
}
else {
if ((lptr = g_list_find(m_notes, note)) == NULL) {
NedResource::Abort("NedChordOrRest::ereaseNote");
}
command_list = new NedCommandList(getMainWindow(), getSystem());
note->testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
command_list->addCommand(new NedEreaseNoteCommand(&m_notes, lptr));
getMainWindow()->getCommandHistory()->addCommandList(command_list);
command_list->execute();
}
}
unsigned int NedChordOrRest::getStopTime() {
return m_time + m_length;
}
double NedChordOrRest::getNeededSpace() {
return m_bbox.width;
}
void NedChordOrRest::saveChordOrRest(FILE *fp) {
GList *lptr;
char Str[1024], *cptr;
int marker;
int last_font_line;
int i;
fprintf(fp, "(");
if (m_beam != NULL || m_tuplet_ptr != NULL || m_freedisp != NULL) {
marker = NedResource::addAddr(this);
fprintf(fp, "<%d>", marker);
}
if (m_type == TYPE_REST) {
fprintf(fp, "r");
if (m_is_hidden) {
fprintf(fp, "h");
}
}
else {
fprintf(fp, "n");
if ((m_status & STAT_UP) != 0) {
fprintf(fp, "u");
}
else {
fprintf(fp, "d");
}
}
fprintf(fp, " %d, %x ", m_length / LENGH_FACTOR, m_status & (~(ACCIDENTAL_MASK)));
if (m_type == TYPE_REST && (m_status & STAT_USER_PLACED_REST)) {
fprintf(fp, "%d ", m_line);
}
if (m_dot_count > 0) {
fprintf(fp, " D %d ", m_dot_count);
}
if (m_type == TYPE_REST) {
fprintf(fp, ")");
return;
}
fprintf(fp, " { ");
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->saveNote(fp);
if (lptr != g_list_last(m_notes)) {
fprintf(fp, " , ");
}
}
fprintf(fp, " } ");
#define MIN_DRIFT 0.01
if (fabs(m_stem_height - STEM_DEFAULT_HEIGHT) > MIN_DRIFT) {
fprintf(fp, " STEM_HEIGHT: %f ", m_stem_height);
}
if (fabs(m_beam_y_offs) > MIN_DRIFT) {
fprintf(fp, " BEAM_Y_OFFS: %f ", m_beam_y_offs);
}
if (m_slope_offs != 0) {
fprintf(fp, " BEAM_SLOPE_OFFS: %d ", m_slope_offs);
}
last_font_line = -1;
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
last_font_line = i;
}
}
if (m_type == TYPE_CHORD && last_font_line >= 0) {
fprintf(fp, "[");
for (i = 0; i <= last_font_line; i++) {
if (m_lyrics[i] != NULL) {
strcpy(Str, m_lyrics[i]->getText());
while ((cptr = strchr(Str, ' ')) != NULL) *cptr = '_';
fprintf(fp, " %s ", Str);
}
if (i < last_font_line) {
fprintf(fp, " , ");
}
}
fprintf(fp, " ] ");
}
fprintf(fp, ")");
}
void NedChordOrRest::saveTies(FILE *fp, bool *ties_written) {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->saveTies(fp, ties_written);
}
}
void NedChordOrRest::saveFreePlaceables(FILE *fp, bool *free_placeables_written) {
GList *lptr;
NedVolumeSign *vol_sign;
NedTempoSign *tempo_sign;
NedLine *line;
NedLinePoint *startp,*endp;
NedSlurPoint **sp;
NedFreeText *ftext;
NedFreeSign *fsign;
NedFreeChord *fchord;
NedFreeSpacer *fspacer;
NedChordName *fcn;
char *roottext, *uptext, *downtext;
int marker;
if (m_freedisp) {
marker = NedResource::getMarkerOfAddress(this);
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
switch (((NedFreeReplaceable *) lptr->data)->getType()) {
case FREE_PLACEABLE_VOLSIGN:
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
vol_sign = (NedVolumeSign *) lptr->data;
fprintf(fp, "( < %d %f %f > VOLUME_SIGN ", marker, vol_sign->getX(), vol_sign->getY());
switch (vol_sign->getKind()) {
case VOL_PPP: fprintf(fp, "VOL_PPP " ); break;
case VOL_PP: fprintf(fp, "VOL_PP " ); break;
case VOL_P: fprintf(fp, "VOL_P " ); break;
case VOL_MP: fprintf(fp, "VOL_MP " ); break;
case VOL_SP: fprintf(fp, "VOL_SP " ); break;
case VOL_MF: fprintf(fp, "VOL_MF " ); break;
case VOL_SF: fprintf(fp, "VOL_SF " ); break;
case VOL_F: fprintf(fp, "VOL_F " ); break;
case VOL_FF: fprintf(fp, "VOL_FF " ); break;
case VOL_FFF: fprintf(fp, "VOL_FFF " ); break;
}
fprintf(fp, "%d ) ", vol_sign->m_midi_volume);
break;
case FREE_PLACEABLE_TEMPO:
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
tempo_sign = (NedTempoSign *) lptr->data;
fprintf(fp, "( < %d %f %f > TEMPO_SIGN %u %d %u) ",
marker, tempo_sign->getX(), tempo_sign->getY(), tempo_sign->getKind(), tempo_sign->getDot(), tempo_sign->getTempo());
break;
case FREE_PLACEABLE_CHORDNAME:
fcn = (NedChordName *) lptr->data;
roottext = fcn->getRootText();
uptext = fcn->getUpText();
downtext = fcn->getDownText();
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
fprintf(fp, "( < %d %f %f > FREE_CHORD_NAME %zu %s %zu %s %zu %s %f) ",
marker, fcn->getX(), fcn->getY(),
roottext == NULL ? 0 : strlen(roottext), roottext == NULL ? "" : roottext,
uptext == NULL ? 0 : strlen(uptext), uptext == NULL ? "" : uptext,
downtext == NULL ? 0 : strlen(downtext), downtext == NULL ? "" : downtext, fcn->getSize());
break;
case FREE_PLACEABLE_SLUR_POINT:
if (((NedSlurPoint *) lptr->data)->m_point_number != 2) break;
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
sp = ((NedSlurPoint *) lptr->data)->getSlurPoints();
fprintf(fp, "( < %d %f %f > SLUR %d %f %f %d %f %f ) ",
NedResource::getMarkerOfAddress(sp[0]->getElement()), sp[0]->getX(), sp[0]->getY(),
NedResource::getMarkerOfAddress(sp[1]->getElement()), sp[1]->getX(), sp[1]->getY(),
NedResource::getMarkerOfAddress(sp[2]->getElement()), sp[2]->getX(), sp[2]->getY());
break;
case FREE_PLACEABLE_LINE_POINT:
line = ((NedLinePoint *) lptr->data)->getLine();
startp = line->getLineStartPoint();
endp = line->getLineEndPoint();
if (lptr->data != endp) break;
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
fprintf(fp, "( < %d %f %f > ",
NedResource::getMarkerOfAddress(startp->getElement()), startp->getX(), startp->getY());
switch (line->getLineType()) {
case LINE_CRESCENDO: fprintf(fp, "LINE_CRESCENDO %d ", ((NedCrescendo *) line)->m_volume_diff); break;
case LINE_DECRESCENDO: fprintf(fp, "LINE_DECRESCENDO %d ", ((NedCrescendo *) line)->m_volume_diff) ; break;
case LINE_OCTAVATION1:
case LINE_OCTAVATION_1:
case LINE_OCTAVATION2:
case LINE_OCTAVATION_2: fprintf(fp, "LINE_OCTAVATION %d ", ((NedOctavation *) line)->getPitchOffset()); break;
case LINE_ACCELERANDO: fprintf(fp, "LINE_ACCELERATO %d", (int) ((NedAcceleration *) line)->m_tempodiff); break;
case LINE_RITARDANDO: fprintf(fp, "LINE_RITARDANDO %d", (int) ((NedAcceleration *) line)->m_tempodiff); break;
}
if ((line->getLineType() & LINE_TEMPO_CHANGE) != 0) {
NedLinePoint *midp = ((NedLine3 *) line)->getLineMidPoint();
fprintf(fp, " %d %f %f %d %f %f ) ",
NedResource::getMarkerOfAddress(midp->getElement()), midp->getX(), midp->getY(),
NedResource::getMarkerOfAddress(endp->getElement()), endp->getX(), endp->getY());
}
else {
fprintf(fp, " %d %f %f ) ",
NedResource::getMarkerOfAddress(endp->getElement()), endp->getX(), endp->getY());
}
break;
case FREE_PLACEABLE_TEXT:
ftext = (NedFreeText *) lptr->data;
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
tempo_sign = (NedTempoSign *) lptr->data;
fprintf(fp, "( < %d %f %f > FREE_TEXT %zu %s %zu %s %f %d %d %d %d %x %d %d %d %d ",
marker, ftext->getX(), ftext->getY(), strlen(ftext->getText()), ftext->getText(),
strlen(ftext->m_font_family), ftext->m_font_family,
ftext->m_font_size, ftext->m_enable_volume_change, ftext->m_midi_volume,
ftext->m_enable_tempo_change, ftext->getTempo(), ftext->m_segno_sign, ftext->m_midi_pgm,
ftext->m_enable_channel, ftext->m_channel, ftext->m_anchor);
switch (ftext->m_font_slant) {
case CAIRO_FONT_SLANT_ITALIC: fprintf(fp, "%d ", WRITTEN_SLANT_ITALIC); break;
case CAIRO_FONT_SLANT_OBLIQUE: fprintf(fp, "%d ", WRITTEN_SLANT_OBLIQUE); break;
default: fprintf(fp, "%d ", WRITTEN_SLANT_NORMAL); break;
}
switch (ftext->m_font_weight) {
case CAIRO_FONT_WEIGHT_BOLD: fprintf(fp, "%d ", WRITTEN_WEIGHT_BOLD); break;
default: fprintf(fp, "%d ", WRITTEN_WEIGHT_NORMAL); break;
}
fprintf(fp, " ) ");
break;
case FREE_PLACEABLE_SIGN:
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
fsign = (NedFreeSign *) lptr->data;
fprintf(fp, "( < %d %f %f > FREE_SIGN %d) ",
marker, fsign->getX(), fsign->getY(), fsign->getKind());
break;
case FREE_PLACEABLE_CHORD:
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
fchord = (NedFreeChord *) lptr->data;
fprintf(fp, "( < %d %f %f > FREE_CHORD %zu %s, %d, %x ) ",
marker, fchord->getX(), fchord->getY(), strlen(fchord->getCode()), fchord->getCode(), fchord->getChordName(), fchord->getStatus());
break;
case FREE_PLACEABLE_SPACER:
if (!*free_placeables_written) {
fprintf(fp, "FREE_PLACEABLES ");
*free_placeables_written = true;
}
fspacer = (NedFreeSpacer *) lptr->data;
fprintf(fp, "( < %d %f %f > FREE_SPACER ) ",
marker, fspacer->getX(), fspacer->getY());
break;
}
}
}
}
NedNote* NedChordOrRest::getFirstNote() {
return (NedNote *)g_list_first(m_notes)->data;
}
NedChordOrRest *NedChordOrRest::getNextChordOrRest() {return m_voice->getNextChordOrRest(this);}
NedChordOrRest *NedChordOrRest::getPreviousChordOrRest() {return m_voice->getPreviousChordOrRest(this);}
NedChordOrRest *NedChordOrRest::getFirstObjectInNextSystem() {
return getSystem()->getFirstObjectInNextSystem(getStaff()->getStaffNumber());
}
void NedChordOrRest::prepareMutedReplay() {
GList *lptr;
int staff_nr;
struct staff_context_str *contexts;
staff_nr = getStaff()->getStaffNumber();
contexts = getMainWindow()->m_staff_contexts;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_TEMPO) {
NedResource::addTempoChange(m_midi_time, ((NedTempoSign *) lptr->data)->getTempoInverse());
}
}
}
void NedChordOrRest::resetActiveFlags() {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->resetActiveFlag();
}
}
void NedChordOrRest::prepareReplay(int clef, int keysig, int octave_shift, int voice_idx, unsigned int grace_time) {
GList *lptr;
int staff_nr, i;
unsigned int midi_start_offs;
NedCrescendo *cres;
NedAcceleration *accel;
NedFreeText *ftext;
bool reset_pitch_offset = false;
struct staff_context_str *contexts;
NedLinePoint *startp, *endp;
NedOctavation *oct;
staff_nr = getStaff()->getStaffNumber();
contexts = getMainWindow()->m_staff_contexts;
unsigned short segno_sign = 0;
if (m_status & STAT_PED_ON) {
NedResource::addMidiCtrlEvent(getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel,
getMidiTime(), MIDI_CTL_SUSTAIN, 100);
}
if (m_status & STAT_PED_OFF) {
NedResource::addMidiCtrlEvent(getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel,
getMidiTime(), MIDI_CTL_SUSTAIN, 1);
}
if (m_status & STAT_FERMATA) {
NedResource::addFermata(getMidiTime());
}
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_TEMPO) {
NedResource::addTempoChange(m_midi_time, ((NedTempoSign *) lptr->data)->getTempoInverse());
}
else if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_TEXT) {
ftext = (NedFreeText *) lptr->data;
if (ftext->m_enable_tempo_change) {
NedResource::addTempoChange(m_midi_time, ftext->getTempoInverse());
}
segno_sign |= ftext->m_segno_sign;
if (ftext->m_enable_channel) {
getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel = ftext->m_channel;
}
if (ftext->m_midi_pgm >= 0) {
getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].voices[0].m_current_midi_program = ftext->m_midi_pgm;
}
if (ftext->m_enable_volume_change) {
NedResource::addPseudoEvent2(m_midi_time, PSEUDO_EVENT_VOL_CHANGE, getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel,
ftext->m_midi_volume);
}
}
else if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_VOLSIGN) {
NedResource::addPseudoEvent2(m_midi_time, PSEUDO_EVENT_VOL_CHANGE, getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel,
((NedVolumeSign *) lptr->data)->m_midi_volume);
}
else if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_LINE_POINT) {
if ((((NedLinePoint *) lptr->data)->getLine()->getLineType() & (LINE_CRESCENDO | LINE_DECRESCENDO)) != 0) {
startp = ((NedLinePoint *) lptr->data)->getLine()->getLineStartPoint();
endp = ((NedLinePoint *) lptr->data)->getLine()->getLineEndPoint();
cres = (NedCrescendo *) ((NedLinePoint *) lptr->data)->getLine();
if (startp == lptr->data) {
NedResource::addPseudoEvent2((unsigned int) m_midi_time, PSEUDO_EVENT_CRES_START,
getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel, cres->m_volume_diff);
}
else if (endp == lptr->data) {
NedResource::addPseudoEvent2((unsigned int) m_midi_time, PSEUDO_EVENT_CRES_STOP,
getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel, cres->m_volume_diff);
}
}
else if ((((NedLinePoint *) lptr->data)->getLine()->getLineType() & LINE_TEMPO_CHANGE) != 0) {
startp = ((NedLinePoint *) lptr->data)->getLine()->getLineStartPoint();
endp = ((NedLinePoint *) lptr->data)->getLine()->getLineEndPoint();
accel = (NedAcceleration *) ((NedLinePoint *) lptr->data)->getLine();
if (startp == lptr->data) {
NedResource::addPseudoEvent2((unsigned int) m_midi_time, PSEUDO_EVENT_RIT_START,
0 /*dummy */, accel->m_tempodiff);
}
else if (endp == lptr->data) {
NedResource::addPseudoEvent2((unsigned int) m_midi_time, PSEUDO_EVENT_RIT_STOP,
0 /*dummy */, accel->m_tempodiff);
}
}
else if ((((NedLinePoint *) lptr->data)->getLine()->getLineType() & LINE_OCTAVIATION_MASK) != 0) {
startp = ((NedLinePoint *) lptr->data)->getLine()->getLineStartPoint();
endp = ((NedLinePoint *) lptr->data)->getLine()->getLineEndPoint();
oct = (NedOctavation *) ((NedLinePoint *) lptr->data)->getLine();
if (startp == lptr->data) {
contexts[staff_nr].m_pitch_offs = oct->getPitchOffset();
}
else if (endp == lptr->data) {
reset_pitch_offset = true;
}
}
}
else if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_SIGN) {
switch (((NedFreeSign *) lptr->data)->getKind()) {
case SIGN_SEGNO: segno_sign |= SEGNO_SIGN; break;
case SIGN_CODA: segno_sign |= SEGNO_CODA; break;
}
}
}
midi_start_offs = 0;
if ((m_status & STAT_ARPEGGIO) != 0 && g_list_length(m_notes) * ARPEGGIO_MIDI_DIST < getDuration()) {
midi_start_offs = ARPEGGIO_MIDI_DIST;
}
if (m_type & (TYPE_CHORD | TYPE_GRACE) ) {
for (i = 0, lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr), i++) {
((NedNote *) lptr->data)->prepareReplay(m_midi_time + i * midi_start_offs, clef, keysig, octave_shift, contexts[staff_nr].m_pitch_offs, voice_idx, grace_time, m_type == TYPE_GRACE, (m_status & (STAT_STACC | STAT_STACCATISSIMO)) != 0, segno_sign);
}
}
else if (segno_sign) { // ensure segno staff attached to rests is correctly handled
NedResource::addMidiNoteEvent(getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel, (unsigned char) m_voice->getVoiceNumber(),
m_midi_time, SND_SEQ_EVENT_NOTEON | PSEUDO2_FLAG /* keep during replay */ , 60 /* dummy */,
0 /* dummy */, segno_sign, NULL /* dummy */);
NedResource::addMidiNoteEvent(getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()].m_effective_channel, (unsigned char) m_voice->getVoiceNumber(),
m_midi_time + getDuration() - grace_time, SND_SEQ_EVENT_NOTEOFF | PSEUDO2_FLAG /* keep during replay */ , 60 /* dummy */, 0, segno_sign, NULL /* dummy */);
}
if (reset_pitch_offset) {
contexts[staff_nr].m_pitch_offs = 0;
}
}
void NedChordOrRest::exportLilyPond(FILE *fp, int *last_line, unsigned int *midi_len, NedSlur **lily_slur,
unsigned int *lyrics_map, bool *guitar_chordnames, bool *chordname, int *breath_script, bool keep_beams) {
GList *lptr;
bool force_length = false;
char restchar;
int dotcount, tremolo;
unsigned int duration, len2;
char Str[100], Str2[100];
int i;
int clef, keysig, octave_shift;
int new_line, old_line;
int clef_number;
bool tie = false;
duration = getDuration();
switch (m_type) {
case TYPE_REST:
exportLilyFreePlaceablesBefore(fp);
restchar =m_is_hidden ? 's' : 'r';
if (m_length == WHOLE_NOTE && duration != WHOLE_NOTE) {
NedResource::setLengthField(duration);
len2 = NedResource::getPartLength(&dotcount);
sprintf(Str, "%c%d", restchar, WHOLE_NOTE / len2);
for (i = 0; i < dotcount; i++) {
strcat(Str, ".");
}
strcat(Str, " ");
len2 = NedResource::getPartLength(&dotcount);
while (len2) {
sprintf(Str2, "%c%d", restchar, WHOLE_NOTE / len2);
strcat(Str, Str2);
for (i = 0; i < dotcount; i++) {
strcat(Str, ".");
}
strcat(Str, " ");
len2 = NedResource::getPartLength(&dotcount);
}
fprintf(fp, Str);
*midi_len = 0;
}
else {
fprintf(fp, "%c%d ", restchar, WHOLE_NOTE / m_length);
for (i = 0; i < m_dot_count; i++) {
fprintf(fp, ".");
}
*midi_len = getDuration();
}
exportLilyAccents(fp);
exportLilyFreePlaceablesAfter(fp, lily_slur, guitar_chordnames, chordname);
putc(' ', fp);
break;
case TYPE_CHORD:
exportLilyFreePlaceablesBefore(fp);
if (g_list_length(m_notes) > 1) {
fprintf(fp, " <");
}
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->exportLilyPond(fp, last_line, &tie);
}
*last_line = ((NedNote *) g_list_first(m_notes)->data)->getLine();
if (g_list_length(m_notes) > 1) {
fprintf(fp, " >");
}
if (duration != *midi_len || (m_status & TREMOLO_MASK)) {
if (m_status & TREMOLO_MASK) {
switch (m_status & TREMOLO_MASK) {
case STAT_TREMOLO1: tremolo = 8; break;
case STAT_TREMOLO2: tremolo = 16; break;
case STAT_TREMOLO3: tremolo = 32; break;
case STAT_TREMOLO4: tremolo = 64; break;
}
sprintf(Str, "%d:%d", WHOLE_NOTE / m_length, tremolo);
}
else {
sprintf(Str, "%d", WHOLE_NOTE / m_length);
}
for (i = 0; i < m_dot_count; i++) {
strcat(Str, ".");
}
force_length = true;
}
if (force_length) {
fprintf(fp, Str);
}
exportLilyAccents(fp);
if (keep_beams && m_beam) {
if (m_beam->getFirst() == this) {
fprintf(fp, " [ ");
}
if (m_beam->getLast() == this) {
fprintf(fp, " ] ");
}
}
if (tie) {
fprintf(fp, " ~ ");
}
exportLilyFreePlaceablesAfter(fp, lily_slur, guitar_chordnames, chordname);
putc(' ', fp);
*midi_len = getDuration();
for (i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
(*lyrics_map) |= (1 << i);
}
}
break;
case TYPE_GRACE:
switch (m_length) {
case STROKEN_GRACE: fprintf(fp, "\\acciaccatura "); break;
default: fprintf(fp, "\\grace{ "); break;
}
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->exportLilyPond(fp, last_line, &tie);
}
switch (m_length) {
case GRACE_8:
case STROKEN_GRACE: fprintf(fp, "8 "); break;
case GRACE_16: fprintf(fp, "16 "); break;
}
switch (m_length) {
case STROKEN_GRACE: break;
default: fprintf(fp, "}"); break;
}
*midi_len = 0;
break;
case TYPE_CLEF:
getStaff()->getCurrentClefAndKeysig(m_midi_time - NOTE_64, &clef, &keysig, &octave_shift);
old_line = NedResource::determineLastLine(-2, clef);
clef_number = m_length;
new_line = NedResource::determineLastLine(-2, clef_number);
fprintf(fp, " \\clef %s ", NedResource::getLilyPondClefName(clef_number));
*last_line += new_line - old_line;
break;
case TYPE_STAFF_SIGN:
switch (m_dot_count) {
case SIGN_BREATH1: if (*breath_script != LILY_BREAH_SCRIPT_RCOMMA) {
fprintf(fp, " \\override BreathingSign #'text = #(make-musicglyph-markup \"scripts.rcomma\") ");
*breath_script = LILY_BREAH_SCRIPT_RCOMMA;
}
fprintf(fp, " \\breathe ");
break;
case SIGN_BREATH2: if (*breath_script != LILY_BREAH_SCRIPT_UPBOW) {
fprintf(fp, " \\override BreathingSign #'text = #(make-musicglyph-markup \"scripts.upbow\") ");
*breath_script = LILY_BREAH_SCRIPT_UPBOW;
}
fprintf(fp, " \\breathe ");
break;
}
break;
case TYPE_KEYSIG:
fprintf(fp, " %s ", NedResource::getLilyPondKeySigName(m_length));
break;
}
}
void NedChordOrRest::exportLilyAccents(FILE *fp) {
if (m_status & STAT_STACC) {
fprintf(fp, "\\staccato ");
}
if (m_status & STAT_TENUTO) {
fprintf(fp, "\\tenuto ");
}
if (m_status & STAT_SFORZATO) {
fprintf(fp, "\\marcato ");
}
if (m_status & STAT_SFORZANDO) {
fprintf(fp, "\\accent ");
}
if (m_status & STAT_BOW_UP) {
fprintf(fp, "\\upbow ");
}
if (m_status & STAT_BOW_DOWN) {
fprintf(fp, "\\downbow ");
}
if (m_status & STAT_PED_ON) {
fprintf(fp, "\\sustainDown ");
}
if (m_status & STAT_PED_OFF) {
fprintf(fp, "\\sustainUp ");
}
if (m_status & STAT_TRILL) {
fprintf(fp, "\\trill ");
}
if (m_status & STAT_PRALL) {
fprintf(fp, "\\prall ");
}
if (m_status & STAT_MORDENT) {
fprintf(fp, "\\mordent ");
}
if (m_status & STAT_TURN) {
fprintf(fp, "\\turn ");
}
if (m_status & STAT_REV_TURN) {
fprintf(fp, "\\reverseturn ");
}
if (m_status & STAT_OPEN) {
fprintf(fp, "\\open ");
}
if (m_status & STAT_FERMATA) {
fprintf(fp, "\\fermata ");
}
if (m_status & STAT_ARPEGGIO) {
fprintf(fp, "\\arpeggio ");
}
}
void NedChordOrRest::exportLilyFreePlaceablesBefore(FILE *fp) {
GList *lptr;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
switch (((NedFreeReplaceable *) lptr->data)->getType()) {
case FREE_PLACEABLE_TEMPO:
fprintf(fp, "\\tempo ");
switch (((NedTempoSign *) lptr->data)->getKind()) {
case WHOLE_NOTE: fprintf(fp, "1="); break;
case NOTE_2: fprintf(fp, "2="); break;
case NOTE_4: fprintf(fp, "4="); break;
case NOTE_8: fprintf(fp, "8="); break;
case NOTE_16: fprintf(fp, "16="); break;
}
fprintf(fp, "%d ", ((NedTempoSign *) lptr->data)->getTempo());
break;
}
}
}
void NedChordOrRest::exportLilyFreePlaceablesAfter(FILE *fp, NedSlur **lily_slur, bool *guitar_chordnames, bool *chordnames) {
GList *lptr;
NedSlur *slur;
NedSlurPoint **sp;
char Str[1024];
int bracenum;
NedLine *line;
NedLinePoint *endp;
NedLinePoint *startp;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
switch (((NedFreeReplaceable *) lptr->data)->getType()) {
case FREE_PLACEABLE_VOLSIGN:
switch (((NedVolumeSign *) lptr->data)->getKind()) {
case VOL_PPP: fprintf(fp, "\\ppp"); break;
case VOL_PP: fprintf(fp, "\\pp"); break;
case VOL_P: fprintf(fp, "\\p"); break;
case VOL_MF: fprintf(fp, "\\mf"); break;
case VOL_SF: fprintf(fp, "\\sf"); break;
case VOL_MP: fprintf(fp, "\\mp"); break;
case VOL_SP: fprintf(fp, "\\sp"); break;
case VOL_F: fprintf(fp, "\\f"); break;
case VOL_FF: fprintf(fp, "\\ff"); break;
case VOL_FFF: fprintf(fp, "\\fff"); break;
}
break;
case FREE_PLACEABLE_SLUR_POINT:
slur = ((NedSlurPoint *) lptr->data)->getSlur();
sp = slur->getSlurPoints();
if (((NedSlurPoint *) lptr->data) == sp[0]) {
if (*lily_slur == NULL) {
fprintf(fp, " ( ");
*lily_slur = slur;
}
}
else if (((NedSlurPoint *) lptr->data) == sp[2]) {
if (*lily_slur == slur) {
fprintf(fp, " ) " );
*lily_slur = NULL;
}
}
break;
case FREE_PLACEABLE_LINE_POINT:
line = ((NedLinePoint *) lptr->data)->getLine();
startp = line->getLineStartPoint();
if (lptr->data == startp) {
switch (line->getLineType()) {
case LINE_CRESCENDO: fprintf(fp, "\\< "); break;
case LINE_DECRESCENDO: fprintf(fp, "\\> "); break;
}
}
endp = line->getLineEndPoint();
if (lptr->data == endp) {
switch (line->getLineType()) {
case LINE_CRESCENDO:
case LINE_DECRESCENDO: fprintf(fp, "\\! "); break;
}
}
break;
case FREE_PLACEABLE_TEXT:
fprintf(fp, "^\\markup {");
bracenum = 0;
if (((NedFreeText *) lptr->data)->m_font_slant == PANGO_STYLE_ITALIC) {
fprintf(fp, " \\italic {"); bracenum++;
}
if (((NedFreeText *) lptr->data)->m_font_weight == PANGO_WEIGHT_BOLD) {
fprintf(fp, " \\bold {"); bracenum++;
}
((NedFreeText *) lptr->data)->getLilyText(Str);
fprintf(fp, "%s }", Str);
while (bracenum--) {
fprintf(fp, " } ");
}
break;
case FREE_PLACEABLE_SIGN:
switch (((NedFreeSign *) lptr->data)->getKind()) {
case SIGN_SEGNO: fprintf(fp, "\\mark \\markup { \\musicglyph #\"scripts.segno\" } "); break;
case SIGN_CODA: fprintf(fp, "\\mark \\markup { \\musicglyph #\"scripts.coda\" } "); break;
}
break;
case FREE_PLACEABLE_CHORD:
if ((((NedFreeChord *) lptr->data)->getStatus() & GUITAR_CHORD_DRAW_TEXT) != 0) {
*guitar_chordnames = true;
}
if ((((NedFreeChord *) lptr->data)->getStatus() & GUITAR_CHORD_DRAW_DIAGRAM) == 0) break;
NedChordPainter::writeLilyChord(fp, ((NedFreeChord *) lptr->data)->getChordPtr());
break;
case FREE_PLACEABLE_CHORDNAME:
*chordnames = true;
break;
}
}
}
void NedChordOrRest::exportLilyLyrics(FILE *fp, int line_nr, int *sil_count) {
#define MAX_LILY_SIL_COUNT 8
GList *lptr;
bool has_tie;
char buffer[1024];
if (line_nr < 0 || line_nr >= MAX_LYRICS_LINES) {
NedResource::Abort("NedChordOrRest::exportLilyLyrics");
}
switch (m_type) {
case TYPE_CHORD:
has_tie = false;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getTieBackward() != NULL) {
has_tie = true;
}
}
if (has_tie) {
break;
}
if (m_lyrics[line_nr] == NULL) {
fprintf(fp, "\" \"" );
}
else {
NedPangoCairoText::makeLilyString(m_lyrics[line_nr]->getText(), buffer);
fprintf(fp, "%s ", buffer);
}
(*sil_count)++;
if (*sil_count > MAX_LILY_SIL_COUNT) {
fprintf(fp, "\n\t");
*sil_count = 0;
}
break;
}
}
void NedChordOrRest::exportLilyGuitarChordnames(FILE *fp, int *last_line, unsigned int *midi_len) {
GList *lptr;
int dotcount;
unsigned int duration, len2;
char Str[100], Str2[100];
int i;
bool chord_name_written = false;
duration = getDuration();
if ((m_type & (TYPE_CHORD | TYPE_REST)) == 0) return;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_CHORD) {
if (((((NedFreeChord *) lptr->data)->getStatus() & GUITAR_CHORD_DRAW_TEXT) != 0)) {
NedChordPainter::writeLilyChordName(fp, (NedFreeChord *) lptr->data, m_length, duration, m_dot_count, midi_len);
chord_name_written = true;
}
}
}
if (chord_name_written) return;
if (m_length == WHOLE_NOTE && duration != WHOLE_NOTE) {
NedResource::setLengthField(duration);
len2 = NedResource::getPartLength(&dotcount);
sprintf(Str, "s%d", WHOLE_NOTE / len2);
for (i = 0; i < dotcount; i++) {
strcat(Str, ".");
}
strcat(Str, " ");
len2 = NedResource::getPartLength(&dotcount);
while (len2) {
sprintf(Str2, "s%d", WHOLE_NOTE / len2);
strcat(Str, Str2);
for (i = 0; i < dotcount; i++) {
strcat(Str, ".");
}
strcat(Str, " ");
len2 = NedResource::getPartLength(&dotcount);
}
fprintf(fp, Str);
*midi_len = 0;
}
else {
if (*midi_len == getDuration()) {
fprintf(fp, "s");
}
else {
fprintf(fp, "s%d ", WHOLE_NOTE / m_length);
for (i = 0; i < m_dot_count; i++) {
fprintf(fp, ".");
}
*midi_len = getDuration();
}
}
putc(' ', fp);
}
void NedChordOrRest::exportLilyFreeChordName(FILE *fp, int *last_line, unsigned int *midi_len) {
GList *lptr;
int dotcount;
unsigned int duration, len2;
char Str[100], Str2[100];
int i;
bool chord_name_written = false;
duration = getDuration();
if ((m_type & (TYPE_CHORD | TYPE_REST)) == 0) return;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_CHORDNAME) {
NedResource::writeLilyFreeChord(fp, (NedChordName *) lptr->data, m_length, duration, m_dot_count, midi_len);
chord_name_written = true;
}
}
if (chord_name_written) return;
if (m_length == WHOLE_NOTE && duration != WHOLE_NOTE) {
NedResource::setLengthField(duration);
len2 = NedResource::getPartLength(&dotcount);
sprintf(Str, "s%d", WHOLE_NOTE / len2);
for (i = 0; i < dotcount; i++) {
strcat(Str, ".");
}
len2 = NedResource::getPartLength(&dotcount);
while (len2) {
sprintf(Str2, "s%d", WHOLE_NOTE / len2);
strcat(Str, Str2);
for (i = 0; i < dotcount; i++) {
strcat(Str, ".");
}
strcat(Str, " ");
len2 = NedResource::getPartLength(&dotcount);
}
fprintf(fp, Str);
*midi_len = 0;
}
else {
if (*midi_len == getDuration()) {
fprintf(fp, "s");
}
else {
fprintf(fp, "s%d ", WHOLE_NOTE / m_length);
for (i = 0; i < m_dot_count; i++) {
fprintf(fp, ".");
}
*midi_len = getDuration();
}
}
putc(' ', fp);
}
void NedChordOrRest::collectLyrics(NedLyricsEditor *leditor) {
GList *lptr;
bool has_tie;
int line_nr;
if (m_type != TYPE_CHORD) return;
has_tie = false;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
if (((NedNote *) lptr->data)->getTieBackward() != NULL) {
has_tie = true;
}
}
if (has_tie) {
return;
}
for (line_nr = 0; line_nr < MAX_LYRICS_LINES; line_nr++) {
if (m_lyrics[line_nr] == NULL) {
leditor->addDot(line_nr);
}
else {
leditor->appendText(line_nr, m_lyrics[line_nr]->getText());
}
}
}
void NedChordOrRest::zoomFreeReplaceables(double zoom, double scale) {
GList *lptr;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() & (FREE_PLACEABLE_TEXT|TYPE_CHORDNAME|FREE_PLACEABLE_CHORDNAME)) {
((NedFreeReplaceable *) lptr->data)->setZoom(zoom, scale);
}
}
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
if (m_lyrics[i] != NULL) {
m_lyrics[i]->setZoom(zoom, scale);
}
}
}
double NedChordOrRest::determineTempoInverse() {
return getMainWindow()->determineTempoInverse(this);
}
void NedChordOrRest::determineTempoInverse(double *tempoinverse) {
GList *lptr;
double temp;
for (lptr = g_list_first(m_freedisp); lptr; lptr = g_list_next(lptr)) {
if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_LINE_POINT) {
if ((((NedLinePoint *) lptr->data)->getLine()->getLineType() & LINE_TEMPO_CHANGE) != 0) {
NedLinePoint *startp = ((NedLinePoint *) lptr->data)->getLine()->getLineStartPoint();
if (startp == lptr->data) {
temp = 60000.0 / *tempoinverse;
temp += ((NedAcceleration *) ((NedLinePoint *) lptr->data)->getLine())->m_tempodiff;
*tempoinverse = 60000.0 / temp;
if (*tempoinverse < 10.0) *tempoinverse = 10.0;
if (*tempoinverse > 999.0) *tempoinverse = 999.0;
}
}
}
else if (((NedFreeReplaceable *) lptr->data)->getType() == FREE_PLACEABLE_TEMPO) {
*tempoinverse = ((NedTempoSign *) lptr->data)->getTempoInverse();
}
}
}
void NedChordOrRest::removeUnneededAccidentals(int clef, int keysig, int octave_shift) {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->removeUnneededAccidental(clef, keysig, octave_shift);
}
}
void NedChordOrRest::setOffset(char offs_array[115]) {
GList *lptr;
for (lptr = g_list_first(m_notes); lptr; lptr = g_list_next(lptr)) {
((NedNote *) lptr->data)->setOffset(offs_array);
}
}
NedChordOrRest *NedChordOrRest::restoreChordOrRest(FILE *fp, NedVoice *voice) {
char buffer[128], note_descr[128], *cptr;
NedChordOrRest *chord_or_rest;
NedNote *note;
int ival;
double fval;
int length;
int dotcount = 0;
int marker, chord_marker;
bool marker_read = FALSE, chord_marker_read = FALSE;
unsigned int status = 0;
int line, head;
int rest_line = -1000;
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "Note or address expected";
return NULL;
}
if (!strcmp(buffer, "<")) {
if (!NedResource::readInt(fp, &chord_marker)) {
NedResource::m_error_message = "Hex number expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ">")) {
NedResource::m_error_message = "> expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "Note expected";
return NULL;
}
chord_marker_read = TRUE;
}
strcpy(note_descr, buffer);
if (!NedResource::readInt(fp, &length)) {
NedResource::m_error_message = "Note length expected";
return NULL;
}
if (voice->getMainWindow()->getFileVersion() > 5) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ",")) {
NedResource::m_error_message = ", expected(0)";
return NULL;
}
if (!NedResource::readHex(fp, (int *) &status)) {
NedResource::m_error_message = "status expected";
return NULL;
}
}
if (status & STAT_USER_PLACED_REST) {
if (!NedResource::readInt(fp, &rest_line)) {
NedResource::m_error_message = "rest line expected(1)";
return NULL;
}
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "{ or D expected";
return NULL;
}
if (!strcmp(buffer, "D")) {
if (!NedResource::readInt(fp, &dotcount)) {
NedResource::m_error_message = "dotcount expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "{ expected";
return NULL;
}
}
if (note_descr[0] == 'r') {
if (note_descr[1] != '\0') {
if (note_descr[1] != 'h') {
NedResource::m_error_message = "rh expected";
return NULL;
}
if (voice->getMainWindow()->getFileVersion() > 9) {
chord_or_rest = new NedChordOrRest(voice, TYPE_REST, TRUE, 3, dotcount, length * LENGH_FACTOR, NORMAL_NOTE, status, 0);
}
else {
chord_or_rest = new NedChordOrRest(voice, TYPE_REST, TRUE, 3, dotcount, length * FACTOR, NORMAL_NOTE, status, 0);
}
if (chord_marker_read) {
NedResource::addAddr(chord_marker, chord_or_rest);
}
if (rest_line > -900) {
chord_or_rest->moveToLine(rest_line);
}
return chord_or_rest;
}
if (voice->getMainWindow()->getFileVersion() > 9) {
chord_or_rest = new NedChordOrRest(voice, TYPE_REST, FALSE, 3, dotcount, length * LENGH_FACTOR, NORMAL_NOTE, status, 0);
}
else {
chord_or_rest = new NedChordOrRest(voice, TYPE_REST, FALSE, 3, dotcount, length * FACTOR, NORMAL_NOTE, status, 0);
}
if (chord_marker_read) {
NedResource::addAddr(chord_marker, chord_or_rest);
}
if (rest_line > -900) {
chord_or_rest->moveToLine(rest_line);
}
return chord_or_rest;
}
if (note_descr[0] != 'n') {
NedResource::m_error_message = "n or r expected";
return NULL;
}
if (strcmp(buffer, "{")) {
NedResource::m_error_message = "{ expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = " | _, b , #, p, c, or = expected(1)";
return NULL;
}
if (buffer[0] == '|') {
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "addr expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != '|' || buffer[1] != '\0') {
NedResource::m_error_message = " | expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = " _, b , #, p, c, or = expected";
return NULL;
}
marker_read = TRUE;
}
switch (buffer[0]) {
case '_': break;
case 'b': status |= STAT_FLAT; break;
case 'p': status |= STAT_DFLAT; break;
case '#': status |= STAT_SHARP; break;
case 'c': status |= STAT_DSHARP; break;
case '=': status |= STAT_NATURAL; break;
default: NedResource::m_error_message = "_, b , #, p, c, or = expected"; return NULL;
}
if (!NedResource::readInt(fp, &line) || line < MIN_LINE || line > MAX_LINE) {
printf("line = %d\n", line); fflush(stdout);
NedResource::m_error_message = "line expected(2)";
return NULL;
}
head = NORMAL_NOTE;
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = " [ or } or , expected";
return NULL;
}
if (strcmp(buffer, "[")) {
NedResource::unreadWord(buffer);
}
else {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "head")) {
NedResource::m_error_message = "head expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": expected";
return NULL;
}
if (!NedResource::readInt(fp, &head) || head < CROSS_NOTE1 || head > CLOSED_HIGH_HAT) {
NedResource::m_error_message = "head value expected(2)";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "]")) {
NedResource::m_error_message = "] expected";
return NULL;
}
}
if (voice->getMainWindow()->getFileVersion() > 9) {
chord_or_rest = new NedChordOrRest(voice, TYPE_CHORD, FALSE, line, dotcount, length * LENGH_FACTOR, head, status, 0);
}
else {
chord_or_rest = new NedChordOrRest(voice, TYPE_CHORD, FALSE, line, dotcount, length * FACTOR, head, status, 0);
}
if (chord_marker_read) {
NedResource::addAddr(chord_marker, chord_or_rest);
}
if (marker_read) {
NedResource::addAddr(marker, g_list_first(chord_or_rest->m_notes)->data);
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = " } or , expected";
return NULL;
}
while (buffer[0] != '}') {
marker_read = FALSE;
if (buffer[0] != ',') {
NedResource::DbgMsg(DBG_CRITICAL, "gelesen(1): *%s*\n", buffer);
NedResource::m_error_message = " , expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::DbgMsg(DBG_CRITICAL, "buffer = %s\n", buffer);
NedResource::m_error_message = " | _, b , #, p, c, or = expected(2)";
return NULL;
}
if (buffer[0] == '|') {
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "addr expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != '|' || buffer[1] != '\0') {
NedResource::m_error_message = " | expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = " _, b , #, p, c, or = expected";
return NULL;
}
marker_read = TRUE;
}
status = 0;
switch (buffer[0]) {
case '_': break;
case 'p': status |= STAT_DFLAT; break;
case 'b': status |= STAT_FLAT; break;
case '#': status |= STAT_SHARP; break;
case 'c': status |= STAT_DSHARP; break;
case '=': status |= STAT_NATURAL; break;
default: NedResource::m_error_message = "_, b , #, p, c or = expected"; return NULL;
}
if (!NedResource::readInt(fp, &line) || line < MIN_LINE || line > MAX_LINE) {
printf("line = %d\n", line); fflush(stdout);
NedResource::m_error_message = "line expected(3)";
return NULL;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = " }, [ or , expected";
return NULL;
}
head = NORMAL_NOTE;
if (strcmp(buffer, "[")) {
NedResource::unreadWord(buffer);
}
else {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "head")) {
NedResource::m_error_message = "head expected";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": expected";
return NULL;
}
if (!NedResource::readInt(fp, &head) || head < CROSS_NOTE1 || head > CLOSED_HIGH_HAT) {
NedResource::m_error_message = "head value expected(1)";
return NULL;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "]")) {
NedResource::m_error_message = "] expected";
return NULL;
}
}
note = new NedNote(chord_or_rest, line, head, status);
void *addr = (void *) note;
chord_or_rest->insertNoteAt(note, FALSE);
if (marker_read) {
NedResource::addAddr(marker, addr);
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::DbgMsg(DBG_CRITICAL, "gelesen(2): *%s*\n", buffer);
NedResource::m_error_message = " } or , expected";
return NULL;
}
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = " ) or STEM_HEIGHT or BEAM_Y_OFFS or BEAM_SLOPE_OFFS expected";
return NULL;
}
while (!strcmp(buffer, "STEM_HEIGHT") || !strcmp(buffer, "BEAM_Y_OFFS") || !strcmp(buffer, "BEAM_SLOPE_OFFS")) {
if (!strcmp(buffer, "STEM_HEIGHT")) {
if (!NedResource::readWord(fp, buffer) || buffer[0] != ':' || buffer[1] != '\0') {
NedResource::m_error_message = " : expected";
return NULL;
}
if (!NedResource::readFloat(fp, &fval)) {
NedResource::m_error_message = "stem height value expected";
return NULL;
}
chord_or_rest->setStemHeight(fval);
}
else if (!strcmp(buffer, "BEAM_Y_OFFS")) {
if (!NedResource::readWord(fp, buffer) || buffer[0] != ':' || buffer[1] != '\0') {
NedResource::m_error_message = " : expected";
return NULL;
}
if (!NedResource::readFloat(fp, &fval)) {
NedResource::m_error_message = "beam y offset value expected";
return NULL;
}
chord_or_rest->setBeamYOffset(fval);
}
else if (!strcmp(buffer, "BEAM_SLOPE_OFFS")) {
if (!NedResource::readWord(fp, buffer) || buffer[0] != ':' || buffer[1] != '\0') {
NedResource::m_error_message = " : expected";
return NULL;
}
if (!NedResource::readInt(fp, &ival)) {
NedResource::m_error_message = "beam slope offset value expected";
return NULL;
}
chord_or_rest->setBeamSlopeOffset(ival);
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = " ) or STEM_HEIGHT or BEAM_Y_OFFS or BEAM_SLOPE_OFFS expected";
return NULL;
}
}
if (buffer[0] == '[' && buffer[1] == '\0') {
line = 0;
while (buffer[0] != ']') {
if (!NedResource::readString(fp, buffer)) {
NedResource::m_error_message = "lyrics expected";
return NULL;
}
if (buffer[0] == ',' && buffer[1] == '\0') {
line++;
continue;
}
while ((cptr = strchr(buffer, '_')) != NULL) *cptr = ' ';
chord_or_rest->createLyrics(line, buffer);
if (!NedResource::readWord(fp, buffer) || (buffer[0] != ']' && buffer[0] != ',') || buffer[1] != '\0') {
NedResource::m_error_message = ", or ] expected";
return NULL;
}
line++;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != ')' || buffer[1] != '\0') {
NedResource::m_error_message = " ) expected";
return NULL;
}
}
else if (buffer[0] != ')' || buffer[1] != '\0') {
NedResource::m_error_message = " ) expected";
return NULL;
}
chord_or_rest->xPositNotes();
chord_or_rest->computeBbox();
return chord_or_rest;
}
void NedChordOrRest::removeFreeDisplaceable(NedFreeReplaceable *freedisplaceable) {
GList *lptr;
if ((lptr = g_list_find(m_freedisp, freedisplaceable)) == NULL) {
NedResource::Abort("removeFreeDisplaceable");
}
m_freedisp = g_list_delete_link(m_freedisp, lptr);
}
void NedChordOrRest::addFreeDislaceable(NedFreeReplaceable *freedisplaceable) {
if (g_list_find(m_freedisp, freedisplaceable)) {
return;
}
m_freedisp = g_list_append(m_freedisp, freedisplaceable);
}
nted-1.10.18/octavation.cpp 0000664 0010410 0000764 00000012050 11520267230 012403 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "octavation.h"
#include "linepoint.h"
#include "page.h"
#include "staff.h"
#include "chordorrest.h"
#include "system.h"
#include "volumedialog.h"
#include
#define X_POS_PAGE_REL(sp, p) ((sp->m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define X_PAGE_POS_PAGE_REL(page, p) (((page)->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
static double dash_array[2] = {1.0, 3.0};
NedOctavation::NedOctavation(NedLinePoint *start, NedLinePoint *end, int sub_type) :
NedLine(start, end), m_octave_dist(1) {
switch(sub_type) {
case LINE_OCTAVATION_1: m_octave_dist = -1; break;
case LINE_OCTAVATION2: m_octave_dist = 2; break;
case LINE_OCTAVATION_2: m_octave_dist = -2; break;
}
}
NedOctavation::NedOctavation(NedLinePoint *start, NedLinePoint *end, NedLinePoint *dummy, int octave_shift) :
NedLine(start, end), m_octave_dist(1) {
switch(octave_shift) {
case -12: m_octave_dist = -1; break;
case 24: m_octave_dist = 2; break;
case -24: m_octave_dist = -2; break;
}
}
#define OCTAVIATION_THICK 0.03
#define OCT_SIGN_LENGTH1 0.5
#define OCT_SIGN_LENGTH2 0.8
void NedOctavation::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level) {
double ypos1;
NedStaff *staff;
GList *lptr, *last;
cairo_glyph_t glyph;
double sign_length = OCT_SIGN_LENGTH1;
if (!m_allow_drawing) return;
cairo_new_path(cr);
switch (m_octave_dist) {
case 1: glyph.index = BASE + 41; break;
case -1: glyph.index = BASE + 42; break;
case 2: glyph.index = BASE + 43;
sign_length = OCT_SIGN_LENGTH2;
break;
case -2: glyph.index = BASE + 44;
sign_length = OCT_SIGN_LENGTH2;
break;
}
glyph.x = X_POS_PAGE_REL(m_line_start_point, m_start_x);
glyph.y = Y_POS_PAGE_REL(m_start_y);
cairo_show_glyphs(cr, &glyph, 1);
cairo_new_path(cr);
cairo_stroke(cr);
cairo_set_line_width(cr, zoom_factor * OCTAVIATION_THICK);
cairo_set_dash(cr, dash_array, 2, 0.0);
if (m_distributed) {
if ((lptr = g_list_first(m_intermediate_staves)) == NULL) {
NedResource::Abort("NedOctavation::draw: error 1");
}
last = g_list_last(m_intermediate_staves);
staff = (NedStaff *) lptr->data;
cairo_new_path(cr);
cairo_move_to(cr, X_PAGE_POS_PAGE_REL(staff->getPage(), m_start_x), Y_POS_PAGE_REL(m_start_y));
cairo_line_to(cr, X_PAGE_POS_PAGE_REL(staff->getPage(), staff->getSystemEnd()), Y_POS_PAGE_REL(m_start_y));
cairo_stroke(cr);
for (lptr = g_list_next(lptr); lptr != last; lptr = g_list_next(lptr)) {
staff = (NedStaff *) lptr->data;
ypos1 = staff->getSystem()->getYPos() + staff->getMidPos() + m_line_start_point->getYposRelative();
cairo_new_path(cr);
cairo_move_to(cr, X_PAGE_POS_PAGE_REL(staff->getPage(), staff->getSystemStart()), Y_POS_PAGE_REL(ypos1));
cairo_line_to(cr, X_PAGE_POS_PAGE_REL(staff->getPage(), staff->getSystemEnd()), Y_POS_PAGE_REL(ypos1));
cairo_stroke(cr);
}
staff = (NedStaff *) lptr->data;
ypos1 = staff->getSystem()->getYPos() + staff->getMidPos() + m_line_start_point->getYposRelative();
cairo_new_path(cr);
cairo_move_to(cr, X_PAGE_POS_PAGE_REL(staff->getPage(), staff->getSystemStart()), Y_POS_PAGE_REL(ypos1));
cairo_line_to(cr, X_PAGE_POS_PAGE_REL(staff->getPage(), m_end_x), Y_POS_PAGE_REL(ypos1));
cairo_stroke(cr);
}
else {
cairo_move_to(cr, X_POS_PAGE_REL(m_line_start_point, m_start_x + sign_length), Y_POS_PAGE_REL(m_start_y));
cairo_line_to(cr, X_POS_PAGE_REL(m_line_end_point, m_end_x), Y_POS_PAGE_REL(m_start_y));
cairo_stroke(cr);
}
cairo_set_dash(cr, dash_array, 0, 0.0);
}
int NedOctavation::getLineType() {
switch (m_octave_dist) {
case 1: return LINE_OCTAVATION1;
case -1: return LINE_OCTAVATION_1;
case 2: return LINE_OCTAVATION2;
}
return LINE_OCTAVATION_2;
}
int NedOctavation::getPitchOffset() {
switch (m_octave_dist) {
case 1: return 12;
case -1: return -12;
case 2: return 24;
}
return -24;
}
nted-1.10.18/volumesign.h 0000664 0010410 0000764 00000004433 11520267230 012077 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef VOLUME_SIGN_H
#define VOLUME_SIGN_H
#include "freereplaceable.h"
#define VOL_PPP 1
#define VOL_PP 2
#define VOL_P 3
#define VOL_MF 4
#define VOL_SF 5
#define VOL_MP 6
#define VOL_SP 7
#define VOL_F 8
#define VOL_FF 9
#define VOL_FFF 10
class NedVolumeSign : public NedFreeReplaceable {
public:
NedVolumeSign(int kind);
NedVolumeSign(int kind, NedChordOrRest *element);
NedVolumeSign(int kind, NedChordOrRest *element, double x, double y, bool relative);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL );
virtual void adjust_pointers(struct addr_ref_str *slurlist);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_VOLSIGN;}
static int determineKind(int volume);
int getKind() {return m_kind;}
virtual void startContextDialog(GtkWidget *ref);
int m_midi_volume;
private:
void setMidiVolume();
int m_kind;
};
#endif /* VOLUME_SIGN_H */
nted-1.10.18/note.h 0000664 0010410 0000764 00000013233 11520267230 010652 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef NOTE_H
#define NOTE_H
#include "config.h"
#include
#include
#include "chordorrest.h"
#include "resource.h"
class NedMainWindow;
class NedPage;
class NedSystem;
class NedStaff;
class NedVoice;
class NedChordOrRest;
class NedBbox;
class NedCommandList;
struct pitch_descr;
#define UNKNOWN_LINE -1111111
class NedNote {
public:
NedNote(NedChordOrRest *chord_or_rest, int line, int head, unsigned int status);
void draw(cairo_t *cr);
static gint compare(NedNote *a, NedNote *b);
NedMainWindow *getMainWindow();
NedPage *getPage();
NedSystem *getSystem();
NedStaff *getStaff();
NedVoice *getVoice();
NedChordOrRest *getChord() {return m_chord_or_rest;}
void setChord(NedChordOrRest *chord) {m_chord_or_rest = chord;}
void handleRelease() {m_tmp_line = UNKNOWN_LINE;}
bool noConflict();
void shiftNote(bool shift);
double placeAccidental(bool all_shifted, int acc_places[4], bool has_arpeggio, bool out);
void collectNotesWithAccidentals(unsigned int *num_notes_with_accidentals, NedNote **note_field);
static int compare_note_lines(NedNote **n1, NedNote **n2);
bool trySelect (double x, double y);
double getYpos();
bool testYShift(double y);
void moveUpDown(int line);
bool testRelativeMove(int dist);
int getTempLine() {return (m_tmp_line == m_line) ? UNKNOWN_LINE : m_tmp_line;}
int getLine() {return m_line;}
void shiftNoteLine(int linedist);
unsigned int getStatus() {return m_status;}
void setStatus(unsigned int status);
void computeBounds(int len, double *minx, double *miny, double *maxx, double *maxy);
void do_tie(NedNote *other_note);
void setTieSimple(NedNote *other_note);
void setTieIfSamePitch(NedNote *other_note, bool check_pitch);
void computeTie();
bool isTheSame(NedNote *other_note);
void tryTieBackward();
void removeBackwardTie();
void resetActiveFlag() {m_active = NOTE_ACTIVE_STATE_NONE;}
void removeForwardTie();
void setTieForward(NedNote *tie_forward) {m_tie_forward = tie_forward;}
void setTieBackward(NedNote *tie_backward) {m_tie_backward = tie_backward;}
bool testForTiesToDelete(NedCommandList *command_list, unsigned int dir = BREAK_TIE_BACKWARD, bool execute = false);
NedNote *getTieForward() {return m_tie_forward;}
NedNote *getTieBackward() {return m_tie_backward;}
void correctTieForward();
void saveNote(FILE *fp);
void saveTies(FILE *fp, bool *ties_written);
bool test_tie_increment(double incr);
void setInternalPitch(int pitchdist, int clef, int keysig, int octave_shift);
void adjustAccidental(int clef, int keysig, int octave_shift);
void changeAccidental(NedCommandList *command_list, int preferred_offs, int clef, int keysig, int octave_shift);
void prepareReplay(unsigned long long midi_start_time, int clef, int keysig,
int octave_shift, int pitch_offs, int voice_idx, unsigned int grace_time, bool is_grace, bool is_stacc, unsigned short segno_sign);
char m_active;
int getPitch(int clef, int keysig, int octave_shift, int pitch_offs, bool *flat, bool use_transpose);
int getPitch();
void removeUnneededAccidental(int clef, int keysig, int octave_shift);
int getNoteHead() {return m_head;}
void setNoteHead(int head) {m_head = head;}
void setOffset(char offs_array[OFFS_ARRAY_SIZE]);
static void setTies(NedNote *n1, NedNote *n2);
void adjust_pointers(struct addr_ref_str *addrlist);
void exportLilyPond(FILE *fp, int *last_line, bool *tie);
static int determineLineOf(int oldline, int newclef);
static int pitchToLine(int pitch, int clef, int keysig, int octave_shift, int *offs, int preferred_offs = 0);
static unsigned int determineState(int pitch, int line, int half_offs, char offs_array[115], int keysig);
bool isFirstNote();
void setTieOffset(double offs) {m_tie_offs = offs;}
private:
int findPitchUpDown(int key, int pitch, int dist);
int getDrumPitch();
void exportLilyPondDrums(FILE *fp);
static pitch_descr lineToPitch[];
static int signToBase[][2];
static int diaDists[];
double m_xpos, m_ypos;
double m_tmp_ypos;
double m_acc_dist;
int m_line, m_tmp_line;
unsigned int m_status;
int m_head;
NedChordOrRest *m_chord_or_rest;
NedNote *m_tie_forward, *m_tie_backward;
double m_tie_y_offs1, m_tie_y_offs2;
double m_tie_xpos0, m_tie_xpos1;
double m_tie_back_xpos0, m_tie_back_xpos1;
double m_tie_offs;
int m_pitch; // used temporarily
friend class NedChangeTieCommand;
friend class NedTieNotesCommand;
friend class NedMoveNoteRelativeCommand;
friend class NedChangeAccidentalCommand;
};
#endif /* NOTE_H */
nted-1.10.18/COPYING.GFDL 0000664 0010410 0000764 00000047663 11520267230 011320 0000000 0000000 GNU Free Documentation License
Version 1.2, November 2002
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as "you". You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (Thus, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the "History" section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
Copyright (c) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
nted-1.10.18/resource.h 0000664 0010410 0000764 00000073321 11520267230 011540 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef RESOURCE_H
#define RESOURCE_H
#include "config.h"
#include
#include
#include
#include
#define FONTFILE "ntedfont.pfa"
#define WIDTH 1023
#define HEIGHT 767
#define ZOOMLEVELS 20
#define MAXELEMENTS 30
#define DEFAULT_BORDER 0.2
#define LEFT_RIGHT_BORDER 1.5
#define TOP_BOTTOM_BORDER 1.5
#define FONT_REL_SIZE 10.0
#define STAFF_TOP_DIST (5.0 * LINE_DIST)
#define PS_ZOOM 24.0
#define PS_ZOOM2 22.4
#define LINE_DIST 0.22
#define LINE_THICK 0.02
#define MEASURE_LINE_THICK 0.03
#define BEAM_THICK 0.1
#define STEM_DEFAULT_HEIGHT (3.4 * LINE_DIST)
#define STEM_THICK 0.04
#define HEAD_THICK (1.2 * LINE_DIST)
#define HEAD_THICK_HALF (1.09 * HEAD_THICK)
#define FLAG_DIST (0.87 * LINE_DIST)
#define STEM_TOP_DIST 0.09
#define HEAD_THICK_2 (HEAD_THICK / 2.0)
#define HEAD_THICK_HALF_2 (HEAD_THICK_HALF / 2.0)
#define HEAD_HIGHT (1.0 * LINE_DIST)
#define HEAD_HIGHT_HALF HEAD_HIGHT
#define HEAD_HIGHT_2 (HEAD_HIGHT / 2.0)
#define HEAD_HIGHT_HALF_2 (HEAD_HIGHT_HALF / 2.0)
#define BRACE_SPACE 0.05
#define BRACE_X_OFFSET 5.0
#define BRACKET_INDENT 0.2
#define NESTED_BRACE_INDENT 0.18
#define VOICE_COUNT 4
#define COUNT_OF_PARALLEL_ELEMENTS 1024
#define MIN_SELECTION_RECTANGLE_DIM 2.0
#define TRIPLET_VAL_SHIFT_X 0.15
#define TUPLET_XOVER 0.15
#define TUPLET_XFRONTOVER 0.1
#define TUPLET_MARKER_DIST 0.1
#define TUPLET_MARKER_DIST_UP 0.2
#define TUPLET_MARKER_DIST_DOWN 0.8
#define NUMNBER_GLYPH_WIDTH 0.4
#define NUMNBER_GLYPH_HEIGHT_UP 0.0
#define NUMNBER_GLYPH_HEIGHT_DOWN 0.6
#define NUMNBER_GLYPH_HEIGHT -0.3
#define TUPLET_LINE_THICK 0.02
#define TUPLET_BRACKET_HEIGHT 0.1
#define FIRST_TUPLET_DIGIT_DIST 0.2
#define TUPLET_MARKER_HEIGHT 0.7
#define DOT1POS (0.145 * LINE_DIST)
#define DOT2POS (0.76 * LINE_DIST)
#define DOT1_REST_POS (0.87 * LINE_DIST)
#define DOT2_REST_POS (1.0 * LINE_DIST)
#define DOT_RAD 0.05
#define WHOLE_NOTE_X_OFFS (0.43 * LINE_DIST)
#define HALF_NOTE_X_OFFS (0.43 * LINE_DIST)
#define WHOLE_NOTE_Y_OFFS (-0.217 * LINE_DIST)
#define HALF_NOTE_Y_OFFS (0.2 * LINE_DIST)
#define ACCIDENTAL_BASE_DIST (1.3 * LINE_DIST)
#define MIN_SHIFT_X_DIFF (0.87 * LINE_DIST)
#define START_ZOOM_LEVEL (ZOOMLEVELS / 2)
#define BASE 66
#define FONT_FACTOR 0.97
#define START_TEMPO_INVERSE 500.0
#define NUMBERBASE 49
#define SIG_HALF (0.4 * LINE_DIST)
#define Y_NUMRATOR_POS (-1.6 * LINE_DIST)
#define Y_DENOMINATOR_POS (0.4 * LINE_DIST)
#define AUX_LINE_OVER (0.435 * LINE_DIST)
#define AUX_LINE_THICK (0.087 * LINE_DIST)
#define MAX_LINE 30
#define MIN_LINE -MAX_LINE
#define TIE_X_START (0.456 * LINE_DIST)
#define TIE_X_START_LARGE (0.6 * LINE_DIST)
#define MIN_TIE_LEN 1.2
#define TIE_Y_OFFS1 (1.74 * LINE_DIST)
#define TIE_Y_OFFS2 (2.174 * LINE_DIST)
#define TIE_X_RIGHT_OVER (3.48 * LINE_DIST)
#define TIE_X_OFFS 0.5
#define D_TIE 0.1
#define MAX_TIE_INCR 1.5
#define MIN_TIE_INCR -1.5
#define SORTING_NONE 0
#define SORTING_LESS 1
#define SORTING_GREAT 2
#define STEM_DIR_NONE 0
#define STEM_DIR_UP 1
#define STEM_DIR_DOWN 2
#define LYRICS_FONT_SIZE 0.4
#define LYRICS_FONT "Sans"
#define LYRICS_FONT_SLANT PANGO_STYLE_NORMAL
#define LYRICS_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define TITLE_FONT_SIZE 0.8
#define TITLE_FONT "Serif"
#define TITLE_FONT_SLANT PANGO_STYLE_NORMAL
#define TITLE_FONT_WEIGHT PANGO_WEIGHT_BOLD
#define SUBJECT_FONT_SIZE 0.5
#define SUBJECT_FONT "Serif"
#define SUBJECT_FONT_SLANT PANGO_STYLE_ITALIC
#define SUBJECT_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define COMPOSER_FONT_SIZE 0.5
#define COMPOSER_FONT "Sans"
#define COMPOSER_FONT_SLANT PANGO_STYLE_NORMAL
#define COMPOSER_FONT_WEIGHT PANGO_WEIGHT_BOLD
#define ARRANGER_FONT_SIZE 0.5
#define ARRANGER_FONT "Sans"
#define ARRANGER_FONT_SLANT PANGO_STYLE_NORMAL
#define ARRANGER_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define COPYRIGHT_FONT_SIZE 0.4
#define COPYRIGHT_FONT "Sans"
#define COPYRIGHT_FONT_SLANT PANGO_STYLE_NORMAL
#define COPYRIGHT_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define STAFF_NAME_FONT_SIZE 0.4
#define STAFF_NAME_FONT "Serif"
#define STAFF_NAME_FONT_SLANT PANGO_STYLE_NORMAL
#define STAFF_NAME_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define STAFF_SHORT_NAME_FONT_SIZE 0.4
#define STAFF_SHORT_NAME_FONT "Serif"
#define STAFF_SHORT_NAME_FONT_SLANT PANGO_STYLE_NORMAL
#define STAFF_SHORT_NAME_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define TEXT_FONT_NAME_DEFAULT "Sans"
#define TEXT_FONT_SIZE_DEFAULT 0.5
#define TEXT_FONT_SLANT_DEFAULT PANGO_STYLE_NORMAL
#define TEXT_FONT_WEIGHT_DEFAULT PANGO_WEIGHT_NORMAL
#define SYSTEM_INTENT_SEC_SPACE 0.2
#define SCORE_INFO_EXTRA_DIST 0.1
#define SCALE_GRANULARITY 50
#define SCALE_MIN 0.6
#define SCALE_MAX 1.4
#define TEXT_Y_OFFS (- 2.0 * LINE_DIST)
#define LYRICS_HEIGHT 0.35
#define MAX_LYRICS_LINES 5
#define MAX_TEXT_LENGTH 10
/* WHOLE_NOTE divisable by 13, 12, ... 5, 4, 3, 2, 1
* and 20 * WHOLE_NOTE < 2^31 - 1
* permits 13plets and up to 20 whole notes per staff
*/
#define FACTOR (13*11*9*8*7*5)
#define WHOLE_NOTE (128*FACTOR)
#define NOTE_2 (WHOLE_NOTE/2)
#define NOTE_4 (NOTE_2/2)
#define NOTE_8 (NOTE_4/2)
#define NOTE_16 (NOTE_8/2)
#define NOTE_32 (NOTE_16/2)
#define NOTE_64 (NOTE_32/2)
#define NOTE_128 (NOTE_64/2)
#define GRACE_DURATION NOTE_32
#define NORMAL_NOTE 0
#define CROSS_NOTE1 1
#define CROSS_NOTE2 2
#define RECT_NOTE1 3
#define RECT_NOTE2 4
#define TRIAG_NOTE1 5
#define TRIAG_NOTE2 6
#define CROSS_NOTE3 7
#define CROSS_NOTE4 8
#define TRIAG_NOTE3 9
#define QUAD_NOTE2 10
#define GUITAR_NOTE_STEM 11
#define GUITAR_NOTE_NO_STEM 12
#define OPEN_HIGH_HAT 13
#define CLOSED_HIGH_HAT 14
#define COUNT_OF_DRUMS_TO_CHOOSE_DURING_MIDI_IMPORT 9
#define OFFSET_TO_BE_USED_DURING_MIDI_IMPORT 1007
#define STROKEN_GRACE (NOTE_64/2)
#define GRACE_8 (STROKEN_GRACE/2)
#define GRACE_16 (GRACE_8/2)
#define GRACE_NOTE_TIME NOTE_32
#define LENGH_FACTOR GRACE_16
#define GRACE_HEIGHT1 0.0
#define GRACE_HEIGHT2 0.1
#define GRACE_HEIGHT3 0.5
#define GRACE_HEAD_THICK 0.12
#define GRACE_HEAD_THICK_HALF (GRACE_HEAD_THICK / 2.0)
#define GRACE_STEM_THICK 0.03
#define GRACE_BEAM_THICK 0.06
#define GRACE_BEAM_DIST 0.1
#define SIGN_BREATH1 3
#define SIGN_BREATH2 4
#define LILY_BREAH_SCRIPT_RCOMMA 0
#define LILY_BREAH_SCRIPT_UPBOW 1
#define SHIFT_MODE (1 << 0)
#define INSERT_EREASE_MODE (1 << 1)
#define KEYBOARD_CTRL_MODE (1 << 2)
#define STAT_UP (1 << 0)
#define STAT_SHARP (1 << 1)
#define STAT_FLAT (1 << 2)
#define STAT_NATURAL ((1 << 1) | (1 << 2))
#define STAT_DSHARP (1 << 3)
#define STAT_DFLAT ((1 << 3) | (1 << 1))
#define ACCIDENTAL_MASK ((1 << 1) | (1 << 2) | (1 << 3))
#define STAT_STACC (1 << 4)
#define STAT_PIZZ (1 << 5)
#define STAT_TENUTO (1 << 6)
#define STAT_SFORZATO (1 << 7)
#define STAT_SFORZANDO (1 << 8)
#define STAT_BOW_UP (1 << 9)
#define STAT_BOW_DOWN (1 << 10)
#define STAT_PED_ON (1 << 11)
#define STAT_PED_OFF (1 << 12)
#define STAT_TRILL (1 << 13)
#define STAT_PRALL (1 << 14)
#define STAT_MORDENT (1 << 15)
#define STAT_OPEN (1 << 16)
#define STAT_STACCATISSIMO (1 << 17)
#define STAT_FERMATA (1 << 18)
#define STAT_ARPEGGIO (1 << 19)
#define STAT_BREAK_BEAM (1 << 20)
#define STAT_FORCE_BEAM (1 << 21)
#define STAT_USER_STEMDIR (1 << 22)
#define STAT_USER_HIDDEN_REST (1 << 23)
#define STAT_USER_PLACED_REST (1 << 24)
#define STAT_TURN (1 << 25)
#define STAT_REV_TURN (1 << 26)
#define STAT_TREMOLO1 (0x1 << 27)
#define STAT_TREMOLO2 (0x2 << 27)
#define STAT_TREMOLO3 (0x3 << 27)
#define STAT_TREMOLO4 (0x4 << 27)
#define TREMOLO_MASK (0x7 << 27)
#define CHORD_STAT_MASK (STAT_STACC | STAT_PIZZ | STAT_TENUTO | \
STAT_SFORZATO | STAT_SFORZANDO | STAT_BOW_UP | STAT_BOW_DOWN | \
STAT_PED_ON | STAT_PED_OFF | STAT_TRILL | STAT_PRALL | \
STAT_MORDENT | STAT_OPEN | STAT_STACCATISSIMO | STAT_FERMATA | STAT_ARPEGGIO | \
STAT_TURN | STAT_REV_TURN | TREMOLO_MASK )
#define VIRTUAL_NATURAL_OFFS -111
#define CLEF_SPACE 0.9
#define CLEF_POS 0.5
#define TIME_SIGNATURE_SPACE 0.37
#define SIG_X_SHIFT (0.87 * LINE_DIST)
#define EXTRA_KEY_OFF 0.05
#define MEAS_BAR_SPACE (0.74 * LINE_DIST)
#define RIGHT_DIST (0.174 * LINE_DIST)
//#define EXTRA_SPACE (0.652 * LINE_DIST)
//#define EXTRA_SPACE (0.2 * LINE_DIST)
#define WHOLE_EXTRA_SPACE (2.6 * LINE_DIST)
#define TIME_SYMBOL_NONE 0
#define TIME_SYMBOL_COMMON_TIME 1
#define TIME_SYMBOL_CUT_TIME 2
// real measure numbers
#define MEASURE_NUMBER_X_POS -0.45
#define MEASURE_NUMBER_Y_POS -0.45
#define MEASURE_NUMBER_SLANT CAIRO_FONT_SLANT_ITALIC
#define MEASURE_NUMBER_WEIGHT CAIRO_FONT_WEIGHT_NORMAL
#define MEASNUMBER_SIZE 0.35
// for testing
#define MEASURE_WEIGHT NOTE_4
#define MEASURE_NUMBER_Y_DIST 0.1
#define MEASURE_NUMBER_X_DIST 0.1
#define MEASURE_NUMBER_SIZE 0.3
#define TIME_SIG_WIDTH 0.5
#define MEASURE_SPREAD_STEP 0.1
#define MEASURE_MAX_SPREAD 2.0
#define MEASURE_MIN_SPREAD 0.4
#define MIN_NEAR_DIST 0.4
#define MIN_STAFF_BORDER_DIST 0.3
#define SEC_DIST_BELOW 0.3
#define SEC_DIST_ABOVE 0.1
#define MIN_SEC_DIST (2 * LINE_DIST)
#define REP_NUM_XPOS 0.09
#define REP_NUM_YPOS 0.4
#define MAX_NON_FULL_REPOSITS 15
#define MAX_NOTES_PER_WITH_ACCIDENTALS_STAFF 50
#define TREBLE_CLEF 0
#define BASS_CLEF 1
#define ALTO_CLEF 2
#define SOPRAN_CLEF 3
#define TENOR_CLEF 4
#define NEUTRAL_CLEF1 5
#define NEUTRAL_CLEF2 6
#define NEUTRAL_CLEF3 7
#define MINCLEF_NUMBER TREBLE_CLEF
#define MAXCLEF_NUMBER NEUTRAL_CLEF3
#define OCTUP_Y_TREBLE_DIST_DOWN 0.8
#define OCTUP_Y_TREBLE_DIST_UP -1.05
#define OCTUP_Y_BASS_DIST_DOWN 0.25
#define OCTUP_Y_BASS_DIST_UP -0.7
#define OCTUP_Y_ALTO_DIST_DOWN 0.5
#define OCTUP_Y_ALTO_DIST_UP -0.7
#define OCTUP_X_ALTO_DIST 0.15
#define DEMO_LINE_THICK 1.4
#define DEMO_LINE_BEGIN 10.0
#define DEMO_LINE_END 80.0
#define DEMO_LINE_YPOS 46.0
#define DEMO_LINE_DIST 9.6
#define DEMO_POS_FAK 44.0
#define MAX_MIDI_INPUT_CHORD 25
#define MAX_RECENT_FILES 8
#define START_EXTRA_SPACE (1.5 * LINE_DIST)
#define OLDVALUES
#ifdef OLDVALUES
#define MINIMUM_EXTRA_SPACE (2.0 * LINE_DIST)
#define MAXIMUM_EXTRA_SPACE (10.0 * LINE_DIST)
#else
#define MINIMUM_EXTRA_SPACE (0.0 * LINE_DIST)
#define MAXIMUM_EXTRA_SPACE (5.0 * LINE_DIST)
#endif
#define MIN_SYSTEM_Y_DIST (1.2 * LINE_DIST)
#define MAX_SYSTEM_Y_DIST (1.8 * LINE_DIST)
#define REP_DOTS_X_DIST (0.8 * LINE_DIST)
#define REP_DOTS_X_EXTRA_DIST (1.0 * LINE_DIST)
#define REP_DOTS_Y1DIST (1.4 * LINE_DIST)
#define REP_DOTS_Y2DIST (2.4 * LINE_DIST)
#define REP_DOTS_RADIUS (0.2 * LINE_DIST)
#define REPEAT_MEASURE_LINE_THICK 0.1
#define REP_THICK_LINE_DIST (0.6 * LINE_DIST)
#define REP_DOUBLE_LINE_DIST (0.4 * LINE_DIST)
#define V1RED 0xf800
#define V1GREEN 0x8b00
#define V1BLUE 0x3100
#define V2RED 0x0000
#define V2GREEN 0xb333
#define V2BLUE 0x0000
#define V3RED 0x2200
#define V3GREEN 0x5800
#define V3BLUE 0xe000
#define V4RED 0xb444
#define V4GREEN 0x4443
#define V4BLUE 0x0000
#define DCOLOR(x) ((double) (x) / (double) (1 << 16))
#define DSCOLOR(x) (0.6 * (double) (x) / (double) (1 << 16))
#define HIDD_RED 255
#define HIDD_GREEN 0
#define HIDD_BLUE 255
#define NOTE_ACTIVE_STATE_NONE 0
#define NOTE_ACTIVE_STATE_ON 1
#define NOTE_ACTIVE_STATE_OFF 2
#define TOLERANCE 0.05
#define MIN_REST_Y_VOICE_DIST 0.1
#define MAX_OVER_UNDER_LINES 12
#define OFFS_ARRAY_SIZE 115
#define OFFS_ARRAY_HALF (OFFS_ARRAY_SIZE / 2)
#define X11_ICONS_DIM 25
#define X11_ICONS_BACK_DIM 35
#define X11_MINI_ICONS_DIM 20
#define X11_ICONS_BACK_MINI_DIM 25
#define MAX_SCREEN_DIM 100000
#define DBG_NO 0
#define DBG_TESTING 1
#define DBG_CRITICAL 2
#define SEGNO_SIGN (1 << 0)
#define SEGNO_D_S_AL_CODA (1 << 1)
#define SEGNO_D_S_AL_FINE (1 << 2)
#define SEGNO_D_CAPO_AL_CODA (1 << 3)
#define SEGNO_D_CAPO_AL_FINE (1 << 4)
#define SEGNO_FINE (1 << 5)
#define SEGNO_FINE2 (1 << 6) // "valid" fine (during replay)
#define SEGNO_CODA (1 << 7)
#define SEGNO_AL_CODA (1 << 8)
#define SEGNO_AL_CODA2 (1 << 9) // "valid" al coda (during replay)
/* Debug macros */
#define LAUS(var) (var), (var) / NOTE_64, (var) / NOTE_4
/* */
class NedNote;
class NedChordOrRest;
class NedMainWindow;
class NedSystem;
class NedStaff;
class NedPage;
class NedMeasure;
class NedTools;
class NedChordName;
struct MidiPortStruct;
struct MidiPortStruct {
int client, port;
char *name;
};
struct addr_ref_str {
void *ori, *copy;
struct addr_ref_str *next;
};
struct MidiListStruct {
double tempoinverse;
GList *notes;
};
struct MidiEventStruct {
unsigned short channel, segno_sign;
unsigned long long midi_time;
unsigned int type;
#define PSEUDO_FLAG (0x1 << 17) // MidiEventStruct will be deleted before reply starts
#define PSEUDO2_FLAG (0x1 << 18) // MidiEventStruct is kept during replay
#define PSEUDO_MASK (0xffff << 16)
#define NOTE_MASK (0xffff)
#define PSEUDO_EVENT_MEASURE (PSEUDO_FLAG | 0x1)
#define PSEUDO_EVENT_VOL_CHANGE (PSEUDO_FLAG | 0x2)
#define PSEUDO_EVENT_RIT_START (PSEUDO2_FLAG | 0x1)
#define PSEUDO_EVENT_RIT_STOP (PSEUDO2_FLAG | 0x2)
#define PSEUDO_EVENT_CRES_START (PSEUDO2_FLAG | 0x4)
#define PSEUDO_EVENT_CRES_STOP (PSEUDO2_FLAG | 0x8)
#define PSEUDO_EVENT_TEMPO_CHANGE (PSEUDO2_FLAG | 0x10)
#define PSEUDO_EVENT_KEY_CHANGE (PSEUDO2_FLAG | 0x20)
unsigned char data2;
unsigned char pgm; // for notes;
unsigned char voice;
double tempoinverse;
int data1;
NedNote *note;
NedMeasure *measure;
bool repetition;
};
struct paper_info_struct {
const char *name;
int width, height;
};
class NedBbox {
public:
double x, y, width, width_netto /* width without lyrics */, height;
};
struct crescendo_info {
unsigned int symbol;
GList *listptr;
unsigned long long midi_time;
int volume;
};
struct accel_info {
unsigned int symbol;
GList *listptr;
unsigned long long midi_time;
double tempo_inverse;
};
class NedResource {
public:
static void initialize();
static void cleanup();
static char *getFontFileName() {return m_font_file_name;}
static cairo_scaled_font_t *getScaledFont(int zoom_level);
static double getStartZoomScale() {return m_zoom_factors[START_ZOOM_LEVEL];}
static double getZoomFactor(int zoom_level);
static void Abort(const char *s);
static void DbgMsg(int level, const char *format, ...);
static void Warning(const char *s);
static void Info(const char *s);
static cairo_text_extents_t fontextentions[ZOOMLEVELS][MAXELEMENTS];
static double m_braceOutline[16][6];
static double m_bracketEndOutline[5][6];
#ifndef HAS_SET_SCALED_FONT
static cairo_font_face_t *getFontFace() {return m_font_face;}
static cairo_matrix_t *getFontMatrix(int zoom_level);
static cairo_font_options_t *getFontOptions() {return m_fontoptions;}
#endif
static GdkPixbuf *m_the_nted_icon;
static GdkPixbuf *m_32ndnote_icon;
static GdkPixbuf *m_64thnote_icon;
static GdkPixbuf *m_eightnote_icon;
static GdkPixbuf *m_eightnote_dot_icon;
static GdkPixbuf *m_fullnote_icon;
static GdkPixbuf *m_halfnote_icon;
static GdkPixbuf *m_halfnote_dot_icon;
static GdkPixbuf *m_quarternote_icon;
static GdkPixbuf *m_quarternote_dot_icon;
static GdkPixbuf *m_stroken_grace_icon;
static GdkPixbuf *m_grace_eighth_icon;
static GdkPixbuf *m_grace_sixth_icon;
static GdkPixbuf *m_sixteenthnote_icon;
static GdkPixbuf *m_sixteenthnote_dot_icon;
static GdkPixbuf *m_rest_icon;
static bool equalContent(GList *l1, GList *l2, NedChordOrRest *except, int *diff_pos);
static GdkPixbuf *m_shift_mode_icon;
static GdkPixbuf *m_insert_mode_icon;
static GdkPixbuf *m_dot_icon;
static GdkPixbuf *m_ddot_icon;
static GdkPixbuf *m_cross_icon;
static GdkPixbuf *m_flat_icon;
static GdkPixbuf *m_natural_icon;
static GdkPixbuf *m_tied_icon;
static GdkPixbuf *m_arrow_up_icon;
static GdkPixbuf *m_arrow_down_icon;
static GdkPixbuf *m_arrow_left_icon;
static GdkPixbuf *m_arrow_right_icon;
static GdkPixbuf *m_treble_clef_icon;
static GdkPixbuf *m_bass_clef_icon;
static GdkPixbuf *m_alto_clef_icon;
static GdkPixbuf *m_delete_staff_icon;
static GdkPixbuf *m_delete_system_icon;
static GdkPixbuf *m_color_icon;
static GdkPixbuf *m_lyrics_icon;
static GdkPixbuf *m_key_icon;
static GdkPixbuf *m_tool_icon;
static GdkPixbuf *m_normal_note_icon;
static GdkPixbuf *m_drum1_icon;
static GdkPixbuf *m_drum2_icon;
static GdkPixbuf *m_drum3_icon;
static GdkPixbuf *m_drum4_icon;
static GdkPixbuf *m_drum5_icon;
static GdkPixbuf *m_drum6_icon;
static GdkPixbuf *m_drum7_icon;
static GdkPixbuf *m_drum8_icon;
static GdkPixbuf *m_drum9_icon;
static GdkPixbuf *m_drum10_icon;
static GdkPixbuf *m_drum11_icon;
static GdkPixbuf *m_drum12_icon;
static GdkPixbuf *m_guitar_note_icon;
static GdkPixbuf *m_guitar_note_no_stem_icon;
static GdkPixbuf *m_drum1_icon_small;
static GdkPixbuf *m_drum2_icon_small;
static GdkPixbuf *m_drum4_icon_small;
static GdkPixbuf *m_drum6_icon_small;
static GdkPixbuf *m_drum8_icon_small;
static GdkPixbuf *m_drum3_icon_small;
static GdkPixbuf *m_drum5_icon_small;
static GdkPixbuf *m_drum7_icon_small;
static GdkPixbuf *m_drum9_icon_small;
static GdkPixbuf *m_drum10_icon_small;
static GdkPixbuf *m_drum11_icon_small;
static GdkPixbuf *m_drum12_icon_small;
static GdkPixbuf *m_normal_note_icon_small;
static GdkPixbuf *m_dcross_icon;
static GdkPixbuf *m_dflat_icon;
static GdkPixbuf *m_stacc_icon;
static GdkPixbuf *m_staccatissimo_icon;
static GdkPixbuf *m_str_pizz_icon;
static GdkPixbuf *m_tenuto_icon;
static GdkPixbuf *m_sforzato_icon;
static GdkPixbuf *m_sforzando_icon;
static GdkPixbuf *m_bow_up_icon;
static GdkPixbuf *m_bow_down_icon;
static GdkPixbuf *m_groupbeams_icon;
static GdkPixbuf *m_isolate_icon;
static GdkPixbuf *m_flipstem_icon;
static GdkPixbuf *m_tremolo_icon1;
static GdkPixbuf *m_tremolo_icon2;
static GdkPixbuf *m_tremolo_icon3;
static GdkPixbuf *m_tremolo_icon4;
static GdkPixbuf *m_brace_icon;
static GdkPixbuf *m_bracket_icon;
static GdkPixbuf *m_ped_on_icon;
static GdkPixbuf *m_ped_off_icon;
static GdkPixbuf *m_trill_icon;
static GdkPixbuf *m_prall_icon;
static GdkPixbuf *m_open_icon;
static GdkPixbuf *m_mordent_icon;
static GdkPixbuf *m_fermata_icon;
static GdkPixbuf *m_arpeggio_icon;
static GdkPixbuf *m_turn_icon;
static GdkPixbuf *m_revturn_icon;
static GdkPixbuf *m_comm_icon;
static GdkPixbuf *m_cut_icon;
static GdkPixbuf *m_midikeyboard_icon;
static GdkPixbuf *m_record_icon;
static GdkPixbuf *m_lines;
static int m_lines_buf_width, m_lines_buf_height;
static GdkPixbuf *m_signs;
static int m_signs_buf_width, m_signs_buf_height;
static int m_drum_icons_width, m_drum_icons_height;
static GdkPixbuf *m_background1;
static GdkPixbuf *m_mini_background1;
static GdkPixbuf *m_mini_background2;
static GdkPixbuf *m_background2;
static GdkPixbuf *m_backgroundv1;
static GdkPixbuf *m_backgroundv2;
static GdkPixbuf *m_backgroundh1;
static GdkPixbuf *m_backgroundh2;
static NedBbox m_acc_bbox;
static double getFlagWidth() {return m_flag_width;}
static char my_getc(FILE *fp);
static void my_ungetc(char c, FILE *fp);
static void unreadWord(char *word);
static bool readWord(FILE *fp, char *word);
static bool readWordWithNum(FILE *fp, char *word);
static bool readWordWithAllChars(FILE *fp, char *word);
static bool readWordOfLength(FILE *fp, char *word);
static bool readString(FILE *fp, char *word);
static bool readTillEnd(FILE *fp, char *word);
static bool readInt(FILE *fp, int *val);
static bool readUnsignedInt(FILE *fp, unsigned int *val);
static bool readLong(FILE *fp, unsigned long long*val);
static bool readHex(FILE *fp, int *val);
static bool readFloat(FILE *fp, double *val);
static bool removeWhiteSpaces(char **s);
static void removeNonAsciiFromUTF8String(const gchar *s);
static const char *m_error_message;
static int m_input_line;
static void startMidiInput();
static void stopMidiInput();
static void close_sequ();
static void MidiCtrl(unsigned int ctrl_param, int channel, int val);
static void NoteOn(int channel, int pitch, int pgm, int vol);
static void NoteOff(int channel, int pitch);
static void SeqReset();
static void addMidiNoteEvent(unsigned short channel, unsigned char voice, unsigned int offset, unsigned int type, int data1, int pgm,
unsigned short segno_sign, NedNote *note);
static void addMidiCtrlEvent(unsigned short channel, unsigned int offset, unsigned int ctrl_param, int val);
static void addTempoChange(unsigned int offset, double tempoinverse);
static void addKeysigEntry(unsigned int offset, int chn, int key);
static void addTempoChangeAbs(unsigned long long midi_time, double tempoinverse);
static void addMeasureEntry(NedMeasure *measure);
static void addTempoChange(double tempoinverse);
static void addFermata(unsigned int offset);
static void addPseudoEvent2(unsigned int offset, int event, int chn, int data);
static void setStartVolume(unsigned char chn, int voice_idx, unsigned char vol);
static void correctFermataTempo();
static void handleSegnos();
static void prepareMidiEventList(double tempo_inverse);
static void startReplay(NedNote *startNote, double tempo_inverse);
static void collectTempoEvents(GList **tempo_chords);
static void copyAllBetweenMeasures(int start_measure_number, int alternative1_measure_number, int end_measure_number);
static bool isPlaying() {return m_playing;}
static bool m_midi_echo;
static void stopReplay();
static void increaseSystemStartTime(unsigned long long system_duration);
static const char *GM_Instruments[];
static int getNumInstruments();
static GList *listMidiOutDevices(int *index_of_subscribed_out_device);
static GList *listMidiInDevices(int *index_of_subscribed_in_device);
static void subscribe_out(int idx);
static void subscribe_in(int idx);
static void prepareAddrStruct();
static int addAddr(void *addr);
static void addAddr(int marker, void *addr);
static void *getAdressOfMarker(int marker);
static int getMarkerOfAddress(void *addr);
static void startMidiExport(FILE *fp, NedMainWindow *main_window);
static void addLastFile(char *filename);
static char *m_recent_files[MAX_RECENT_FILES];
static void addToRecentFiles(char *fname);
static int getClefDist(int oldclef, int old_oct_offs, int newclef, int new_oct_offs);
static void reset_tools();
static void playImmediately(int channel, int pgm, int num_midi_input_notes, int *midi_input_chord, int vol);
static bool alsaSequencerOutOk() {return m_sequ_out != NULL;}
static bool alsaSequencerInOk() {return m_sequ_in != NULL;}
static bool m_avoid_immadiate_play;
static struct paper_info_struct *getPaperInfo(const char *papername);
static const char *m_print_cmd;
static int m_width;
static int m_height;
static int m_tuplet_tab[14];
static GList *m_main_clip_board;
static int m_number_of_first_selected_staff, m_number_of_last_selected_staff;
#ifdef YELP_PATH
static char *m_yelparg;
#endif
static GList *m_main_windows;
static NedMainWindow *m_window_with_last_focus;
static void appendTempFileName(char *fname);
static const char *m_last_folder;
static char *m_last_xml_dir;
static char *m_last_midi_dir;
static GList *clone_chords_and_rests(GList *group, bool remove_completely_hidden_voices);
static void split_element(GList **elements, GList *sp_element, unsigned long long delta1, unsigned long long delta2);
static bool test_for_incomplete_tuplets(GList *elements);
static void showLicense(GtkWindow *parent);
static bool selection_has_uncomplete_tuplets(GList *elements);
static void setLengthField(unsigned int length_field_value) {m_length_field_value = length_field_value;}
static unsigned int getPartLength(int *dotcount);
static unsigned int getPartLength(int *dotcount, bool is_rest, bool build_whole_rests, unsigned int measure_duration);
static void setLengthField2(unsigned long long measure_start, unsigned long long note_start, unsigned int length_field_value);
static unsigned int getPartLength2(int *dotcount);
static unsigned int getPartLength2(int *dotcount, bool is_rest, bool build_whole_rests, unsigned int measure_duration);
static bool fittingDuration(unsigned int duration);
static bool fittingPosition(unsigned long long position);
static unsigned int subtime(struct timeval *future, struct timeval *now);
static void addtime(struct timeval *now, unsigned int msecs, struct timeval *res);
static unsigned long long getSystemStartTime() {return m_system_start_time;}
static int determineLastLine(int treble_line, int clef);
static const char *getLilyPondClefName(int clef_number);
static const char *getLilyPondKeySigName(int keysig_number);
static void writeLilyFreeChord(FILE *fp, NedChordName *chordname, unsigned int length, unsigned int duration, int dotcount, unsigned int *midi_len);
static unsigned int getCurrentLength();
static int getCurrentNoteHead();
static unsigned int getStatus();
static bool getRestMode();
static int getDotCount();
static bool getTiedMode();
static void setButtons(unsigned int length, int dotcount, unsigned int chord_status, unsigned int note_status, bool isRest, bool tie_forward, int note_head);
static void setNoteLengthButtons(unsigned int length);
static void setToolboxTransient(NedMainWindow *w);
static void popup_tools(NedMainWindow *w);
static void resetSomeButtons();
static void resetButtons();
static void resetTieButton();
static void toggleButton(int nr);
static void toggleRest();
static void toggleTie();
static void toggleDot();
static void toggleSharp();
static void toggleNatural();
static void toggleFlat();
static NedMainWindow *getMainwWindowWithLastFocus();
static NedStaff *m_recorded_staff;
static void setMainwWindowWithFocus(NedMainWindow *w);
static snd_seq_t *getMidiInSequ() {return m_sequ_in;}
static snd_seq_t *getMidiOutSequ() {return m_sequ_out;}
static gint m_toolboxX, m_toolboxY;
private:
static void printMidiEvent(MidiEventStruct *ev);
static void handleVolAndTempoChanges(double tempo_inverse);
static void removeAllPseudosEvents();
static GList *findListAtMeasure(int meas_number, NedMeasure **measure);
static void addTimeOffsetAfter(GList *end_ptr, unsigned long long time_diff);
static void subTimeOffsetAfter(GList *end_ptr, unsigned long long time_diff);
static GList *cloneAllMidiEventsBetween(GList *start_ptr, GList *end_ptr, unsigned long long extra_offs);
static void deleteAllBetween(GList *start_ptr, GList *end_ptr /* , unsigned long long time_diff */);
static void handleDSalFine(bool da_capo);
static void handleDSalCoda(bool da_capo);
static struct paper_info_struct m_paper_info[];
static void process_midi_event();
static gboolean do_poll_midi_device(void *data);
static gboolean stopImmediate(void *data);
static int m_number_of_midi_poll_fds;
static bool m_run_midi_in;
static GList *m_midi_out_devices, *m_midi_in_devices;
static GList *m_midi_events;
static GList *m_play_ptr;
static int m_handler_id;
static snd_seq_addr_t m_alsa_out_addr;
static snd_seq_addr_t m_alsa_in_addr;
static snd_seq_addr_t m_alsa_out_dest_addr;
static snd_seq_addr_t m_alsa_in_src_addr;
static unsigned long long m_system_start_time;
static int m_channel_pgms[16];
static int m_channel_volume[16][VOICE_COUNT];
static struct crescendo_info m_last_crescendo_info[16];
static double m_channel_volume_ratio[16][VOICE_COUNT];
static struct accel_info m_last_ritardando;
static GList *m_addr_rel_list;
static void write_config();
static void read_config();
static bool permtest(snd_seq_port_info_t *pinfo, unsigned int perm);
static void placeMidiEvent(MidiEventStruct *ev);
static int m_marker_counter;
static gboolean playNext(void *data);
static bool m_playing;
static cairo_font_options_t *m_fontoptions;
#ifndef HAS_SET_SCALED_FONT
static cairo_matrix_t m_matrixes[ZOOMLEVELS];
#endif
static void open_seq();
static cairo_font_face_t *m_font_face;
static cairo_scaled_font_t *m_scaled_fonts[ZOOMLEVELS];
static char *m_font_file_name;
static double m_zoom_factors[ZOOMLEVELS];
static cairo_scaled_font_t *createScaledFont(int zoom_level);
static unsigned int m_length_field_value;
static unsigned int m_part_start, m_part_end;
static void init_fonts(char *font_file_name);
static int loadfontface(char *font_file_name);
static void loadPixmap(const guint8 *data, GdkPixbuf **pixbuf, const char *stock_id, int *width, int *height);
static GtkIconFactory *m_icon_factory;
static struct timeval m_expected_time;
static NedTools *m_tools;
static double m_flag_width;
static char m_word_buffer[128];
static snd_seq_t *m_sequ_out;
static snd_seq_t *m_sequ_in;
static int m_count_of_last_imm_pitches;
static snd_seq_event_t m_last_imm_notes[MAX_MIDI_INPUT_CHORD];
static GList *m_temp_file_names;
static double m_tempo_inverse;
static GList *m_fermata_list;
static bool m_ds_al_coda_available, m_ds_al_fine_available;
static bool m_d_capo_al_fine_available, m_d_capo_al_coda_available;
};
#endif /* RESOURCE_H */
nted-1.10.18/linepoint.h 0000664 0010410 0000764 00000005172 11520267230 011711 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef LINE_POINT_H
#define LINE_POINT_H
#include "freereplaceable.h"
#include
class NedStaff;
class NedLine;
class NedCrescendo;
class NedLinePoint : public NedFreeReplaceable {
public:
NedLinePoint(NedLine *line, int p_nr);
NedLinePoint(NedLine *line, int p_nr, NedChordOrRest *element);
NedLinePoint(NedLine *line, int p_nr, NedChordOrRest *element, double x, double y, bool relative);
void getXYPosAndStaff(double *xpos, double *ypos, NedStaff **staff);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL);
virtual void adjust_pointers(struct addr_ref_str *slurlist);
NedStaff *getStaff();
NedLinePoint *getLineStartPoint();
NedLinePoint *getLineEndPoint();
virtual void shift(double x, double y, double zoom_factor, double current_scale, double leftx, double topy);
void setLine(NedLine *line) {m_line = line;}
NedLine *getLine() {return m_line;}
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_LINE_POINT;}
virtual void startContextDialog(GtkWidget *ref);
virtual void toRel();
virtual void toRel2();
void virtual recompute();
int getNumber() {return m_point_number;}
private:
int m_point_number;
NedLine *m_line;
friend class NedLine;
friend class NedCrescendo;
};
#endif /* LINE_POINT_H */
nted-1.10.18/freereplaceable.cpp 0000664 0010410 0000764 00000027161 11520267230 013346 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "mainwindow.h"
#include "volumesign.h"
#include "chordorrest.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#include "freereplaceable.h"
#define X_POS_PAGE_REL(p) (((p) + m_element->getPage()->getContentXpos()) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy + (TOP_BOTTOM_BORDER + DEFAULT_BORDER))
#define X_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + leftx) / zoom_factor - m_element->getPage()->getContentXpos())
//#define Y_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + topy) / zoom_factor - (TOP_BOTTOM_BORDER + DEFAULT_BORDER))
#define Y_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + topy - (TOP_BOTTOM_BORDER + DEFAULT_BORDER)) / zoom_factor)
NedFreeReplaceable::NedFreeReplaceable() : m_abs(false), m_element(NULL), m_is_abs(false) {}
NedFreeReplaceable::NedFreeReplaceable(NedChordOrRest *element) : m_abs(false), m_element(element), m_is_abs(false), m_element_at_move_start(element) {
m_element->addFreeDislaceable(this);
if (m_is_abs) {
toRel();
}
}
NedFreeReplaceable::NedFreeReplaceable(NedChordOrRest *element, double x, double y, bool relative) :
m_x(x), m_y(y), m_abs(false), m_element(element), m_is_abs(!relative), m_element_at_move_start(element) {
m_element->addFreeDislaceable(this);
if (m_is_abs) {
toRel();
}
m_x_at_start = m_x;
m_y_at_start = m_y;
m_yrel = m_y;
}
void NedFreeReplaceable::setElement(NedChordOrRest *element) {
m_element = element;
m_element->addFreeDislaceable(this); // friend !!
m_element_at_move_start = element;
}
void NedFreeReplaceable::freeFromElement() {
if (m_element == NULL) return;
m_element->removeFreeDisplaceable(this); // friend !!
}
void NedFreeReplaceable::setXY(double x, double y, bool relative) {
m_x = x; m_y = y;
m_is_abs = !relative;
if (m_is_abs) {
toRel();
}
m_x_at_start = m_x;
m_y_at_start = m_y;
m_yrel = m_y;
computeBbox();
}
double NedFreeReplaceable::getAbsoluteX() {
if (m_is_abs) {
return m_x;
}
return m_x + m_element->m_xpos;
}
double NedFreeReplaceable::getAbsoluteY() {
if (m_is_abs) {
return m_y;
}
return m_y + m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
}
void NedFreeReplaceable::setThis() {
if (m_element == NULL) return;
m_element->getMainWindow()->m_selected_free_replaceable = this;
}
bool NedFreeReplaceable::isActive() {
if (m_element == NULL) return false;
return m_element->getMainWindow()->m_selected_free_replaceable == this;
}
void NedFreeReplaceable::getXYPos(double *xpos, double *ypos) {
if (m_is_abs) {
*xpos = m_x;
*ypos = m_y;
}
else {
*xpos = m_x + m_element->m_xpos;
*ypos = m_y + m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
}
}
void NedFreeReplaceable::toAbs() {
m_x_at_start = m_x;
m_y_at_start = m_y;
m_element_at_move_start = m_element;
if (m_is_abs) return;
m_x += m_element->m_xpos;
m_y += m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
m_last_ref_x = m_x;
m_last_ref_y = m_y;
m_is_abs = true;
}
void NedFreeReplaceable::toRel() {
if (!m_is_abs) return;
m_x -= m_element->m_xpos;
m_y -= m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
m_yrel = m_y;
m_is_abs = false;
computeBbox();
}
void NedFreeReplaceable::shift(double x, double y, double zoom_factor, double current_scale, double leftx, double topy) {
NedChordOrRest *newelement;
NedPage *nextpage;
double ydist, yd;
if (!m_is_abs) {
toAbs();
}
#define CRITICAL_DIST 0.4
m_x = X_POS_PAGE_REL_INVERSE(x);
m_y = Y_POS_PAGE_REL_INVERSE(y);
if (m_x < 0.0) {
if ((nextpage = m_element->getPage()->getPreviousPage()) == NULL) {
m_x = 0.0;
}
else {
newelement = nextpage->findNearestElement(-1, m_x, m_y, m_element ? m_element->getStaff() : NULL, &ydist);
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
return;
}
}
if (m_x > m_element->getPage()->getWidth()) {
if ((nextpage = m_element->getPage()->getNextPage()) == NULL) {
m_x = m_element->getPage()->getWidth() - LEFT_RIGHT_BORDER;
}
else {
newelement = nextpage->findNearestElement(-1, m_x, m_y, m_element ? m_element->getStaff() : NULL, &ydist);
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
return;
}
}
if (m_y < TOP_BOTTOM_BORDER) m_y = TOP_BOTTOM_BORDER;
if (m_y > m_element->getPage()->getHeight() - TOP_BOTTOM_BORDER) m_y = m_element->getPage()->getHeight() - TOP_BOTTOM_BORDER;
if ((m_x - m_last_ref_x) * (m_x - m_last_ref_x) + (m_y - m_last_ref_y) * (m_y - m_last_ref_y) > CRITICAL_DIST) {
newelement = m_element->getPage()->findNearestElement(-1, m_x, m_y, m_element ? m_element->getStaff() : NULL, &ydist);
yd = m_y - m_last_elements_y;
if (yd < 0.0) yd = -yd;
if (m_element != newelement) {
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
}
}
}
void NedFreeReplaceable::shiftOnlyX(double x, double y, double zoom_factor, double current_scale, double leftx, double topy) {
NedChordOrRest *newelement;
NedPage *nextpage;
int staff_nr;
double ydist, yd, test_y;
if (!m_is_abs) {
toAbs();
}
#define CRITICAL_DIST 0.4
m_x = X_POS_PAGE_REL_INVERSE(x);
test_y = Y_POS_PAGE_REL_INVERSE(y);
staff_nr = m_element->getStaff()->getStaffNumber();
if (m_x < 0.0) {
if ((nextpage = m_element->getPage()->getPreviousPage()) == NULL) {
m_x = 0.0;
}
else {
newelement = nextpage->findNearestElement(staff_nr, m_x, test_y, m_element ? m_element->getStaff() : NULL, &ydist);
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
return;
}
}
if (m_x > m_element->getPage()->getWidth()) {
if ((nextpage = m_element->getPage()->getNextPage()) == NULL) {
m_x = m_element->getPage()->getWidth() - LEFT_RIGHT_BORDER;
}
else {
newelement = nextpage->findNearestElement(staff_nr, m_x, test_y, m_element ? m_element->getStaff() : NULL, &ydist);
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
return;
}
}
if (test_y < TOP_BOTTOM_BORDER) test_y = TOP_BOTTOM_BORDER;
if (test_y > m_element->getPage()->getHeight() - TOP_BOTTOM_BORDER) test_y = m_element->getPage()->getHeight() - TOP_BOTTOM_BORDER;
if ((m_x - m_last_ref_x) * (m_x - m_last_ref_x) + (test_y - m_last_ref_y) * (test_y - m_last_ref_y) > CRITICAL_DIST) {
newelement = m_element->getPage()->findNearestElement(staff_nr, m_x, test_y, m_element ? m_element->getStaff() : NULL, &ydist);
yd = test_y - m_last_elements_y;
if (yd < 0.0) yd = -yd;
if (m_element != newelement) {
if (m_element->getStaff() != newelement->getStaff()) {
m_y += newelement->getSystem()->getYPos() + newelement->getStaff()->getMidPos() - (
m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos());
}
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
}
}
}
void NedFreeReplaceable::shiftOnlyY(int staff_nr, double y, double zoom_factor, double current_scale, double leftx, double topy) {
NedChordOrRest *newelement;
double dummy0 = 10000000.0, dummy;
if (!m_is_abs) {
toAbs();
}
#define CRITICAL_DIST 0.4
m_y = Y_POS_PAGE_REL_INVERSE(y);
if (m_y < TOP_BOTTOM_BORDER) m_y = TOP_BOTTOM_BORDER;
if (m_y > m_element->getPage()->getHeight() - TOP_BOTTOM_BORDER) m_y = m_element->getPage()->getHeight() - TOP_BOTTOM_BORDER;
if (m_element->getStaff()->getStaffNumber() != staff_nr) {
newelement = m_element->getSystem()->findNearestElement(staff_nr, m_x, m_y, NULL, &dummy0, &dummy);
if (m_element != newelement) {
m_element->removeFreeDisplaceable(this);
newelement->addFreeDislaceable(this);
m_element = newelement;
m_last_elements_y = m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos();
}
}
}
bool NedFreeReplaceable::trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy) {
bool ret;
double x = X_POS_PAGE_REL_INVERSE(xl);
double y = Y_POS_PAGE_REL_INVERSE(yl);
double xx, yy;
getXYPos(&xx, &yy);
ret = ((xx - x) * (xx - x) + (yy - y) * (yy - y) < 0.15);
if (ret) {
setThis();
}
return ret;
}
void NedFreeReplaceable::drawConnection(cairo_t *cr, double xpos, double ypos, double leftx, double topy, double zoom_factor) {
cairo_new_path(cr);
#define THIN_LINE_THICK 0.02
cairo_set_line_width(cr, zoom_factor * THIN_LINE_THICK);
cairo_set_source_rgb (cr, 0.0, 0.8, 0.8);
cairo_move_to(cr, X_POS_PAGE_REL(xpos), Y_POS_PAGE_REL(ypos)) ;
cairo_line_to(cr, X_POS_PAGE_REL(m_element->getRealXpos()), Y_POS_PAGE_REL(m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos()));
cairo_stroke(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
void NedFreeReplaceable::drawConnectionInFreeText(cairo_t *cr, double xpos, double ypos, double scale, double leftx, double topy, double zoom_factor) {
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * THIN_LINE_THICK);
cairo_set_source_rgb (cr, 0.0, 0.8, 0.8);
cairo_move_to(cr, scale * X_POS_PAGE_REL(xpos), scale * Y_POS_PAGE_REL(ypos)) ;
cairo_line_to(cr, scale * X_POS_PAGE_REL(m_element->getRealXpos()), scale * Y_POS_PAGE_REL(m_element->getSystem()->getYPos() + m_element->getStaff()->getMidPos()));
cairo_stroke(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
bool NedFreeReplaceable::less_than(NedFreeReplaceable *other) {
NedPage *my_page, *other_page;
NedStaff *my_staff, *other_staff;
my_staff = m_element->getStaff();
other_staff = other->m_element->getStaff();
if (my_staff == other_staff) {
return getAbsoluteX() < other->getAbsoluteX();
}
my_page = my_staff->getPage();
other_page = other_staff->getPage();
if (my_page == other_page) {
return my_staff->getSystem()->getSystemNumber() < other_staff->getSystem()->getSystemNumber();
}
return my_page->getPageNumber() < other_page->getPageNumber();
}
nted-1.10.18/idiotseditor/ 0000775 0010410 0000764 00000000000 11520270234 012312 5 0000000 0000000 nted-1.10.18/idiotseditor/idiotseditor.cpp 0000664 0010410 0000764 00000343025 11520267221 015451 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "idiotseditor.h"
#include "chordorrest.h"
#include "mainwindow.h"
#include "temposign.h"
#include "volumesign.h"
#include "idcommandhistory.h"
#include "changeidnotecommand.h"
#include "idcommandlist.h"
#include "note.h"
#include
#include
#include "localization.h"
#include
#define STEP_DIVISION 10.0
#define ID_ZOOM_STEP (8.0 / 3.0)
#define ID_MIN_ZOOM 0.25
#define ID_MAX_ZOOM 8.0
#define ID_DEFAULT_ZOOM 1.0
#define PIANO_PART_WIDTH 50
#define TUNE_NAME_X_START 10
#define TIME_SIG_TRACK_HEIGHT 8.0
#define TEMPO_TRACK_HEIGHT 8.0
#define SIGN_TRACK_HEIGHT 8.0
#define VOLUME_TRACK_HEIGHT 8.0
#define SPEC_TRACKS_HEIGHT (TIME_SIG_TRACK_HEIGHT + TEMPO_TRACK_HEIGHT + SIGN_TRACK_HEIGHT + VOLUME_TRACK_HEIGHT)
#define NOTE_BORDER_LINE_THICK 4.0
#define NOTE_BORDER_LINE_THICK_2 (NOTE_BORDER_LINE_THICK / 2.0)
#define SEP_LINE_THICK 2.0
#define BAR_LINE_THICK 3.0
#define NOTE_LINE_THICK 0.8
#define SEP_LINE_DIST 20.0
#define NOTE_SEP_THICK 4
#define NOTE_SEP_THICK_2 (NOTE_SEP_THICK / 2)
#define SEP_LINE_BORDER (0.2 * SEP_LINE_DIST)
#define ID_HEIGHT (120 - 4 + 1) * SEP_LINE_DIST
#define START_HEIGHT 800
#define START_WIDTH 1000
#define MIN_VERTICAL_LINES_DIST 12.0
#define TREBLE_CLEF_UPPER_PITCH 88
#define BASS_CLEF_UPPER_PITCH 59
#define BASS_CLEF_LOWER_PITCH 33
#define PART_RELEVANT 10 /* % */
#define ALLOW1 4
#define ALLOW2 2
#define ALLOW3 4
#define DEFAULT_FREE_X_DIST -0.3
#define DEFAULT_FREE_Y_DIST -1.3
#define VOLUME_SIGN_Y_DIST 1.3
#define MOTION_MODE_NONE 0
#define MOTION_MODE_MOVE 1
#define MOTION_NODE_LEFT 2
#define MOTION_NODE_RIGHT 3
#define CHOOSE_HEAD(line) ((m_channel == 9) ? (((line + OFFSET_TO_BE_USED_DURING_MIDI_IMPORT) % COUNT_OF_DRUMS_TO_CHOOSE_DURING_MIDI_IMPORT) + 1) : NORMAL_NOTE )
#define X_POS(p) (PIANO_PART_WIDTH + (p) / FACTOR * zoom_value - xleft)
#define PITCH_TO_YPOS(pi) ((116 - ((pi) - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT)
#define POS_TO_PITCH(y) (((116 + 4) * SEP_LINE_DIST - (y) - SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT) / SEP_LINE_DIST + 0.5)
#define WITH_SHOWING_ID_EDITOR
const char *NedIdiotsEditor::guiDescription =
""
" "
" "
" "
" "
" "
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
"";
const GtkActionEntry NedIdiotsEditor::file_entries[] = {
{ "IdFileMenu", NULL, _("_File")},
{ "IdViewMenu", NULL, _("_View")},
{ "IdEditMenu", NULL, _("_Edit") },
{ "IdNew", GTK_STOCK_NEW, _("New"), NULL, _("New File"), NULL /* G_CALLBACK(new_file) */ },
{ "IdOpen", GTK_STOCK_OPEN, _("Open ..."), "O", _("Open a file"), NULL /* G_CALLBACK(restore_score) */ },
{ "IdExit", GTK_STOCK_QUIT, _("E_xit"), "Q", _("Exit the program"), G_CALLBACK(close_i_edit)},
{"IdzoomIn", GTK_STOCK_ZOOM_IN, "in", "plus", _("Zoom in Ctrl + +"), G_CALLBACK(zoom_in)},
{"IdzoomOut", GTK_STOCK_ZOOM_OUT, "out", "minus", _("Zoom out Ctrl + -"), G_CALLBACK(zoom_out)},
{"Idundo", GTK_STOCK_UNDO, _("undo"), "z", _("Undo Ctrl + z"), G_CALLBACK(do_undo)},
{"Idredo", GTK_STOCK_REDO, _("redo"), "y", _("Redo Ctrl + y"), G_CALLBACK(do_redo)}
};
const char *NedIdiotsEditor::pitch_tab[] = { "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C"};
NedIdNote::~NedIdNote() {
GList *lptr;
if (m_chordnotes != NULL) {
for (lptr = g_list_first(m_chordnotes); lptr; lptr = g_list_next(lptr)) {
delete (pitch_info *) lptr->data;
}
g_list_free(m_chordnotes);
m_chordnotes = NULL;
}
for (int i = 0; i < 3; i++) {
if (m_tripletnotes[i] != NULL) {
delete m_tripletnotes[i];
m_tripletnotes[i] = NULL;
}
}
}
void NedIdNote::addPitch(int pitch, bool tiebackward) {
GList *lptr;
pitch_info *pi;
int p;
if (pitch == m_pitch) return;
if (pitch < m_pitch) {
p = pitch;
pitch = m_pitch;
m_pitch = p;
}
for (lptr = g_list_first(m_chordnotes); lptr; lptr = g_list_next(lptr)) {
if (pitch == ((pitch_info* ) lptr->data)->m_pitch) return;
if (pitch < ((pitch_info *) lptr->data)->m_pitch) {
pi = new pitch_info();
pi->m_pitch = pitch;
pi->m_tiebackward = tiebackward;
m_chordnotes = g_list_insert_before(m_chordnotes, lptr, pi);
return;
}
}
pi = new pitch_info();
pi->m_pitch = pitch;
pi->m_tiebackward = tiebackward;
m_chordnotes = g_list_append(m_chordnotes, pi);
}
void NedIdNote::determineLines(int clef, int octave_shift, int key, char *offs_array) {
pitch_info *pi;
GList *lptr;
int offs;
m_line = NedNote::pitchToLine(m_pitch, clef, key, octave_shift, &offs);
m_state = NedNote::determineState(m_pitch, m_line, offs, offs_array, key);
for (lptr = g_list_first(m_chordnotes); lptr; lptr = g_list_next(lptr)) {
pi = (pitch_info *) lptr->data;
pi->m_line = NedNote::pitchToLine(pi->m_pitch, clef, key, octave_shift, &offs);
pi->m_state = NedNote::determineState(pi->m_pitch, pi->m_line, offs, offs_array, key);
}
}
NedIdNote *NedIdNote::cloneWithDifferentTime(unsigned long long sta, unsigned long long sto) {
pitch_info *pi;
GList *lptr;
NedIdNote *cl = new NedIdNote(m_pitch, m_volume, sta, sto);
cl->m_line = m_line;
cl->m_state = m_state;
cl->m_tiedbackward = true;
for (lptr = g_list_first(m_chordnotes); lptr; lptr = g_list_next(lptr)) {
pi = new pitch_info();
pi->m_pitch = ((pitch_info *) lptr->data)->m_pitch;
pi->m_line = ((pitch_info *) lptr->data)->m_line;
pi->m_state = ((pitch_info *) lptr->data)->m_state;
cl->m_chordnotes = g_list_append(cl->m_chordnotes, pi);
}
return cl;
}
bool NedIdNote::isInRect(double x, double y, double zoom_value, double xleft, double ytop) {
double startpos = X_POS(m_midi_start);
double endpos = X_POS(m_midi_stop);
double ypos = PITCH_TO_YPOS(m_pitch);
if (x < startpos) return false;
if (x > endpos) return false;
if (y < ypos) return false;
if (y > ypos + SEP_LINE_DIST - 2 * SEP_LINE_BORDER) return false;
return true;
}
int NedIdiotsInstrument::m_mid_lines[4] = { 38, 50, 67, 79 };
NedIdiotsInstrument::NedIdiotsInstrument(NedIdiotsEditor *id_edit, int channel, int orig_channel, int midi_nr, int volume_change_density) :
m_id_edit(id_edit), m_specials(NULL), m_selected_note(NULL), m_volume_change_density(volume_change_density),
m_midi_nr(midi_nr), m_channel(channel), m_orig_channel(orig_channel), m_volume(64) {m_inst_name[0] = '\0'; for (int i = 0; i < VOICE_COUNT; m_notes[i++] = NULL);}
NedIdiotsInstrument::~NedIdiotsInstrument() {
GList *lptr;
int voi;
for (voi = 0; voi < VOICE_COUNT; voi++) {
if (m_notes[voi] != NULL) {
for (lptr = m_notes[voi]; lptr; lptr = g_list_next(lptr)) {
delete (NedIdNote *) lptr->data;
}
g_list_free(m_notes[voi]);
m_notes[voi] = NULL;
}
}
if (m_specials != NULL) {
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
switch (((NedIdSpecial *) lptr->data)->m_type) {
case ID_SPEC_VOLUME_CHANGE: delete (NedIdVolumeChange *) lptr->data;
break;
}
}
g_list_free(m_specials);
m_specials = NULL;
}
}
void NedIdiotsInstrument::draw(Display *dpy, Drawable d, GC xgc, GC x_border_gc, double zoom_value, double xleft, double ytop, double visible_start_pos, double visible_end_pos) {
GList *lptr;
NedIdNote *note;
int voice;
XSetLineAttributes(dpy, x_border_gc, NOTE_BORDER_LINE_THICK, LineSolid, CapRound, JoinMiter);
XSetForeground(dpy, x_border_gc, 0x000000);
//for (voice = 0; voice < VOICE_COUNT; voice++) {
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
if (note->m_midi_start / FACTOR * zoom_value > visible_end_pos) continue;
if (note->m_midi_stop / FACTOR * zoom_value < visible_start_pos) continue;
if (note == m_selected_note && m_id_edit->motion_mode != MOTION_MODE_NONE) {
XSetForeground(dpy, xgc, 0x00ff00);
switch(m_id_edit->motion_mode) {
case MOTION_MODE_MOVE:
XFillRectangle(dpy, d, xgc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + m_id_edit->getOffX(),
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT + m_id_edit->getOffY(),
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value, SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
XDrawRectangle(dpy, d, x_border_gc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft +
NOTE_BORDER_LINE_THICK_2 + m_id_edit->getOffX(),
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT + m_id_edit->getOffY(),
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value - NOTE_BORDER_LINE_THICK_2,
SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
break;
case MOTION_NODE_LEFT:
XFillRectangle(dpy, d, xgc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + m_id_edit->getOffX(),
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value - m_id_edit->getOffX(), SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
XDrawRectangle(dpy, d, x_border_gc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft +
NOTE_BORDER_LINE_THICK_2 + m_id_edit->getOffX(),
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value - NOTE_BORDER_LINE_THICK_2 - m_id_edit->getOffX(),
SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
break;
case MOTION_NODE_RIGHT:
XFillRectangle(dpy, d, xgc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value + m_id_edit->getOffX(),
SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
XDrawRectangle(dpy, d, x_border_gc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft +
NOTE_BORDER_LINE_THICK_2,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value - NOTE_BORDER_LINE_THICK_2 + m_id_edit->getOffX(),
SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
break;
}
}
else {
XSetForeground(dpy, xgc, 0xff0000);
XFillRectangle(dpy, d, xgc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value, SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
XDrawRectangle(dpy, d, x_border_gc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + NOTE_BORDER_LINE_THICK_2,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value - NOTE_BORDER_LINE_THICK_2,
SEP_LINE_DIST - 2 * SEP_LINE_BORDER);
}
/*
XDrawLine(dpy, d, xgc, PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value + NOTE_BORDER_LINE_THICK / 2.0 - xleft,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value + NOTE_BORDER_LINE_THICK / 2.0 - xleft,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_DIST - SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT);
XDrawLine(dpy, d, xgc, PIANO_PART_WIDTH + note->m_midi_stop / FACTOR * zoom_value - NOTE_BORDER_LINE_THICK / 2.0 - xleft,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT,
PIANO_PART_WIDTH + note->m_midi_stop / FACTOR * zoom_value - NOTE_BORDER_LINE_THICK / 2.0 - xleft,
(116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_DIST - SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT);
*/
/*
cairo_rectangle (cr, note->m_midi_start / FACTOR * zoom_value, (116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER,
(note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value, SEP_LINE_DIST - 2 * SEP_LINE_BORDER - SPEC_TRACKS_HEIGHT);
*/
}
//}
}
void NedIdiotsInstrument::draw_specials(cairo_t *cr, double zoom_value, double xleft, double ytop, double visible_start_pos, double visible_end_pos) {
GList *lptr;
NedIdSpecial *spec;
char Str[128];
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
spec = (NedIdSpecial *) lptr->data;
if (spec->m_time / FACTOR * zoom_value > visible_end_pos) break;
if (spec->m_time / FACTOR * zoom_value < visible_start_pos) continue;
switch (spec->m_type) {
case ID_SPEC_KEYSIG_CHANGE: sprintf(Str, "%d", ((NedIdKeysigChange *) spec)->m_key);
cairo_new_path(cr);
cairo_move_to(cr, PIANO_PART_WIDTH + spec->m_time / FACTOR * zoom_value - xleft, TIME_SIG_TRACK_HEIGHT + TEMPO_TRACK_HEIGHT + SIGN_TRACK_HEIGHT);
cairo_show_text(cr, Str);
cairo_stroke(cr);
break;
case ID_SPEC_VOLUME_CHANGE: sprintf(Str, "%d", ((NedIdVolumeChange *) spec)->m_volume);
cairo_new_path(cr);
cairo_move_to(cr, PIANO_PART_WIDTH + spec->m_time / FACTOR * zoom_value - xleft, TIME_SIG_TRACK_HEIGHT + TEMPO_TRACK_HEIGHT + SIGN_TRACK_HEIGHT + VOLUME_TRACK_HEIGHT);
cairo_show_text(cr, Str);
cairo_stroke(cr);
break;
default: NedResource::Abort("draw_specials");
}
}
}
void NedIdiotsEditor::getMeasureNumber(unsigned long long start_time, int *num, int *denom) {
GList *lptr;
NedIdTimesigChange *found = NULL, *newfound;
int numerator = 4, denominator = 4;
unsigned long long duration = WHOLE_NOTE;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_time > start_time) break;
if (((NedIdSpecial *) lptr->data)->m_type == ID_SPEC_TIME_SIG_CHANGE) {
newfound = (NedIdTimesigChange *) lptr->data;
numerator = newfound->m_numerator;
denominator = newfound->m_denominator;
if (found != NULL) {
if (((newfound->m_time - found->m_time) % duration) != 0) {
printf("start_time = %llu(%llu), %llu(%llu) - %llu(%llu) = %llu(%llu), duration = %llu(%llu) mod = %llu(%llu)\n",
start_time, start_time/ NOTE_8,
newfound->m_time, newfound->m_time / NOTE_8, found->m_time, found->m_time / NOTE_8,
newfound->m_time - found->m_time, (newfound->m_time - found->m_time) / NOTE_8,
duration, duration / NOTE_8,
(newfound->m_time - found->m_time) % duration,
((newfound->m_time - found->m_time) % duration) / NOTE_8); fflush(stdout);
NedResource::Abort("NedIdiotsEditor::getMeasureNumber");
}
}
found = newfound;
duration = numerator * WHOLE_NOTE / denominator;
}
}
*num = numerator;
*denom = denominator;
}
unsigned long long NedIdiotsEditor::getMeasureStart(unsigned long long sample_time, bool endtime) {
GList *lptr;
double divide_d;
int divide;
NedIdTimesigChange *found = NULL, *newfound;
int numerator = 4, denominator = 4;
unsigned long long duration = WHOLE_NOTE;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (!endtime && ((NedIdSpecial *) lptr->data)->m_time > sample_time) break;
if (endtime && ((NedIdSpecial *) lptr->data)->m_time >= sample_time) break;
if (((NedIdSpecial *) lptr->data)->m_type == ID_SPEC_TIME_SIG_CHANGE) {
newfound = (NedIdTimesigChange *) lptr->data;
numerator = newfound->m_numerator;
denominator = newfound->m_denominator;
if (found != NULL) {
if (((newfound->m_time - found->m_time) % duration) != 0) {
printf("sample_time = %llu(%llu), %llu(%llu) - %llu(%llu) = %llu(%llu), duration = %llu(%llu) mod = %llu(%llu)\n",
sample_time, sample_time/ NOTE_8,
newfound->m_time, newfound->m_time / NOTE_8, found->m_time, found->m_time / NOTE_8,
newfound->m_time - found->m_time, (newfound->m_time - found->m_time) / NOTE_8,
duration, duration / NOTE_8,
(newfound->m_time - found->m_time) % duration,
((newfound->m_time - found->m_time) % duration) / NOTE_8); fflush(stdout);
NedResource::Abort("NedIdiotsEditor::getMeasureStart(1)");
}
}
found = newfound;
duration = numerator * WHOLE_NOTE / denominator;
}
}
if (found == NULL) {
divide_d = (double) sample_time / (double) duration;
divide = (int) divide_d;
return (unsigned long long) divide * (unsigned long long) duration;
}
if (sample_time < found->m_time) {
NedResource::Abort("NedIdiotsEditor::getMeasureStart(2)");
}
divide_d = (double) (sample_time - found->m_time) / (double) duration;
divide = (int) divide_d;
return found->m_time + (unsigned long long) divide * duration;
}
GList* NedIdiotsInstrument::trySplitInstrument(bool force_piano, bool dont_split) {
NedIdNote *note;
int i, idx, dist, mindist;
GList *lptr;
GList *deleted_note_ptrs = NULL;
int sum = 1;
int max_idx, max_sum;
int part_sums[4];
NedIdiotsInstrument *newinstruments[4];
GList *instruments_list = NULL;
bool first;
for (i = 0; i < 4; i++) {
part_sums[i] = 0;
newinstruments[i] = NULL;
}
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
sum++;
if (note->m_pitch > TREBLE_CLEF_UPPER_PITCH) part_sums[3]++;
else if (note->m_pitch > BASS_CLEF_UPPER_PITCH) part_sums[2]++;
else if (note->m_pitch > BASS_CLEF_LOWER_PITCH) part_sums[1]++;
else part_sums[0]++;
}
if (force_piano || m_channel == 9) {
part_sums[2] += part_sums[3];
part_sums[3] = 0;
part_sums[1] += part_sums[0];
part_sums[0] = 0;
}
if (!dont_split) {
first = true;
for (i = 3; i >= 0; i--) {
if (part_sums[i] * 100 / sum > PART_RELEVANT) {
if (first) {
first = false;
newinstruments[i] = this;
}
else {
newinstruments[i] = new NedIdiotsInstrument(m_id_edit, m_channel, m_orig_channel, m_midi_nr, m_volume_change_density);
if (m_inst_name[0] != '\0') {
strcpy(newinstruments[i]->m_inst_name, m_inst_name);
}
newinstruments[i]->m_volume = m_volume;
newinstruments[i]->m_inst_number = m_inst_number;
newinstruments[i]->m_specials = clone_specials();
}
switch(i) {
case 3: newinstruments[i]->m_clef = TREBLE_CLEF;
newinstruments[i]->m_octave_shift = 12;
break;
case 2: newinstruments[i]->m_clef = (m_channel == 9) ? NEUTRAL_CLEF1 : TREBLE_CLEF;
newinstruments[i]->m_octave_shift = 0;
break;
case 1: newinstruments[i]->m_clef = (m_channel == 9) ? NEUTRAL_CLEF2 : BASS_CLEF;
newinstruments[i]->m_octave_shift = 0;
break;
default: newinstruments[i]->m_clef = BASS_CLEF;
newinstruments[i]->m_octave_shift = -12;
break;
}
}
}
}
if (newinstruments[0] == NULL && newinstruments[1] == NULL && newinstruments[2] == NULL && newinstruments[3] == NULL) {
max_idx = 0;
max_sum = part_sums[0];
for (i = 1; i < 4; i++) {
if (part_sums[i] > max_sum) {
max_sum = part_sums[i];
max_idx = i;
}
}
switch(max_idx) {
case 3: m_clef = TREBLE_CLEF;
m_octave_shift = 12;
break;
case 2: m_clef = (m_channel == 9) ? NEUTRAL_CLEF1 : TREBLE_CLEF;
m_octave_shift = 0;
break;
case 1: m_clef = (m_channel == 9) ? NEUTRAL_CLEF2 : BASS_CLEF;
m_octave_shift = 0;
break;
default: m_clef = BASS_CLEF;
m_octave_shift = -12;
break;
}
return NULL;
}
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
mindist = 1000;
idx = -1;
for (i = 0; i < 4; i++) {
if (newinstruments[i] != NULL) {
dist = note->m_pitch - m_mid_lines[i];
if (dist < 0) dist = -dist;
if (dist < mindist) {
mindist = dist;
idx = i;
}
}
}
if (idx < 0) {
NedResource::Abort("NedIdiotsInstrument::trySplitInstrument");
}
if (newinstruments[idx] != this) {
newinstruments[idx]->addNote(note);
deleted_note_ptrs = g_list_append(deleted_note_ptrs, lptr);
}
}
for (lptr = g_list_first(deleted_note_ptrs); lptr; lptr = g_list_next(lptr)) {
m_notes[0] = g_list_delete_link(m_notes[0], (GList *) lptr->data);
}
g_list_free(deleted_note_ptrs);
for (i = 3; i >= 0; i--) {
if (newinstruments[i] == NULL) continue;
if (newinstruments[i] == this) continue;
instruments_list = g_list_append(instruments_list, newinstruments[i]);
}
return instruments_list;
}
void NedIdiotsInstrument::determineLines(NedIdiotsEditor *id) {
char offs_array[115];
NedIdNote *note;
bool first;
int key;
unsigned long long start_time = 0, end_time, measure_width;
int numerator, denominator;
id->getMeasureNumber(start_time, &numerator, &denominator);
m_notes[0] = g_list_sort(m_notes[0], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
GList *lptr = g_list_first(m_notes[0]);
do {
memset(offs_array, 0, sizeof(offs_array));
measure_width = numerator * WHOLE_NOTE / denominator;
end_time = start_time + measure_width;
for (; lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
if (note->m_midi_start < start_time) {
NedResource::Abort("NedIdiotsInstrument::determineLines");
}
if (note->m_midi_start >= end_time) break;
if (note->m_is_triplet_note) {
first = true;
for (int i = 0; i < 3; i++) {
if (note->m_tripletnotes[i] != NULL) {
key = id->determine_key(note->m_tripletnotes[i]->m_midi_start, m_channel);
note->m_tripletnotes[i]->determineLines(m_clef, m_octave_shift, key, offs_array);
if (first) {
first = false;
note->m_line = note->m_tripletnotes[i]->m_line;
note->m_state = note->m_tripletnotes[i]->m_state;
note->m_pitch = note->m_tripletnotes[i]->m_pitch;
}
}
}
}
else {
key = id->determine_key(note->m_midi_start, m_channel);
note->determineLines(m_clef, m_octave_shift, key, offs_array);
}
}
id->getMeasureNumber(end_time, &numerator, &denominator);
start_time = end_time;
}
while (lptr != NULL);
}
void NedIdiotsInstrument::splitNotesAtMeasureStart(NedIdiotsEditor *id) {
char offs_array[115];
GList *lptr;
NedIdNote * note;
unsigned long long duration, start_time, end_time, split_time;
int dist;
int pitch;
int pos;
int voi;
int key;
for (voi = 0; voi < VOICE_COUNT; voi++) {
for (lptr = g_list_first(m_notes[voi]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
pos = g_list_position(m_notes[voi], lptr);
duration = note->m_midi_stop - note->m_midi_start;
if (duration > WHOLE_NOTE) duration = WHOLE_NOTE;
start_time = note->m_midi_start;
while ((split_time = id->getFirstSplitTime(start_time, note->m_midi_stop)) != 0) {
if (note->m_is_triplet_note) {
NedResource::Abort("NedIdiotsInstrument::splitNotesAtMeasureStart(1)");
}
dist = (int) (split_time - note->m_midi_start);
if ((unsigned int ) dist < duration / ALLOW1) {
note->m_midi_start = split_time;
if (note->m_max_stop > 0 && note->m_max_stop <= note->m_midi_start) {
note->m_max_stop = 0;
}
note->fix_start = true;
memset(offs_array, 0, sizeof(offs_array));
key = id->determine_key(note->m_midi_start, m_channel);
note->determineLines(m_clef, m_octave_shift, key, offs_array); // because the start is now behind the new measure
start_time = split_time;
continue;
}
dist = (int) (note->m_midi_stop - start_time);
if ((unsigned int) dist < duration / ALLOW1) {
note->m_midi_stop = split_time;
if (note->m_max_stop > 0 && note->m_max_stop <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::splitNotesAtMeasureStart(2)");
}
note->fix_end = true;
break;
}
if (note->m_midi_stop <= note->m_midi_start) {
note->m_valid = false;
break;
}
dist = note->m_midi_stop - note->m_midi_start;
if ((unsigned int) dist < duration / ALLOW1) {
note->m_valid = false;
break;
}
end_time = note->m_midi_stop;
pitch = note->m_pitch;
note->m_midi_stop = split_time;
if (note->m_max_stop > 0 && note->m_max_stop <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::splitNotesAtMeasureStart(3)");
}
note->fix_end = true;
if (end_time - split_time < NOTE_16) break;
note = note->cloneWithDifferentTime(split_time, end_time);
note->fix_start = true;
if (note->m_max_stop > 0 && note->m_max_stop <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::splitNotesAtMeasureStart(4)");
}
m_notes[voi] = g_list_insert(m_notes[voi], note, ++pos);
memset(offs_array, 0, sizeof(offs_array));
key = id->determine_key(note->m_midi_start, m_channel);
note->determineLines(m_clef, m_octave_shift, key, offs_array); // because the start is now behind the new measure
start_time = split_time;
if ((lptr = g_list_find(m_notes[voi], note)) == NULL) {
NedResource::Abort("NedIdiotsInstrument::splitNotesAtMeasureStart(5)");
}
}
}
m_notes[voi] = g_list_sort(m_notes[voi], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
}
}
void NedIdiotsInstrument::snapStartOfNotes(NedIdiotsEditor *id) {
unsigned long long start_time, snap, divide;
double divide_d;
int duration;
GList *lptr;
NedIdNote *note;
unsigned long long pow2dist, pow23dist;
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
start_time = id->getMeasureStart(note->m_midi_start, false);
duration = (int) (note->m_midi_stop - note->m_midi_start);
if (duration > NOTE_8) duration = NOTE_8;
for (snap = NOTE_64; snap < NOTE_4 && snap < (unsigned int) duration / ALLOW2; snap <<= 1);
divide_d = (double) (note->m_midi_start - start_time) / (double) snap;
divide = (unsigned long long) (divide_d + 0.5);
note->m_midi_start = start_time + divide * snap;
if (note->m_midi_stop < note->m_midi_start) {
note->m_valid = false;
}
}
m_notes[0] = g_list_sort(m_notes[0], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
start_time = id->getMeasureStart(note->m_midi_start, false);
pow2dist = (note->m_ori_start > note->m_midi_start) ? (note->m_ori_start - note->m_midi_start) : (note->m_midi_start - note->m_ori_start);
snap = NOTE_4 / 3;
divide_d = (double) (note->m_ori_start - start_time) / (double) snap;
divide = (unsigned long long) (divide_d + 0.5);
//if (divide % 3 != 0) continue;
note->m_tri_start = start_time + divide * snap;
pow23dist = (note->m_tri_start > note->m_ori_start) ? ( note->m_tri_start - note->m_ori_start ) : (note->m_ori_start - note->m_tri_start);
if ((int) divide >= 0 && (int) divide < 40) {
note->m_tri_start_numerator = (pow23dist < pow2dist) ? ((int) divide) : 0;
}
}
}
void NedIdiotsInstrument::findChords(bool all_voices) {
GList *lptr1, *lptr2;
NedIdNote *note1, *note2;
int dur1, dur2, dist, durmax;
int i, max_voice = all_voices ? 4 : 1;
for (i = 0; i < max_voice; i++) {
for (lptr1 = g_list_first(m_notes[i]); lptr1; lptr1 = g_list_next(lptr1)) {
note1 = (NedIdNote *) lptr1->data;
if (!note1->m_valid) continue;
if (note1->m_is_triplet_note) continue;
for (lptr2 = g_list_next(lptr1); lptr2; lptr2 = g_list_next(lptr2)) {
note2 = (NedIdNote *) lptr2->data;
if (!note2->m_valid) continue;
if (note2->m_is_triplet_note) continue;
if (note2->m_midi_start >= note1->m_midi_stop) break;
if (note1->m_midi_start != note2->m_midi_start) continue;
dur1 = (int) (note1->m_midi_stop - note1->m_midi_start);
dur2 = (int) (note2->m_midi_stop - note2->m_midi_start);
durmax = (dur1 > dur2) ? dur1 : dur2;
dist = (dur1 > dur2) ? (dur1 - dur2) : (dur2 - dur1);
if (dist < durmax / 2) {
note1->addPitch(note2->m_pitch, note2->m_tiedbackward);
note2->m_valid = false;
}
}
}
}
}
bool NedIdiotsInstrument::newVolumeNeeded(unsigned long long time, int *new_volume) {
GList *lptr;
for (lptr = g_list_last(m_specials); lptr; lptr = g_list_previous(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_VOLUME_CHANGE) continue;
if (((NedIdSpecial *) lptr->data)->m_time > time) continue;
if (((NedIdVolumeChange *) lptr->data)->m_taken) return false;
*new_volume = ((NedIdVolumeChange *) lptr->data)->m_volume;
((NedIdVolumeChange *) lptr->data)->m_taken = true;
return true;
}
return false;
}
#define WEIGHT_PAUSE 4
#define WEIGHT_DOTTED_PAUSE 6
#define WEIGHT_DOTTED_NOTE 2
#define WEIGHT_NOTE 1
int NedIdiotsInstrument::compute_weight(unsigned long long sta, unsigned long long sto, bool is_rest) {
int ndotcount = 0, rdotcount = 0;
int ncount = 0, rcount = 0;
int dotcount;
unsigned int len2;
if (sto < sta) {
NedResource::Abort("NedIdiotsInstrument::compute_weight");
}
NedResource::setLengthField((int) sto - sta);
len2 = NedResource::getPartLength(&dotcount);
while(len2) {
if (is_rest) {
if (dotcount != 0) {
rdotcount++;
}
else {
rcount++;
}
}
else {
if (dotcount != 0) {
ndotcount++;
}
else {
ncount++;
}
}
len2 = NedResource::getPartLength(&dotcount);
}
return rcount * WEIGHT_PAUSE + ncount * WEIGHT_NOTE + rdotcount * WEIGHT_DOTTED_PAUSE + ndotcount * WEIGHT_DOTTED_NOTE;
}
unsigned long long NedIdiotsInstrument::findEndTime(unsigned long long sta, unsigned long long sto, unsigned long long max_stop, unsigned long long rest_end, unsigned long long measure_start) {
unsigned long long duration, snap, i, minsnap = 0, mini = 0;
int weight, minweight = 10000;
if (rest_end < max_stop) {
NedResource::Abort("NedIdiotsInstrument::findEndTime");
}
duration = sto - sta;
sto = sta + (duration >> 1);
for (snap = NOTE_2; snap >= NOTE_64; snap >>= 1) {
i = 0;
while (true) {
if (measure_start + i * snap <= sto) {i++; continue;}
if (measure_start + i * snap > max_stop) break;
weight = compute_weight(sta, measure_start + i * snap, false);
weight += compute_weight(measure_start + i * snap, rest_end, true);
if (weight < minweight) {
minweight = weight;
mini = i;
minsnap = snap;
}
i++;
}
}
if (minsnap != 0) {
return measure_start + mini * minsnap;
}
return sto;
}
void NedIdiotsInstrument::enlargeNotesWithUnusualLength(NedIdiotsEditor *id) {
NedIdNote *note, *note2;
unsigned long long note_duration, new_end_time, max_end_time, start_time, end_time, measure_width;
/* unsigned long long snap, minsnap, maxsnap, dist, mindist; */
int numerator, denominator;
GList *lptr, *lptr2;
m_notes[0] = g_list_sort(m_notes[0], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
start_time = 0;
id->getMeasureNumber(start_time, &numerator, &denominator);
lptr = g_list_first(m_notes[0]);
do {
measure_width = numerator * WHOLE_NOTE / denominator;
end_time = start_time + measure_width;
for (; lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (note->m_is_triplet_note) continue;
if (!note->m_valid) continue;
if (note->m_midi_start >= end_time) break;
for (lptr2 = g_list_next(lptr); lptr2; lptr2 = g_list_next(lptr2)) {
note2 = (NedIdNote *) lptr2->data;
if (note2->m_midi_start == note->m_midi_start) continue;
if (note2->m_valid) break;
}
if (lptr2 == NULL) {
new_end_time = max_end_time = end_time;
if (new_end_time <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesWithUnusualLength(1)");
}
}
else {
if (note2->m_midi_start > end_time) {
new_end_time = max_end_time = end_time;
if (new_end_time <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesWithUnusualLength(2)");
}
}
else {
new_end_time = max_end_time = note2->m_midi_start;
note_duration = note->m_midi_stop - note->m_midi_start;
if (max_end_time - note->m_midi_start < 3 * note_duration / 5) {
new_end_time = max_end_time = end_time;
}
if (new_end_time <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesWithUnusualLength(3)");
}
}
}
note_duration = note->m_midi_stop - note->m_midi_start;
if (note_duration < NOTE_8) {
if (new_end_time - note->m_midi_start > (note_duration << 2)) {
new_end_time = note->m_midi_start + (note_duration << 2);
}
}
else {
if (new_end_time - note->m_midi_start > (note_duration + (note_duration >> 1))) {
new_end_time = note->m_midi_start + (note_duration + (note_duration >> 1));
}
}
note->m_max_stop = new_end_time;
if (note->m_max_stop > 0 && note->m_max_stop <= note->m_midi_start) {
//NedResource::Abort("NedIdiotsInstrument::enlargeNotesWithUnusualLength(4)");
note->m_valid = false;
continue;
}
note->m_midi_stop = findEndTime(note->m_midi_start, note->m_midi_stop, new_end_time, max_end_time, start_time);
/*
note_duration = new_end_time - note->m_midi_start;
mindist = WHOLE_NOTE;
minsnap = 0;
for (snap = WHOLE_NOTE; snap >= NOTE_64; snap >>= 1) {
dist = (note_duration > snap ) ? (note_duration - snap) : (snap - note_duration);
if (dist < mindist && note->m_midi_start + snap <= new_end_time) {
mindist = dist;
minsnap = snap;
}
}
for (snap = NOTE_2 + NOTE_4; snap > NOTE_64; snap >>= 1) {
dist = (note_duration > snap ) ? (note_duration - snap) : (snap - note_duration);
if (dist < mindist && note->m_midi_start + snap <= new_end_time) {
mindist = dist;
minsnap = snap;
}
}
if (minsnap > 0) {
note->m_midi_stop = note->m_midi_start + minsnap;
}
*/
}
id->getMeasureNumber(end_time, &numerator, &denominator);
start_time = end_time;
}
while (lptr != NULL);
}
void NedIdiotsInstrument::notesAus(char *s, int i) {
GList *lptr;
NedIdNote *note;
printf("%s, voi %d:\n", s, i);
for (lptr = g_list_first(m_notes[i]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
printf("\tnote(0x%p): %llu(%llu, %llu) - %llu(%llu,%llu), m_pitch = %d, m_line = %d, m_is_triplet_note = %d, m_valid = %d\n",
note, LAUS(note->m_midi_start), LAUS(note->m_midi_stop),
note->m_pitch, note->m_line, note->m_is_triplet_note, note->m_valid);
if (note->m_is_triplet_note) {
for (int i = 0; i <3; i++) {
printf("\t\tnote(0x%p): %llu(%llu, %llu) - %llu(%llu,%llu), m_pitch = %d, m_line = %d, m_triplet_type = %d, m_valid = %d\n",
note->m_tripletnotes[i], LAUS(note->m_tripletnotes[i]->m_midi_start), LAUS(note->m_tripletnotes[i]->m_midi_stop),
note->m_tripletnotes[i]->m_pitch, note->m_tripletnotes[i]->m_line, note->m_tripletnotes[i]->m_is_triplet_note, note->m_tripletnotes[i]->m_valid);
}
}
}
fflush(stdout);
}
NedIdNote *NedIdiotsInstrument::findNote(GList *start, unsigned long long start_time, unsigned long long end_time, NedIdNote *not_note1, NedIdNote *not_note2) {
NedIdNote *note;
unsigned long long diff, dur;
for (; start; start = g_list_next(start)) {
note = (NedIdNote *) start->data;
if (!note->m_valid) continue;
if (note == not_note1) continue;
if (note == not_note2) continue;
if (note->m_ori_start > end_time) return NULL;
diff = (start_time > note->m_ori_start) ? (start_time - note->m_ori_start) : ( note->m_ori_start - start_time);
if (diff > NOTE_8) continue;
dur = note->m_ori_stop - note->m_ori_start;
diff = (dur > NOTE_4 / 3) ? (dur - NOTE_4 / 3) : (NOTE_4 / 3 - dur);
if (diff > NOTE_8) continue;
if (note->m_ori_stop - note->m_ori_start <= NOTE_32) continue;
return note;
}
return NULL;
}
void NedIdiotsInstrument::recognizeTriplets(NedIdiotsEditor *id) {
NedIdNote *note = NULL, *tri_note, *tri_array[40][3]; // worst case: 20/2 that is 40 quarter triplets
unsigned long long start_time, end_time, measure_width;
int numerator, denominator, i, j;
GList *lptr_start, *lptr, *lptr2;
GList *tri_notes = NULL;
m_notes[0] = g_list_sort(m_notes[0], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
start_time = 0;
id->getMeasureNumber(start_time, &numerator, &denominator);
lptr = g_list_first(m_notes[0]);
do {
for (i = 0; i < 40; i++) {
for (j = 0; j < 3; tri_array[i][j++] = NULL);
}
measure_width = numerator * WHOLE_NOTE / denominator;
end_time = start_time + measure_width;
lptr_start = lptr;
for (; lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
if (note->m_midi_start >= end_time) break;
if (note->m_tri_start_numerator) {
tri_array[note->m_tri_start_numerator / 3][note->m_tri_start_numerator % 3] = note;
}
}
if (measure_width >= NOTE_4) {
for (i = 0; i < 40; i++) {
if (tri_array[i][1] && tri_array[i][1]->m_valid && start_time + (i + 1) * NOTE_4 <= end_time) {
if ((tri_array[i][0] = findNote(lptr_start, start_time + i * NOTE_4, start_time + i * NOTE_4 + NOTE_8, tri_array[i][1], tri_array[i][2]))) {
tri_note = new NedIdNote(tri_array[i][0]->m_pitch, tri_array[i][0]->m_volume, start_time + i * NOTE_4, start_time + (i + 1) * NOTE_4);
tri_note->m_line = tri_array[i][0]->m_line;
tri_note->m_state = tri_array[i][0]->m_state;
tri_note->m_is_triplet_note = true;
tri_notes = g_list_append(tri_notes, tri_note);
for (j = 0; j < 2; j++) {
tri_note->m_tripletnotes[j] = tri_array[i][j];
tri_array[i][j]->m_valid = false; // avoid normal treatment of these notes
}
if (tri_array[i][2] && tri_array[i][2]->m_valid) {
tri_note->m_tripletnotes[2] = tri_array[i][2];
tri_array[i][2]->m_valid = false; // avoid normal treatment of these notes
}
}
else if (tri_array[i][2] && tri_array[i][2]->m_valid) {
tri_note = new NedIdNote(tri_array[i][1]->m_pitch, tri_array[i][1]->m_volume, start_time + i * NOTE_4, start_time + (i + 1) * NOTE_4);
tri_note->m_is_triplet_note = true;
tri_note->m_line = tri_array[i][1]->m_line;
tri_note->m_state = tri_array[i][1]->m_state;
tri_note->m_is_triplet_note = true;
tri_notes = g_list_append(tri_notes, tri_note);
for (j = 1; j < 3; j++) { // only 2 notes --> first ist a break
tri_note->m_tripletnotes[j] = tri_array[i][j];
tri_array[i][j]->m_valid = false; // avoid normal treatment of these notes
}
}
}
}
}
id->getMeasureNumber(end_time, &numerator, &denominator);
start_time = end_time;
}
while (lptr != NULL);
for (lptr = g_list_first(tri_notes); lptr; lptr = g_list_next(lptr)) {
tri_note = (NedIdNote *) lptr->data;
for (i = 0; i < 3; i++) {
if (tri_note->m_tripletnotes[i] != NULL) {
if ((lptr2 = g_list_find(m_notes[0], tri_note->m_tripletnotes[i])) == NULL) {
NedResource::Abort("NedIdiotsInstrument::recognizeTriplets(1)");
}
m_notes[0] = g_list_delete_link(m_notes[0], lptr2);
note->m_valid = true;
}
}
}
for (lptr = g_list_first(tri_notes); lptr; lptr = g_list_next(lptr)) {
m_notes[0] = g_list_insert_sorted(m_notes[0], lptr->data, (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
}
g_list_free(tri_notes);
}
void NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(NedIdiotsEditor *id) {
NedIdNote *note, *note2;
unsigned long long note_duration, max_end_time, new_end_time, start_time, end_time, measure_width;
/* unsigned long long snap, minsnap, maxsnap, dist, mindist; */
int numerator, denominator;
GList *lptr, *lptr2;
int voi;
for (voi = 0; voi < VOICE_COUNT; voi++) {
m_notes[voi] = g_list_sort(m_notes[voi], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
start_time = 0;
id->getMeasureNumber(start_time, &numerator, &denominator);
lptr = g_list_first(m_notes[voi]);
do {
measure_width = numerator * WHOLE_NOTE / denominator;
end_time = start_time + measure_width;
for (; lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
if (note->m_is_triplet_note) continue;
if (note->fix_end) continue;
if (note->m_midi_start >= end_time) break;
for (lptr2 = g_list_next(lptr); lptr2; lptr2 = g_list_next(lptr2)) {
note2 = (NedIdNote *) lptr2->data;
if (note2->m_midi_start == note->m_midi_start) continue;
if (note2->m_valid) break;
}
if (lptr2 == NULL || note2->m_midi_start > end_time) {
new_end_time = max_end_time = end_time;
}
else {
new_end_time = max_end_time = note2->m_midi_start;
}
if (new_end_time > end_time) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(1)");
}
if (max_end_time > end_time) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(2)");
}
/*
if (note->m_max_stop > 0 && max_end_time > note->m_max_stop) {
if (note->m_max_stop <= note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(3)");
}
new_end_time = max_end_time = note->m_max_stop;
}
*/
if (new_end_time > end_time) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(4)");
}
note_duration = note->m_midi_stop - note->m_midi_start;
if (note_duration < NOTE_16) {
if (new_end_time - note->m_midi_start > (note_duration << 2)) {
new_end_time = note->m_midi_start + (note_duration << 2);
}
}
else {
if (new_end_time - note->m_midi_start > (note_duration + (note_duration >> 1))) {
new_end_time = note->m_midi_start + (note_duration + (note_duration >> 1));
}
}
if (new_end_time > end_time) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(5)");
}
if (new_end_time > max_end_time) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(6)");
}
note->m_midi_stop = findEndTime(note->m_midi_start, note->m_midi_stop, new_end_time, max_end_time, start_time);
if (note->m_midi_stop > end_time) {
NedResource::Abort("NedIdiotsInstrument::enlargeNotesToAvoidSmallRests(7)");
}
/*
note_duration = new_end_time - note->m_midi_start;
mindist = WHOLE_NOTE;
minsnap = 0;
for (snap = WHOLE_NOTE; snap >= NOTE_64; snap >>= 1) {
dist = (note_duration > snap ) ? (note_duration - snap) : (snap - note_duration);
if (dist < mindist && note->m_midi_start + snap <= new_end_time) {
mindist = dist;
minsnap = snap;
}
}
for (snap = NOTE_2 + NOTE_4; snap > NOTE_64; snap >>= 1) {
dist = (note_duration > snap ) ? (note_duration - snap) : (snap - note_duration);
if (dist < mindist && note->m_midi_start + snap <= new_end_time) {
mindist = dist;
minsnap = snap;
}
}
if (minsnap > 0) {
note->m_midi_stop = note->m_midi_start + minsnap;
}
*/
}
id->getMeasureNumber(end_time, &numerator, &denominator);
start_time = end_time;
}
while (lptr != NULL);
}
}
void NedIdiotsInstrument::computeVolume() {
GList *lptr;
NedIdNote *note;
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
m_volume = note->m_volume;
return;
}
}
void NedIdiotsInstrument::findConflictingNotes() {
GList *lptr1, *lptr2;
NedIdNote *note1, *note2;
GList *conflict_list_ptrs = NULL;
GList *conflict_list_nts = NULL;
int voi;
for (voi = 0; voi < VOICE_COUNT; voi++) {
m_notes[voi] = g_list_sort(m_notes[voi], (gint (*)(const void*, const void*)) NedIdNote::compare_note_start);
for (lptr1 = g_list_first(m_notes[voi]); lptr1; lptr1 = g_list_next(lptr1)) {
note1 = (NedIdNote *) lptr1->data;
if (!note1->m_valid) continue;
if (conflict_list_ptrs != NULL) {
g_list_free(conflict_list_ptrs);
}
conflict_list_ptrs = NULL;
if (conflict_list_nts != NULL) {
g_list_free(conflict_list_nts);
}
conflict_list_nts = NULL;
for (lptr2 = g_list_next(lptr1); lptr2; lptr2 = g_list_next(lptr2)) {
note2 = (NedIdNote *) lptr2->data;
if (!note2->m_valid) continue;
if (note2->m_midi_start >= note1->m_midi_stop) break;
if (note2->m_midi_start < note1->m_midi_stop) {
conflict_list_ptrs = g_list_append(conflict_list_ptrs, lptr2);
conflict_list_nts = g_list_append(conflict_list_nts, lptr2->data);
}
}
for (lptr2 = g_list_first(conflict_list_ptrs); lptr2; lptr2 = g_list_next(lptr2)) {
m_notes[voi] = g_list_delete_link(m_notes[voi], (GList *) (lptr2->data));
}
if (voi < VOICE_COUNT - 1) {
for (lptr2 = g_list_first(conflict_list_nts); lptr2; lptr2 = g_list_next(lptr2)) {
m_notes[voi + 1] = g_list_append(m_notes[voi + 1], lptr2->data);
}
}
}
if (conflict_list_ptrs != NULL) {
g_list_free(conflict_list_ptrs);
conflict_list_ptrs = NULL;
}
if (conflict_list_nts != NULL) {
g_list_free(conflict_list_nts);
conflict_list_nts = NULL;
}
}
for (voi = 0; voi < VOICE_COUNT; voi++) {
for (lptr1 = g_list_first(m_notes[voi]); lptr1; lptr1 = g_list_next(lptr1)) {
note1 = (NedIdNote *) lptr1->data;
if (!note1->m_valid) continue;
if (note1->m_max_stop > 0 && note1->m_max_stop <= note1->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::findConflictingNotes");
}
}
}
}
void NedIdiotsInstrument::addSpecial(NedIdSpecial *spec) {
m_specials = g_list_insert_sorted(m_specials, spec, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
}
GList *NedIdiotsInstrument::clone_specials() {
GList *cl = NULL;
GList *lptr;
NedIdVolumeChange *vc0, *vc1;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
switch (((NedIdSpecial *) lptr->data)->m_type) {
case ID_SPEC_VOLUME_CHANGE: vc0 = (NedIdVolumeChange *) lptr->data;
vc1 = new NedIdVolumeChange(vc0->m_time, 0, vc0->m_volume);
cl = g_list_insert_sorted(cl, vc1, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
break;
}
}
return cl;
}
int NedIdiotsInstrument::specCount() {
return g_list_length(m_specials);
}
void NedIdiotsInstrument::generateVolumeSigns(int volume_change_density) {
GList *lptr;
int current_volume = -1000;
int vol_dist;
NedIdNote *note;
NedIdVolumeChange *vc;
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
vol_dist = note->m_volume - current_volume;
if (vol_dist < 0) vol_dist = -vol_dist;
if ((int) ((double) (vol_dist * 100) / /* 127.0 */ (double) (current_volume + 1) ) > volume_change_density) {
vc = new NedIdVolumeChange(note->m_midi_start, 0, note->m_volume);
m_specials = g_list_insert_sorted(m_specials, vc, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
current_volume = note->m_volume;
}
}
}
GList * NedIdiotsInstrument::convertToNtEdNotes(NedIdiotsEditor *id, bool place_tempo_sigs, bool place_volume_or_key_signs, int voice_nr, unsigned long long last_time) {
/* int j; */
pitch_info *pi;
GList *notes = NULL;
NedChordOrRest *chord_or_rest = NULL, *last_chord = NULL, *last_splitted_chord = NULL;
int measure_nr = 0;
int dotcount, len2;
unsigned long long start_time = 0, end_time, current_time;
unsigned long long measure_width;
unsigned long long last_tempo_test = 0, last_key_test = 0;
int numerator, denominator;
int current_tempo = -1, newtempo, newvolume = 1000, newkey;
int last_key = 0;
NedVolumeSign *volsign;
GList *lptr2;
NedIdNote *note, *tri_note;
NedNote *ned_note;
bool first, tie_required;
bool volume_set = false;
if (voice_nr == 0) {
generateVolumeSigns(id->getVolumeChangeDensity());
splitNotesAtMeasureStart(id);
findChords(false);
determineLines(id);
enlargeNotesWithUnusualLength(id);
findConflictingNotes();
enlargeNotesToAvoidSmallRests(id);
//findChords(true); // after "splitNotesAtMeasureStart" new chords are possible
}
id->getMeasureNumber(start_time, &numerator, &denominator);
GList *lptr = g_list_first(m_notes[voice_nr]);
do {
measure_nr++;
current_time = start_time;
measure_width = numerator * WHOLE_NOTE / denominator;
end_time = start_time + measure_width;
for (; lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (!note->m_valid) continue;
if (note->m_midi_start < start_time) {
NedResource::Abort("NedIdiotsInstrument::convertToNtEdNotes(1)");
}
if (note->m_midi_start >= end_time) {
NedResource::setLengthField(end_time - current_time);
}
else {
NedResource::setLengthField(note->m_midi_start - current_time);
}
if (place_volume_or_key_signs && m_channel != 9 && id->newKeyNeeded(current_time, &newkey, &last_key_test)) {
if (current_time != 0) {
chord_or_rest = new NedChordOrRest(NULL, TYPE_KEYSIG, newkey, last_key, 0);
notes = g_list_append(notes, chord_or_rest);
}
last_key = newkey;
}
len2 = NedResource::getPartLength(&dotcount, true, current_time == start_time && measure_width <= NOTE_4, measure_width);
while (len2) {
last_chord = NULL;
chord_or_rest = new NedChordOrRest(NULL, TYPE_REST, false, 3 /* dummy */, dotcount, len2, NORMAL_NOTE, 0, 0);
if (place_tempo_sigs && m_channel != 9 && id->newTempoNeeded(current_time, &newtempo, current_tempo, &last_tempo_test)) {
new NedTempoSign(NOTE_4, newtempo, chord_or_rest, DEFAULT_FREE_X_DIST, DEFAULT_FREE_Y_DIST, true);
current_tempo = newtempo;
}
current_time += chord_or_rest->getDuration(measure_width);
notes = g_list_append(notes, chord_or_rest);
len2 = NedResource::getPartLength(&dotcount, true, current_time == start_time, measure_width);
}
if (note->m_midi_start >= end_time) break;
if (end_time < current_time + note->m_midi_stop - note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::convertToNtEdNotes(2a)");
}
if (note->m_midi_stop < note->m_midi_start) {
NedResource::Abort("NedIdiotsInstrument::convertToNtEdNotes(2)");
}
if (place_volume_or_key_signs && m_channel != 9 && id->newKeyNeeded(current_time, &newkey, &last_key_test)) {
if (current_time != 0) {
chord_or_rest = new NedChordOrRest(NULL, TYPE_KEYSIG, newkey, last_key, 0);
notes = g_list_append(notes, chord_or_rest);
}
last_key = newkey;
}
chord_or_rest = NULL;
if (note->m_is_triplet_note) {
for (int i = 0; i < 3; i++) {
if ((tri_note = note->m_tripletnotes[i]) != NULL) {
chord_or_rest = new NedChordOrRest(NULL, TYPE_CHORD, false, tri_note->m_line, 0, NOTE_8, CHOOSE_HEAD(tri_note->m_line), tri_note->m_state, 0);
for (lptr2 = g_list_first(tri_note->m_chordnotes); lptr2; lptr2 = g_list_next(lptr2)) {
pi = (pitch_info *) lptr2->data;
ned_note = new NedNote(chord_or_rest, pi->m_line, CHOOSE_HEAD(pi->m_line), pi->m_state);
chord_or_rest->insertNoteAt(ned_note);
}
}
else {
chord_or_rest = new NedChordOrRest(NULL, TYPE_REST, false, 3 /* dummy */, 0, NOTE_8, NORMAL_NOTE, 0, 0);
}
chord_or_rest->setTupletVal(3);
notes = g_list_append(notes, chord_or_rest);
}
chord_or_rest->setLastTupletFlag(true);
current_time += NOTE_4;
last_chord = NULL;
}
else {
first = true;
last_splitted_chord = NULL;
#define SPLIT2
#ifdef SPLIT2
NedResource::setLengthField2(start_time, note->m_midi_start, note->m_midi_stop - note->m_midi_start);
len2 = NedResource::getPartLength2(&dotcount, false, true, measure_width);
#else
NedResource::setLengthField(note->m_midi_stop - note->m_midi_start);
len2 = NedResource::getPartLength(&dotcount, false, true, measure_width);
#endif
while (len2) {
chord_or_rest = new NedChordOrRest(NULL, TYPE_CHORD, false, note->m_line, dotcount, len2, CHOOSE_HEAD(note->m_line), note->m_state, 0);
if (place_tempo_sigs && id->newTempoNeeded(current_time, &newtempo, current_tempo, &last_tempo_test)) {
new NedTempoSign(NOTE_4, newtempo, chord_or_rest, DEFAULT_FREE_X_DIST, DEFAULT_FREE_Y_DIST, true);
current_tempo = newtempo;
}
if (first && place_volume_or_key_signs && newVolumeNeeded(current_time, &newvolume)) {
if (volume_set) {
volsign = new NedVolumeSign(NedVolumeSign::determineKind(newvolume), chord_or_rest, DEFAULT_FREE_X_DIST, VOLUME_SIGN_Y_DIST, true);
volsign->m_midi_volume = newvolume;
}
else {
//m_volume = newvolume;
}
volume_set = true;
}
tie_required = (first && note->m_tiedbackward);
for (lptr2 = g_list_first(note->m_chordnotes); lptr2; lptr2 = g_list_next(lptr2)) {
pi = (pitch_info *) lptr2->data;
ned_note = new NedNote(chord_or_rest, pi->m_line, CHOOSE_HEAD(pi->m_line), pi->m_state);
tie_required = (tie_required || (first && pi->m_tiebackward));
chord_or_rest->insertNoteAt(ned_note);
}
if (tie_required) {
if (last_chord == NULL) {
fprintf(stderr, "cannot tie\n"); fflush(stderr);
}
else {
last_chord->tieCompleteTo(chord_or_rest, false);
last_chord = NULL;
}
}
if (last_splitted_chord != NULL) {
last_splitted_chord->tieCompleteTo(chord_or_rest, false);
}
last_splitted_chord = chord_or_rest;
current_time += chord_or_rest->getDuration(measure_width);
notes = g_list_append(notes, chord_or_rest);
#ifdef SPLIT2
len2 = NedResource::getPartLength2(&dotcount, false, true, measure_width);
#else
len2 = NedResource::getPartLength(&dotcount, false, true, measure_width);
#endif
first = false;
last_chord = chord_or_rest;
}
}
}
if (end_time < current_time) {
printf("Crash: end_time = %llu(%llu, %llu), current_time = %llu(%llu, %llu)\n",
end_time, end_time / NOTE_64, end_time / NOTE_4, current_time, current_time / NOTE_64, current_time / NOTE_4); fflush(stdout);
NedResource::Abort("NedIdiotsInstrument::convertToNtEdNotes(3)");
}
NedResource::setLengthField(end_time - current_time);
if (place_volume_or_key_signs && id->newKeyNeeded(current_time, &newkey, &last_key_test)) {
if (current_time != 0) {
chord_or_rest = new NedChordOrRest(NULL, TYPE_KEYSIG, newkey, last_key, 0);
notes = g_list_append(notes, chord_or_rest);
}
last_key = newkey;
}
len2 = NedResource::getPartLength(&dotcount, true, current_time == start_time && measure_width <= NOTE_4, measure_width);
while (len2) {
last_chord = NULL;
chord_or_rest = new NedChordOrRest(NULL, TYPE_REST, false, 3 /* dummy */, dotcount, len2, NORMAL_NOTE, 0, 0);
if (place_tempo_sigs && id->newTempoNeeded(current_time, &newtempo, current_tempo, &last_tempo_test)) {
new NedTempoSign(NOTE_4, newtempo, chord_or_rest, DEFAULT_FREE_X_DIST, DEFAULT_FREE_Y_DIST, true);
current_tempo = newtempo;
}
current_time += chord_or_rest->getDuration(measure_width);
notes = g_list_append(notes, chord_or_rest);
len2 = NedResource::getPartLength(&dotcount, true, current_time == start_time, measure_width);
}
if (end_time != current_time) {
printf("Crash: end_time = %llu(%llu, %llu), current_time = %llu(%llu, %llu)\n",
end_time, end_time / NOTE_64, end_time / NOTE_4, current_time, current_time / NOTE_64, current_time / NOTE_4); fflush(stdout);
NedResource::Abort("NedIdiotsInstrument::convertToNtEdNotes(4)");
}
id->getMeasureNumber(end_time, &numerator, &denominator);
start_time = end_time;
}
while(end_time < last_time);
/*
}
else {
for (j = 0; j < measure_nr; j++) {
chord_or_rest = new NedChordOrRest(NULL, TYPE_REST, true, 3, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0);
notes = g_list_append(notes, chord_or_rest);
}
}
*/
return notes;
}
void NedIdiotsInstrument::addNote(int pitch, int volume, unsigned long long start, int midi_nr) {
m_notes[0] = g_list_append(m_notes[0], new NedIdNote(pitch, volume, start));
}
void NedIdiotsInstrument::addNote(NedIdNote *note) {
m_notes[0] = g_list_append(m_notes[0], note);
}
void NedIdiotsInstrument::setInstrumentName(char *name) {
strcpy(m_inst_name, name);
}
void NedIdiotsInstrument::closeNote(int pitch, unsigned long long end_time, int midi_nr) {
GList *lptr;
for (lptr = g_list_last(m_notes[0]); lptr; lptr = g_list_previous(lptr)) {
if (((NedIdNote *) lptr->data)->m_pitch == pitch &&
!((NedIdNote *) lptr->data)->m_valid && ((NedIdNote *) lptr->data)->m_midi_start < end_time) {
((NedIdNote *) lptr->data)->m_midi_stop =
((NedIdNote *) lptr->data)->m_ori_stop = end_time;
((NedIdNote *) lptr->data)->m_valid = true;
return;
}
}
printf("cannot close note, inst = %d, pitch = %d\n", m_midi_nr, pitch); fflush(stdout);
}
#define MAX_BORDER_CLICK_DIST 5.4
void NedIdiotsInstrument::handle_button_press (GdkEventButton *event, double xleft, double ytop, double visible_start_pos, double visible_end_pos) {
NedIdNote *note, *prev_selected;
GList * lptr;
double dist;
double zoom_value = m_id_edit->getZoomValue();
prev_selected = m_selected_note;
m_selected_note = NULL;
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (note->m_midi_start / FACTOR * zoom_value > visible_end_pos) continue;
if (note->m_midi_stop / FACTOR * zoom_value < visible_start_pos) continue;
double startpos = X_POS(note->m_midi_start);
double endpos = X_POS(note->m_midi_stop);
double ypos = PITCH_TO_YPOS(note->m_pitch);
if (note->isInRect(event->x, event->y, zoom_value, xleft, ytop)) {
m_selected_note = note;
dist = event->x - startpos;
if (dist < 0) dist = -dist;
if (dist < MAX_BORDER_CLICK_DIST) {
//printf("move start\n"); fflush(stdout);
gdk_window_set_cursor (GDK_WINDOW(m_id_edit->getDrawingArea()->window), m_id_edit->getDoubldArrowCursor());
m_id_edit->motion_mode = MOTION_NODE_LEFT;
}
else {
dist = event->x - endpos;
if (dist < 0) dist = -dist;
if (dist < MAX_BORDER_CLICK_DIST) {
//printf("move end\n"); fflush(stdout);
m_id_edit->motion_mode = MOTION_NODE_RIGHT;
gdk_window_set_cursor (GDK_WINDOW(m_id_edit->getDrawingArea()->window), m_id_edit->getDoubldArrowCursor());
}
else {
//printf("move mid\n"); fflush(stdout);
m_id_edit->motion_mode = MOTION_MODE_MOVE;
gdk_window_set_cursor (GDK_WINDOW(m_id_edit->getDrawingArea()->window), m_id_edit->getFleurCursor());
}
}
}
}
if (m_selected_note == prev_selected) return;
m_id_edit->repaint();
}
NedIdiotsEditor::NedIdiotsEditor(int tempo_change_density, int volume_change_density, bool force_piano, bool sort_instruments, bool dont_split, bool X11Version /* = false */) :
m_tempo_inverse(START_TEMPO_INVERSE), motion_mode(MOTION_MODE_NONE),
m_zoom_value(ID_DEFAULT_ZOOM), m_force_piano(force_piano),
m_tempo_change_density(tempo_change_density), m_volume_change_density(volume_change_density),
m_current_instrument_number(0), m_channel_nr(0), m_last_inserted(NULL),
m_sort_according_instrument(sort_instruments), m_dont_split(dont_split),
m_X11version(X11Version), m_min_denom(1), m_instruments(NULL), m_specials(NULL),
m_mouse_x(0.0), m_mouse_y(0.0), m_dpy(NULL), m_off_x(0.0), m_off_y(0.0) {
m_pending_inst_name[0] = '\0';
GtkWidget *menubar;
if (m_X11version) {
GtkWidget *drawing_hbox;
GdkColor bgcolor;
GtkWidget *main_vbox;
GtkWidget *toolbar;
GtkWidget *hscrollbar;
GtkWidget *vscrollbar;
GtkAccelGroup *accel_group;
#ifdef ORIORI
GtkActionGroup *instrument_group;
#endif
m_command_history = new NedIdCommandHistory(this);
GError *error;
double min, max;
m_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (m_main_window), _("Idiot's editor"));
gtk_window_set_default_size (GTK_WINDOW (m_main_window), 600, 400);
m_menu_action_group = gtk_action_group_new ("IdMenuActions");
gtk_action_group_set_translation_domain(m_menu_action_group, NULL);
gtk_action_group_add_actions (m_menu_action_group, file_entries, G_N_ELEMENTS (file_entries), (void *) this);
m_ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (m_ui_manager, m_menu_action_group, 0);
accel_group = gtk_ui_manager_get_accel_group (m_ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (m_main_window), accel_group);
error = NULL;
if (!gtk_ui_manager_add_ui_from_string (m_ui_manager, guiDescription, -1, &error)) {
g_message ("building menus failed: %s", error->message);
g_error_free (error);
NedResource::Abort("error");
}
menubar = gtk_ui_manager_get_widget (m_ui_manager, "/IdMainMenu");
toolbar = gtk_ui_manager_get_widget (m_ui_manager, "/IdToolBar");
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
//table = gtk_notebook_new();
m_instrument_toolbar = gtk_toolbar_new();
m_instr_bu = gtk_radio_button_new_with_label(NULL, "Inst 1");
g_signal_connect (GTK_BUTTON(m_instr_bu), "pressed", G_CALLBACK (select_instrument), (void *) this);
gtk_toolbar_append_widget(GTK_TOOLBAR(m_instrument_toolbar), m_instr_bu , NULL, NULL);
m_drawing_area = gtk_drawing_area_new ();
gtk_widget_set_double_buffered(m_drawing_area, FALSE);
//gtk_widget_set_size_request(m_drawing_area, 16 * m_zoom_value , (int) ID_HEIGHT);
gtk_widget_set_size_request(m_drawing_area, START_WIDTH, START_HEIGHT);
m_hadjust = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 100, 1, 100, START_WIDTH));
m_vadjust = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, ID_HEIGHT, 1, 10, START_HEIGHT));
hscrollbar = gtk_hscrollbar_new(m_hadjust);
vscrollbar = gtk_vscrollbar_new(m_vadjust);
bgcolor.pixel = 0;
bgcolor.red = bgcolor.green = bgcolor.blue = 0xffff;
gtk_widget_modify_bg(GTK_WIDGET(m_drawing_area), GTK_STATE_NORMAL, &bgcolor);
/*
GTK_WIDGET_SET_FLAGS(m_drawing_area, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS(m_main_window, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS(m_drawing_area, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS(m_main_window, GTK_CAN_FOCUS);
gtk_widget_add_events(m_main_window, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
gtk_widget_add_events(m_drawing_area, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
gtk_widget_add_events(m_main_window, GDK_KEY_RELEASE_MASK );
gtk_widget_add_events(m_drawing_area, GDK_KEY_RELEASE_MASK );
*/
/*
gtk_widget_add_events(m_drawing_area, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
*/
m_double_arrow = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW);
m_pointer = gdk_cursor_new(GDK_LEFT_PTR);
m_fleur = gdk_cursor_new(GDK_FLEUR);
gtk_widget_add_events(m_drawing_area, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK );
g_signal_connect (m_drawing_area, "expose-event",
G_CALLBACK (handle_expose), (void *) this);
g_signal_connect (m_hadjust, "value-changed",
G_CALLBACK (handle_scroll), (void *) this);
g_signal_connect (m_vadjust, "value-changed",
G_CALLBACK (handle_scroll), (void *) this);
g_signal_connect (m_drawing_area, "size-allocate",
G_CALLBACK (size_change_handler), (void *) this);
g_signal_connect (m_drawing_area, "button-press-event",
G_CALLBACK (handle_button_press), (void *) this);
g_signal_connect (m_drawing_area, "motion-notify-event",
G_CALLBACK (handle_motion), (void *) this);
g_signal_connect (m_drawing_area, "button-release-event",
G_CALLBACK (handle_button_release), (void *) this);
/*
g_signal_connect (m_drawing_area, "motion-notify-event",
G_CALLBACK (handle_motion), (void *) this);
g_signal_connect (m_drawing_area, "key-press-event",
G_CALLBACK (key_press_handler), (void *) this);
g_signal_connect (m_drawing_area, "key-release-event",
G_CALLBACK (key_release_handler), (void *) this);
g_signal_connect (m_drawing_area, "enter-notify-event",
G_CALLBACK (window_enter_handler), (void *) this);
g_signal_connect (m_drawing_area, "leave-notify-event",
G_CALLBACK (window_leave_handler), (void *) this);
g_signal_connect (m_drawing_area, "scroll-event",
G_CALLBACK (scroll_event_handler), (void *) this);
g_signal_connect (m_main_window, "delete-event",
G_CALLBACK (handle_delete), (void *) this);
g_signal_connect (m_page_selector, "value-changed",
G_CALLBACK (handle_page_request), (void *) this);
*/
drawing_hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (drawing_hbox), m_drawing_area, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (drawing_hbox), vscrollbar, FALSE, FALSE, 0);
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), m_instrument_toolbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), drawing_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), hscrollbar, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (m_main_window), main_vbox);
gtk_widget_show_all (m_main_window);
g_object_get (m_vadjust, "lower", &min, "upper", &max, NULL);
gtk_adjustment_set_value(GTK_ADJUSTMENT(m_vadjust), min + (max - min) / 3.0);
} /* if (x11version) */
m_instruments = g_list_append(m_instruments, new NedIdiotsInstrument(this, m_channel_nr++, -2, -2, m_volume_change_density));
setLastTime(4 * NOTE_4);
}
NedIdiotsEditor::~NedIdiotsEditor() {
GList *lptr;
if (m_dpy != NULL) {
XFreePixmap(m_dpy, m_back_image);
}
if (m_X11version) {
gtk_widget_destroy(m_main_window);
}
if (m_instruments != NULL) {
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
delete (NedIdiotsInstrument *) lptr->data;
}
g_list_free(m_instruments);
m_instruments = NULL;
}
if (m_specials != NULL) {
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
delete (NedIdSpecial *) lptr->data;
}
g_list_free(m_specials);
m_specials = NULL;
}
}
void NedIdiotsEditor::initX11() {
char *image_data;
unsigned int i;
bool ok = false;
XGCValues vals;
const char* font_names [] = {
"-misc-*-bold-r-normal--13-*-*-*-*-*-*-*",
"-*-*-bold-r-normal--13-*-*-*-*-*-*-*",
"-*-*-bold-*-normal--13-*-*-*-*-*-*-*",
"-*-*-bold-*-*--13-*-*-*-*-*-*-*",
"-*-*-*-*-*--13-*-*-*-*-*-*-*"};
XFontStruct *font_info;
if (m_dpy != NULL) return;
GTK_WIDGET_UNSET_FLAGS (m_drawing_area, GTK_DOUBLE_BUFFERED);
m_dpy = gdk_x11_drawable_get_xdisplay(m_drawing_area->window);
m_win = gdk_x11_drawable_get_xid(m_drawing_area->window);
m_screen = DefaultScreen(m_dpy);
m_xgc = DefaultGC(m_dpy, m_screen);
for (i = 0; i < sizeof(font_names) / sizeof(const char*); i++) {
font_info = XLoadQueryFont(m_dpy, font_names[i]);
if (font_info) {
ok = true;
break;
}
}
if (ok) {
XSetFont(m_dpy, m_xgc, font_info->fid);
}
else {
fprintf(stderr, "XLoadQueryFont: failed loading font '%s'\n", font_names[(sizeof(font_names) / sizeof(const char*)) - 1]);
}
m_x_border_gc = XCreateGC(m_dpy, m_win, 0, &vals);
if ((image_data = (char *) g_try_malloc(4 * m_drawing_area->allocation.width * m_drawing_area->allocation.height)) == NULL) {
NedResource::Abort("NedIdiotsEditor::handle_map_event");
}
m_back_image = XCreatePixmap(m_dpy, m_win, m_drawing_area->allocation.width, m_drawing_area->allocation.height,
DefaultDepth(m_dpy, m_screen));
}
gboolean NedIdiotsEditor::handle_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data) {
if (event->button != 1) return FALSE;
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
double visible_start_pos, visible_end_pos;
double xleft = gtk_adjustment_get_value(id_editor->m_hadjust);
double ytop = gtk_adjustment_get_value(id_editor->m_vadjust);
int width = id_editor->m_drawing_area->allocation.width;
int height = id_editor->m_drawing_area->allocation.height;
visible_start_pos = xleft;
visible_end_pos = xleft + width;
id_editor->m_mouse_x = event->x;
id_editor->m_mouse_y = event->y;
NedIdiotsInstrument *inst = (NedIdiotsInstrument *) g_list_first(id_editor->m_instruments)->data;
inst->handle_button_press(event, xleft, ytop, visible_start_pos, visible_end_pos);
return FALSE;
}
gboolean NedIdiotsEditor::handle_motion (GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
if ((event->state & GDK_BUTTON1_MASK) == 0) return FALSE;
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
if (id_editor->motion_mode == MOTION_MODE_NONE) return FALSE;
NedIdiotsInstrument *inst = (NedIdiotsInstrument *) g_list_first(id_editor->m_instruments)->data;
id_editor->m_off_x = event->x - id_editor->m_mouse_x;
id_editor->m_off_y = event->y - id_editor->m_mouse_y;
id_editor->repaint();
return FALSE;
}
gboolean NedIdiotsEditor::handle_button_release (GtkWidget *widget, GdkEventButton *event, gpointer data)
{
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
double xleft = gtk_adjustment_get_value(id_editor->m_hadjust);
double ytop = gtk_adjustment_get_value(id_editor->m_vadjust);
double zoom_value = id_editor->getZoomValue();
gdk_window_set_cursor(GDK_WINDOW(id_editor->m_drawing_area->window), id_editor->m_pointer);
NedIdiotsInstrument *inst = (NedIdiotsInstrument *) g_list_first(id_editor->m_instruments)->data;
inst->recomputeNotes(zoom_value, xleft, ytop);
id_editor->motion_mode = MOTION_MODE_NONE;
id_editor->m_off_x = id_editor->m_off_y = 0.0;
id_editor->repaint();
}
void NedIdiotsInstrument::recomputeNotes(double zoom_value, double xleft, double ytop) {
if (!m_selected_note) return;
GList *lptr;
NedIdNote *note;
unsigned int f, snap, xpitch;
double xstart, xend, ypos;
unsigned int newstart, newstop;
int newpitch;
NedChangeIdNoteCommand *nidchange;
NedIdCommandList *nidchange_cl;
for (lptr = g_list_first(m_notes[0]); lptr; lptr = g_list_next(lptr)) {
note = (NedIdNote *) lptr->data;
if (note != m_selected_note) continue;
switch(m_id_edit->motion_mode) {
case MOTION_MODE_MOVE:
ypos = (116 - (note->m_pitch - 4)) * SEP_LINE_DIST + SEP_LINE_BORDER - ytop - SPEC_TRACKS_HEIGHT;
newpitch = POS_TO_PITCH(ypos + m_id_edit->getOffY());
xstart = PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + m_id_edit->getOffX();
xend = PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + m_id_edit->getOffX() + (note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value;
newstart = (xstart - PIANO_PART_WIDTH + xleft) * FACTOR / zoom_value;
newstop = (xend - PIANO_PART_WIDTH + xleft) * FACTOR / zoom_value;
snap = WHOLE_NOTE / m_id_edit->getMinDenom();
f = (newstart + snap / 2) / snap;
newstart = snap * f;
f = (newstop + snap / 2) / snap;
newstop = snap * f;
nidchange = new NedChangeIdNoteCommand(note, newstart, newstop, newpitch);
nidchange_cl = new NedIdCommandList(m_id_edit);
nidchange_cl->addCommand(nidchange);
nidchange->execute();
m_id_edit->getCommandHistory()->addCommandList(nidchange_cl);
m_selected_note = NULL;
return;
case MOTION_NODE_LEFT:
xstart = PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + m_id_edit->getOffX();
newstart = (xstart - PIANO_PART_WIDTH + xleft) * FACTOR / zoom_value;
snap = WHOLE_NOTE / m_id_edit->getMinDenom();
f = (newstart + snap / 2) / snap;
newstart = snap * f;
nidchange = new NedChangeIdNoteCommand(note, newstart, note->m_midi_stop, note->m_pitch);
nidchange_cl = new NedIdCommandList(m_id_edit);
nidchange_cl->addCommand(nidchange);
nidchange->execute();
m_id_edit->getCommandHistory()->addCommandList(nidchange_cl);
m_selected_note = NULL;
return;
case MOTION_NODE_RIGHT:
xend = PIANO_PART_WIDTH + note->m_midi_start / FACTOR * zoom_value - xleft + m_id_edit->getOffX() + (note->m_midi_stop - note->m_midi_start) / FACTOR * zoom_value;
newstop = (xend - PIANO_PART_WIDTH + xleft) * FACTOR / zoom_value;
snap = WHOLE_NOTE / m_id_edit->getMinDenom();
f = (newstop + snap / 2) / snap;
newstop = snap * f;
m_selected_note = NULL;
nidchange = new NedChangeIdNoteCommand(note, note->m_midi_start, newstop, note->m_pitch);
nidchange_cl = new NedIdCommandList(m_id_edit);
nidchange_cl->addCommand(nidchange);
nidchange->execute();
m_id_edit->getCommandHistory()->addCommandList(nidchange_cl);
return;
default: return;
}
}
}
void NedIdiotsEditor::close_i_edit(GtkWidget *widget, void *data) {
/* GList *lptr; */
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
/*
for (i = 0, lptr = g_list_first(id_editor->m_instruments); lptr; lptr = g_list_next(lptr), i++) {
((NedIdiotsInstrument *) lptr->data)->convertToNotes(id_editor, i, id_editor->m_last_time);
}
gtk_widget_destroy(id_editor->m_main_window);
*/
delete id_editor;
}
void NedIdiotsEditor::addTimeSigChange(unsigned long long time, int numerator, int denominator) {
NedIdTimesigChange *time_sig_change;
bool deleted;
time_sig_change = new NedIdTimesigChange(time, 0, numerator, denominator);
m_specials = g_list_insert_sorted(m_specials, time_sig_change, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
do {
correct_times_of_specials();
deleted = delete_double_specials();
}
while (deleted);
}
void NedIdiotsEditor::addTempoChange(unsigned long long time, int tempo) {
NedIdTempoChange *tempo_change;
bool deleted;
tempo_change = new NedIdTempoChange(time, 0, tempo);
m_specials = g_list_insert_sorted(m_specials, tempo_change, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
do {
deleted = delete_double_specials();
}
while (deleted);
}
bool NedIdiotsEditor::newTempoNeeded(unsigned long long current_time, int *newtempo, int current_tempo, unsigned long long *last_tempo_test) {
GList *lptr;
int tempo = -1;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_time <= *last_tempo_test) continue;
if (((NedIdSpecial *) lptr->data)->m_time > current_time) break;
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TEMPO_CHANGE) continue;
if (((NedIdTempoChange *) lptr->data)->m_used) continue;
tempo = ((NedIdTempoChange *) lptr->data)->m_tempo;
((NedIdTempoChange *) lptr->data)->m_used = true;
}
if (tempo >= 0) {
if (tempo == current_tempo) return false;
*newtempo = tempo;
*last_tempo_test = current_time;
return true;
}
return false;
}
bool NedIdiotsEditor::newKeyNeeded(unsigned long long current_time, int *newkey, unsigned long long *last_key_test) {
GList *lptr;
int key = -100;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_time <= *last_key_test) continue;
if (((NedIdSpecial *) lptr->data)->m_time > current_time) break;
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_KEYSIG_CHANGE) continue;
key = ((NedIdKeysigChange *) lptr->data)->m_key;
}
if (key > -100) {
*newkey = key;
*last_key_test = current_time;
return true;
}
return false;
}
void NedIdiotsEditor::correct_times_of_specials() {
unsigned long long last_measure_change_time = 0;
unsigned long long time;
unsigned long current_measure_length = WHOLE_NOTE;
double measure_dist_d;
unsigned int measure_dist;
GList *lptr;
bool time_changed;
m_specials = g_list_sort(m_specials, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
do {
time_changed = false;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (last_measure_change_time > ((NedIdSpecial *)lptr->data)->m_time) {
//time_changed = true;
continue;
}
measure_dist_d = (double)(((NedIdSpecial *)lptr->data)->m_time - last_measure_change_time) / (double) current_measure_length;
measure_dist = (unsigned int) measure_dist_d;
time = last_measure_change_time + (unsigned long long) measure_dist * (unsigned long long) current_measure_length;
if (time != ((NedIdSpecial *)lptr->data)->m_time) {
time_changed = true;
((NedIdSpecial *)lptr->data)->m_time = time;
}
//((NedIdSpecial *)lptr->data)->m_time = time;
//((NedIdSpecial *)lptr->data)->m_measure_number = last_measure_change_number + measure_dist;
if (((NedIdSpecial *)lptr->data)->m_type == ID_SPEC_TIME_SIG_CHANGE) {
current_measure_length = ((NedIdTimesigChange *)lptr->data)->m_numerator * WHOLE_NOTE / ((NedIdTimesigChange *)lptr->data)->m_denominator;
last_measure_change_time = ((NedIdSpecial *)lptr->data)->m_time;
}
}
if (time_changed) {
m_specials = g_list_sort(m_specials, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
}
}
while (time_changed);
}
bool NedIdiotsEditor::delete_double_specials() {
int type = ID_SPEC_TIME_SIG_CHANGE;
GList *lptr, *lptr2;
bool del;
bool deleted = false;
NedIdSpecial *spec;
unsigned long long time;
for (type = ID_SPEC_TIME_SIG_CHANGE; type <= ID_SPEC_TEMPO_CHANGE; type++) {
for(lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *)lptr->data)->m_type != type) continue;
time = ((NedIdSpecial *)lptr->data)->m_time;
del= false;
for (lptr2 = g_list_first(m_specials); lptr2; lptr2 = g_list_next(lptr2)) {
if (lptr2 == lptr) continue;
if (((NedIdSpecial *)lptr2->data)->m_type != type) continue;
if (((NedIdSpecial *)lptr2->data)->m_time == time) {
del = true;
deleted = true;
spec = (NedIdSpecial *) lptr2->data;
m_specials = g_list_delete_link(m_specials, lptr2);
switch (spec->m_type) {
case ID_SPEC_TIME_SIG_CHANGE: delete (NedIdTimesigChange *) spec; break;
case ID_SPEC_TEMPO_CHANGE: delete (NedIdTempoChange *) spec; break;
default: NedResource::Abort("delete_double_specials(1)"); break;
}
lptr2 = g_list_first(m_specials);
}
}
if (del) {
if ((lptr = g_list_find(m_specials, lptr->data)) == NULL) {
NedResource::Abort("delete_double_specials(2)");
}
}
}
}
return deleted;
}
void NedIdiotsEditor::thin_out_temposigs() {
GList *lptr;
GList *del_list_ptr = NULL, *del_list_specials = NULL;
int last_tempo = -1, tempo_dist, proz_dist;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *)lptr->data)->m_type != ID_SPEC_TEMPO_CHANGE) continue;
tempo_dist = ((NedIdTempoChange *) lptr->data)->m_tempo - last_tempo;
if (tempo_dist < 0) tempo_dist = -tempo_dist;
proz_dist = (int) ((double) (tempo_dist * 100) / /*127.0*/ (double) (last_tempo + 1));
if (last_tempo > 0 && proz_dist < m_tempo_change_density) {
del_list_ptr = g_list_append(del_list_ptr, lptr);
del_list_specials = g_list_append(del_list_specials, lptr->data);
}
else {
last_tempo = ((NedIdTempoChange *) lptr->data)->m_tempo;
}
}
for (lptr = g_list_first(del_list_ptr); lptr; lptr = g_list_next(lptr)) {
m_specials = g_list_delete_link(m_specials, (GList *) lptr->data);
}
for (lptr = g_list_first(del_list_specials); lptr; lptr = g_list_next(lptr)) {
delete (NedIdTempoChange *) lptr->data;
}
g_list_free(del_list_ptr);
g_list_free(del_list_specials);
}
int NedIdiotsEditor::determine_key(unsigned long long time, int channel) {
GList *lptr;
if (channel == 9) return 0;
for (lptr = g_list_last(m_specials); lptr; lptr = g_list_previous(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_KEYSIG_CHANGE) continue;
if (((NedIdSpecial *) lptr->data)->m_time <= time) return ((NedIdKeysigChange *) lptr->data)->m_key;
}
return 0;
}
void NedIdiotsEditor::getNumDenom(unsigned long long time, unsigned int *num, unsigned int *denom) {
GList *lptr;
*num = *denom = 4;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *)lptr->data)->m_time > time) break;
if (((NedIdSpecial *)lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
*num = ((NedIdTimesigChange *)lptr->data)->m_numerator;
*denom = ((NedIdTimesigChange *)lptr->data)->m_denominator;
}
}
char *NedIdiotsInstrument::getInstrumentName() {
static char inst_name[128];
if (m_inst_name[0] != '\0') return m_inst_name;
sprintf(inst_name, "Inst %d", m_inst_number + 1);
return inst_name;
}
void NedIdiotsEditor::addNote(int pitch, int volume, unsigned long long start, int midi_nr, int chan) {
GList *lptr;
NedIdiotsInstrument *inst = NULL;
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
if (((NedIdiotsInstrument *) lptr->data)->getMidiNr() == -2) {
inst = (NedIdiotsInstrument *) lptr->data;
inst->setMidiNr(midi_nr);
inst->setOrigChannel(chan);
inst->setChannel(chan);
break;
}
if (m_sort_according_instrument) {
if (((NedIdiotsInstrument *) lptr->data)->getMidiNr() == midi_nr) {
inst = (NedIdiotsInstrument *) lptr->data;
inst->setOrigChannel(chan);
break;
}
}
else {
if (((NedIdiotsInstrument *) lptr->data)->getOrigChannel() == chan) {
inst = (NedIdiotsInstrument *) lptr->data;
break;
}
}
}
if (inst == NULL) {
if (midi_nr == -1) {
inst = new NedIdiotsInstrument(this, 9, chan, midi_nr, m_volume_change_density);
}
else {
while (++m_channel_nr == 9);
inst = new NedIdiotsInstrument(this, m_channel_nr, chan, midi_nr, m_volume_change_density);
}
m_instruments = g_list_append(m_instruments, inst);
}
inst->addNote(pitch, volume, start, midi_nr);
m_last_inserted = inst;
if (m_pending_inst_name[0] != '\0') {
inst->setInstrumentName(m_pending_inst_name);
m_pending_inst_name[0] = '\0';
}
}
void NedIdiotsEditor::addKeySig(unsigned long long time, int measure_number, int key) {
NedIdKeysigChange* kc = new NedIdKeysigChange(time, measure_number, key);
m_specials = g_list_insert_sorted(m_specials, kc, (gint (*)(const void*, const void*)) NedIdSpecial::compare_specials);
}
void NedIdiotsEditor::closeNote(int pitch, unsigned long long end_time, int midi_nr, int chan) {
GList *lptr;
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
if (m_sort_according_instrument) {
if (((NedIdiotsInstrument *) lptr->data)->getMidiNr() != midi_nr) continue;
}
else {
if (((NedIdiotsInstrument *) lptr->data)->getOrigChannel() != chan) continue;
}
((NedIdiotsInstrument *) lptr->data)->closeNote(pitch, end_time, midi_nr);
return;
}
fprintf(stderr, "cannot close note(1), midi_nr = %d\n", midi_nr); fflush(stderr);
}
gboolean NedIdiotsEditor::handle_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) {
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
#ifdef ORIORI
if (id_editor->m_X11version) {
#endif
id_editor->draw_new();
#ifdef ORIORI
}
else {
id_editor->draw();
}
#endif
return FALSE;
}
void NedIdiotsEditor::repaint() {
if (!m_X11version) return;
gdk_window_invalidate_rect (m_main_window->window, NULL, FALSE);
gdk_window_invalidate_rect (m_drawing_area->window, NULL, FALSE);
}
void NedIdiotsEditor::handle_scroll(GtkAdjustment *adjustment, gpointer data) {
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
if (!id_editor->m_X11version) return;
id_editor->repaint();
}
void NedIdiotsEditor::setHadjust() {
if (!m_X11version) return;
m_hadjust->upper = m_paper_len * m_zoom_value;
m_hadjust->page_size = m_drawing_area->allocation.width - PIANO_PART_WIDTH;
m_hadjust->page_increment = (m_drawing_area->allocation.width - PIANO_PART_WIDTH) / STEP_DIVISION;
}
void NedIdiotsEditor::setVadjust() {
if (!m_X11version) return;
m_vadjust->upper = ID_HEIGHT - SPEC_TRACKS_HEIGHT;
m_vadjust->page_size = m_drawing_area->allocation.height;
m_vadjust->page_increment = m_drawing_area->allocation.height / STEP_DIVISION;
}
void NedIdiotsEditor::setLastTime(unsigned long long last_time) {
GList *lptr;
GtkWidget *instr_bu;
int inst_num = 0;
m_paper_len = last_time / FACTOR;
m_last_time = last_time;
//gtk_widget_set_size_request(m_drawing_area, (int) (m_paper_len * m_zoom_value) , (int) ID_HEIGHT);
setHadjust();
/*
printf("A:up = %f (l = %f, zv = %f), ps = %f, pi = %f\n", m_hadjust->upper,
m_paper_len, m_zoom_value,
m_hadjust->page_size, m_hadjust->page_increment);
*/
lptr = g_list_first(m_instruments);
((NedIdiotsInstrument *) lptr->data)->setInstNumber(inst_num);
if (m_X11version) {
gtk_button_set_label(GTK_BUTTON(m_instr_bu), ((NedIdiotsInstrument *) lptr->data)->getInstrumentName());
}
for (inst_num++,lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr), inst_num++) {
((NedIdiotsInstrument *) lptr->data)->setInstNumber(inst_num);
if (m_X11version) {
instr_bu = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_instr_bu), ((NedIdiotsInstrument *) lptr->data)->getInstrumentName());
g_signal_connect (GTK_BUTTON(instr_bu), "pressed", G_CALLBACK (select_instrument), (void *) this);
gtk_toolbar_append_widget(GTK_TOOLBAR(m_instrument_toolbar), instr_bu , NULL, NULL);
}
}
if (m_X11version) {
gtk_widget_hide (m_main_window);
gtk_widget_show_all (m_main_window);
}
}
#ifdef ORIORI
void NedIdiotsEditor::draw () {
int i;
double x, y;
int width, height;
cairo_t *cr;
unsigned int measure_width;
unsigned long long current_time, time_dist;
double d, measure_dist_d;
int measure_dist;
double start_pos_measure, end_pos_measure;
double visible_start_pos, visible_end_pos;
unsigned int current_dist, nominator_dist;
int current_color;
unsigned int curr_dnom;
GList *lptr;
unsigned int numerator = 4;
unsigned int denominator = 4;
x = gtk_adjustment_get_value(m_hadjust);
y = gtk_adjustment_get_value(m_vadjust);
width = m_drawing_area->allocation.width;
height = m_drawing_area->allocation.height;
cr = gdk_cairo_create (m_drawing_area->window);
//cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
#define BAR_COLOR 0.0, 0.0, 0.0
#define NOMINATOR_COLOR 0.0, 0.0, 0.8
#define HALF_COLOR 0.0, 0.1, 0.6
#define QUARTER_COLOR 0.0, 0.2, 0.5
#define EIGHTS_COLOR 0.5, 0.3, 0.4
#define COLOR_16 0.0, 0.4, 0.3
#define COLOR32 0.5, 0.5, 0.2
#define COLOR64 0.9, 0.6, 0.1
#ifdef ORIORI
static double color_array[8][3] = {
{BAR_COLOR},
{NOMINATOR_COLOR},
{HALF_COLOR},
{QUARTER_COLOR},
{EIGHTS_COLOR},
{COLOR_16},
{COLOR32},
{COLOR64}};
#endif
cairo_new_path(cr);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, PIANO_PART_WIDTH, SPEC_TRACKS_HEIGHT, width - PIANO_PART_WIDTH, height - SPEC_TRACKS_HEIGHT);
cairo_fill(cr);
cairo_set_line_width(cr, SEP_LINE_THICK);
for (i = 4; i < 4 + 117; i++) {
cairo_new_path(cr);
if (strlen(pitch_tab[i-4]) > 1) {
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
cairo_rectangle (cr, PIANO_PART_WIDTH, (i - 4) * SEP_LINE_DIST - y - SPEC_TRACKS_HEIGHT, width - PIANO_PART_WIDTH, SEP_LINE_DIST);
cairo_fill(cr);
}
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
if (y < (i - 3) * SEP_LINE_DIST && y + height > (i - 4) * SEP_LINE_DIST) {
cairo_move_to(cr, PIANO_PART_WIDTH, (i - 4) * SEP_LINE_DIST - y - SPEC_TRACKS_HEIGHT);
cairo_line_to(cr, width, (i - 4) * SEP_LINE_DIST - y - SPEC_TRACKS_HEIGHT);
}
cairo_stroke(cr);
}
visible_start_pos = x;
/*
current_time = 0;
getNumDenom(current_time, &numerator, &denominator);
*/
measure_width = numerator * WHOLE_NOTE / FACTOR / denominator;
start_pos_measure = 0;
visible_end_pos = x + width;
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
/*
while (end_pos_measure < visible_start_pos) {
current_time += numerator * WHOLE_NOTE / denominator;
getNumDenom(current_time, &numerator, &denominator);
start_pos_measure = end_pos_measure;
measure_width = numerator * WHOLE_NOTE / FACTOR / denominator;
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
}
*/
current_time = (unsigned long long) ((visible_start_pos * (double) FACTOR) / m_zoom_value);
for (lptr = g_list_last(m_specials); lptr; lptr = g_list_previous(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
measure_width = ((NedIdTimesigChange *) lptr->data)->m_numerator * WHOLE_NOTE / FACTOR / ((NedIdTimesigChange *) lptr->data)->m_denominator;
if (((NedIdSpecial *) lptr->data)->m_time + measure_width * FACTOR <= current_time) break;
}
if (lptr != NULL) {
time_dist = current_time - (((NedIdSpecial *) lptr->data)->m_time + measure_width * FACTOR);
numerator = ((NedIdTimesigChange *) lptr->data)->m_numerator;
denominator = ((NedIdTimesigChange *) lptr->data)->m_denominator;
current_time = ((NedIdSpecial *) lptr->data)->m_time;
measure_dist_d = (double) time_dist / (double) (measure_width * FACTOR);
measure_dist = (int) measure_dist_d;
unsigned long long add = (unsigned long long) measure_dist * (unsigned long long) measure_width * (unsigned long long) FACTOR;
current_time += add;
//printf("current_time = %llu(%llu), add = %llu(%llu)\n", current_time, current_time / NOTE_8, add, add / NOTE_8); fflush(stdout);
//current_time += measure_dist * measure_width * FACTOR;
start_pos_measure = current_time / FACTOR * m_zoom_value;
}
else {
current_time = 0;
measure_width = WHOLE_NOTE / FACTOR;
start_pos_measure = 0;
numerator = denominator = 4;
}
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
while (start_pos_measure < visible_end_pos) {
nominator_dist = measure_width / numerator;
current_dist = nominator_dist / (64 / denominator);
cairo_set_line_width(cr, NOTE_LINE_THICK);
curr_dnom = 64;
current_color = 6;
cairo_stroke(cr);
while (curr_dnom > denominator) {
if (current_dist * m_zoom_value > MIN_ZOOM_DIST) {
cairo_new_path(cr);
cairo_set_source_rgb (cr, color_array[current_color][0], color_array[current_color][1],color_array[current_color][2]);
i = 0;
do {
d = PIANO_PART_WIDTH + start_pos_measure + ((double) i * (double) current_dist) * m_zoom_value - x;
cairo_move_to(cr, d, SPEC_TRACKS_HEIGHT);
cairo_line_to(cr, d, height - SPEC_TRACKS_HEIGHT);
cairo_stroke(cr);
i++;
}
while (d < end_pos_measure + PIANO_PART_WIDTH);
cairo_stroke(cr);
}
current_color--;
curr_dnom /= 2;
current_dist *= 2;
}
current_color = 1;
cairo_new_path(cr);
cairo_set_line_width(cr, NOTE_LINE_THICK);
cairo_set_source_rgb (cr, color_array[current_color][0], color_array[current_color][1],color_array[current_color][2]);
i = 0;
do {
d = PIANO_PART_WIDTH + start_pos_measure + ((double) i * (double) nominator_dist) * m_zoom_value - x;
cairo_move_to(cr, d, SPEC_TRACKS_HEIGHT);
cairo_line_to(cr, d, height - SPEC_TRACKS_HEIGHT);
cairo_stroke(cr);
i++;
}
while (d < end_pos_measure + PIANO_PART_WIDTH);
current_color = 0;
cairo_new_path(cr);
cairo_set_line_width(cr, BAR_LINE_THICK);
cairo_set_source_rgb (cr, color_array[current_color][0], color_array[current_color][1],color_array[current_color][2]);
d = PIANO_PART_WIDTH + start_pos_measure - x;
cairo_move_to(cr, d, SPEC_TRACKS_HEIGHT);
cairo_line_to(cr, d, height - SPEC_TRACKS_HEIGHT);
cairo_stroke(cr);
current_time += numerator * WHOLE_NOTE / denominator;
getNumDenom(current_time, &numerator, &denominator);
start_pos_measure = end_pos_measure;
measure_width = numerator * WHOLE_NOTE / FACTOR / denominator;
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
}
lptr = g_list_nth(m_instruments, m_current_instrument_number);
((NedIdiotsInstrument *) lptr->data)->draw(cr, m_zoom_value, x, y, visible_start_pos, visible_end_pos);
draw_specials(cr, m_zoom_value, x, y, width, visible_start_pos, visible_end_pos);
((NedIdiotsInstrument *) lptr->data)->draw_specials(cr, m_zoom_value, x, y, visible_start_pos, visible_end_pos);
draw_piano(cr, y, height);
cairo_destroy (cr);
}
#endif
void NedIdiotsEditor::draw_new () {
int i;
double xleft, ytop;
int width, height;
unsigned int measure_width;
unsigned long long current_time, time_dist;
double d, measure_dist_d;
int measure_dist;
double start_pos_measure, end_pos_measure;
double visible_start_pos, visible_end_pos;
unsigned int current_dist, nominator_dist;
int current_color;
unsigned int curr_dnom;
GList *lptr;
unsigned int numerator = 4;
unsigned int denominator = 4;
#define MIN_ZOOM_DIST 8.0
if (m_dpy == NULL) initX11();
xleft = gtk_adjustment_get_value(m_hadjust);
ytop = gtk_adjustment_get_value(m_vadjust);
width = m_drawing_area->allocation.width;
height = m_drawing_area->allocation.height;
#define BAR_COLOR 0, 0, 0
#define NOMINATOR_COLOR 0, 0, 204
#define HALF_COLOR 0.0, 26, 153
#define QUARTER_COLOR 0, 51, 127
#define EIGHTS_COLOR 127, 77, 102
#define COLOR_16 0, 102, 77
#define COLOR32 127, 127, 51
#define COLOR64 230, 153,25
static unsigned int color_array[8][3] = {
{BAR_COLOR},
{NOMINATOR_COLOR},
{HALF_COLOR},
{QUARTER_COLOR},
{EIGHTS_COLOR},
{COLOR_16},
{COLOR32},
{COLOR64}};
XSetForeground(m_dpy, m_xgc, 0xeeeeee);
XFillRectangle(m_dpy, m_back_image, m_xgc, 0, 0, width, height);
XSetForeground(m_dpy, m_xgc, 0x0);
XSetLineAttributes(m_dpy, m_xgc, SEP_LINE_THICK, LineSolid, CapRound, JoinMiter);
for (i = 4; i < 4 + 117; i++) {
if (strlen(pitch_tab[i-4]) > 1) {
XSetForeground(m_dpy, m_xgc, 0x999999);
XFillRectangle(m_dpy, m_back_image, m_xgc, PIANO_PART_WIDTH, (i - 4) * SEP_LINE_DIST - ytop - SPEC_TRACKS_HEIGHT, width - PIANO_PART_WIDTH, SEP_LINE_DIST);
}
XSetForeground(m_dpy, m_xgc, 0x0);
if (ytop < (i - 3) * SEP_LINE_DIST && ytop + height > (i - 4) * SEP_LINE_DIST) {
XDrawLine(m_dpy, m_back_image, m_xgc, PIANO_PART_WIDTH, (i - 4) * SEP_LINE_DIST - ytop - SPEC_TRACKS_HEIGHT,
width, (i - 4) * SEP_LINE_DIST - ytop - SPEC_TRACKS_HEIGHT);
}
}
visible_start_pos = xleft;
/*
current_time = 0;
getNumDenom(current_time, &numerator, &denominator);
*/
measure_width = numerator * WHOLE_NOTE / FACTOR / denominator;
start_pos_measure = 0;
visible_end_pos = xleft + width;
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
/*
while (end_pos_measure < visible_start_pos) {
current_time += numerator * WHOLE_NOTE / denominator;
getNumDenom(current_time, &numerator, &denominator);
start_pos_measure = end_pos_measure;
measure_width = numerator * WHOLE_NOTE / FACTOR / denominator;
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
}
*/
current_time = (unsigned long long) ((visible_start_pos * (double) FACTOR) / m_zoom_value);
for (lptr = g_list_last(m_specials); lptr; lptr = g_list_previous(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
measure_width = ((NedIdTimesigChange *) lptr->data)->m_numerator * WHOLE_NOTE / FACTOR / ((NedIdTimesigChange *) lptr->data)->m_denominator;
if (((NedIdSpecial *) lptr->data)->m_time + measure_width * FACTOR <= current_time) break;
}
if (lptr != NULL) {
time_dist = current_time - (((NedIdSpecial *) lptr->data)->m_time + measure_width * FACTOR);
numerator = ((NedIdTimesigChange *) lptr->data)->m_numerator;
denominator = ((NedIdTimesigChange *) lptr->data)->m_denominator;
current_time = ((NedIdSpecial *) lptr->data)->m_time;
measure_dist_d = (double) time_dist / (double) (measure_width * FACTOR);
measure_dist = (int) measure_dist_d;
unsigned long long add = (unsigned long long) measure_dist * (unsigned long long) measure_width * (unsigned long long) FACTOR;
current_time += add;
//printf("current_time = %llu(%llu), add = %llu(%llu)\n", current_time, current_time / NOTE_8, add, add / NOTE_8); fflush(stdout);
//current_time += measure_dist * measure_width * FACTOR;
start_pos_measure = current_time / FACTOR * m_zoom_value;
}
else {
current_time = 0;
measure_width = WHOLE_NOTE / FACTOR;
start_pos_measure = 0;
numerator = denominator = 4;
}
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
m_min_denom = 1;
while (start_pos_measure < visible_end_pos) {
nominator_dist = measure_width / numerator;
current_dist = nominator_dist / (64 / denominator);
XSetLineAttributes(m_dpy, m_xgc, SEP_LINE_THICK, LineSolid, CapRound, JoinMiter);
curr_dnom = 64;
current_color = 6;
while (curr_dnom > denominator) {
if (current_dist * m_zoom_value > MIN_VERTICAL_LINES_DIST) {
if (m_min_denom == 1) {
m_min_denom = curr_dnom;
}
XSetForeground(m_dpy, m_xgc, (color_array[current_color][0] << 16 ) | (color_array[current_color][1] << 8) | color_array[current_color][2]);
i = 0;
do {
d = PIANO_PART_WIDTH + start_pos_measure + ((double) i * (double) current_dist) * m_zoom_value - xleft;
XDrawLine(m_dpy, m_back_image, m_xgc, d, SPEC_TRACKS_HEIGHT, d, height - SPEC_TRACKS_HEIGHT);
i++;
}
while (d < end_pos_measure + PIANO_PART_WIDTH);
}
current_color--;
curr_dnom /= 2;
current_dist *= 2;
}
current_color = 1;
XSetLineAttributes(m_dpy, m_xgc, NOTE_LINE_THICK, LineSolid, CapRound, JoinMiter);
XSetForeground(m_dpy, m_xgc, (color_array[current_color][0] << 16 ) | (color_array[current_color][1] << 8) | color_array[current_color][2]);
i = 0;
do {
d = PIANO_PART_WIDTH + start_pos_measure + ((double) i * (double) nominator_dist) * m_zoom_value - xleft;
XDrawLine(m_dpy, m_back_image, m_xgc, d, SPEC_TRACKS_HEIGHT, d, height - SPEC_TRACKS_HEIGHT);
i++;
}
while (d < end_pos_measure + PIANO_PART_WIDTH);
current_color = 0;
XSetLineAttributes(m_dpy, m_xgc, BAR_LINE_THICK, LineSolid, CapRound, JoinMiter);
XSetForeground(m_dpy, m_xgc, (color_array[current_color][0] << 16 ) | (color_array[current_color][1] << 8) | color_array[current_color][2]);
d = PIANO_PART_WIDTH + start_pos_measure - xleft;
XDrawLine(m_dpy, m_back_image, m_xgc, d, SPEC_TRACKS_HEIGHT, d, height - SPEC_TRACKS_HEIGHT);
current_time += numerator * WHOLE_NOTE / denominator;
getNumDenom(current_time, &numerator, &denominator);
start_pos_measure = end_pos_measure;
measure_width = numerator * WHOLE_NOTE / FACTOR / denominator;
end_pos_measure = start_pos_measure + m_zoom_value * measure_width;
}
lptr = g_list_nth(m_instruments, m_current_instrument_number);
((NedIdiotsInstrument *) lptr->data)->draw(m_dpy, m_back_image, m_xgc, m_x_border_gc, m_zoom_value, xleft, ytop, visible_start_pos, visible_end_pos);
XSetForeground(m_dpy, m_xgc, 0xffffff);
XFillRectangle(m_dpy, m_back_image, m_xgc, 0, 0, PIANO_PART_WIDTH, height);
XSetForeground(m_dpy, m_xgc, 0x0);
for (i = 4; i < 4 + 117; i++) {
/*
if (strlen(pitch_tab[i-4]) > 1) {
XSetForeground(m_dpy, m_xgc, 0x999999);
XFillRectangle(m_dpy, m_back_image, m_xgc, PIANO_PART_WIDTH, (i - 4) * SEP_LINE_DIST - ytop - SPEC_TRACKS_HEIGHT, width - PIANO_PART_WIDTH, SEP_LINE_DIST);
}
*/
if (ytop < (i - 3) * SEP_LINE_DIST && ytop + height > (i - 4) * SEP_LINE_DIST) {
XDrawString(m_dpy, m_back_image, m_xgc, TUNE_NAME_X_START, (i - 4) * SEP_LINE_DIST + SEP_LINE_DIST / 2 - ytop - SPEC_TRACKS_HEIGHT,
"ABC", strlen("ABC"));
}
}
XSetForeground(m_dpy, m_xgc, 0xffffff);
XFillRectangle(m_dpy, m_back_image, m_xgc, 0, 0, width, SPEC_TRACKS_HEIGHT);
XFillRectangle(m_dpy, m_back_image, m_xgc, 0, height - SPEC_TRACKS_HEIGHT, width, height);
#ifdef XXX
draw_specials(cr, m_zoom_value, xleft, ytop, width, visible_start_pos, visible_end_pos);
((NedIdiotsInstrument *) lptr->data)->draw_specials(cr, m_zoom_value, xleft, ytop, visible_start_pos, visible_end_pos);
draw_piano(cr, ytop, height);
#endif
XCopyArea(m_dpy, m_back_image, m_win, m_xgc, 0, 0, width, height, 0, 0);
XFlush(m_dpy);
}
void NedIdiotsEditor::do_undo(GtkWidget *widget, void *data) {
//if (NedResource::isPlaying()) return;
//NedResource::m_avoid_immadiate_play = TRUE;
NedIdiotsEditor *id_editor = (NedIdiotsEditor *) data;
//id_editor->m_selected_note = NULL;
id_editor->m_command_history->unexecute();
id_editor->repaint();
//NedResource::m_avoid_immadiate_play = FALSE;
}
void NedIdiotsEditor::do_redo(GtkWidget *widget, void *data) {
//if (NedResource::isPlaying()) return;
//NedResource::m_avoid_immadiate_play = TRUE;
NedIdiotsEditor *id_editor = (NedIdiotsEditor *) data;
//id_editor->m_selected_note = NULL;
id_editor->m_command_history->execute();
id_editor->repaint();
//NedResource::m_avoid_immadiate_play = FALSE;
}
unsigned long long NedIdiotsEditor::getFirstSplitTime(unsigned long long start_time, unsigned long long end_time) {
GList *lptr;
unsigned long long time_dist, current_time;
int numerator, denominator, measure_width, measure_dist;
for (lptr = g_list_last(m_specials); lptr; lptr = g_list_previous(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
if (((NedIdSpecial *) lptr->data)->m_time <= start_time) break;
}
if (lptr != NULL) {
time_dist = start_time - ((NedIdSpecial *) lptr->data)->m_time;
numerator = ((NedIdTimesigChange *) lptr->data)->m_numerator;
denominator = ((NedIdTimesigChange *) lptr->data)->m_denominator;
measure_width = numerator * WHOLE_NOTE / denominator;
current_time = ((NedIdSpecial *) lptr->data)->m_time;
measure_dist = (time_dist / measure_width) + 1;
current_time += (unsigned long long) measure_dist * (unsigned long long) measure_width;
}
else {
time_dist = start_time;
current_time = 0;
measure_width = WHOLE_NOTE;
numerator = denominator = 4;
measure_dist = (time_dist / measure_width) + 1;
current_time += (unsigned long long) measure_dist * (unsigned long long) measure_width;
}
if (current_time > start_time && current_time < end_time) return current_time;
return 0;
}
void NedIdiotsEditor::draw_specials (cairo_t *cr, double zoom_value, double xleft, double ytop, int width, double visible_start_pos, double visible_end_pos) {
GList *lptr;
NedIdSpecial *spec;
char Str[128];
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.9, 0.9, 0.0);
cairo_rectangle (cr, PIANO_PART_WIDTH, 0, width - PIANO_PART_WIDTH, TIME_SIG_TRACK_HEIGHT);
cairo_fill(cr);
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.8, 0.8, 0.4);
cairo_rectangle (cr, PIANO_PART_WIDTH, TIME_SIG_TRACK_HEIGHT, width - PIANO_PART_WIDTH, TEMPO_TRACK_HEIGHT);
cairo_fill(cr);
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.9, 0.9, 0.2);
cairo_rectangle (cr, PIANO_PART_WIDTH, TIME_SIG_TRACK_HEIGHT + SIGN_TRACK_HEIGHT, width - PIANO_PART_WIDTH, SIGN_TRACK_HEIGHT);
cairo_fill(cr);
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.4, 0.9, 0.4);
cairo_rectangle (cr, PIANO_PART_WIDTH, TIME_SIG_TRACK_HEIGHT + SIGN_TRACK_HEIGHT + VOLUME_TRACK_HEIGHT, width - PIANO_PART_WIDTH, VOLUME_TRACK_HEIGHT);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
spec = (NedIdSpecial *) lptr->data;
if (spec->m_time / FACTOR * zoom_value > visible_end_pos) break;
if (spec->m_time / FACTOR * zoom_value < visible_start_pos) continue;
switch (spec->m_type) {
case ID_SPEC_TIME_SIG_CHANGE: sprintf(Str, "%d/%d", ((NedIdTimesigChange *) spec)->m_numerator,
((NedIdTimesigChange *) spec)->m_denominator);
cairo_new_path(cr);
cairo_move_to(cr, PIANO_PART_WIDTH + spec->m_time / FACTOR * zoom_value - xleft, TIME_SIG_TRACK_HEIGHT);
cairo_show_text(cr, Str);
cairo_stroke(cr);
break;
case ID_SPEC_TEMPO_CHANGE: sprintf(Str, "%d", ((NedIdTempoChange *) spec)->m_tempo);
cairo_new_path(cr);
cairo_move_to(cr, PIANO_PART_WIDTH + spec->m_time / FACTOR * zoom_value - xleft, TIME_SIG_TRACK_HEIGHT + TEMPO_TRACK_HEIGHT);
cairo_show_text(cr, Str);
cairo_stroke(cr);
break;
case ID_SPEC_KEYSIG_CHANGE: /* TODO: draw */break;
default: NedResource::Abort("draw_specials");
}
}
}
void NedIdiotsEditor::draw_piano (cairo_t *cr, double ytop, int height) {
int i;
#define T_X_OFFS 2.0
//cr = gdk_cairo_create (m_drawing_area->window);
cairo_set_source_rgb (cr, 1.0, 2.0, 1.0);
cairo_rectangle (cr, 0, 0, PIANO_PART_WIDTH, m_drawing_area->allocation.height);
cairo_fill(cr);
cairo_select_font_face (cr, "SANS", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 8.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
for (i = 4; i < 4 + 117; i++) {
if (ytop < (116 - (i - 4)) * SEP_LINE_DIST && ytop + height > (116 - (i - 5)) * SEP_LINE_DIST) {
if (strlen(pitch_tab[i-4]) > 1) {
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
cairo_rectangle (cr, 0, (116 - (i - 4)) * SEP_LINE_DIST - ytop - TIME_SIG_TRACK_HEIGHT, PIANO_PART_WIDTH, SEP_LINE_DIST);
cairo_fill(cr);
}
}
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
if (ytop < (116 - (i - 4)) * SEP_LINE_DIST && ytop + height > (116 - (i - 5)) * SEP_LINE_DIST) {
cairo_move_to(cr, T_X_OFFS, (116 - (i - 4)) * SEP_LINE_DIST - ytop + SEP_LINE_DIST / 1.2 - TIME_SIG_TRACK_HEIGHT);
cairo_show_text(cr, pitch_tab[i-4]);
}
cairo_stroke(cr);
}
}
void NedIdiotsEditor::zoom_in(GtkWidget *widget, void *data) {
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
id_editor->m_zoom_value *= ID_ZOOM_STEP;
if (id_editor->m_zoom_value > ID_MAX_ZOOM) {
id_editor->m_zoom_value = ID_MAX_ZOOM;
}
id_editor->setHadjust();
id_editor->repaint();
}
void NedIdiotsEditor::zoom_out(GtkWidget *widget, void *data) {
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
id_editor->m_zoom_value /= ID_ZOOM_STEP;
if (id_editor->m_zoom_value < ID_MIN_ZOOM) {
id_editor->m_zoom_value = ID_MIN_ZOOM;
}
id_editor->setHadjust();
id_editor->repaint();
}
void NedIdiotsEditor::size_change_handler(GtkWidget *widget, GtkRequisition *requisition, gpointer data) {
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
if (id_editor->m_dpy == NULL) return;
XFreePixmap(id_editor->m_dpy, id_editor->m_back_image);
id_editor->m_back_image = XCreatePixmap(id_editor->m_dpy, id_editor->m_win,
id_editor->m_drawing_area->allocation.width, id_editor->m_drawing_area->allocation.height,
DefaultDepth(id_editor->m_dpy, id_editor->m_screen));
id_editor->setHadjust();
id_editor->setVadjust();
}
void NedIdiotsEditor::setInstrumentName(char *name) {
name[MAX_INST_NAME - 1] = '\0';
strcpy(m_pending_inst_name, name);
}
int NedIdiotsEditor::getPartCount() {
return g_list_length(m_instruments);
}
char *NedIdiotsEditor::getInstrumentName(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::getInstrumentName");
}
return ((NedIdiotsInstrument *) lptr->data)->getInstrumentName();
}
int NedIdiotsEditor::getNumerator() {
GList *lptr;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_time > 0) break;
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
return ((NedIdTimesigChange *) lptr->data)->m_numerator;
}
return 4;
}
int NedIdiotsEditor::getDenominator() {
GList *lptr;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_time > 0) break;
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
return ((NedIdTimesigChange *) lptr->data)->m_denominator;
}
return 4;
}
void NedIdiotsEditor::computeTimeSigMeasureNumbers(NedMainWindow *main_window) {
unsigned int num = 0;
unsigned long long last_timesig_time = 0;
int dummy;
unsigned int dummy2;
GList *lptr;
unsigned int duration = WHOLE_NOTE;
NedIdTimesigChange *timesig;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TIME_SIG_CHANGE) continue;
timesig = (NedIdTimesigChange *) lptr->data;
num = timesig->m_measure_number = num + (timesig->m_time - last_timesig_time) / duration;
if (timesig->m_time > 0) {
main_window->setSpecialTimesig(num + 1, timesig->m_numerator, timesig->m_denominator, TIME_SYMBOL_NONE, &dummy, &dummy, &dummy2, false);
}
duration = timesig->m_numerator * WHOLE_NOTE / timesig->m_denominator;
last_timesig_time = timesig->m_time;
}
}
void NedIdiotsEditor::trySplitInstruments() {
GList *lptr, *lptr2;
GList *new_instruments;
int pos;
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
new_instruments = ((NedIdiotsInstrument *) lptr->data)->trySplitInstrument(m_force_piano, m_dont_split);
pos = g_list_position(m_instruments, lptr);
for (lptr2 = g_list_first(new_instruments); lptr2; lptr2 = g_list_next(lptr2)) {
m_instruments = g_list_insert(m_instruments, lptr2->data, ++pos);
if ((lptr = g_list_find(m_instruments, lptr2->data)) == NULL) {
NedResource::Abort("NedIdiotsEditor::trySplitInstruments");
}
}
g_list_free(new_instruments);
}
}
void NedIdiotsEditor::computeVolumes() {
GList *lptr;
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
((NedIdiotsInstrument *) lptr->data)->computeVolume();
}
}
void NedIdiotsEditor::snapStartOfNotes() {
GList *lptr;
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
((NedIdiotsInstrument *) lptr->data)->snapStartOfNotes(this);
}
}
void NedIdiotsEditor::recognizeTriplets() {
GList *lptr;
for (lptr = g_list_first(m_instruments); lptr; lptr = g_list_next(lptr)) {
((NedIdiotsInstrument *) lptr->data)->recognizeTriplets(this);
}
}
void NedIdiotsEditor::computeTempo() {
GList *lptr;
GList *del_list_ptr = NULL, *del_list_specs = NULL;
thin_out_temposigs();
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_time > 0) break;
if (((NedIdSpecial *) lptr->data)->m_type != ID_SPEC_TEMPO_CHANGE) continue;
m_tempo_inverse = 60000.0 / (double) ((NedIdTempoChange *) lptr->data)->m_tempo;
del_list_ptr = g_list_append(del_list_ptr, lptr);
del_list_specs = g_list_append(del_list_specs, lptr->data);
}
for (lptr = g_list_first(del_list_ptr); lptr; lptr = g_list_next(lptr)) {
m_specials = g_list_delete_link(m_specials, (GList *) lptr->data);
}
for (lptr = g_list_first(del_list_specs); lptr; lptr = g_list_next(lptr)) {
delete (NedIdTempoChange *) lptr->data;
}
g_list_free(del_list_ptr);
g_list_free(del_list_specs);
}
GList *NedIdiotsEditor::convertToNtEdNotes(int staff_nr, int voice_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::convertToNtEdNotes");
}
return ((NedIdiotsInstrument *) lptr->data)->convertToNtEdNotes(this, /* staff_nr == 0 && */ voice_nr == 0, voice_nr == 0, voice_nr, m_last_time);
}
int NedIdiotsEditor::getClef(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::getClef");
}
return ((NedIdiotsInstrument *) lptr->data)->getClef();
}
int NedIdiotsEditor::getOctaveShift(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::getOctaveShift");
}
return ((NedIdiotsInstrument *) lptr->data)->getOctaveShift();
}
int NedIdiotsEditor::getMidiPgm(int staff_nr) {
GList *lptr;
int midi_pgm;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::getMidiPgm");
}
midi_pgm = ((NedIdiotsInstrument *) lptr->data)->getMidiNr();
if (midi_pgm < 0) {
midi_pgm = 0;
}
return midi_pgm;
}
int NedIdiotsEditor::getChannel(int staff_nr) {
GList *lptr;
int midi_pgm;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::getMidiPgm");
}
midi_pgm = ((NedIdiotsInstrument *) lptr->data)->getMidiNr();
if (midi_pgm < 0) {
return 9;
}
return ((NedIdiotsInstrument *) lptr->data)->getChannel();
}
int NedIdiotsEditor::getVolume(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::getVolume");
}
return ((NedIdiotsInstrument *) lptr->data)->getVolume();
}
int NedIdiotsEditor::getKeySig(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
}
if (((NedIdiotsInstrument *) lptr->data)->getChannel() == 9) return 0;
for (lptr = g_list_first(m_specials); lptr; lptr = g_list_next(lptr)) {
if (((NedIdSpecial *) lptr->data)->m_type == ID_SPEC_KEYSIG_CHANGE) {
if (((NedIdSpecial *) lptr->data)->m_time > 0) return 0;
return ((NedIdKeysigChange *) lptr->data)->m_key;
}
}
return 0;
}
void NedIdiotsEditor::changeChannelAndPgm(int staff_nr, int chan, int pgm) {
GList *lptr;
if ((lptr = g_list_nth(m_instruments, staff_nr)) == NULL) {
NedResource::Abort("NedIdiotsEditor::changeChannelAndPgm");
}
((NedIdiotsInstrument *) lptr->data)->setChannel(chan);
((NedIdiotsInstrument *) lptr->data)->setMidiNr(pgm);
}
void NedIdiotsEditor::select_instrument(GtkButton *button, gpointer data) {
NedIdiotsEditor *id_editor = (NedIdiotsEditor*) data;
GSList *l, *ll;
int i;
l = gtk_radio_button_get_group(GTK_RADIO_BUTTON(id_editor->m_instr_bu));
ll = gtk_radio_button_get_group(GTK_RADIO_BUTTON(id_editor->m_instr_bu));
for (; ll ; ll = g_slist_next(ll)) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ll->data))) {
i = g_slist_position(l, ll);
if (i > 0) {
i = g_slist_length(l) - i;
}
id_editor->m_current_instrument_number = i;
id_editor->repaint();
return;
}
}
}
nted-1.10.18/idiotseditor/idcommandlist.cpp 0000664 0010410 0000764 00000005010 11520267221 015563 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "idcommandlist.h"
#include "command.h"
#include "idiotseditor.h"
NedIdCommandList::NedIdCommandList(NedIdiotsEditor *id_edit):
m_commands(NULL), m_id_edit(id_edit) {}
NedIdCommandList::~NedIdCommandList() {
GList *lptr;
lptr = g_list_first(m_commands);
while (lptr != NULL) {
delete ((NedCommand*) lptr->data);
m_commands = g_list_delete_link(m_commands, lptr);
lptr = g_list_first(m_commands);
}
}
void NedIdCommandList::execute(bool adjust /* = false */) {
GList *lptr;
#ifdef EXECUTE_DEBUG
printf("NedIdCommandList::execute\n");
#endif
for (lptr = g_list_first(m_commands); lptr; lptr = g_list_next(lptr)) {
((NedCommand*) lptr->data)->execute(adjust);
}
m_id_edit->repaint();
#ifdef EXECUTE_DEBUG
printf("NedIdCommandList::execute END\n");
#endif
}
void NedIdCommandList::unexecute(bool adjust /* = false */) {
#ifdef UNEXECUTE_DEBUG
printf("NedIdCommandList::unexecute\n");
#endif
GList *lptr;
for (lptr = g_list_last(m_commands); lptr; lptr = g_list_previous(lptr)) {
((NedCommand*) lptr->data)->unexecute(adjust);
}
m_id_edit->repaint();
#ifdef UNEXECUTE_DEBUG
printf("NedIdCommandList::unexecute END\n");
#endif
}
void NedIdCommandList::addCommand(NedCommand *command) {
m_commands = g_list_append(m_commands, command);
}
int NedIdCommandList::getNumberOfCommands() {
return g_list_length(m_commands);
}
nted-1.10.18/idiotseditor/changeidnotecommand.h 0000664 0010410 0000764 00000003506 11520267221 016400 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef CHANGE_ID_NOTE_COMMAND_H
#define CHANGE_ID_NOTE_COMMAND_H
#include "config.h"
#include "command.h"
class NedIdNote;
class NedChangeIdNoteCommand : public NedCommand {
public:
NedChangeIdNoteCommand(NedIdNote *id_note, unsigned long long new_start, unsigned long long new_stop, int new_pitch);
virtual void execute(bool adjust = false);
virtual void unexecute(bool adjust = false);
private:
NedIdNote *m_id_note;
unsigned long long m_old_midi_start, m_new_midi_start;
unsigned long long m_old_midi_stop, m_new_midi_stop;
int m_old_pitch, m_new_pitch;
bool m_old_valid, m_new_valid;
};
#endif /* CHANGE_ID_NOTE_COMMAND_H */
nted-1.10.18/idiotseditor/Makefile.am 0000775 0010410 0000764 00000002742 11520267221 014300 0000000 0000000 #########################################################################################
# #
# This program is free software; you can redistribute it and#or modify it under the #
# terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this #
# program; (See "COPYING"). If not, If not, see . #
# #
#---------------------------------------------------------------------------------------#
# #
# Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY #
# ja@informatik.tu-chemnitz.de #
# #
# #
#########################################################################################
AM_CPPFLAGS = $(FT2_CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/commands $(CAIRO_CFLAGS) $(GTK_CFLAGS)
noinst_LIBRARIES = libidiotseditor.a
libidiotseditor_a_SOURCES = idiotseditor.cpp idcommandhistory.cpp idcommandlist.cpp changeidnotecommand.cpp
libidiotseditor_a_SOURCES += idiotseditor.h idcommandhistory.h idcommandlist.h changeidnotecommand.h
nted-1.10.18/idiotseditor/idcommandhistory.cpp 0000664 0010410 0000764 00000006247 11520267221 016326 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "idcommandhistory.h"
#include "idcommandlist.h"
#include "idiotseditor.h"
NedIdCommandHistory::NedIdCommandHistory(NedIdiotsEditor *id_edit) :
m_command_lists(NULL), m_current_command_list(NULL), m_id_edit(id_edit) {
}
void NedIdCommandHistory::reset() {
/* TODO: free commdand lists */
m_command_lists = NULL;
m_current_command_list = NULL;
}
void NedIdCommandHistory::execute() {
GList *lptr;
if (m_current_command_list == NULL) {
if (m_command_lists == NULL) {
return;
}
m_current_command_list = g_list_first(m_command_lists);
((NedIdCommandList *) m_current_command_list->data)->execute(true);
return;
}
lptr = g_list_next(m_current_command_list);
if (lptr == NULL) {
return;
}
m_current_command_list = lptr;
((NedIdCommandList *) m_current_command_list->data)->execute(true);
}
void NedIdCommandHistory::unexecute() {
if (m_current_command_list == NULL) {
return;
}
((NedIdCommandList *) m_current_command_list->data)->unexecute(true);
m_current_command_list = g_list_previous(m_current_command_list);
}
void NedIdCommandHistory::addCommandList(NedIdCommandList *command_list) {
GList *lptr;
if (m_current_command_list == NULL) {
// TODO free old command list
m_command_lists = NULL;
}
if (m_command_lists != NULL) {
if (m_current_command_list == NULL) {
lptr = m_command_lists;
}
else {
lptr = g_list_next(m_current_command_list);
}
while (lptr != NULL) {
delete ((NedIdCommandList *) lptr->data);
m_command_lists = g_list_delete_link(m_command_lists, lptr);
lptr = g_list_next(m_current_command_list);
}
}
m_command_lists = g_list_append(m_command_lists, command_list);
m_current_command_list = g_list_last(m_command_lists);
}
bool NedIdCommandHistory::unexecute_possible() {
return m_current_command_list != NULL;
}
bool NedIdCommandHistory::execute_possible() {
if (m_current_command_list == NULL) {
if (m_command_lists == NULL) {
return FALSE;
}
return TRUE;
}
return g_list_next(m_current_command_list) != NULL;
}
nted-1.10.18/idiotseditor/idiotseditor.h 0000664 0010410 0000764 00000032067 11520267221 015117 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef IDIOTSEDITOR_H
#define IDIOTSEDITOR_H
#include "config.h"
#include
#include
#include
#include
#include
#include
#include "resource.h"
#include "paths.h"
class NedIdiotsEditor;
class NedIdCommandHistory;
class pitch_info {
public:
int m_pitch, m_line;
bool m_tiebackward;
unsigned int m_state;
};
class NedIdNote {
public:
NedIdNote(int f_pitch, int volume, unsigned long long sta, unsigned long long sto) :
m_midi_start(sta), m_midi_stop(sto), m_max_stop(0),
m_ori_start(sta), m_ori_stop(sto),
m_tri_start_numerator(0), m_chordnotes(NULL),
m_pitch(f_pitch), m_valid(true), m_is_triplet_note(false), fix_start(false), fix_end(false), m_volume(volume), m_line(3 /* dummy */), m_tiedbackward(false) {
m_tripletnotes[0] = m_tripletnotes[1] = m_tripletnotes[2] = NULL;
}
NedIdNote(int f_pitch, int volume, unsigned long long sta) :
m_midi_start(sta), m_midi_stop(sta), m_max_stop(0),
m_ori_start(sta), m_tri_start_numerator(0), m_chordnotes(NULL),
m_pitch(f_pitch), m_valid(false), m_is_triplet_note(false), fix_start(false), fix_end(false), m_volume(volume), m_line(3 /* dummy */), m_tiedbackward(false) {
m_tripletnotes[0] = m_tripletnotes[1] = m_tripletnotes[2] = NULL;
}
NedIdNote *cloneWithDifferentTime(unsigned long long sta, unsigned long long sto);
bool isInRect(double x, double y, double zoom_value, double xleft, double ytop);
void determineLines(int clef, int octave_shift, int key, char *offs_array);
~NedIdNote();
void addPitch(int pitch, bool tiebackward);
void closeNote(unsigned long long sto) {
if (sto > m_midi_start) {
m_midi_stop = sto;
m_valid = true;
}
}
static int compare_note_start(NedIdNote *n1, NedIdNote *n2) {
if (n1->m_midi_start < n2->m_midi_start) return -1;
if (n1->m_midi_start < n2->m_midi_start) return 0;
return 1;
}
unsigned long long m_midi_start, m_midi_stop, m_max_stop;
unsigned long long m_ori_start, m_ori_stop;
unsigned long long m_tri_start;
int m_tri_start_numerator;
GList *m_chordnotes;
NedIdNote *m_tripletnotes[3];
int m_pitch;
bool m_valid;
bool m_is_triplet_note;
bool fix_start, fix_end;
unsigned int m_state;
int m_volume;
int m_line;
bool m_tiedbackward;
};
class NedIdSpecial {
public:
NedIdSpecial(int type, unsigned long long time, int measure_number) :
m_type(type), m_time(time), m_measure_number(measure_number) {}
int m_type;
#define ID_SPEC_TIME_SIG_CHANGE 1
#define ID_SPEC_TEMPO_CHANGE 2
#define ID_SPEC_VOLUME_CHANGE 3
#define ID_SPEC_KEYSIG_CHANGE 4
unsigned long long m_time;
int m_measure_number;
static int compare_specials(NedIdSpecial *m1, NedIdSpecial *m2) {
if (m1->m_time == m2->m_time) return 0;
if (m1->m_time < m2->m_time) return -1;
return 1;
}
};
class NedIdTimesigChange : public NedIdSpecial {
public:
NedIdTimesigChange(unsigned long long time, int measure_number, int numerator, int denominator) :
NedIdSpecial(ID_SPEC_TIME_SIG_CHANGE, time, measure_number), m_numerator(numerator), m_denominator(denominator) {}
int m_numerator, m_denominator;
};
class NedIdTempoChange : public NedIdSpecial {
public:
NedIdTempoChange(unsigned long long time, int measure_number, int tempo) :
NedIdSpecial(ID_SPEC_TEMPO_CHANGE, time, measure_number), m_tempo(tempo), m_used(false) {}
int m_tempo;
bool m_used;
};
class NedIdVolumeChange : public NedIdSpecial {
public:
NedIdVolumeChange(unsigned long long time, int measure_number, int volume) :
NedIdSpecial(ID_SPEC_VOLUME_CHANGE, time, measure_number), m_volume(volume), m_taken(false) {}
int m_volume;
bool m_taken;
};
class NedIdKeysigChange : public NedIdSpecial {
public:
NedIdKeysigChange(unsigned long long time, int measure_number, int key) :
NedIdSpecial(ID_SPEC_KEYSIG_CHANGE, time, measure_number), m_key(key) {}
int m_key;
};
#define MAX_INST_NAME 12
#define MAX_64TH 640
class NedIdiotsInstrument {
public:
NedIdiotsInstrument(NedIdiotsEditor *id_edit, int channel, int orig_channel, int midi_nr, int volume_change_density);
~NedIdiotsInstrument();
GList* trySplitInstrument(bool force_piano, bool dont_split);
void setInstNumber(int nr) {m_inst_number = nr;}
void draw(Display *dpy, Window win, GC xgc, GC border_gc, double zoom_value, double xleft, double ytop, double visible_start_pos, double visible_end_pos);
void draw_specials(cairo_t *cr, double zoom_value, double xleft, double ytop, double visible_start_pos, double visible_end_pos);
void closeNote(int pitch, unsigned long long end_time, int midi_nr);
int specCount();
void addNote(int pitch, int volume, unsigned long long start, int midi_nr);
void addNote(NedIdNote *note);
void addKeySig(NedIdKeysigChange *kc);
void handle_button_press (GdkEventButton *event, double xleft, double ytop, double visible_start_pos, double visible_end_pos);
void enlargeNotesWithUnusualLength(NedIdiotsEditor *id);
void recognizeTriplets(NedIdiotsEditor *id);
void enlargeNotesToAvoidSmallRests(NedIdiotsEditor *id);
void generateVolumeSigns(int volume_change_density);
int getMidiNr() {return m_midi_nr;}
void setMidiNr(int midi_nr) {m_midi_nr = midi_nr;}
void setInstrumentName(char *name);
void snapStartOfNotes(NedIdiotsEditor *id);
void computeVolume();
void recomputeNotes(double zoom_value, double xleft, double ytop);
int getChannel() {return m_channel;}
int getClef() {return m_clef;}
int getOctaveShift() {return m_octave_shift;}
int getVolume() {return m_volume;}
int getOrigChannel() {return m_orig_channel;}
void setOrigChannel(int chan) {m_orig_channel = chan;}
void setChannel(int chan) {m_channel = chan;}
void determineLines(NedIdiotsEditor *id);
void findConflictingNotes();
void findChords(bool all_voices);
void addSpecial(NedIdSpecial *spec);
GList *clone_specials();
GList *convertToNtEdNotes(NedIdiotsEditor *id, bool place_tempo_sigs, bool place_volume_or_key_signs,
int voice_nr, unsigned long long last_time);
char *getInstrumentName();
private:
void splitNotesAtMeasureStart(NedIdiotsEditor *id);
int compute_weight(unsigned long long sta, unsigned long long sto, bool is_rest);
unsigned long long findEndTime(unsigned long long sta, unsigned long long sto, unsigned long long max_stop, unsigned long long rest_end, unsigned long long measure_start);
bool newVolumeNeeded(unsigned long long time, int *new_volume);
NedIdNote *findNote(GList *start, unsigned long long start_time, unsigned long long end_time, NedIdNote *not_note1, NedIdNote *not_note2);
void notesAus(char *s, int i);
NedIdiotsEditor *m_id_edit;
int m_clef, m_octave_shift;
GList *m_notes[VOICE_COUNT];
GList *m_specials;
NedIdNote *m_selected_note;
int m_inst_number;
int m_volume_change_density;
int m_midi_nr;
int m_channel;
int m_orig_channel;
int m_volume;
char m_inst_name[MAX_INST_NAME];
char m_dist_array[4][MAX_64TH];
static int m_mid_lines[4];
};
class NedIdiotsEditor {
public:
NedIdiotsEditor(int tempo_change_density, int volume_change_density, bool force_piano, bool sort_instruments, bool dont_split, bool X11Version = false);
~NedIdiotsEditor();
void setLastTime(unsigned long long last_time);
void closeNote(int pitch, unsigned long long end_time, int midi_nr, int chan);
void addNote(int pitch, int volume, unsigned long long start, int midi_nr, int chan);
void addTimeSigChange(unsigned long long time, int numerator, int denominator);
void addTempoChange(unsigned long long time, int tempo);
void addKeySig(unsigned long long time, int measure_number, int key);
void setInstrumentName(char *name);
void computeTimeSigMeasureNumbers(NedMainWindow *main_window);
int getVolumeChangeDensity() {return m_volume_change_density;}
void computeTempo();
bool newTempoNeeded(unsigned long long current_time, int *newtempo, int current_tempo, unsigned long long *last_tempo_test);
bool newVolumeNeeded(int *current_volume, int volume);
bool newKeyNeeded(unsigned long long current_time, int *newkey, unsigned long long *last_key_test);
void printMeasures();
void getMeasureNumber(unsigned long long start_time, int *num, int *denom);
void computeVolumes();
void changeChannelAndPgm(int staff_nr, int chan, int pgm);
unsigned long long getMeasureStart(unsigned long long sample_time, bool endtime);
unsigned long long getFirstSplitTime(unsigned long long start_time, unsigned long long end_time);
char* getInstrumentName(int staff_nr);
int getNumerator();
int getDenominator();
int getPartCount();
int determine_key(unsigned long long time, int channel);
void trySplitInstruments();
void snapStartOfNotes();
void recognizeTriplets();
GList *convertToNtEdNotes(int staff_nr, int voice_nr);
GList *colone_specials();
int getClef(int staff_nr);
int getOctaveShift(int staff_nr);
int getMidiPgm(int staff_nr);
int getChannel(int staff_nr);
int getVolume(int staff_nr);
int getKeySig(int staff_nr);
GtkWidget *getDrawingArea() {return m_drawing_area;}
GdkCursor *getPointCursor() {return m_pointer;}
GdkCursor *getFleurCursor() {return m_fleur;}
GdkCursor *getDoubldArrowCursor() {return m_double_arrow;}
NedIdCommandHistory *getCommandHistory() {return m_command_history;}
double getOffX() {return m_off_x;}
double getOffY() {return m_off_y;}
double getZoomValue() {return m_zoom_value;}
unsigned int getMinDenom() {return m_min_denom;}
void repaint();
double m_tempo_inverse;
int motion_mode;
private:
void correct_times_of_specials();
bool delete_double_specials();
void initX11();
GdkCursor *m_double_arrow, *m_pointer, *m_fleur;
static const char *guiDescription;
static const GtkActionEntry file_entries[];
static gboolean handle_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data);
void draw_piano(cairo_t *cr, double ytop, int height);
static void select_instrument(GtkButton *button, gpointer data);
static void zoom_in(GtkWidget *widget, void *data);
static void zoom_out(GtkWidget *widget, void *data);
static void size_change_handler(GtkWidget *widget, GtkRequisition *requisition, gpointer data);
static void handle_scroll(GtkAdjustment *adjustment, gpointer data);
static gboolean handle_button_press (GtkWidget *widget,
GdkEventButton *event, gpointer data);
static gboolean handle_motion (GtkWidget *widget, GdkEventMotion *event, gpointer data);
static gboolean handle_button_release (GtkWidget *widget,
GdkEventButton *event, gpointer data);
static void do_undo(GtkWidget *widget, void *data);
static void do_redo(GtkWidget *widget, void *data);
void getNumDenom(unsigned long long time, unsigned int *num, unsigned int *denom);
static const char *pitch_tab[];
#ifdef ORIORI
void draw();
#endif
void draw_new();
void draw_specials (cairo_t *cr, double zoom_value, double xleft, double ytop, int width, double visible_start_pos, double visible_end_pos);
void thin_out_temposigs();
void setHadjust();
void setVadjust();
double m_zoom_value;
GtkUIManager *m_ui_manager;
GtkActionGroup *m_menu_action_group;
GtkWidget *m_main_window;
GtkWidget *m_drawing_area;
GtkWidget *m_instrument_toolbar;
GtkAdjustment *m_hadjust;
GtkAdjustment *m_vadjust;
GtkWidget *m_instr_bu;
double m_paper_len;
double m_paper_height;
bool m_force_piano, m_force_one_staff;
int m_tempo_change_density, m_volume_change_density;
int m_current_instrument_number;
unsigned long long m_last_time;
char m_pending_inst_name[MAX_INST_NAME];
int m_channel_nr;
NedIdiotsInstrument *m_last_inserted;
bool m_sort_according_instrument;
bool m_dont_split;
bool m_X11version;
unsigned int m_min_denom;
NedIdCommandHistory *m_command_history;
GList *m_instruments;
GList *m_specials;
double m_mouse_x, m_mouse_y;
double m_off_x, m_off_y;
Display *m_dpy;
Window m_win;
GC m_xgc, m_x_border_gc;
Pixmap m_back_image;
int m_screen;
static void close_i_edit(GtkWidget *widget, void *data);
};
#endif /* IDIOTSEDITOR_H */
nted-1.10.18/idiotseditor/idcommandlist.h 0000664 0010410 0000764 00000003232 11520267221 015234 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef ID_COMMAND_LIST_H
#define ID_COMMAND_LIST_H
#include
#include "config.h"
class NedCommand;
class NedIdiotsEditor;
class NedIdCommandList {
public:
NedIdCommandList(NedIdiotsEditor *id_edit);
~NedIdCommandList();
void addCommand(NedCommand *command);
int getNumberOfCommands();
void execute(bool adjust = false);
void unexecute(bool adjust = false);
private:
GList *m_commands;
NedIdiotsEditor *m_id_edit;
};
#endif /* ID_COMMAND_LIST_H */
nted-1.10.18/idiotseditor/idcommandhistory.h 0000664 0010410 0000764 00000003326 11520267221 015766 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef ID_COMMAND_HISTORY_H
#define ID_COMMAND_HISTORY_H
#include
#include "config.h"
class NedIdCommandList;
class NedIdiotsEditor;
class NedIdCommandHistory {
public:
NedIdCommandHistory(NedIdiotsEditor *main_window);
void addCommandList(NedIdCommandList *command_list);
void execute();
void unexecute();
void reset();
private:
bool execute_possible();
bool unexecute_possible();
GList *m_command_lists;
GList *m_current_command_list;
NedIdiotsEditor *m_id_edit;
};
#endif /* ID_COMMAND_HISTORY_H */
nted-1.10.18/idiotseditor/changeidnotecommand.cpp 0000664 0010410 0000764 00000004363 11520267221 016735 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "changeidnotecommand.h"
#include "idiotseditor.h"
NedChangeIdNoteCommand::NedChangeIdNoteCommand(NedIdNote *id_note, unsigned long long new_start, unsigned long long new_stop, int new_pitch) :
m_id_note(id_note), m_new_midi_start(new_start), m_new_midi_stop(new_stop), m_new_pitch(new_pitch) {
m_old_valid = m_new_valid = id_note->m_valid;
m_old_midi_start = id_note->m_midi_start;
m_old_midi_stop = id_note->m_midi_stop;
m_old_pitch = id_note->m_pitch;
}
void NedChangeIdNoteCommand::execute(bool adjust /* = false */) {
#ifdef EXECUTE_DEBUG
printf("\tNedChangeIdNoteCommand::execute\n");
#endif
m_id_note->m_midi_start = m_new_midi_start;
m_id_note->m_midi_stop = m_new_midi_stop;
m_id_note->m_pitch = m_new_pitch;
m_id_note->m_valid = m_new_valid;
}
void NedChangeIdNoteCommand::unexecute(bool adjust /* = false */) {
#ifdef UNEXECUTE_DEBUG
printf("\tNedChangeIdNoteCommand::unexecute\n");
#endif
m_id_note->m_midi_start = m_old_midi_start;
m_id_note->m_midi_stop = m_old_midi_stop;
m_id_note->m_pitch = m_old_pitch;
m_id_note->m_valid = m_old_valid;
}
nted-1.10.18/idiotseditor/Makefile.in 0000664 0010410 0000764 00000037253 11520267353 014321 0000000 0000000 # Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
#########################################################################################
# #
# This program is free software; you can redistribute it and#or modify it under the #
# terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this #
# program; (See "COPYING"). If not, If not, see . #
# #
#---------------------------------------------------------------------------------------#
# #
# Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY #
# ja@informatik.tu-chemnitz.de #
# #
# #
#########################################################################################
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = idiotseditor
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LIBRARIES = $(noinst_LIBRARIES)
AR = ar
ARFLAGS = cru
libidiotseditor_a_AR = $(AR) $(ARFLAGS)
libidiotseditor_a_LIBADD =
am_libidiotseditor_a_OBJECTS = idiotseditor.$(OBJEXT) \
idcommandhistory.$(OBJEXT) idcommandlist.$(OBJEXT) \
changeidnotecommand.$(OBJEXT)
libidiotseditor_a_OBJECTS = $(am_libidiotseditor_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
-o $@
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libidiotseditor_a_SOURCES)
DIST_SOURCES = $(libidiotseditor_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALSA_CFLAGS = @ALSA_CFLAGS@
ALSA_LIBS = @ALSA_LIBS@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CAIRO_CFLAGS = @CAIRO_CFLAGS@
CAIRO_LIBS = @CAIRO_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EXEEXT = @EXEEXT@
FT2_CFLAGS = @FT2_CFLAGS@
FT2_LIBS = @FT2_LIBS@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IMAGE2HEADER = @IMAGE2HEADER@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PANGO_CFLAGS = @PANGO_CFLAGS@
PANGO_LIBS = @PANGO_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PO2XML = @PO2XML@
POSUB = @POSUB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
X11_CFLAGS = @X11_CFLAGS@
X11_LIBS = @X11_LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XML2POT = @XML2POT@
XMLTO = @XMLTO@
YELP = @YELP@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = $(FT2_CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/commands $(CAIRO_CFLAGS) $(GTK_CFLAGS)
noinst_LIBRARIES = libidiotseditor.a
libidiotseditor_a_SOURCES = idiotseditor.cpp idcommandhistory.cpp \
idcommandlist.cpp changeidnotecommand.cpp idiotseditor.h \
idcommandhistory.h idcommandlist.h changeidnotecommand.h
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign idiotseditor/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign idiotseditor/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libidiotseditor.a: $(libidiotseditor_a_OBJECTS) $(libidiotseditor_a_DEPENDENCIES)
-rm -f libidiotseditor.a
$(libidiotseditor_a_AR) libidiotseditor.a $(libidiotseditor_a_OBJECTS) $(libidiotseditor_a_LIBADD)
$(RANLIB) libidiotseditor.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/changeidnotecommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idcommandhistory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idcommandlist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idiotseditor.Po@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-noinstLIBRARIES ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
nted-1.10.18/line.h 0000664 0010410 0000764 00000005077 11520267230 010643 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef LINE_H
#define LINE_H
#include
#include
#define LINE_CRESCENDO (1 << 0)
#define LINE_DECRESCENDO (1 << 1)
#define LINE_OCTAVATION1 (1 << 3)
#define LINE_OCTAVATION_1 (1 << 4)
#define LINE_OCTAVATION2 (1 << 5)
#define LINE_OCTAVATION_2 (1 << 6)
#define LINE_OCTAVIATION_MASK (LINE_OCTAVATION1 | LINE_OCTAVATION_1 | LINE_OCTAVATION2 | LINE_OCTAVATION_2)
#define LINE_ACCELERANDO (1 << 7)
#define LINE_RITARDANDO (1 << 8)
#define LINE_TEMPO_CHANGE (LINE_ACCELERANDO | LINE_RITARDANDO)
class NedLinePoint;
class NedLine {
public:
NedLine(NedLinePoint *start, NedLinePoint *end);
virtual ~NedLine() {}
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level) = 0;
virtual void computeParams();
virtual void startContextDialog(GtkWidget *ref) {}
virtual bool isActive();
virtual bool isLine3() {return false;}
NedLinePoint *getLineStartPoint() {return m_line_start_point;}
NedLinePoint *getLineEndPoint() {return m_line_end_point;}
virtual int getLineType() = 0;
virtual unsigned long long computeMidiDuration();
virtual void setAllPointsToRel(NedLinePoint *initiator);
protected:
NedLinePoint *m_line_start_point, *m_line_end_point;
double m_start_x, m_start_y;
double m_end_x, m_end_y;
GList *m_intermediate_staves;
bool m_distributed;
bool m_allow_drawing;
friend class NedLinePoint;
};
#endif /* LINE_H */
nted-1.10.18/freechordname.h 0000664 0010410 0000764 00000005366 11520267230 012517 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef FREE_CHORD_NAME
#define FREE_CHORD_NAME
#include "freereplaceable.h"
#include
class NedPangoCairoText;
class NedChordName : public NedFreeReplaceable {
public:
NedChordName(GtkWidget *drawing_area, char *roottext, char *uptext, char *downtext, double fontsize);
NedChordName(GtkWidget *drawing_area, char *roottext, char *uptext, char *downtext, double fontsize,
NedChordOrRest *element);
NedChordName(GtkWidget *drawing_area, char *roottext, char *uptext, char *downtext, double fontsize,
NedChordOrRest *element, double x, double y, bool relative);
~NedChordName();
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL);
virtual void adjust_pointers(struct addr_ref_str *slurlist);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_CHORDNAME;}
virtual void startContextDialog(GtkWidget *ref);
virtual bool trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy);
char *getRootText();
char *getUpText();
char *getDownText();
double getSize() {return m_fontsize;}
void setTexts(char *roottext, char *uptext, char *downtext, double zoom);
virtual void setZoom(double zoom, double scale);
const char *m_font_family;
private:
NedPangoCairoText *m_root_text, *m_up_text, *m_down_text;
double m_fontsize;
GtkWidget *m_drawing_area;
};
#endif /* FREE_CHORD_NAME */
nted-1.10.18/AUTHORS 0000664 0010410 0000764 00000000054 11520267230 010601 0000000 0000000 Joerg Anders
nted-1.10.18/beam.h 0000664 0010410 0000764 00000005535 11520267230 010617 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef BEAM_H
#define BEAM_H
#include "config.h"
#include "resource.h"
#include "resource.h"
#include
#include
#define SLOPE_COUNT 7
class NedMainWindow;
class NedPage;
class NedSystem;
class NedStaff;
class NedVoice;
class NedChordOrRest;
class NedBeam {
public:
NedBeam(GList *beamed_chords_list);
~NedBeam();
void print();
void draw(cairo_t *cr);
void drawPostscript(cairo_t *cr);
void insertChord(NedChordOrRest *chord, int newpos);
void removeChord(NedChordOrRest *chord);
bool isEqual(GList *beamlist, NedChordOrRest *except, int *diff_pos);
void changeStemDir(int dir);
NedMainWindow *getMainWindow();
NedPage *getPage();
NedSystem *getSystem();
NedStaff *getStaff();
double getTopOfBeam();
double getBottomOfBeam();
int getChordCount();
int getPosition(NedChordOrRest *chord);
double getYPosAt(double xpos);
void setTupletMarker(int tuplet_marker, double *topy, double *boty);
bool isBeamUp() {return m_up;}
void computeBeam(int staff_voice_offs);
void freeChords();
void reconnect();
void saveBeam(FILE *fp);
NedChordOrRest *getFirst();
NedChordOrRest *getLast();
double getBeamLength();
bool isFirstInBeam(NedChordOrRest *chord);
bool isLastInBeam(NedChordOrRest *chord);
bool m_needed; // aux.
double getSlope() {return m_slope;}
private:
void computeGraceBeam(NedChordOrRest *first, NedChordOrRest *last);
void drawGraceBeam(cairo_t *cr);
static double m_slopes[SLOPE_COUNT];
GList *m_beamed_chords;
double m_slope;
double m_start_x, m_start_y;
double m_end_x, m_end_y;
double m_tuplet_x, m_tuplet_y;
bool m_up;
int m_tuplet_marker;
int m_beam_count;
};
#endif /* BEAM_H */
nted-1.10.18/Makefile.am 0000664 0010410 0000764 00000007362 11520267230 011576 0000000 0000000 #########################################################################################
# #
# This program is free software; you can redistribute it and#or modify it under the #
# terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this #
# program; (See "COPYING"). If not, If not, see . #
# #
#---------------------------------------------------------------------------------------#
# #
# Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY #
# ja@informatik.tu-chemnitz.de #
# #
# #
#########################################################################################
SUBDIRS = commands idiotseditor dialogs chords icons . po datafiles doc man
dist_doc_DATA =
dist_doc_DATA += AUTHORS
dist_doc_DATA += ABOUT_THE_EXAMPLES.TXT
dist_doc_DATA += FAQ
AM_CPPFLAGS =
AM_CPPFLAGS += -DNTED_HTMLDIR=\"${htmldir}\"
AM_CPPFLAGS += -DNTED_DATADIR=\"${datarootdir}/${PACKAGE_TARNAME}\"
AM_CPPFLAGS += -DLOCALEDIR=\"${localedir}\"
AM_CPPFLAGS += -I$(top_srcdir)/dialogs -I$(top_srcdir)/commands -I$(top_srcdir)/chords -I$(top_srcdir)/idiotseditor
AM_CPPFLAGS += $(FT2_CFLAGS) $(CAIRO_CFLAGS) $(GTK_CFLAGS) $(PANGO_CFLAGS)
bin_PROGRAMS = nted
nted_SOURCES = mainwindow.cpp resource.cpp page.cpp system.cpp staff.cpp \
voice.cpp chordorrest.cpp note.cpp musicxmlimport.cpp \
beam.cpp tuplet.cpp clipboard.cpp midiexport.cpp measure.cpp \
freereplaceable.cpp volumesign.cpp temposign.cpp slurpoint.cpp \
slur.cpp linepoint.cpp line.cpp crescendo.cpp octavation.cpp \
line3.cpp acceleration.cpp freetext.cpp freesign.cpp \
importer.cpp positionarray.cpp freechord.cpp freespacer.cpp \
pangocairotext.cpp freechordname.cpp midiimporter.cpp midirecorder.cpp
nted_SOURCES += acceleration.h beam.h beaming.h chordorrest.h \
clipboard.h crescendo.h freereplaceable.h freesign.h freetext.h \
importer.h line3.h line.h linepoint.h localization.h \
mainwindow.h measure.h midiexport.h musicxmlimport.h note.h\
octavation.h page.h resource.h slur.h slurpoint.h staff.h system.h \
temposign.h tuplet.h voice.h volumesign.h positionarray.h dynarray.h COPYING.GFDL COPYING.FONT.TXT \
freechord.h freespacer.h pangocairotext.h freechordname.h midiimporter.h midirecorder.h
nted_LDADD = commands/libcommands.a dialogs/libdialogs.a chords/libchords.a idiotseditor/libidiotseditor.a $(CAIRO_LIBS) $(PANGO_LIBS) $(GTK_LIBS) $(X11_LIBS) -lasound
cleanup: maintainer-clean cleanup-local
distclean-local:
rm -f po/stamp-po
# Clean up all generated files. You can re-create them with autoreconf.
cleanup-local:
find . -name Makefile | xargs rm -f
find $(srcdir) -name Makefile.in | xargs rm -f
rm -f ./config.status ./config.log
cd $(srcdir) && rm -f config.sub config.guess config.rpath
cd $(srcdir) && rm -f aclocal.m4 configure config.h.in
cd $(srcdir) && rm -f depcomp install-sh missing mkinstalldirs
rm -f ./config.h
find . -type d -name .deps -exec rm -fr {} \; -prune
rm -f stamp-h1
rm -rf $(srcdir)/autom4te.cache
cd $(srcdir) && rm -rf m4
cd $(srcdir)/po && rm -f boldquot.sed en@boldquot.header en@quot.header insert-header.sin quot.sed remove-potcdate.sin Rules-quot
cd $(srcdir)/po && rm -f Makefile.in.in Makevars.template
cd $(srcdir) && rm -f ABOUT-NLS
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = config.rpath INSTALL README
nted-1.10.18/ABOUT_THE_EXAMPLES.TXT 0000664 0010410 0000764 00000010303 11520267230 013000 0000000 0000000 Here is some information about the 11 examples, to enable a
copyright-free estimation:
First of all: I (J.Anders wrote down all
these notes. I wrote all notes from my remembrances, not from
a sheet of paper. So the notes are not copies of some printed notes.
And I declare I'll never demand any copyright.
Of course I'm not the composer! Thus, the question is: Does any
composer hold a copyright? I think this isn't the case because
according to (German) copyright law the copyright ends 70 years
after the composer died. And this is the case here.
I'll tell something about the examples to give
others the opportunity to find out whether the examples
are copyright free:
example1.ntd, example2.ntd, example11.ntd:
This is a jazz variant of the famous Barcarole from the opera
"Les Contes d'Hoffmann" ("The Tales of Hoffmann") by Jacques Offenbach.
Offenbach died 5 October 1880.
See also : http://en.wikipedia.org/wiki/Jacques_Offenbach
As a child I heard a big band playing this song this way.
But note: I never saw any notes.
example3.ntd
This is the famous Bouree e - minor (BWV Nr. 996) by
Johann Sebastian Bach who died 28 July 1750.
see: http://en.wikipedia.org/wiki/Bach
I can play this without any notes on guitar. I don't
know from which notes I learned it. I simply wrote down
what I'm playing.
You can find the notes at many places in Internet:
http://bs.cyty.com/visitabilis/gitarre/img/bourree.gif
http://www.delcamp.net/pdf/2_baroque/bwv9965_bach_bourree.pdf
http://www.thomaskoenigs.de/bach_bwv996.zip
example4.ntd
This is an Irish folk song called "Oh danny boy". Again as a child
I heard a big band playing the song this way. But I never saw
any notes.
To hear a MIDI example look here:
http://www.ireland-information.com/irishmusic/dannyboy.shtml
(you'll hear I made some mistakes, the exact melody differs from
my version, another indication: It is written down from my
remembrances)
Actually the song is by Frederic Edward Weatherly (1848-1929).
But he only wrote the lyrics to an unsuccessful song called
"Danny Boy". As he heard an old song called "Londonderry Air"
he found the words fit exactly to the music. So he used the
melody of "Londonderry Air" for his song "Danny Boy".
Therefore the question is: Where does the melody of "Londonderry Air"
come form:
It was first published 1855 in "Ancient Music of Ireland" by the
collector George Petrie (1789-1866) as untitled melody, who
claimed he had written down it from an itinerant piper.
The whole story about this song is at:
http://www.standingstones.com/dannyboy.html
example5.ntd, example6.ntd:
This is a Celtic/Irish folk song known as
"Kilgary Mountain"
or
"Whiskey In The Jar"
(I changed some notes and added my own finish)
The MIDI and the words are mentiond here:
http://www.contemplator.com/tunebook/ireland/kilgary.htm
http://www.contemplator.com/tunebook/midimusic/kilgary.mid
example7.ntd:
This is the famous "Huntmen's Chorus" ("Jaegerchor") from
the opera "The Freeshooter" ("Der Freischuetz") by
the German composer Carl Maria von Weber who died June 5, 1826, see
http://en.wikipedia.org/wiki/Carl_Maria_von_Weber
example8.ntd:
This song is called "Old folks at home", also known
as "Suwanee River".
It is written by Stephen C. Foster who died January 13, 1864.
See also:
http://en.wikipedia.org/wiki/Stephen_C._Foster
example9.ntd:
This is the famous Prelude No.1 in C Major from "Well-tempered Clavier" BWV846
by Johann Sebastian Bach who died 28 July 1750.
see: http://en.wikipedia.org/wiki/Bach
I could play this on piano and wrote down what I'm playing as
I developed "NoteEdit". What you see here is the MusicXML import
from MusicXML created by "NoteEdit".
example10.ntd:
This is a German folk song:
"Es wollt ein Schneider wandern"
first published in Stuttgart, 1850. You can find
the text, the melody, and the history on many WEB sites,
for instance:
http://musicanet.org/robokopp/Lieder/eswollts.html
http://ingeb.org/Lieder/eswollts.html
http://www.lieder-archiv.de/lieder/show_song.php?ix=300641
nted-1.10.18/system.cpp 0000664 0010410 0000764 00000175516 11520267230 011601 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include
#include "system.h"
#include "staff.h"
#include "page.h"
#include "chordorrest.h"
#include "resource.h"
#include "mainwindow.h"
#include "clipboard.h"
#include "commandlist.h"
#include "commandhistory.h"
#include "voice.h"
#include "movechordsandrestscommand.h"
#include "movechordsandrestsreversecommand.h"
#include "appendstaffcommand.h"
#include "mainwindow.h"
#include "musicxmlimport.h"
#include "pangocairotext.h"
#define DEFAULT_SYSTEM_DIST (4 * LINE_DIST)
#define X_POS_PAGE_REL(p) ((getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS(p) ((p) * zoom_factor - topy)
#define Y_POS_INVERSE(p) (((p) / current_scale + topy) / zoom_factor)
#define X_POS_PAGE_REL_INVERSE(p) (((p) + leftx) / zoom_factor - getPage()->getContentXpos())
#define X_POS_INVERSE(p) (((p) / current_scale + leftx) / zoom_factor)
#define X_PS_POS(p) ((DEFAULT_BORDER + LEFT_RIGHT_BORDER + (p)) * PS_ZOOM)
#define Y_PS_POS(p) ((height - (p)) * PS_ZOOM)
NedSystem::NedSystem(NedPage *page, double ypos, double width, int nr, unsigned int start_measure_number, bool start) :
m_system_start(CLEF_SPACE), m_is_positioned(false), m_staffs(NULL), m_deleted_staffs(NULL),
m_ypos(ypos), m_width(width), m_system_number(nr), m_has_repeat_lines(false),
m_page(page), m_measure_count(0), m_extra_space(0.0), m_only_whole_elements(FALSE), m_endMeasure(NULL), m_special_measure_at_end(0) {
int i;
double staff_pos = 0;
NedStaff *staff;
GList *lptr;
if (page->getPageNumber() == 0 && nr == 0) {
m_system_start += TIME_SIGNATURE_SPACE;
}
for (i = 0; i < MAX_MEASURES; m_measures[i++].setSystem(this));
if (start) {
for (i = 0; i < getMainWindow()->getStaffCount(); i++) {
m_staffs = g_list_append(m_staffs,
staff = new NedStaff(this,
staff_pos, m_width, i, TRUE));
staff_pos += staff->getHeight() + DEFAULT_SYSTEM_DIST;
}
do {
for (i = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
((NedStaff *) lptr->data)->appendWholeRest();
}
//do_reposit();
reposit(start_measure_number);
}
while (m_extra_space > MAXIMUM_EXTRA_SPACE);
}
}
NedSystem::~NedSystem() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
delete ((NedStaff *) (lptr->data));
}
g_list_free(m_staffs);
m_staffs = NULL;
for (lptr = g_list_first(m_deleted_staffs); lptr; lptr = g_list_next(lptr)) {
delete ((NedStaff *) (lptr->data));
}
g_list_free(m_deleted_staffs);
m_deleted_staffs = NULL;
}
NedSystem *NedSystem::clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedPage *p_page, bool *staves) {
GList *lptr;
int i, j;
NedSystem *system = new NedSystem(p_page, m_ypos, m_width, m_system_number, getNumberOfFirstMeasure(), false);
for (i = j = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
if (!staves[i]) continue;
system->m_staffs = g_list_append(system->m_staffs, ((NedStaff *) lptr->data)->clone(addrlist, slurlist, system, j++));
}
return system;
}
void NedSystem::adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->adjust_pointers(addrlist, slurlist);
}
}
NedStaff *NedSystem::getStaff(int nr) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, nr)) == NULL) {
return NULL;
}
return (NedStaff *) lptr->data;
}
void NedSystem::fill_up(NedCommandList *command_list) {
GList *lptr;
do {
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->appendWholeRest(command_list);
}
compute_extra_space(false);
//do_reposit(false);
}
while (m_extra_space > MINIMUM_EXTRA_SPACE);
}
double NedSystem::getHeight() {
NedStaff *staff;
staff = (NedStaff *) g_list_last(m_staffs)->data;
return staff->getBottomPos();
}
double NedSystem::getBottomPos() {
NedStaff *staff;
staff = (NedStaff *) g_list_last(m_staffs)->data;
return m_ypos + staff->getBottomPos();
}
NedMainWindow *NedSystem::getMainWindow() {return m_page->getMainWindow();}
/*
bool NedSystem::find_new_cursor_pos(guint keyval, int *x, int *y, double *dist) {
GList *lptr;
double newx = x, newy = y;
bool found = false;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (((NedSystem *) lptr->data)->find_new_cursor_pos(keyval, &newx, &newy, dist)) {
found = true;
*x = newx; *y = newy;
}
}
return found;
}
*/
void NedSystem::draw(cairo_t *cr, bool first_page, bool show_measure_numbers, bool *freetexts_or_lyrics_present) {
double leftx = getMainWindow()->getLeftX();
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
NedStaff *firststaff, *laststaff;
NedStaff *staff;
double brace_start_y_pos = -1.0;
double bracket_start_y_pos = -1.0;
bool inside_connected_staves = false;
bool inside_bracket = false;
int i;
double botp, botp1, botp2;
double indent = first_page ? getMainWindow()->getFirstSystemIndent() : getMainWindow()->get2ndSystemIndent();
GList *lptr1, *lptr2;
lptr1 = g_list_first(m_staffs);
lptr2 = g_list_next(lptr1);
m_freetexts_or_lyrics_present = false;
for (i = 0, lptr2 = g_list_next(lptr1); lptr1; lptr1 = lptr2, lptr2 = g_list_next(lptr2), i++) {
if ((getMainWindow()->m_staff_contexts[i].m_flags & CON_BAR_START) != 0) {
inside_connected_staves = true;
}
if ((getMainWindow()->m_staff_contexts[i].m_flags & CON_BAR_END) != 0) {
inside_connected_staves = false;
}
botp1 = botp2 = ((NedStaff *) lptr1->data)->getBottomPos();
if (lptr2) botp2 = ((NedStaff *) lptr2->data)->getBottomPos();
if (inside_connected_staves) {
if (lptr2 == NULL) {
NedResource::Abort("NedSystem::draw");
}
botp = botp2;
}
else {
botp = botp1;
}
((NedStaff *) lptr1->data)->draw(cr, botp, first_page, indent, &m_freetexts_or_lyrics_present);
}
firststaff = (NedStaff *) g_list_first(m_staffs)->data;
laststaff = (NedStaff *) g_list_last(m_staffs)->data;
if (show_measure_numbers && (m_system_number != 0 || !first_page)) {
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(indent + MEASURE_NUMBER_X_POS), Y_POS(m_ypos + firststaff->getTopPos() + MEASURE_NUMBER_Y_POS));
cairo_select_font_face(cr, "Sans", MEASURE_NUMBER_SLANT, MEASURE_NUMBER_WEIGHT);
cairo_set_font_size(cr, MEASNUMBER_SIZE * zoom_factor);
cairo_show_text(cr, m_measures[0].getNumberString());
cairo_stroke(cr);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(getMainWindow()->getCurrentZoomLevel()));
#endif
}
cairo_new_path(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
#ifdef BADLINEPOLICY
cairo_set_line_width(cr, zoom_factor * STAFF_START_LEFT_THICK);
#else
cairo_set_line_width(cr, zoom_factor * MEASURE_LINE_THICK);
#endif
if (g_list_length(m_staffs) > 1) {
cairo_move_to(cr, X_POS_PAGE_REL(indent),
Y_POS(m_ypos + firststaff->getTopPos() - LINE_THICK / 2.0));
cairo_line_to(cr, X_POS_PAGE_REL(indent),
Y_POS(m_ypos + laststaff->getBottomPos() + LINE_THICK / 2.0));
}
#ifdef BADLINEPOLICY
if (!m_special_measure_at_end) { // i.e there is a key signature at the end
cairo_move_to(cr, X_POS_PAGE_REL(m_width),
Y_POS(m_ypos + firststaff->getTopPos() - LINE_THICK / 2.0));
cairo_line_to(cr, X_POS_PAGE_REL(m_width),
Y_POS(m_ypos + laststaff->getBottomPos() + LINE_THICK / 2.0));
}
#endif
cairo_stroke(cr);
//#define SHOW_MEASURES_END
#ifdef SHOW_MEASURES_END
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * 4 * STEM_THICK);
cairo_move_to(cr, X_POS_PAGE_REL(m_measures[m_measure_count].end), Y_POS(m_ypos + firststaff->getTopPos() - LINE_THICK / 2.0));
cairo_line_to(cr, X_POS_PAGE_REL(m_measures[m_measure_count].end), Y_POS(m_ypos + laststaff->getBottomPos() + LINE_THICK / 2.0));
cairo_stroke(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(m_measures[m_measure_count].end - m_extra_space), Y_POS(m_ypos + firststaff->getTopPos() + 3 * LINE_THICK));
cairo_line_to(cr, X_POS_PAGE_REL(m_measures[m_measure_count].end), Y_POS(m_ypos + firststaff->getTopPos() + 3 * LINE_THICK));
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_stroke(cr);
#endif
for (i = 0; i < getMainWindow()->getStaffCount(); i++) {
staff = (NedStaff *) g_list_nth(m_staffs, i)->data;
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACE_START) != 0) {
brace_start_y_pos = staff->getTopPos();
}
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACE_END) != 0) {
if (brace_start_y_pos >= 0.0) {
drawBrace(cr, leftx, indent - (inside_bracket ? 2 * NESTED_BRACE_INDENT : BRACE_SPACE) , topy, zoom_factor, staff->getBottomPos() - brace_start_y_pos, brace_start_y_pos);
if (first_page) {
if (getMainWindow()->m_staff_contexts[i].m_group_name != NULL) {
m_freetexts_or_lyrics_present = true;
}
}
else if (getMainWindow()->m_staff_contexts[i].m_group_short_name != NULL) {
m_freetexts_or_lyrics_present = true;
}
brace_start_y_pos = -1.0;
}
}
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACKET_START) != 0) {
bracket_start_y_pos = staff->getTopPos();
inside_bracket = true;
}
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACKET_END) != 0) {
if (bracket_start_y_pos >= 0.0) {
drawBracket(cr, leftx, indent, topy, zoom_factor, bracket_start_y_pos, staff->getBottomPos());
if (first_page) {
if (getMainWindow()->m_staff_contexts[i].m_group_name != NULL) {
m_freetexts_or_lyrics_present = true;
}
}
else if (getMainWindow()->m_staff_contexts[i].m_group_short_name != NULL) {
m_freetexts_or_lyrics_present = true;
}
bracket_start_y_pos = -1.0;
}
inside_bracket = false;
}
}
if (m_freetexts_or_lyrics_present) *freetexts_or_lyrics_present = true;
if (m_endMeasure != NULL) {
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, X_POS_PAGE_REL(m_endMeasure->start + REP_THICK_LINE_DIST / 3.0), Y_POS(m_ypos + firststaff->getTopPos() + firststaff->getTopYBorder() - 2 * REP_THICK_LINE_DIST ),
(m_width - (m_endMeasure->start) + (LEFT_RIGHT_BORDER - 2 * DEFAULT_BORDER)) * zoom_factor,
(laststaff->getBottomPos() + laststaff->getBottomYBorder() - (firststaff->getTopPos() + firststaff->getTopYBorder()) + 4 * REP_THICK_LINE_DIST) * zoom_factor);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
};
void NedSystem::drawTexts(cairo_t *cr, bool first_page, double scale) {
double leftx = getMainWindow()->getLeftX();
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
NedStaff *staff;
double brace_start_y_pos = -1.0;
double bracket_start_y_pos = -1.0;
int i;
bool group_written;
if (!m_freetexts_or_lyrics_present) return;
for (i = 0; i < getMainWindow()->getStaffCount(); i++) {
staff = (NedStaff *) g_list_nth(m_staffs, i)->data;
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACE_START) != 0) {
brace_start_y_pos = staff->getTopPos();
}
group_written = false;
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACE_END) != 0) {
if (brace_start_y_pos >= 0.0) {
if (first_page) {
if (getMainWindow()->m_staff_contexts[i].m_group_name != NULL) {
group_written = true;
getMainWindow()->m_staff_contexts[i].m_group_name->draw(cr,
((getPage()->getContentXpos()) * zoom_factor - leftx - BRACE_X_OFFSET) * scale +
(getMainWindow()->getNettoIndent() - getMainWindow()->m_staff_contexts[i].m_group_name->getInternalWidth()),
Y_POS(m_ypos + brace_start_y_pos + (staff->getTopPos() + 4 * LINE_DIST - brace_start_y_pos - LINE_DIST) / 2.0) * scale, zoom_factor, scale);
}
}
else if (getMainWindow()->m_staff_contexts[i].m_group_short_name != NULL) {
group_written = true;
getMainWindow()->m_staff_contexts[i].m_group_short_name->draw(cr,
((getPage()->getContentXpos()) * zoom_factor - leftx - BRACE_X_OFFSET) * scale +
(getMainWindow()->get2ndNettoIndent() - getMainWindow()->m_staff_contexts[i].m_group_short_name->getInternalWidth()),
Y_POS(m_ypos + brace_start_y_pos + (staff->getTopPos() + 4 * LINE_DIST - brace_start_y_pos - LINE_DIST) / 2.0) * scale, zoom_factor, scale);
}
}
}
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACKET_START) != 0) {
bracket_start_y_pos = staff->getTopPos();
}
if ((getMainWindow()->m_staff_contexts[i].m_flags & BRACKET_END) != 0) {
if (bracket_start_y_pos >= 0.0) {
if (!group_written) {
if (first_page) {
if (getMainWindow()->m_staff_contexts[i].m_group_name != NULL) {
getMainWindow()->m_staff_contexts[i].m_group_name->draw(cr,
((getPage()->getContentXpos()) * zoom_factor - leftx) * scale +
(getMainWindow()->getNettoIndent() - getMainWindow()->m_staff_contexts[i].m_group_name->getInternalWidth()),
Y_POS(m_ypos + bracket_start_y_pos + (staff->getTopPos() + 4 * LINE_DIST - bracket_start_y_pos - LINE_DIST) / 2.0) * scale, zoom_factor, scale);
}
}
else if (getMainWindow()->m_staff_contexts[i].m_group_short_name != NULL) {
getMainWindow()->m_staff_contexts[i].m_group_short_name->draw(cr,
((getPage()->getContentXpos()) * zoom_factor - leftx) * scale +
(getMainWindow()->get2ndNettoIndent() - getMainWindow()->m_staff_contexts[i].m_group_short_name->getInternalWidth()),
Y_POS(m_ypos + bracket_start_y_pos + (staff->getTopPos() + 4 * LINE_DIST - bracket_start_y_pos - LINE_DIST) / 2.0) * scale, zoom_factor, scale);
}
bracket_start_y_pos = -1.0;
}
}
}
staff->drawTexts(cr, first_page, scale);
}
};
void NedSystem::drawBrace (cairo_t *cr, double leftx, double indent, double topy, double zoom_factor, double height, double toppos) {
int i;
cairo_new_path(cr);
cairo_set_line_width(cr, 1.0);
#define BRACE_OFFS -0.03
#define BRACE_X_FACTOR 0.004
#define BRACE_Y_FACTOR 0.00106
#define FAKX(a) (BRACE_X_FACTOR * zoom_factor * a)
#define FAKY(a) (BRACE_Y_FACTOR * zoom_factor * a * height)
cairo_move_to(cr, X_POS_PAGE_REL(indent-0.05), Y_POS(m_ypos + toppos + BRACE_OFFS));
for (i = 0; i < 16; i++) {
cairo_rel_curve_to(cr, FAKX(NedResource::m_braceOutline[i][0]), FAKY(NedResource::m_braceOutline[i][1]),
FAKX(NedResource::m_braceOutline[i][2]), FAKY(NedResource::m_braceOutline[i][3]),
FAKX(NedResource::m_braceOutline[i][4]), FAKY(NedResource::m_braceOutline[i][5]));
}
cairo_fill(cr);
}
void NedSystem::drawBracket (cairo_t *cr, double leftx, double indent, double topy, double zoom_factor, double toppos, double botpos) {
int i;
cairo_new_path(cr);
cairo_set_line_width(cr, 1.0);
#define BRACKET_X_OFFS -0.2
#define BRACKET_Y_OFFS 0.1
#define BRACKET_X_FACTOR 0.0008
#define BRACKET_Y_FACTOR 0.0008
#define BRACKET_FAKX(a) (BRACKET_X_FACTOR * zoom_factor * a)
#define BRACKET_FAKY(a) (BRACKET_Y_FACTOR * zoom_factor * a)
#define BRACKET_THICK 0.1
#define BRACKET_LINE_DIST 0.05
cairo_move_to(cr, X_POS_PAGE_REL(indent+BRACKET_X_OFFS), Y_POS(m_ypos + botpos + BRACKET_Y_OFFS));
for (i = 0; i < 5; i++) {
cairo_rel_curve_to(cr, BRACKET_FAKX(NedResource::m_bracketEndOutline[i][0]), BRACKET_FAKY(NedResource::m_bracketEndOutline[i][1]),
BRACKET_FAKX(NedResource::m_bracketEndOutline[i][2]), BRACKET_FAKY(NedResource::m_bracketEndOutline[i][3]),
BRACKET_FAKX(NedResource::m_bracketEndOutline[i][4]), BRACKET_FAKY(NedResource::m_bracketEndOutline[i][5]));
}
cairo_close_path(cr);
cairo_fill(cr);
cairo_new_path(cr);
cairo_move_to(cr, X_POS_PAGE_REL(indent+BRACKET_X_OFFS), Y_POS(m_ypos + toppos - BRACKET_Y_OFFS));
for (i = 0; i < 5; i++) {
cairo_rel_curve_to(cr, BRACKET_FAKX(NedResource::m_bracketEndOutline[i][0]), BRACKET_FAKY(-NedResource::m_bracketEndOutline[i][1]),
BRACKET_FAKX(NedResource::m_bracketEndOutline[i][2]), BRACKET_FAKY(-NedResource::m_bracketEndOutline[i][3]),
BRACKET_FAKX(NedResource::m_bracketEndOutline[i][4]), BRACKET_FAKY(-NedResource::m_bracketEndOutline[i][5]));
}
cairo_close_path(cr);
cairo_fill(cr);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * BRACKET_THICK);
cairo_move_to(cr, X_POS_PAGE_REL(indent+BRACKET_X_OFFS - BRACKET_LINE_DIST), Y_POS(m_ypos + toppos - BRACKET_Y_OFFS));
cairo_line_to(cr, X_POS_PAGE_REL(indent+BRACKET_X_OFFS - BRACKET_LINE_DIST), Y_POS(m_ypos + botpos + BRACKET_Y_OFFS));
cairo_stroke(cr);
}
void NedSystem::empty() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->empty();
}
}
bool NedSystem::hasOnlyRests() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (!((NedStaff *) lptr->data)->hasOnlyRests()) return false;
}
return true;
}
bool NedSystem::trySelect(double x, double y, bool only_free_placeables) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (((NedStaff *) lptr->data)->trySelect(x, y, only_free_placeables)) {
return TRUE;
}
}
return FALSE;
}
NedChordOrRest *NedSystem::findNearestElement(int staff_nr, double x, double y, NedStaff *oldstaff, double *mindist, double *ydist) {
NedChordOrRest *nearestElement = NULL, *element;
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (staff_nr >= 0 && ((NedStaff *) lptr->data)->getStaffNumber() != staff_nr) continue;
if ((element = ((NedStaff *) lptr->data)->findNearestElement(x, y, oldstaff, mindist, ydist)) != NULL) {
nearestElement = element;
}
}
return nearestElement;
}
bool NedSystem::tryChangeLength(NedChordOrRest *chord_or_rest) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (((NedStaff *) lptr->data)->tryChangeLength(chord_or_rest)) {
return TRUE;
}
}
return FALSE;
}
double NedSystem::computeMidDist(double y) {
double tp, bt;
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
tp = Y_POS(m_ypos + ((NedStaff *) g_list_first(m_staffs)->data)->getTopPos());
bt = Y_POS(m_ypos + ((NedStaff *) g_list_last(m_staffs)->data)->getBottomPos());
y /= getMainWindow()->getCurrentScale();
if (y < tp) {
return tp - y;
}
if (y > bt) {
return y - bt;
}
return 0.0;
}
bool NedSystem::testLineOverflow() {
compute_extra_space(false);
//do_reposit(false);
return m_extra_space < MINIMUM_EXTRA_SPACE && m_measure_count > 1;
}
void NedSystem::removeLastImported() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->removeLastImported();
}
m_measure_count--;
}
bool NedSystem::truncateAtStart(NedCommandList *command_list, unsigned long long midi_time) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (!((NedStaff *) lptr->data)->truncateAtStart(command_list, midi_time)) return false;
}
return true;
}
bool NedSystem::handleImportedTuplets() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (!((NedStaff *) lptr->data)->handleImportedTuplets()) return false;
}
return true;
}
void NedSystem::prepareForImport() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->prepareForImport();
}
}
void NedSystem::appendElementsOfMeasureLength(part *parts, unsigned int meas_duration, int meas_num) {
NedStaff *staff;
part *part_ptr;
int i;
GList *lptr;
for (i = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
staff = (NedStaff *) lptr->data;
part_ptr = &(parts[i]);
staff->appendElementsOfMeasureLength(part_ptr, meas_duration, meas_num);
}
}
void NedSystem::copyDataOfWholeStaff(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::copyDataOfWholeStaff");
}
((NedStaff *) lptr->data)->copyDataOfWholeStaff();
}
void NedSystem::handleStaffElements() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->handleStaffElements();
}
}
void NedSystem::setInternalPitches() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->setInternalPitches();
}
}
void NedSystem::adjustAccidentals(int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::adjustAccidentals");
}
((NedStaff *) lptr->data)->adjustAccidentals();
}
void NedSystem::changeAccidentals(NedCommandList *command_list, int preferred_offs, bool *staff_list, GList *selected_group) {
GList *lptr;
int i;
for (i = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
if (!staff_list[i]) continue;
((NedStaff *) lptr->data)->changeAccidentals(command_list, preferred_offs, selected_group);
}
}
void NedSystem::transpose(int pitchdist, bool *staff_list, GList *selected_group) {
GList *lptr;
int i;
for (i = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
if (!staff_list[i]) continue;
((NedStaff *) lptr->data)->transpose(pitchdist, selected_group);
}
}
void NedSystem::hideRests(NedCommandList *command_list, bool unhide, int staff_nr, int voice_nr) {
GList *lptr;
if (staff_nr < 0) {
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->hideRests(command_list, unhide, voice_nr);
}
return;
}
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::hideRests");
}
((NedStaff *) lptr->data)->hideRests(command_list, unhide, voice_nr);
}
bool NedSystem::shiftNotes(unsigned long long start_time, int linedist, int staff_number) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_number)) == NULL) {
NedResource::Abort("NedSystem::shiftNotes");
}
return ((NedStaff *) lptr->data)->shiftNotes(start_time, linedist);
}
void NedSystem::removeUnneededAccidentals(int staff_nr) {
GList *lptr;
if (staff_nr < 0) {
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->removeUnneededAccidentals();
}
}
else {
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::removeUnneededAccidentals");
}
((NedStaff *) lptr->data)->removeUnneededAccidentals();
}
}
bool NedSystem::tryInsertOrErease(double x, double y, int num_midi_input_notes, int *midi_input_chord /* given if insert from midikeyboard */, NedChordOrRest **newObj, bool force_rest) {
GList *lptr;
double mindist, d;
lptr = g_list_first(m_staffs);
NedStaff *nearest_staff = (NedStaff *) lptr->data;
mindist = nearest_staff->computeMidDist(y);
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if ((d = ((NedStaff *) lptr->data)->computeMidDist(y)) < mindist) {
nearest_staff = (NedStaff *) lptr->data;
mindist = d;
}
}
if (nearest_staff->tryInsertOrErease(x, y, num_midi_input_notes, midi_input_chord, newObj, force_rest)) {
return true;
}
return false;
}
bool NedSystem::findLine(double x, double y, double *ypos, int *line, double *bottom, NedStaff **staff) {
GList *lptr;
double mindist, d;
lptr = g_list_first(m_staffs);
NedStaff *nearest_staff = (NedStaff *) lptr->data;
mindist = nearest_staff->computeMidDist(y);
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if ((d = ((NedStaff *) lptr->data)->computeMidDist(y)) < mindist) {
nearest_staff = (NedStaff *) lptr->data;
mindist = d;
}
}
if (nearest_staff->findLine(x, y, ypos, line, bottom)) {
*staff = nearest_staff;
return TRUE;
}
return FALSE;
}
bool NedSystem::findElement(guint keyval, double x, double y, NedChordOrRest **element, NedStaff **staff) {
double leftx = getMainWindow()->getLeftX();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
int i;
double dummy1, dummy3;
int dummy2;
double xx;
if (!findLine(x, y, &dummy1, &dummy2, &dummy3, staff) ) return FALSE;
xx = X_POS_PAGE_REL_INVERSE(x);
switch(keyval) {
case GDK_Right:
for (i = 0; i < m_measure_count; i++) {
if (m_measures[i].start <= xx && m_measures[i].end >= xx) {
return (*staff)->findFirstElementeGreaterThan(m_measures[i].end, element);
}
}
return false;
case GDK_Left:
for (i = m_measure_count - 1; i >= 0; i--) {
if (m_measures[i].start <= xx && m_measures[i].end >= xx) {
return (*staff)->findLastElementeLessThan(m_measures[i].start, element);
}
}
return false;
}
return false;
}
NedStaff *NedSystem::findStaff(double x, double y, NedMeasure **measure) {
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
double topy = getMainWindow()->getTopY();
double current_scale = getMainWindow()->getCurrentScale();
double yl = Y_POS_INVERSE(y) - m_ypos;
int i;
GList *lptr;
x -= getPage()->getContentXpos();
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (((NedStaff *) lptr->data)->getTopPos() < yl && ((NedStaff *) lptr->data)->getBottomPos() > yl) {
for (i = 0; i <= m_measure_count; i++) {
if (m_measures[i].isNearStart(x)) {
*measure = &(m_measures[i]);
}
}
return (NedStaff *) lptr->data;
}
}
return NULL;
}
void NedSystem::appendStaff(NedCommandList *command_list, int p_staff_nr /* = -1 */) {
NedStaff *staff;
int staff_nr;
if (p_staff_nr < 0) {
staff_nr = g_list_length(m_staffs);
}
else {
staff_nr = p_staff_nr;
}
staff = new NedStaff(this, 10.0 /* dummy */, m_width, staff_nr, TRUE);
if (getMainWindow()->getUpBeatInverse() > 0 && m_page->getPageNumber() == 0 && m_system_number == 0) {
staff->setUpbeatRests(getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator() - getMainWindow()->getUpBeatInverse());
staff->appendAppropriateWholes(1);
}
else {
staff->appendAppropriateWholes(0);
}
command_list->addCommand(new NedAppendStaffCommand(this, staff));
}
NedChordOrRest *NedSystem::getFirstObjectInNextSystem(int staff_nr) {
NedSystem *system;
GList *lptr;
if ((system = m_page->getNextSystem(this)) == NULL) return NULL;
if ((lptr = g_list_nth(system->m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::getFirstObjectInNextSystem");
}
lptr = ((NedStaff *) lptr->data)->getFirstChordOrRest(0, 0, false, false);
if (lptr == NULL) return NULL;
return (NedChordOrRest *) lptr->data;
}
void NedSystem::do_append_staff(NedStaff *staff) {
m_staffs = g_list_append(m_staffs, staff);
}
void NedSystem::do_remove_staff(NedStaff *staff) {
GList *lptr;
if ((lptr = g_list_find(m_staffs, staff)) == NULL) {
NedResource::Abort("NedSystem::do_remove_staff");
}
m_staffs = g_list_delete_link(m_staffs, lptr);
}
void NedSystem::cutEmptyVoices() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->cutEmptyVoices();
}
}
void NedSystem::handleEmptyMeasures() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->handleEmptyMeasures();
}
}
void NedSystem::zoomFreeReplaceables(double zoom, double scale) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->zoomFreeReplaceables(zoom, scale);
}
}
void NedSystem::recomputeFreeReplaceables() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->recomputeFreeReplaceables();
}
}
void NedSystem::testTies() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->testTies();
}
}
void NedSystem::removeLastStaff() {
GList *lptr;
NedStaff *staff;
if (g_list_length(m_staffs) < 2) {
NedResource::Abort("NedSystem::removeLastStaff");
}
lptr = g_list_last(m_staffs);
staff = (NedStaff *) lptr->data;
delete staff;
m_staffs = g_list_delete_link(m_staffs, lptr);
}
void NedSystem::deleteStaff(int staff_number) {
GList *lptr;
NedStaff *staff;
int i;
if ((lptr = g_list_nth(m_staffs, staff_number)) == NULL) {
NedResource::Abort("NedSystem::deleteStaff");
}
staff = (NedStaff *) lptr->data;
m_staffs = g_list_delete_link(m_staffs, lptr);
m_deleted_staffs = g_list_append(m_deleted_staffs, staff);
for (i = 0, lptr = g_list_first(m_staffs); lptr; i++, lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->setStaffNumber(i);
}
}
void NedSystem::restoreStaff(int staff_number) {
GList *lptr;
NedStaff *staff;
int pos, i;
if ((lptr = g_list_last(m_deleted_staffs)) == NULL) {
NedResource::Abort("NedSystem::restoreStaff");
}
staff = (NedStaff *) lptr->data;
m_deleted_staffs = g_list_delete_link(m_deleted_staffs, lptr);
pos = staff->getStaffNumber();
if (pos != staff_number) {
NedResource::Abort("NedSystem::restoreStaff: pos != staff_number");
}
m_staffs = g_list_insert(m_staffs, staff, pos);
for (i = 0, lptr = g_list_first(m_staffs); lptr; i++, lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->setStaffNumber(i);
}
}
void NedSystem::shiftStaff(int staff_number, unsigned int position) {
GList *lptr;
NedStaff *staff;
int i;
if (position > g_list_length(m_staffs)) {
NedResource::Abort("NedSystem::shiftStaff(1)");
}
if ((lptr = g_list_nth(m_staffs, staff_number)) == NULL) {
NedResource::Abort("NedSystem::shiftStaff(2)");
}
staff = (NedStaff *) lptr->data;
m_staffs = g_list_delete_link(m_staffs, lptr);
m_staffs = g_list_insert(m_staffs, staff, position);
for (i = 0, lptr = g_list_first(m_staffs); lptr; i++, lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->setStaffNumber(i);
}
}
bool NedSystem::reposit(int measure_number, NedCommandList *command_list /* = NULL */, NedSystem **next_system /* = NULL */) {
GList *lptr;
NedSystem *other_system;
int newnum, i;
unsigned long long midi_time = 0;
unsigned int meas_duration;
bool use_upbeat = (m_system_number == 0 && m_page->getPageNumber() == 0);
int critical_measure;
//bool changed = false;
//bool out = (m_system_number == 6 && m_page->getPageNumber() == 2);
if (next_system != NULL) *next_system = m_page->getNextSystem(this);
if (m_is_positioned) {
return false;
}
if (measure_number < 0) {
measure_number = m_measures[0].getMeasureNumber();
}
for (i = 0; i < MAX_MEASURES; i++) {
m_measures[i].midi_start = midi_time;
meas_duration = getMainWindow()->getMeasureDuration(measure_number);
m_measures[i].setMeasureNumber(measure_number++, getMainWindow()->m_special_measures /* friend !! */, true);
if (!m_measures[i].m_special_spread) {
m_measures[i].m_spread_fac = getMainWindow()->getGlopabSpreadFac();
}
midi_time += meas_duration;
m_measures[i].midi_end = midi_time;
}
if (command_list == NULL) {
do_reposit(use_upbeat);
return false;
}
compute_extra_space(use_upbeat);
//do_reposit(use_upbeat);
m_check_line_compression = true;
if (m_extra_space < MINIMUM_EXTRA_SPACE && m_measure_count > 1) {
//printf("pag: %d sys: %d: m_extra_space(%f) < MINIMUM_EXTRA_SPACE (%f)reposit\n", m_page->getPageNumber(), m_system_number, m_extra_space, MINIMUM_EXTRA_SPACE); fflush(stdout);
m_check_line_compression = FALSE;
//critical_measure = m_special_measure_at_end ? m_measure_count-2 : m_measure_count-1;
critical_measure = m_measure_count-1;
//int xx = 0;
NedClipBoard *board = new NedClipBoard();
if (m_measures[critical_measure].m_measure_has_only_staff_members) critical_measure--;
board->setRefTimeAndDuration(m_measures[critical_measure].midi_start, m_measures[critical_measure].midi_end - m_measures[critical_measure].midi_start);
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->collectChordsAndRests(board, m_measures[critical_measure].midi_start, m_measures[critical_measure].midi_end);
}
if ((board->onlyWholeRests() && m_page->isLastSystem(this))) {
board->setDeleteOnly();
other_system = NULL;
}
else {
other_system = m_page->getNextSystem(this, command_list);
if (next_system != NULL) *next_system = other_system;
}
//changed = true;
newnum = m_measures[m_measure_count-1].getMeasureNumber();
if (other_system != NULL) {
other_system->collectDestinationVoices(board);
// Do not add this because if unexecute the syszem is already deleted command_list->addSystemForRepositioning(other_system);
compute_extra_space(use_upbeat);
//do_reposit(use_upbeat);
newnum = m_measures[m_measure_count-1].getMeasureNumber() + 1;
other_system->m_is_positioned = false;
if (other_system != NULL && getMainWindow()->m_start_measure_number_for_renumbering > newnum) {
getMainWindow()->m_start_system_for_renumbering = other_system;
getMainWindow()->m_start_measure_number_for_renumbering = newnum;
}
}
NedMoveChordsAndRestsCommand *command = new NedMoveChordsAndRestsCommand(board);
command_list->addCommand(command);
command->execute();
}
if (m_check_line_compression && m_extra_space > MAXIMUM_EXTRA_SPACE) {
//printf("pag: %d sys: %d : m_extra_space(%f) > MAXIMUM_EXTRA_SPACE (%f)reposit\n", m_page->getPageNumber(), m_system_number, m_extra_space, MAXIMUM_EXTRA_SPACE); fflush(stdout);
if ((other_system = m_page->getNextSystem(this)) != NULL) {
NedClipBoard *board = new NedClipBoard();
if (other_system->collectFirstMeasure(board, getMainWindow()->getMeasureDuration(m_measures[m_measure_count].getMeasureNumber()), getSystemEndTime())) {
collectDestinationVoices(board);
if (board->onlyWholeRests() && m_page->isLastSystem(this)) {
board->setInsertOnly();
}
board->execute_reverse();
compute_extra_space(use_upbeat);
//do_reposit(use_upbeat);
if (m_extra_space < MINIMUM_EXTRA_SPACE) {
board->unexecute_reverse();
compute_extra_space(use_upbeat);
//do_reposit(use_upbeat);
other_system->do_reposit(false); // the ping-pong elements have bad x position
m_check_line_compression = false;
}
else {
//board->unexecute_reverse();
NedMoveChordsAndRestsReverseCommand *command = new NedMoveChordsAndRestsReverseCommand(board);
for (lptr = g_list_first(other_system->m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->assignMidiTimes();
}
//changed = true;
command_list->addCommand(command);
//command->execute(); do not execut because is already done
command_list->addSystemForRepositioning(other_system);
if (board->onlyWholeRests() && m_page->isLastSystem(this)) {
board->setInsertOnly();
}
compute_extra_space(use_upbeat);
//do_reposit(use_upbeat);
newnum = m_measures[0].getMeasureNumber();
if (other_system != NULL && getMainWindow()->m_start_measure_number_for_renumbering > newnum) {
getMainWindow()->m_start_system_for_renumbering = this;
getMainWindow()->m_start_measure_number_for_renumbering = newnum;
}
}
}
else {
m_check_line_compression = FALSE;
}
other_system->m_is_positioned = false;
}
else {
m_check_line_compression = FALSE;
if (command_list != NULL) {
fill_up(command_list);
}
}
}
do_reposit(use_upbeat);
m_is_positioned = (m_extra_space >= MINIMUM_EXTRA_SPACE || m_measure_count < 2) && (!m_check_line_compression || m_extra_space <= MAXIMUM_EXTRA_SPACE);
/*
if (out) {
printf("raus mit %d, m_extra_space >= MINIMUM_EXTRA_SPACE = %d, m_measure_count = %d, m_check_line_compression = %d, m_extra_space <= MAXIMUM_EXTRA_SPACE = %d\n",
!m_is_positioned, m_extra_space >= MINIMUM_EXTRA_SPACE, m_measure_count, m_check_line_compression , m_extra_space <= MAXIMUM_EXTRA_SPACE ); fflush(stdout);
}
*/
return !m_is_positioned;
}
bool NedSystem::findTimeOfMeasure(int meas_num, unsigned long long *meas_time) {
int i;
for (i = 0; i < m_measure_count; i++) {
if (m_measures[i].getMeasureNumber() == meas_num) {
*meas_time = m_measures[i].midi_start;
return true;
}
}
return false;
}
void NedSystem::renumberMeasures(int *measure_number, GList *special_measures, bool force) {
int i;
for (i = 0; i <= m_measure_count; i++) {
m_measures[i].setMeasureNumber((*measure_number)++, special_measures, force);
}
(*measure_number)--;
}
void NedSystem::setNewMeasureSpread(double spread) {
for (int i = 0; i < MAX_MEASURES; i++) {
m_measures[i].m_spread_fac = spread;
m_measures[i].m_special_spread = false;
}
}
int NedSystem::getNumberOfFirstMeasure() {
return m_measures[0].getMeasureNumber();
}
int NedSystem::getNumberOfLastMeasure() {
return m_measures[m_measure_count - 1].getMeasureNumber();
}
unsigned long long NedSystem::getSystemEndTime() {
return m_measures[m_measure_count - 1].midi_end;
}
double NedSystem::placeStaffs(double staffpos) {
#define SYSTEM_MIN_DIST 0.08
GList *lptr;
m_ypos = staffpos;
double yy = 0.0;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
yy = ((NedStaff *) lptr->data)->placeStaff(yy);
}
return yy + m_ypos + SYSTEM_MIN_DIST;
}
bool NedSystem::collectFirstMeasure(NedClipBoard *board, unsigned long long length_of_first_measure, unsigned long long length_of_previous_system) {
GList *lptr;
if (m_measure_count < 2) return FALSE;
m_measures[0].midi_start = 0;
m_measures[0].midi_end = length_of_first_measure; // preliminary times importatnt is the correct duration. Under some circumstances
// collectFirstMeasure is called before the measure got their time
board->setRefTimeAndDuration(length_of_previous_system, m_measures[0].midi_end);
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->collectChordsAndRests(board, m_measures[0].midi_start, m_measures[0].midi_end);
}
return TRUE;
}
void NedSystem::collectSelectionRectangleElements(double xp, NedBbox *sel_rect, GList **sel_group,
NedSystem *first_selected_system, NedSystem *last_selected_system,
bool is_first_selected_page, bool is_last_selected_page) {
GList *lptr;
NedStaff *firststaff, *laststaff;
firststaff = (NedStaff *) g_list_first(m_staffs)->data;
laststaff = (NedStaff *) g_list_last(m_staffs)->data;
double yp = firststaff->getTopPos() + firststaff->getTopYBorder() + m_ypos;
if (is_last_selected_page && sel_rect->y + sel_rect->height < yp) return;
if (is_first_selected_page && m_ypos + laststaff->getBottomPos() < sel_rect->y) return;
yp = sel_rect->y - m_ypos;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->collectSelectionRectangleElements(xp, yp, sel_rect, sel_group,
is_first_selected_page && (first_selected_system == this), is_last_selected_page && (last_selected_system == this));
}
}
void NedSystem::findSelectedSystems(NedBbox *sel_rect, int *number_of_first_selected_staff,
int *number_of_last_selected_staff, NedSystem **first_selected_system, NedSystem **last_selected_system) {
GList *lptr;
NedStaff *firststaff, *laststaff;
firststaff = (NedStaff *) g_list_first(m_staffs)->data;
laststaff = (NedStaff *) g_list_last(m_staffs)->data;
double yp = firststaff->getTopPos() + m_ypos;
if (sel_rect->y + sel_rect->height < yp || yp + laststaff->getBottomPos() - firststaff->getTopPos() < sel_rect->y) return;
if (*first_selected_system == NULL) {
*first_selected_system = *last_selected_system = this;
}
else {
*last_selected_system = this;
}
if (first_selected_system == last_selected_system) {
*number_of_first_selected_staff = 0;
*number_of_last_selected_staff = g_list_length(m_staffs) - 1;
}
else {
double yp = sel_rect->y - m_ypos;
/*
if (m_page->getPageNumber() == 0) {
printf("yp = %f, m_ypos = %f, m_ypos + 4 * LINE_DIST = %f\n", yp, m_ypos, m_ypos + 4 * LINE_DIST); fflush(stdout);
}
*/
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->findSelectedStaffs(yp, sel_rect, number_of_first_selected_staff, number_of_last_selected_staff);
}
}
}
void NedSystem::setAndUpdateClefTypeAndKeySig(int *clef_and_key_array, double indent, bool first) {
GList *lptr;
m_system_start = CLEF_SPACE;
if (getMainWindow()->isTimsigChangingMeasure(getNumberOfFirstMeasure())) {
m_system_start += SIG_X_SHIFT;
}
if (first) {
m_system_start += TIME_SIGNATURE_SPACE;
}
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->setAndUpdateClefTypeAndKeySig(clef_and_key_array, first);
}
m_system_start += indent; // do this here because otherwise the staves
// do not update m_system_start correctly
}
void NedSystem::determineTempoInverse(NedChordOrRest *element, unsigned long long till, double *tempoinverse, bool *found) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->determineTempoInverse(element, till, tempoinverse, found);
}
}
GList *NedSystem::getFirstChordOrRest(int staff_nr, int voice_nr, int lyrics_line, bool lyrics_required, bool note_required) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("getFirstChordOrRest");
}
return ((NedStaff *) lptr->data)->getFirstChordOrRest(voice_nr, lyrics_line, lyrics_required, note_required);
}
GList *NedSystem::getLastChordOrRest(int staff_nr, int voice_nr, int lyrics_line, bool lyrics_required, bool note_required) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("getFirstChordOrRest");
}
return ((NedStaff *) lptr->data)->getLastChordOrRest(voice_nr, lyrics_line, lyrics_required, note_required);
}
bool NedSystem::hasTupletConflict(unsigned int meas_duration, GList **elements, int from_staff, int to_staff, unsigned long long start_midi_time) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, to_staff)) == NULL) {
NedResource::Abort("NedSystem::hasTupletConflict");
}
return ((NedStaff *) lptr->data)->hasTupletConflict(meas_duration, elements, from_staff, start_midi_time);
}
void NedSystem::pasteElements(NedCommandList *command_list, GList **elements, int from_staff, int to_staff, unsigned long long start_midi_time) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, to_staff)) == NULL) {
NedResource::Abort("NedSystem::pasteElements");
}
((NedStaff *) lptr->data)->pasteElements(command_list, elements, from_staff, start_midi_time);
}
bool NedSystem::findFromTo(GList *clipboard, NedSystem **min_sys, NedSystem **max_sys) {
GList *lptr;
bool found = FALSE;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
if (((NedStaff *) lptr->data)->findFromTo(clipboard)) {
found = TRUE;
if (*min_sys == NULL) {
*min_sys = *max_sys = this;
}
else {
*max_sys = this;
}
}
}
return found;
}
bool NedSystem::findStartMeasureLimits(GList *clipboard, unsigned long long *start_midi) {
GList *lptr;
bool found = FALSE, fnd;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
fnd = ((NedStaff *) lptr->data)->findStartMeasureLimits(clipboard, start_midi);
found = found || fnd;
}
return found;
}
bool NedSystem::findEndMeasureLimits(GList *clipboard, unsigned long long *end_midi) {
GList *lptr;
bool found = FALSE, fnd;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
fnd = ((NedStaff *) lptr->data)->findEndMeasureLimits(clipboard, end_midi);
found = found || fnd;
}
return found;
}
void NedSystem::deleteItemsFromTo(NedCommandList *command_list, bool is_first, bool is_last, unsigned long long start_midi, unsigned long long end_midi) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->deleteItemsFromTo(command_list, is_first, is_last, start_midi, end_midi);
}
}
void NedSystem::removeNotesFromTo(NedCommandList *command_list, GList *items, bool is_first, bool is_last) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->removeNotesFromTo(command_list, items, is_first, is_last);
}
}
void NedSystem::insertBlocks(NedCommandList *command_list, int blockcount, unsigned long long midi_time) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->insertBlocks(command_list, blockcount, midi_time);
}
}
void NedSystem::checkForElementsToSplit(NedCommandList *command_list, int *measure_number) {
GList *lptr;
int i;
unsigned int meas_duration;
unsigned long long midi_time = 0;
unsigned long long end_time = getSystemEndTime();
for (i = 0; midi_time < end_time && i < MAX_MEASURES; i++) {
m_measures[i].midi_start = midi_time;
meas_duration = getMainWindow()->getMeasureDuration(*measure_number);
m_measures[i].setMeasureNumber((*measure_number)++, getMainWindow()->m_special_measures /* friend !! */, true);
midi_time += meas_duration;
m_measures[i].midi_end = midi_time;
}
m_measure_count = i; // otherwise " NedVoice::checkForElementsToSplit" crashes, because it cannot find the appropriate measure
// if the measure count increases/decreases
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->checkForElementsToSplit(command_list);
}
}
void NedSystem::testForPageBackwardTies(NedCommandList *command_list) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->testForPageBackwardTies(command_list);
}
}
void NedSystem::collectDestinationVoices(NedClipBoard *board) {
GList *lptr;
board->element_counter = g_list_first(board->m_elements);
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->collectDestinationVoices(board);
}
}
void NedSystem::assignMidiTimes() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->assignMidiTimes();
}
}
void NedSystem::do_reposit(bool use_upbeat) {
GList *lptr;
int num_elements;
int i;
double current_position;
double shift;
double extra_space_divided;
double extra_width_at_end;
int new_measure_count;
int grace_positions[MAX_POSITIONS];
double extra_space_for_accidentals;
bool measure_has_only_staff_members;
m_special_measure_at_end = new_measure_count = 0;
if (m_measures[0].getStoredStaffCount() != g_list_length(m_staffs)) {
for (i = 0; i < MAX_MEASURES; i++) {
m_measures[i].m_position_array.setNewStaffCount(g_list_length(m_staffs));
}
}
for (i = 0; i < MAX_MEASURES; i++) {
m_measures[i].m_position_array.empty();
m_measures[i].m_staff_elements_width = 0.0;
}
current_position = m_system_start - m_measures[0].getNeededSpaceAfter();
if (m_measures[0].getSpecial() == REPEAT_OPEN || m_measures[0].getSpecial() == REPEAT_OPEN_CLOSE) {
current_position += m_measures[0].getNeededSpaceAfter();
}
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->assignMidiTimes();
}
memset(grace_positions, 0, sizeof(grace_positions));
for (i = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
new_measure_count = ((NedStaff *) lptr->data)->assignElementsToMeasures(m_measures, VOICE_COUNT * i, use_upbeat, &m_special_measure_at_end, m_system_number == 0);
new_measure_count++;
m_measure_count = new_measure_count;
}
if (m_special_measure_at_end) {
m_measures[m_measure_count+1].m_staff_elements_width = 0.2;
m_measures[m_measure_count+1].m_position_array.empty();
}
if (((m_measures[m_measure_count+m_special_measure_at_end].getSpecial() & REP_TYPE_MASK) == REPEAT_CLOSE) || ((m_measures[m_measure_count+m_special_measure_at_end].getSpecial() & REP_TYPE_MASK) == REPEAT_OPEN_CLOSE) ||
(m_measures[m_measure_count+m_special_measure_at_end].getSpecial() & REP_TYPE_MASK) == END_BAR) {
extra_width_at_end = m_measures[m_measure_count+m_special_measure_at_end].getNeededSpaceBefore();
}
else {
extra_width_at_end = 0.0;
}
num_elements = 0;
extra_space_for_accidentals = 0.0;
current_position = m_measures[0].computeAndSetPositions(current_position, &num_elements, &extra_space_for_accidentals, &measure_has_only_staff_members, false);
if (m_measures[0].getSpecial() & (START_TYPE_MASK | END_TYPE_MASK)) {
}
m_endMeasure = NULL;
m_has_repeat_lines = false;
for (i = 1; i < m_measure_count+m_special_measure_at_end; i++) {
measure_has_only_staff_members = true;
current_position = m_measures[i].computeAndSetPositions(current_position, &num_elements, &extra_space_for_accidentals, &measure_has_only_staff_members, false);
if (m_measures[i].barRequiresHideFollowing()) {
m_endMeasure = &(m_measures[i]);
}
m_measures[i-1].end = m_measures[i].start;
if (m_measures[i].getSpecial() & (START_TYPE_MASK | END_TYPE_MASK)) {
m_has_repeat_lines = true;
}
}
m_measures[i-1].end = m_width - RIGHT_DIST;
if (m_measures[i].getSpecial() & (START_TYPE_MASK | END_TYPE_MASK)) {
m_has_repeat_lines = true;
}
num_elements += m_measure_count+m_special_measure_at_end;
m_extra_space = m_width - current_position - extra_space_for_accidentals - m_measures[m_measure_count+m_special_measure_at_end+1].getNeededSpaceBefore() - RIGHT_DIST - extra_width_at_end;
/*
if (m_page->getPageNumber() == 0 && m_system_number == 0) {
printf("m_extra_space(%f) = m_width(%f) - current_position(%f) - extra_space_for_accidentals(%f) - nb(%f) - RIGHT_DIST(%f)\n",
m_extra_space, m_width, current_position, extra_space_for_accidentals,
m_measures[m_measure_count+m_special_measure_at_end+1].getNeededSpaceBefore(), RIGHT_DIST); fflush(stdout);
}
*/
extra_space_divided = m_extra_space / (num_elements + 2);
shift = 0;
if (extra_space_divided > 0.0) {
for (i = 0; i < m_measure_count+m_special_measure_at_end+1; i++) {
#define BBB
#ifdef BBB
shift = m_measures[i].shiftXpos(extra_space_divided, shift, m_page->getPageNumber() == 0 && m_system_number == 0);
#endif
if (i > 0) {
m_measures[i-1].end = m_measures[i].start;
}
}
}
m_measures[i-2].end = m_measures[i-1].start = m_width - RIGHT_DIST;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->searchForBeamGroups(use_upbeat ? getMainWindow()->getUpBeatInverse() : 0);
((NedStaff *) lptr->data)->computeBeams();
((NedStaff *) lptr->data)->computeTuplets(m_has_repeat_lines);
((NedStaff *) lptr->data)->computeTies();
}
if (m_special_measure_at_end) { /* means last measure consists of only a key signature */
/*
m_measures[i-2].start -= 0.15;
m_measures[i-1].end = m_measures[i-2].start;
*/
}
}
void NedSystem::computeTuplets() {
GList *lptr;
int i;
m_has_repeat_lines = false;
for (i = 0; i < m_measure_count; i++) {
if (m_measures[i].getSpecial() & (START_TYPE_MASK | END_TYPE_MASK)) {
m_has_repeat_lines = true;
}
}
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->computeBeams();
((NedStaff *) lptr->data)->computeTuplets(m_has_repeat_lines);
}
}
void NedSystem::resetActiveFlags() {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->resetActiveFlags();
}
}
void NedSystem::compute_extra_space(bool use_upbeat) {
GList *lptr;
int num_elements;
int i;
double current_position;
double extra_width_at_end;
int new_measure_count;
int grace_positions[MAX_POSITIONS];
double extra_space_for_accidentals;
bool measure_has_only_staff_members;
new_measure_count = 0;
if (m_measures[0].getStoredStaffCount() != g_list_length(m_staffs)) {
for (i = 0; i < MAX_MEASURES; i++) {
m_measures[i].m_position_array.setNewStaffCount(g_list_length(m_staffs));
}
}
for (i = 0; i < MAX_MEASURES; i++) {
m_measures[i].m_position_array.empty();
m_measures[i].m_staff_elements_width = 0.0;
}
current_position = m_system_start - m_measures[0].getNeededSpaceAfter();
if (m_measures[0].getSpecial() == REPEAT_OPEN || m_measures[0].getSpecial() == REPEAT_OPEN_CLOSE) {
current_position += m_measures[0].getNeededSpaceAfter();
}
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->assignMidiTimes();
}
memset(grace_positions, 0, sizeof(grace_positions));
for (i = 0, lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr), i++) {
new_measure_count = ((NedStaff *) lptr->data)->assignElementsToMeasures(m_measures, VOICE_COUNT * i, use_upbeat, &m_special_measure_at_end, m_system_number == 0);
new_measure_count++;
m_measure_count = new_measure_count;
}
if (m_special_measure_at_end) {
m_measures[m_measure_count+1].m_staff_elements_width = 0.2;
m_measures[m_measure_count+1].m_position_array.empty();
}
if (((m_measures[m_measure_count+m_special_measure_at_end].getSpecial() & REP_TYPE_MASK) == REPEAT_CLOSE) || ((m_measures[m_measure_count+m_special_measure_at_end].getSpecial() & REP_TYPE_MASK) == REPEAT_OPEN_CLOSE) ||
(m_measures[m_measure_count+m_special_measure_at_end].getSpecial() & REP_TYPE_MASK) == END_BAR) {
extra_width_at_end = m_measures[m_measure_count+m_special_measure_at_end].getNeededSpaceBefore();
}
else {
extra_width_at_end = 0.0;
}
num_elements = 0;
extra_space_for_accidentals = 0.0;
current_position = m_measures[0].computeAndSetPositions(current_position, &num_elements, &extra_space_for_accidentals, &measure_has_only_staff_members, false);
m_endMeasure = NULL;
for (i = 1; i < m_measure_count+m_special_measure_at_end; i++) {
measure_has_only_staff_members = true;
current_position = m_measures[i].computeAndSetPositions(current_position, &num_elements, &extra_space_for_accidentals, &measure_has_only_staff_members, false);
if (m_measures[i].barRequiresHideFollowing()) {
m_endMeasure = &(m_measures[i]);
}
m_measures[i-1].end = m_measures[i].start;
}
m_measures[i-1].end = m_width - RIGHT_DIST;
num_elements += m_measure_count+m_special_measure_at_end;
m_extra_space = m_width - current_position - extra_space_for_accidentals - m_measures[m_measure_count+m_special_measure_at_end+1].getNeededSpaceBefore() - RIGHT_DIST - extra_width_at_end;
/*
if (m_page->getPageNumber() == 0 && m_system_number == 0) {
printf("m_extra_space(%f) = m_width(%f) - current_position(%f) - extra_space_for_accidentals(%f) - nb(%f) - RIGHT_DIST(%f)\n",
m_extra_space, m_width, current_position, extra_space_for_accidentals,
m_measures[m_measure_count+1].getNeededSpaceBefore(), RIGHT_DIST); fflush(stdout);
}
*/
//if (measure_has_only_staff_members) { /* means last measure consists of only a key signature */
/*
m_measures[i-2].start -= 0.15;
m_measures[i].end = m_measures[i-2].start;
*/
// }
}
unsigned int NedSystem::getWholeMidiLength() {
return m_measure_count * getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
}
NedMeasure *NedSystem::getMeasure(unsigned long long midi_time) {
int i;
for (i = 0; i < m_measure_count; i++) {
if (m_measures[i].midi_start <= midi_time && m_measures[i].midi_end > midi_time) {
return (&(m_measures[i]));
}
}
#ifdef VVV
NedResource::DbgMsg(DBG_TESTING, "pag: %d, sys. %d, midi_time = %llu(%llu, %llu) , m_measures[m_measure_count(%d)].midi_start = %llu(%llu,%llu), m_measures[m_measure_count(%d)].midi_end = %llu(%llu, %llu)\n",
m_page->getPageNumber(), m_system_number,
LAUS(midi_time), m_measure_count, m_measures[m_measure_count].midi_start, m_measure_count, m_measures[m_measure_count].midi_end, NOTE_4);
if (m_measure_count >= 0) {
NedResource::DbgMsg(DBG_TESTING, "m_measures[m_measure_count - 1(%d)].midi_start = %llu, m_measures[m_measure_count - 1(%d)].midi_end = %llu\n",
m_measure_count-1, m_measures[m_measure_count-1].midi_start, m_measure_count-1, m_measures[m_measure_count-1].midi_end);
}
NedResource::Abort("NedSystem::getMeasure");
#endif
return NULL;
}
int NedSystem::getNumberOfStaffs() {
return g_list_length(m_staffs);
}
void NedSystem::prepareReplay(bool with_keysig) {
GList *lptr;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->prepareReplay(with_keysig);
}
}
void NedSystem::setWidth(double w) {
GList *lptr;
m_width = w;
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->setWidth(m_width);
}
}
void NedSystem::saveSystem(FILE *fp) {
int i;
GList *lptr;
fprintf(fp, "SYSTEM %d: %d MEASURES\n", m_system_number, m_measure_count);
for (i = 0; i < m_measure_count; i++) {
fprintf(fp, "MEASURE: %d %f\n", m_measures[i].getMeasureNumber(), m_measures[i].m_spread_fac);
}
for (lptr = g_list_first(m_staffs); lptr; lptr = g_list_next(lptr)) {
((NedStaff *) lptr->data)->saveStaff(fp);
}
}
void NedSystem::restoreSystem(FILE *fp) {
char buffer[128];
int i, measnum, staffnum;
NedStaff *staff;
double staff_pos = 0;
if (!NedResource::readInt(fp, &m_measure_count)) {
NedResource::m_error_message = "Measure count expected";
return;
}
if (m_measure_count < 0 || m_measure_count >= MAX_MEASURES) {
NedResource::m_error_message = "Bad measure count";
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "MEASURES")) {
NedResource::m_error_message = "MEASURES expected";
return;
}
for (i = 0; NedResource::m_error_message == NULL && i < m_measure_count; i++) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "MEASURE")) {
NedResource::m_error_message = "MEASURE expected";
return;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": expected";
return;
}
if (getMainWindow()->getFileVersion() > 14) {
if (!NedResource::readInt(fp, &measnum)) {
NedResource::m_error_message = "measure number expected";
return;
}
}
if (getMainWindow()->getFileVersion() > 9) {
if (!NedResource::readFloat(fp, &(m_measures[i].m_spread_fac))) {
NedResource::m_error_message = "spread factor expected";
return;
}
}
else {
if (!NedResource::readInt(fp, &measnum)) {
NedResource::m_error_message = "MeasureNumber expected";
return;
}
if (i != measnum) {
NedResource::m_error_message = "Bad measure number";
return;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": expected";
return;
}
if (!NedResource::readLong(fp, (unsigned long long *) &(m_measures[i].midi_start))) {
NedResource::m_error_message = "Midi start value expected";
return;
}
if (!NedResource::readLong(fp, (unsigned long long *) &(m_measures[i].midi_end))) {
NedResource::m_error_message = "Midi end value expected";
return;
}
}
}
for (i = 0; NedResource::m_error_message == NULL && i < getMainWindow()->getPreStaffCount(); i++) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "STAFF")) {
NedResource::m_error_message = "STAFF expected(2)";
return;
}
if (!NedResource::readInt(fp, &staffnum)) {
NedResource::m_error_message = "STAFF number expected";
return;
}
if (staffnum != i) {
NedResource::m_error_message = "Bad STAFF number";
return;
}
staff = new NedStaff(this, staff_pos, m_width, i, FALSE);
m_staffs = g_list_append(m_staffs, staff);
staff->restoreStaff(fp);
staff_pos += staff->getHeight() + DEFAULT_SYSTEM_DIST;
}
}
void NedSystem::detectVoices(int staff_nr, unsigned int *voice_mask, NedSystem **last_system, unsigned long long *end_time) {
GList *lptr;
unsigned long long e_time = 0;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::detectVoices");
}
if (((NedStaff *) lptr->data)->detectVoices(voice_mask, &e_time)) {
if (*last_system == NULL) {
*last_system = this;
*end_time = e_time;
}
else if ((*last_system)->m_page->getPageNumber() < m_page->getPageNumber()) {
*last_system = this;
*end_time = e_time;
}
else if ((*last_system)->m_page->getPageNumber() == m_page->getPageNumber() && (*last_system)->m_system_number < m_system_number) {
*last_system = this;
*end_time = e_time;
}
else if ((*last_system)->m_page->getPageNumber() == m_page->getPageNumber() && (*last_system)->m_system_number == m_system_number && *last_system == this) {
if (e_time > *end_time) {
*end_time = e_time;
}
}
}
}
void NedSystem::exportLilyPond(FILE *fp, int staff_nr, int voice_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, NedSlur **lily_slur,
unsigned int *lyrics_map, bool with_break, bool *guitar_chordnames, bool *chordnames, int *breath_script, bool keep_beams) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::exportLilyPond");
}
((NedStaff *) lptr->data)->exportLilyPond(fp, voice_nr, last_line, midi_len, last_system == this, end_time, in_alternative,
lily_slur, lyrics_map, with_break, guitar_chordnames, chordnames, breath_script, keep_beams);
}
void NedSystem::exportLilyGuitarChordnames(FILE *fp, int staff_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, bool with_break) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::exportLilyGuitarChordnames");
}
((NedStaff *) lptr->data)->exportLilyGuitarChordnames(fp, last_line, midi_len, last_system == this, end_time, in_alternative, with_break);
}
void NedSystem::exportLilyFreeChordName(FILE *fp, int staff_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, bool with_break) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::exportLilyFreeChordName");
}
((NedStaff *) lptr->data)->exportLilyFreeChordName(fp, last_line, midi_len, last_system == this, end_time, in_alternative, with_break);
}
void NedSystem::exportLilyLyrics(FILE *fp, bool last_system, int staff_nr, int voice_nr, int line_nr, unsigned long long end_time, int *sil_count) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::exportLilyLyrics");
}
((NedStaff *) lptr->data)->exportLilyLyrics(fp, last_system, voice_nr, line_nr, end_time, sil_count);
}
void NedSystem::collectLyrics(NedLyricsEditor *leditor, int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::collectLyrics");
}
((NedStaff *) lptr->data)->collectLyrics(leditor);
}
void NedSystem::setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor, int staff_nr) {
GList *lptr;
if ((lptr = g_list_nth(m_staffs, staff_nr)) == NULL) {
NedResource::Abort("NedSystem::setLyrics");
}
((NedStaff *) lptr->data)->setLyrics(command_list, leditor);
}
nted-1.10.18/aclocal.m4 0000664 0010410 0000764 00000116547 11520267351 011414 0000000 0000000 # generated automatically by aclocal 1.11.1 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
[m4_warning([this file was generated for autoconf 2.66.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 1 (pkg-config-0.24)
#
# Copyright © 2004 Scott James Remnant .
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
# only at the first occurence in configure.ac, so if the first place
# it's called might be skipped (such as if it is within an "if", you
# have to call PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see .])
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])# PKG_CHECK_MODULES
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.11.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.11.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 9
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 10
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], UPC, [depcc="$UPC" am_compiler_list=],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
msvisualcpp | msvcmsys)
# This compiler won't grok `-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
if depmode=$depmode \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 5
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[{
# Autoconf 2.62 quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 16
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.62])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I."
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
# test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES(OBJC)],
[define([AC_PROG_OBJC],
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
])
_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro
dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
])
dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$_am_arg | $_am_arg:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
*)
install_sh="\${SHELL} $am_aux_dir/install-sh"
esac
fi
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from `make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 6
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check for `mkdir -p'.
AC_DEFUN([AM_PROG_MKDIR_P],
[AC_PREREQ([2.60])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
dnl while keeping a definition of mkdir_p for backward compatibility.
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
dnl Makefile.ins that do not define MKDIR_P, so we do our own
dnl adjustment using top_builddir (which is defined more often than
dnl MKDIR_P).
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
case $mkdir_p in
[[\\/$]]* | ?:[[\\/]]*) ;;
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
esac
])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 5
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
*[[\\\"\#\$\&\'\`$am_lf]]*)
AC_MSG_ERROR([unsafe absolute working directory name]);;
esac
case $srcdir in
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
esac
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t "$srcdir/configure" conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar /dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/gettext.m4])
m4_include([m4/iconv.m4])
m4_include([m4/intlmacosx.m4])
m4_include([m4/lib-ld.m4])
m4_include([m4/lib-link.m4])
m4_include([m4/lib-prefix.m4])
m4_include([m4/nls.m4])
m4_include([m4/po.m4])
m4_include([m4/progtest.m4])
nted-1.10.18/beaming.h 0000664 0010410 0000764 00000005647 11520267230 011321 0000000 0000000 #ifndef BEAM_RULES_H
#define BEAM_RULES_H
#define NUM_BEAM_RULES 71
static struct rule_str {
#define FUNC_BEGIN 1
#define FUNC_END 2
#define END_OF_TABLE 3
int function;
int notelen;
int time_num, time_denom;
int duration;
} beam_rules_tab__[NUM_BEAM_RULES] = {
{ FUNC_END, -1, 3, 2, 23063040},
{ FUNC_END, -1, 3, 2, 46126080},
{ FUNC_END, 2882880, 3, 2, 11531520},
{ FUNC_END, 2882880, 3, 2, 23063040},
{ FUNC_END, 2882880, 3, 2, 34594560},
{ FUNC_END, 2882880, 3, 2, 57657600},
{ FUNC_END, 1441440, 3, 2, 5765760},
{ FUNC_END, 1441440, 3, 2, 11531520},
{ FUNC_END, 1441440, 3, 2, 17297280},
{ FUNC_END, 1441440, 3, 2, 23063040},
{ FUNC_END, 1441440, 3, 2, 28828800},
{ FUNC_END, 1441440, 3, 2, 34594560},
{ FUNC_END, 1441440, 3, 2, 51891840},
{ FUNC_END, 1441440, 3, 2, 57657600},
{ FUNC_END, 1441440, 3, 2, 63423360},
{ FUNC_END, -1, 3, 4, 34594560},
{ FUNC_END, 2882880, 3, 4, 11531520},
{ FUNC_END, 2882880, 3, 4, 23063040},
{ FUNC_END, 1441440, 3, 4, 5765760},
{ FUNC_END, 1441440, 3, 4, 11531520},
{ FUNC_END, 1441440, 3, 4, 17297280},
{ FUNC_END, 1441440, 3, 4, 23063040},
{ FUNC_END, 1441440, 3, 4, 28828800},
{ FUNC_END, -1, 3, 8, 17297280},
{ FUNC_END, -1, 4, 4, 23063040},
{ FUNC_END, 3843840, 4, 4, 11531520},
{ FUNC_END, 3843840, 4, 4, 34594560},
{ FUNC_END, 2882880, 4, 4, 11531520},
{ FUNC_END, 2882880, 4, 4, 34594560},
{ FUNC_END, 1441440, 4, 4, 5765760},
{ FUNC_END, 1441440, 4, 4, 11531520},
{ FUNC_END, 1441440, 4, 4, 17297280},
{ FUNC_END, 1441440, 4, 4, 28828800},
{ FUNC_END, 1441440, 4, 4, 34594560},
{ FUNC_END, 1441440, 4, 4, 40360320},
{ FUNC_END, 1441440, 2, 2, 11531520},
{ FUNC_END, 1441440, 2, 2, 23063040},
{ FUNC_END, 1441440, 2, 2, 34594560},
{ FUNC_END, 2882880, 2, 2, 11531520},
{ FUNC_END, 2882880, 2, 2, 23063040},
{ FUNC_END, 2882880, 2, 2, 34594560},
{ FUNC_END, 5765760, 2, 2, 11531520},
{ FUNC_END, 5765760, 2, 2, 23063040},
{ FUNC_END, 5765760, 2, 2, 34594560},
{ FUNC_END, -1, 2, 4, 11531520},
{ FUNC_END, 1441440, 2, 4, 5765760},
{ FUNC_END, 1441440, 2, 4, 17297280},
{ FUNC_END, -1, 4, 8, 11531520},
{ FUNC_END, 1441440, 4, 8, 5765760},
{ FUNC_END, 1441440, 4, 8, 17297280},
{ FUNC_END, -1, 4, 16, 5765760},
{ FUNC_END, -1, 6, 8, 17297280},
{ FUNC_END, 1441440, 6, 8, 5765760},
{ FUNC_END, 1441440, 6, 8, 11531520},
{ FUNC_END, 1441440, 6, 8, 23063040},
{ FUNC_END, 1441440, 6, 8, 28828800},
{ FUNC_END, -1, 9, 8, 17297280},
{ FUNC_END, -1, 9, 8, 34594560},
{ FUNC_END, 1441440, 9, 8, 5765760},
{ FUNC_END, 1441440, 9, 8, 11531520},
{ FUNC_END, 1441440, 9, 8, 23063040},
{ FUNC_END, 1441440, 9, 8, 28828800},
{ FUNC_END, 1441440, 9, 8, 40360320},
{ FUNC_END, 1441440, 9, 8, 46126080},
{ FUNC_END, 1441440, 9, 8, 51891840},
{ FUNC_END, -1, 12, 8, 17297280},
{ FUNC_END, -1, 12, 8, 34594560},
{ FUNC_END, -1, 12, 8, 51891840},
{ FUNC_END, -1, 12, 8, 92252160},
{ FUNC_END, 1441440, 12, 8, 5765760},
{ END_OF_TABLE, -1, -1, -1, -1}
};
#endif /* BEAM_RULES_H */
nted-1.10.18/mainwindow.cpp 0000664 0010410 0000764 00001305730 11520267230 012423 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
//#define KEYDEBUG
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef CAIRO_HAS_SVG_SURFACE
#include
#endif
#ifdef CAIRO_HAS_PDF_SURFACE
#include
#endif
#include "localization.h"
#include "mainwindow.h"
#include "freereplaceable.h"
#include "page.h"
#include "system.h"
#include "clipboard.h"
#include "chordorrest.h"
#include "note.h"
#include "staff.h"
#include "voice.h"
#include "measure.h"
#include "commandhistory.h"
#include "commandlist.h"
#include "notemovecommand.h"
#include "notemoverelativecommand.h"
#include "changenotestatus.h"
#include "changenotehead.h"
#include "untieforwardcommand.h"
#include "appendnewpagecommand.h"
#include "removelastpagecommand.h"
#include "removepagecommand.h"
#include "deletestaffcommand.h"
#include "deletesystemcommand.h"
#include "clefconfigdialog.h"
#include "staffcontextdialog.h"
#include "lilypondexportdialog.h"
#include "measureconfigdialog.h"
#include "midirecordconfigdialog.h"
#include "drumconfigdialog.h"
#include "appendsystemcommand.h"
#include "spacementdialog.h"
#include "scoreinfodialog.h"
#include "setstaffcontext.h"
#include "keysigdialog.h"
#include "linesdialog.h"
#include "signsdialog.h"
#include "freesign.h"
#include "tupletdialog.h"
#include "printconfigdialog.h"
#include "deletechordcommand.h"
#include "ereasechordorrestcommand.h"
#include "paperconfigdialog.h"
#include "paperconfigcommand.h"
#include "insertnewpagecommand.h"
#include "portchoosedialog.h"
#include "insertblockdialog.h"
#include "shiftstaffcommand.h"
#include "lyricseditor.h"
#include "changemeasuretypecommand.h"
#include "movespecmeasurecommand.h"
#include "changemeasuretimsigcommand.h"
#include "changechordorreststatus.h"
#include "changeupbeatcommand.h"
#include "changetimsigcommand.h"
#include "removestaffelemcommand.h"
#include "removefreeplaceablecommand.h"
#include "fixmovedfreeplaceablecommand.h"
#include "restmovecommand.h"
#include "fixintermediatecommand.h"
#include "changemeasurespread.h"
#include "staffselectdialog.h"
#include "changespacement.h"
#include "changestaffkeysigcmd.h"
#include "changestaffclefcmd.h"
#include "transposecommand.h"
#include "changetie.h"
#include "slurpoint.h"
#include "volumesign.h"
#include "tempodialog.h"
#include "textdialog.h"
#include "chordnamedialog.h"
#include "importer.h"
#include "musicxmlimport.h"
#include "mutedialog.h"
#include "selectordialog.h"
#include "midiimportdialog.h"
#include "chorddialog.h"
#include "scaledialog.h"
#include "chordstruct.h"
#include "linepoint.h"
#include "line3.h"
#include "freetext.h"
#include "midiimporter.h"
#include "midirecorder.h"
#include "pangocairotext.h"
#define SHIFT_ACCEL 3.0
#ifdef WITH_TIME_TEST
#define MIN_TIME_BETWEEN_MOTION 20
#endif
const char *NedMainWindow::guiDescription =
""
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
//" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" "
" "
" "
" "
" "
" "
" "
" "
/*
" "
" " */
" "
" \n"
" \n"
" \n"
" \n"
" \n"
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
#ifdef YELP_PATH
" "
#endif
" "
" "
" "
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" "
" "
" "
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
"";
const GtkActionEntry NedMainWindow::file_entries[] = {
{ "FileMenu", NULL, _("_File") },
{ "OpenRecentMenu", NULL, _("Open_Recent") },
{ "ExportMenu", NULL, _("_Export") },
{ "ViewMenu", NULL, _("_View") },
{ "EditMenu", NULL, _("_Edit") },
{ "ToolsMenu", NULL, _("_Tools") },
{ "SystemLayout", NULL, _("_System layout ...") },
{ "InsertMenu", NULL, _("_Insert") },
{ "UpbeatMenu", NULL, _("_Upbeat ...") },
{ "PrefMenu", NULL, _("_Preferences ...") },
{ "DynamicsMenu", NULL, _("_Dynamics ...") },
{ "LyricsMenu", NULL, _("_Lyrics") },
{ "HelpMenu", NULL, _("_Help") },
{ "config_midi_out", NULL, _("Configure MIDI out..."), NULL, _("configure MIDI output"), G_CALLBACK(config_midi_out) },
{ "config_midi_in", NULL, _("Configure MIDI in..."), NULL, _("configure MIDI input"), G_CALLBACK(config_midi_in) },
{ "config_paper", NULL, _("Configure Paper..."), NULL, _("configure paper"), G_CALLBACK(config_paper) },
{ "config_print_cmd", NULL, _("Configure Print..."), NULL, _("configure print command"), G_CALLBACK(config_print_cmd) },
{ "New", GTK_STOCK_NEW, _("New"), NULL, _("New File"), G_CALLBACK(new_file) },
{ "Open", GTK_STOCK_OPEN, _("Open ..."), "O", _("Open a file"), G_CALLBACK(restore_score) },
{ "Save", GTK_STOCK_SAVE, _("Save ..."), NULL, _("Save a file"), G_CALLBACK(save_score) },
{ "SaveAs", GTK_STOCK_SAVE, _("Save As ..."), NULL, _("Save a file"), G_CALLBACK(save_score_as) },
{ "print_file", GTK_STOCK_PRINT, _("Print"), NULL, _("print file"), G_CALLBACK(print_file) },
{ "import_musicxml", NULL, _("Import MusicXML ..."), NULL, _("import a musicxml file"), G_CALLBACK(import_musicxml) },
{ "import_midi", NULL, _("Import MIDI..."), NULL, _("import a midi file"), G_CALLBACK(import_midi) },
{ "import_midi2", NULL, _("Import MIDI(2)..."), NULL, _("import a midi file(2)"), G_CALLBACK(import_midi2) },
{ "copy", GTK_STOCK_COPY, _("Copy"), "C", _("copy - Ctrl + C"), G_CALLBACK(copy_data) },
{ "paste", GTK_STOCK_PASTE, _("Paste"), "V", _("paste - Ctrl + V"), G_CALLBACK(paste_data) },
{ "delete_block", NULL, _("Delete block"), "X", _("delete block - Ctrl + X"), G_CALLBACK(delete_block) },
{ "append_system", NULL, _("append a system at end"), "B", _("append system - Ctrl + B"), G_CALLBACK(append_system) },
{ "insert_block", NULL, _("Insert block"), NULL, _("insert block"), G_CALLBACK(insert_block) },
{ "insert_clef", NULL, _("Insert clef ..."), NULL, _("insert a clef"), G_CALLBACK(insert_clef) },
{ "empty_block", NULL, _("Empty block"), "E", _("empty block - Ctrl + E"), G_CALLBACK(empty_block) },
{ "reposit_all", NULL, _("reposit all"), "T", _("reposit the whole score - Ctrl + T"), G_CALLBACK(reposit_all) },
{ "export_midi", NULL, _("Export MIDI ..."), NULL, _("export a midi file"), G_CALLBACK(export_midi) },
{ "export_lily", NULL, _("Export LilyPond ..."), NULL, _("LilyPond export"), G_CALLBACK(export_lily) },
#ifdef CAIRO_HAS_PDF_SURFACE
{ "write_pdf", NULL, _("Export PDF ..."), NULL, _("export PDF"), G_CALLBACK(write_pdf) },
#endif
{ "write_png", NULL, _("Export P_NG ..."), NULL, _("Write a png image"), G_CALLBACK(write_png) },
#ifdef CAIRO_HAS_SVG_SURFACE
{ "write_svg", NULL, _("Export S_VG ..."), NULL, _("Write an svg image"), G_CALLBACK(write_svg) },
#endif
{ "write_ps_action", NULL, _("Export P_S ..."), NULL, _("Write PostScript"), G_CALLBACK(write_ps) },
{ "new_window", NULL, _("New Window"), NULL, _("Open a new window"), G_CALLBACK(new_window) },
{ "excerpt", NULL, _("Excerpt ..."), NULL, _("Make an excerpt of the score"), G_CALLBACK(create_excerpt) },
{ "close_window", NULL, _("Close Window"), NULL, _("Close current window"), G_CALLBACK(close_window) },
/* { "append_page", NULL, _("Append page"), NULL, _("append an empty page"), G_CALLBACK(append_page) },
{ "insert_page", NULL, _("Insert page"), NULL, _("insert an empty page"), G_CALLBACK(insert_page) }, */
{ "remove_page", NULL, _("Remove last page"), NULL, _("remove the last page"), G_CALLBACK(remove_page) },
{ "remove_empty_pages", NULL, _("Remove empty pages"), NULL, _("remove empty pages at end"), G_CALLBACK(remove_empty_pages) },
{ "change_spacement", NULL, _("Change spacement ..."), NULL, _("change the horizontal spacement"), G_CALLBACK(change_spacement) },
{ "change_scale", NULL, _("Change Scale ..."), NULL, _("change scale"), G_CALLBACK(change_scale) },
{ "config_record", NULL, _("Configure Record ..."), NULL, _("configure record"), G_CALLBACK(config_record) },
{ "config_drums", NULL, _("Configure Drums ..."), NULL, _("configure drums"), G_CALLBACK(config_drums) },
{ "toolbox", "tool-icon", _("Tools ..."), NULL, _("Tools "), G_CALLBACK(popup_tools) },
{ "set_upbeat_measure", NULL, _("give first measure"), NULL, _("set upbeat by giving the start of first full measure"), G_CALLBACK(set_upbeat_measure) },
{ "set_upbeat_start", NULL, _("give start"), NULL, _("set upbeat by giving the start of the score"), G_CALLBACK(set_upbeat_start) },
{ "score_info", NULL, _("Score info ..."), NULL, _("edit score info"), G_CALLBACK(edit_score_info) },
{ "insert_keysig", NULL, _("Insert keysig ... "), NULL, _("insert a key signature"), G_CALLBACK(insert_keysig) },
{ "insert_lines", NULL, _("Insert lines ... "), NULL, _("insert a horizontal line"), G_CALLBACK(insert_lines) },
{ "insert_signs", NULL, _("Insert sign ... "), NULL, _("insert a free placeable sign"), G_CALLBACK(insert_signs) },
{ "insert_slur", NULL, _("Slur"), "h", _("insert a slur - Ctrl+H"), G_CALLBACK(insert_slur) },
{ "insert_chord", NULL, _("chord ..."), NULL , _("insert a chord"), G_CALLBACK(insert_chord) },
{ "insert_chord_name", NULL, _("chordname ..."), NULL , _("insert a chordname"), G_CALLBACK(insert_chord_name) },
{ "insert_spacer", NULL, _("spacer"), NULL , _("insert a staff spacer"), G_CALLBACK(insert_spacer) },
{ "append_staff", NULL, _("Append staff"), "a", _("append a new staff"), G_CALLBACK(append_staff) },
{ "import_recorded", NULL, _("Import recorded"), NULL, _("import recorded staff"), G_CALLBACK(importRecorded) },
{ "lyrics_editor", NULL, _("Lyrics editor ..."), NULL, _("edit lyrics in text editor"), G_CALLBACK(lyrics_editor) },
{ "dyn_ppp", NULL, _("ppp"), NULL, _("insert ppp"), G_CALLBACK(insert_ppp)},
{ "dyn_pp", NULL, _("pp"), NULL, _("insert pp"), G_CALLBACK(insert_pp)},
{ "dyn_p", NULL, _("p"), NULL, _("insert p"), G_CALLBACK(insert_p)},
{ "dyn_mp", NULL, _("mp"), NULL, _("insert mp"), G_CALLBACK(insert_mp)},
{ "dyn_sp", NULL, _("sp"), NULL, _("insert sp"), G_CALLBACK(insert_sp)},
{ "dyn_mf", NULL, _("mf"), NULL, _("insert mf"), G_CALLBACK(insert_mf)},
{ "dyn_sf", NULL, _("sf"), NULL, _("insert sf"), G_CALLBACK(insert_sf)},
{ "dyn_f", NULL, _("f"), NULL, _("insert f"), G_CALLBACK(insert_f)},
{ "dyn_ff", NULL, _("ff"), NULL, _("insert ff"), G_CALLBACK(insert_ff)},
{ "dyn_fff", NULL, _("fff"), NULL, _("insert fff"), G_CALLBACK(insert_fff)},
{ "insert_tempo", NULL, _("tempo ..."), NULL, _("insert tempo"), G_CALLBACK(insert_tempo)},
{ "insert_text", NULL, _("Text ..."), NULL, _("insert text"), G_CALLBACK(insert_text)},
{ "insert_accelerato", NULL, _("accelerando"), NULL, _("insert accelerando"), G_CALLBACK(insert_accelerando)},
{ "insert_ritardando", NULL, _("ritardando"), NULL, _("insert ritardando"), G_CALLBACK(insert_ritardando)},
{ "lyrics_mode1", NULL, _("lyrics1"), NULL, _("insert lyrics at line 1"), G_CALLBACK(set_lyrics_mode1)},
{ "lyrics_mode2", NULL, _("lyrics2"), NULL, _("insert lyrics at line 2"), G_CALLBACK(set_lyrics_mode2)},
{ "lyrics_mode3", NULL, _("lyrics3"), NULL, _("insert lyrics at line 3"), G_CALLBACK(set_lyrics_mode3)},
{ "lyrics_mode4", NULL, _("lyrics4"), NULL, _("insert lyrics at line 4"), G_CALLBACK(set_lyrics_mode4)},
{ "lyrics_mode5", NULL, _("lyrics5"), NULL, _("insert lyrics at line 5"), G_CALLBACK(set_lyrics_mode5)},
{ "insert_tuplet", NULL, _("Insert tuplet ..."), NULL, _("insert a tuplet (Ctrl + num)"), G_CALLBACK(insert_tuplet) },
{ "set_brace", "brace-icon", _("brace"), NULL, _("group staves by means of a brace"), G_CALLBACK(set_brace_system_delimiter) },
{ "set_bracket", "bracket-icon", _("bracket"), NULL, _("group staves by means of a bracket"), G_CALLBACK(set_bracket_system_delimiter) },
{ "set_connected", NULL, _("connect barlines"), NULL, _("set connected bar lines"), G_CALLBACK(set_connected_bar_line) },
{ "remove_element", GTK_STOCK_CANCEL, _("remove group"), NULL, _("remove a group of connected staves"), G_CALLBACK(remove_system_delimiter) },
{ "remove_tuplet", NULL, _("Remove tuplet"), NULL, _("remove a tuplet"), G_CALLBACK(remove_tuplet) },
{ "mute_staves", NULL, _("Muting ..."), NULL, _("mute some staves"), G_CALLBACK(mute_staves) },
{ "transpose", NULL, _("Transpose ..."), NULL, _("transpose"), G_CALLBACK(transpose) },
{ "hide_rests", NULL, _("hide rests"), "R", _("hide (selected) rests"), G_CALLBACK(hide_rests) },
{ "unhide_rests", NULL, _("unhide rests"), "U", _("unhide (selected) rests"), G_CALLBACK(unhide_rests) },
{ "hide_rests_of_all_voices", NULL, _("hide rests (all v.)"), NULL, _("hide selected rests (all v.)"), G_CALLBACK(hide_rests_of_all_voices) },
{ "unhide_rests_of_all_voices", NULL, _("unhide rests (all v.)"), NULL, _("unhide selected rests (all v.)"), G_CALLBACK(unhide_rests_of_all_voices) },
{ "set_all_halfs_to_sharp", NULL, _("set all to sharp ..."), NULL, _("set all flats to sharp"), G_CALLBACK(set_all_halfs_to_sharp) },
{ "set_all_halfs_to_flat", NULL, _("set all to flat ..."), NULL, _("set all sharps to flat"), G_CALLBACK(set_all_halfs_to_flat) },
{ "about_nted", NULL, _("About NtEd"), NULL, NULL, G_CALLBACK(show_about) },
#ifdef YELP_PATH
{ "show_docu", NULL, _("Documentation ..."), NULL, NULL, G_CALLBACK(show_docu) },
#endif
{ "show_license", NULL, _("License"), NULL, NULL, G_CALLBACK(show_license) },
{ "Exit", GTK_STOCK_QUIT, _("E_xit"), "Q", _("Exit the program"), G_CALLBACK(quit_app)}
};
const GtkToggleActionEntry NedMainWindow::accessory_buttons[] = {
{"play", GTK_STOCK_MEDIA_PLAY, "play", NULL, _("play"), G_CALLBACK(do_play), FALSE},
{"color_notes", "color-notes", "color notes", NULL, _("voices in different colors"), G_CALLBACK(set_paint_colored), FALSE},
{"show_measure_numbers", NULL, _("show measure numbers"), NULL, _("show measure numbers"), G_CALLBACK(initiate_repaint), FALSE},
{"show_hidden_elements", NULL, _("show hidden elements"), NULL, _("show hidden elements"), G_CALLBACK(toggle_show_hidden), FALSE},
{"midi_input", "midikeyboard-icon", _("midi input"), NULL, _("midi input"), G_CALLBACK(toggle_midi_input), FALSE},
{"record_midi", "record-icon", _("record midi"), "i", _("record midi - i"), G_CALLBACK(toggle_record_midi), FALSE}
};
const GtkActionEntry NedMainWindow::main_tools[] = {
{"zoom_in", GTK_STOCK_ZOOM_IN, _("in"), "plus", _("Zoom in Ctrl + +"), G_CALLBACK(zoom_in)},
{"zoom_out", GTK_STOCK_ZOOM_OUT, _("out"), "minus", _("Zoom out Ctrl + -"), G_CALLBACK(zoom_out)},
{"undo", GTK_STOCK_UNDO, _("undo"), "z", _("Undo Ctrl + z"), G_CALLBACK(do_undo)},
{"redo", GTK_STOCK_REDO, _("redo"), "y", _("Redo Ctrl + y"), G_CALLBACK(do_redo)},
{"customize_beam", "isolate-icon", _("customize beam"), "j", _("customize beam - Ctrl + j"), G_CALLBACK(customize_beam)},
{"flip_stem", "flipstem-icon", _("flip stem"), "f", _("flip stem - Ctrl + f"), G_CALLBACK(flip_stem)}
};
const GtkToggleActionEntry NedMainWindow::insert_erease_button[] = {
{"toggle_insert_erease_mode", "insert-mode-icon", _("insert"), "n", _("Toggle Insert/Erase Mode - n"), G_CALLBACK(toggle_insert_erease_mode), FALSE},
};
const GtkToggleActionEntry NedMainWindow::toggle_mode_buttons[] = {
{"set_page_mode", "shift-mode-icon", _("page"), "p", _("Page Mode - p"), G_CALLBACK(toggle_shift_mode), FALSE},
{"toggle_keyboard_insert_mode", "key-icon", _("key"), "k", _("Keyboard insert mode - k"), G_CALLBACK(prepare_keyboard_insertion), FALSE},
};
NedMainWindow::NedMainWindow() :
m_selected_note(NULL),
m_selected_chord_or_rest(NULL),
m_selected_stem(NULL),
m_selected_free_replaceable(NULL),
m_selected_spec_measure(NULL),
m_selected_tie_forward(NULL),
m_freetext(NULL),
m_special_measures(NULL),
m_last_staff_during_key_insertion(NULL),
m_current_scale(SCALE_GRANULARITY),
m_leftx(0),
m_topy(0),
m_mouse_x(0),
m_mouse_y(0),
m_current_zoom_level(START_ZOOM_LEVEL),
m_special_type(-1),
m_pages(NULL),
m_recentFileMergeId(-1),
m_numerator(4),
m_denominator(4),
m_timesig_symbol(TIME_SYMBOL_NONE),
m_staff_count(1),
m_config_changed(FALSE),
m_midi_tempo_inverse(START_TEMPO_INVERSE),
m_last_touched_system(NULL),
m_first_page_yoffs(0.0),
m_upbeat_inverse(0),
m_selected_group(NULL),
m_avoid_feedback(FALSE),
m_avoid_feedback_action(FALSE),
m_lyrics_mode(NO_LYRICS),
m_midi_recorder(NULL),
m_pointer_xpos(-1.0),
m_paint_colored(FALSE),
m_portrait(TRUE),
m_keyboard_ctrl_mode(FALSE),
m_draw_postscript(false),
m_netto_indent(0.0),
m_2ndnetto_indent(0.0),
m_first_system_indent(0.0),
m_2nd_system_indent(0.0),
m_global_spacement_fac(1.0),
m_last_cursor_x(-1),
m_last_cursor_y(-1),
m_last_obj(NULL),
m_record_midi_numerator(4),
m_record_midi_denominator(4),
m_record_midi_pgm(0),
m_record_midi_tempo_inverse(170000),
m_record_midi_metro_volume(64),
m_record_midi_triplet_recognition(true),
m_record_midi_f_piano(false),
m_record_midi_dnt_split(false),
m_record_midi_keysig(0)
#ifdef YELP_PATH
,m_docu(NULL)
#endif
{
int i;
NedResource::m_main_windows = g_list_append(NedResource::m_main_windows, this);
m_command_history = new NedCommandHistory(this);
m_special_sub_type.m_special_sub_type_int = -1;
m_special_sub_type.m_chord_info.chord_ptr = NULL;
if ((m_current_paper = NedResource::getPaperInfo("A4")) == NULL) {
NedResource::Abort("paper info A4 not available");
}
m_score_info = new ScoreInfo();
m_current_filename[0] = '\0';
#ifdef TTT
char *str1, *str2, *str3, *str4;
str1 = strdup("Хěвел");
str2 = strdup(" Хěвел");
str3 = strdup("Хěвел ");
str4 = strdup(" Хěвел ");
NedResource::removeWhiteSpaces(&str1);
NedResource::DbgMsg(DBG_TESTING, "str1 = *%s*\n", str1);
NedResource::removeWhiteSpaces(&str2);
NedResource::DbgMsg(DBG_TESTING, "str2 = *%s*\n", str2);
NedResource::removeWhiteSpaces(&str3);
NedResource::DbgMsg(DBG_TESTING,"str3 = *%s*\n", str3);
NedResource::removeWhiteSpaces(&str4);
NedResource::DbgMsg(DBG_TESTING, "str4 = *%s*\n", str4);
#endif
m_staff_contexts[0].m_key_signature_number = 0;
m_staff_contexts[0].m_clef_number = 0;
m_staff_contexts[0].m_clef_octave_shift = 0;
m_staff_contexts[0].m_different_voices = false;
for (i = 0; i < MAX_STAFFS; i++) {
m_staff_contexts[i].m_staff_name = NULL;
m_staff_contexts[i].m_staff_short_name = NULL;
m_staff_contexts[i].m_group_name = NULL;
m_staff_contexts[i].m_group_short_name = NULL;
}
for (i = 0; i < VOICE_COUNT; i++) {
m_staff_contexts[0].voices[i].m_midi_volume = 64;
m_staff_contexts[0].voices[i].m_midi_pan = 64;
m_staff_contexts[0].voices[i].m_midi_program = 0;
m_staff_contexts[0].m_muted[i] = false;
}
m_staff_contexts[0].m_midi_chorus = 0;
m_staff_contexts[0].m_play_transposed = 0;
m_staff_contexts[0].m_midi_reverb = 0;
m_staff_contexts[0].m_midi_channel = 0;
m_staff_contexts[0].m_flags = 0;
m_selection_rect.width = m_selection_rect.height = 0;
gettimeofday(&m_last_motion_call, NULL);
}
void NedMainWindow::createLayout(char *fname, char *yelparg) {
FILE *fp;
GtkAccelGroup *accel_group;
GtkActionGroup *tool_action_group;
GtkActionGroup *cursor_action_group;
GtkActionGroup *accessories_action_group;
GtkActionGroup *insert_erease_action_group;
GError *error;
GtkWidget *menubar;
GtkWidget *toolbar;
GdkColor bgcolor;
GtkToolItem* pageitem;
GtkToolItem* voicesitem;
GtkWidget *vc_bu_vbox, *vc_bu_hbox1, *vc_bu_hbox2;
int i;
char pathfoldername[1024], *cptr;
#ifdef YELP_PATH
m_docu = yelparg;
#endif
m_hand = gdk_cursor_new(GDK_HAND2);
m_pointer = gdk_cursor_new(GDK_TOP_LEFT_ARROW);
m_pencil = gdk_cursor_new(GDK_PENCIL);
m_current_zoom = NedResource::getZoomFactor(m_current_zoom_level);
m_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (m_main_window), NedResource::m_width, NedResource::m_height);
gtk_window_set_title (GTK_WINDOW (m_main_window), "Nted");
gtk_window_set_default_icon(NedResource::m_the_nted_icon);
m_menu_action_group = gtk_action_group_new ("MenuActions");
gtk_action_group_set_translation_domain(m_menu_action_group, NULL);
gtk_action_group_add_actions (m_menu_action_group, file_entries, G_N_ELEMENTS (file_entries), (void *) this);
for (i = 0; i < MAX_RECENT_FILES; i++) {
char ac_name[128], ac_label[128];
sprintf(ac_name, "open_recent_action_%d", i);
sprintf(ac_label, "Open Recent %d", i);
m_recent_actions[i] = gtk_action_new (ac_name, ac_label, NULL, NULL);
}
m_open_recent_action_group = gtk_action_group_new ("OpenRecent");
gtk_action_group_set_translation_domain(m_open_recent_action_group, NULL);
tool_action_group = gtk_action_group_new ("ToolActions");
gtk_action_group_set_translation_domain(tool_action_group, NULL);
gtk_action_group_add_actions (tool_action_group, main_tools, G_N_ELEMENTS (main_tools), (void *) this);
cursor_action_group = gtk_action_group_new ("CursorActions");
gtk_action_group_set_translation_domain(cursor_action_group, NULL);
gtk_action_group_add_toggle_actions (cursor_action_group, toggle_mode_buttons, G_N_ELEMENTS (toggle_mode_buttons), (void *) this);
insert_erease_action_group = gtk_action_group_new ("InsertEreaseActions");
gtk_action_group_set_translation_domain(insert_erease_action_group, NULL);
gtk_action_group_add_toggle_actions (insert_erease_action_group, insert_erease_button, G_N_ELEMENTS (insert_erease_button), (void *) this);
accessories_action_group = gtk_action_group_new ("AccessoryAction");
gtk_action_group_set_translation_domain(accessories_action_group, NULL);
gtk_action_group_add_toggle_actions (accessories_action_group, accessory_buttons, G_N_ELEMENTS (accessory_buttons), (void *) this);
m_ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (m_ui_manager, m_menu_action_group, 0);
gtk_ui_manager_insert_action_group (m_ui_manager, tool_action_group, 1);
gtk_ui_manager_insert_action_group (m_ui_manager, insert_erease_action_group, 3);
gtk_ui_manager_insert_action_group (m_ui_manager, cursor_action_group, 3);
gtk_ui_manager_insert_action_group (m_ui_manager, accessories_action_group, 4);
gtk_ui_manager_insert_action_group (m_ui_manager, m_open_recent_action_group, 5);
accel_group = gtk_ui_manager_get_accel_group (m_ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (m_main_window), accel_group);
error = NULL;
if (!gtk_ui_manager_add_ui_from_string (m_ui_manager, guiDescription, -1, &error)) {
g_message ("building menus failed: %s", error->message);
g_error_free (error);
NedResource::Abort("error");
}
menubar = gtk_ui_manager_get_widget (m_ui_manager, "/MainMenu");
toolbar = gtk_ui_manager_get_widget (m_ui_manager, "/ToolBar");
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
m_undo_action = gtk_ui_manager_get_action (m_ui_manager, "/MainMenu/EditMenu/undo");
if (m_undo_action == NULL) {
NedResource::Abort("m_undo_action not found");
}
gtk_action_set_sensitive(m_undo_action, FALSE);
m_redo_action = gtk_ui_manager_get_action (m_ui_manager, "/MainMenu/EditMenu/redo");
if (m_redo_action == NULL) {
NedResource::Abort("m_redo_action not found");
}
gtk_action_set_sensitive(m_redo_action, FALSE);
m_insert_erease_mode_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/ToolBar/toggle_insert_erease_mode"));
if (m_insert_erease_mode_action == NULL) {
NedResource::Abort("insert_mode_erease_action not found");
}
m_shift_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/ToolBar/set_page_mode"));
if (m_shift_action == NULL) {
NedResource::Abort("m_shift_action not found");
}
m_keyboard_insert_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/ToolBar/toggle_keyboard_insert_mode"));
if (m_keyboard_insert_action == NULL) {
NedResource::Abort("m_keyboard_insert_action not found");
}
m_midi_input_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/ToolBar/midi_input"));
if (m_midi_input_action == NULL) {
NedResource::Abort("m_midi_input_action not found");
}
m_midi_record_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/ToolBar/record_midi"));
if (m_midi_record_action == NULL) {
NedResource::Abort("m_midi_record_action not found");
}
m_replay_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/ToolBar/play"));
if (m_replay_action == NULL) {
NedResource::Abort("m_replay_action not found");
}
m_remove_page_action = gtk_ui_manager_get_action (m_ui_manager, "/MainMenu/EditMenu/remove_page");
if (m_remove_page_action == NULL) {
NedResource::Abort("m_remove_page_action not found");
}
m_show_hidden_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/MainMenu/ViewMenu/show_hidden_elements"));
if (m_show_hidden_action == NULL) {
NedResource::Abort("m_show_hidden_action not found");
}
m_show_measure_numbers_action = GTK_TOGGLE_ACTION(gtk_ui_manager_get_action (m_ui_manager, "/MainMenu/ViewMenu/show_measure_numbers"));
if (m_show_measure_numbers_action == NULL) {
NedResource::Abort("m_show_measure_numbers_action not found");
}
m_customize_beam_button = gtk_ui_manager_get_widget(m_ui_manager, "/ToolBar/customize_beam");
if (m_customize_beam_button == NULL) {
NedResource::Abort("m_customize_beam_button not found");
}
gtk_action_set_sensitive(m_remove_page_action, FALSE);
g_signal_connect (m_main_window, "delete-event",
G_CALLBACK (close_window2), this);
g_signal_connect (m_main_window, "set-focus",
G_CALLBACK (OnSetFocus), this);
double w = m_portrait ? m_current_paper->width : m_current_paper->height;
double h = m_portrait ? m_current_paper->height : m_current_paper->width;
w /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
h /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
NedPage *page = new NedPage(this, w, h, 0, 1, TRUE);
m_pages = g_list_append(m_pages, page);
reposit();
m_page_selector = gtk_spin_button_new_with_range (1.0, g_list_length(m_pages), 1.0);
pageitem = gtk_tool_item_new();
gtk_container_set_border_width(GTK_CONTAINER(pageitem), 5);
gtk_container_add(GTK_CONTAINER(pageitem), m_page_selector);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), pageitem, 8);
vc_bu_vbox = gtk_vbox_new (FALSE, 0);
vc_bu_hbox1 = gtk_hbox_new (FALSE, 0);
vc_bu_hbox2 = gtk_hbox_new (FALSE, 0);
m_v1bu = gtk_radio_button_new_with_label(NULL, "1");
m_v2bu = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_v1bu), "2");
m_v3bu = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_v1bu), "3");
m_v4bu = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_v1bu), "4");
m_voice_buttons = gtk_radio_button_get_group(GTK_RADIO_BUTTON(m_v1bu));
GdkColor bucolor;
bucolor.pixel = 0;
bucolor.red = V1RED; bucolor.green = V1GREEN; bucolor.blue = V1BLUE;
gtk_widget_modify_base(m_v1bu, GTK_STATE_NORMAL, &bucolor);
bucolor.red = V2RED; bucolor.green = V2GREEN; bucolor.blue = V2BLUE;
gtk_widget_modify_base(m_v2bu, GTK_STATE_NORMAL, &bucolor);
bucolor.red = V3RED; bucolor.green = V3GREEN; bucolor.blue = V3BLUE;
gtk_widget_modify_base(m_v3bu, GTK_STATE_NORMAL, &bucolor);
bucolor.red = V4RED; bucolor.green = V4GREEN; bucolor.blue = V4BLUE;
gtk_widget_modify_base(m_v4bu, GTK_STATE_NORMAL, &bucolor);
g_signal_connect (GTK_BUTTON(m_v1bu), "pressed", G_CALLBACK (select_voice), (void *) this);
g_signal_connect (GTK_BUTTON(m_v2bu), "pressed", G_CALLBACK (select_voice), (void *) this);
g_signal_connect (GTK_BUTTON(m_v3bu), "pressed", G_CALLBACK (select_voice), (void *) this);
g_signal_connect (GTK_BUTTON(m_v4bu), "pressed", G_CALLBACK (select_voice), (void *) this);
gtk_box_pack_start (GTK_BOX (vc_bu_hbox1), m_v1bu, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vc_bu_hbox1), m_v2bu, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vc_bu_hbox2), m_v3bu, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vc_bu_hbox2), m_v4bu, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vc_bu_vbox), vc_bu_hbox1, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vc_bu_vbox), vc_bu_hbox2, FALSE, FALSE, 0);
voicesitem = gtk_tool_item_new();
gtk_container_add(GTK_CONTAINER(voicesitem), vc_bu_vbox);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), voicesitem, 10);
m_drawing_area = gtk_drawing_area_new ();
bgcolor.pixel = 0;
bgcolor.red = bgcolor.green = bgcolor.blue = 0xffff;
gtk_widget_modify_bg(GTK_WIDGET(m_drawing_area), GTK_STATE_NORMAL, &bgcolor);
GTK_WIDGET_SET_FLAGS(m_drawing_area, GTK_CAN_FOCUS);
GTK_WIDGET_SET_FLAGS(m_main_window, GTK_CAN_FOCUS);
gtk_widget_add_events(m_drawing_area, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
g_signal_connect (m_drawing_area, "expose-event",
G_CALLBACK (handle_expose), (void *) this);
g_signal_connect (m_drawing_area, "button-press-event",
G_CALLBACK (handle_button_press), (void *) this);
g_signal_connect (m_drawing_area, "button-release-event",
G_CALLBACK (handle_button_release), (void *) this);
g_signal_connect (m_drawing_area, "motion-notify-event",
G_CALLBACK (handle_motion), (void *) this);
g_signal_connect (m_drawing_area, "size-allocate",
G_CALLBACK (size_change_handler), (void *) this);
g_signal_connect (m_drawing_area, "key-press-event",
G_CALLBACK (key_press_handler), (void *) this);
g_signal_connect (m_drawing_area, "key-release-event",
G_CALLBACK (key_release_handler), (void *) this);
g_signal_connect (m_drawing_area, "enter-notify-event",
G_CALLBACK (window_enter_handler), (void *) this);
g_signal_connect (m_drawing_area, "leave-notify-event",
G_CALLBACK (window_leave_handler), (void *) this);
g_signal_connect (m_drawing_area, "scroll-event",
G_CALLBACK (scroll_event_handler), (void *) this);
g_signal_connect (m_main_window, "delete-event",
G_CALLBACK (handle_delete), (void *) this);
g_signal_connect (m_page_selector, "value-changed",
G_CALLBACK (handle_page_request), (void *) this);
m_main_vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (m_main_vbox), menubar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (m_main_vbox), toolbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (m_main_vbox), m_drawing_area, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (m_main_window), m_main_vbox);
gtk_widget_show_all (m_main_window);
gtk_toggle_action_set_active(m_show_measure_numbers_action, TRUE);
m_im_context = gtk_im_context_simple_new ();
g_signal_connect (m_im_context, "commit", G_CALLBACK (OnCommit), this);
gdk_window_set_cursor (GDK_WINDOW(m_drawing_area->window), m_pointer);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(m_insert_erease_mode_action), TRUE);
if (fname != NULL) {
if ((fp = fopen(fname, "r")) == NULL) {
fprintf(stderr, "Cannot open %s\n", fname);
}
else {
do_restore(fp, fname);
fclose(fp);
if (fname[0] == '/' && (cptr = strrchr(fname, '/')) != NULL) {
strncpy(pathfoldername, fname, cptr - fname);
pathfoldername[cptr - fname] = '\0';
NedResource::m_last_folder = strdup(pathfoldername);
}
}
}
updateRecentFiles();
NedResource::popup_tools(this);
#ifdef WITH_BANNER
#define BANNERSIZE 4.0
m_banner1 = new NedPangoCairoText(m_drawing_area->window, "Vorführung", STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, BANNERSIZE, m_current_zoom, getCurrentScale(), false);
m_banner2 = new NedPangoCairoText(m_drawing_area->window, "dieser", STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, BANNERSIZE, m_current_zoom, getCurrentScale(), false);
m_banner3 = new NedPangoCairoText(m_drawing_area->window, "Software", STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, BANNERSIZE, m_current_zoom, getCurrentScale(), false);
m_banner4 = new NedPangoCairoText(m_drawing_area->window, "11:00 Uhr", STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, BANNERSIZE, m_current_zoom, getCurrentScale(), false);
m_banner5 = new NedPangoCairoText(m_drawing_area->window, "Raum N105", STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, BANNERSIZE, m_current_zoom, getCurrentScale(), false);
#endif
}
NedMainWindow::~NedMainWindow() {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
delete (NedPage *) lptr->data;
}
g_list_free(m_pages);
m_pages = NULL;
gtk_widget_destroy (m_main_window);
}
bool NedMainWindow::isTimsigChangingMeasure(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return false;
}
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == meas_num && ((SpecialMeasure *) lptr->data)->type == TIMESIG) {
return true;
}
}
return false;
}
int NedMainWindow::getNumerator(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return m_numerator;
}
int num = m_numerator;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number > meas_num) {
return num;
}
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) continue;
num = ((SpecialMeasure *) lptr->data)->numerator;
/*
if (meas_num == 1) {
NedResource::DbgMsg(DBG_TESTING, "Stelle 3 num = %d, ((SpecialMeasure *) lptr->data)->measure_number = %d\n",
num, ((SpecialMeasure *) lptr->data)->measure_number);
}
*/
}
/*
if (meas_num == 1) {
NedResource::DbgMsg(DBG_TESTING, "Stelle 4 num = %d\n", num);
}
*/
return num;
}
int NedMainWindow::getDenominator(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return m_denominator;
}
int denom = m_denominator;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number > meas_num) {
return denom;
}
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) continue;
denom = ((SpecialMeasure *) lptr->data)->denominator;
}
return denom;
}
unsigned int NedMainWindow::getTimesigSymbol(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return TIME_SYMBOL_NONE;
}
unsigned int symbol = m_timesig_symbol;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number > meas_num) {
return symbol;
}
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) continue;
symbol = ((SpecialMeasure *) lptr->data)->symbol;
}
return symbol;
}
unsigned int NedMainWindow::getTimesigSymbolOfThisMeasure(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return TIME_SYMBOL_NONE;
}
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == meas_num) {
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) return TIME_SYMBOL_NONE;
return ((SpecialMeasure *) lptr->data)->symbol;
}
}
return TIME_SYMBOL_NONE;
}
int NedMainWindow::getNumeratorOfThisMeasure(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return 4;
}
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == meas_num) {
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) return 4;
return ((SpecialMeasure *) lptr->data)->numerator;
}
}
return 4;
}
int NedMainWindow::getDenominatorOfThisMeasure(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return 4;
}
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == meas_num) {
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) return 4;
return ((SpecialMeasure *) lptr->data)->denominator;
}
}
return 4;
}
unsigned int NedMainWindow::getMeasureDuration(int meas_num) {
GList *lptr;
if (meas_num < 0) {
return WHOLE_NOTE;
}
unsigned int duration = m_numerator * WHOLE_NOTE / m_denominator;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number > meas_num) {
return duration;
}
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG) == 0) continue;
duration = ((SpecialMeasure *) lptr->data)->measure_duration;
}
return duration;
}
bool NedMainWindow::findTimeOfMeasure(int meas_num, unsigned long long *meas_time) {
GList *lptr;
unsigned long long system_offs = 0;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->findTimeOfMeasure(meas_num, meas_time, &system_offs)) {
*meas_time += system_offs;
return true;
}
}
return false;
}
void NedMainWindow::setAllUnpositioned() {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->setAllUnpositioned();
}
}
void NedMainWindow::zoomFreeReplaceables(double zoom, double scale) {
GList *lptr;
if (m_score_info->title != NULL && strlen(m_score_info->title->getText()) > 0) {
m_score_info->title->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->subject != NULL && strlen(m_score_info->subject->getText()) > 0) {
m_score_info->subject->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->composer != NULL && strlen(m_score_info->composer->getText()) > 0) {
m_score_info->composer->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->arranger != NULL && strlen(m_score_info->arranger->getText()) > 0) {
m_score_info->arranger->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->copyright != NULL && strlen(m_score_info->copyright->getText()) > 0) {
m_score_info->copyright->setZoom(m_current_zoom, 1.0);
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->zoomFreeReplaceables(zoom, scale);
}
}
void NedMainWindow::removeEmptyInteriourPages() {
GList *lptr;
bool empty_found;
do {
empty_found = false;
lptr = g_list_first(m_pages);
while (lptr) {
if (((NedPage *) lptr->data)->isEmpty()) {
m_pages = g_list_delete_link(m_pages, lptr);
lptr = g_list_first(m_pages);
empty_found = true;
continue;
}
lptr = g_list_next(lptr);
}
}
while (empty_found);
}
NedSystem *NedMainWindow::getNextSystem(NedPage *page, NedCommandList *command_list /* ev. == NULL */) {
GList *lptr;
int len;
unsigned int measure_number;
NedPage *newpage;
if ((lptr = g_list_find(m_pages, page)) == NULL) {
NedResource::Abort("NedMainWindow::getNextSystem");
}
lptr = g_list_next(lptr);
if (lptr == NULL) {
if (command_list == NULL) {
return NULL;
}
len = g_list_length(m_pages);
measure_number = ((NedPage *) g_list_last(m_pages)->data)->getNumberOfLastMeasure();
NedAppendNewPageCommand *app_page_command = new NedAppendNewPageCommand(this, len, measure_number + 1);
app_page_command->execute(); // the commend list is not executed
resetPointerLastTouchedSystems();
command_list->addCommand(app_page_command);
lptr = g_list_last(m_pages);
}
newpage = (NedPage *) lptr->data;
if (newpage->isEmpty()) return NULL;
return newpage->getFirstSystem();
}
NedPage *NedMainWindow::getNextPage(NedPage *page, NedCommandList *command_list /* ev. == NULL */) {
GList *lptr;
int len;
unsigned int measure_number;
if ((lptr = g_list_find(m_pages, page)) == NULL) {
NedResource::Abort("NedMainWindow::getNextPage");
}
if ((lptr = g_list_next(lptr)) == NULL) {
if (command_list == NULL) {
return NULL;
}
measure_number = ((NedPage *) g_list_last(m_pages)->data)->getNumberOfLastMeasure();
len = g_list_length(m_pages);
NedAppendNewPageCommand *app_page_command = new NedAppendNewPageCommand(this, len, measure_number + 1);
app_page_command->execute(); // the commend list is not executed
command_list->addCommand(app_page_command);
lptr = g_list_last(m_pages);
}
return ((NedPage *) lptr->data);
}
NedPage *NedMainWindow::getPreviousPage(NedPage *page) {
GList *lptr;
if ((lptr = g_list_find(m_pages, page)) == NULL) {
NedResource::Abort("NedMainWindow::getNextPage");
}
if ((lptr = g_list_previous(lptr)) == NULL) {
return NULL;
}
return ((NedPage *) lptr->data);
}
void NedMainWindow::setUnRedoButtons(bool execute_possible, bool unexecute_possible) {
gtk_action_set_sensitive(m_undo_action, unexecute_possible);
gtk_action_set_sensitive(m_redo_action, execute_possible);
}
void NedMainWindow::updatePageCounter() {
gtk_spin_button_set_range(GTK_SPIN_BUTTON(m_page_selector), 1, g_list_length(m_pages));
m_selection_rect.width = m_selection_rect.height = 0;
gtk_action_set_sensitive(m_remove_page_action, (g_list_length(m_pages) > 1));
}
double NedMainWindow::getLeftX() {
if (m_draw_postscript) return 0.0;
return m_leftx;
}
double NedMainWindow::getTopY() {
if (m_draw_postscript) return 0.0;
return m_topy;
}
void NedMainWindow::draw (cairo_t *cr, int width, int height)
{
cairo_scaled_font_t *scaled_font;
bool dummy = false;
scaled_font = NedResource::getScaledFont(m_current_zoom_level);
GdkColor sel_color;
//cairo_scale(cr, 0.4, 0.4);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(m_current_zoom_level));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->draw(cr, gtk_toggle_action_get_active(m_show_measure_numbers_action), width, height);
}
cairo_new_path(cr);
#ifdef WITH_BANNER
#define BANNER_Y_DIST 180
#define BANNER_X 50
cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 0.3);
m_banner1->draw(cr, BANNER_X, 100 + 0 * BANNER_Y_DIST, 200, 1);
m_banner2->draw(cr, BANNER_X, 100 + 1 * BANNER_Y_DIST, 200, 1);
m_banner3->draw(cr, BANNER_X, 100 + 2 * BANNER_Y_DIST, 200, 1);
m_banner4->draw(cr, BANNER_X, 100 + 3 * BANNER_Y_DIST, 200, 1);
m_banner5->draw(cr, BANNER_X, 100 + 4 * BANNER_Y_DIST, 200, 1);
cairo_stroke(cr);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
#endif
if (!NedResource::isPlaying() && m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM) {
cairo_new_path(cr);
cairo_set_line_width(cr, 1.0);
cairo_set_source_rgb (cr, 0.4, 0.0, 1.0);
cairo_move_to(cr, m_selection_rect.x, m_selection_rect.y);
cairo_line_to(cr, m_selection_rect.x + m_selection_rect.width, m_selection_rect.y);
cairo_line_to(cr, m_selection_rect.x + m_selection_rect.width, m_selection_rect.y + m_selection_rect.height);
cairo_line_to(cr, m_selection_rect.x , m_selection_rect.y + m_selection_rect.height);
cairo_line_to(cr, m_selection_rect.x , m_selection_rect.y);
cairo_stroke(cr);
cairo_scale(cr, getCurrentScale(), getCurrentScale());
sel_color.pixel = 0;
sel_color.red = 200; sel_color.green = 0; sel_color.blue = 250;
for (lptr = g_list_first(m_selected_group); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->draw(cr, &dummy);
}
cairo_identity_matrix(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
}
void NedMainWindow::repaintDuringReplay(NedNote *notes[], int num_notes) {
int i;
bool dummy;
cairo_t *cr;
cr = gdk_cairo_create (m_drawing_area->window);
cairo_scaled_font_t *scaled_font;
scaled_font = NedResource::getScaledFont(m_current_zoom_level);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(m_current_zoom_level));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
cairo_scale(cr, getCurrentScale(), getCurrentScale());
for (i = 0; i < num_notes; i++) {
if (notes[i]->getChord()->getType() == TYPE_GRACE) {
notes[i]->getChord()->draw(cr, &dummy);
continue;
}
notes[i]->draw(cr);
}
cairo_destroy (cr);
}
void NedMainWindow::reposit(NedCommandList *command_list /* = NULL */, NedPage *start_page /* = NULL */, NedSystem *start_system /* = NULL */,
bool with_progress_bar /* = false */) {
GList *lptr, *plptr;
GtkWidget *progressbar = NULL, *progressdialog = NULL;
bool changes, ch;
//bool page_deleted = false;
int pass, lowest_page = 0;
int page_number;
double percent;
NedSystem *system, *next_system;
m_start_system_for_renumbering = NULL;
m_start_measure_number_for_renumbering = (1 << 30);
//NedRemovePageCommand *rem_page_cmd;
int measure_number;
if (start_page == NULL) {
start_page = ((NedPage *) g_list_first(m_pages)->data);
plptr = g_list_first(m_pages);
}
else {
if ((plptr = g_list_find(m_pages, start_page)) == NULL) {
// can happen in unexecute if the page ist inserted
//NedResource::Abort("NedMainWindow::reposit");
start_page = ((NedPage *) g_list_first(m_pages)->data);
plptr = g_list_first(m_pages);
}
}
resetPointerLastTouchedSystems();
if (with_progress_bar) {
progressdialog = gtk_dialog_new_with_buttons("Placing", NULL, (GtkDialogFlags) 0, NULL);
progressbar = gtk_progress_bar_new();
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(progressdialog)->vbox), progressbar);
gtk_widget_show_all(progressdialog);
}
#ifdef XXX
unsigned int old_page_map = 0;
unsigned int page_map = 0;
int zz = 0;
#endif
do {
#ifdef XXX
page_map = 0;
#endif
changes = FALSE;
if (start_system == NULL) {
system = start_page->getFirstSystem();
}
else {
system = start_system;
system->m_is_positioned = false;
}
measure_number = system->getNumberOfFirstMeasure();
if (with_progress_bar) {
lowest_page = 100000;
}
while (system != NULL) {
ch = system->reposit(measure_number, command_list, &next_system);
/*
if (ch) {
printf("pag: %d, sys %d: changes = 1\n", system->getPage()->getPageNumber(),
system->getSystemNumber()); fflush(stdout);
}
*/
measure_number = system->getNumberOfLastMeasure();
measure_number++;
#ifdef XXX
if (ch) {
page_map |= (1 << system->getPage()->getPageNumber());
}
#endif
if (with_progress_bar) {
if (ch) {
if (system->getPage()->getPageNumber() < lowest_page) {
lowest_page = system->getPage()->getPageNumber();
}
}
}
changes = changes || ch;
system = next_system;
}
if (with_progress_bar) {
percent = (double) lowest_page / (double) g_list_length(m_pages);
if (percent > 1.0) percent = 1.0;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), percent);
g_main_context_iteration(NULL, FALSE);
}
#ifdef XXX
if (old_page_map != page_map) {
for (int i = 0; i < 31; i++) {
NedResource::DbgMsg(DBG_TESTING, "%c ", (page_map & (1 << i)) == 0 ? '.' : 'x');
}
NedResource::DbgMsg(DBG_TESTING, "\n");
old_page_map = page_map;
}
zz++;
#endif
}
while (changes);
#ifdef XXX
NedResource::DbgMsg(DBG_TESTING, "%d elemente bewegt\n", NedClipBoard::count);
//NedClipBoard::count = 0;
#endif
for (pass = 0; pass < 2; pass++) {
do {
changes = FALSE;
ch = TRUE;
for (lptr = plptr; lptr; lptr = g_list_next(lptr)) {
ch = ((NedPage *) lptr->data)->placeStaffs(pass, command_list);
changes = changes || ch;
}
}
while (changes);
}
#ifdef UNNEEDED // removing a page is already done during placeStaffs (above)
if (command_list != NULL) {
command_list->setRenumber();
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->isEmpty()) {
rem_page_cmd = new NedRemovePageCommand(this, (NedPage *) lptr->data);
rem_page_cmd->execute();
page_deleted = true;
lptr = g_list_first(m_pages);
command_list->addCommand(rem_page_cmd);
}
}
if (page_deleted) {
command_list->setRenumberPages();
renumberPages();
}
}
#endif
deletePagesWithoutSystem();
for (page_number = 0, lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->setPageNumber(page_number++);
((NedPage *) lptr->data)->recomputeFreeReplaceables();
((NedPage *) lptr->data)->computeTuplets(); // do it here again, otherwise
// it can happen some tuplets are not recomputed
}
renumberMeasures(NULL, 1, true);
if (with_progress_bar) {
gtk_widget_destroy (GTK_WIDGET(progressdialog));
}
}
void NedMainWindow::renumberMeasures(NedSystem *start_system /* = NULL */, int measure_number /* = 1 */, bool force /* = false */) {
NedSystem *system;
NedPage *start_page;
/*
GList *lptr;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == 17) {
NedResource::DbgMsg(DBG_TESTING, "setspecial (17) auf 0x0 (0x%x)\n", &(((SpecialMeasure *) lptr->data)->measure_number));
}
((SpecialMeasure *) lptr->data)->measure = NULL;
}
*/
system = start_system;
if (start_system == NULL) {
start_page = (NedPage *) g_list_first(m_pages)->data;
system = start_page->getFirstSystem();
}
while (system != NULL) {
system->renumberMeasures(&measure_number, m_special_measures, force);
system = system->getPage()->getNextSystem(system);
}
}
void NedMainWindow::setNewMeasureSpread(double spread) {
NedSystem *system;
system = ((NedPage *) g_list_first(m_pages)->data)->getFirstSystem();
while (system != NULL) {
system->setNewMeasureSpread(spread);
system = system->getPage()->getNextSystem(system);
}
}
bool NedMainWindow::needsARepLine(int measure_number) {
int current_type = 0;
GList *lptr;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number > measure_number) {
return current_type != 0;
}
switch ((((SpecialMeasure *) lptr->data)->type & END_TYPE_MASK)) {
case REP1END:
case REP2END: current_type = 0; break;
}
switch ((((SpecialMeasure *) lptr->data)->type & START_TYPE_MASK)) {
case REP1START:
case REP2START: current_type = ((SpecialMeasure *) lptr->data)->type; break;
}
}
return false;
}
gboolean NedMainWindow::handle_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
cairo_t *cr;
NedMainWindow *main_window = (NedMainWindow *) data;
GList *lptr;
int c, line, yy, l;
double xpos, ypos, bottom;
NedStaff *dummy;
cr = gdk_cairo_create (widget->window);
main_window->draw (cr, widget->allocation.width, widget->allocation.height);
if (main_window->m_lyrics_mode < 0 && (main_window->getMainWindowStatus() & INSERT_EREASE_MODE) != 0 &&
!NedResource::isPlaying() && main_window->m_pointer_xpos >= 0.0) {
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->findLine(main_window->m_pointer_xpos, main_window->m_pointer_ypos, &ypos, &line, &bottom, &dummy)) {
ypos *= (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
bottom *= (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
xpos = main_window->m_pointer_xpos;
#ifdef OOO
#ifdef CCC
Display *dpy = cairo_xlib_surface_get_display (cairo_get_target (cr));
Window win = cairo_xlib_surface_get_drawable (cairo_get_target (cr));
#else
Display *dpy = gdk_x11_drawable_get_xdisplay(widget->window);
Window win =gdk_x11_drawable_get_xid(widget->window);
#endif
GC gc = DefaultGC(dpy, DefaultScreen(dpy));
XSetForeground(dpy, gc, 0x0000bb);
linewidth = (int) main_window->m_current_zoom * 0.5;
rad1 = (int) main_window->m_current_zoom * 0.15;
rad2 = (int) main_window->m_current_zoom * 0.1;
XDrawArc(dpy, win, gc, main_window->m_pointer_xpos - rad1, ypos - rad2, 2 * rad1, 2 * rad2, 0, 64 * 360);
if (line < -9) {
c = -(line + 8) / 2;
for (l = 0; l < c; l++) {
yy = (int) (bottom - ((5 + l) * LINE_DIST) * main_window->m_current_zoom);
XDrawLine(dpy, win, gc, main_window->m_pointer_xpos - linewidth / 2, yy, main_window->m_pointer_xpos + linewidth / 2, yy);
}
}
if (line > 1) {
c = line / 2;
for (l = 0; l < c; l++) {
yy = (int) (bottom + ((1 + l) * LINE_DIST) * main_window->m_current_zoom);
XDrawLine(dpy, win, gc, main_window->m_pointer_xpos - linewidth / 2, yy, main_window->m_pointer_xpos + linewidth / 2, yy);
}
}
break;
}
#else
double dlinewidth = main_window->m_current_zoom * 0.5 * (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
double drad1 = main_window->m_current_zoom * 0.15 * (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
double drad2 = main_window->m_current_zoom * 0.24 * (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
cairo_new_path(cr);
cairo_set_line_width(cr, 0.02 * main_window->m_current_zoom);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.9);
//cairo_arc(cr, main_window->m_pointer_xpos - rad1, ypos - rad1, 2 * rad1, 0, 2.0 *M_PI);
cairo_move_to(cr, xpos - drad1, ypos);
cairo_curve_to(cr, xpos - drad1, ypos,
xpos, ypos + drad2,
xpos + drad1, ypos);
cairo_curve_to(cr, xpos + drad1, ypos,
xpos, ypos - drad2,
xpos - drad1, ypos);
/*
cairo_move_to(cr, main_window->m_pointer_xpos - drad1, ypos);
cairo_line_to(cr, main_window->m_pointer_xpos, ypos + drad2);
cairo_line_to(cr, main_window->m_pointer_xpos + drad1, ypos);
cairo_line_to(cr, main_window->m_pointer_xpos, ypos - drad2);
cairo_line_to(cr, main_window->m_pointer_xpos - drad1, ypos);
*/
cairo_stroke(cr);
if (line < -9) {
c = -(line + 8) / 2;
for (l = 0; l < c; l++) {
yy = (int) (bottom - ((5 + l) * LINE_DIST) * main_window->m_current_zoom * main_window->getCurrentScale());
cairo_new_path(cr);
cairo_move_to(cr, xpos - dlinewidth / 2, yy);
cairo_line_to(cr, xpos + dlinewidth / 2, yy);
cairo_stroke(cr);
}
}
if (line > 1) {
c = line / 2;
for (l = 0; l < c; l++) {
yy = (int) (bottom + ((1 + l) * LINE_DIST) * main_window->m_current_zoom * main_window->getCurrentScale());
cairo_new_path(cr);
cairo_move_to(cr, xpos - dlinewidth / 2, yy);
cairo_line_to(cr, xpos + dlinewidth / 2, yy);
cairo_stroke(cr);
}
}
break;
}
#endif
}
}
cairo_destroy (cr);
return FALSE;
}
void NedMainWindow::do_undo(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedResource::m_avoid_immadiate_play = TRUE;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_selected_tie_forward = NULL;
main_window->m_command_history->unexecute();
main_window->repaint();
NedResource::m_avoid_immadiate_play = FALSE;
}
int NedMainWindow::getLyricsMode() {
return m_lyrics_mode;
}
unsigned int NedMainWindow::getMainWindowStatus() {
unsigned int status = 0;
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(m_insert_erease_mode_action))) {
status |= INSERT_EREASE_MODE;
}
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(m_shift_action))) {
status |= SHIFT_MODE;
}
return status;
}
bool NedMainWindow::getShowHidden() {
return gtk_toggle_action_get_active(m_show_hidden_action);
}
bool NedMainWindow::hasFocus() {
return gtk_widget_is_focus(m_main_window);
}
void NedMainWindow::do_redo(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedResource::m_avoid_immadiate_play = TRUE;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_selected_tie_forward = NULL;
main_window->m_command_history->execute();
main_window->repaint();
NedResource::m_avoid_immadiate_play = FALSE;
}
int NedMainWindow::getCurrentVoice() {
int voice_nr = 3;
GSList *l;
for (l = m_voice_buttons; l ; l = l->next, voice_nr--) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l->data))) {
return voice_nr;
}
}
NedResource::Abort("NedMainWindow::getCurrentVoice");
return 0;
}
void NedMainWindow::select_voice(GtkButton *button, gpointer data) {}
void NedMainWindow::do_play(GtkAction *action, gpointer data) {
if (!NedResource::alsaSequencerOutOk()) {
NedResource::Info(_("Cannot replay because could not open ALSA sequencer"));
return;
}
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->replay(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION (action)));
}
void NedMainWindow::replay(bool on) {
int i, j;
GList *lptr;
SpecialMeasure *spec_ptr;
int last_rep_open = 1, last_alternative1 = -1;
m_last_y_adjustment = NULL;
if (NedResource::isPlaying() && NedResource::getMainwWindowWithLastFocus() != this) {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(m_replay_action), FALSE);
return;
}
if (on) {
gtk_toggle_action_set_active(m_midi_record_action, FALSE);
gtk_toggle_action_set_active(m_midi_input_action, FALSE);
for (i = 0; i < m_staff_count; i++) {
m_staff_contexts[i].m_effective_channel = m_staff_contexts[i].m_midi_channel;
m_staff_contexts[i].m_pitch_offs = 0;
if (m_staff_contexts[i].m_different_voices) {
for (j = 0; j < VOICE_COUNT; j++) {
m_staff_contexts[i].voices[j].m_current_midi_program = m_staff_contexts[i].voices[j].m_midi_program;
NedResource::setStartVolume(m_staff_contexts[i].m_midi_channel, j,
m_staff_contexts[i].voices[j].m_midi_volume);
}
}
else {
for (j = 0; j < VOICE_COUNT; j++) {
m_staff_contexts[i].voices[j].m_current_midi_program = m_staff_contexts[i].voices[j].m_midi_program;
NedResource::setStartVolume(m_staff_contexts[i].m_midi_channel, j,
m_staff_contexts[i].voices[0].m_midi_volume);
}
}
}
for (i = 0; i < m_staff_count; i++) {
//NedResource::MidiProgramChange(m_staff_contexts[i].m_midi_channel, m_staff_contexts[i].voices[0].m_current_midi_program);
NedResource::MidiCtrl(MIDI_CTL_MSB_PAN, m_staff_contexts[i].m_midi_channel, m_staff_contexts[i].voices[0].m_midi_pan);
NedResource::MidiCtrl(MIDI_CTL_LSB_PAN, m_staff_contexts[i].m_midi_channel, 0);
NedResource::MidiCtrl(MIDI_CTL_E1_REVERB_DEPTH, m_staff_contexts[i].m_midi_channel, m_staff_contexts[i].m_midi_reverb);
NedResource::MidiCtrl(MIDI_CTL_E3_CHORUS_DEPTH, m_staff_contexts[i].m_midi_channel, m_staff_contexts[i].m_midi_chorus);
}
NedResource::prepareMidiEventList(m_midi_tempo_inverse);
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->prepareReplay();
}
NedResource::correctFermataTempo();
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
spec_ptr = (SpecialMeasure *) lptr->data;
switch (spec_ptr->type & REP_TYPE_MASK) {
case REPEAT_OPEN: last_rep_open = spec_ptr->measure_number; break;
case REPEAT_CLOSE: NedResource::copyAllBetweenMeasures(last_rep_open, last_alternative1, spec_ptr->measure_number);
last_alternative1 = -1; break;
case REPEAT_OPEN_CLOSE: NedResource::copyAllBetweenMeasures(last_rep_open, -1, spec_ptr->measure_number);
last_rep_open = spec_ptr->measure_number;
last_alternative1 = -1;
break;
}
switch (spec_ptr->type & START_TYPE_MASK) {
case REP1START: last_alternative1 = spec_ptr->measure_number; break;
}
}
NedResource::handleSegnos();
NedResource::startReplay(m_selected_note, m_midi_tempo_inverse);
/*
m_selected_note = NULL;
m_selected_spec_measure = NULL;
m_selected_chord_or_rest = NULL;
m_selected_tie_forward = NULL;
*/
}
else {
NedResource::stopReplay();
}
}
void NedMainWindow::resetActiveFlags() {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->resetActiveFlags();
}
}
double NedMainWindow::determineTempoInverse(NedChordOrRest *element) {
double tempoinverse = m_midi_tempo_inverse;
bool found = false;
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->determineTempoInverse(element, element->getSystem(), &tempoinverse, &found);
if (found) break;
}
if (!found) {
NedResource::Abort("NedMainWindow::determineTempo");
}
return tempoinverse;
}
void NedMainWindow::deleteStaff(int staff_number) {
int i;
GList *lptr;
if (staff_number < 0 || staff_number >= m_staff_count || m_staff_count < 2) {
NedResource::Abort("NedMainWindow::deleteStaff");
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->deleteStaff(staff_number);
}
for (i = staff_number; i < m_staff_count - 1; i++) {
m_staff_contexts[i] = m_staff_contexts[i+1];
}
m_staff_count--;
computeSystemIndent();
}
void NedMainWindow::shiftStaff(int staff_number, int position) {
int i;
GList *lptr;
struct staff_context_str context;
if (staff_number < 0 || staff_number >= m_staff_count || position < 0 || position >= m_staff_count) {
NedResource::Abort("NedMainWindow::shiftStaff");
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->shiftStaff(staff_number, position);
}
context = m_staff_contexts[staff_number];
if (position > staff_number) {
for (i = staff_number; i < position; i++) {
m_staff_contexts[i] = m_staff_contexts[i+1];
}
}
else {
for (i = staff_number; i > position; i--) {
m_staff_contexts[i] = m_staff_contexts[i-1];
}
}
m_staff_contexts[position] = context;
reposit();
repaint();
}
void NedMainWindow::restoreStaff(int staff_number, staff_context_str *staff_context) {
int i;
GList *lptr;
if (staff_number < 0 || staff_number > m_staff_count) {
NedResource::Abort("NedMainWindow::restoreStaff");
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->restoreStaff(staff_number);
}
for (i = m_staff_count; i > staff_number; i--) {
m_staff_contexts[i] = m_staff_contexts[i-1];
}
m_staff_contexts[staff_number] = *staff_context;
m_staff_count++;
computeSystemIndent();
}
void NedMainWindow::do_staff_config(int staff_number, NedSystem *system) {
bool state, delete_staff, delete_system, do_adjust;
int clef_number, key_signature_number, numerator, denominator, tempo;
int chorus, reverb;
int pan[VOICE_COUNT], vol[VOICE_COUNT], midi_program[VOICE_COUNT];
char *staff_name, *staff_short_name;
char *group_name, *group_short_name;
bool different_voices;
unsigned int symbol = m_timesig_symbol;
int channel, position, play_transposed;
NedChangeTimeSigCommand *change_timesig_command;
int octave_shift = 0;
bool allow_delete_systems;
NedCommandList *command_list = NULL;
bool text_diff;
bool newmuted[VOICE_COUNT];
int i;
/*
allow_delete_systems = ((g_list_length(m_pages) > 1) || (((NedPage *) g_list_first(m_pages)->data)->getSystemCount() > 1));
if (allow_delete_systems && system->getPage()->getPageNumber() == 0 && ((NedPage *) g_list_first(m_pages)->data)->getSystemCount() < 2) {
allow_delete_systems = false;
}
*/
allow_delete_systems = system->getPage()->getSystemCount() > 1;
if (NedResource::isPlaying()) return;
for (i = 0; i < VOICE_COUNT; i++) {
pan[i] = m_staff_contexts[staff_number].voices[i].m_midi_pan;
vol[i] = m_staff_contexts[staff_number].voices[i].m_midi_volume;
midi_program[i] = m_staff_contexts[staff_number].voices[i].m_midi_program;
}
NedStaffContextDialog *dialog = new NedStaffContextDialog (GTK_WINDOW(m_main_window), this, m_staff_contexts[staff_number].m_different_voices, allow_delete_systems, m_staff_count, staff_number,
m_staff_contexts[staff_number].m_staff_name != NULL ? m_staff_contexts[staff_number].m_staff_name->getText() : NULL,
m_staff_contexts[staff_number].m_staff_short_name != NULL ? m_staff_contexts[staff_number].m_staff_short_name->getText() : NULL,
m_staff_contexts[staff_number].m_group_name != NULL ? m_staff_contexts[staff_number].m_group_name->getText() : NULL,
m_staff_contexts[staff_number].m_group_short_name != NULL ? m_staff_contexts[staff_number].m_group_short_name->getText() : NULL,
m_staff_contexts[staff_number].m_clef_number, m_staff_contexts[staff_number].m_clef_octave_shift, m_staff_contexts[staff_number].m_key_signature_number,
m_numerator, m_denominator, symbol, vol, midi_program,
m_staff_contexts[staff_number].m_midi_channel, (int) (60000.0 / m_midi_tempo_inverse),
pan, m_staff_contexts[staff_number].m_midi_chorus, m_staff_contexts[staff_number].m_play_transposed,
m_staff_contexts[staff_number].m_midi_reverb, m_staff_contexts[staff_number].m_muted);
dialog->getValues(&state, &different_voices, &delete_staff, &delete_system, &position, &staff_name, &staff_short_name, &group_name, &group_short_name, &clef_number, &octave_shift, &key_signature_number, &do_adjust, &numerator, &denominator,
&symbol, vol, midi_program, &channel, &tempo, pan, &chorus, &play_transposed, &reverb, &m_config_changed, newmuted);
delete dialog;
if (delete_staff) {
NedCommandList *command_list = new NedCommandList(this);
NedResource::m_recorded_staff = NULL;
NedDeleteStaffCommand *delete_staff_command = new NedDeleteStaffCommand(this, staff_number);
command_list->addCommand(delete_staff_command);
delete_staff_command->execute();
setAllUnpositioned();
command_list->setFullReposit();
reposit(command_list);
m_command_history->addCommandList(command_list);
return;
}
if (delete_system) {
NedCommandList *command_list = new NedCommandList(this);
NedDeleteSystemCommand *delete_system_command = new NedDeleteSystemCommand(system);
command_list->addCommand(delete_system_command);
delete_system_command->execute();
setAllUnpositioned();
command_list->setFullReposit();
reposit(command_list);
m_command_history->addCommandList(command_list);
return;
}
if (state) {
if (staff_number != position) {
NedShiftStaffCommand *shift_staff_command = new NedShiftStaffCommand(this, staff_number, position);
command_list = new NedCommandList(this);
command_list->addCommand(shift_staff_command);
shift_staff_command->execute();
command_list->setFullReposit();
m_command_history->addCommandList(command_list);
computeSystemIndent();
setAndUpdateClefTypeAndKeySig();
setAllUnpositioned();
reposit(command_list);
repaint();
return; // this has priority; all other operations are ignored
}
if (m_staff_contexts[staff_number].m_staff_name != NULL) {
text_diff = m_staff_contexts[staff_number].m_staff_name->textDiffers(staff_name);
}
else {
text_diff = (staff_name != NULL);
}
if (text_diff) {
if (m_staff_contexts[staff_number].m_staff_name != NULL) {
delete m_staff_contexts[staff_number].m_staff_name;
m_staff_contexts[staff_number].m_staff_name = NULL;
}
if (staff_name != NULL && strlen(staff_name) > 0) {
m_staff_contexts[staff_number].m_staff_name = new NedPangoCairoText(m_drawing_area->window, staff_name, STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, STAFF_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
if (staff_name != NULL) {
free(staff_name);
}
if (m_staff_contexts[staff_number].m_staff_short_name != NULL) {
text_diff = m_staff_contexts[staff_number].m_staff_short_name->textDiffers(staff_short_name);
}
else {
text_diff = (staff_short_name != NULL);
}
if (text_diff) {
if (m_staff_contexts[staff_number].m_staff_short_name != NULL) {
delete m_staff_contexts[staff_number].m_staff_short_name;
m_staff_contexts[staff_number].m_staff_short_name = NULL;
}
if (staff_short_name != NULL && strlen(staff_short_name) > 0) {
m_staff_contexts[staff_number].m_staff_short_name = new NedPangoCairoText(m_drawing_area->window, staff_short_name, STAFF_SHORT_NAME_FONT, STAFF_SHORT_NAME_FONT_SLANT,
STAFF_SHORT_NAME_FONT_WEIGHT, STAFF_SHORT_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
if (staff_short_name != NULL) {
free(staff_short_name);
}
if (m_staff_contexts[staff_number].m_group_short_name != NULL) {
text_diff = m_staff_contexts[staff_number].m_group_short_name->textDiffers(group_name);
}
else {
text_diff = (group_name != NULL);
}
if (text_diff) {
if (m_staff_contexts[staff_number].m_group_name != NULL) {
delete m_staff_contexts[staff_number].m_group_name;
m_staff_contexts[staff_number].m_group_name = NULL;
}
if (group_name != NULL && strlen(group_name) > 0) {
m_staff_contexts[staff_number].m_group_name = new NedPangoCairoText(m_drawing_area->window, group_name, STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, STAFF_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
if (group_name != NULL) {
free(group_name);
}
if (m_staff_contexts[staff_number].m_group_short_name != NULL) {
text_diff = m_staff_contexts[staff_number].m_group_short_name->textDiffers(group_short_name);
}
else {
text_diff = (group_short_name != NULL);
}
if (text_diff) {
if (m_staff_contexts[staff_number].m_group_short_name != NULL) {
delete m_staff_contexts[staff_number].m_group_short_name;
m_staff_contexts[staff_number].m_group_short_name = NULL;
}
if (group_short_name != NULL && strlen(group_short_name) > 0) {
m_staff_contexts[staff_number].m_group_short_name = new NedPangoCairoText(m_drawing_area->window, group_short_name, STAFF_SHORT_NAME_FONT, STAFF_SHORT_NAME_FONT_SLANT,
STAFF_SHORT_NAME_FONT_WEIGHT, STAFF_SHORT_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
if (group_short_name != NULL) {
free(group_short_name);
}
if (m_staff_contexts[staff_number].m_different_voices != different_voices) {
m_staff_contexts[staff_number].m_different_voices = different_voices;
}
for (i = 0; i < VOICE_COUNT; i++) {
if (midi_program[i] >= 0) {
m_staff_contexts[staff_number].voices[i].m_midi_program = midi_program[i];
}
m_staff_contexts[staff_number].voices[i].m_midi_volume = vol[i];
m_staff_contexts[staff_number].voices[i].m_midi_pan = pan[i];
m_staff_contexts[staff_number].m_muted[i] = newmuted[i];
}
m_staff_contexts[staff_number].m_midi_channel = channel;
m_staff_contexts[staff_number].m_midi_chorus = chorus;
m_staff_contexts[staff_number].m_play_transposed = play_transposed;
m_staff_contexts[staff_number].m_midi_reverb = reverb;
m_midi_tempo_inverse = 60000.0 / (double) tempo;
if (m_numerator != numerator || m_denominator != denominator || m_timesig_symbol != symbol) {
if (command_list == NULL) {
command_list = new NedCommandList(this);
}
change_timesig_command = new NedChangeTimeSigCommand(this, numerator, denominator, symbol);
change_timesig_command->execute();
command_list->addCommand(change_timesig_command);
command_list->setFullReposit();
//setAllUnpositioned();
//reposit(command_list);
checkForElementsToSplit(command_list);
}
if (m_staff_contexts[staff_number].m_key_signature_number != key_signature_number) {
if (command_list == NULL) {
command_list = new NedCommandList(this);
}
NedChangeStaffKeysigCmd *change_staff_keysig_cmd = new NedChangeStaffKeysigCmd(this, staff_number, key_signature_number, do_adjust);
change_staff_keysig_cmd->execute();
command_list->addCommand(change_staff_keysig_cmd);
command_list->setFullReposit();
setAllUnpositioned();
}
if (m_staff_contexts[staff_number].m_clef_number != clef_number || m_staff_contexts[staff_number].m_clef_octave_shift != octave_shift) {
if (command_list == NULL) {
command_list = new NedCommandList(this);
}
NedChangeStaffClefCmd *change_staff_clef_cmd = new NedChangeStaffClefCmd(this, staff_number, clef_number, octave_shift, do_adjust);
change_staff_clef_cmd->execute();
command_list->addCommand(change_staff_clef_cmd);
command_list->setFullReposit();
setAllUnpositioned();
}
if (command_list != NULL) {
command_list->setFullReposit();
m_command_history->addCommandList(command_list);
}
computeSystemIndent();
setAndUpdateClefTypeAndKeySig();
setAllUnpositioned();
reposit(command_list);
repaint();
}
}
void NedMainWindow::computeSystemIndent() {
int i;
double bracket_indent = 0.0, nested_braceindent = 0.0;
double width, width2 = 0.0;
bool inside_bracket = false;
bool inside_brace = false;
m_2ndnetto_indent =
m_netto_indent =
m_first_system_indent =
m_2nd_system_indent = 0.0;
for (i = 0; i < m_staff_count; i++) {
if (m_staff_contexts[i].m_flags & BRACKET_START) {
bracket_indent = BRACKET_INDENT;
inside_bracket = true;
}
if (m_staff_contexts[i].m_flags & BRACKET_END) {
if (inside_bracket && m_staff_contexts[i].m_group_name) {
if (m_staff_contexts[i].m_group_name->getWidth() > width2) {
width2 = m_staff_contexts[i].m_group_name->getWidth();
}
}
inside_bracket = false;
}
if (m_staff_contexts[i].m_flags & BRACE_END) {
if (inside_brace && m_staff_contexts[i].m_group_name) {
if (m_staff_contexts[i].m_group_name->getWidth() > width2) {
width2 = m_staff_contexts[i].m_group_name->getWidth() + BRACE_X_OFFSET;
}
}
inside_brace = false;
}
if ((m_staff_contexts[i].m_flags & BRACE_START)) {
inside_brace = true;
if (inside_bracket) {
nested_braceindent = NESTED_BRACE_INDENT;
}
bracket_indent = BRACKET_INDENT;
}
if (width2 > m_netto_indent) {
m_netto_indent = width2;
}
if (m_staff_contexts[i].m_staff_name == NULL) continue;
width = m_staff_contexts[i].m_staff_name->getWidth();
if (width > m_netto_indent) {
m_netto_indent = width;
}
}
if (m_netto_indent > 0.0) {
m_first_system_indent = m_netto_indent / m_current_zoom / getCurrentScale() + SYSTEM_INTENT_SEC_SPACE + bracket_indent + 2 * nested_braceindent;
}
inside_brace = inside_bracket = 0;
width2 = 0.0;
for (i = 0; i < m_staff_count; i++) {
if (m_staff_contexts[i].m_flags & BRACKET_START) {
inside_bracket = true;
}
if (m_staff_contexts[i].m_flags & BRACKET_END) {
if (inside_bracket && m_staff_contexts[i].m_group_short_name) {
if (m_staff_contexts[i].m_group_short_name->getWidth() > width2) {
width2 = m_staff_contexts[i].m_group_short_name->getWidth();
}
}
inside_bracket = false;
}
if (m_staff_contexts[i].m_flags & BRACE_END) {
if (inside_brace && m_staff_contexts[i].m_group_short_name) {
if (m_staff_contexts[i].m_group_short_name->getWidth() > width2) {
width2 = m_staff_contexts[i].m_group_short_name->getWidth();
}
}
inside_brace = false;
}
if ((m_staff_contexts[i].m_flags & BRACE_START)) {
inside_brace = true;
}
if (width2 > m_2ndnetto_indent) {
m_2ndnetto_indent = width2;
}
if (m_staff_contexts[i].m_staff_short_name == NULL) continue;
width = m_staff_contexts[i].m_staff_short_name->getWidth();
if (width > m_2ndnetto_indent) {
m_2ndnetto_indent = width;
}
}
if (m_2ndnetto_indent > 0.0) {
m_2nd_system_indent = m_2ndnetto_indent / m_current_zoom / getCurrentScale() + 2 * SYSTEM_INTENT_SEC_SPACE + bracket_indent + 2 * nested_braceindent;
}
}
void NedMainWindow::setSelected(NedChordOrRest *chord_or_rest, NedNote *note) {
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(m_keyboard_insert_action))) {
m_selected_chord_or_rest = NULL;
m_selected_tie_forward = NULL;
m_selected_note = NULL;
return;
}
m_selected_chord_or_rest = chord_or_rest;
m_selected_note = note;
}
void NedMainWindow::setVisibleSystem(NedSystem *system) {
#define OFFS 1.0
NedPage *page;
page = system->getPage();
double ytop = system->getYPos() * m_current_zoom * getCurrentScale() - m_topy;
double height = system->getHeight() * m_current_zoom * getCurrentScale();
double page_height = page->getHeight() * m_current_zoom * getCurrentScale();
double ybot = ytop + height;
bool repaint_needed = FALSE;
if (ybot > m_drawing_area->allocation.height) {
m_topy = (system->getYPos() - OFFS) * m_current_zoom;
if (m_topy + m_drawing_area->allocation.height > page_height) m_topy = page_height - m_drawing_area->allocation.height;
if (m_topy < 0.0) m_topy = 0.0;
repaint_needed = TRUE;
}
if (ytop < 0) {
m_topy = 0.0;
if (m_topy + m_drawing_area->allocation.height > page_height) m_topy = page_height - m_drawing_area->allocation.height;
repaint_needed = TRUE;
}
else if (ytop < 0) {
m_topy = ytop + OFFS;
if (m_topy < 0) {
m_topy = 0;
}
repaint_needed = TRUE;
}
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
if (repaint_needed) {
repaint();
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), page->getPageNumber() + 1);
}
}
/*
void NedMainWindow::setVisiblePage(NedPage *page) {
int page_nr;
m_leftx = page->getXPos() * m_current_zoom;
if (m_leftx < 0.0) m_leftx = 0.0;
if ((page_nr = g_list_index(m_pages, page)) >= 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), page_nr + 1);
}
repaint();
}
*/
void NedMainWindow::drawVisibleRectangle(cairo_t *cr, NedNote *note) {
double pointx = (note->getPage()->getContentXpos() + note->getChord()->getXPos()) * m_current_zoom - m_leftx;
double pointy = (note->getSystem()->getYPos() + note->getStaff()->getTopPos()) * m_current_zoom - m_topy;
double width = (double) m_drawing_area->allocation.width / getCurrentScale();
double height = (double) m_drawing_area->allocation.height / getCurrentScale();
printf("left: %f, top: %f, width: %f, height: %f\n", pointx, pointy, width, height);
}
void NedMainWindow::setVisible(NedNote *note) {
double pointx = (note->getPage()->getContentXpos() + note->getChord()->getXPos()) * m_current_zoom - m_leftx;
double pointy = (note->getSystem()->getYPos() + note->getStaff()->getBottomPos()) * m_current_zoom - m_topy;
//double pointy = note->getSystem()->getYPos() * m_current_zoom - m_topy;
double width = (double) m_drawing_area->allocation.width / getCurrentScale();
double height = (double) m_drawing_area->allocation.height / getCurrentScale();
bool repaint_needed = false;
if (pointx > width) {
if ((note->getPage()->getContentXpos() + note->getChord()->getXPos() -
note->getPage()->getXPos()) * m_current_zoom < width) {
m_leftx = note->getPage()->getXPos() * m_current_zoom;
}
else {
m_leftx = (note->getPage()->getContentXpos() + note->getChord()->getXPos()) * m_current_zoom;
if (m_leftx < 0.0) m_leftx = 0.0;
}
repaint_needed = true;
}
else if (pointx < 0.0) {
if ((note->getPage()->getContentXpos() + note->getChord()->getXPos() -
note->getPage()->getXPos()) * m_current_zoom < width) {
m_leftx = note->getPage()->getXPos() * m_current_zoom;
}
else {
m_leftx = (note->getPage()->getContentXpos() + note->getChord()->getXPos()) * m_current_zoom - m_drawing_area->allocation.width;
}
repaint_needed = true;
}
if (m_last_y_adjustment != note->getSystem()) {
if (pointy > height) {
m_topy = (note->getSystem()->getYPos() - OFFS) * m_current_zoom;
if (m_topy < 0.0) m_topy = 0.0;
m_last_y_adjustment = note->getSystem();
repaint_needed = true;
}
if (pointy < 0) {
if (note->getSystem()->getBottomPos() * m_current_zoom < height) {
m_topy = 0.0;
}
else {
m_topy = (note->getSystem()->getYPos() - OFFS) * m_current_zoom;
}
m_last_y_adjustment = note->getSystem();
repaint_needed = true;
}
}
if (repaint_needed) {
repaint();
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), note->getPage()->getPageNumber() + 1);
}
}
void NedMainWindow::setVisible(NedChordOrRest *chord_or_rest) {
double pointx = (chord_or_rest->getPage()->getContentXpos() + chord_or_rest->getXPos()) * m_current_zoom - m_leftx;
double pointy = (chord_or_rest->getSystem()->getYPos() + chord_or_rest->getStaff()->getTopPos()) * m_current_zoom - m_topy;
double width = (double) m_drawing_area->allocation.width / getCurrentScale();
double height = (double) m_drawing_area->allocation.height / getCurrentScale();
bool repaint_needed = false;
if (pointx > width) {
if ((chord_or_rest->getPage()->getContentXpos() + chord_or_rest->getXPos() -
chord_or_rest->getPage()->getXPos()) * m_current_zoom < width) {
m_leftx = chord_or_rest->getPage()->getXPos() * m_current_zoom;
}
else {
m_leftx = (chord_or_rest->getPage()->getContentXpos() + chord_or_rest->getXPos()) * m_current_zoom;
if (m_leftx < 0.0) m_leftx = 0.0;
}
repaint_needed = true;
}
else if (pointx < 0.0) {
if ((chord_or_rest->getPage()->getContentXpos() + chord_or_rest->getXPos() -
chord_or_rest->getPage()->getXPos()) * m_current_zoom < width) {
m_leftx = chord_or_rest->getPage()->getXPos() * m_current_zoom;
}
else {
m_leftx = (chord_or_rest->getPage()->getContentXpos() + chord_or_rest->getXPos()) * m_current_zoom - m_drawing_area->allocation.width;
}
repaint_needed = true;
}
if (pointy > height) {
m_topy = (chord_or_rest->getSystem()->getYPos() - OFFS) * m_current_zoom;
if (m_topy < 0.0) m_topy = 0.0;
repaint_needed = true;
}
else if (pointy < 0) {
if (chord_or_rest->getSystem()->getBottomPos() * m_current_zoom < height) {
m_topy = 0.0;
}
else {
m_topy = (chord_or_rest->getSystem()->getYPos() - OFFS) * m_current_zoom;
}
repaint_needed = true;
}
if (repaint_needed) {
repaint();
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), chord_or_rest->getPage()->getPageNumber() + 1);
}
}
void NedMainWindow::toggle_shift_mode(GtkAction *action, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_avoid_feedback) return;
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
main_window->m_avoid_feedback = TRUE;
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(main_window->m_insert_erease_mode_action), FALSE);
main_window->m_avoid_feedback = FALSE;
}
main_window->setCursor();
}
void NedMainWindow::toggle_insert_erease_mode(GtkAction *action, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_avoid_feedback) return;
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
main_window->m_avoid_feedback = TRUE;
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(main_window->m_shift_action), FALSE);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(main_window->m_midi_record_action), FALSE);
NedResource::resetSomeButtons();
NedResource::resetTieButton();
main_window->m_avoid_feedback = FALSE;
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_selected_tie_forward = NULL;
}
main_window->setCursor();
main_window->repaint();
}
void NedMainWindow::resetMidiInput() {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(m_midi_input_action), FALSE);
}
void NedMainWindow::prepare_keyboard_insertion(GtkAction *action, gpointer data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION (action))) {
if (NedChordNameDialog::isAlreadyActive()) return;
gtk_toggle_action_set_active(main_window->m_midi_record_action, FALSE);
main_window->m_last_cursor_x = main_window->m_last_cursor_y = -1;
main_window->m_last_obj = NULL;
}
}
void NedMainWindow::setCursor() {
if (getMainWindowStatus() & SHIFT_MODE) {
gdk_window_set_cursor (GDK_WINDOW(m_drawing_area->window), m_hand);
return;
}
if (m_lyrics_mode != NO_LYRICS) {
gdk_window_set_cursor (GDK_WINDOW(m_drawing_area->window), m_pencil);
}
else {
gdk_window_set_cursor (GDK_WINDOW(m_drawing_area->window), m_pointer);
}
}
void NedMainWindow::changeLength() {
if (NedResource::isPlaying()) return;
if (m_selected_chord_or_rest != NULL && m_selected_chord_or_rest->getType() == TYPE_CHORD &&
NedResource::getCurrentLength() > STROKEN_GRACE && (((getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (m_keyboard_ctrl_mode))) {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->tryChangeLength(m_selected_chord_or_rest)) break;
}
}
}
void NedMainWindow::changeState() {
unsigned int status;
NedCommandList *command_list;
if (m_selected_chord_or_rest != NULL && ((m_selected_chord_or_rest->getType() & (TYPE_CHORD | TYPE_REST)) != 0) &&
NedResource::getCurrentLength() > STROKEN_GRACE && (((getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (m_keyboard_ctrl_mode))) {
status = m_selected_chord_or_rest->getStatus();
status &= (~(CHORD_STAT_MASK));
status |= (NedResource::getStatus() & CHORD_STAT_MASK);
command_list = new NedCommandList(this, m_selected_chord_or_rest->getSystem());
command_list->addCommand(new NedChangeChordOrRestStatusCommand(m_selected_chord_or_rest, status));
command_list->execute();
m_command_history->addCommandList(command_list);
repaint();
}
}
void NedMainWindow::changeDots() {
if (NedResource::isPlaying()) return;
if (m_selected_chord_or_rest != NULL && m_selected_chord_or_rest->getType() == TYPE_CHORD &&
NedResource::getCurrentLength() > STROKEN_GRACE && (((getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (m_keyboard_ctrl_mode))) {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->tryChangeLength(m_selected_chord_or_rest)) break;
}
}
}
void NedMainWindow::changeNoteHead() {
if (NedResource::isPlaying()) return;
if (m_selected_chord_or_rest != NULL && m_selected_chord_or_rest->getType() == TYPE_CHORD &&
NedResource::getCurrentLength() > STROKEN_GRACE && (((getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (m_keyboard_ctrl_mode))) {
if (m_selected_note == NULL) return;
if (m_selected_note->getNoteHead() == NedResource::getCurrentNoteHead()) return;
NedCommandList *command_list = new NedCommandList(this, m_selected_chord_or_rest->getSystem());
command_list->addCommand(new NedChangeNoteHeadCommand(m_selected_note, NedResource::getCurrentNoteHead()));
command_list->execute();
m_command_history->addCommandList(command_list);
repaint();
}
}
void NedMainWindow::changeTieState() {
if (!NedResource::getTiedMode() && m_selected_note != NULL && m_selected_note->getTieForward() != NULL) {
NedCommandList *command_list = new NedCommandList(this, m_selected_chord_or_rest->getSystem());
command_list->addCommand(new NedUnTieForwardCommand(m_selected_note, m_selected_note->getTieForward()));
m_command_history->addCommandList(command_list);
command_list->execute();
}
}
void NedMainWindow::changeNoteState() {
if (m_selected_note != NULL && m_selected_chord_or_rest != NULL && (((getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (m_keyboard_ctrl_mode))) {
unsigned int status = m_selected_note->getStatus();
status &= (~(ACCIDENTAL_MASK));
status |= ACCIDENTAL_MASK & NedResource::getStatus();
NedCommandList *command_list = new NedCommandList(this, m_selected_note->getSystem());
command_list->addCommand(new NedChangeNoteStatusCommand(m_selected_note, status));
m_command_history->addCommandList(command_list);
command_list->execute();
}
}
void NedMainWindow::set_paint_colored(GtkAction *action, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_paint_colored = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
main_window->repaint();
}
void NedMainWindow::initiate_repaint(GtkAction *action, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->repaint();
}
void NedMainWindow::customize_beam(GtkAction *action, gpointer data) {
if (NedResource::isPlaying()) return;
NedChordOrRest *first_element = NULL;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM) {
if (g_list_length(main_window->m_selected_group) > 0) {
first_element = main_window->findAndBeamElementsOfCurrentVoice();
if (first_element != NULL) {
main_window->reposit(NULL, first_element->getPage(), first_element->getSystem());
main_window->repaint();
}
}
return;
}
if (main_window->m_selected_chord_or_rest != NULL && main_window->m_selected_chord_or_rest->getType() == TYPE_CHORD) {
NedCommandList *command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_selected_chord_or_rest->getVoice()->isolate(command_list, main_window->m_selected_chord_or_rest);
if (command_list->getNumberOfCommands() > 0) {
main_window->m_command_history->addCommandList(command_list);
}
else {
delete command_list;
}
main_window->reposit(NULL, main_window->m_selected_chord_or_rest->getPage(), main_window->m_selected_chord_or_rest->getSystem());
main_window->repaint();
}
}
void NedMainWindow::flip_stem(GtkAction *action, gpointer data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_chord_or_rest == NULL) return;
if (main_window->m_selected_chord_or_rest->getType() != TYPE_CHORD) return;
if (main_window->m_selected_chord_or_rest->getFirstNote()->getNoteHead() == GUITAR_NOTE_STEM ||
main_window->m_selected_chord_or_rest->getFirstNote()->getNoteHead() == GUITAR_NOTE_NO_STEM) return;
NedCommandList *command_list;
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_selected_chord_or_rest->flipStem(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->reposit(NULL, main_window->m_selected_chord_or_rest->getPage(), main_window->m_selected_chord_or_rest->getSystem());
main_window->repaint();
}
void NedMainWindow::resetSomeButtons() {
NedResource::resetSomeButtons();
}
void NedMainWindow::disconnectKeys() {
if (m_lyrics_mode != NO_LYRICS) return;
gtk_action_disconnect_accelerator(GTK_ACTION(m_shift_action));
gtk_action_disconnect_accelerator(GTK_ACTION(m_keyboard_insert_action));
gtk_action_disconnect_accelerator(GTK_ACTION(m_insert_erease_mode_action));
gtk_action_disconnect_accelerator(GTK_ACTION(m_shift_action));
gtk_action_disconnect_accelerator(GTK_ACTION(m_replay_action));
gtk_action_disconnect_accelerator(GTK_ACTION(m_midi_record_action));
}
void NedMainWindow::insert_ppp(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_PPP;
main_window->prepareInsertion();
}
void NedMainWindow::insert_pp(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_PP;
main_window->prepareInsertion();
}
void NedMainWindow::insert_p(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_P;
main_window->prepareInsertion();
}
void NedMainWindow::insert_mp(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_MP;
main_window->prepareInsertion();
}
void NedMainWindow::insert_sp(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_SP;
main_window->prepareInsertion();
}
void NedMainWindow::insert_mf(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_MF;
main_window->prepareInsertion();
}
void NedMainWindow::insert_sf(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_SF;
main_window->prepareInsertion();
}
void NedMainWindow::insert_f(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_F;
main_window->prepareInsertion();
}
void NedMainWindow::insert_ff(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_FF;
main_window->prepareInsertion();
}
void NedMainWindow::insert_fff(GtkAction *widget, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_DYNAMIC;
main_window->m_special_sub_type.m_special_sub_type_int = VOL_FFF;
main_window->prepareInsertion();
}
void NedMainWindow::insert_tempo(GtkAction *widget, gpointer data) {
bool state;
unsigned int kind, tempo;
bool dot;
NedMainWindow *main_window = (NedMainWindow *) data;
NedTempoDialog *dialog = new NedTempoDialog((GTK_WINDOW(main_window->m_main_window)), false);
dialog->getValues(&state, &kind, &dot, &tempo);
delete dialog;
main_window->m_special_type = TYPE_TEMPO;
main_window->m_special_sub_type.m_special_sub_type_int = dot ? (3 * kind / 2 / FACTOR) : (kind / FACTOR);
main_window->m_special_sub_type.m_special_sub_type_int |= (tempo << 16);
main_window->prepareInsertion();
}
void NedMainWindow::insert_text(GtkAction *widget, gpointer data) {
bool state;
char *textptr = NULL;
const char *font_family;
PangoStyle font_slant;
PangoWeight font_weight;
bool enable_volume = false;
bool enable_tempo = false;
unsigned short segno_sign = 0;
int anchor = ANCHOR_MID;
unsigned int volume = 64;
unsigned int tempo = 120;
unsigned int channel;
bool enable_channel;
int midi_pgm;
double font_size;
NedMainWindow *main_window = (NedMainWindow *) data;
font_slant = TEXT_FONT_SLANT_DEFAULT;
font_size = TEXT_FONT_SIZE_DEFAULT;
font_weight = TEXT_FONT_WEIGHT_DEFAULT;
NedTextDialog *dialog = new NedTextDialog (GTK_WINDOW(main_window->m_main_window), textptr, anchor, tempo, enable_tempo, volume, enable_volume, segno_sign, -1, 1, false, TEXT_FONT_NAME_DEFAULT, TEXT_FONT_SIZE_DEFAULT, TEXT_FONT_SLANT_DEFAULT, TEXT_FONT_WEIGHT_DEFAULT);
dialog->getValues(&state, &textptr, &anchor, &tempo, &enable_tempo, &volume, &enable_volume, &segno_sign, &midi_pgm, &channel, &enable_channel, &font_family, &font_size, &font_slant, &font_weight);
if (state) {
/*
NedResource::DbgMsg(DBG_TESTING, "family = %s, size = %f, slant = ", font_family, font_size);
switch (font_slant) {
case CAIRO_FONT_SLANT_NORMAL: NedResource::DbgMsg(DBG_TESTING, "CAIRO_FONT_SLANT_NORMAL"); break;
case CAIRO_FONT_SLANT_ITALIC: NedResource::DbgMsg(DBG_TESTING, "CAIRO_FONT_SLANT_ITALIC"); break;
case CAIRO_FONT_SLANT_OBLIQUE: NedResource::DbgMsg(DBG_TESTING, "CAIRO_FONT_SLANT_OBLIQUE"); break;
default: NedResource::DbgMsg(DBG_TESTING, "unknown"); break;
}
NedResource::DbgMsg(DBG_TESTING, "; weight = ");
switch (font_weight) {
case CAIRO_FONT_WEIGHT_NORMAL: NedResource::DbgMsg(DBG_TESTING, "CAIRO_FONT_WEIGHT_NORMAL"); break;
case CAIRO_FONT_WEIGHT_BOLD: NedResource::DbgMsg(DBG_TESTING, "CAIRO_FONT_WEIGHT_BOLD"); break;
default: NedResource::DbgMsg(DBG_TESTING, "unknown"); break;
}
NedResource::DbgMsg(DBG_TESTING, "\n");
*/
if (main_window->m_freetext != NULL) {
delete main_window->m_freetext;
main_window->m_freetext = NULL;
}
if (textptr != NULL) {
if (strlen(textptr) > 0) {
main_window->m_freetext = new NedFreeText(textptr, main_window->m_drawing_area, anchor, tempo, enable_tempo,
volume, enable_volume, segno_sign, midi_pgm,
channel, enable_channel,
font_family, font_size, font_slant, font_weight);
free(textptr);
main_window->m_special_type = TYPE_FREE_TEXT;
main_window->prepareInsertion();
}
}
}
delete dialog;
}
void NedMainWindow::set_lyrics_mode1(GtkAction *widget, gpointer data) {
if (NedChordNameDialog::isAlreadyActive()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->disconnectKeys();
main_window->m_lyrics_mode = LYRICS1;
main_window->setCursor();
main_window->repaint();
}
void NedMainWindow::set_lyrics_mode2(GtkAction *widget, gpointer data) {
if (NedChordNameDialog::isAlreadyActive()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->disconnectKeys();
main_window->m_lyrics_mode = LYRICS2;
main_window->setCursor();
main_window->repaint();
}
void NedMainWindow::set_lyrics_mode3(GtkAction *widget, gpointer data) {
if (NedChordNameDialog::isAlreadyActive()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->disconnectKeys();
main_window->m_lyrics_mode = LYRICS3;
main_window->setCursor();
main_window->repaint();
}
void NedMainWindow::set_lyrics_mode4(GtkAction *widget, gpointer data) {
if (NedChordNameDialog::isAlreadyActive()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->disconnectKeys();
main_window->m_lyrics_mode = LYRICS4;
main_window->setCursor();
main_window->repaint();
}
void NedMainWindow::set_lyrics_mode5(GtkAction *widget, gpointer data) {
if (NedChordNameDialog::isAlreadyActive()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->disconnectKeys();
main_window->m_lyrics_mode = LYRICS5;
main_window->setCursor();
main_window->repaint();
}
void NedMainWindow::resetLyricsMode() {
if (m_lyrics_mode == NO_LYRICS) return;
gtk_action_connect_accelerator(GTK_ACTION(m_shift_action));
gtk_action_connect_accelerator(GTK_ACTION(m_keyboard_insert_action));
gtk_action_connect_accelerator(GTK_ACTION(m_insert_erease_mode_action));
gtk_action_connect_accelerator(GTK_ACTION(m_shift_action));
gtk_action_connect_accelerator(GTK_ACTION(m_replay_action));
gtk_action_connect_accelerator(GTK_ACTION(m_midi_record_action));
m_lyrics_mode = NO_LYRICS;
setCursor();
}
void NedMainWindow::lyrics_editor(GtkWidget *widget, void *data) {
int staff_nr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_lyrics_mode != NO_LYRICS) return;
if (main_window->m_selected_chord_or_rest != NULL) {
staff_nr = main_window->m_selected_chord_or_rest->getStaff()->getStaffNumber();
}
else if (main_window->m_staff_count < 2) {
staff_nr = 0;
}
else {
NedResource::Info("Please select a chord or rest");
return;
}
new NedLyricsEditor(GTK_WINDOW(main_window->m_main_window), main_window, staff_nr);
}
void NedMainWindow::updateLyrics(NedLyricsEditor *leditor, int staff_nr) {
GList *lptr;
NedCommandList *command_list = new NedCommandList(this);
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->setLyrics(command_list, leditor, staff_nr);
}
setAllUnpositioned();
command_list->setFullReposit();
reposit(command_list);
m_command_history->addCommandList(command_list);
repaint();
}
void NedMainWindow::collectLyrics(NedLyricsEditor *leditor, int staff_nr) {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->collectLyrics(leditor, staff_nr);
}
}
void NedMainWindow::stopReplay() {
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(m_replay_action), FALSE);
repaint();
}
void NedMainWindow::repaint() {
GdkRectangle rect;
int dummy;
gdk_window_get_geometry(m_drawing_area->window, &dummy, &dummy, &rect.width, &rect.height, &dummy);
rect.x = rect.y = 0;
gdk_window_invalidate_rect (m_drawing_area->window, &rect, FALSE);
}
void NedMainWindow::new_file(GtkWidget *widget, void *data) {
int i;
GtkWidget *unsaved_dialog;
bool stop_new = FALSE, do_save = FALSE;
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_config_changed || main_window->m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = TRUE; break;
case GTK_RESPONSE_REJECT: stop_new = TRUE; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_new) {
return;
}
if (do_save) {
main_window->save_score(widget, data);
}
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
delete ((NedPage *) lptr->data);
}
g_list_free(main_window->m_pages);
main_window->m_pages = NULL;
for (lptr = g_list_first(main_window->m_special_measures); lptr; lptr = g_list_next(lptr)) {
free(lptr->data);
}
g_list_free(main_window->m_special_measures);
main_window->m_special_measures = NULL;
main_window->m_current_paper = NedResource::getPaperInfo("A4");
main_window->m_portrait = TRUE;
double w = main_window->m_portrait ? main_window->m_current_paper->width : main_window->m_current_paper->height;
double h = main_window->m_portrait ? main_window->m_current_paper->height : main_window->m_current_paper->width;
w /= PS_ZOOM * (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
h /= PS_ZOOM * (double) main_window->m_current_scale / (double) SCALE_GRANULARITY;
main_window->m_global_spacement_fac = 1.0;
main_window->m_numerator = 4;
main_window->m_denominator = 4;
main_window->m_timesig_symbol = TIME_SYMBOL_NONE;
main_window->m_upbeat_inverse = 0;
main_window->m_staff_count = 1;
main_window->m_current_scale = SCALE_GRANULARITY;
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_tie_forward = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_config_changed = FALSE;
main_window->resetLyricsMode();
main_window->m_midi_tempo_inverse = START_TEMPO_INVERSE;
main_window->m_staff_contexts[0].m_key_signature_number = 0;
main_window->m_staff_contexts[0].m_clef_number = 0;
main_window->m_staff_contexts[0].m_clef_octave_shift = 0;
main_window->m_staff_contexts[0].m_different_voices = false;
for (i = 0; i < VOICE_COUNT; i++) {
main_window->m_staff_contexts[0].voices[i].m_midi_volume = 64;
main_window->m_staff_contexts[0].voices[i].m_midi_program = 0;
main_window->m_staff_contexts[0].voices[i].m_midi_pan = 64;
main_window->m_staff_contexts[0].m_muted[i] = false;
}
main_window->m_staff_contexts[0].m_midi_channel = 0;
main_window->m_staff_contexts[0].m_flags = 0;
for (i = 0; i < MAX_STAFFS; i++) {
if (main_window->m_staff_contexts[i].m_staff_name != NULL) {
delete main_window->m_staff_contexts[i].m_staff_name;
main_window->m_staff_contexts[i].m_staff_name = NULL;
}
if (main_window->m_staff_contexts[i].m_staff_short_name != NULL) {
delete main_window->m_staff_contexts[i].m_staff_short_name;
main_window->m_staff_contexts[i].m_staff_short_name = NULL;
}
if (main_window->m_staff_contexts[i].m_group_name != NULL) {
delete main_window->m_staff_contexts[i].m_group_name;
main_window->m_staff_contexts[i].m_group_name = NULL;
}
if (main_window->m_staff_contexts[i].m_group_short_name != NULL) {
delete main_window->m_staff_contexts[i].m_group_short_name;
main_window->m_staff_contexts[i].m_group_short_name = NULL;
}
}
main_window->m_selection_rect.width = 0;
main_window->m_first_page_yoffs = 0.0;
if (main_window->m_selected_group != NULL) {
g_list_free(main_window->m_selected_group);
main_window->m_selected_group = NULL;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(main_window->m_v1bu), TRUE);
gtk_toggle_action_set_active(main_window->m_show_hidden_action, FALSE);
delete main_window->m_score_info;
main_window->m_score_info = new ScoreInfo();
main_window->computeSystemIndent();
main_window->computeScoreTextExtends();
main_window->m_command_history->reset();
main_window->m_current_filename[0] = '\0';
main_window->updatePageCounter();
main_window->m_pages = g_list_append(main_window->m_pages, new NedPage(main_window, w, h, 0, 1, TRUE));
main_window->resetButtons();
gtk_spin_button_set_value(GTK_SPIN_BUTTON(main_window->m_page_selector), 1);
main_window->m_topy = main_window->m_leftx = 0;
gtk_window_set_title (GTK_WINDOW (main_window->m_main_window), "Nted");
main_window->renumberMeasures();
main_window->reposit();
main_window->repaint();
}
void NedMainWindow::save_score(GtkWidget *widget, void *data) {
FILE *fp;
GtkWidget *error_dialog;
char fnamenew[1024];
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_current_filename[0] == '\0') {
save_score_as(widget, data);
return;
}
sprintf(fnamenew, "%s.new", main_window->m_current_filename);
if ((fp = fopen(fnamenew, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), fnamenew);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
return;
}
main_window->storeScore(fp);
if (rename(fnamenew, main_window->m_current_filename) < 0) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot rename %s to %s"), fnamenew, main_window->m_current_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
}
}
void NedMainWindow::save_score_as(GtkWidget *widget, void *data) {
FILE *fp;
char fnamenew[1024];
char the_filename[4096], show_file_name[4096];
NedMainWindow *main_window = (NedMainWindow *) data;
char pathfoldername[4096];
DIR *the_directory;
GtkWidget *save_dialog;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
char *filename;
bool ok = FALSE;
bool extend = FALSE;
char *cptr;
char *folder = NULL;
if (NedResource::isPlaying()) return;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.ntd (Nted-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.ntd");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
save_dialog = gtk_file_chooser_dialog_new (_("Save score"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(save_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(save_dialog), file_filter2);
if (NedResource::m_last_folder != NULL) {
if ((the_directory = opendir(NedResource::m_last_folder)) != NULL) { // avoid gtk error message
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(save_dialog), NedResource::m_last_folder);
closedir(the_directory);
}
else {
NedResource::m_last_folder = NULL;
}
}
if (gtk_dialog_run (GTK_DIALOG (save_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (save_dialog));
strcpy(the_filename, filename);
folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER (save_dialog));
g_free (filename);
ok = TRUE;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (save_dialog))) == file_filter1) {
extend = TRUE;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
extend = FALSE;
}
}
if (extend) {
strcat(the_filename, ".ntd");
}
}
gtk_widget_destroy (save_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = FALSE;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
sprintf(fnamenew, "%s.new", the_filename);
if ((fp = fopen(fnamenew, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), fnamenew);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (ok) {
main_window->storeScore(fp);
if (rename(fnamenew, the_filename) < 0) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot rename %s to %s"), fnamenew, the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
}
if ((cptr = strrchr(the_filename, '/')) != NULL) {
strncpy(pathfoldername, the_filename, cptr - the_filename);
pathfoldername[cptr - the_filename] = '\0';
NedResource::m_last_folder = strdup(pathfoldername);
}
else {
NedResource::m_last_folder = strdup(folder);
}
strcpy(main_window->m_current_filename, the_filename);
if ((cptr = strrchr(the_filename, '/')) != NULL) {
cptr++;
}
else {
cptr = the_filename;
}
sprintf(show_file_name, "Nted - %s", cptr);
gtk_window_set_title (GTK_WINDOW (main_window->m_main_window), show_file_name);
NedResource::addToRecentFiles(main_window->m_current_filename);
main_window->updateRecentFiles();
}
if (folder != NULL) {
g_free(folder);
}
}
void NedMainWindow::storeScore(FILE *fp) {
int i;
GList *lptr;
NedResource::prepareAddrStruct();
fprintf(fp, "NTED version 24\n");
fprintf(fp, "HEAD\n");
if (m_score_info->title != NULL && strlen(m_score_info->title->getText()) > 0) {
fprintf(fp, "TITLE : %s\n", m_score_info->title->getText());
}
if (m_score_info->subject != NULL && strlen(m_score_info->subject->getText()) > 0) {
fprintf(fp, "SUBJECT : %s\n", m_score_info->subject->getText());
}
if (m_score_info->composer != NULL && strlen(m_score_info->composer->getText()) > 0) {
fprintf(fp, "COMPOSER : %s\n", m_score_info->composer->getText());
}
if (m_score_info->arranger != NULL && strlen(m_score_info->arranger->getText()) > 0) {
fprintf(fp, "ARRANGER : %s\n", m_score_info->arranger->getText());
}
if (m_score_info->copyright != NULL && strlen(m_score_info->copyright->getText()) > 0) {
fprintf(fp, "COPYRIGHT : %s\n", m_score_info->copyright->getText());
}
fprintf(fp, "MEDIA %s\n", m_current_paper->name);
fprintf(fp, "ORIENTATION %s\n", m_portrait ? "Portrait" : "Landscape");
fprintf(fp, "SPACEMENT %f\n", m_global_spacement_fac);
fprintf(fp, "SCALE %d\n", m_current_scale);
fprintf(fp, "NUMERATOR %d\n", m_numerator);
fprintf(fp, "DENOMINATOR %d\n", m_denominator);
fprintf(fp, "TIMESIG_SYMBOL %d\n", m_timesig_symbol);
fprintf(fp, "TEMPOINVERSE %d\n", (int) m_midi_tempo_inverse);
fprintf(fp, "UPBEAT_INVERSE %u\n", m_upbeat_inverse);
fprintf(fp, "MEASURE_NUMBERS %s\n", gtk_toggle_action_get_active(m_show_measure_numbers_action) ? "On" : "Off");
fprintf(fp, "STAFFS %d\n", ((NedPage *) g_list_first(m_pages)->data)->getNumberOfStaffs());
for (i = 0; i < ((NedPage *) g_list_first(m_pages)->data)->getNumberOfStaffs(); i++) {
fprintf(fp, "STAFF %d: ", i);
if (m_staff_contexts[i].m_staff_name == NULL) {
fprintf(fp, "NAME: 0 ");
}
else if (strlen(m_staff_contexts[i].m_staff_name->getText()) < 1) {
fprintf(fp, "NAME: 0 ");
}
else {
fprintf(fp, "NAME: %zd %s\n", strlen(m_staff_contexts[i].m_staff_name->getText()), m_staff_contexts[i].m_staff_name->getText());
}
if (m_staff_contexts[i].m_staff_short_name == NULL) {
fprintf(fp, "NAME_SHORT_NAME: 0 ");
}
else if (strlen(m_staff_contexts[i].m_staff_short_name->getText()) < 1) {
fprintf(fp, "NAME_SHORT_NAME: 0 ");
}
else {
fprintf(fp, "NAME_SHORT_NAME: %zd %s\n", strlen(m_staff_contexts[i].m_staff_short_name->getText()), m_staff_contexts[i].m_staff_short_name->getText());
}
if (m_staff_contexts[i].m_group_name == NULL) {
fprintf(fp, "GROUP_NAME: 0 ");
}
else if (strlen(m_staff_contexts[i].m_group_name->getText()) < 1) {
fprintf(fp, "GROUP_NAME: 0 ");
}
else {
fprintf(fp, "GROUP_NAME: %zd %s\n", strlen(m_staff_contexts[i].m_group_name->getText()), m_staff_contexts[i].m_group_name->getText());
}
if (m_staff_contexts[i].m_group_short_name == NULL) {
fprintf(fp, "GROUP_SHORT_NAME: 0 ");
}
else if (strlen(m_staff_contexts[i].m_group_short_name->getText()) < 1) {
fprintf(fp, "GROUP_SHORT_NAME: 0 ");
}
else {
fprintf(fp, "GROUP_SHORT_NAME: %zd %s\n", strlen(m_staff_contexts[i].m_group_short_name->getText()), m_staff_contexts[i].m_group_short_name->getText());
}
fprintf(fp, " KEY: %d CLEF: ", m_staff_contexts[i].m_key_signature_number);
switch (m_staff_contexts[i].m_clef_number) {
case TREBLE_CLEF: fprintf(fp, "TREBLE "); break;
case BASS_CLEF: fprintf(fp, "BASS "); break;
case SOPRAN_CLEF: fprintf(fp, "SOPRAN "); break;
case TENOR_CLEF: fprintf(fp, "TENOR "); break;
case NEUTRAL_CLEF1: fprintf(fp, "NEUTRAL1 "); break;
case NEUTRAL_CLEF2: fprintf(fp, "NEUTRAL2 "); break;
case NEUTRAL_CLEF3: fprintf(fp, "NEUTRAL3 "); break;
default: fprintf(fp, "ALTO "); break;
}
fprintf(fp, "%d ", m_staff_contexts[i].m_clef_octave_shift);
fprintf(fp, "CHANNEL: %d DIFFERENT: %s VOL: %d %d %d %d MIDIPGM: %d %d %d %d PAN: %d %d %d %d CHORUS: %d REVERB: %d",
m_staff_contexts[i].m_midi_channel,
m_staff_contexts[i].m_different_voices ? "On" : "Off",
m_staff_contexts[i].voices[0].m_midi_volume,
m_staff_contexts[i].voices[1].m_midi_volume,
m_staff_contexts[i].voices[2].m_midi_volume,
m_staff_contexts[i].voices[3].m_midi_volume,
m_staff_contexts[i].voices[0].m_midi_program,
m_staff_contexts[i].voices[1].m_midi_program,
m_staff_contexts[i].voices[2].m_midi_program,
m_staff_contexts[i].voices[3].m_midi_program,
m_staff_contexts[i].voices[0].m_midi_pan,
m_staff_contexts[i].voices[1].m_midi_pan,
m_staff_contexts[i].voices[2].m_midi_pan,
m_staff_contexts[i].voices[3].m_midi_pan,
m_staff_contexts[i].m_midi_chorus, m_staff_contexts[i].m_midi_reverb);
fprintf(fp, " FLAGS: %x", m_staff_contexts[i].m_flags);
putc('\n', fp);
fprintf(fp, "PLAY_TRANSPOSED: %d\n", m_staff_contexts[i].m_play_transposed);
}
if (m_special_measures != NULL) {
fprintf(fp, "SPEC_MEASURES\n");
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
fprintf(fp, "( %d ", ((SpecialMeasure *) lptr->data)->measure_number);
switch (((SpecialMeasure *) lptr->data)->type & REP_TYPE_MASK) {
case REPEAT_OPEN: fprintf(fp, "REPEAT_OPEN "); break;
case REPEAT_CLOSE: fprintf(fp, "REPEAT_CLOSE %s ", ((SpecialMeasure *) lptr->data)->hide_following ? "HIDE_FOLLOWING": "SHOW_FOLLOWING"); break;
case REPEAT_OPEN_CLOSE: fprintf(fp, "REPEAT_OPEN_CLOSE "); break;
case DOUBLE_BAR: fprintf(fp, "DOUBLE_BAR "); break;
case END_BAR: fprintf(fp, "END_BAR %s ", ((SpecialMeasure *) lptr->data)->hide_following ? "HIDE_FOLLOWING": "SHOW_FOLLOWING"); break;
default: fprintf(fp, "REPEAT_NONE "); break;
}
switch(((SpecialMeasure *) lptr->data)->type & START_TYPE_MASK) {
case REP1START: fprintf(fp, " , REP1START "); break;
case REP2START: fprintf(fp, " , REP2START "); break;
}
switch(((SpecialMeasure *) lptr->data)->type & END_TYPE_MASK) {
case REP1END: fprintf(fp, " , REP1END "); break;
case REP2END: fprintf(fp, " , REP2END "); break;
}
switch(((SpecialMeasure *) lptr->data)->type & TIMESIG_TYPE_MASK) {
case TIMESIG: fprintf(fp, " , TIMSIG ( %d, %d, %d ) ",
((SpecialMeasure *) lptr->data)->numerator, ((SpecialMeasure *) lptr->data)->denominator,
((SpecialMeasure *) lptr->data)->symbol); break;
}
fprintf(fp, ")\n");
}
}
fprintf(fp, "MUSIC\n");
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->savePage(fp);
}
fclose(fp);
m_config_changed = FALSE;
m_command_history->setSavePoint();
}
void NedMainWindow::print_file(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
char print_cmd[4096];
char fname[4096];
int fd;
FILE *psfile;
char Str[1024];
strcpy(fname, "/tmp/nted_tmp-XXXXXX");
if ((fd = mkstemp(fname)) < 0) {
sprintf(Str, "Cannot open %s for writing(1)", fname);
NedResource::Warning(Str);
return;
}
if ((psfile = fdopen(fd, "w")) == NULL) {
sprintf(Str, "Cannot open %s for writing(2)", fname);
NedResource::Warning(Str);
return;
}
main_window->do_export_to_stream(psfile, STREAM_FILE_TYPE_PS);
fclose(psfile);
sprintf(print_cmd, NedResource::m_print_cmd, fname);
system(print_cmd);
NedResource::appendTempFileName(fname);
}
void NedMainWindow::setAndUpdateClefTypeAndKeySig() {
GList *lptr;
bool first = true;
int i;
int clef_and_key_array[3 * m_staff_count];
for (i = 0; i < m_staff_count; i++) {
clef_and_key_array[3 * i + 0] = m_staff_contexts[i].m_clef_number;
clef_and_key_array[3 * i + 1] = m_staff_contexts[i].m_clef_octave_shift;
clef_and_key_array[3 * i + 2] = m_staff_contexts[i].m_key_signature_number;
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->setAndUpdateClefTypeAndKeySig(clef_and_key_array, first);
first = false;
}
}
void NedMainWindow::copy_data(GtkWidget *widget, void *data) {
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_main_clip_board != NULL) {
g_list_free(NedResource::m_main_clip_board);
NedResource::m_main_clip_board = NULL;
}
for (lptr = g_list_first(main_window->m_selected_group); lptr; lptr = g_list_next(lptr)) {
NedResource::m_main_clip_board = g_list_append(NedResource::m_main_clip_board, lptr->data);
}
}
void NedMainWindow::importRecorded(GtkWidget *widget, void *data) {
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_recorded_staff == NULL) {
NedResource::Info("No recorded staff found");
return;
}
if (NedResource::m_main_clip_board != NULL) {
g_list_free(NedResource::m_main_clip_board);
NedResource::m_main_clip_board = NULL;
}
for (lptr = g_list_first(NedResource::m_recorded_staff->getMainWindow()->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->copyDataOfWholeStaff(NedResource::m_recorded_staff->getStaffNumber());
}
NedResource::m_number_of_first_selected_staff = NedResource::m_number_of_last_selected_staff = 0;
paste_data(main_window->m_main_window, data);
}
void NedMainWindow::paste_data(GtkWidget *widget, void *data) {
int start_staff;
unsigned long long midi_time;
unsigned int meas_duration;
NedSystem *system;
int i;
int nelems, num_elems;
GList *c_board;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_main_clip_board == NULL) return;
if (main_window->m_selected_chord_or_rest == NULL) {
NedResource::Info(_("Please select a note or rest!"));
return;
}
start_staff = main_window->m_selected_chord_or_rest->getStaff()->getStaffNumber();
if (main_window->m_selected_chord_or_rest->getTupletVal() != 0 && !NedResource::fittingPosition(main_window->m_selected_chord_or_rest->getMidiTime())) {
NedResource::Info(_("You select a note in an tuplet"));
return;
}
if (NedResource::test_for_incomplete_tuplets(NedResource::m_main_clip_board)) {
NedResource::Info(_("You cannot copy incomplete tuplets!"));
return;
}
system = main_window->m_selected_chord_or_rest->getSystem();
midi_time = main_window->m_selected_chord_or_rest->getMidiTime();
c_board = NedResource::clone_chords_and_rests(NedResource::m_main_clip_board, true);
nelems = 0;
num_elems = g_list_length(c_board);
meas_duration = main_window->m_numerator * WHOLE_NOTE / main_window->m_denominator;
while (nelems != num_elems && system != NULL) {
for (i = 0; i <= NedResource::m_number_of_last_selected_staff - NedResource::m_number_of_first_selected_staff &&
start_staff + i < main_window->m_staff_count; i++) {
if (system->hasTupletConflict(meas_duration, &(c_board), NedResource::m_number_of_first_selected_staff + i, start_staff + i, midi_time)) {
NedResource::Info(_("Paste not possible: A tuplet would cross a measure"));
return;
}
}
system = system->getPage()->getNextSystem(system);
midi_time = 0;
num_elems = nelems;
nelems = g_list_length(c_board);
}
g_list_free(c_board);
c_board = NedResource::clone_chords_and_rests(NedResource::m_main_clip_board, true);
system = main_window->m_selected_chord_or_rest->getSystem();
midi_time = main_window->m_selected_chord_or_rest->getMidiTime();
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_tie_forward = NULL;
main_window->m_selected_note = NULL;
main_window->m_selected_spec_measure = NULL;
NedCommandList *command_list = new NedCommandList(main_window);
nelems = 0;
num_elems = g_list_length(c_board);
while (nelems != num_elems && system != NULL) {
for (i = 0; i <= NedResource::m_number_of_last_selected_staff - NedResource::m_number_of_first_selected_staff &&
start_staff + i < main_window->m_staff_count; i++) {
system->pasteElements(command_list, &(c_board),
NedResource::m_number_of_first_selected_staff + i, start_staff + i, midi_time);
}
system = system->getPage()->getNextSystem(system, command_list);
midi_time = 0;
num_elems = nelems;
nelems = g_list_length(c_board);
}
g_list_free(c_board);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::delete_block(GtkWidget *widget, void *data) {
NedPage *min_page = NULL, *max_page = NULL;
NedSystem *min_sys = NULL, *max_sys = NULL;
GList *lptr;
GList *start_page_ptr, *end_page_ptr;
unsigned long long min_time, max_time;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_main_clip_board != NULL) {
g_list_free(NedResource::m_main_clip_board);
NedResource::m_main_clip_board = NULL;
}
for (lptr = g_list_first(main_window->m_selected_group); lptr; lptr = g_list_next(lptr)) {
NedResource::m_main_clip_board = g_list_append(NedResource::m_main_clip_board, lptr->data);
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->findFromTo(NedResource::m_main_clip_board, &min_page, &max_page, &min_sys, &max_sys);
}
if (min_page != NULL && max_page!= NULL) {
if (min_sys == NULL || max_sys == NULL) {
NedResource::Abort("NedMainWindow::delete_block(1)");
}
if ((start_page_ptr = g_list_find(main_window->m_pages, min_page)) == NULL) {
NedResource::Abort("NedMainWindow::delete_block(2)");
}
if ((end_page_ptr = g_list_find(main_window->m_pages, max_page)) == NULL) {
NedResource::Abort("NedMainWindow::delete_block(3)");
}
min_time = (1 << 30);
min_time = min_time * (1 << 30);
max_time = 0;
if (!min_sys->findStartMeasureLimits(NedResource::m_main_clip_board, &min_time)) return;
if (!max_sys->findEndMeasureLimits(NedResource::m_main_clip_board, &max_time)) return;
NedCommandList *command_list = new NedCommandList(main_window);
while (1) {
if (start_page_ptr == NULL) {
NedResource::Abort("NedMainWindow::delete_block(4)");
}
((NedPage *) start_page_ptr->data)->deleteItemsFromTo(command_list, start_page_ptr->data == min_page,
start_page_ptr->data == max_page, min_sys, max_sys, min_time, max_time);
if (start_page_ptr == end_page_ptr) break;
start_page_ptr = g_list_next(start_page_ptr);
}
main_window->m_selection_rect.width = main_window->m_selection_rect.height = 0;
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
}
void NedMainWindow::append_system(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list = new NedCommandList(main_window);
NedPage *last_page;
last_page = (NedPage *) g_list_last(main_window->m_pages)->data;
NedAppendSystemCommand *app_sys_cmd = new NedAppendSystemCommand(last_page);
app_sys_cmd->execute();
command_list->addCommand(app_sys_cmd);
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::insert_block(GtkWidget *widget, void *data) {
int blockcount;
bool state;
NedMeasure *measure;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_chord_or_rest == NULL) {
NedResource::Info(_("Please select a note or rest!"));
return;
}
NedInsertBlockDialog *dialog = new NedInsertBlockDialog(GTK_WINDOW(main_window->m_main_window));
dialog->getValues(&state, &blockcount);
delete dialog;
if (!state) return;
//measure = main_window->m_selected_chord_or_rest->getSystem()->getMeasure(main_window->m_selected_chord_or_rest->getMidiTime());
measure = main_window->m_selected_chord_or_rest->m_measure;
NedCommandList *command_list = new NedCommandList(main_window);
main_window->m_selected_chord_or_rest->getSystem()->insertBlocks(command_list, blockcount, measure->midi_end);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::empty_block(GtkWidget *widget, void *data) {
NedPage *min_page = NULL, *max_page = NULL;
NedSystem *min_sys = NULL, *max_sys = NULL;
GList *lptr;
GList *start_page_ptr, *end_page_ptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::selection_has_uncomplete_tuplets(main_window->m_selected_group)) {
NedResource::Info(_("Empty not possible because of incomplete tuplets"));
return;
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->findFromTo(main_window->m_selected_group, &min_page, &max_page, &min_sys, &max_sys);
}
if (min_page != NULL && max_page!= NULL) {
if (min_sys == NULL || max_sys == NULL) {
NedResource::Abort("NedMainWindow::empty_block(1)");
}
if ((start_page_ptr = g_list_find(main_window->m_pages, min_page)) == NULL) {
NedResource::Abort("NedMainWindow::empty_block(2)");
}
if ((end_page_ptr = g_list_find(main_window->m_pages, max_page)) == NULL) {
NedResource::Abort("NedMainWindow::empty_block(3)");
}
NedCommandList *command_list = new NedCommandList(main_window);
while (1) {
if (start_page_ptr == NULL) {
NedResource::Abort("NedMainWindow::empty_block(4)");
}
((NedPage *) start_page_ptr->data)->removeNotesFromTo(command_list, main_window->m_selected_group, start_page_ptr->data == min_page,
start_page_ptr->data == max_page, min_sys, max_sys);
if (start_page_ptr == end_page_ptr) break;
start_page_ptr = g_list_next(start_page_ptr);
}
main_window->m_selection_rect.width = main_window->m_selection_rect.height = 0;
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
}
void NedMainWindow::reposit_all(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list = new NedCommandList(main_window);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
if (command_list->getNumberOfCommands() > 0) {
main_window->m_command_history->addCommandList(command_list);
}
main_window->repaint();
}
void NedMainWindow::export_midi(GtkWidget *widget, void *data) {
int i, j;
FILE *fp;
GList *lptr;
char the_filename[4096];
NedMainWindow *main_window = (NedMainWindow *) data;
GtkWidget *midi_export_dialog;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
char *filename;
bool ok = FALSE;
bool extend = FALSE;
char *cptr;
int last_rep_open = 1, last_alternative1 = -1;
SpecialMeasure *spec_ptr;
if (NedResource::isPlaying()) return;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.mid (MIDI-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.mid");
gtk_file_filter_add_pattern(file_filter1, "*.midi");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
midi_export_dialog = gtk_file_chooser_dialog_new ("Export MIDI",
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(midi_export_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(midi_export_dialog), file_filter2);
if (main_window->m_current_filename[0] != '\0') {
strcpy(the_filename, main_window->m_current_filename);
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
*cptr = '\0';
}
}
strcat(the_filename, ".mid");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(midi_export_dialog), the_filename);
}
if (gtk_dialog_run (GTK_DIALOG (midi_export_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (midi_export_dialog));
strcpy(the_filename, filename);
g_free (filename);
ok = TRUE;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (midi_export_dialog))) == file_filter1) {
extend = TRUE;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".mid") || !strcmp(cptr, ".midi")) {
extend = FALSE;
}
}
if (extend) {
strcat(the_filename, ".mid");
}
}
gtk_widget_destroy (midi_export_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = FALSE;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((fp = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
return;
}
for (i = 0; i < main_window->m_staff_count; i++) {
main_window->m_staff_contexts[i].m_effective_channel = main_window->m_staff_contexts[i].m_midi_channel;
main_window->m_staff_contexts[i].m_pitch_offs = 0;
if (main_window->m_staff_contexts[i].m_different_voices) {
for (j = 0; j < VOICE_COUNT; j++) {
main_window->m_staff_contexts[i].voices[j].m_current_midi_program = main_window->m_staff_contexts[i].voices[j].m_midi_program;
NedResource::setStartVolume(main_window->m_staff_contexts[i].m_midi_channel, j,
main_window->m_staff_contexts[i].voices[j].m_midi_volume);
}
}
else {
for (j = 0; j < VOICE_COUNT; j++) {
main_window->m_staff_contexts[i].voices[j].m_current_midi_program = main_window->m_staff_contexts[i].voices[j].m_midi_program;
NedResource::setStartVolume(main_window->m_staff_contexts[i].m_midi_channel, j,
main_window->m_staff_contexts[i].voices[0].m_midi_volume);
}
}
}
for (i = 0; i < main_window->m_staff_count; i++) {
NedResource::MidiCtrl(MIDI_CTL_MSB_PAN, main_window->m_staff_contexts[i].m_midi_channel, main_window->m_staff_contexts[i].voices[0].m_midi_pan);
NedResource::MidiCtrl(MIDI_CTL_LSB_PAN, main_window->m_staff_contexts[i].m_midi_channel, 0);
NedResource::MidiCtrl(MIDI_CTL_E1_REVERB_DEPTH, main_window->m_staff_contexts[i].m_midi_channel, main_window->m_staff_contexts[i].m_midi_reverb);
NedResource::MidiCtrl(MIDI_CTL_E3_CHORUS_DEPTH, main_window->m_staff_contexts[i].m_midi_channel, main_window->m_staff_contexts[i].m_midi_chorus);
}
NedResource::prepareMidiEventList(main_window->m_midi_tempo_inverse);
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->prepareReplay(true);
}
NedResource::correctFermataTempo();
for (lptr = g_list_first(main_window->m_special_measures); lptr; lptr = g_list_next(lptr)) {
spec_ptr = (SpecialMeasure *) lptr->data;
switch (spec_ptr->type & REP_TYPE_MASK) {
case REPEAT_OPEN: last_rep_open = spec_ptr->measure_number; break;
case REPEAT_CLOSE: NedResource::copyAllBetweenMeasures(last_rep_open, last_alternative1, spec_ptr->measure_number);
last_alternative1 = -1; break;
case REPEAT_OPEN_CLOSE: NedResource::copyAllBetweenMeasures(last_rep_open, -1, spec_ptr->measure_number);
last_rep_open = spec_ptr->measure_number;
last_alternative1 = -1;
break;
}
switch (spec_ptr->type & START_TYPE_MASK) {
case REP1START: last_alternative1 = spec_ptr->measure_number; break;
}
}
NedResource::handleSegnos();
NedResource::startMidiExport(fp, main_window);
fclose(fp);
}
}
void NedMainWindow::export_lily(GtkWidget *widget, void *data) {
FILE *fp;
char the_filename[4096];
NedMainWindow *main_window = (NedMainWindow *) data;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
NedLilyPondExportDialog *lily_export_dialog;
bool state, with_break, ok = FALSE;
bool extend = FALSE;
char *cptr;
bool *selected_staves = NULL;
bool *keep_beams = NULL;
if (NedResource::isPlaying()) return;
the_filename[0] = '\0';
if (main_window->m_current_filename[0] != '\0') {
strcpy(the_filename, main_window->m_current_filename);
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
*cptr = '\0';
}
}
strcat(the_filename, ".ly");
}
selected_staves = (bool *) alloca(main_window->m_staff_count * sizeof(bool));
for (int i = 0; i < main_window->m_staff_count; selected_staves[i++] = true);
keep_beams = (bool *) alloca(main_window->m_staff_count * sizeof(bool));
for (int i = 0; i < main_window->m_staff_count; keep_beams[i++] = false);
lily_export_dialog = new NedLilyPondExportDialog(GTK_WINDOW(main_window->m_main_window), main_window, the_filename, selected_staves, keep_beams);
lily_export_dialog->getValues(&state, &with_break);
delete lily_export_dialog;
if (!state) return;
extend = TRUE;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ly")) {
extend = FALSE;
}
}
if (extend) {
strcat(the_filename, ".ly");
}
ok = true;
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = FALSE;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((fp = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
return;
}
main_window->do_lily_export(fp, with_break, selected_staves, keep_beams);
fclose(fp);
}
}
int NedMainWindow::computeLilySize() {
#define LILY_MIN_SIZE 10
#define LILY_MAX_SIZE 27
double m = (double) (LILY_MAX_SIZE - LILY_MIN_SIZE) / ((SCALE_MAX - SCALE_MIN) * (double) SCALE_GRANULARITY);
double n = (double) LILY_MIN_SIZE - SCALE_MIN * (double) SCALE_GRANULARITY * m;
double ly_size = m * (double) m_current_scale + n;
if (ly_size < 12.0) return 11;
if (ly_size < 13.5) return 13;
if (ly_size < 15.0) return 14;
if (ly_size < 17.0) return 16;
if (ly_size < 19.0) return 18;
if (ly_size < 22.5) return 20;
if (ly_size < 24.5) return 23;
return 26;
}
void NedMainWindow::do_lily_export(FILE *fp, bool with_break, bool *selected_staves, bool *keep_beams) {
GList *lptr;
int i, j, k;
unsigned int m, voice_mask[m_staff_count];
int the_voice = 0, voice_count[m_staff_count];
int last_line;
unsigned int midi_len;
NedSystem *last_system = NULL, *dummy = NULL;
unsigned long long end_time = 0, dummy2;
unsigned int partial = 0;
bool open_repeat = false;
bool go_on;
int tabs;
bool in_alternative;
unsigned int lyrics_map[m_staff_count], lm_dummy, *lm;
int clef_number;
int sil_count;
NedSlur *lily_slur;
bool all_staves = true;
bool guitar_chordnames[m_staff_count];
bool chordnames[m_staff_count];
int breath_script;
char Str[1024];
computeLilySize();
for (i = 0; i < m_staff_count; i++) {
guitar_chordnames[i] = false;
chordnames[i] = false;
if (!selected_staves[i]) {
all_staves = false;
break;
}
}
fprintf(fp, "\\header {\n");
if (m_score_info->title != NULL && strlen(m_score_info->title->getText()) > 1) {
NedPangoCairoText::makeLilyString(m_score_info->title->getText(), Str);
fprintf(fp, "\ttitle = \\markup \\center-align {%s}\n", Str);
}
if (m_score_info->subject != NULL && strlen(m_score_info->subject->getText()) > 1) {
NedPangoCairoText::makeLilyString(m_score_info->subject->getText(), Str);
fprintf(fp, "\tsubtitle = \\markup \\center-align {%s}\n", Str);
}
if (m_score_info->composer != NULL && strlen(m_score_info->composer->getText()) > 1) {
NedPangoCairoText::makeLilyString(m_score_info->composer->getText(), Str);
fprintf(fp, "\tcomposer = %s\n", Str);
}
if (m_score_info->arranger != NULL && strlen(m_score_info->arranger->getText()) > 1) {
NedPangoCairoText::makeLilyString(m_score_info->arranger->getText(), Str);
fprintf(fp, "\tarranger = %s\n", Str);
}
if (m_score_info->copyright != NULL && strlen(m_score_info->copyright->getText()) > 1) {
NedPangoCairoText::makeLilyString(m_score_info->copyright->getText(), Str);
fprintf(fp, "\tcopyright = %s\n", Str);
}
fprintf(fp, "}\n\n");
if (!strcmp(m_current_paper->name, "A3")) {
if (m_portrait) {
fprintf(fp, "#(set-default-paper-size \"a3\")\n");
}
else {
fprintf(fp, "#(set-default-paper-size \"a3\" 'landscape)\n");
}
}
else if (!strcmp(m_current_paper->name, "A5")) {
if (m_portrait) {
fprintf(fp, "#(set-default-paper-size \"a5\")\n");
}
else {
fprintf(fp, "#(set-default-paper-size \"a5\" 'landscape)\n");
}
}
else {
if (m_portrait) {
fprintf(fp, "#(set-default-paper-size \"a4\")\n");
}
else {
fprintf(fp, "#(set-default-paper-size \"a4\" 'landscape)\n");
}
}
if (m_current_scale != SCALE_GRANULARITY) {
fprintf(fp, "#(set-global-staff-size %d)\n", computeLilySize());
}
for (go_on = true, lptr = g_list_first(m_special_measures); go_on && lptr; lptr = g_list_next(lptr)) {
switch (((SpecialMeasure *) lptr->data)->type & REP_TYPE_MASK) {
case REPEAT_OPEN_CLOSE:
case REPEAT_CLOSE: open_repeat = true; go_on = false; break;
case REPEAT_OPEN: if (((SpecialMeasure *) lptr->data)->measure_number == 1) open_repeat = true; go_on = false; break;
}
}
if (m_upbeat_inverse != 0) {
partial = m_numerator * WHOLE_NOTE / m_denominator - m_upbeat_inverse;
partial /= NOTE_64;
}
for (i = 0; i < m_staff_count; i++) {
voice_mask[i] = 0x0;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->detectVoices(i, &(voice_mask[i]), &last_system, &end_time);
}
}
for (i = 0; i < m_staff_count; i++) {
if (!selected_staves[i]) continue;
voice_mask[i] = 0x0;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->detectVoices(i, &(voice_mask[i]), &dummy, &dummy2);
}
clef_number = m_staff_contexts[i].m_clef_number;
voice_count[i] = 0;
the_voice = 0;
for (j = 0; j < VOICE_COUNT; j++) {
m = (1 << j);
if ((m & voice_mask[i]) != 0) {
voice_count[i]++;
the_voice = j;
}
}
lyrics_map[i] = 0;
lm = &(lyrics_map[i]);
for (j = 0; j < VOICE_COUNT; j++) {
m = (1 << j);
if ((m & voice_mask[i]) == 0) continue;
if (m_staff_contexts[i].m_clef_number == NEUTRAL_CLEF3) {
fprintf(fp, "Staff%cVoice%c = \\drummode {\n", 'A' + i, 'A' + j);
}
else {
fprintf(fp, "Staff%cVoice%c = \\relative c' {\n", 'A' + i, 'A' + j);
}
if (keep_beams[i]) {
fprintf(fp, " \\autoBeamOff ");
}
if (open_repeat) {
fprintf(fp, "\t\\repeat volta 2 {\n");
}
putc('\t', fp);
last_line = NedResource::determineLastLine(-2, clef_number);
midi_len = 0;
in_alternative = false;
lily_slur = NULL;
breath_script = LILY_BREAH_SCRIPT_RCOMMA;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (!((NedPage *) lptr->data)->exportLilyPond(fp, i, j, &last_line, &midi_len, last_system,
end_time, &in_alternative, &lily_slur, lm, with_break, &(guitar_chordnames[i]), &(chordnames[i]), &breath_script, keep_beams[i])) break;
}
if (in_alternative) { // last measure is REP2END
fprintf(fp, "\n\t}\n\t}\n");
}
fprintf(fp, "\n}\n\n");
if (j == 0 && lyrics_map[i] != 0) {
for (k = 0; k < MAX_LYRICS_LINES; k++) {
if ((lyrics_map[i] & (1 << k)) == 0) continue;
sil_count = 0;
fprintf(fp, "Staff%cLyrics%c = \\lyricmode{\n\t", 'A' + i, 'A' + k);
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (!((NedPage *) lptr->data)->exportLilyLyrics(fp, i, 0, k, last_system, end_time, &sil_count)) {
break;
}
}
fprintf(fp, "\n}\n");
}
}
lm_dummy = 0;
lm = &lm_dummy;
}
if (m_staff_contexts[i].m_clef_number == NEUTRAL_CLEF3) {
fprintf(fp, "Staff%c = \\new DrumStaff { ", 'A' + i);
}
else {
fprintf(fp, "Staff%c = \\new Staff \\relative c' {", 'A' + i);
}
if (m_staff_contexts[i].m_staff_name != NULL && strlen(m_staff_contexts[i].m_staff_name->getText()) > 0) {
fprintf(fp, " \\set Staff.instrumentName = \"%s \"", m_staff_contexts[i].m_staff_name->getText());
}
if (m_staff_contexts[i].m_staff_short_name != NULL && strlen(m_staff_contexts[i].m_staff_short_name->getText()) > 0) {
fprintf(fp, " \\set Staff.shortInstrumentName = \"%s \"", m_staff_contexts[i].m_staff_short_name->getText());
}
fprintf(fp, NedResource::getLilyPondClefName(m_staff_contexts[i].m_clef_number));
fprintf(fp, NedResource::getLilyPondKeySigName(m_staff_contexts[i].m_key_signature_number));
fprintf(fp, " \\time %d/%d", m_numerator, m_denominator);
if (m_upbeat_inverse != 0) {
fprintf(fp, " \\partial 64*%d", partial);
}
fprintf(fp, "\n");
fprintf(fp, "\t<<\n");
for (j = 0; j < VOICE_COUNT; j++) {
m = (1 << j);
if ((m & voice_mask[i]) == 0) continue;
if (m_staff_contexts[i].m_clef_number == NEUTRAL_CLEF3) {
fprintf(fp, "\\drummode{\n\t\t\\Staff%cVoice%c", 'A' + i, 'A' + j);
}
else {
fprintf(fp, "\t\t\\new Voice = \"");
switch(j) {
case 0: if (voice_count[i] > 1) {
fprintf(fp, "one\" { \\voiceOne ");
}
else {
fprintf(fp, "one\" { ");
}
break;
case 1: fprintf(fp, "two\" { \\voiceTwo "); break;
case 2: fprintf(fp, "three\" { \\voiceThree "); break;
case 3: fprintf(fp, "four\" { \\voiceFour "); break;
}
fprintf(fp, "\\Staff%cVoice%c }", 'A' + i, 'A' + j);
}
fprintf(fp, " \n");
if (m_staff_contexts[i].m_clef_number == NEUTRAL_CLEF3) {
fprintf(fp, "\t\t}\n");
}
}
fprintf(fp, "\t>>\n");
fprintf(fp, "\n}\n\n");
if (guitar_chordnames[i]) {
fprintf(fp, "Staff%cGuitarChords = \\new ChordNames {\n", 'A' + i);
fprintf(fp, "\t\\chordmode {\n\t\t");
if (open_repeat) {
fprintf(fp, "\t\\repeat volta 2 {\n");
}
in_alternative = false;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (!((NedPage *) lptr->data)->exportLilyGuitarChordnames(fp, i, &last_line, &midi_len, last_system,
end_time, &in_alternative, with_break)) break;
}
if (in_alternative) { // last measure is REP2END
fprintf(fp, "\n\t}\n\t}\n");
}
fprintf(fp, "\n\t}\n");
fprintf(fp, "}\n\n");
}
if (chordnames[i]) {
fprintf(fp, "Staff%cChords = \\new ChordNames {\n", 'A' + i);
fprintf(fp, "\t\\chordmode {\n\t\t");
if (open_repeat) {
fprintf(fp, "\t\\repeat volta 2 {\n");
}
in_alternative = false;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (!((NedPage *) lptr->data)->exportLilyFreeChordName(fp, i, &last_line, &midi_len, last_system,
end_time, &in_alternative, with_break)) break;
}
if (in_alternative) { // last measure is REP2END
fprintf(fp, "\n\t}\n\t}\n");
}
fprintf(fp, "\n\t}\n");
fprintf(fp, "}\n\n");
}
}
fprintf(fp, "\\score {\n");
fprintf(fp, "\t<<\n");
tabs = 1;
for (i = 0; i < m_staff_count; i++) {
if (!selected_staves[i]) continue;
if ((all_staves && m_staff_contexts[i].m_flags & BRACKET_START) != 0) {
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "\\new StaffGroup <<\n\n");
tabs++;
}
if (all_staves && (m_staff_contexts[i].m_flags & BRACE_START) != 0) {
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "\\new PianoStaff <<\n");
tabs++;
}
if (guitar_chordnames[i]) {
tabs++;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "<<\n");
tabs++;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "\\Staff%cGuitarChords\n", 'A' + i);
tabs--;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, ">>\n");
}
if (chordnames[i]) {
tabs++;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "<<\n");
tabs++;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "\\Staff%cChords\n", 'A' + i);
tabs--;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, ">>\n");
}
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, "\\Staff%c\n", 'A' + i);
for (j = 0; j < MAX_LYRICS_LINES; j++) {
m = (1 << j);
if ((lyrics_map[i] & m) == 0) continue;
for (k = 0; k < tabs; k++) putc('\t', fp);
fprintf(fp, "\\new Lyrics \\lyricsto \"one\" { \\Staff%cLyrics%c }\n", 'A' + i, 'A' + j);
}
if (all_staves && ((m_staff_contexts[i].m_flags & BRACKET_END) != 0)) {
tabs--;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, ">>\n");
}
if (all_staves && ((m_staff_contexts[i].m_flags & BRACE_END) != 0)) {
tabs--;
for (j = 0; j < tabs; j++) putc('\t', fp);
fprintf(fp, ">>\n");
}
}
fprintf(fp, "\t>>\n");
fprintf(fp, "\t\\layout { }\n");
fprintf(fp, "}\n");
}
/*
void NedMainWindow::append_page(GtkWidget *widget, void *data) {
NedCommandList *command_list;
int len;
unsigned int measure_number;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
measure_number = ((NedPage *) g_list_last(main_window->m_pages)->data)->getNumberOfLastMeasure();
command_list = new NedCommandList(main_window, NULL);
len = g_list_length(main_window->m_pages);
command_list->addCommand(new NedAppendNewPageCommand(main_window, len, measure_number + 1));
command_list->execute();
command_list->setFullReposit();
command_list->setRenumber();
main_window->m_command_history->addCommandList(command_list);
main_window->renumberMeasures(NULL, 1, true);
}
void NedMainWindow::insert_page(GtkWidget *widget, void *data) {
NedCommandList *command_list;
int pos;
unsigned int measure_number;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_chord_or_rest == NULL) {
NedResource::Info(_("Please select a note or rest!"));
return;
}
command_list = new NedCommandList(main_window, NULL);
if ((pos = g_list_index(main_window->m_pages, main_window->m_selected_chord_or_rest->getPage())) < 0) {
NedResource::Abort("NedMainWindow::insert_page");
}
measure_number = main_window->m_selected_chord_or_rest->getPage()->getNumberOfLastMeasure();
main_window->m_selected_chord_or_rest->getPage()->testForPageBackwardTies(command_list);
command_list->addCommand(new NedInsertNewPageCommand(main_window, pos, measure_number + 1));
command_list->execute();
main_window->m_command_history->addCommandList(command_list);
}
*/
void NedMainWindow::renumberPages() {
int number = 0;
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->setPageNumber(number++);
}
}
void NedMainWindow::checkForElementsToSplit(NedCommandList *command_list) {
GList *lptr;
int measure_number = 1;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->checkForElementsToSplit(command_list, &measure_number);
}
}
#define ABOUT_WIDTH 700
#define ABOUT_HEIGHT 250
void NedMainWindow::show_about(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
GtkWidget *about_dialog;
NedMainWindow *main_window = (NedMainWindow *) data;
about_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
_("NtEd version %s by Joerg Anders\nSend bug reports to %s\n\nInfos at http://vsr.informatik.tu-chemnitz.de/staff/jan/nted/nted.xhtml\n\nAuthor:\n J.Anders \n\nTranslation: "), PACKAGE_VERSION, PACKAGE_BUGREPORT);
gtk_dialog_run (GTK_DIALOG (about_dialog));
gtk_widget_destroy (about_dialog);
}
#ifdef YELP_PATH
void NedMainWindow::show_docu(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
char arg[1024];
if (main_window->m_docu == NULL || access(YELP_PATH, X_OK)) {
NedResource::Info(_("Excuse! The documentation is not available\n"
"due to an installation error"));
return;
}
switch (fork()) {
case 0:
sprintf(arg, "ghelp:%s", main_window->m_docu);
fprintf(stderr, "YELP_PATH: %s\narg: %s\n", YELP_PATH, arg);
if (execl(YELP_PATH, YELP_PATH, arg, NULL) < 0) {
perror("execl");
NedResource::Info(_("Excuse! Cannot exec"));
return;
}
exit(0);
case -1:
NedResource::Info(_("Excuse! Cannot fork"));
return;
default:
return;
}
}
#endif
void NedMainWindow::show_license(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedResource::showLicense(GTK_WINDOW(main_window->m_main_window));
}
void NedMainWindow::remove_page(GtkWidget *widget, void *data) {
NedCommandList *command_list;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (g_list_length(main_window->m_pages) < 2) return;
command_list = new NedCommandList(main_window, NULL);
command_list->addCommand(new NedRemoveLastPageCommand(main_window));
command_list->setFullReposit();
command_list->execute();
main_window->m_command_history->addCommandList(command_list);
}
void NedMainWindow::remove_empty_pages(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->deleteEmptyPagesAtEnd();
main_window->updatePageCounter();
main_window->setAllUnpositioned();
main_window->reposit();
main_window->repaint();
}
void NedMainWindow::realizeNewSpacement(double spacement) {
m_global_spacement_fac = spacement;
setNewMeasureSpread(spacement);
setAllUnpositioned();
NedCommandList *command_list = new NedCommandList(this);
reposit(command_list);
repaint();
}
void NedMainWindow::change_spacement(GtkWidget *widget, void *data) {
double spacement;
bool state;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedSpacementDialog *dialog = new NedSpacementDialog (GTK_WINDOW(main_window->m_main_window), main_window->m_global_spacement_fac);
dialog->getValues(&state, &spacement);
delete dialog;
if (state) {
NedCommandList *command_list = new NedCommandList(main_window);
NedChangeSpacementCommand *new_spacement_cmd = new NedChangeSpacementCommand(main_window, spacement);
new_spacement_cmd->execute();
command_list->addCommand(new_spacement_cmd);
main_window->m_command_history->addCommandList(command_list);
/* --- this is all done during new_spacement_cmd->execute(); see void NedMainWindow::realizeNewSpacement(double spacement) */
//command_list->setFullReposit();
//main_window->setAllUnpositioned();
//NedCommandList *command_list2 = new NedCommandList(main_window);
//main_window->reposit(command_list2);
//main_window->repaint();
}
}
void NedMainWindow::popup_tools(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedResource::popup_tools((NedMainWindow*) data);
}
void NedMainWindow::set_upbeat_measure(GtkWidget *widget, void *data) {
unsigned int measure_length;
NedCommandList *command_list;
NedChangeUpbeadCommand *change_up_beat_cmd;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_chord_or_rest == NULL) return;
measure_length = main_window->m_numerator * WHOLE_NOTE / main_window->m_denominator;
if (main_window->m_selected_chord_or_rest->getMidiTime() >= measure_length) return;
change_up_beat_cmd = new NedChangeUpbeadCommand(main_window, measure_length - main_window->m_selected_chord_or_rest->getMidiTime());
change_up_beat_cmd->execute();
command_list = new NedCommandList(main_window);
command_list->addCommand(change_up_beat_cmd);
main_window->computeSystemIndent();
main_window->reposit(command_list);
//((NedPage *) g_list_first(main_window->m_pages)->data)->getFirstSystem()->assignMidiTimes();
main_window->checkForElementsToSplit(command_list);
//((NedPage *) g_list_first(main_window->m_pages)->data)->getFirstSystem()->assignMidiTimes();
main_window->m_command_history->addCommandList(command_list);
command_list->setFullReposit();
main_window->setAndUpdateClefTypeAndKeySig();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->repaint();
}
void NedMainWindow::set_upbeat_start(GtkWidget *widget, void *data) {
unsigned int measure_length;
NedCommandList *command_list;
unsigned int upbeat_inverse;
NedChangeUpbeadCommand *change_up_beat_cmd;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_chord_or_rest == NULL) return;
upbeat_inverse = main_window->m_selected_chord_or_rest->getMidiTime();
measure_length = main_window->m_numerator * WHOLE_NOTE / main_window->m_denominator;
if (main_window->m_selected_chord_or_rest->getMidiTime() >= measure_length) return;
command_list = new NedCommandList(main_window);
if (!((NedPage *) g_list_first(main_window->m_pages)->data)->getFirstSystem()->truncateAtStart(command_list, main_window->m_selected_chord_or_rest->getMidiTime())) {
NedResource::Info("Upbeat not possible here because note structures must be destroyed");
return;
}
command_list->execute();
((NedPage *) g_list_first(main_window->m_pages)->data)->getFirstSystem()->assignMidiTimes();
change_up_beat_cmd = new NedChangeUpbeadCommand(main_window, upbeat_inverse);
change_up_beat_cmd->execute();
command_list->addCommand(change_up_beat_cmd);
main_window->computeSystemIndent();
//((NedPage *) g_list_first(main_window->m_pages)->data)->getFirstSystem()->assignMidiTimes();
//main_window->checkForElementsToSplit(command_list);
((NedPage *) g_list_first(main_window->m_pages)->data)->getFirstSystem()->assignMidiTimes();
main_window->m_command_history->addCommandList(command_list);
command_list->setFullReposit();
main_window->setAndUpdateClefTypeAndKeySig();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->repaint();
}
void NedMainWindow::edit_score_info(GtkWidget *widget, void *data) {
bool state;
NedMainWindow *main_window = (NedMainWindow *) data;
NedScoreInfoConfigDialog *dialog = new NedScoreInfoConfigDialog(GTK_WINDOW(main_window->m_main_window), main_window, main_window->m_score_info);
dialog->getValues(&state);
delete dialog;
if (!state) return;
main_window->computeScoreTextExtends();
NedCommandList *command_list = new NedCommandList(main_window);
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
if (command_list->getNumberOfCommands() > 0) {
main_window->m_command_history->addCommandList(command_list);
}
main_window->repaint();
}
void NedMainWindow::mute_staves(GtkWidget *widget, void *data) {
int i, j;
bool state;
NedMainWindow *main_window = (NedMainWindow *) data;
bool mutes[main_window->m_staff_count];
NedMuteDialog *dialog = new NedMuteDialog(GTK_WINDOW(main_window->m_main_window), mutes, main_window->m_staff_contexts, main_window->m_staff_count);
dialog->getValues(&state);
if (state) {
for (i = 0; i < main_window->m_staff_count; i++) {
for (j = 0; j < VOICE_COUNT; j++) {
main_window->m_staff_contexts[i].m_muted[j] = mutes[i];
}
}
}
delete dialog;
}
void NedMainWindow::transpose(GtkWidget *widget, void *data) {
NedTransposeCommand *transpose_cmd;
int pitchdist;
bool state, selected;
NedMainWindow *main_window = (NedMainWindow *) data;
bool staff_list[main_window->m_staff_count];
selected = main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM;
if (selected) {
if (g_list_length(main_window->m_selected_group) < 1) selected = false;
}
NedSelectorDialog *dialog = new NedSelectorDialog(GTK_WINDOW(main_window->m_main_window), true, staff_list, selected, main_window->m_staff_contexts, main_window->m_staff_count);
dialog->getValues(&state, &pitchdist, &selected);
delete dialog;
if (!state) return;
NedCommandList *command_list = new NedCommandList(main_window);
if (main_window->m_selected_group != NULL) {
NedChordOrRest::handleOpenTies(command_list, main_window->m_selected_group);
}
transpose_cmd = new NedTransposeCommand(main_window, pitchdist, main_window->m_staff_count, staff_list, selected ? main_window->m_selected_group : NULL);
command_list->addCommand(transpose_cmd);
transpose_cmd->execute();
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::do_transpose(int pitchdist, bool *staff_list, GList *selected_group) {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->transpose(pitchdist, staff_list, selected_group);
}
}
void NedMainWindow::set_all_halfs_to_sharp(GtkWidget *widget, void *data) {
GList *lptr;
bool state, selected;
int dummy;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
bool staff_list[main_window->m_staff_count];
selected = main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM;
if (selected) {
if (g_list_length(main_window->m_selected_group) < 1) selected = false;
}
NedSelectorDialog *dialog = new NedSelectorDialog(GTK_WINDOW(main_window->m_main_window), false, staff_list, selected, main_window->m_staff_contexts, main_window->m_staff_count);
dialog->getValues(&state, &dummy, &selected);
delete dialog;
if (!state) return;
NedCommandList *command_list = new NedCommandList(main_window);
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->changeAccidentals(command_list, 1, staff_list, selected ? main_window->m_selected_group : NULL);
}
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::set_all_halfs_to_flat(GtkWidget *widget, void *data) {
GList *lptr;
bool state, selected;
int dummy;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
bool staff_list[main_window->m_staff_count];
selected = main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM;
if (selected) {
if (g_list_length(main_window->m_selected_group) < 1) selected = false;
}
NedSelectorDialog *dialog = new NedSelectorDialog(GTK_WINDOW(main_window->m_main_window), false, staff_list, selected, main_window->m_staff_contexts, main_window->m_staff_count);
dialog->getValues(&state, &dummy, &selected);
delete dialog;
if (!state) return;
NedCommandList *command_list = new NedCommandList(main_window);
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->changeAccidentals(command_list, -1, staff_list, selected ? main_window->m_selected_group : NULL);
}
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::hide_rests(GtkWidget *widget, void *data) {
int current_voice_nr;
NedChordOrRest *element;
int staff_number = -1;
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list = new NedCommandList(main_window);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(main_window->m_v2bu))) {
current_voice_nr = 1;
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(main_window->m_v3bu))) {
current_voice_nr = 2;
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(main_window->m_v4bu))) {
current_voice_nr = 3;
}
else {
current_voice_nr = 0;
}
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM &&
g_list_length(main_window->m_selected_group) > 0) {
for (lptr = g_list_first(main_window->m_selected_group); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
if (element->getVoice()->getVoiceNumber() != current_voice_nr) continue;
element->hideRest(command_list, false);
}
}
else {
if (main_window->m_selected_chord_or_rest != NULL) {
staff_number = main_window->m_selected_chord_or_rest->getStaff()->getStaffNumber();
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->hideRests(command_list, false, staff_number, current_voice_nr);
}
}
main_window->setAllUnpositioned();
command_list->setFullReposit();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::unhide_rests(GtkWidget *widget, void *data) {
int current_voice_nr;
NedChordOrRest *element;
int staff_number = -1;
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list = new NedCommandList(main_window);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(main_window->m_v2bu))) {
current_voice_nr = 1;
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(main_window->m_v3bu))) {
current_voice_nr = 2;
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(main_window->m_v4bu))) {
current_voice_nr = 3;
}
else {
current_voice_nr = 0;
}
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM &&
g_list_length(main_window->m_selected_group) > 0) {
for (lptr = g_list_first(main_window->m_selected_group); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
if (element->getVoice()->getVoiceNumber() != current_voice_nr) continue;
element->hideRest(command_list, true);
}
}
else {
if (main_window->m_selected_chord_or_rest != NULL) {
staff_number = main_window->m_selected_chord_or_rest->getStaff()->getStaffNumber();
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->hideRests(command_list, true, staff_number, current_voice_nr);
}
}
main_window->setAllUnpositioned();
command_list->setFullReposit();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::hide_rests_of_all_voices(GtkWidget *widget, void *data) {
NedChordOrRest *element;
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list = new NedCommandList(main_window);
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM &&
g_list_length(main_window->m_selected_group) > 0) {
for (lptr = g_list_first(main_window->m_selected_group); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
element->hideRest(command_list, false);
}
}
main_window->setAllUnpositioned();
command_list->setFullReposit();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::unhide_rests_of_all_voices(GtkWidget *widget, void *data) {
NedChordOrRest *element;
GList *lptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list = new NedCommandList(main_window);
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM &&
g_list_length(main_window->m_selected_group) > 0) {
for (lptr = g_list_first(main_window->m_selected_group); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
element->hideRest(command_list, false);
}
}
main_window->setAllUnpositioned();
command_list->setFullReposit();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
void NedMainWindow::shiftNotes(unsigned long long start_time, int linedist, NedPage *start_page, NedSystem *start_system, int staff_number) {
GList *lptr;
if (start_page == NULL) {
lptr = g_list_first(m_pages);
}
else {
if ((lptr = g_list_find(m_pages, start_page)) == NULL) {
NedResource::Abort("NedMainWindow::shiftNotes");
}
}
for (; lptr; lptr = g_list_next(lptr), start_system = NULL) {
if (!((NedPage *) lptr->data)->shiftNotes(start_time, linedist, start_system, staff_number)) return;
}
}
void NedMainWindow::computeScoreTextExtends() {
cairo_t *cr = NULL;
m_first_page_yoffs = 0.0;
if (m_score_info->title != NULL) {
m_score_info->title_extends.width = m_score_info->title->getWidth() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_score_info->title_extends.height = m_score_info->title->getHeight() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_first_page_yoffs += m_score_info->title_extends.height + SCORE_INFO_EXTRA_DIST / ((double) m_current_scale / (double) SCALE_GRANULARITY);
}
if (m_score_info->subject != NULL) {
m_score_info->subject_extends.width = m_score_info->subject->getWidth() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_score_info->subject_extends.height = m_score_info->subject->getHeight() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_first_page_yoffs += m_score_info->subject_extends.height ;
}
if (m_score_info->composer != NULL) {
m_score_info->composer_extends.width = m_score_info->composer->getWidth() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_score_info->composer_extends.height = m_score_info->composer->getHeight() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_first_page_yoffs += m_score_info->composer_extends.height + SCORE_INFO_EXTRA_DIST / ((double) m_current_scale / (double) SCALE_GRANULARITY);
}
if (m_score_info->arranger != NULL) {
m_score_info->arranger_extends.width = m_score_info->arranger->getWidth() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_score_info->arranger_extends.height = m_score_info->arranger->getHeight() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_first_page_yoffs += m_score_info->arranger_extends.height + SCORE_INFO_EXTRA_DIST / ((double) m_current_scale / (double) SCALE_GRANULARITY);
}
if (m_score_info->copyright != NULL) {
m_score_info->copyright_extends.width = m_score_info->copyright->getWidth() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_score_info->copyright_extends.height = m_score_info->copyright->getHeight() / m_current_zoom / ((double) m_current_scale / (double) SCALE_GRANULARITY);
m_first_page_yoffs += m_score_info->copyright_extends.height + SCORE_INFO_EXTRA_DIST / ((double) m_current_scale / (double) SCALE_GRANULARITY);
}
if (cr != NULL) {
cairo_destroy (cr);
cr = NULL;
}
}
void NedMainWindow::quit_app(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->closeApplication();
}
void NedMainWindow::do_remove_last_staff() {
GList *lptr;
m_staff_count--;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->removeLastStaff();
}
reposit();
repaint();
}
void NedMainWindow::insert_keysig(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
int key_signature_number;
bool state, do_adjust;
NedKeysigDialog *keysigdialog = new NedKeysigDialog(GTK_WINDOW(main_window->m_main_window), 0);
keysigdialog->getValues(&state, &key_signature_number, &do_adjust);
delete keysigdialog;
if (state) {
main_window->m_special_type = (TYPE_KEYSIG | (do_adjust << 24));
main_window->m_special_sub_type.m_special_sub_type_int = key_signature_number;
main_window->prepareInsertion();
}
}
void NedMainWindow::insert_spacer(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
gtk_toggle_action_set_active(main_window->m_show_hidden_action, TRUE);
main_window->m_special_type = TYPE_SPACER;
main_window->prepareInsertion();
}
void NedMainWindow::insert_lines(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
bool state;
int line_type;
NedLinesDialog *linedialog = new NedLinesDialog(GTK_WINDOW(main_window->m_main_window));
linedialog->getValues(&state, &line_type);
delete linedialog;
if (state) {
main_window->prepareInsertion();
switch (line_type) {
case LINE_CRESCENDO:
main_window->m_special_type = TYPE_LINE;
main_window->m_special_sub_type.m_special_sub_type_int = LINE_CRESCENDO;
break;
case LINE_DECRESCENDO:
main_window->m_special_type = TYPE_LINE;
main_window->m_special_sub_type.m_special_sub_type_int = LINE_DECRESCENDO;
break;
case LINE_OCTAVATION1:
main_window->m_special_type = TYPE_LINE; main_window->m_special_sub_type.m_special_sub_type_int = LINE_OCTAVATION1; break;
case LINE_OCTAVATION_1:
main_window->m_special_type = TYPE_LINE; main_window->m_special_sub_type.m_special_sub_type_int = LINE_OCTAVATION_1; break;
case LINE_OCTAVATION2:
main_window->m_special_type = TYPE_LINE; main_window->m_special_sub_type.m_special_sub_type_int = LINE_OCTAVATION2; break;
case LINE_OCTAVATION_2:
main_window->m_special_type = TYPE_LINE; main_window->m_special_sub_type.m_special_sub_type_int = LINE_OCTAVATION_2; break;
}
}
}
void NedMainWindow::insert_signs(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
bool state;
int sign_type;
NedSignsDialog *signsdialog = new NedSignsDialog(GTK_WINDOW(main_window->m_main_window));
signsdialog->getValues(&state, &sign_type);
delete signsdialog;
if (state) {
main_window->prepareInsertion();
switch (sign_type) {
case SIGN_SEGNO:
main_window->m_special_type = TYPE_SIGN;
main_window->m_special_sub_type.m_special_sub_type_int = SIGN_SEGNO;
break;
case SIGN_CODA:
main_window->m_special_type = TYPE_SIGN;
main_window->m_special_sub_type.m_special_sub_type_int = SIGN_CODA;
break;
case SIGN_BREATH1:
main_window->m_special_type = TYPE_STAFF_SIGN;
main_window->m_special_sub_type.m_special_sub_type_int = SIGN_BREATH1;
break;
case SIGN_BREATH2:
main_window->m_special_type = TYPE_STAFF_SIGN;
main_window->m_special_sub_type.m_special_sub_type_int = SIGN_BREATH2;
break;
}
}
}
void NedMainWindow::insert_chord(GtkWidget *widget, void *data) {
bool state;
int chordnum;
unsigned int status;
struct chord_str *chord_ptr;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedChordDialog *dialog = new NedChordDialog (GTK_WINDOW(main_window->m_main_window), main_window, NULL, (GUITAR_CHORD_DRAW_DIAGRAM | GUITAR_CHORD_DRAW_TEXT));
dialog->getValues(&state, &chord_ptr, &chordnum, &status);
if (!state) return;
main_window->m_special_type = TYPE_GUITAR_CHORD;
main_window->m_special_sub_type.m_chord_info.chord_ptr = chord_ptr;
main_window->m_special_sub_type.m_chord_info.chord_name_num = chordnum;
main_window->m_special_sub_type.m_chord_info.status = status;
delete dialog;
main_window->prepareInsertion();
}
void NedMainWindow::setChorNameInfo(char *rootname, char *uptext, char *downtext, double fontsize, double ydist) {
m_special_type = TYPE_CHORDNAME;
m_special_sub_type.m_chordname_info.root_name = rootname;
m_special_sub_type.m_chordname_info.up_name = uptext;
m_special_sub_type.m_chordname_info.down_name = downtext;
m_special_sub_type.m_chordname_info.fontsize = fontsize;
m_special_sub_type.m_chordname_info.ydist = ydist;
prepareInsertion();
}
void NedMainWindow::insert_chord_name(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
if (NedChordNameDialog::isAlreadyActive()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_lyrics_mode >= 0) return;
new NedChordNameDialog (main_window, GTK_WINDOW(main_window->m_main_window), NULL, NULL,NULL, -1.0, -1.0, true);
}
void NedMainWindow::insert_slur(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
GList *lptr;
NedStaff *staff = NULL;
NedPage *page;
int voice_nr = 0;
copy_data(widget, data);
lptr = g_list_first(NedResource::m_main_clip_board);
while (lptr) {
if (((NedChordOrRest *) lptr->data)->getType() != TYPE_CHORD) {
NedResource::m_main_clip_board = g_list_delete_link(NedResource::m_main_clip_board, lptr);
lptr = g_list_first(NedResource::m_main_clip_board);
}
else {
if (staff == NULL) {
staff = ((NedChordOrRest *) lptr->data)->getStaff();
voice_nr = ((NedChordOrRest *) lptr->data)->getVoice()->getVoiceNumber();
}
else if (staff != ((NedChordOrRest *) lptr->data)->getStaff() ||
voice_nr != ((NedChordOrRest *) lptr->data)->getVoice()->getVoiceNumber()) {
NedResource::m_main_clip_board = g_list_delete_link(NedResource::m_main_clip_board, lptr);
lptr = g_list_first(NedResource::m_main_clip_board);
}
else {
lptr = g_list_next(lptr);
}
}
}
if (main_window->m_selection_rect.width < MIN_SELECTION_RECTANGLE_DIM || main_window->m_selection_rect.height < MIN_SELECTION_RECTANGLE_DIM) {
NedResource::Info("Please create a selection rectangle first");
return;
}
page = NULL;
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->isXOnPage(main_window->m_selection_rect.x)) {
page = (NedPage *) lptr->data;
break;
}
}
if (page == NULL) {
NedResource::Abort("No page found");
}
if (g_list_length(NedResource::m_main_clip_board) < 2) {
g_list_free(NedResource::m_main_clip_board);
NedResource::m_main_clip_board = NULL;
}
else {
NedResource::m_main_clip_board = g_list_sort(NedResource::m_main_clip_board,
(gint (*)(const void*, const void*)) NedChordOrRest::compareMidiTimes);
}
page->insertSlur(&(main_window->m_selection_rect));
/*
main_window->m_special_type = TYPE_SLUR;
main_window->m_special_sub_type.m_special_sub_type_int = 0;
main_window->prepareInsertion();
*/
main_window->m_selection_rect.width = main_window->m_selection_rect.height = 0.0;
}
void NedMainWindow::insert_accelerando(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_LINE3;
main_window->m_special_sub_type.m_special_sub_type_int = LINE_ACCELERANDO;
main_window->prepareInsertion();
}
void NedMainWindow::insert_ritardando(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_special_type = TYPE_LINE3;
main_window->m_special_sub_type.m_special_sub_type_int = LINE_RITARDANDO;
main_window->prepareInsertion();
}
void NedMainWindow::append_staff(GtkWidget *widget, void *data) {
unsigned int staff_map = 0;
int midi_channel = -1;
int i;
GList *lptr;
staff_context_str staff_context;
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list;
if (NedResource::isPlaying()) return;
command_list = new NedCommandList(main_window);
for (i = 0; i < main_window->m_staff_count; i++) {
staff_map |= (1 << main_window->m_staff_contexts[i].m_midi_channel);
}
for (i = 0; i < 16; i++) {
if (i == 9) continue;
if ((staff_map & (1 << i)) == 0) {
midi_channel = i;
break;
}
}
if (midi_channel < 0) {
NedResource::DbgMsg(DBG_TESTING, "To many staffs: no free MIDI channel! I choose channel 1\n");
midi_channel = 0;
}
staff_context.m_key_signature_number = 0;
staff_context.m_clef_number = 0;
staff_context.m_clef_octave_shift = 0;
staff_context.m_different_voices = false;
for (i = 0; i < VOICE_COUNT; i++) {
staff_context.voices[i].m_midi_volume = 64;
staff_context.voices[i].m_midi_pan = 64;
staff_context.voices[i].m_midi_program = 0;
staff_context.m_muted[i] = false;
}
staff_context.m_staff_name = NULL;
staff_context.m_staff_short_name = NULL;
staff_context.m_group_name = NULL;
staff_context.m_group_short_name = NULL;
staff_context.m_midi_chorus = 0;
staff_context.m_play_transposed = 0;
staff_context.m_midi_reverb = 0;
staff_context.m_midi_channel = midi_channel;
staff_context.m_flags = 0;
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->appendStaff(command_list);
}
command_list->addCommand(new NedSetStaffContext(main_window, &staff_context, &(main_window->m_staff_count)));
main_window->m_command_history->addCommandList(command_list);
command_list->execute();
command_list->setFullReposit();
main_window->setAllUnpositioned();
command_list->setRenumber(NULL, 0, true);
main_window->reposit(command_list);
main_window->renumberMeasures(NULL, 1, true);
main_window->repaint();
}
void NedMainWindow::insert_tuplet(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
bool state;
int tuplet_val;
int method;
NedMainWindow *main_window = (NedMainWindow *) data;
if (!main_window->m_selected_chord_or_rest) {
NedResource::Info(_("please select a note or rest first"));
return;
}
if (main_window->m_selected_chord_or_rest->getDotCount() != 0) {
NedResource::Info(_("you cannot select an element with dot"));
return;
}
NedTupletDialog *dialog = new NedTupletDialog(GTK_WINDOW(main_window->m_main_window));
dialog->getValues(&state, &tuplet_val, &method);
delete dialog;
if (!state) return;
if (!main_window->m_selected_chord_or_rest->getVoice()->
tryConvertToTuplet(method, tuplet_val, main_window->m_selected_chord_or_rest)) {
NedResource::Info(_("I'm not able to create a tuplet here"));
}
}
void NedMainWindow::remove_tuplet(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (!main_window->m_selected_chord_or_rest) {
NedResource::Info(_("please select a note or rest first"));
return;
}
if (main_window->m_selected_chord_or_rest->getTupletVal() == 0) {
NedResource::Info(_("selected element is not inside a tuplet"));
return;
}
main_window->m_selected_chord_or_rest->getVoice()->removeTuplet(main_window->m_selected_chord_or_rest);
}
void NedMainWindow::insert_clef(GtkWidget *widget, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
int clef_type, octave_shift;
bool state, do_adjust;
NedClefConfigDialog *dialog = new NedClefConfigDialog (GTK_WINDOW(main_window->m_main_window), TREBLE_CLEF, 0);
dialog->getValues(&state, &clef_type, &octave_shift, &do_adjust);
delete dialog;
main_window->m_special_type = (TYPE_CLEF | (do_adjust << 24));
main_window->m_special_sub_type.m_special_sub_type_int = clef_type | ((octave_shift + 100) << 16);
main_window->prepareInsertion();
}
void NedMainWindow::set_brace_system_delimiter(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_number_of_first_selected_staff < 0 ||
NedResource::m_number_of_last_selected_staff < 0) return;
//if (NedResource::m_number_of_last_selected_staff - NedResource::m_number_of_first_selected_staff < 1) return;
main_window->deleteEnclosedBras(BRACE_START, BRACE_END);
main_window->m_staff_contexts[NedResource::m_number_of_first_selected_staff].m_flags |= BRACE_START;
main_window->m_staff_contexts[NedResource::m_number_of_last_selected_staff].m_flags |= BRACE_END;
main_window->computeSystemIndent();
main_window->reposit();
main_window->repaint();
}
void NedMainWindow::set_bracket_system_delimiter(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_number_of_first_selected_staff < 0 ||
NedResource::m_number_of_last_selected_staff < 0) return;
//if (NedResource::m_number_of_last_selected_staff - NedResource::m_number_of_first_selected_staff < 1) return;
if (main_window->deleteEnclosedBras(BRACE_START|BRACKET_START, BRACE_END|BRACKET_END)) {
main_window->m_staff_contexts[NedResource::m_number_of_first_selected_staff].m_flags |= BRACKET_START;
main_window->m_staff_contexts[NedResource::m_number_of_last_selected_staff].m_flags |= BRACKET_END;
main_window->computeSystemIndent();
main_window->reposit();
main_window->repaint();
}
}
void NedMainWindow::set_connected_bar_line(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_number_of_first_selected_staff < 0 ||
NedResource::m_number_of_last_selected_staff < 0) return;
if (NedResource::m_number_of_last_selected_staff - NedResource::m_number_of_first_selected_staff < 1) return;
if (main_window->deleteEnclosedConnections()) {
main_window->m_staff_contexts[NedResource::m_number_of_first_selected_staff].m_flags |= CON_BAR_START;
main_window->m_staff_contexts[NedResource::m_number_of_last_selected_staff].m_flags |= CON_BAR_END;
main_window->repaint();
}
}
void NedMainWindow::remove_system_delimiter(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::m_number_of_first_selected_staff < 0 ||
NedResource::m_number_of_last_selected_staff < 0) return;
main_window->deleteEnclosedBras(BRACE_START|BRACKET_START, BRACE_END|BRACKET_END);
main_window->deleteEnclosedConnections();
main_window->computeSystemIndent();
main_window->reposit();
main_window->repaint();
}
bool NedMainWindow::deleteEnclosedBras(unsigned int starts, unsigned int ends) {
int i, j;
for (i = 0; i < m_staff_count; i++) {
if (i < NedResource::m_number_of_first_selected_staff && (m_staff_contexts[i].m_flags & starts) != 0) {
for (j = i + 1; j < m_staff_count; j++) {
if ((m_staff_contexts[j].m_flags & ends) != 0) {
if (j > NedResource::m_number_of_last_selected_staff) return false;
break;
}
}
}
}
for (i = 0; i < m_staff_count; i++) {
if ((m_staff_contexts[i].m_flags & starts) != 0) {
if (i >= NedResource::m_number_of_first_selected_staff && i <= NedResource::m_number_of_last_selected_staff) {
for (j = i + 1; j < m_staff_count; j++) {
if ((m_staff_contexts[j].m_flags & ends) != 0) {
m_staff_contexts[j].m_flags &= (~ends);
break;
}
}
m_staff_contexts[i].m_flags &= (~starts);
}
}
if ((m_staff_contexts[i].m_flags & ends) != 0) {
if (i >= NedResource::m_number_of_first_selected_staff && i <= NedResource::m_number_of_last_selected_staff) {
for (j = i - 1; j >= 0; j--) {
if ((m_staff_contexts[j].m_flags & starts) != 0) {
m_staff_contexts[j].m_flags &= (~starts);
break;
}
}
}
}
}
return true;
}
bool NedMainWindow::deleteEnclosedConnections() {
int i, j;
for (i = 0; i < m_staff_count; i++) {
if (i < NedResource::m_number_of_first_selected_staff && (m_staff_contexts[i].m_flags & CON_BAR_START) != 0) {
for (j = i + 1; j < m_staff_count; j++) {
if ((m_staff_contexts[j].m_flags & CON_BAR_END) != 0) {
if (j > NedResource::m_number_of_last_selected_staff) return false;
break;
}
}
}
}
for (i = 0; i < m_staff_count; i++) {
if ((m_staff_contexts[i].m_flags & CON_BAR_START) != 0) {
if (i >= NedResource::m_number_of_first_selected_staff && i <= NedResource::m_number_of_last_selected_staff) {
for (j = i + 1; j < m_staff_count; j++) {
if ((m_staff_contexts[j].m_flags & CON_BAR_END) != 0) {
m_staff_contexts[j].m_flags &= (~(CON_BAR_END));
break;
}
}
m_staff_contexts[i].m_flags &= (~(CON_BAR_START));
}
}
if ((m_staff_contexts[i].m_flags & CON_BAR_END) != 0) {
if (i >= NedResource::m_number_of_first_selected_staff && i <= NedResource::m_number_of_last_selected_staff) {
for (j = i - 1; j >= 0; j--) {
if ((m_staff_contexts[j].m_flags & CON_BAR_START) != 0) {
m_staff_contexts[j].m_flags &= (~(CON_BAR_START));
break;
}
}
}
}
}
return true;
}
gboolean NedMainWindow::handle_delete(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->closeApplication();
return TRUE;
}
void NedMainWindow::handle_page_request(GtkSpinButton *spinbutton, gpointer data) {
int page;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_avoid_feedback) return;
page = (int) gtk_spin_button_get_value(spinbutton);
main_window->setToPage(page);
}
void NedMainWindow::closeApplication() {
GtkWidget *unsaved_dialog;
bool stop_closing, do_save;
GList *lptr;
NedMainWindow *main_window;
if (NedResource::isPlaying()) return;
for (lptr = g_list_first(NedResource::m_main_windows); lptr; lptr = g_list_next(lptr)) {
main_window = (NedMainWindow *) lptr->data;
stop_closing = false; do_save = false;
if (main_window->m_config_changed || main_window->m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = TRUE; break;
case GTK_RESPONSE_REJECT: stop_closing = TRUE; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_closing) {
return;
}
if (do_save) {
save_score(main_window->m_main_window, main_window);
}
}
if (g_list_length(NedResource::m_main_windows) == 1) {
NedResource::cleanup();
}
//delete main_window;
}
/*
g_list_free(NedResource::m_main_windows);
NedResource::m_main_windows = NULL;
*/
gtk_main_quit();
}
void NedMainWindow::restore_score(GtkWidget *widget, void *data) {
FILE *fp;
NedMainWindow *main_window = (NedMainWindow *) data;
DIR *the_directory;
char pathfoldername[4096], *cptr;
GtkWidget *open_dialog;
GtkWidget *error_dialog;
GtkWidget *unsaved_dialog;
char *filename, *folder = NULL;
bool ok = FALSE, stop_opening = FALSE, do_save = FALSE;
if (NedResource::isPlaying()) return;
if (main_window->m_config_changed || main_window->m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = TRUE; break;
case GTK_RESPONSE_REJECT: stop_opening = TRUE; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_opening) {
return;
}
if (do_save) {
main_window->save_score(widget, data);
}
}
open_dialog = gtk_file_chooser_dialog_new (_("Open score"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.ntd (Nted-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.ntd");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(open_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(open_dialog), file_filter2);
if (NedResource::m_last_folder != NULL) {
if ((the_directory = opendir(NedResource::m_last_folder)) != NULL) { // avoid gtk error message
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(open_dialog), NedResource::m_last_folder);
closedir(the_directory);
}
else {
NedResource::m_last_folder = NULL;
}
}
if (gtk_dialog_run (GTK_DIALOG (open_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (open_dialog));
folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER (open_dialog));
ok = TRUE;
}
gtk_widget_destroy (open_dialog);
if (ok) {
if ((fp = fopen(filename, "r")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for reading"), filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (ok) {
main_window->do_restore(fp, filename);
if ((cptr = strrchr(filename, '/')) != NULL) {
strncpy(pathfoldername, filename, cptr - filename);
pathfoldername[cptr - filename] = '\0';
NedResource::m_last_folder = strdup(pathfoldername);
}
else {
NedResource::m_last_folder = strdup(folder);
}
g_free (filename);
fclose(fp);
}
if (folder != NULL) {
g_free(folder);
}
}
void NedMainWindow::do_restore(FILE *fp, char *filename) {
int i, j;
int score_info_idx;
int midi_channel = 0;
unsigned int upbeat_inverse = 0;
int pan, chorus, reverb;
int pagenum;
int tsig_sym;
NedPangoCairoText **sc_ptr;
NedPage *page;
GList *lptr, *newpages = NULL;
int num, denom, tempo_inverse;
char the_filename[4096], *cptr, show_file_name[4096];
int play_transposed;
staff_context_str staff_contexts[MAX_STAFFS];
unsigned int flags;
NedResource::m_error_message = NULL;
NedResource::m_input_line = 1;
char buffer[128];
ScoreInfo *newscoreinfo = new ScoreInfo();
NedResource::prepareAddrStruct();
NedResource::m_avoid_immadiate_play = TRUE;
GList *new_spec_measures = NULL;
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "NTED")) {
NedResource::m_error_message = "NTED expected";
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "version")) {
NedResource::m_error_message = "version expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &m_file_version) || m_file_version < 1 || m_file_version > 24) {
NedResource::m_error_message = "version number expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "HEAD")) {
NedResource::m_error_message = "HEAD expected";
}
}
while(NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "MEDIA, SUBJECT, COMPOSER, ARRANGER, COPYRIGHT OR MEDIA expected";
}
if (!strcmp(buffer, "MEDIA")) {
NedResource::unreadWord(buffer);
break;
}
else if (!strcmp(buffer, "TITLE")) {
sc_ptr = &(newscoreinfo->title);
score_info_idx = 1;
}
else if (!strcmp(buffer, "SUBJECT")){
sc_ptr = &(newscoreinfo->subject);
score_info_idx = 2;
}
else if (!strcmp(buffer, "COMPOSER")){
sc_ptr = &(newscoreinfo->composer);
score_info_idx = 3;
}
else if (!strcmp(buffer, "ARRANGER")) {
sc_ptr = &(newscoreinfo->arranger);
score_info_idx = 4;
}
else if (!strcmp(buffer, "COPYRIGHT")) {
sc_ptr = &(newscoreinfo->copyright);
score_info_idx = 5;
}
else {
NedResource::m_error_message = "MEDIA, SUBJECT, COMPOSER, ARRANGER, COPYRIGHT OR MEDIA expected";
break;
}
if (*sc_ptr != NULL) {
NedResource::m_error_message = "double information";
break;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": expected";
break;
}
if (!NedResource::readTillEnd(fp, buffer)) {
NedResource::m_error_message = "value expected";
break;
}
switch (score_info_idx) {
case 1:
newscoreinfo->title = new NedPangoCairoText(m_drawing_area->window,
buffer, TITLE_FONT, TITLE_FONT_SLANT, TITLE_FONT_WEIGHT, TITLE_FONT_SIZE, m_current_zoom, 1.0, false);
break;
case 2:
newscoreinfo->subject = new NedPangoCairoText(m_drawing_area->window,
buffer, SUBJECT_FONT, SUBJECT_FONT_SLANT, SUBJECT_FONT_WEIGHT, SUBJECT_FONT_SIZE, m_current_zoom, 1.0, false);
break;
case 3:
newscoreinfo->composer = new NedPangoCairoText(m_drawing_area->window,
buffer, COMPOSER_FONT, COMPOSER_FONT_SLANT, COMPOSER_FONT_WEIGHT, COMPOSER_FONT_SIZE, m_current_zoom, 1.0, false);
break;
case 4:
newscoreinfo->arranger = new NedPangoCairoText(m_drawing_area->window,
buffer, ARRANGER_FONT, ARRANGER_FONT_SLANT, ARRANGER_FONT_WEIGHT, ARRANGER_FONT_SIZE, m_current_zoom, 1.0, false);
break;
case 5:
newscoreinfo->copyright = new NedPangoCairoText(m_drawing_area->window,
buffer, STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT, STAFF_NAME_FONT_WEIGHT, STAFF_NAME_FONT_SIZE, m_current_zoom, 1.0, false);
break;
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "MEDIA")) {
NedResource::m_error_message = "MEDIA expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readString(fp, buffer)) {
NedResource::m_error_message = "MEDIA value expected";
}
if ((m_current_paper = NedResource::getPaperInfo(buffer)) == NULL) {
NedResource::m_error_message = "wrong media";
NedResource::DbgMsg(DBG_CRITICAL, "buffer = %s\n", buffer);
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "ORIENTATION")) {
NedResource::m_error_message = "ORIENTATION expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "ORIENTATION value expected";
}
if (!strcmp(buffer, "Portrait")) {
m_portrait = TRUE;
}
else if (!strcmp(buffer, "Landscape")) {
m_portrait = FALSE;
}
else {
NedResource::m_error_message = "Wrong orientation value";
}
}
if (m_file_version > 9) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "SPACEMENT")) {
NedResource::m_error_message = "SPACEMENT expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readFloat(fp, &m_global_spacement_fac) || m_global_spacement_fac < MEASURE_MIN_SPREAD || m_global_spacement_fac > MEASURE_MAX_SPREAD) {
NedResource::m_error_message = "SPACEMENT value expected";
}
}
}
if (m_file_version > 13) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "SCALE")) {
NedResource::m_error_message = "SCALE expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &m_current_scale) || m_current_scale < (int) (SCALE_MIN * (double) SCALE_GRANULARITY - 2.0) ||
m_current_scale > (int) (SCALE_MAX * (double) SCALE_GRANULARITY + 2.0)) {
NedResource::m_error_message = "SCALE value expected";
}
if (m_current_scale > (int) (SCALE_MAX * (double) SCALE_GRANULARITY + 2.0)) {
m_current_scale = (int) (SCALE_MAX * (double) SCALE_GRANULARITY + 2.0);
}
if (m_current_scale < (int) (SCALE_MIN * (double) SCALE_GRANULARITY - 2.0)) {
m_current_scale = (int) (SCALE_MIN * (double) SCALE_GRANULARITY - 2.0);
}
}
}
else {
m_current_scale = SCALE_GRANULARITY;
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "NUMERATOR")) {
NedResource::m_error_message = "NUMERATOR expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &num) || num > 20 || num < 0) {
NedResource::m_error_message = "NUMERATOR value expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "DENOMINATOR")) {
NedResource::m_error_message = "DENOMINATOR expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &denom) || (denom != 2 && denom != 4 && denom != 8 && denom != 16)) {
NedResource::m_error_message = "DENOMINATOR value expected";
}
}
tsig_sym = TIME_SYMBOL_NONE;
if (m_file_version > 16) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "TIMESIG_SYMBOL")) {
NedResource::m_error_message = "TIMESIG_SYMBOL expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &tsig_sym) || ( tsig_sym < TIME_SYMBOL_NONE || tsig_sym > TIME_SYMBOL_CUT_TIME)) {
NedResource::m_error_message = "TIMSIG_SYMBOL value expected";
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "TEMPOINVERSE")) {
NedResource::m_error_message = "TEMPO_INVERSE expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &tempo_inverse) || tempo_inverse > 2900 || tempo_inverse < 200) {
NedResource::m_error_message = "TEMPO INVERSE VALUE value expected";
}
}
if (m_file_version > 2) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "UPBEAT_INVERSE")) {
NedResource::m_error_message = "UPBEAT_INVERSE expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readUnsignedInt(fp, &upbeat_inverse)) {
NedResource::m_error_message = "UPBEAT_INVERSE VALUE value expected";
}
}
}
if (m_file_version > 18) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "MEASURE_NUMBERS")) {
NedResource::m_error_message = "MEASURE_NUMBERS expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || (strcmp(buffer, "On") && strcmp(buffer, "Off"))) {
NedResource::m_error_message = "On or Off expected";
}
if (!strcmp(buffer, "On")) {
gtk_toggle_action_set_active(m_show_measure_numbers_action, TRUE);
}
else {
gtk_toggle_action_set_active(m_show_measure_numbers_action, FALSE);
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "STAFFS")) {
NedResource::m_error_message = "STAFFS expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, & m_pre_staffcount) || m_pre_staffcount > MAX_STAFFS || m_pre_staffcount < 1) {
NedResource::m_error_message = "STAFF COUNT value expected";
}
}
for (i = 0; i < MAX_STAFFS; i++) {
staff_contexts[i].m_staff_name = NULL;
staff_contexts[i].m_staff_short_name = NULL;
staff_contexts[i].m_group_name = NULL;
staff_contexts[i].m_group_short_name = NULL;
}
for (i = 0; NedResource::m_error_message == NULL && i < m_pre_staffcount; i++) {
int key, staffnum, channel, vol, midi_pgm;
staff_contexts[i].m_midi_channel = midi_channel++;
for (j = 0; j < VOICE_COUNT; j++) {
staff_contexts[i].voices[j].m_midi_program = 0;
staff_contexts[i].voices[j].m_midi_pan = 64;
staff_contexts[i].voices[j].m_midi_volume = 64;
staff_contexts[i].m_muted[j] = false;
}
staff_contexts[i].m_flags = 0;
if (staff_contexts[i].m_staff_name != NULL) {
delete staff_contexts[i].m_staff_name;
}
staff_contexts[i].m_staff_short_name = NULL;
if (staff_contexts[i].m_staff_short_name != NULL) {
delete staff_contexts[i].m_staff_short_name;
}
staff_contexts[i].m_staff_short_name = NULL;
if (staff_contexts[i].m_group_name != NULL) {
delete staff_contexts[i].m_group_name;
}
staff_contexts[i].m_group_name = NULL;
if (staff_contexts[i].m_group_short_name != NULL) {
delete staff_contexts[i].m_group_short_name;
}
staff_contexts[i].m_group_short_name = NULL;
staff_contexts[i].m_midi_chorus = 0;
staff_contexts[i].m_play_transposed = 0;
staff_contexts[i].m_midi_reverb = 0;
if (midi_channel == 9) {
midi_channel++;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "STAFF")) {
NedResource::m_error_message = "STAFF expected(1)";
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &staffnum) || staffnum != i) {
NedResource::m_error_message = "STAFF_NUM value expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (1)expected";
}
}
if (m_file_version > 1) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "NAME")) {
NedResource::m_error_message = "NAME expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWordOfLength(fp, buffer)) {
NedResource::m_error_message = "STAFF NAME value expected";
}
else {
if (buffer[0] != '\0') {
if (staff_contexts[i].m_staff_name != NULL) {
delete staff_contexts[i].m_staff_name;
}
staff_contexts[i].m_staff_name = new NedPangoCairoText(m_drawing_area->window, buffer,
STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT, STAFF_NAME_FONT_WEIGHT,
STAFF_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
}
}
if (m_file_version > 10) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "NAME_SHORT_NAME")) {
NedResource::m_error_message = "NAME_SHORT_NAME expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWordOfLength(fp, buffer)) {
NedResource::m_error_message = "STAFF SHORT NAME value expected";
}
else {
if (buffer[0] != '\0') {
if (staff_contexts[i].m_staff_short_name != NULL) {
delete staff_contexts[i].m_staff_short_name;
}
staff_contexts[i].m_staff_short_name = new NedPangoCairoText(m_drawing_area->window, buffer,
STAFF_SHORT_NAME_FONT, STAFF_SHORT_NAME_FONT_SLANT, STAFF_SHORT_NAME_FONT_WEIGHT,
STAFF_SHORT_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
}
}
if (m_file_version > 19) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "GROUP_NAME")) {
NedResource::m_error_message = "GROUP_NAME expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (8)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWordOfLength(fp, buffer)) {
NedResource::m_error_message = "GROUP_NAME value expected";
}
else {
if (buffer[0] != '\0') {
if (staff_contexts[i].m_group_name != NULL) {
delete staff_contexts[i].m_group_name;
}
staff_contexts[i].m_group_name = new NedPangoCairoText(m_drawing_area->window, buffer,
STAFF_SHORT_NAME_FONT, STAFF_SHORT_NAME_FONT_SLANT, STAFF_SHORT_NAME_FONT_WEIGHT,
STAFF_SHORT_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "GROUP_SHORT_NAME")) {
NedResource::m_error_message = "GROUP_SHORT_NAME expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (9)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWordOfLength(fp, buffer)) {
NedResource::m_error_message = "GROUP_SHORT_NAME value expected";
}
else {
if (buffer[0] != '\0') {
if (staff_contexts[i].m_group_short_name != NULL) {
delete staff_contexts[i].m_group_short_name;
}
staff_contexts[i].m_group_short_name = new NedPangoCairoText(m_drawing_area->window, buffer,
STAFF_SHORT_NAME_FONT, STAFF_SHORT_NAME_FONT_SLANT, STAFF_SHORT_NAME_FONT_WEIGHT,
STAFF_SHORT_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "KEY")) {
NedResource::DbgMsg(DBG_CRITICAL, "gelesen: %s\n", buffer);
NedResource::m_error_message = "KEY expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &key) || key < -6 || key > 6) {
NedResource::m_error_message = "KEY value expected";
}
else {
staff_contexts[i].m_key_signature_number = key;
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "CLEF")) {
NedResource::DbgMsg(DBG_CRITICAL, "GOT: *%s*\n", buffer);
NedResource::m_error_message = "CLEF expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = "(3): expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWordWithNum(fp, buffer)) {
NedResource::m_error_message = "CLEF value expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!strcmp(buffer, "TREBLE")) {
staff_contexts[i].m_clef_number = TREBLE_CLEF;
}
else if (!strcmp(buffer, "BASS")) {
staff_contexts[i].m_clef_number = BASS_CLEF;
}
else if (!strcmp(buffer, "ALTO")) {
staff_contexts[i].m_clef_number = ALTO_CLEF;
}
else if (!strcmp(buffer, "TENOR")) {
staff_contexts[i].m_clef_number = TENOR_CLEF;
}
else if (!strcmp(buffer, "SOPRAN")) {
staff_contexts[i].m_clef_number = SOPRAN_CLEF;
}
else if (!strcmp(buffer, "NEUTRAL1")) {
staff_contexts[i].m_clef_number = NEUTRAL_CLEF1;
}
else if (!strcmp(buffer, "NEUTRAL2")) {
staff_contexts[i].m_clef_number = NEUTRAL_CLEF2;
}
else if (!strcmp(buffer, "NEUTRAL3")) {
staff_contexts[i].m_clef_number = NEUTRAL_CLEF3;
}
else {
NedResource::m_error_message = "CLEF value expected";
}
}
staff_contexts[i].m_clef_octave_shift = 0;
if (m_file_version > 3) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &(staff_contexts[i].m_clef_octave_shift)) ||
(staff_contexts[i].m_clef_octave_shift != -12 && staff_contexts[i].m_clef_octave_shift != 0 && staff_contexts[i].m_clef_octave_shift != 12)) {
NedResource::m_error_message = "Octve shift expected";
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "CHANNEL")) {
NedResource::m_error_message = "CHANNEL expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &channel) || channel < 0 || channel > 15) {
NedResource::m_error_message = "CHANNEL number expected";
}
else {
staff_contexts[i].m_midi_channel = channel;
}
}
staff_contexts[i].m_different_voices = false;
if (m_file_version > 23) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "DIFFERENT")) {
NedResource::m_error_message = "DIFFERENT expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "On/Off expected";
}
if (!strcmp(buffer, "On")) {
staff_contexts[i].m_different_voices = true;
}
else if (!strcmp(buffer, "Off")) {
staff_contexts[i].m_different_voices = false;
}
else {
NedResource::m_error_message = "On/Off(2) expected";
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "VOL")) {
NedResource::m_error_message = "VOL expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (m_file_version > 23) {
for (j = 0; j < VOICE_COUNT; j++) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &vol) || vol < 0 || channel > 127) {
NedResource::m_error_message = "volume valueexpected";
}
else {
staff_contexts[i].voices[j].m_midi_volume = vol;
}
}
}
}
else {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &vol) || vol < 0 || channel > 127) {
NedResource::m_error_message = "volume valueexpected";
}
else {
for (j = 0; j < VOICE_COUNT; j++) {
staff_contexts[i].voices[j].m_midi_volume = vol;
}
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "MIDIPGM")) {
NedResource::m_error_message = "MIDIPGM expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (2)expected";
}
}
if (m_file_version > 23) {
if (NedResource::m_error_message == NULL) {
for (j = 0; j < VOICE_COUNT; j++) {
if (!NedResource::readInt(fp, &midi_pgm) || midi_pgm < 0 || midi_pgm >= NedResource::getNumInstruments()) {
NedResource::m_error_message = "PROGRAM number expected";
}
else {
staff_contexts[i].voices[j].m_midi_program = midi_pgm;
}
}
}
}
else {
if (!NedResource::readInt(fp, &midi_pgm) || midi_pgm < 0 || midi_pgm >= NedResource::getNumInstruments()) {
NedResource::m_error_message = "PROGRAM number expected";
}
else {
for (j = 0; j < VOICE_COUNT; j++) {
staff_contexts[i].voices[j].m_midi_program = midi_pgm;
}
}
}
if (m_file_version > 1) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "PAN")) {
NedResource::m_error_message = "PAN expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (3)expected";
}
}
if (m_file_version > 23) {
for (j = 0; j < VOICE_COUNT; j++) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, (int *) &pan)) {
NedResource::m_error_message = "pan value expected";
}
else {
staff_contexts[i].voices[j].m_midi_pan = pan;
}
}
}
}
else {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, (int *) &pan)) {
NedResource::m_error_message = "pan value expected";
}
else {
for (j = 0; j < VOICE_COUNT; j++) {
staff_contexts[i].voices[j].m_midi_pan = pan;
}
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "CHORUS")) {
NedResource::m_error_message = "CHORUS expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (4)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, (int *) &chorus)) {
NedResource::m_error_message = "chorus value expected";
}
else {
staff_contexts[i].m_midi_chorus = chorus;
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "REVERB")) {
NedResource::m_error_message = "REVERB expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (5)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, (int *) &reverb)) {
NedResource::m_error_message = "reverb value expected";
}
else {
staff_contexts[i].m_midi_reverb = reverb;
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "FLAGS")) {
NedResource::m_error_message = "FLAGS expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (6)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readHex(fp, (int *) &flags)) {
NedResource::m_error_message = "flags value expected";
}
else {
staff_contexts[i].m_flags = flags;
}
}
if (m_file_version > 7 ) {
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "PLAY_TRANSPOSED")) {
NedResource::m_error_message = "PLAY_TRANSPOSED expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ":")) {
NedResource::m_error_message = ": (7)expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &play_transposed) || play_transposed < -24 || play_transposed > 24) {
NedResource::m_error_message = "play transposed value expected";
}
else {
staff_contexts[i].m_play_transposed = play_transposed;
}
}
}
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "MUSIC or SPEC_MEASURES expected";
}
if (NedResource::m_error_message == NULL) {
if (!strcmp(buffer, "SPEC_MEASURES")) {
readSpecMeasures(fp, &new_spec_measures);
}
else if (strcmp(buffer, "MUSIC")) {
NedResource::m_error_message = "MUSIC expected";
}
}
}
i = 0;
while (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) {
break;
}
}
if (strcmp(buffer, "PAGE")) {
NedResource::m_error_message = "PAGE expected";
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &pagenum) || pagenum != i) {
NedResource::m_error_message = "Pagenum expected expected";
}
i++;
double w = m_portrait ? m_current_paper->width : m_current_paper->height;
double h = m_portrait ? m_current_paper->height : m_current_paper->width;
w /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
h /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
page = new NedPage(this, w, h, pagenum, 0 /* dummy is reset during "renumberMeasures()" at the end of "reposit()" */, FALSE);
newpages = g_list_append(newpages, page);
page->restorePage(fp);
}
}
if (NedResource::m_error_message == NULL) {
NedResource::DbgMsg(DBG_TESTING, "%s successfully loaded\n", filename);
m_numerator = num;
m_denominator = denom;
m_timesig_symbol = tsig_sym;
m_staff_count = m_pre_staffcount;
for (i = 0; i < m_staff_count; i++) {
if (m_staff_contexts[i].m_staff_name != NULL) {
delete m_staff_contexts[i].m_staff_name;
}
if (m_staff_contexts[i].m_staff_short_name != NULL) {
delete m_staff_contexts[i].m_staff_short_name;
}
if (m_staff_contexts[i].m_group_name != NULL) {
delete m_staff_contexts[i].m_group_name;
}
if (m_staff_contexts[i].m_group_short_name != NULL) {
delete m_staff_contexts[i].m_group_short_name;
}
m_staff_contexts[i] = staff_contexts[i];
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
delete ((NedPage *) lptr->data);
}
g_list_free(m_pages);
m_pages = newpages;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
free(lptr->data);
}
g_list_free(m_special_measures);
m_special_measures = new_spec_measures;
m_command_history->reset();
m_selected_note = NULL;
m_upbeat_inverse = upbeat_inverse;
m_selected_chord_or_rest = NULL;
m_selected_tie_forward = NULL;
m_selected_spec_measure = NULL;
resetLyricsMode();
m_midi_tempo_inverse = tempo_inverse;
m_config_changed = FALSE;
resetButtons();
m_selection_rect.width = 0;
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
delete m_score_info;
m_score_info = newscoreinfo;
computeSystemIndent();
computeScoreTextExtends();
m_topy = m_leftx = 0;
setAndUpdateClefTypeAndKeySig();
reposit();
updatePageCounter();
zoomFreeReplaceables(m_current_zoom, getCurrentScale());
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), 1);
strcpy(m_current_filename, filename);
strcpy(the_filename, filename);
if ((cptr = strrchr(the_filename, '/')) != NULL) {
cptr++;
}
else {
cptr = the_filename;
}
sprintf(show_file_name, "Nted - %s", cptr);
gtk_window_set_title (GTK_WINDOW (m_main_window), show_file_name);
NedResource::addToRecentFiles(filename);
updateRecentFiles();
setAllUnpositioned();
NedCommandList *cm = new NedCommandList(this);
reposit(cm, NULL, NULL, true);
deleteEmptyPagesAtEnd();
setAllUnpositioned();
updatePageCounter();
repaint();
}
else {
delete newscoreinfo;
NedResource::DbgMsg(DBG_CRITICAL, "Error loading %s: line %d: %s\n", filename, NedResource::m_input_line, NedResource::m_error_message);
}
NedResource::m_avoid_immadiate_play = FALSE;
}
void NedMainWindow::import_musicxml(GtkWidget *widget, void *data) {
DIR *the_directory;
char *filename = NULL, *folder = NULL;
GtkWidget *import_dialog;
GtkWidget *unsaved_dialog;
bool stop_opening = FALSE, do_save = FALSE;
bool ok=false;
if (NedResource::isPlaying()) return;
NedMusicXMLImport musicxmlimport;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_config_changed || main_window->m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = TRUE; break;
case GTK_RESPONSE_REJECT: stop_opening = TRUE; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_opening) {
return;
}
if (do_save) {
main_window->save_score(main_window->m_main_window, (void *) main_window);
}
}
import_dialog = gtk_file_chooser_dialog_new (_("Import MusicXML"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, ".xml (XML-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.xml");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(import_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(import_dialog), file_filter2);
if (NedResource::m_last_xml_dir != NULL) {
if ((the_directory = opendir(NedResource::m_last_xml_dir)) != NULL) { // avoid gtk error message
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(import_dialog), NedResource::m_last_xml_dir);
closedir(the_directory);
}
}
if (gtk_dialog_run (GTK_DIALOG (import_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (import_dialog));
folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER (import_dialog));
ok = TRUE;
}
gtk_widget_destroy (import_dialog);
if (!ok) return;
if (filename == NULL) return;
if (strlen(filename) < 1) return;
if (NedResource::m_last_xml_dir != NULL) {
free(NedResource::m_last_xml_dir);
NedResource::m_last_xml_dir = NULL;
}
if (folder != NULL) {
if (strlen(folder) > 0) {
NedResource::m_last_xml_dir = strdup(folder);
}
}
main_window->import_from_other(&musicxmlimport, filename, true);
}
void NedMainWindow::import_midi(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->do_import_midi(false);
}
void NedMainWindow::import_midi2(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->do_import_midi(true);
}
void NedMainWindow::do_import_midi(bool use_id_ed) {
bool state, with_triplets;
GtkWidget *unsaved_dialog;
bool stop_opening = FALSE, do_save = FALSE;
bool force_piano, sort_instruments, dont_split;
int tempo_change_density, volume_change_density;
char *filename = NULL;
if (m_config_changed || m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = TRUE; break;
case GTK_RESPONSE_REJECT: stop_opening = TRUE; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_opening) {
return;
}
if (do_save) {
save_score(m_main_window, (void *) this);
}
}
NedMidiImportDialog *dialog = new NedMidiImportDialog (GTK_WINDOW(m_main_window), &NedResource::m_last_midi_dir, &filename);
dialog->getValues(&state, &with_triplets, &tempo_change_density, &volume_change_density, &force_piano, &sort_instruments, &dont_split);
delete dialog;
if (!state) return;
if (filename == NULL) return;
if (strlen(filename) < 1) return;
NedMidiImporter *midiimport = new NedMidiImporter(with_triplets, tempo_change_density, volume_change_density,
force_piano, sort_instruments, dont_split, use_id_ed);
FILE *fp;
if ((fp = fopen(filename, "r")) == NULL) {
fprintf(stderr, "Cannot open %s\n", filename);
return;
}
midiimport->setImportParameters(this, fp);
if (use_id_ed) {
if (!midiimport->import()) {
if (midiimport->getErrorString()) {
NedResource::Info(midiimport->getErrorString());
}
}
}
else {
import_from_other(midiimport, filename, true);
}
fclose(fp);
if (!use_id_ed) {
delete midiimport;
}
}
void NedMainWindow::deleteEmptyPagesAtEnd() {
GList *lptr;
bool deleted;
if (g_list_length(m_pages) < 2) return;
do {
deleted = false;
lptr = g_list_last(m_pages);
if (((NedPage *) lptr->data)->hasOnlyRests()) {
deleted = true;
m_pages = g_list_delete_link(m_pages, lptr);
}
}
while (deleted && g_list_length(m_pages) > 0);
}
void NedMainWindow::deletePagesWithoutSystem() {
GList *lptr;
bool deleted;
do {
deleted = false;
lptr = g_list_last(m_pages);
if (((NedPage *) lptr->data)->getSystemCount() < 1) {
deleted = true;
m_pages = g_list_delete_link(m_pages, lptr);
}
if (g_list_length(m_pages) < 1) {
NedResource::Abort("NedMainWindow::deletePagesWithoutSystem");
}
}
while (deleted);
}
bool NedMainWindow::import_from_other(NedImporter *im, char *filename, bool execute_import) {
FILE *fp = NULL;
GtkWidget *error_dialog;
#ifdef ASSIGN1
char pathfoldername[4096], *cptr;
#endif
int i;
GList *lptr;
GList *old_spec_measures;
GList *old_pages;
bool old_portrait;
double old_tempo_inverse;
double old_spacement_fac;
bool old_config_changed;
int old_numerator;
int old_denominator;
unsigned int old_timesig_symbol;
int old_staff_count;
int old_scale;
struct paper_info_struct *old_paper_type;
unsigned int old_upbeat_inverse;
staff_context_str old_staff_contexts[MAX_STAFFS];
double old_first_page_yoffs;
ScoreInfo *old_score_info;
bool state, portrait;
const char *paper;
bool ok = true;
for (i = 0; i < MAX_STAFFS; i++) {
old_staff_contexts[i].m_staff_name = NULL;
old_staff_contexts[i].m_staff_short_name = NULL;
old_staff_contexts[i].m_group_name = NULL;
old_staff_contexts[i].m_group_short_name = NULL;
}
if (filename != NULL) {
if ((fp = fopen(filename, "r")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for reading"), filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (ok) {
im->setImportParameters(this, fp);
old_spec_measures = m_special_measures;
m_special_measures = NULL;
old_pages = m_pages;
old_portrait = m_portrait;
old_paper_type = m_current_paper;
old_tempo_inverse = m_midi_tempo_inverse;
old_numerator = m_numerator;
old_scale = m_current_scale;
old_denominator = m_denominator;
old_timesig_symbol = m_timesig_symbol;
old_staff_count = m_staff_count;
old_upbeat_inverse = m_upbeat_inverse;
old_spacement_fac = m_global_spacement_fac;
old_config_changed = m_config_changed;
for (i = 0; i < old_staff_count; i++) {
old_staff_contexts[i] = m_staff_contexts[i];
}
old_first_page_yoffs = m_first_page_yoffs;
old_score_info = m_score_info;
m_staff_count = 1;
m_current_scale = SCALE_GRANULARITY;
m_selected_note = NULL;
m_selected_chord_or_rest = NULL;
m_selected_tie_forward = NULL;
m_selected_spec_measure = NULL;
m_config_changed = TRUE;
m_selection_rect.width = 0;
resetLyricsMode();
m_midi_tempo_inverse = START_TEMPO_INVERSE;
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_v1bu), TRUE);
gtk_toggle_action_set_active(m_show_hidden_action, FALSE);
m_score_info = new ScoreInfo();
computeScoreTextExtends();
resetButtons();
ok = true;
if (execute_import) {
ok = im->import();
}
ok = ok && im->convertToScore();
if (ok) {
NedPaperConfigDialog *dialog = new NedPaperConfigDialog (GTK_WINDOW(m_main_window),
m_current_paper->name, m_portrait, true);
dialog->getValues(&state, &paper, &portrait);
delete dialog;
ok = state;
}
if (ok) {
struct paper_info_struct *paper_type = NedResource::getPaperInfo(paper);
m_current_paper = paper_type;
m_portrait = portrait;
if (do_import_from_other(im)) {
#ifdef ASSIGN1
if (filename != NULL) {
if ((cptr = strrchr(filename, '/')) != NULL) {
strncpy(pathfoldername, filename, cptr - filename);
pathfoldername[cptr - filename] = '\0';
*last_dir = strdup(pathfoldername);
}
else {
*last_dir = strdup(folder);
}
}
#endif
#define FREE1
#ifdef FREE1
if (filename != NULL) {
g_free(filename);
}
for (lptr = g_list_first(old_pages); lptr; lptr = g_list_next(lptr)) {
delete ((NedPage *) lptr->data);
}
g_list_free(old_pages);
if (old_spec_measures != NULL) {
for (lptr = g_list_first(old_spec_measures); lptr; lptr = g_list_next(lptr)) {
delete ((SpecialMeasure *) lptr->data);
}
g_list_free(old_spec_measures);
}
delete old_score_info;
#endif
m_upbeat_inverse = im->m_upbeat_inverse;
m_global_spacement_fac = 1.0;
m_midi_tempo_inverse = im->m_tempo_inverse;
m_command_history->reset();
m_current_filename[0] = '\0';
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), 1);
m_topy = m_leftx = 0;
gtk_window_set_title (GTK_WINDOW (m_main_window), "Nted");
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->handleStaffElements();
}
computeSystemIndent();
setAndUpdateClefTypeAndKeySig();
updatePageCounter();
zoomFreeReplaceables(m_current_zoom, getCurrentScale());
NedCommandList *command_list = new NedCommandList(this);
renumberMeasures(NULL, 1, true);
/*
removeAllBeams();
*/
reposit(command_list, NULL, NULL, true);
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->testTies();
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->cutEmptyVoices();
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->handleEmptyMeasures();
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->removeUnneededAccidentals();
}
setAllUnpositioned();
removeEmptyInteriourPages();
reposit(command_list, NULL, NULL, true);
deleteEmptyPagesAtEnd();
renumberMeasures(NULL, 1, true);
updatePageCounter();
//delete command_list;
}
else {
#define FREE2
#ifdef FREE2
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
delete ((NedPage *) lptr->data);
}
g_list_free(m_pages);
m_pages = NULL;
if (m_special_measures != NULL) {
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
free(lptr->data);
}
g_list_free(m_special_measures);
}
delete m_score_info;
#endif
m_special_measures = old_spec_measures;
m_pages = old_pages;
m_upbeat_inverse = old_upbeat_inverse;
m_global_spacement_fac = old_spacement_fac;
m_portrait = old_portrait;
m_current_paper = old_paper_type;
m_midi_tempo_inverse = old_tempo_inverse;
m_numerator = old_numerator;
m_current_scale = old_scale;
m_denominator = old_denominator;
m_timesig_symbol = old_timesig_symbol;
m_staff_count = old_staff_count;
m_config_changed = old_config_changed;
for (i = 0; i < old_staff_count; i++) {
m_staff_contexts[i] = old_staff_contexts[i];
}
m_first_page_yoffs = old_first_page_yoffs;
m_score_info = old_score_info;
computeSystemIndent();
}
repaint();
}
else {
if (im->getErrorString()) {
NedResource::Info(im->getErrorString());
}
}
if (filename != NULL) {
fclose(fp);
}
}
return ok;
}
bool NedMainWindow::do_import_from_other(NedImporter *im) {
int i, j;
bool first = true;
bool first_measure = true;
bool overflow;
NedPage *current_page;
NedSystem *current_system;
int page_nr = 0;
unsigned int measure_duration;
int num, denom;
unsigned int meas_num = 1;
if (im->m_partcount < 1) return false;
double w = m_portrait ? m_current_paper->width : m_current_paper->height;
double h = m_portrait ? m_current_paper->height : m_current_paper->width;
w /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
h /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
m_staff_count = im->m_partcount;
m_numerator = im->m_parts[0].numerator;
m_denominator = im->m_parts[0].denominator;
m_timesig_symbol = TIME_SYMBOL_NONE;
for (i = 0; i < m_staff_count; i++) {
if (m_staff_contexts[i].m_staff_name != NULL) {
delete m_staff_contexts[i].m_staff_name;
m_staff_contexts[i].m_staff_name = NULL;
}
if (im->m_parts[i].name != NULL && strlen(im->m_parts[i].name) > 0) {
m_staff_contexts[i].m_staff_name = new NedPangoCairoText(m_drawing_area->window, im->m_parts[i].name, STAFF_NAME_FONT, STAFF_NAME_FONT_SLANT,
STAFF_NAME_FONT_WEIGHT, STAFF_NAME_FONT_SIZE, m_current_zoom, getCurrentScale(), false);
}
if (m_staff_contexts[i].m_staff_short_name != NULL) {
delete m_staff_contexts[i].m_staff_short_name;
}
m_staff_contexts[i].m_staff_short_name = NULL;
if (m_staff_contexts[i].m_group_name != NULL) {
delete m_staff_contexts[i].m_group_name;
}
m_staff_contexts[i].m_group_name = NULL;
if (m_staff_contexts[i].m_group_short_name != NULL) {
delete m_staff_contexts[i].m_group_short_name;
}
m_staff_contexts[i].m_group_short_name = NULL;
m_staff_contexts[i].m_key_signature_number = im->m_parts[i].key_signature;
m_staff_contexts[i].m_clef_number = im->m_parts[i].clef;
m_staff_contexts[i].m_clef_octave_shift = im->m_parts[i].clef_octave;
m_staff_contexts[i].m_different_voices = false;
for (j = 0; j < VOICE_COUNT; j++) {
m_staff_contexts[i].voices[j].m_midi_volume = im->m_parts[i].volume;
m_staff_contexts[i].voices[j].m_midi_pan = 64;
m_staff_contexts[i].voices[j].m_midi_program = im->m_parts[i].midi_pgm;
m_staff_contexts[i].m_muted[j] = false;
}
m_staff_contexts[i].m_midi_chorus = 0;
m_staff_contexts[i].m_play_transposed = 0;
m_staff_contexts[i].m_midi_reverb = 0;
m_staff_contexts[i].m_midi_channel = im->m_parts[i].midi_channel;
m_staff_contexts[i].m_flags = 0;
}
// current_page = (NedPage *) g_list_first(m_pages)->data;
m_pages = NULL;
current_page = new NedPage(this, w, h, page_nr++, 0, false);
m_pages = g_list_append(m_pages, current_page);
current_system = current_page->appendSystem();
/*
NedCommandList *command_list = new NedCommandList(this);
for (i = 1; i < m_staff_count; i++) {
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->appendStaff(command_list, i);
}
}
command_list->execute();
*/
current_system->empty();
current_system->prepareForImport();
computeSystemIndent();
num = getNumerator(meas_num);
denom = getDenominator(meas_num);
while(!im->is_eof() && !(overflow = current_system->testLineOverflow())) {
if (first_measure) {
first_measure = false;
measure_duration = num * WHOLE_NOTE / denom - m_upbeat_inverse;
}
else {
measure_duration = num * WHOLE_NOTE / denom;
}
current_system->appendElementsOfMeasureLength(im->m_parts, measure_duration, meas_num);
meas_num++;
num = getNumerator(meas_num);
denom = getDenominator(meas_num);
}
if (overflow) {
im->resetTaken();
current_system->removeLastImported();
meas_num--;
num = getNumerator(meas_num);
denom = getDenominator(meas_num);
}
if (!current_system->handleImportedTuplets()) {
NedResource::Info("Problems setting Tuplets");
return false;;
}
if (!im->is_eof()) {
if (current_page->isPageOverflow()) {
current_page->removeSystem(current_system);
current_page = new NedPage(this, w, h, page_nr++, 0, false);
m_pages = g_list_append(m_pages, current_page);
current_page->insertSystem(current_system);
}
current_system = current_page->appendSystem();
first = false;
}
while (!im->is_eof()) {
current_system->empty();
current_system->prepareForImport();
overflow = false;
while(!im->is_eof() && !overflow) {
measure_duration = num * WHOLE_NOTE / denom;
current_system->appendElementsOfMeasureLength(im->m_parts, num * WHOLE_NOTE / denom, meas_num);
meas_num++;
num = getNumerator(meas_num);
denom = getDenominator(meas_num);
overflow = current_system->testLineOverflow();
}
if (overflow) {
im->resetTaken();
current_system->removeLastImported();
NedResource::DbgMsg(DBG_TESTING, "Stelle 3: meas_num = %d\n", meas_num);
meas_num--;
NedResource::DbgMsg(DBG_TESTING, "Stelle 4: meas_num = %d\n", meas_num);
num = getNumerator(meas_num);
denom = getDenominator(meas_num);
}
if (!current_system->handleImportedTuplets()) {
NedResource::Info("Problems setting Tuplets");
return false;
}
if (current_page->isPageOverflow()) {
current_page->removeSystem(current_system);
current_page = new NedPage(this, w, h, page_nr++, 0, false);
m_pages = g_list_append(m_pages, current_page);
current_page->insertSystem(current_system);
}
if (!im->is_eof()) {
current_system = current_page->appendSystem();
}
}
current_system->fill_up(NULL);
return true;
}
void NedMainWindow::readSpecMeasures(FILE *fp, GList **new_spec_measures) {
int measnum, type;
int tsig_sym = TIME_SYMBOL_NONE;
bool hide_following;
int num, denom;
char buffer[1024], buffer2[1024];
SpecialMeasure *spec;
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "(")) {
NedResource::m_error_message = "( expected";
return;
}
while (1) {
hide_following = false;
if (!NedResource::readInt(fp, &measnum) || measnum < 0 || measnum > 100000) {
NedResource::m_error_message = "measure number expected";
return;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "REPEAT_OPEN, REPEAT_CLOSE, REPEAT_OPEN_CLOSE, END_BAR, DOUBLE_BAR or REPEAT_NONE expected";
return;
}
if (!strcmp(buffer, "REPEAT_OPEN")) {
type = REPEAT_OPEN;
}
else if (!strcmp(buffer, "REPEAT_CLOSE")) {
type = REPEAT_CLOSE;
if (m_file_version > 15) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "HIDE_FOLLOWING or SHOW_FOLLOWING expected";
return;
}
if (!strcmp(buffer, "HIDE_FOLLOWING")) {
hide_following = true;
}
else if (!strcmp(buffer, "SHOW_FOLLOWING")) {
hide_following = false;
}
else {
NedResource::m_error_message = "HIDE_FOLLOWING or SHOW_FOLLOWING expected";
return;
}
}
}
else if (!strcmp(buffer, "REPEAT_OPEN_CLOSE")) {
type = REPEAT_OPEN_CLOSE;
}
else if (!strcmp(buffer, "END_BAR")) {
type = END_BAR;
if (m_file_version > 12) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "HIDE_FOLLOWING or SHOW_FOLLOWING expected";
return;
}
if (!strcmp(buffer, "HIDE_FOLLOWING")) {
hide_following = true;
}
else if (!strcmp(buffer, "SHOW_FOLLOWING")) {
hide_following = false;
}
else {
NedResource::m_error_message = "HIDE_FOLLOWING or SHOW_FOLLOWING expected";
return;
}
}
}
else if (!strcmp(buffer, "DOUBLE_BAR")) {
type = DOUBLE_BAR;
}
else if (!strcmp(buffer, "REPEAT_NONE")) {
type = 0;
}
else {
NedResource::m_error_message = "REPEAT_NONE, REPEAT_OPEN, REPEAT_CLOSE, REPEAT_OPEN_CLOSE, END_BAR, DOUBLE_BAR, REPEAT_NONE or TIMESIG expected";
return;
}
do {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = ") or , expected";
return;
}
if (!strcmp(buffer, ",")) {
if (!NedResource::readWordWithNum(fp, buffer)) {
NedResource::m_error_message = "REP1START, REP1END, REP2START or REP2END expected(1)";
return;
}
if (!strcmp(buffer, "REP1START")) {
type |= REP1START;
}
else if (!strcmp(buffer, "REP2START")) {
type |= REP2START;
}
else if (!strcmp(buffer, "REP1END")) {
type |= REP1END;
}
else if (!strcmp(buffer, "REP2END")) {
type |= REP2END;
}
else if (!strcmp(buffer, "TIMSIG")) {
type |= TIMESIG;
if (!NedResource::readWord(fp, buffer2) || strcmp(buffer2, "(")) {
NedResource::m_error_message = "( expected";
return;
}
if (!NedResource::readInt(fp, &num) || num < 1 || num > 20) {
NedResource::m_error_message = "numerator expected";
return;
}
if (!NedResource::readWord(fp, buffer2) || strcmp(buffer2, ",")) {
NedResource::m_error_message = ", expected";
return;
}
if (!NedResource::readInt(fp, &denom) || (denom != 2 && denom != 4 && denom != 8 && denom != 16)) {
NedResource::m_error_message = "denominator expected";
return;
}
if (m_file_version > 16) {
if (!NedResource::readWord(fp, buffer2) || strcmp(buffer2, ",")) {
NedResource::m_error_message = ", expected";
return;
}
if (!NedResource::readInt(fp, &tsig_sym) || (tsig_sym < TIME_SYMBOL_NONE || tsig_sym > TIME_SYMBOL_CUT_TIME)) {
NedResource::m_error_message = "timesig symbol value expected";
return;
}
}
if (!NedResource::readWord(fp, buffer2) || strcmp(buffer2, ")")) {
NedResource::m_error_message = ") expected";
return;
}
}
else {
NedResource::DbgMsg(DBG_CRITICAL, "buffer = %s\n", buffer);
NedResource::m_error_message = "REP1START, REP1END, REP2START or REP2END expected";
return;
}
}
}
while (strcmp(buffer, ")"));
spec = new SpecialMeasure();
spec->measure_number = measnum;
spec->hide_following = hide_following;
spec->type = type;
if ((type & TIMESIG) != 0) {
spec->setTimeSignature(num, denom, tsig_sym);
}
*new_spec_measures = g_list_insert_sorted(*new_spec_measures, spec, compare_spec_measures_according_measnum);
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "( or MUSIC expected";
return;
}
if (!strcmp(buffer, "MUSIC")) {
//NedResource::unreadWord(buffer);
return;
}
if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( or MUSIC expected";
return;
}
}
}
void NedMainWindow::testAlternativeState(NedCommandList *command_list, NedMeasure *measure, bool alter1, bool alter2) {
GList *lptr;
NedChangeMeasureTypeCommand *change_measure_command;
if ((measure->getSpecial() & REP_TYPE_MASK) != REPEAT_CLOSE) return;
if (!alter1 && ((measure->getSpecial() & END_TYPE_MASK) == REP1END)) {
if ((lptr = g_list_find(m_special_measures, measure->m_special_descr /* friend!! */)) == NULL) {
NedResource::Abort("NedMainWindow::testAlternativeState(1)");
}
for (lptr = g_list_previous(lptr); lptr; lptr = g_list_previous(lptr)) {
if (((((SpecialMeasure *) lptr->data)->type & START_TYPE_MASK)) == REP1START) {
change_measure_command = new NedChangeMeasureTypeCommand(this, ((SpecialMeasure *) lptr->data)->measure_number,
(((SpecialMeasure *) lptr->data)->type) & (~(REP1START)), false);
command_list->addCommand(change_measure_command);
change_measure_command->execute();
break;
}
}
}
if (!alter2 && ((measure->getSpecial() & START_TYPE_MASK) == REP2START)) {
if ((lptr = g_list_find(m_special_measures, measure->m_special_descr /* friend!! */)) == NULL) {
NedResource::Abort("NedMainWindow::testAlternativeState(2)");
}
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if (((((SpecialMeasure *) lptr->data)->type & END_TYPE_MASK)) == REP2END) {
change_measure_command = new NedChangeMeasureTypeCommand(this, ((SpecialMeasure *) lptr->data)->measure_number,
(((SpecialMeasure *) lptr->data)->type) & (~(REP2END)), false);
command_list->addCommand(change_measure_command);
change_measure_command->execute();
break;
}
}
}
}
bool NedMainWindow::conflictWithOhterSpecMeasure(int measnum, int dir) {
GList *lptr;
int measnum2;
measnum2 = measnum + dir;
if (measnum2 < 2) return true;
if (dir > 0) {
for (lptr = g_list_first(m_special_measures); lptr ; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number > measnum2) return false;
if (((SpecialMeasure *) lptr->data)->measure_number <= measnum) continue;
if ((((SpecialMeasure *) lptr->data)->type & (REP_TYPE_MASK | START_TYPE_MASK | END_TYPE_MASK)) == 0) continue;
if ((((SpecialMeasure *) lptr->data)->type & REP_TYPE_MASK) == DOUBLE_BAR) continue;
if ((((SpecialMeasure *) lptr->data)->type & REP_TYPE_MASK) == END_BAR) continue;
return true;
}
}
else {
for (lptr = g_list_last(m_special_measures); lptr ; lptr = g_list_previous(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number < measnum2) return false;
if (((SpecialMeasure *) lptr->data)->measure_number >= measnum) continue;
if ((((SpecialMeasure *) lptr->data)->type & (REP_TYPE_MASK | START_TYPE_MASK | END_TYPE_MASK)) == 0) continue;
if ((((SpecialMeasure *) lptr->data)->type & REP_TYPE_MASK) == DOUBLE_BAR) continue;
if ((((SpecialMeasure *) lptr->data)->type & REP_TYPE_MASK) == END_BAR) continue;
return true;
}
}
return false;
}
void NedMainWindow::moveSpecMeasure(SpecialMeasure *spec, int dir) {
GList *lptr;
NedMoveSpecMeasureCommand *spec_meas_cmd;
NedCommandList *command_list;
if ((spec->type & START_TYPE_MASK) == REP1START) {
if (conflictWithOhterSpecMeasure(spec->measure_number, dir)) {
return;
}
command_list = new NedCommandList(this);
spec_meas_cmd = new NedMoveSpecMeasureCommand(this, spec->measure_number, dir);
spec_meas_cmd->execute();
command_list->addCommand(spec_meas_cmd);
command_list->setRenumber(NULL, 0, true);
m_command_history->addCommandList(command_list);
renumberMeasures(NULL, 1, true);
repaint();
}
else if ((spec->type & START_TYPE_MASK) == REP2START) {
if ((lptr = g_list_find(m_special_measures, spec)) == NULL) {
NedResource::Abort("NedMainWindow::move_spec_measure_to_left");
}
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
spec = (SpecialMeasure *) lptr->data;
if ((spec->type & START_TYPE_MASK) != 0) break;
if ((spec->type & END_TYPE_MASK) == REP2END) break;
}
if (lptr == NULL) return;
if ((spec->type & END_TYPE_MASK) == REP2END) {
if (conflictWithOhterSpecMeasure(spec->measure_number, dir)) {
return;
}
command_list = new NedCommandList(this);
spec_meas_cmd = new NedMoveSpecMeasureCommand(this, spec->measure_number, dir);
spec_meas_cmd->execute();
command_list->addCommand(spec_meas_cmd);
command_list->setRenumber(NULL, 0, true);
m_command_history->addCommandList(command_list);
renumberMeasures(NULL, 1, true);
repaint();
}
}
}
void NedMainWindow::open_recent(GtkAction *action, gpointer data) {
int idx;
FILE *fp;
NedMainWindow *main_window = (NedMainWindow *) data;
char pathfoldername[4096], *cptr;
GtkWidget *error_dialog;
bool ok = TRUE;
GtkWidget *unsaved_dialog;
bool stop_opening = FALSE, do_save = FALSE;
if (NedResource::isPlaying()) return;
if (main_window->m_config_changed || main_window->m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = TRUE; break;
case GTK_RESPONSE_REJECT: stop_opening = TRUE; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_opening) {
return;
}
if (do_save) {
main_window->save_score(main_window->m_main_window, main_window);
}
}
if (sscanf(gtk_action_get_name(action), "open_recent_action_%d", &idx) != 1) {
NedResource::Warning("NedMainWindow::open_recent: cannot get index");
return;
}
if (NedResource::m_recent_files[idx] == NULL) {
NedResource::Warning("NedMainWindow::open_recent: NedResource::m_recent_files[idx] == NULL");
return;
}
if ((fp = fopen(NedResource::m_recent_files[idx], "r")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for reading"), NedResource::m_recent_files[idx]);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
if (ok) {
main_window->do_restore(fp, NedResource::m_recent_files[idx]);
if ((cptr = strrchr(NedResource::m_recent_files[idx], '/')) != NULL) {
strncpy(pathfoldername, NedResource::m_recent_files[idx], cptr - NedResource::m_recent_files[idx]);
pathfoldername[cptr - NedResource::m_recent_files[idx]] = '\0';
NedResource::m_last_folder = strdup(pathfoldername);
}
fclose(fp);
}
}
void NedMainWindow::updateRecentFiles() {
int i;
GError *error = NULL;
static const char *uiadd_start = ""
" "
" "
" ";
static const char *uiadd_end = ""
" "
" "
"";
char Str[4096], str[4096], ac_name[128];
if (m_recentFileMergeId >= 0) {
gtk_ui_manager_remove_ui(m_ui_manager, m_recentFileMergeId);
m_recentFileMergeId = -1;
}
strcpy(Str, uiadd_start);
for (i = 0; i < MAX_RECENT_FILES; i++) {
if (NedResource::m_recent_files[i] != NULL) {
sprintf(str, "", i);
sprintf(ac_name, "open_recent_action_%d", i);
gtk_action_group_remove_action(m_open_recent_action_group, m_recent_actions[i]);
g_object_ref(m_recent_actions[i]);
m_recent_actions[i] = gtk_action_new(ac_name, NedResource::m_recent_files[i], NULL, NULL);
g_signal_connect (m_recent_actions[i], "activate", G_CALLBACK (open_recent), (void *) this);
gtk_action_group_add_action(m_open_recent_action_group, m_recent_actions[i]);
strcat(Str, str);
}
}
strcat(Str, uiadd_end);
m_recentFileMergeId = gtk_ui_manager_add_ui_from_string(m_ui_manager, Str, strlen(Str), &error);
}
void NedMainWindow::config_midi_out(GtkWidget *widget, void *data) {
GList *midi_ports, *lptr;
int idx;
if (!NedResource::alsaSequencerOutOk()) {
NedResource::Info(_("Cannot list midi ports because could not open ALSA sequencer"));
return;
}
NedMainWindow *main_window = (NedMainWindow *) data;
midi_ports = NedResource::listMidiOutDevices(&idx);
NedPortChooseDialog *dialog = new NedPortChooseDialog(GTK_WINDOW(main_window->m_main_window), midi_ports, idx, NedResource::m_midi_echo, true);
idx = dialog->getSelection();
if (idx < 0) {
NedResource::DbgMsg(DBG_TESTING, "nothing selected\n");
}
else {
if ((lptr = g_list_nth(midi_ports, idx)) == NULL) {
NedResource::Abort("NedMainWindow::do_configure");
}
NedResource::subscribe_out(idx);
NedResource::m_midi_echo = dialog->getMidiEcho();
}
delete dialog;
}
void NedMainWindow::config_midi_in(GtkWidget *widget, void *data) {
GList *midi_ports, *lptr;
int idx;
if (!NedResource::alsaSequencerInOk()) {
NedResource::Info(_("Cannot list midi ports because could not open ALSA sequencer"));
return;
}
NedMainWindow *main_window = (NedMainWindow *) data;
midi_ports = NedResource::listMidiInDevices(&idx);
NedPortChooseDialog *dialog = new NedPortChooseDialog(GTK_WINDOW(main_window->m_main_window), midi_ports, idx, false, false);
idx = dialog->getSelection();
if (idx < 0) {
NedResource::DbgMsg(DBG_TESTING, "nothing selected\n");
}
else {
if ((lptr = g_list_nth(midi_ports, idx)) == NULL) {
NedResource::Abort("NedMainWindow::do_configure");
}
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(main_window->m_midi_input_action), FALSE);
NedResource::subscribe_in(idx);
}
delete dialog;
}
void NedMainWindow::reconfig_paper(bool do_reposit, struct paper_info_struct *paper_type, bool portrait, int scale) {
GList *lptr;
m_current_scale = scale;
m_current_paper = paper_type;
m_portrait = portrait;
double w = m_portrait ? m_current_paper->width : m_current_paper->height;
double h = m_portrait ? m_current_paper->height : m_current_paper->width;
w /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
h /= PS_ZOOM * (double) m_current_scale / (double) SCALE_GRANULARITY;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->reconfig_paper(w, h);
}
adjustAfterZoom();
computeScoreTextExtends();
/*
NedCommandList *dummy = new NedCommandList(this);
if (do_reposit) {
reposit(dummy);
}
*/
//delete dummy;
repaint();
}
void NedMainWindow::config_print_cmd(GtkWidget *widget, void *data) {
bool state;
const char *new_print_command;
NedMainWindow *main_window = (NedMainWindow *) data;
NedPrintConfigDialog *dialog = new NedPrintConfigDialog (GTK_WINDOW(main_window->m_main_window), NedResource::m_print_cmd);
dialog->getValues(&state, &new_print_command);
if (state) {
NedResource::m_print_cmd = new_print_command;
}
/*
else {
free(new_print_command);
}
*/
delete dialog;
}
void NedMainWindow::config_meas_num_font(GtkWidget *widget, void *data) {
GtkWidget* fontdialog;
gchar *fontname;
fontdialog = gtk_font_selection_dialog_new(_("Font selection - Measure numbers"));
gtk_dialog_run(GTK_DIALOG(fontdialog));
fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontdialog));
NedResource::DbgMsg(DBG_TESTING, "Font name = %s\n", fontname);
gtk_widget_destroy (GTK_WIDGET(fontdialog));
}
void NedMainWindow::config_paper(GtkWidget *widget, void *data) {
bool state, portrait;
const char *paper;
int w, h;
bool p;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedPaperConfigDialog *dialog = new NedPaperConfigDialog (GTK_WINDOW(main_window->m_main_window),
main_window->m_current_paper->name, main_window->m_portrait, true);
dialog->getValues(&state, &paper, &portrait);
delete dialog;
if (state) {
struct paper_info_struct *paper_type = NedResource::getPaperInfo(paper);
w = main_window->m_current_paper->width;
h = main_window->m_current_paper->height;
p = main_window->m_portrait;
if (main_window->m_portrait != portrait || paper_type->width != w || paper_type->height != h) {
//NedCommandList *dummy = new NedCommandList(main_window);
NedCommandList *command_list = new NedCommandList(main_window);
NedPaperConfigCommand *page_config_command = new NedPaperConfigCommand(main_window, main_window->m_current_paper,
main_window->m_portrait, paper_type, portrait, main_window->m_current_scale, main_window->m_current_scale);
page_config_command->execute();
command_list->addCommand(page_config_command);
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list, NULL, NULL, true);
main_window->repaint();
main_window->m_command_history->addCommandList(command_list);
//delete dummy; // crashes shouldn't !!!
}
}
}
void NedMainWindow::change_scale(GtkWidget *widget, void *data) {
bool state;
int newscale;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedScaleDialog *dialog = new NedScaleDialog (GTK_WINDOW(main_window->m_main_window), main_window->m_current_scale);
dialog->getValues(&state, &newscale);
delete dialog;
if (state && newscale != main_window->m_current_scale) {
//NedCommandList *dummy = new NedCommandList(main_window);
NedCommandList *command_list = new NedCommandList(main_window);
NedPaperConfigCommand *page_config_command = new NedPaperConfigCommand(main_window, main_window->m_current_paper,
main_window->m_portrait, main_window->m_current_paper, main_window->m_portrait, main_window->m_current_scale, newscale);
page_config_command->execute();
command_list->addCommand(page_config_command);
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list, NULL, NULL, true);
main_window->repaint();
main_window->m_command_history->addCommandList(command_list);
//delete dummy; // crashes shouldn't !!!
}
}
void NedMainWindow::config_record(GtkWidget *widget, void *data) {
bool state;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_chord_or_rest != NULL) {
NedStaff *staff = main_window->m_selected_chord_or_rest->getStaff();
main_window->m_record_midi_numerator = main_window->m_numerator;
main_window->m_record_midi_denominator = main_window->m_denominator;
main_window->m_record_midi_keysig = main_window->m_staff_contexts[staff->getStaffNumber()].m_key_signature_number;
main_window->m_record_midi_pgm = main_window->m_staff_contexts[staff->getStaffNumber()].voices[0].m_midi_program;
}
NedMidiRecordConfigDialog *dialog = new NedMidiRecordConfigDialog (GTK_WINDOW(main_window->m_main_window),
main_window->m_record_midi_numerator, main_window->m_record_midi_denominator, main_window->m_record_midi_pgm,
main_window->m_record_midi_tempo_inverse, main_window->m_record_midi_metro_volume, main_window->m_record_midi_triplet_recognition, main_window->m_record_midi_f_piano, main_window->m_record_midi_dnt_split,
main_window->m_record_midi_keysig);
dialog->getValues(&state, &(main_window->m_record_midi_numerator), &(main_window->m_record_midi_denominator),
&(main_window->m_record_midi_pgm),
&(main_window->m_record_midi_tempo_inverse), &(main_window->m_record_midi_metro_volume), &(main_window->m_record_midi_triplet_recognition), &(main_window->m_record_midi_f_piano), &(main_window->m_record_midi_dnt_split),
&(main_window->m_record_midi_keysig));
delete dialog;
}
void NedMainWindow::config_drums(GtkWidget *widget, void *data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
NedDrumConfigDialog NedDrumConfigDialog(GTK_WINDOW(main_window->m_main_window));
}
void NedMainWindow::toggle_show_hidden(GtkAction *action, gpointer data) {
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->repaint();
}
void NedMainWindow::toggle_midi_input(GtkAction *action, gpointer data) {
if (NedResource::isPlaying()) return;
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION (action))) {
NedMainWindow *main_window = (NedMainWindow *) data;
gtk_toggle_action_set_active(main_window->m_midi_record_action, FALSE);
NedResource::startMidiInput();
}
else {
NedResource::stopMidiInput();
}
}
int NedMainWindow::setChannelFromCursor() {
GdkDisplay *display = NULL;
NedStaff *staff;
double dummy1;
int dummy2;
gint x=0, y=0;
GList *lptr;
bool found = false;
GdkScreen *screen = NULL;
gtk_widget_get_pointer(m_drawing_area, &x, &y);
display = gdk_display_get_default();
screen = gdk_display_get_default_screen(display);
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->findLine(x, y, &dummy1, &dummy2, &dummy1, &staff)) {
found = true; break;
}
}
if (found) {
return m_staff_contexts[staff->getStaffNumber()].m_midi_channel;
}
return 0;
}
void NedMainWindow::toggle_record_midi(GtkAction *action, gpointer data) {
if (NedResource::isPlaying()) return;
GList *lptr;
bool ok;
NedMainWindow *main_window = (NedMainWindow *) data;
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION (action))) {
gtk_toggle_action_set_active(main_window->m_midi_input_action, FALSE);
gtk_toggle_action_set_active(main_window->m_keyboard_insert_action, FALSE);
gtk_toggle_action_set_active(main_window->m_insert_erease_mode_action, FALSE);
if (main_window->m_selected_chord_or_rest != NULL) {
NedStaff *staff = main_window->m_selected_chord_or_rest->getStaff();
main_window->m_record_midi_numerator = main_window->m_numerator;
main_window->m_record_midi_denominator = main_window->m_denominator;
main_window->m_record_midi_keysig = main_window->m_staff_contexts[staff->getStaffNumber()].m_key_signature_number;
main_window->m_record_midi_pgm = main_window->m_staff_contexts[staff->getStaffNumber()].voices[0].m_midi_program;
}
main_window->m_midi_recorder = new NedMidiRecorder(main_window->m_record_midi_numerator, main_window->m_record_midi_denominator, main_window->m_record_midi_keysig,
main_window->m_record_midi_pgm, main_window->m_record_midi_tempo_inverse, main_window->m_record_midi_metro_volume,
main_window->m_record_midi_triplet_recognition, main_window->m_record_midi_f_piano, main_window->m_record_midi_dnt_split);
main_window->m_midi_recorder->startMetronom();
}
else {
main_window->m_midi_recorder->stopMetronom();
NedMainWindow *ned_main_window = new NedMainWindow(); // the new window registers itself in NedResource::m_main_windows list
#ifdef YELP_PATH
ned_main_window->createLayout(NULL, NedResource::m_yelparg);
#else
ned_main_window->createLayout(NULL, NULL);
#endif
ok = ned_main_window->import_from_other(main_window->m_midi_recorder, NULL, true);
delete main_window->m_midi_recorder;
ned_main_window->m_midi_recorder = NULL;
if (!ok) {
if ((lptr = g_list_find(NedResource::m_main_windows, ned_main_window)) == NULL) {
NedResource::Abort("NedMainWindow::toggle_record_midi(1)");
}
if (g_list_length(NedResource::m_main_windows) < 1) {
NedResource::Abort("NedMainWindow::toggle_record_midi(2)");
}
NedResource::m_main_windows = g_list_delete_link(NedResource::m_main_windows, lptr);
delete ned_main_window;
}
else {
NedResource::m_recorded_staff = ((NedPage *) g_list_first(ned_main_window->m_pages)->data)->getFirstSystem()->getStaff(0);
}
}
}
void NedMainWindow::zoom_in(GtkWidget *widget, void *data) {
double midx;
double old_zoom;
NedMainWindow *main_window = (NedMainWindow *) data;
old_zoom = main_window->getCurrentZoomFactor();
main_window->m_current_zoom_level++;
if (main_window->m_current_zoom_level >= ZOOMLEVELS) {
main_window->m_current_zoom_level = ZOOMLEVELS - 1;
}
main_window->m_selection_rect.width = main_window->m_selection_rect.height = 0;
main_window->m_current_zoom = NedResource::getZoomFactor(main_window->m_current_zoom_level);
main_window->adjustAfterZoom();
main_window->repaint();
midx = main_window->m_leftx + main_window->m_drawing_area->allocation.width / 2;
midx *= main_window->m_current_zoom / old_zoom;
main_window->m_leftx = midx - main_window->m_drawing_area->allocation.width / 2;
main_window->adjustView();
}
void NedMainWindow::zoom_out(GtkWidget *widget, void *data) {
double midx;
double old_zoom;
NedMainWindow *main_window = (NedMainWindow *) data;
old_zoom = main_window->getCurrentZoomFactor();
main_window->m_current_zoom_level--;
if (main_window->m_current_zoom_level < 0) {
main_window->m_current_zoom_level = 0;
}
main_window->m_current_zoom = NedResource::getZoomFactor(main_window->m_current_zoom_level);
main_window->adjustAfterZoom();
main_window->m_selection_rect.width = main_window->m_selection_rect.height = 0;
if (main_window->m_selected_group != NULL) {
g_list_free(main_window->m_selected_group);
main_window->m_selected_group = NULL;
}
midx = main_window->m_leftx + main_window->m_drawing_area->allocation.width / 2;
midx *= main_window->m_current_zoom / old_zoom;
main_window->m_leftx = midx - main_window->m_drawing_area->allocation.width / 2;
main_window->adjustView();
main_window->repaint();
}
void NedMainWindow::adjustAfterZoom() {
int i;
for (i = 0; i < m_staff_count; i++) {
if (m_staff_contexts[i].m_staff_name != NULL) {
m_staff_contexts[i].m_staff_name->setZoom(m_current_zoom, getCurrentScale());
}
if (m_staff_contexts[i].m_staff_short_name != NULL) {
m_staff_contexts[i].m_staff_short_name->setZoom(m_current_zoom, getCurrentScale());
}
if (m_staff_contexts[i].m_group_name != NULL) {
m_staff_contexts[i].m_group_name->setZoom(m_current_zoom, getCurrentScale());
}
if (m_staff_contexts[i].m_group_short_name != NULL) {
m_staff_contexts[i].m_group_short_name->setZoom(m_current_zoom, getCurrentScale());
}
}
rezoomScoreInfo();
zoomFreeReplaceables(m_current_zoom, getCurrentScale());
computeSystemIndent();
computeScoreTextExtends();
//reposit();
}
void NedMainWindow::rezoomScoreInfo() {
if (m_score_info->title != NULL) {
m_score_info->title->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->subject != NULL) {
m_score_info->subject->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->composer != NULL) {
m_score_info->composer->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->arranger != NULL) {
m_score_info->arranger->setZoom(m_current_zoom, 1.0);
}
if (m_score_info->copyright != NULL) {
m_score_info->copyright->setZoom(m_current_zoom, 1.0);
}
}
NedPage *NedMainWindow::getLastPage() {
return (NedPage *) g_list_last(m_pages)->data;
}
void NedMainWindow::find_new_cursor_pos(guint keyval, int *x, int *y) {
GList *lptr;
bool found = false;
if (m_last_staff_during_key_insertion == NULL) {
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->find_staff_and_line(*x, *y, &m_last_staff_during_key_insertion, &m_last_line_during_key_insertion)) {
found = true;
break;
}
}
}
else {
found = true;
}
if (!found) {
return;
}
switch (keyval) {
case GDK_Up: m_last_line_during_key_insertion--; break;
case GDK_Down: m_last_line_during_key_insertion++; break;
default: return;
}
*y = (int) m_last_staff_during_key_insertion->getRealYPosOfLine(m_last_line_during_key_insertion);
}
bool NedMainWindow::find_new_cursor_pos_at_measure(guint keyval, int *x, int *y) {
GList *lptr;
double newx, newy;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->findXposInOtherMeasure(keyval, *x, *y, &newx, &newy)) {
*x = (int) newx;
*y = (int) newy;
return true;
}
}
return false;
}
gboolean NedMainWindow::key_press_handler (GtkWidget *widget, GdkEventKey *event,
gpointer data) {
int method, ret;
unsigned int nl;
NedMainWindow *main_window = (NedMainWindow *) data;
NedCommandList *command_list;
int tuplet_val = 0;
NedRemoveFreePlaceableCommand *rem_displaceable;
GList *lptr;
NedChordOrRest *newObj, *newObj1;
int wx, wy;
int page_nr;
double newx;
gint x=0, y=0;
bool keyboard_insertion = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(main_window->m_keyboard_insert_action));
NedPage *page;
NedChangeMeasureSpreadCommand *change_spread_cmd;
GdkDisplay *display = NULL;
GdkScreen *screen = NULL;
char utf8string[10];
guint32 unichar = gdk_keyval_to_unicode(event->keyval);
int ll = g_unichar_to_utf8(unichar, utf8string);
utf8string[ll] = '\0';
if (NedResource::isPlaying()) return FALSE;
if (main_window->m_lyrics_mode >= 0) {
if (event->keyval == GDK_Escape) {
main_window->resetLyricsMode();
main_window->repaint();
return TRUE;
}
if (main_window->m_selected_chord_or_rest == NULL) return TRUE;
if (event->keyval == GDK_Left) {
if (!main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_LEFT)) {
main_window->m_selected_chord_or_rest->selectPreviousChord(true, main_window->m_lyrics_mode);
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_END);
}
}
main_window->repaint();
return TRUE;
}
else if (event->keyval == GDK_Right) {
if (!main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_RIGHT)) {
main_window->m_selected_chord_or_rest->selectNextChord(true, main_window->m_lyrics_mode);
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_START);
}
}
main_window->repaint();
return TRUE;
}
else if (event->keyval == GDK_BackSpace) {
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
bool not_empty = main_window->m_selected_chord_or_rest->deleteLyricsLetter(command_list, main_window->m_lyrics_mode);
main_window->reposit(command_list, main_window->m_selected_chord_or_rest->getPage(),
main_window->m_selected_chord_or_rest->getSystem());
main_window->repaint();
if (!not_empty) {
main_window->m_selected_chord_or_rest->selectPreviousChord(main_window->m_lyrics_mode, true);
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_END);
}
}
if (command_list->getNumberOfCommands() > 0) {
main_window->m_command_history->addCommandList(command_list);
}
return TRUE;
}
if (!strcmp(event->string, " ") || event->keyval == GDK_Return) {
main_window->m_selected_chord_or_rest->selectNextChord(false, main_window->m_lyrics_mode);
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_START);
}
return TRUE;
}
#ifdef KEYDEBUG
printf("KEY = %c(0x%x)\n", event->keyval, event->keyval); fflush(stdout);
#endif
gtk_im_context_filter_keypress(main_window->m_im_context, event);
return TRUE;
}
/* ------------------------------------- */
if (keyboard_insertion) {
gtk_widget_get_pointer(main_window->m_drawing_area, &x, &y);
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
switch (event->keyval) {
case GDK_Up:
case GDK_Down:
gtk_widget_get_pointer(main_window->m_drawing_area, &x, &y);
main_window->find_new_cursor_pos(event->keyval, &x, &y);
gtk_widget_translate_coordinates(main_window->m_drawing_area, main_window->m_main_window,
x, y, &x, &y);
gdk_window_get_position(GDK_WINDOW(main_window->m_main_window->window), &wx, &wy);
gdk_display_warp_pointer (display, screen, wx + x, wy + y);
break;
case GDK_Right:
case GDK_Left:
gtk_widget_get_pointer(main_window->m_drawing_area, &x, &y);
if (!main_window->find_new_cursor_pos_at_measure(event->keyval, &x, &y)) break;
gtk_widget_translate_coordinates(main_window->m_drawing_area, main_window->m_main_window,
x, y, &x, &y);
gdk_window_get_position(GDK_WINDOW(main_window->m_main_window->window), &wx, &wy);
gdk_display_warp_pointer (display, screen, wx + x, wy + y);
break;
case GDK_BackSpace:
if (main_window->m_last_obj == NULL) break;
if (main_window->m_last_cursor_x < 0) break;
if (main_window->m_last_cursor_y < 0) break;
command_list = new NedCommandList(main_window, main_window->m_last_obj->getSystem());
main_window->m_last_obj->testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
if (main_window->m_last_obj->getType() == TYPE_GRACE) {
command_list->addCommand(new NedEreaseChordOrRestCommand(main_window->m_last_obj));
}
else {
command_list->addCommand(new NedDeleteChordCommand(main_window->m_last_obj));
}
command_list->execute();
main_window->m_command_history->addCommandList(command_list);
main_window->reposit(command_list, main_window->m_last_obj->getPage(), main_window->m_last_obj->getSystem());
gtk_widget_translate_coordinates(main_window->m_drawing_area, main_window->m_main_window,
main_window->m_last_cursor_x, main_window->m_last_cursor_y, &x, &y);
gdk_window_get_position(GDK_WINDOW(main_window->m_main_window->window), &wx, &wy);
gdk_display_warp_pointer (display, screen, wx + x, wy + y);
main_window->m_last_obj = NULL;
main_window->m_last_cursor_x = main_window->m_last_cursor_y = -1;
main_window->repaint();
return TRUE;
}
}
/*----------------------------------------- */
if (event->keyval == GDK_Control_L || event->keyval == GDK_Control_R) {
main_window->m_keyboard_ctrl_mode = TRUE;
main_window->m_pointer_xpos = -1.0;
main_window->repaint();
}
else if (event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R) {
gdk_window_set_cursor (GDK_WINDOW(main_window->m_drawing_area->window), main_window->m_hand);
}
else if (!keyboard_insertion && event->keyval == GDK_Down) {
if (main_window->m_selected_note != NULL) {
if (event->state & GDK_SHIFT_MASK) {
if (!main_window->m_selected_chord_or_rest->testMeasureSpread(-1)) return FALSE;
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
change_spread_cmd = new NedChangeMeasureSpreadCommand(main_window->m_selected_chord_or_rest->m_measure, -1);
change_spread_cmd->execute();
command_list->addCommand(change_spread_cmd);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
else if (main_window->m_selected_note->testRelativeMove(-1)) {
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_selected_note->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD | BREAK_TIE_FORWARD);
main_window->m_selected_chord_or_rest->testForDeleteableConstraints(command_list);
command_list->addCommand(new NedMoveNoteRelativeCommand(main_window->m_selected_note, -1));
command_list->execute();
main_window->reposit(command_list, NULL, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_command_history->addCommandList(command_list);
}
}
else if (main_window->m_selected_chord_or_rest != NULL) { // rest
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
command_list->addCommand(new NedRestMoveCommand(main_window->m_selected_chord_or_rest, main_window->m_selected_chord_or_rest->getLine(),
main_window->m_selected_chord_or_rest->getLine() - 1));
command_list->execute();
main_window->reposit(command_list, NULL, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_command_history->addCommandList(command_list);
}
else if (main_window->m_selected_tie_forward != NULL) {
if (main_window->m_selected_tie_forward->test_tie_increment(D_TIE)) {
command_list = new NedCommandList(main_window, main_window->m_selected_tie_forward->getSystem());
command_list->addCommand(new NedChangeTieCommand(main_window->m_selected_tie_forward, D_TIE));
command_list->execute();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
}
return TRUE;
}
else if (!keyboard_insertion && event->keyval == GDK_Up) {
if (main_window->m_selected_note != NULL) {
if (event->state & GDK_SHIFT_MASK) {
if (!main_window->m_selected_chord_or_rest->testMeasureSpread(1)) return FALSE;
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
change_spread_cmd = new NedChangeMeasureSpreadCommand(main_window->m_selected_chord_or_rest->m_measure, 1);
change_spread_cmd->execute();
command_list->addCommand(change_spread_cmd);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
else if (main_window->m_selected_note->testRelativeMove(1)) {
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_selected_note->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD | BREAK_TIE_FORWARD);
main_window->m_selected_chord_or_rest->testForDeleteableConstraints(command_list);
command_list->addCommand(new NedMoveNoteRelativeCommand(main_window->m_selected_note, 1));
command_list->execute();
main_window->reposit(command_list, NULL, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_command_history->addCommandList(command_list);
}
}
else if (main_window->m_selected_chord_or_rest != NULL) { // rest
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
command_list->addCommand(new NedRestMoveCommand(main_window->m_selected_chord_or_rest, main_window->m_selected_chord_or_rest->getLine(),
main_window->m_selected_chord_or_rest->getLine() + 1));
command_list->execute();
main_window->reposit(command_list, NULL, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_command_history->addCommandList(command_list);
}
else if (main_window->m_selected_tie_forward != NULL) {
if (main_window->m_selected_tie_forward->test_tie_increment(-D_TIE)) {
command_list = new NedCommandList(main_window, main_window->m_selected_tie_forward->getSystem());
command_list->addCommand(new NedChangeTieCommand(main_window->m_selected_tie_forward, -D_TIE));
command_list->execute();
main_window->m_command_history->addCommandList(command_list);
main_window->reposit(NULL, main_window->m_selected_tie_forward->getPage(), main_window->m_selected_tie_forward->getSystem());
main_window->repaint();
}
}
return TRUE;
}
else if (!keyboard_insertion && event->keyval == GDK_Left) {
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest = main_window->m_selected_chord_or_rest->getPreviousChordOrRest();
if (main_window->m_selected_chord_or_rest != NULL) {
if (main_window->m_selected_chord_or_rest->isRest()) {
main_window->m_selected_note = NULL;
}
else {
main_window->m_selected_note = main_window->m_selected_chord_or_rest->getFirstNote();
}
}
else {
main_window->m_selected_note = NULL;
}
main_window->setButtons();
main_window->repaint();
}
else if (main_window->m_selected_spec_measure) {
main_window->moveSpecMeasure(main_window->m_selected_spec_measure, -1);
}
else if (main_window->m_score_info->title != NULL && strlen(main_window->m_score_info->title->getText()) > 0) {
main_window->m_score_info->title->moveCursor(-1);
main_window->repaint();
}
return TRUE;
}
else if (!keyboard_insertion && event->keyval == GDK_Right) {
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest = main_window->m_selected_chord_or_rest->getNextChordOrRest();
if (main_window->m_selected_chord_or_rest != NULL) {
if (main_window->m_selected_chord_or_rest->isRest()) {
main_window->m_selected_note = NULL;
}
else {
main_window->m_selected_note = main_window->m_selected_chord_or_rest->getFirstNote();
}
}
else {
main_window->m_selected_note = NULL;
}
main_window->setButtons();
main_window->repaint();
}
else if (main_window->m_selected_spec_measure) {
main_window->moveSpecMeasure(main_window->m_selected_spec_measure, 1);
}
else if (main_window->m_score_info->title != NULL && strlen(main_window->m_score_info->title->getText()) > 0) {
main_window->m_score_info->title->moveCursor(1);
main_window->repaint();
}
return TRUE;
}
else if (!keyboard_insertion && event->keyval == GDK_BackSpace) {
if (main_window->m_selected_chord_or_rest != NULL && ((main_window->m_selected_chord_or_rest->getType() & (TYPE_CLEF | TYPE_STAFF_SIGN | TYPE_KEYSIG)) != 0)) {
if (main_window->m_selected_chord_or_rest->getType() & TYPE_STAFF_SIGN) {
ret = GTK_RESPONSE_NO;
}
else {
GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(main_window->m_main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("Adjust notes ?"));
ret = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
NedStaff *staff = main_window->m_selected_chord_or_rest->getStaff();
NedRemoveStaffElemCommand *rem_staff_el_cmd = new NedRemoveStaffElemCommand(main_window, staff->getStaffNumber(), main_window->m_selected_chord_or_rest,
ret == GTK_RESPONSE_YES);
rem_staff_el_cmd->execute();
command_list->setFullReposit();
command_list->addCommand(rem_staff_el_cmd);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->m_command_history->addCommandList(command_list);
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_note = NULL;
}
else if (main_window->m_selected_free_replaceable != NULL) {
command_list = new NedCommandList(main_window);
if (main_window->m_selected_free_replaceable->getType() == FREE_PLACEABLE_SLUR_POINT) {
NedSlurPoint **sp;
sp = ((NedSlurPoint *) main_window->m_selected_free_replaceable)->getSlurPoints();
rem_displaceable = new NedRemoveFreePlaceableCommand(sp[0]);
command_list->addCommand(rem_displaceable);
rem_displaceable->execute();
rem_displaceable = new NedRemoveFreePlaceableCommand(sp[1]);
command_list->addCommand(rem_displaceable);
rem_displaceable->execute();
rem_displaceable = new NedRemoveFreePlaceableCommand(sp[2]);
command_list->addCommand(rem_displaceable);
rem_displaceable->execute();
}
else if (main_window->m_selected_free_replaceable->getType() == FREE_PLACEABLE_LINE_POINT) {
NedLinePoint *startp, *endp, *midp;
startp = ((NedLinePoint *) main_window->m_selected_free_replaceable)->getLine()->getLineStartPoint();
endp = ((NedLinePoint *) main_window->m_selected_free_replaceable)->getLine()->getLineEndPoint();
rem_displaceable = new NedRemoveFreePlaceableCommand(startp);
command_list->addCommand(rem_displaceable);
rem_displaceable->execute();
if ((((NedLinePoint *) main_window->m_selected_free_replaceable)->getLine()->getLineType() & LINE_TEMPO_CHANGE) != 0) {
midp = ((NedLine3 *) ((NedLinePoint *) main_window->m_selected_free_replaceable)->getLine())->getLineMidPoint();
rem_displaceable = new NedRemoveFreePlaceableCommand(midp);
command_list->addCommand(rem_displaceable);
rem_displaceable->execute();
}
rem_displaceable = new NedRemoveFreePlaceableCommand(endp);
command_list->addCommand(rem_displaceable);
rem_displaceable->execute();
}
else {
NedRemoveFreePlaceableCommand *rem_displaceable = new NedRemoveFreePlaceableCommand(main_window->m_selected_free_replaceable);
rem_displaceable->execute();
command_list->addCommand(rem_displaceable);
}
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
}
else if (main_window->m_selected_chord_or_rest != NULL && !main_window->m_selected_chord_or_rest->isRest()) {
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
main_window->m_selected_chord_or_rest->testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
GList *already_deleted_free_displaceables = NULL;
main_window->m_selected_chord_or_rest->testForFreeReplaceablesToDelete(command_list, &already_deleted_free_displaceables);
g_list_free(already_deleted_free_displaceables);
if (main_window->m_selected_chord_or_rest->getType() == TYPE_GRACE) {
command_list->addCommand(new NedEreaseChordOrRestCommand(main_window->m_selected_chord_or_rest));
}
else {
command_list->addCommand(new NedDeleteChordCommand(main_window->m_selected_chord_or_rest));
}
main_window->m_selected_chord_or_rest = main_window->m_selected_chord_or_rest->getPreviousChordOrRest();
if (main_window->m_selected_chord_or_rest != NULL) {
if (main_window->m_selected_chord_or_rest->isRest()) {
main_window->m_selected_note = NULL;
}
else {
main_window->m_selected_note = main_window->m_selected_chord_or_rest->getFirstNote();
}
}
command_list->execute();
main_window->m_command_history->addCommandList(command_list);
main_window->m_selected_spec_measure = NULL;
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->reposit(command_list, main_window->m_selected_chord_or_rest->getPage(), main_window->m_selected_chord_or_rest->getSystem());
}
else {
main_window->reposit(command_list);
}
main_window->repaint();
}
}
else if (event->keyval == GDK_Page_Up) {
page_nr = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(main_window->m_page_selector));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(main_window->m_page_selector), page_nr - 1);
}
else if (event->keyval == GDK_Page_Down) {
page_nr = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(main_window->m_page_selector));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(main_window->m_page_selector), page_nr + 1);
}
else if (event->keyval >= GDK_2 && event->keyval <= GDK_9 && ( event->state & GDK_CONTROL_MASK) ) {
method = (event->state & GDK_MOD1_MASK) ? 1 : 0;
if (!main_window->m_selected_chord_or_rest) {
NedResource::Info(_("please select a note or rest first"));
return TRUE;
}
if (main_window->m_selected_chord_or_rest->getDotCount() != 0) {
NedResource::Info(_("you cannot select an element with dot"));
return TRUE;
}
switch (event->keyval) {
case GDK_2: tuplet_val = 2; break;
case GDK_3: tuplet_val = 3; break;
case GDK_4: tuplet_val = 4; break;
case GDK_5: tuplet_val = 5; break;
case GDK_6: tuplet_val = 6; break;
case GDK_7: tuplet_val = 7; break;
case GDK_8: tuplet_val = 8; break;
case GDK_9: tuplet_val = 9; break;
}
if (!main_window->m_selected_chord_or_rest->getVoice()->
tryConvertToTuplet(method, tuplet_val, main_window->m_selected_chord_or_rest)) {
NedResource::Info(_("I'm not able to create a tuplet here"));
return TRUE;
}
}
else if ((event->keyval >= GDK_1 && event->keyval <= GDK_8) || (event->keyval >= GDK_KP_1 && event->keyval <= GDK_KP_8)) {
switch (event->keyval) {
case GDK_1: nl = WHOLE_NOTE; break;
case GDK_2: nl = NOTE_2; break;
case GDK_4: nl = NOTE_4; break;
case GDK_5: nl = NOTE_8; break;
case GDK_6: nl = NOTE_16; break;
case GDK_7: nl = NOTE_32; break;
case GDK_8: nl = NOTE_64; break;
default: nl = NOTE_4; break;
}
NedResource::setNoteLengthButtons(nl);
if (keyboard_insertion) {
gtk_widget_get_pointer(main_window->m_drawing_area, &x, &y);
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
main_window->m_last_cursor_x = x; main_window->m_last_cursor_y = y;
gtk_widget_get_pointer(main_window->m_drawing_area, &x, &y);
main_window->find_new_cursor_pos(0, &x, &y);
main_window->m_last_obj = NULL;
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->tryInsertOrErease(x, y, 0, NULL /* no pitch given */, &newObj, (event->state & GDK_MOD1_MASK))) {
page = (NedPage *) lptr->data;
if (newObj != NULL) {
main_window->m_last_obj = newObj;
newObj1 = newObj->getNextChordOrRest();
if (newObj1 == NULL) {
newObj1 = newObj->getFirstObjectInNextSystem();
}
if (newObj1 != NULL) {
main_window->m_last_staff_during_key_insertion = newObj1->getStaff();
page = newObj1->getPage();
newx = page->convertX(newObj1->getXPos());
y = (int) main_window->m_last_staff_during_key_insertion->getRealYPosOfLine(main_window->m_last_line_during_key_insertion);
gtk_widget_translate_coordinates(main_window->m_drawing_area, main_window->m_main_window,
(gint)newx, y, &x, &y);
gdk_window_get_position(GDK_WINDOW(main_window->m_main_window->window), &wx, &wy);
gdk_display_warp_pointer (display, screen, (int) (x + wx), y + wy);
}
}
main_window->resetSomeButtons();
}
}
}
}
else {
switch(event->keyval) {
case GDK_KP_Divide: NedResource::toggleButton(1); break;
case GDK_KP_Multiply: NedResource::toggleButton(2); break;
case GDK_KP_Subtract: NedResource::toggleButton(3); break;
case GDK_KP_Home: NedResource::toggleButton(4); break;
case GDK_KP_Up: NedResource::toggleButton(5); break;
case GDK_KP_Prior: NedResource::toggleButton(6); break;
case GDK_KP_Add: NedResource::toggleButton(7); break;
case GDK_KP_Left: NedResource::toggleButton(8); break;
case GDK_KP_Begin: NedResource::toggleButton(9); break;
case GDK_KP_Right: NedResource::toggleButton(10); break;
case GDK_KP_End: NedResource::toggleButton(11); break;
case GDK_KP_Down: NedResource::toggleButton(12); break;
case GDK_KP_Next: NedResource::toggleButton(13); break;
case GDK_KP_Enter: NedResource::toggleButton(14); break;
case GDK_KP_Insert: NedResource::toggleButton(15); break;
case GDK_KP_Delete: NedResource::toggleButton(16); break;
case GDK_R:
case GDK_r: NedResource::toggleRest(); break;
case GDK_comma: main_window->tryTieBackward(); break;
case GDK_underscore: NedResource::toggleTie(); break;
case GDK_period: NedResource::toggleDot(); break;
case GDK_numbersign: NedResource::toggleSharp(); break;
case GDK_equal: NedResource::toggleNatural(); break;
case GDK_minus: NedResource::toggleFlat(); break;
case GDK_Delete: if (main_window->m_selected_note == NULL) break;
if (main_window->m_selected_chord_or_rest == NULL) break;
main_window->m_selected_chord_or_rest->ereaseNote(main_window->m_selected_note);
break;
}
}
return TRUE;
}
void NedMainWindow::OnCommit(GtkIMContext *context, const gchar *str, void *data) {
NedMainWindow *main_window = (NedMainWindow *) data;
#ifdef KEYDEBUG
printf("str = %s\n", str); fflush(stdout);
#endif
NedCommandList *command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
if (!strcmp(str, "_")) {
main_window->m_selected_chord_or_rest->appendToLyrics(command_list, main_window->m_lyrics_mode, " ");
}
else {
main_window->m_selected_chord_or_rest->appendToLyrics(command_list, main_window->m_lyrics_mode, str);
}
main_window->reposit(command_list, main_window->m_selected_chord_or_rest->getPage(),
main_window->m_selected_chord_or_rest->getSystem());
if (!strcmp(str, "-")) {
main_window->m_selected_chord_or_rest->selectNextChord(false, main_window->m_lyrics_mode);
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest->setLyricsCursor(main_window->m_lyrics_mode, LYR_CURSOR_START);
}
}
main_window->repaint();
if (command_list->getNumberOfCommands() > 0) {
main_window->m_command_history->addCommandList(command_list);
}
}
void NedMainWindow::tryTieBackward() {
if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(m_keyboard_insert_action))) { // keyboard insertion mode
if (m_last_obj == NULL) return;
m_last_obj->tryTieBackward();
return;
}
if (m_selected_chord_or_rest == NULL || m_selected_note == NULL) return;
m_selected_note->tryTieBackward();
}
gboolean NedMainWindow::key_release_handler (GtkWidget *widget, GdkEventKey *event,
gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
if (event->keyval == GDK_Control_L || event->keyval == GDK_Control_R) {
main_window->m_keyboard_ctrl_mode = false;
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_selected_tie_forward = NULL;
main_window->repaint();
}
else if (event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R) {
main_window->setCursor();
}
return FALSE;
}
gboolean NedMainWindow::window_leave_handler (GtkWidget *widget, GdkEventCrossing *event,
gpointer data) {
return FALSE;
}
gboolean NedMainWindow::window_enter_handler (GtkWidget *widget, GdkEventCrossing *event,
gpointer data) {
gtk_widget_grab_focus (widget);
NedResource::setMainwWindowWithFocus((NedMainWindow *) data);
return FALSE;
}
void NedMainWindow::OnSetFocus(GtkWindow *window, GtkWidget *widget, gpointer data) {
}
gboolean NedMainWindow::handle_button_press (GtkWidget *widget,
GdkEventButton *event, gpointer data)
{
int staff_num, mtype, measnum, mtypeold;
bool state;
bool alter1, alter2, allow_alter;
bool oldalter1, oldalter2, old_hide_following;
GList *lptr, *lptr2;
NedStaff *staff = NULL;
NedMainWindow *main_window = (NedMainWindow *) data;
NedNote *note;
NedMeasure *measure;
bool hide_following;
int newnum, newdenom;
int num, denom;
unsigned int symbol, newsymbol;
bool time_sig_state, delete_timesig;
NedCommandList *command_list = NULL;
NedChangeMeasureTimeSignatureCommand *change_sig_command;
if (NedResource::isPlaying()) return FALSE;
main_window->m_last_staff_during_key_insertion = NULL;
main_window->m_pointer_ypos = event->y;
if (event->button == 3) {
if (g_list_length(main_window->m_selected_group) > 0 && main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM) {
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if ((staff = ((NedPage *) lptr->data)->findStaff(event->x, event->y, &measure /* dummy */)) != NULL) {
staff_num = staff->getStaffNumber();
lptr2 = g_list_first(main_window->m_selected_group);
while (lptr2) {
if (((NedChordOrRest *) lptr2->data)->getStaff()->getStaffNumber() == staff_num) {
main_window->m_selected_group = g_list_delete_link(main_window->m_selected_group, lptr2);
lptr2 = g_list_first(main_window->m_selected_group);
}
else {
lptr2 = g_list_next(lptr2);
}
}
main_window->repaint();
return FALSE;
}
}
return FALSE;
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->trySelect(event->x, event->y, true)) {
if (main_window->m_selected_free_replaceable != NULL) {
main_window->m_selected_free_replaceable->startContextDialog(main_window->m_main_window);
return FALSE;
}
}
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
measure = NULL;
if ((staff = ((NedPage *) lptr->data)->findStaff(event->x, event->y, &measure)) != NULL) {
if (measure != NULL) {
mtype = measure->getSpecial();
measnum = measure->getMeasureNumber();
mtypeold = mtype;
oldalter1 = ((mtype & REP_TYPE_MASK) == REPEAT_CLOSE) && ((mtype & END_TYPE_MASK) == REP1END);
oldalter2 = ((mtype & REP_TYPE_MASK) == REPEAT_CLOSE) && ((mtype & START_TYPE_MASK) == REP2START);
allow_alter = oldalter1 || oldalter2 || !main_window->conflictWithOhterSpecMeasure(measure->getMeasureNumber(), -1);
if ((mtype & REP_TYPE_MASK) & (END_BAR | REPEAT_CLOSE)) {
old_hide_following = measure->m_hide_following;
}
else {
old_hide_following = true;
}
num = main_window->getNumeratorOfThisMeasure(measure->getMeasureNumber());
denom = main_window->getDenominatorOfThisMeasure(measure->getMeasureNumber());
symbol = main_window->getTimesigSymbolOfThisMeasure(measure->getMeasureNumber());
NedMeasureConfigDialog *dialog =
new NedMeasureConfigDialog(GTK_WINDOW(main_window->m_main_window), mtype & REP_TYPE_MASK, oldalter1, oldalter2, allow_alter,
old_hide_following, num, denom, symbol);
dialog->getValues(&state, &mtype, &alter1, &alter2, &hide_following, &time_sig_state, &delete_timesig, &newnum, &newdenom, &newsymbol);
if (state && (mtypeold != mtype || oldalter1 != alter1 || oldalter2 != alter2 || old_hide_following != hide_following)) {
command_list = new NedCommandList(main_window, staff->getSystem());
main_window->testAlternativeState(command_list, measure, alter1, alter2);
alter1 = alter1 && ((mtype & REP_TYPE_MASK) == REPEAT_CLOSE);
alter2 = alter2 && ((mtype & REP_TYPE_MASK) == REPEAT_CLOSE);
if (alter1) {
mtype |= REP1END;
}
if (alter2) {
mtype |= REP2START;
}
if ((mtypeold & END_TYPE_MASK) == REP2END) {
mtype |= REP2END;
}
/*
if ((mtypeold & END_TYPE_MASK) == REP1END) {
mtype |= REP1END;
}
*/
NedChangeMeasureTypeCommand *change_measure_command = new
NedChangeMeasureTypeCommand(main_window, measnum, mtype, hide_following);
command_list->addCommand(change_measure_command);
change_measure_command->execute();
if (alter1 && !oldalter1) {
if (measnum > 0) {
change_measure_command = new NedChangeMeasureTypeCommand(main_window, measnum - 1, REP1START, hide_following);
command_list->addCommand(change_measure_command);
change_measure_command->execute();
}
}
if (alter2 && !oldalter2) {
change_measure_command = new NedChangeMeasureTypeCommand(main_window, measnum + 1, REP2END, hide_following);
command_list->addCommand(change_measure_command);
change_measure_command->execute();
}
}
num = main_window->getNumerator(measure->getMeasureNumber());
denom = main_window->getDenominator(measure->getMeasureNumber());
if (time_sig_state && ((newnum != num || newdenom != denom || newsymbol != symbol) || delete_timesig)) {
if (command_list == NULL) {
command_list = new NedCommandList(main_window, staff->getSystem());
}
if (delete_timesig) {
change_sig_command = new NedChangeMeasureTimeSignatureCommand(main_window, measnum, -1, -1, -1);
}
else {
change_sig_command = new NedChangeMeasureTimeSignatureCommand(main_window, measnum, newnum, newdenom, newsymbol);
}
command_list->addCommand(change_sig_command);
change_sig_command->execute();
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->reposit(command_list);
main_window->checkForElementsToSplit(command_list);
}
if (command_list != NULL) {
command_list->setFullReposit();
main_window->setAllUnpositioned();
main_window->m_command_history->addCommandList(command_list);
main_window->reposit(command_list);
}
delete dialog;
}
else {
main_window->do_staff_config(staff->getStaffNumber(), staff->getSystem());
}
return FALSE;
}
}
return FALSE;
}
main_window->m_mouse_x = event->x;
main_window->m_mouse_y = event->y;
main_window->m_leftx0 = main_window->m_leftx;
main_window->m_topy0 = main_window->m_topy;
main_window->m_selection_rect.x = (int) event->x;
main_window->m_selection_rect.y = (int) event->y;
main_window->m_selection_rect.width = 0;
main_window->m_selection_rect.height = 0;
if (main_window->m_selected_group != NULL) {
g_list_free(main_window->m_selected_group);
main_window->m_selected_group = NULL;
}
if (main_window->m_selected_chord_or_rest != NULL && ((main_window->getMainWindowStatus() & INSERT_EREASE_MODE) == 0)) {
if (main_window->m_selected_chord_or_rest->hitStemEnd(event->x, event->y)) {
main_window->m_selected_stem = main_window->m_selected_chord_or_rest;
return FALSE;
}
}
if (NedResource::getTiedMode()) {
if (main_window->m_selected_note) {
note = main_window->m_selected_note;
bool sel2 = FALSE;
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->trySelect(event->x, event->y)) {
sel2 = TRUE;
break;
}
}
if (main_window->m_selected_note) {
main_window->m_selected_note->do_tie(note);
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_selected_tie_forward = NULL;
}
if (!sel2) {
main_window->resetSomeButtons();
}
}
else {
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->trySelect(event->x, event->y)) {
main_window->repaint();
return FALSE;
}
}
main_window->resetSomeButtons();
}
main_window->repaint();
return FALSE;
}
if ((main_window->getMainWindowStatus() & SHIFT_MODE) != 0 || ((event->state & GDK_SHIFT_MASK) != 0)) return FALSE;
main_window->m_selected_note = NULL;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_spec_measure = NULL;
main_window->m_selected_free_replaceable = NULL;
main_window->m_selected_tie_forward = NULL;
if (main_window->m_lyrics_mode < 0 && (main_window->getMainWindowStatus() & INSERT_EREASE_MODE) != 0 && ((event->state & GDK_CONTROL_MASK) == 0)) {
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->tryInsertOrErease(event->x, event->y, 0, NULL /* no pitch given */)) {
main_window->resetSomeButtons();
main_window->repaint();
return FALSE;
}
}
}
else {
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->trySelect(event->x, event->y)) {
main_window->setButtons();
main_window->repaint();
return FALSE;
}
}
for (lptr = g_list_first(main_window->m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->isNear(event->x, event->y)) {
main_window->m_selected_spec_measure = (SpecialMeasure *) lptr->data;
}
}
main_window->resetSomeButtons();
}
if (main_window->m_selected_chord_or_rest == NULL && main_window->m_selected_note == NULL && main_window->m_selected_spec_measure == NULL &&
main_window->m_selected_free_replaceable != NULL) {
}
main_window->repaint();
return FALSE;
}
void NedMainWindow::insertNoteWithPitch(int num_midi_input_notes, int *midi_input_chord) {
GList *lptr;
NedChordOrRest *newObj, *newObj1;
GdkDisplay *display = NULL;
GdkScreen *screen = NULL;
double newx;
gint x=0, y=0;
NedPage *page;
int wx, wy;
bool found = false;
double dummy1;
int dummy2;
NedStaff *staff;
if (num_midi_input_notes == 0) return;
gtk_widget_get_pointer(m_drawing_area, &x, &y);
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
m_last_cursor_x = x; m_last_cursor_y = y;
gtk_widget_get_pointer(m_drawing_area, &x, &y);
find_new_cursor_pos(0, &x, &y);
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->findLine(x, y, &dummy1, &dummy2, &dummy1, &staff)) {
found = true; break;
}
}
if (!found) return;
if (!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(m_keyboard_insert_action)) ||
!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(m_insert_erease_mode_action))) {
return;
}
m_last_obj = NULL;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
if (((NedPage *) lptr->data)->tryInsertOrErease(x, y, num_midi_input_notes, midi_input_chord, &newObj)) {
page = (NedPage *) lptr->data;
if (newObj != NULL) {
m_last_obj = newObj;
newObj1 = newObj->getNextChordOrRest();
if (newObj1 == NULL) {
newObj1 = newObj->getFirstObjectInNextSystem();
}
if (newObj1 != NULL) {
m_last_staff_during_key_insertion = newObj1->getStaff();
page = newObj1->getPage();
newx = page->convertX(newObj1->getXPos());
y = (int) m_last_staff_during_key_insertion->getRealYPosOfLine(m_last_line_during_key_insertion);
gtk_widget_translate_coordinates(m_drawing_area, m_main_window,
(gint)newx, y, &x, &y);
gdk_window_get_position(GDK_WINDOW(m_main_window->window), &wx, &wy);
gdk_display_warp_pointer (display, screen, (int) (x + wx), y + wy);
}
}
resetSomeButtons();
}
}
}
gint NedMainWindow::compare_spec_measures_according_measnum(gconstpointer ptr1, gconstpointer ptr2) {
SpecialMeasure *spec_meas1 = (SpecialMeasure *) ptr1;
SpecialMeasure *spec_meas2 = (SpecialMeasure *) ptr2;
if (spec_meas1->measure_number < spec_meas2->measure_number) return -1;
if (spec_meas1->measure_number > spec_meas2->measure_number) return 1;
return 0;
}
int NedMainWindow::setSpecial(int measnum, int mtype, bool hide, bool *oldhide, bool overwrite) {
GList *lptr;
SpecialMeasure *spec_meas;
int ret = 0;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == measnum) {
ret = (((SpecialMeasure *) lptr->data)->type & (REP_TYPE_MASK | START_TYPE_MASK | END_TYPE_MASK));
/*
if (mtype == 0) {
((SpecialMeasure *) lptr->data)->type &= (~(REP_TYPE_MASK | START_TYPE_MASK | END_TYPE_MASK));
if (((SpecialMeasure *) lptr->data)->type == 0) {
free(lptr->data);
m_special_measures = g_list_delete_link(m_special_measures, lptr);
}
}
else {
((SpecialMeasure *) lptr->data)->type |= mtype;
}
*/
if (overwrite) {
((SpecialMeasure *) lptr->data)->type &= (~(REP_TYPE_MASK | START_TYPE_MASK | END_TYPE_MASK));
}
((SpecialMeasure *) lptr->data)->type |= mtype;
if (oldhide != NULL) {
*oldhide = ((SpecialMeasure *) lptr->data)->hide_following;
}
((SpecialMeasure *) lptr->data)->hide_following = hide;
if (((SpecialMeasure *) lptr->data)->type == 0) {
free(lptr->data);
m_special_measures = g_list_delete_link(m_special_measures, lptr);
}
repaint();
return ret;
}
}
if (mtype == 0) return 0;
spec_meas = new SpecialMeasure();
spec_meas->type = mtype;
if (oldhide != NULL) {
*oldhide = false;
}
spec_meas->hide_following = hide;
spec_meas->measure_number = measnum;
m_special_measures = g_list_insert_sorted(m_special_measures, spec_meas, compare_spec_measures_according_measnum);
repaint();
return 0;
}
void NedMainWindow::setInternalPitches() {
GList *lptr;
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->setInternalPitches();
}
}
void NedMainWindow::adjustAccidentals(int staff_nr) {
GList *lptr;
setAndUpdateClefTypeAndKeySig();
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->adjustAccidentals(staff_nr);
}
for (lptr = g_list_first(m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->removeUnneededAccidentals(staff_nr);
}
}
void NedMainWindow::setSpecialTimesig(int measnum, int num, int denom, unsigned int newsym, int *oldnum, int *olddenom, unsigned int *oldsym, bool do_reposit /* = true */) {
GList *lptr;
SpecialMeasure *spec_meas;
*oldnum = *olddenom = -1;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == measnum) {
if ((((SpecialMeasure *) lptr->data)->type & TIMESIG_TYPE_MASK) != 0) {
*oldnum = ((SpecialMeasure *) lptr->data)->numerator;
*olddenom = ((SpecialMeasure *) lptr->data)->denominator;
*oldsym = ((SpecialMeasure *) lptr->data)->symbol;
}
if (num < 0 || denom < 0) {
((SpecialMeasure *) lptr->data)->type &= (~(TIMESIG));
if (((SpecialMeasure *) lptr->data)->type == 0) {
free(lptr->data);
m_special_measures = g_list_delete_link(m_special_measures, lptr);
}
}
else {
((SpecialMeasure *) lptr->data)->setTimeSignature(num, denom, newsym);
((SpecialMeasure *) lptr->data)->type |= TIMESIG;
}
if (do_reposit) {
renumberMeasures(NULL, 1, true);
reposit();
repaint();
}
return;
}
}
if (num < 0 || denom < 0) return;
spec_meas = new SpecialMeasure();
spec_meas->type = TIMESIG;
spec_meas->measure_number = measnum;
spec_meas->setTimeSignature(num, denom, newsym);
m_special_measures = g_list_insert_sorted(m_special_measures, spec_meas, compare_spec_measures_according_measnum);
if (do_reposit) {
renumberMeasures(NULL, 1, true);
reposit();
repaint();
}
}
unsigned int NedMainWindow::getSpecial(int meas_num) {
GList *lptr;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == meas_num) {
return ((SpecialMeasure *) lptr->data)->type;
}
}
return 0;
}
SpecialMeasure *NedMainWindow::getSpecialMeasure(int meas_num) {
GList *lptr;
for (lptr = g_list_first(m_special_measures); lptr; lptr = g_list_next(lptr)) {
if (((SpecialMeasure *) lptr->data)->measure_number == meas_num) {
return (SpecialMeasure *) lptr->data;
}
}
return NULL;
}
gboolean NedMainWindow::handle_motion (GtkWidget *widget,
GdkEventMotion *event,
gpointer data)
{
GList *lptr;
if (NedResource::isPlaying()) return FALSE;
NedBbox sel_rect;
struct timeval now;
NedSystem *first_selected_system, *last_selected_system;
NedPage *first_selected_page, *last_selected_page;
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->m_last_staff_during_key_insertion = NULL;
if (!(event->state & GDK_BUTTON1_MASK)) {
if (((main_window->getMainWindowStatus() & INSERT_EREASE_MODE) != 0) && (!main_window->m_keyboard_ctrl_mode) && ((main_window->getMainWindowStatus() & SHIFT_MODE) == 0)) {
main_window->m_pointer_xpos = event->x;
main_window->m_pointer_ypos = event->y;
main_window->repaint();
}
return FALSE;
}
main_window->m_pointer_xpos = -1.0;
if ((main_window->getMainWindowStatus() & SHIFT_MODE) != 0 || ((event->state & GDK_SHIFT_MASK) != 0)) {
main_window->m_selection_rect.width = main_window->m_selection_rect.height = 0;
if (main_window->m_selected_group != NULL) {
g_list_free(main_window->m_selected_group);
main_window->m_selected_group = NULL;
}
main_window->setTopLeft(event->x, event->y);
main_window->repaint();
return FALSE;
}
if (main_window->m_selected_stem != NULL && ((main_window->getMainWindowStatus() & INSERT_EREASE_MODE) == 0)) {
gettimeofday(&now, NULL);
if (NedResource::subtime(&now, &(main_window->m_last_motion_call)) > 50000) {
if (main_window->m_selected_stem->scaleStem(event->y, main_window->m_pointer_ypos)) {
main_window->m_pointer_ypos = event->y;
}
main_window->repaint();
gettimeofday(&(main_window->m_last_motion_call), NULL);
}
return FALSE;
}
if (NedResource::getTiedMode()) {
return FALSE;
}
if (main_window->m_selected_chord_or_rest != NULL && ((main_window->m_selected_chord_or_rest->getType() & (TYPE_CLEF | TYPE_STAFF_SIGN | TYPE_KEYSIG)) != 0)) {
return FALSE;
}
if (main_window->m_selected_chord_or_rest != NULL && (((main_window->getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (main_window->m_keyboard_ctrl_mode) != 0)) {
main_window->m_selected_chord_or_rest->testXShift(event->x);
main_window->repaint();
}
else if (main_window->m_selected_free_replaceable != NULL && (((main_window->getMainWindowStatus() & INSERT_EREASE_MODE) == 0) || (main_window->m_keyboard_ctrl_mode) != 0)) {
main_window->m_selected_free_replaceable->shift(event->x, event->y, main_window->m_current_zoom, main_window->getCurrentScale(), main_window->m_leftx, main_window->m_topy);
main_window->repaint();
return FALSE;
}
if (main_window->m_selected_note == NULL || (((main_window->getMainWindowStatus() & INSERT_EREASE_MODE) != 0) && (!main_window->m_keyboard_ctrl_mode))) {
gettimeofday(&now, NULL);
if (NedResource::subtime(&now, &(main_window->m_last_motion_call)) > 50000) {
if (main_window->m_selected_chord_or_rest == NULL) {
int w = (int) (event->x - main_window->m_mouse_x);
int h = (int) (event->y - main_window->m_mouse_y);
if (w > 0) {
main_window->m_selection_rect.width = w;
}
else {
main_window->m_selection_rect.width = -w;
main_window->m_selection_rect.x = (int) (main_window->m_mouse_x + w);
}
if (h > 0) {
main_window->m_selection_rect.height = h;
}
else {
main_window->m_selection_rect.height = -h;
main_window->m_selection_rect.y = (int) (main_window->m_mouse_y + h);
}
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM) {
sel_rect.x = (main_window->m_leftx + main_window->m_selection_rect.x / main_window->getCurrentScale()) / main_window->m_current_zoom;
sel_rect.y = (main_window->m_topy + main_window->m_selection_rect.y / main_window->getCurrentScale()) / main_window->m_current_zoom;
sel_rect.width = main_window->m_selection_rect.width / main_window->m_current_zoom / main_window->getCurrentScale();
sel_rect.height = main_window->m_selection_rect.height / main_window->m_current_zoom / main_window->getCurrentScale();
if (main_window->m_selected_group != NULL) {
g_list_free(main_window->m_selected_group);
main_window->m_selected_group = NULL;
}
first_selected_system = last_selected_system = NULL;
first_selected_page = last_selected_page = NULL;
NedResource::m_number_of_first_selected_staff = NedResource::m_number_of_last_selected_staff = -1;
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->findSelectedFirstsLasts(&sel_rect, &(NedResource::m_number_of_first_selected_staff),
&(NedResource::m_number_of_last_selected_staff), &first_selected_system, &last_selected_system,
&first_selected_page, &last_selected_page);
}
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->collectSelectionRectangleElements(&sel_rect,
&(main_window->m_selected_group), first_selected_system, last_selected_system,
first_selected_page, last_selected_page);
}
}
main_window->repaint();
}
gettimeofday(&(main_window->m_last_motion_call), NULL);
}
return FALSE;
}
if (main_window->m_selected_note->testYShift(event->y)) {
main_window->repaint();
}
return FALSE;
}
NedChordOrRest* NedMainWindow::findAndBeamElementsOfCurrentVoice() {
GList *lptr;
NedChordOrRest *element = NULL;
NedCommandList *command_list;
for (lptr = g_list_first(m_selected_group); lptr; lptr = g_list_next(lptr)) {
if ((((NedChordOrRest *) lptr->data)->getType() & TYPE_CHORD) &&
(((NedChordOrRest *) lptr->data)->getVoice()->getVoiceNumber() == getCurrentVoice())){
element= (NedChordOrRest *) lptr->data;
break;
}
}
if (element == NULL) return NULL;
command_list = new NedCommandList(this, element->getSystem());
element->getVoice()->setBeamFlagsOf(command_list, m_selected_group, element);
if (command_list->getNumberOfCommands() > 0) {
m_command_history->addCommandList(command_list);
}
else {
delete command_list;
}
return element;
}
gboolean NedMainWindow::handle_button_release (GtkWidget *widget,
GdkEventButton *event, gpointer data)
{
double x;
int i;
GList *lptr;
NedCommandList *commandList;
if (NedResource::isPlaying()) return FALSE;
NedMainWindow *main_window = (NedMainWindow *) data;
if (main_window->m_selected_stem != NULL) {
NedCommandList *command_list = new NedCommandList(main_window, main_window->m_selected_stem->getSystem());
NedFixIntermediateCommand *fix_intermdiate_cmd = new NedFixIntermediateCommand(main_window->m_selected_stem);
fix_intermdiate_cmd->execute();
command_list->addCommand(fix_intermdiate_cmd);
main_window->reposit(NULL, main_window->m_selected_note->getPage(), main_window->m_selected_note->getSystem());
main_window->m_command_history->addCommandList(command_list);
}
main_window->m_selected_stem = NULL;
if (main_window->m_selection_rect.width > MIN_SELECTION_RECTANGLE_DIM && main_window->m_selection_rect.height > MIN_SELECTION_RECTANGLE_DIM) {
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(main_window->m_customize_beam_button), "groupbeams-icon");
}
else {
gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON(main_window->m_customize_beam_button), "isolate-icon");
}
if (event->button != 1) {
return FALSE;
}
if (main_window->getMainWindowStatus() & SHIFT_MODE) {
x = main_window->m_leftx / main_window->m_current_zoom;
for (i = 0, lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr), i++) {
if (((NedPage *) lptr->data)->getXPos() > x) {
break;
}
}
main_window->m_avoid_feedback = TRUE;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(main_window->m_page_selector), i);
main_window->m_avoid_feedback = FALSE;
return FALSE;
}
if (main_window->getMainWindowStatus() & INSERT_EREASE_MODE && !main_window->m_keyboard_ctrl_mode) return FALSE;
if (main_window->m_selected_chord_or_rest != NULL) {
main_window->m_selected_chord_or_rest->ReleaseTmpValue();
main_window->repaint();
}
if (main_window->m_selected_free_replaceable != NULL) {
main_window->m_selected_free_replaceable->toRel();
commandList = new NedCommandList(main_window);
commandList->addCommand(new NedFixMovedFreePlaceableCommand(main_window->m_selected_free_replaceable));
if ((main_window->m_selected_free_replaceable->getType() & (FREE_PLACEABLE_CHORD | FREE_PLACEABLE_SPACER | FREE_PLACEABLE_CHORDNAME)) != 0) {
main_window->setAllUnpositioned();
main_window->reposit(commandList);
}
main_window->m_command_history->addCommandList(commandList);
main_window->repaint();
return FALSE;
}
if (main_window->m_selected_note == NULL) return FALSE;
int new_line = main_window->m_selected_note->getTempLine();
if (new_line == UNKNOWN_LINE) return FALSE;
int old_line = main_window->m_selected_note->getLine();
if (main_window->m_selected_note->noConflict()) {
commandList = new NedCommandList(main_window, main_window->m_selected_note->getSystem());
main_window->m_selected_note->testForTiesToDelete(commandList, BREAK_TIE_BACKWARD | BREAK_TIE_FORWARD);
commandList->addCommand(new NedNoteMoveCommand(main_window->m_selected_note,
old_line, new_line));
commandList->execute();
main_window->m_command_history->addCommandList(commandList);
}
main_window->m_selected_note->handleRelease();
main_window->reposit(NULL, main_window->m_selected_note->getPage(), main_window->m_selected_note->getSystem());
main_window->repaint();
return FALSE;
}
gboolean NedMainWindow::scroll_event_handler(GtkWidget *widget, GdkEventScroll *event, gpointer data) {
#define SCROLL_INCREMENT 40.0
if (NedResource::isPlaying()) return FALSE;
NedMainWindow *main_window = (NedMainWindow *) data;
if (event->state & GDK_SHIFT_MASK) {
if (main_window->m_selected_chord_or_rest == NULL) return FALSE;
int dir = (event->direction == GDK_SCROLL_UP) ? 1 : -1;
if (!main_window->m_selected_chord_or_rest->testMeasureSpread(dir)) return FALSE;
NedCommandList *command_list;
NedChangeMeasureSpreadCommand *change_spread_cmd;
command_list = new NedCommandList(main_window, main_window->m_selected_chord_or_rest->getSystem());
change_spread_cmd = new NedChangeMeasureSpreadCommand(main_window->m_selected_chord_or_rest->m_measure, dir);
change_spread_cmd->execute();
command_list->addCommand(change_spread_cmd);
main_window->setAllUnpositioned();
main_window->reposit(command_list);
command_list->setFullReposit();
main_window->m_command_history->addCommandList(command_list);
main_window->repaint();
return FALSE;
}
if (event->direction == GDK_SCROLL_UP) {
main_window->setTopRelative(-SCROLL_INCREMENT);
}
else if (event->direction == GDK_SCROLL_DOWN) {
main_window->setTopRelative(SCROLL_INCREMENT);
}
return FALSE;
}
int NedMainWindow::getSorting(NedPage *this_page, NedStaff *this_staff, NedPage *other_page, NedStaff *other_staff) {
int pos0, pos1;
if (this_staff->getStaffNumber() != other_staff->getStaffNumber()) {
return SORTING_NONE;
}
if ((pos0 = g_list_index(m_pages, this_page)) < 0) {
NedResource::Warning("NedMainWindow::getSorting: didn't foind page 0");
return SORTING_NONE;
}
if ((pos1 = g_list_index(m_pages, other_page)) < 0) {
NedResource::Warning("NedMainWindow::getSorting: didn't foind page 1");
return SORTING_NONE;
}
if (pos0 + 1 == pos1) {
return SORTING_GREAT;
}
if (pos1 + 1 == pos0) {
return SORTING_LESS;
}
return SORTING_NONE;
}
void NedMainWindow::size_change_handler(GtkWidget *widget, GtkRequisition *allocation, gpointer data) {
NedMainWindow *main_window = (NedMainWindow *) data;
main_window->adjustView();
}
void NedMainWindow::setButtons() {
if (m_selected_chord_or_rest == NULL) return;
m_avoid_feedback_action = TRUE;
NedResource::setButtons(m_selected_chord_or_rest->getLength(), m_selected_chord_or_rest->getDotCount(), m_selected_chord_or_rest->getStatus(),
(m_selected_chord_or_rest->isRest() || m_selected_note == NULL) ? 0 : m_selected_note->getStatus(),
m_selected_chord_or_rest->isRest(), (m_selected_note == NULL) ? false : m_selected_note->getTieForward() != NULL,
(m_selected_note == NULL) ? NORMAL_NOTE : m_selected_note->getNoteHead());
}
void NedMainWindow::resetButtons() {
NedResource::resetButtons();
}
void NedMainWindow::prepareInsertion() {
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (m_insert_erease_mode_action), TRUE);
g_main_context_iteration (NULL, FALSE);
NedResource::resetTieButton();
}
void NedMainWindow::setTopLeft(double x, double y) {
NedPage *page;
m_leftx += SHIFT_ACCEL * (m_mouse_x - x);
m_topy += SHIFT_ACCEL * (m_mouse_y - y);
page = (NedPage *) g_list_first(m_pages)->data;
if (m_topy > page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale()) {
m_topy = page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale();
}
page = (NedPage *) g_list_last(m_pages)->data;
if (m_leftx > page->getLeftPos() - m_drawing_area->allocation.width / getCurrentScale()) {
m_leftx = page->getLeftPos() - m_drawing_area->allocation.width / getCurrentScale();
}
if (m_leftx < 0) {m_leftx = 0; }
if (m_topy < 0) {m_topy = 0;}
m_mouse_x = x;
m_mouse_y = y;
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
}
void NedMainWindow::setTopRelative(double y_incr) {
NedPage *page;
bool next_page_allowed = FALSE;
page = (NedPage *) g_list_first(m_pages)->data;
if (m_topy < 0.001 || m_topy > page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale() - 0.001) {
next_page_allowed = TRUE;
}
m_topy += y_incr;
if (m_topy > page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale()) {
if (next_page_allowed) {
if (setPageRelative(1)) {
m_topy = 0.0;
}
else {
m_topy = page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale();
}
}
else {
m_topy = page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale();
}
}
if (m_topy < 0) {
if (next_page_allowed) {
if (setPageRelative(-1)) {
m_topy = page->getTopPos() - m_drawing_area->allocation.height / getCurrentScale();
}
else {
m_topy = 0;
}
}
else {
m_topy = 0;
}
}
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
repaint();
}
void NedMainWindow::setToPage(int page_nr) {
GList *lptr;
if ((lptr = g_list_nth (m_pages, page_nr - 1)) == NULL) {
return;
}
m_topy = 0;
m_leftx = ((NedPage *) lptr->data)->getXPos() * m_current_zoom;
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
repaint();
}
bool NedMainWindow::setPageRelative(int y_incr) {
GList *lptr;
int page_nr;
page_nr = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(m_page_selector));
page_nr += y_incr;
if ((lptr = g_list_nth (m_pages, page_nr - 1)) == NULL) {
return FALSE;
}
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_page_selector), page_nr);
m_leftx = ((NedPage *) lptr->data)->getXPos() * m_current_zoom;
return TRUE;
}
void NedMainWindow::adjustView() {
if (m_pages == NULL) return;
NedPage *page;
page = (NedPage *) g_list_first(m_pages)->data;
if (m_topy > page->getTopPos() - m_drawing_area->allocation.height) {
m_topy = page->getTopPos() - m_drawing_area->allocation.height;
}
page = (NedPage *) g_list_last(m_pages)->data;
if (m_leftx > page->getLeftPos() - m_drawing_area->allocation.width) {
m_leftx = page->getLeftPos() - m_drawing_area->allocation.width;
}
if (m_selected_group != NULL) {
g_list_free(m_selected_group);
m_selected_group = NULL;
}
m_selection_rect.width = m_selection_rect.height = 0;
if (m_leftx < 0) m_leftx = 0;
if (m_topy < 0) m_topy = 0;
}
void NedMainWindow::write_png(GtkWidget *widget, void *data) {
GList *lptr;
gchar *selected_filename;
char the_filename[4096];
GtkWidget *png_file_dialog;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
char *cptr;
bool ok = false;
bool extend;
int page_nr;
NedPage *page;
char page_num_str[128];
cairo_surface_t *surface;
cairo_t *cr;
bool old_paint_colored;
NedNote *old_selected_note;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
page_nr = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(main_window->m_page_selector));
sprintf(page_num_str, "_%d", page_nr);
if ((lptr = g_list_nth (main_window->m_pages, page_nr - 1)) == NULL) {
lptr = g_list_first(main_window->m_pages);
}
page = (NedPage *) lptr->data;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.png (PNG-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.png");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
png_file_dialog = gtk_file_chooser_dialog_new (_("Create PNG"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(png_file_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(png_file_dialog), file_filter2);
if (main_window->m_current_filename[0] != '\0') {
strcpy(the_filename, main_window->m_current_filename);
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
*cptr = '\0';
}
}
strcat(the_filename, page_num_str);
strcat(the_filename, ".png");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(png_file_dialog), the_filename);
}
if (gtk_dialog_run (GTK_DIALOG (png_file_dialog)) == GTK_RESPONSE_ACCEPT) {
selected_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (png_file_dialog));
strcpy(the_filename, selected_filename);
g_free (selected_filename);
ok = true;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (png_file_dialog))) == file_filter1) {
extend = true;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".png")) {
extend = false;
}
}
if (extend) {
strcat(the_filename, page_num_str);
strcat(the_filename, ".png");
}
}
gtk_widget_destroy (png_file_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = false;
}
gtk_widget_destroy (access_dialog);
}
if (!ok) return;
NedChordOrRest *old_selected_chord_or_rest = main_window->m_selected_chord_or_rest;
old_selected_note = main_window->m_selected_note;
old_paint_colored = main_window->m_paint_colored;
main_window->m_paint_colored = false;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_note = NULL;
main_window->m_draw_postscript = true;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
(int) (page->getWidth() * main_window->m_current_zoom * main_window->getCurrentScale()),
(int) (page->getHeight() * main_window->m_current_zoom * main_window->getCurrentScale()));
cr = cairo_create (surface);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(main_window->m_current_zoom_level));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
page->draw(cr, gtk_toggle_action_get_active(main_window->m_show_measure_numbers_action),
page->getWidth() * main_window->m_current_zoom * main_window->getCurrentScale(),
page->getHeight() * main_window->m_current_zoom * main_window->getCurrentScale());
if (cairo_surface_write_to_png (surface, the_filename) != CAIRO_STATUS_SUCCESS) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = false;
}
cairo_surface_destroy (surface);
cairo_destroy (cr);
main_window->m_draw_postscript = false;
main_window->m_paint_colored = old_paint_colored;
main_window->m_selected_chord_or_rest = old_selected_chord_or_rest;
main_window->m_selected_note = old_selected_note;
}
#ifdef CAIRO_HAS_SVG_SURFACE
void NedMainWindow::write_svg(GtkWidget *widget, void *data) {
FILE *svgfile;
GList *lptr;
gchar *selected_filename;
char the_filename[4096];
GtkWidget *svg_file_dialog;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
char *cptr;
bool ok = false;
bool extend;
int page_nr;
NedPage *page;
char page_num_str[128];
cairo_surface_t *surface;
cairo_t *cr;
bool old_paint_colored;
NedNote *old_selected_note;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
page_nr = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(main_window->m_page_selector));
sprintf(page_num_str, "_%d", page_nr);
if ((lptr = g_list_nth (main_window->m_pages, page_nr - 1)) == NULL) {
lptr = g_list_first(main_window->m_pages);
}
page = (NedPage *) lptr->data;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.svg (SVG-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.svg");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
svg_file_dialog = gtk_file_chooser_dialog_new (_("Create SVG"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(svg_file_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(svg_file_dialog), file_filter2);
if (main_window->m_current_filename[0] != '\0') {
strcpy(the_filename, main_window->m_current_filename);
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
*cptr = '\0';
}
}
strcat(the_filename, page_num_str);
strcat(the_filename, ".svg");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(svg_file_dialog), the_filename);
}
if (gtk_dialog_run (GTK_DIALOG (svg_file_dialog)) == GTK_RESPONSE_ACCEPT) {
selected_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (svg_file_dialog));
strcpy(the_filename, selected_filename);
g_free (selected_filename);
ok = true;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (svg_file_dialog))) == file_filter1) {
extend = true;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".svg")) {
extend = false;
}
}
if (extend) {
strcat(the_filename, page_num_str);
strcat(the_filename, ".svg");
}
}
gtk_widget_destroy (svg_file_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = false;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((svgfile = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = false;
}
}
if (!ok) return;
NedChordOrRest *old_selected_chord_or_rest = main_window->m_selected_chord_or_rest;
old_selected_note = main_window->m_selected_note;
old_paint_colored = main_window->m_paint_colored;
main_window->m_paint_colored = false;
main_window->m_selected_chord_or_rest = NULL;
main_window->m_selected_note = NULL;
main_window->m_draw_postscript = true;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
(int) (page->getWidth() * main_window->m_current_zoom * main_window->getCurrentScale()),
(int) (page->getHeight() * main_window->m_current_zoom * main_window->getCurrentScale()));
surface = cairo_svg_surface_create_for_stream (writefunc, (void *) svgfile,
(int) (page->getWidth() * main_window->m_current_zoom * main_window->getCurrentScale()),
(int) (page->getHeight() * main_window->m_current_zoom * main_window->getCurrentScale()));
cr = cairo_create (surface);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(main_window->m_current_zoom_level));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
page->draw(cr, gtk_toggle_action_get_active(main_window->m_show_measure_numbers_action),
page->getWidth() * main_window->m_current_zoom * main_window->getCurrentScale(),
page->getHeight() * main_window->m_current_zoom * main_window->getCurrentScale());
cairo_surface_destroy (surface);
cairo_destroy (cr);
fclose(svgfile);
main_window->m_draw_postscript = false;
main_window->m_paint_colored = old_paint_colored;
main_window->m_selected_chord_or_rest = old_selected_chord_or_rest;
main_window->m_selected_note = old_selected_note;
}
#endif
void NedMainWindow::write_ps(GtkWidget *widget, void *data) {
FILE *psfile;
gchar *selected_filename;
char the_filename[4096];
GtkWidget *ps_file_dialog;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
char *cptr;
bool ok = FALSE;
bool extend;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::isPlaying()) return;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.ps (PostScript-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.ps");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
ps_file_dialog = gtk_file_chooser_dialog_new (_("Create Postscript"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ps_file_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ps_file_dialog), file_filter2);
if (main_window->m_current_filename[0] != '\0') {
strcpy(the_filename, main_window->m_current_filename);
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
*cptr = '\0';
}
}
strcat(the_filename, ".ps");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ps_file_dialog), the_filename);
}
if (gtk_dialog_run (GTK_DIALOG (ps_file_dialog)) == GTK_RESPONSE_ACCEPT) {
selected_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ps_file_dialog));
strcpy(the_filename, selected_filename);
g_free (selected_filename);
ok = TRUE;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (ps_file_dialog))) == file_filter1) {
extend = TRUE;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ps")) {
extend = FALSE;
}
}
if (extend) {
strcat(the_filename, ".ps");
}
}
gtk_widget_destroy (ps_file_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = FALSE;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((psfile = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (!ok) return;
main_window->do_export_to_stream(psfile, STREAM_FILE_TYPE_PS);
fclose(psfile);
}
#ifdef CAIRO_HAS_PDF_SURFACE
void NedMainWindow::write_pdf(GtkWidget *widget, void *data) {
FILE *pdffile;
gchar *selected_filename;
char the_filename[4096];
GtkWidget *pdf_file_dialog;
GtkWidget *access_dialog;
GtkWidget *error_dialog;
char *cptr;
bool ok = FALSE;
bool extend;
NedMainWindow *main_window = (NedMainWindow *) data;
if (NedResource::isPlaying()) return;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.pdf (PDF-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.pdf");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
pdf_file_dialog = gtk_file_chooser_dialog_new (_("Create PDF"),
GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pdf_file_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pdf_file_dialog), file_filter2);
if (main_window->m_current_filename[0] != '\0') {
strcpy(the_filename, main_window->m_current_filename);
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntd")) {
*cptr = '\0';
}
}
strcat(the_filename, ".pdf");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(pdf_file_dialog), the_filename);
}
if (gtk_dialog_run (GTK_DIALOG (pdf_file_dialog)) == GTK_RESPONSE_ACCEPT) {
selected_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (pdf_file_dialog));
strcpy(the_filename, selected_filename);
g_free (selected_filename);
ok = TRUE;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (pdf_file_dialog))) == file_filter1) {
extend = TRUE;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".pdf")) {
extend = FALSE;
}
}
if (extend) {
strcat(the_filename, ".pdf");
}
}
gtk_widget_destroy (pdf_file_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = FALSE;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((pdffile = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (!ok) return;
main_window->do_export_to_stream(pdffile, STREAM_FILE_TYPE_PDF);
fclose(pdffile);
}
#endif
cairo_status_t NedMainWindow::writefunc(void *fdv, const unsigned char *data, unsigned int length) {
if (fwrite(data, length, 1, (FILE *) fdv) != 1) {
NedResource::Abort("Fehler in writefunc\n");
}
return CAIRO_STATUS_SUCCESS;
}
void NedMainWindow::do_export_to_stream(FILE *psfile, int stream_file_type) {
cairo_surface_t* stream_file_surface;
cairo_t *cr;
char Str[1024];
int old_zoom_level = m_current_zoom_level;
NedChordOrRest *old_selected_chord_or_rest = m_selected_chord_or_rest;
NedNote *old_selected_note = m_selected_note;
bool old_paint_colored = m_paint_colored;
m_paint_colored = false;
m_selected_chord_or_rest = NULL;
m_selected_note = NULL;
m_draw_postscript = true;
if (NedResource::isPlaying()) return;
if (stream_file_type == STREAM_FILE_TYPE_PS) {
if (m_portrait) {
stream_file_surface = cairo_ps_surface_create_for_stream(writefunc, (void *) psfile, m_current_paper->width, m_current_paper->height);
}
else {
stream_file_surface = cairo_ps_surface_create_for_stream(writefunc, (void *) psfile, m_current_paper->height, m_current_paper->width);
}
cairo_ps_surface_dsc_comment(stream_file_surface, "%%Creator: nted by J.Anders (ja@informatik.tu-chemnitz.de\n");
if (m_current_filename[0] == '\0') {
cairo_ps_surface_dsc_comment(stream_file_surface, "%%Title: Music\n");
}
else {
sprintf(Str, "%%Title: %s\n", m_current_filename);
cairo_ps_surface_dsc_comment(stream_file_surface, Str);
}
cairo_ps_surface_dsc_begin_setup(stream_file_surface);
cairo_ps_surface_dsc_begin_page_setup (stream_file_surface);
}
else {
if (m_portrait) {
stream_file_surface = cairo_pdf_surface_create_for_stream(writefunc, (void *) psfile, m_current_paper->width, m_current_paper->height);
}
else {
stream_file_surface = cairo_pdf_surface_create_for_stream(writefunc, (void *) psfile, m_current_paper->height, m_current_paper->width);
}
}
cr = cairo_create (stream_file_surface);
m_current_zoom_level = 4;
m_current_zoom = PS_ZOOM2;
adjustAfterZoom();
computeSystemIndent();
computeScoreTextExtends();
draw(cr, m_current_paper->width, m_current_paper->height);
cairo_surface_destroy (stream_file_surface);
cairo_destroy (cr);
m_draw_postscript = false;
m_paint_colored = old_paint_colored;
m_selected_chord_or_rest = old_selected_chord_or_rest;
m_selected_note = old_selected_note;
m_current_zoom_level = old_zoom_level;
m_current_zoom = NedResource::getZoomFactor(m_current_zoom_level);
adjustAfterZoom();
computeSystemIndent();
computeScoreTextExtends();
}
void NedMainWindow::new_window(GtkWidget *widget, void *data) {
NedMainWindow *ned_main_window = new NedMainWindow(); // the new window registers itself in NedResource::m_main_windows list
#ifdef YELP_PATH
ned_main_window->createLayout(NULL, NedResource::m_yelparg);
#else
ned_main_window->createLayout(NULL, NULL);
#endif
}
void NedMainWindow::create_excerpt(GtkWidget *widget, void *data) {
GList *lptr;
struct addr_ref_str *addrlist = NULL, *slurlist = NULL, *addr_ptr;
SpecialMeasure *spec_measure;
NedMainWindow *main_window = (NedMainWindow *) data;
bool *staves = (bool *) alloca(main_window->m_staff_count * sizeof(bool));
bool state, correct_layout = false;
int i, j;
NedStaffSelectDialog *staff_select_dialog = new NedStaffSelectDialog(GTK_WINDOW(main_window->m_main_window), _("select staves"), main_window, staves);
staff_select_dialog->getValues(&state);
delete staff_select_dialog;
if (!state) return;
NedMainWindow *ned_main_window = new NedMainWindow(); // the new window registers itself in NedResource::m_main_windows list
ned_main_window->m_staff_count = main_window->m_staff_count;
ned_main_window->m_global_spacement_fac = main_window->m_global_spacement_fac;
ned_main_window->m_numerator = main_window->m_numerator;
ned_main_window->m_denominator = main_window->m_denominator;
ned_main_window->m_timesig_symbol = main_window->m_timesig_symbol;
ned_main_window->m_midi_tempo_inverse = main_window->m_midi_tempo_inverse;
ned_main_window->m_upbeat_inverse = main_window->m_upbeat_inverse;
ned_main_window->m_score_info = main_window->m_score_info;
ned_main_window->m_first_page_yoffs = main_window->m_first_page_yoffs;
ned_main_window->m_current_paper = main_window->m_current_paper;
ned_main_window->m_current_scale = main_window->m_current_scale;
ned_main_window->m_portrait = main_window->m_portrait;
for (lptr = g_list_first(main_window->m_special_measures); lptr; lptr = g_list_next(lptr)) {
if ((spec_measure = (SpecialMeasure *) g_try_malloc(sizeof(SpecialMeasure))) == NULL) {
NedResource::Abort("NedMainWindow::create_excerpt: malloc");
}
*spec_measure = (*((SpecialMeasure *) lptr->data));
ned_main_window->m_special_measures = g_list_append(ned_main_window->m_special_measures, spec_measure);
}
#ifdef YELP_PATH
ned_main_window->createLayout(NULL, NedResource::m_yelparg);
#else
ned_main_window->createLayout(NULL, NULL);
#endif
for (i = j = 0; i < main_window->m_staff_count; i++) {
if (!staves[i]) {
ned_main_window->m_staff_count--;
correct_layout = true;
continue;
}
ned_main_window->m_staff_contexts[j] = main_window->m_staff_contexts[i];
if (main_window->m_staff_contexts[i].m_staff_name != NULL) {
ned_main_window->m_staff_contexts[j].m_staff_name = main_window->m_staff_contexts[i].m_staff_name->clone();
}
if (ned_main_window->m_staff_contexts[j].m_staff_short_name != NULL) {
ned_main_window->m_staff_contexts[j].m_staff_short_name = main_window->m_staff_contexts[i].m_staff_short_name->clone();
}
if (main_window->m_staff_contexts[i].m_group_name != NULL) {
ned_main_window->m_staff_contexts[j].m_group_name = main_window->m_staff_contexts[i].m_group_name->clone();
}
if (ned_main_window->m_staff_contexts[j].m_group_short_name != NULL) {
ned_main_window->m_staff_contexts[j].m_group_short_name = main_window->m_staff_contexts[i].m_group_short_name->clone();
}
j++;
}
delete (NedPage *) g_list_first(ned_main_window->m_pages)->data;
g_list_free(ned_main_window->m_pages);
ned_main_window->m_pages = NULL;
for (lptr = g_list_first(main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
ned_main_window->m_pages = g_list_append(ned_main_window->m_pages, ((NedPage *) lptr->data)->clone(&addrlist, &slurlist, ned_main_window, staves));
}
for (lptr = g_list_first(ned_main_window->m_pages); lptr; lptr = g_list_next(lptr)) {
((NedPage *) lptr->data)->adjust_pointers(addrlist, slurlist);
}
while (addrlist != NULL) {
addr_ptr = addrlist->next;
g_free(addrlist);
addrlist = addr_ptr;
}
while (slurlist != NULL) {
addr_ptr = slurlist->next;
g_free(slurlist);
slurlist = addr_ptr;
}
if (correct_layout) {
for (i = 0; i < ned_main_window->m_staff_count; i++) {
ned_main_window->m_staff_contexts[i].m_flags = 0;
}
}
ned_main_window->computeSystemIndent();
ned_main_window->m_topy = ned_main_window->m_leftx = 0;
NedCommandList *command_list = new NedCommandList(ned_main_window);
ned_main_window->setNewMeasureSpread(ned_main_window->m_global_spacement_fac);
ned_main_window->setAndUpdateClefTypeAndKeySig();
ned_main_window->setAllUnpositioned();
ned_main_window->reposit(command_list);
ned_main_window->zoomFreeReplaceables(ned_main_window->m_current_zoom, ned_main_window->getCurrentScale());
ned_main_window->setAndUpdateClefTypeAndKeySig();
ned_main_window->setAllUnpositioned();
ned_main_window->reposit(command_list);
ned_main_window->updatePageCounter();
}
bool NedMainWindow::close_window2(GtkWidget *widget, GdkEvent *event, gpointer data) {
close_window(widget, data);
return FALSE;
}
void NedMainWindow::close_window(GtkWidget *widget, void *data) {
GList *lptr;
bool stop_closing = false, do_save = false;
GtkWidget *unsaved_dialog;
if (NedResource::isPlaying()) return;
NedMainWindow *main_window = (NedMainWindow *) data;
if ((lptr = g_list_find(NedResource::m_main_windows, main_window)) == NULL) {
NedResource::Abort("NedMainWindow::close_window");
}
if (main_window->m_config_changed || main_window->m_command_history->unsavedOperations()) {
unsaved_dialog = gtk_message_dialog_new (GTK_WINDOW(main_window->m_main_window),
(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
_("Save Changes ?"));
gtk_dialog_add_buttons(GTK_DIALOG (unsaved_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
switch (gtk_dialog_run (GTK_DIALOG (unsaved_dialog))) {
case GTK_RESPONSE_YES: do_save = true; break;
case GTK_RESPONSE_REJECT: stop_closing = true; break;
}
gtk_widget_destroy (unsaved_dialog);
if (stop_closing) {
return;
}
if (do_save) {
save_score(main_window->m_main_window, data);
}
}
NedResource::m_main_windows = g_list_delete_link(NedResource::m_main_windows, lptr);
if (g_list_length(NedResource::m_main_windows) < 1) {
NedResource::cleanup();
}
if (NedResource::m_recorded_staff != NULL && NedResource::m_recorded_staff->getMainWindow() == main_window) {
NedResource::m_recorded_staff = NULL;
}
delete main_window;
if (g_list_length(NedResource::m_main_windows) < 1) {
gtk_main_quit();
}
}
int main (int argc, char **argv)
{
#ifdef YELP_PATH
const gchar* const *langnames;
const gchar* const *cptr;
char Str[1024];
#endif
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
NedMainWindow *ned_main_window = new NedMainWindow(); // the new window registers itself in NedResource::m_main_windows list
if (argc > 2) {
fprintf(stderr, _("Usage: %s [.ntd]\n"), argv[0]);
exit(1);
}
gtk_init (&argc, &argv);
#ifdef YELP_PATH
langnames = g_get_language_names ();
for (cptr = langnames; *cptr != NULL; cptr++) {
sprintf(Str, "%s/%s/index.docbook", NTED_HTMLDIR, *cptr);
if (!access(Str, R_OK)) {
NedResource::m_yelparg = strdup(Str);
break;
}
}
if (NedResource::m_yelparg == NULL) {
sprintf(Str, "%s/en/index.docbook", NTED_HTMLDIR);
if (!access(Str, R_OK)) {
NedResource::m_yelparg = strdup(Str);
}
}
#endif
if (setlocale(LC_NUMERIC, "C") == NULL) {
if (setlocale(LC_NUMERIC, "POSIX") == NULL) {
NedResource::Warning(_("unable to set decimal point to '.'. PostScript output will be erroneous. \
Please set the $LANG environment variable appropriately!"));
}
}
NedResource::initialize();
#ifdef YELP_PATH
ned_main_window->createLayout((argc == 2) ? argv[1] : NULL, NedResource::m_yelparg);
#else
ned_main_window->createLayout((argc == 2) ? argv[1] : NULL, NULL);
#endif
gtk_main ();
return 0;
}
bool SpecialMeasure::isNear(double x, double y) {
//if (type & REP_TYPE_MASK != REPEAT_CLOSE) return false;
if ((type & START_TYPE_MASK) == 0) return false;
if (measure == NULL) {
NedResource::DbgMsg(DBG_CRITICAL, "0x%x: type = 0x%x, measnum = %d measure = 0x%x, (0x%x)\n", this, type, measure_number, measure, &measure);
NedResource::Abort("SpecialMeasure::isNear");
}
return measure->nearRepeatElement(x, y);
}
int SpecialMeasure::compare_spec_measures(const SpecialMeasure *a, const SpecialMeasure *b) {
if (a->measure_number < b->measure_number) return -1;
if (a->measure_number == b->measure_number) return 0;
return 1;
}
nted-1.10.18/freespacer.h 0000664 0010410 0000764 00000004300 11520267230 012017 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef FREE_SPACER_H
#define FREE_SPACER_H
#include "freereplaceable.h"
class NedMainWindow;
class NedFreeSpacer : public NedFreeReplaceable {
public:
NedFreeSpacer(NedMainWindow *main_window);
NedFreeSpacer(NedMainWindow *main_window, NedChordOrRest *element);
NedFreeSpacer(NedMainWindow *main_window, NedChordOrRest *element, double x, double y, bool relative);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL ) {
return NULL;
}
virtual void adjust_pointers(struct addr_ref_str *slurlist) {}
virtual bool trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_SPACER;}
virtual void startContextDialog(GtkWidget *ref) {}
private:
NedMainWindow *m_main_window;
};
#endif /* FREE_SPACER_H */
nted-1.10.18/positionarray.h 0000664 0010410 0000764 00000007414 11520267230 012614 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef POSITIONARRAY_H
#define POSITIONARRAY_H
#include "dynarray.h"
class NedChordOrRest;
struct voice_properties {
char m_stem_decision;
short m_line_sum;
short m_note_count;
short m_rests_count;
};
class NedPosition {
public:
NedPosition(NedChordOrRest *element, int offs, unsigned int staff_count);
void placeRests(struct voice_properties *vprops);
bool m_valid;
bool m_has_notes;
bool m_has_unhidden_elements;
bool m_has_only_staff_members;
bool m_has_only_graces;
bool m_element_has_arpeggio;
bool isUsed(int offs);
double m_max_microshift;
double m_step_width;
unsigned int m_min_duration;
unsigned long long m_midi_time;
bool hasNote();
void placeAt(double xpos, int *v_array, struct voice_properties *v_props, int mnum, bool out);
void computeAccidentalPositions(int mnum, bool out);
void shiftXpos(double xshift, int mnum, int pos);
void setNewStaffCount(unsigned int newstaffcount);
void computeMicroShifts(int mnum, int pos, bool out);
bool hasOtherStaffElements(int type);
double m_min_width_after, m_min_width_before, m_acc_dist, m_needed_width, m_min_needed_width ;
void insertElement(NedChordOrRest *element, int offs);
bool insertStaffElement(NedChordOrRest *element, int staff_offs);
void empty();
#ifdef UUU
bool print();
#endif
private:
NedDynArray m_voice_members;
NedDynArray m_count_of_elements_per_staff;
NedDynArray m_staff_members;
unsigned int m_staff_count;
};
class NedPositionArray {
public:
NedPositionArray();
~NedPositionArray();
void insertElement(NedChordOrRest *element, int offs, int mnum);
void insertStaffElement(NedChordOrRest *element, int staff_offs, int mnum);
void insertGraceElement(NedChordOrRest *element, int offs, int mnum);
void empty();
double computeAndSetPositions(double start_position, int *num_elements, double *extra_space_for_accidentals, bool *measure_has_only_staff_members /* means keysig */ ,double timesig_space, int mnum, double spread_fac, bool out);
void setNewStaffCount(unsigned int newstaffcount);
double shiftXpos(double extra_space_divided, double shift, int mnum, bool out);
unsigned int getStoredStaffCount() {return m_staff_count;}
int getStemDirectionOfTheMeasure(int m_staff_voice_offs);
#ifdef UUU
void print();
#endif
private:
unsigned int m_staff_count;
unsigned int m_min_duration;
double m_min_durations_dist;
NedDynArray m_positions;
NedDynArray m_voice_properties;
static int compare_positions(NedPosition **pos1, NedPosition **pos2);
};
#endif /* POSITIONARRAY_H */
nted-1.10.18/pangocairotext.h 0000664 0010410 0000764 00000006763 11520267230 012746 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef PANGO_CAIRO_TEXT_H
#define PANGO_CAIRO_TEXT_H
#include "config.h"
#include
#include
#include
class NedPangoCairoText {
public:
NedPangoCairoText(GdkDrawable *d, const char *text, const char* font_family, PangoStyle style, PangoWeight weight, double size, double zoom, double scale, bool hide_trailing_hyphen);
~NedPangoCairoText();
NedPangoCairoText *clone();
void setZoom(double zoom, double scale);
void adjust(GdkDrawable *d, double zoom, double scale);
void setText(char *text, double zoom, bool hide_trailing_hyphen);
bool textDiffers(char *other_text);
bool moveCursor(int dist);
void insertAtCursorPosition(const char *text, double zoom);
bool removeAtCursorPosition(double zoom);
char *getText();
double getWidth();
double getHeight();
double getInternalWidth();
double getInternalHeight();
bool hasHiddenHyphen() {return m_hidden_hyphen;}
void setCursorToLastPos();
void setCursorToFirstPos();
double getFontSize();
void draw(cairo_t *cr, double xpos, double ypos, double zoom, double scale);
void drawCursor(cairo_t *cr, double xpos, double ypos, double zoom_factor);
static double getInternalFactor();
static void handle_spec_utf8_chars(char *cptr, char *cptr2);
static void convert_bslash_text_to_utf8_text(const char *in_text, char *out_text);
static void makeLilyString(char *n_string, char *buffer);
private:
void createLayout(cairo_t *cr, double zoom, double scale);
void computeCursorPosition();
void computeDimensions();
char *inspect_text(const char *text);
static struct utf8_element {
const char *short_chars;
unsigned char utf8code[4];
} utf8code_array[];
PangoLayout *m_display_layout;
PangoLayout *m_measure_layout;
GdkDrawable *m_drawable;
bool m_hidden_hyphen;
char *m_text;
char *m_measure_text;
const char *m_font_family;
PangoStyle m_style;
PangoWeight m_weight;
double m_size;
int m_width;
int m_height;
int m_internal_width;
int m_internal_height;
bool m_hide_hyphen;
unsigned int m_cursor_idx;
PangoRectangle m_cursorpos;
class specLetter {
public:
specLetter(const char *let, int ix, double xo, double yo);
const char *letter;
int idx;
double xoffs, yoffs;
PangoRectangle pos;
};
GList *m_spec_letters;
};
#endif /* PANGO_CAIRO_TEXT_H */
nted-1.10.18/acceleration.h 0000664 0010410 0000764 00000003554 11520267230 012343 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef ACCELERATION_H
#define ACCELERATION_H
#include "line3.h"
class NedAcceleration : public NedLine3 {
public:
NedAcceleration(NedLinePoint *start, NedLinePoint *mid, NedLinePoint *end, bool ritardando);
NedAcceleration(NedLinePoint *start, NedLinePoint *mid, NedLinePoint *end, bool ritardando, double tempodiff);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level);
virtual int getLineType() {return m_ritardando ? LINE_RITARDANDO : LINE_ACCELERANDO;}
virtual void startContextDialog(GtkWidget *ref);
bool isRitardando() {return m_ritardando;}
double m_tempodiff;
private:
bool m_ritardando;
};
#endif /* ACCELERATION_H */
nted-1.10.18/missing 0000775 0010410 0000764 00000026233 11520267230 011137 0000000 0000000 #! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2009-04-28.21; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard , 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case $1 in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
\`g' are ignored when checking the name.
Send bug reports to ."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# normalize program name to check for.
program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program). This is about non-GNU programs, so use $1 not
# $program.
case $1 in
lex*|yacc*)
# Not GNU programs, they don't have --version.
;;
tar*)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $program in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te*)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison*|yacc*)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG="\${$#}"
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if test ! -f y.tab.h; then
echo >y.tab.h
fi
if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex*|flex*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG="\${$#}"
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit $?
fi
;;
makeinfo*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '
/^@setfilename/{
s/.* \([^ ]*\) *$/\1/
p
q
}' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar*)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
nted-1.10.18/config.h.in 0000664 0010410 0000764 00000002527 11520267352 011570 0000000 0000000 /* config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */
#undef HAVE_CFLOCALECOPYCURRENT
/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Version number of package */
#undef VERSION
/* Path to yelp program */
#undef YELP_PATH
nted-1.10.18/temposign.cpp 0000664 0010410 0000764 00000016051 11520267230 012246 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "temposign.h"
#include "chordorrest.h"
#include "tempodialog.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#define X_POS_PAGE_REL(p) ((m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
NedTempoSign::NedTempoSign(unsigned int kind, unsigned int tempo) : NedFreeReplaceable(), m_kind(kind), m_tempo(tempo), m_number_len(0), m_dot(0) {computeGlypths();}
NedTempoSign::NedTempoSign(unsigned int kind, unsigned int tempo, NedChordOrRest *element) : NedFreeReplaceable(element), m_kind(kind), m_tempo(tempo), m_number_len(0), m_dot(0) {computeGlypths();}
NedTempoSign::NedTempoSign(unsigned int kind, unsigned int tempo, NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative), m_kind(kind), m_tempo(tempo), m_number_len(0), m_dot(0) {computeGlypths();}
NedFreeReplaceable *NedTempoSign::clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area /* = NULL */, NedMainWindow *main_window /* = NULL */) {
NedTempoSign *newVolSig = new NedTempoSign(m_kind, m_tempo, newelement, m_x, m_y, true);
return newVolSig;
}
void NedTempoSign::adjust_pointers(struct addr_ref_str *slurlist) {
}
void NedTempoSign::setTempo(unsigned int kind, unsigned int tempo) {
m_kind = kind;
m_tempo = tempo;
computeGlypths();
}
double NedTempoSign::getTempoInverse() {
if (m_dot) {
return (double) NOTE_4 / (double) (3 * m_kind / 2) * 60000.0 / (double) m_tempo;
}
return (double) NOTE_4 / (double) m_kind * 60000.0 / (double) m_tempo;
}
void NedTempoSign::computeGlypths() {
switch (m_kind) {
case WHOLE_NOTE: m_dot = 0; break;
case NOTE_2: m_dot = 0; break;
case 3 * NOTE_2 / 2: m_dot = 1; m_kind = NOTE_2; break;
case NOTE_4: m_dot = 0; break;
case 3 * NOTE_4 / 2: m_dot = 1; m_kind = NOTE_4; break;
case NOTE_8: m_dot = 0; break;
case 3 * NOTE_8 / 2: m_dot = 1; m_kind = NOTE_8; break;
case NOTE_16: m_dot = 0; break;
case 3 * NOTE_16 / 2: m_dot = 1; m_kind = NOTE_16; break;
default: NedResource::Abort("NedTempoSign::computeGlypths"); break;
}
if (m_tempo < 10) {
m_number_len = 1;
m_glyphs[0].index = m_tempo + NUMBERBASE;
return;
}
if (m_tempo < 100) {
m_number_len = 2;
m_glyphs[0].index = (m_tempo / 10) + NUMBERBASE;
m_glyphs[1].index = (m_tempo % 10) + NUMBERBASE;
return;
}
m_number_len = 3;
m_glyphs[0].index = (m_tempo / 100) + NUMBERBASE;
m_glyphs[1].index = ((m_tempo % 100) / 10) + NUMBERBASE;
m_glyphs[2].index = (m_tempo % 10) + NUMBERBASE;
}
void NedTempoSign::startContextDialog(GtkWidget *ref) {
bool state;
unsigned int newtempo, newkind;
bool newdot;
NedTempoDialog *tempo_dialog = new NedTempoDialog(GTK_WINDOW(ref), false, m_kind, m_dot, m_tempo);
tempo_dialog->getValues(&state, &newkind, &newdot, &newtempo);
delete tempo_dialog;
if (state) {
m_kind = newdot ? 3 * newkind / 2 : newkind;
m_tempo = newtempo;
computeGlypths();
}
}
void NedTempoSign::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale) {
if (m_element == NULL) return;
double xpos, ypos;
int i;
#define EXTRA_OFFS 0.15
double extra_offs = 0.0;
cairo_glyph_t glyph;
cairo_matrix_t m;
double extra_x_offs = 0.0;
getXYPos(&xpos, &ypos);
cairo_new_path(cr);
if (isActive()) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
switch(m_kind) {
case WHOLE_NOTE: glyph.index = BASE + 6; break;
case NOTE_2: glyph.index = BASE + 7; break;
case NOTE_4: glyph.index = BASE + 4; break;
default: glyph.index = BASE + 4;
extra_offs = EXTRA_OFFS; break;
}
glyph.x = 0.0;
glyph.y = 0.0;
cairo_get_matrix(cr, &m);
#define X_SPACE 0.4
cairo_translate(cr, X_POS_PAGE_REL(xpos - X_SPACE), Y_POS_PAGE_REL(ypos));
#define SCALE 0.6
cairo_scale(cr, SCALE, SCALE);
cairo_show_glyphs(cr, &glyph, 1);
#define EQU_XOFFS 0.3
#define EQU_LEN 0.3
#define QE_1_POS 0.0
#define QE_2_POS 0.1
#define NUMBER_DIST 0.55
#define DIGIT_DIST 0.3
#define NUMBER_Y_POS 0.2
#define TEMPO_DOT_DIST (1.3 * LINE_DIST)
#define TEMPO_DOT_RAD (0.2 * LINE_DIST)
#define TEMPO_DOT_EXTRA_X_OFFS (0.4 * LINE_DIST)
if (m_dot) {
extra_x_offs = TEMPO_DOT_EXTRA_X_OFFS;
cairo_new_path(cr);
cairo_arc(cr, zoom_factor * TEMPO_DOT_DIST, 0.0, zoom_factor * TEMPO_DOT_RAD, 0.9, 2.0 * M_PI);
cairo_fill(cr);
}
glyph.index = BASE + 5;
if (m_kind < NOTE_4) {
glyph.x = zoom_factor * (extra_x_offs + HEAD_THICK_HALF - 0.15);
glyph.y = -zoom_factor * 0.8 * STEM_DEFAULT_HEIGHT;
cairo_show_glyphs(cr, &glyph, 1);
}
if (m_kind < NOTE_8) {
glyph.x = zoom_factor * (extra_x_offs + HEAD_THICK_HALF - 0.15);
glyph.y = -zoom_factor * 0.6 * STEM_DEFAULT_HEIGHT;
cairo_show_glyphs(cr, &glyph, 1);
}
for (i = 0; i < 3;i++) {
m_glyphs[i].x = zoom_factor * (extra_x_offs + NUMBER_DIST + extra_offs + i * DIGIT_DIST);
m_glyphs[i].y = zoom_factor * NUMBER_Y_POS;
}
cairo_show_glyphs(cr, m_glyphs, m_number_len);
cairo_stroke(cr);
cairo_set_line_width(cr, zoom_factor * 1.4 * STEM_THICK);
if (m_kind < WHOLE_NOTE) {
cairo_new_path(cr);
cairo_move_to(cr, zoom_factor * (HEAD_THICK_HALF - 0.15), 0.0);
cairo_line_to(cr, zoom_factor * (HEAD_THICK_HALF - 0.15), - zoom_factor * 0.8 * STEM_DEFAULT_HEIGHT);
cairo_stroke(cr);
}
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * STEM_THICK);
cairo_move_to(cr, zoom_factor * (extra_x_offs + EQU_XOFFS + EQU_LEN + extra_offs), - zoom_factor * QE_1_POS);
cairo_line_to(cr, zoom_factor * (extra_x_offs + EQU_XOFFS + extra_offs), - zoom_factor * QE_1_POS);
cairo_move_to(cr, zoom_factor * (extra_x_offs + EQU_XOFFS + EQU_LEN + extra_offs), - zoom_factor * QE_2_POS);
cairo_line_to(cr, zoom_factor * (extra_x_offs + EQU_XOFFS + extra_offs), - zoom_factor * QE_2_POS);
cairo_stroke(cr);
if (isActive()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
cairo_set_matrix(cr, &m);
if (m_is_abs) {
drawConnection(cr, xpos, ypos, leftx, topy, zoom_factor);
}
}
;
nted-1.10.18/staff.h 0000664 0010410 0000764 00000021435 11520267230 011013 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef STAFF_H
#define STAFF_H
#include "config.h"
#include "resource.h"
#include
#include
class NedMainWindow;
class NedPage;
class NedSystem;
class NedVoice;
class NedChordOrRest;
class NedClipBoard;
class NedCommandList;
class NedLyricsEditor;
struct VoiceInfoContainer;
class NedMeasure;
class NedSlur;
class part;
class NedStaff {
public:
NedStaff(NedSystem *system, double ypos, double width, int nr, bool start);
~NedStaff();
NedStaff *clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedSystem *p_system, int staff_number);
void adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist);
void draw(cairo_t *cr, double botpos, bool first_page, double indent, bool *freetexts_or_lyrics_present);
void drawTexts(cairo_t *cr, bool first_page, double scale);
NedMainWindow *getMainWindow();
NedPage *getPage();
NedSystem *getSystem() {return m_system;}
int getStaffNumber() {return m_staff_number;}
bool truncateAtStart(NedCommandList *command_list, unsigned long long midi_time);
void setStaffNumber(int nr) {m_staff_number = nr;}
void prepareForImport();
void appendElementsOfMeasureLength(part *part_ptr, unsigned int meas_duration, int meas_num);
void copyDataOfWholeStaff();
void removeLastImported();
bool handleImportedTuplets();
void handleStaffElements();
//bool find_new_cursor_pos(guint keyval, int *x, int *y, double *dist);
bool trySelect (double x, double y, bool only_free_placeables);
NedChordOrRest *findNearestElement(double x, double y, NedStaff *oldstaff, double *mindist, double *ydist);
bool tryInsertOrErease (double x, double y, int num_midi_input_notes, int *midi_input_chord/* given if insert from midikeyboard */, NedChordOrRest **newObj, bool force_rest);
bool tryErease (double x, double y);
bool findLine(double x, double y, double *ypos, int *line, double *bottom);
bool findFirstElementeGreaterThan(double x, NedChordOrRest **element);
bool findLastElementeLessThan(double x, NedChordOrRest **element);
double getBottomPos();
double getMidPos();
double getTopPos() {return m_ypos;}
double getWidth() {return m_width;}
double getRealYPosOfLine(int line);
void setWidth(double w) {m_width = w;}
double getHeight();
void empty();
bool hasOnlyRests();
void cutEmptyVoices();
void handleEmptyMeasures();
void zoomFreeReplaceables(double zoom, double scale);
void recomputeFreeReplaceables();
void computeBeams();
void computeTuplets(bool has_repeat_lines);
void computeTies();
unsigned int getStaffDurationTotal();
void assignMidiTimes();
double computeMidDist(double y);
void collectChordsAndRests(NedClipBoard *board, unsigned long long midi_start, unsigned long long midi_end);
void collectDestinationVoices(NedClipBoard *board);
int assignElementsToMeasures(NedMeasure *measures, int staff_offs, bool use_upbeat, int *special_measure_at_end, bool out = false);
bool tryChangeLength(NedChordOrRest *chord_or_rest);
void searchForBeamGroups(unsigned int midi_start_time);
double getTopYBorder() {return m_top_y_border;}
double getBottomYBorder() {return m_bottom_y_border;}
void convertStaffRel(double x, double y, double *x_trans, double *y_trans);
double placeStaff(double staffpos);
int getNumberOfVoices(int staff_number);
void saveStaff(FILE *fp);
void restoreStaff(FILE *fp);
void resetActiveFlags();
void prepareReplay(bool with_keysig);
void findAccidentals(char offs_array[115], NedMeasure *meas_info, unsigned long long midi_time, bool including);
void setInternalPitches();
void adjustAccidentals();
void changeAccidentals(NedCommandList *command_list, int preferred_offs, GList *selected_group);
void transpose(int pitchdist, GList *selected_group);
void hideRests(NedCommandList *command_list, bool unhide, int voice_nr);
bool shiftNotes(unsigned long long start_time, int linedist);
void removeUnneededAccidentals(GList *selected_group = NULL);
void appendWholeRest(NedCommandList *command_list = NULL);
void getCurrentClefAndKeysig(unsigned long long miditime, int *clef, int *keysig, int *octave_shift);
void appendAppropriateWholes(int start_measure);
void setUpbeatRests(unsigned int upbeat_inverse);
void testTies();
void collectSelectionRectangleElements(double xp, double yp, NedBbox *sel_rect, GList **sel_group,
bool is_first_selected, bool is_last_selected);
void findSelectedStaffs(double yp, NedBbox *sel_rect, int *number_of_first_selected_staff, int *number_of_last_selected_staff);
void pasteElements(NedCommandList *command_list, GList **elements, int from_staff, unsigned long long start_midi_time);
bool hasTupletConflict(unsigned int meas_duration, GList **elements, int from_staff, unsigned int long long midi_time);
bool findFromTo(GList *clipboard);
bool findStartMeasureLimits(GList *clipboard, unsigned long long *start_midi);
bool findEndMeasureLimits(GList *clipboard, unsigned long long *end_midi);
void deleteItemsFromTo(NedCommandList *command_list, bool is_first, bool is_last, unsigned long long start_midi, unsigned long long end_midi);
void removeNotesFromTo(NedCommandList *command_list, GList *items, bool is_first, bool is_last);
void insertBlocks(NedCommandList *command_list, int blockcount, unsigned long long midi_time);
void testForPageBackwardTies(NedCommandList *command_list);
void checkForElementsToSplit(NedCommandList *command_list);
void insertStaffElement(NedChordOrRest *elem, bool redraw = true);
void removeStaffElement(NedChordOrRest *elem);
void deleteStaffElements(bool unexecute, GList *elems, unsigned long long reftime, unsigned long duration);
bool hasStaffElem(unsigned long long miditime);
void insertIntoStaff(GList *elems, unsigned long long duration);
void appendAtStaff(GList *elems);
void setAndUpdateClefTypeAndKeySig(int *clef_and_key_array, bool first);
double getSystemEnd();
double getSystemStart();
GList *getFirstChordOrRest(int voice_nr, int lyrics_line, bool lyrics_required, bool note_required);
GList *getLastChordOrRest(int voice_nr, int lyrics_line, bool lyrics_required, bool note_required);
void determineTempoInverse(NedChordOrRest *element, unsigned long long till, double *tempoinverse, bool *found);
bool detectVoices(unsigned int *voice_mask, unsigned long long *e_time);
void exportLilyPond(FILE *fp, int voice_nr, int *last_line, unsigned int *midi_len,
bool last_system, unsigned long long end_time, bool *in_alternative, NedSlur **lily_slur, unsigned int *lyrics_map, bool with_break,
bool *guitar_chordnames, bool *chordnames, int *breath_script, bool keep_beams);
void exportLilyGuitarChordnames(FILE *fp, int *last_line, unsigned int *midi_len,
bool last_system, unsigned long long end_time, bool *in_alternative, bool with_break);
void exportLilyFreeChordName(FILE *fp, int *last_line, unsigned int *midi_len,
bool last_system, unsigned long long end_time, bool *in_alternative, bool with_break);
void exportLilyLyrics(FILE *fp, bool last_system, int voice_nr, int line_nr, unsigned long long end_time, int *sil_count);
void collectLyrics(NedLyricsEditor *leditor);
void setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor);
GList *getStaffElements(unsigned long long midi_time);
static const char m_sharpPos[7][7];
static const char m_flatPos[7][7];
private:
GList *m_staffelems;
NedVoice *m_voices[VOICE_COUNT];
double m_ypos;
double m_width;
double m_top_y_border;
int m_lyrics_lines;
double m_bottom_y_border;
int m_staff_number;
int m_clef_type;
int m_clef_octave_shift;
int m_keysig;
bool m_freetexts_or_lyrics_present;
GList *m_volume_changes;
NedSystem *m_system;
};
#endif /* STAFF_H */
nted-1.10.18/system.h 0000664 0010410 0000764 00000023267 11520267230 011241 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SYSTEM_H
#define SYSTEM_H
#include "config.h"
#include
#include
#include "measure.h"
class NedMainWindow;
class NedPage;
class NedStaff;
class NedClipBoard;
class NedCommandList;
class NedChordOrRest;
class NedLyricsEditor;
class NedBbox;
class NedSlur;
class part;
#define MAX_POSITIONS 4096
#define MAX_MEASURES 160
//#define WITH_WEIGHTS
class NedSystem {
public:
NedSystem(NedPage *page, double ypos, double width, int nr, unsigned int start_measure_number, bool start);
~NedSystem();
NedSystem *clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedPage *p_page, bool *staves);
void adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist);
void draw(cairo_t *cr, bool first_page, bool show_measure_numbers, bool *freetexts_or_lyrics_present);
void drawTexts(cairo_t *cr, bool first_page, double scale);
NedMainWindow *getMainWindow();
NedPage *getPage() {return m_page;}
void assignMidiTimes();
void prepareForImport();
void setInternalPitches();
bool testLineOverflow();
void appendElementsOfMeasureLength(part *parts, unsigned int meas_duration, int meas_num);
void copyDataOfWholeStaff(int staff_nr);
void removeLastImported();
bool handleImportedTuplets();
void handleStaffElements();
void transpose(int pitchdist, bool *staff_list, GList *selected_group);
void hideRests(NedCommandList *command_list, bool unhide, int staff_nr, int voice_nr);
bool shiftNotes(unsigned long long start_time, int linedist, int staff_number);
void adjustAccidentals(int staff_nr);
void changeAccidentals(NedCommandList *command_list, int preferred_offs, bool *staff_list, GList *selected_group);
void testBeams(char *s);
void removeUnneededAccidentals(int staff_nr);
bool trySelect (double x, double y, bool only_free_placeables);
NedChordOrRest *findNearestElement(int staff_nr, double x, double y, NedStaff *oldstaff, double *mindist, double *ydist);
NedChordOrRest *getFirstObjectInNextSystem(int staff_nr);
bool tryInsertOrErease (double x, double y, int num_midi_input_notes, int *midi_input_chord /* given if insert from midikeyboard */, NedChordOrRest **newObj, bool force_rest);
bool findLine(double x, double y, double *ypos, int *line, double *bottom, NedStaff **staff);
bool findElement(guint keyval, double x, double y, NedChordOrRest **element, NedStaff **staff);
double getHeight();
double getYPos() {return m_ypos;}
double getBottomPos();
int getSystemNumber() {return m_system_number;}
void setSystemNumber(int number) {m_system_number = number;}
void changePageInfo(NedPage *page) {m_page = page;}
int getNumberOfStaffs();
void appendStaff(NedCommandList *command_list, int p_staff_nr = -1);
void cutEmptyVoices();
void handleEmptyMeasures();
void zoomFreeReplaceables(double zoom, double scale);
void recomputeFreeReplaceables();
void testTies();
void removeLastStaff();
void deleteStaff(int staff_number);
void restoreStaff(int staff_number);
void shiftStaff(int staff_number, unsigned int position);
bool reposit(int measure_number, NedCommandList *command_list = NULL, NedSystem **next_system = NULL);
void computeTuplets();
void resetActiveFlags();
void renumberMeasures(int *measure_number, GList *special_measures, bool force);
void setNewMeasureSpread(double spread);
int getNumberOfFirstMeasure();
int getNumberOfLastMeasure();
unsigned long long getSystemEndTime();
void checkForElementsToSplit(NedCommandList *command_list, int *measure_number);
void collectDestinationVoices(NedClipBoard *board);
bool collectFirstMeasure(NedClipBoard *board, unsigned long long length_of_first_measure, unsigned long long length_of_previous_system);
void findSelectedSystems(NedBbox *sel_rect, int *number_of_first_selected_staff,
int *number_of_last_selected_staff, NedSystem **first_selected_system, NedSystem **last_selected_system);
void collectSelectionRectangleElements(double xp, NedBbox *sel_rect, GList **sel_group,
NedSystem *first_selected_system, NedSystem *last_selected_system, bool is_first_selected_page,
bool is_last_selected_page);
void pasteElements(NedCommandList *command_list, GList **elements, int from_staff, int to_staff, unsigned long long start_midi_time);
bool hasTupletConflict(unsigned int meas_duration, GList **elements, int from_staff, int to_staff, unsigned long long start_midi_time);
bool findFromTo(GList *clipboard, NedSystem **min_sys, NedSystem **max_sys);
bool truncateAtStart(NedCommandList *command_list, unsigned long long midi_time);
bool findStartMeasureLimits(GList *clipboard, unsigned long long *start_midi);
bool findEndMeasureLimits(GList *clipboard, unsigned long long *end_midi);
void deleteItemsFromTo(NedCommandList *command_list, bool is_first, bool is_last, unsigned long long start_midi, unsigned long long end_midi);
void removeNotesFromTo(NedCommandList *command_list, GList *items, bool is_first, bool is_last);
void insertBlocks(NedCommandList *command_list, int blockcount, unsigned long long midi_time);
void testForPageBackwardTies(NedCommandList *command_list);
double computeMidDist(double y);
NedMeasure *getMeasure(unsigned long long midi_time);
NedMeasure *getMeasureNr(int m_number) {return &(m_measures[m_number]);}
NedMeasure *getLastMeasure() {return &(m_measures[m_measure_count]);}
bool findTimeOfMeasure(int meas_num, unsigned long long *meas_time);
int getMeasureCount() {return m_measure_count;}
int getFullMeasureCount() {return m_measure_count + m_special_measure_at_end;}
int getSpecialMeasuresAtEnd() {return m_special_measure_at_end;}
bool tryChangeLength(NedChordOrRest *chord_or_rest);
double placeStaffs(double staffpos);
NedStaff *findStaff(double x, double y, NedMeasure **measure);
void empty();
bool hasOnlyRests();
void shiftY(double offs) {m_ypos += offs;}
void saveSystem(FILE *fp);
void restoreSystem(FILE *fp);
void prepareReplay(bool with_keysig);
unsigned int getWholeMidiLength();
void setWidth(double w);
void do_remove_staff(NedStaff *staff);
void do_append_staff(NedStaff *staff);
void setAndUpdateClefTypeAndKeySig(int *clef_and_key_array, double indent, bool first);
void fill_up(NedCommandList *command_list);
GList *getFirstChordOrRest(int staff_nr, int voice_nr, int lyrics_line, bool lyrics_required, bool note_required);
GList *getLastChordOrRest(int staff_nr, int voice_nr, int lyrics_line, bool lyrics_required, bool note_required);
NedStaff *getStaff(int nr);
void determineTempoInverse(NedChordOrRest *element, unsigned long long till, double *tempoinverse, bool *found);
void detectVoices(int staff_nr, unsigned int *voice_mask, NedSystem **last_system, unsigned long long *end_time);
void exportLilyPond(FILE *fp, int staff_nr, int voice_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, NedSlur **lily_slur,
unsigned int *lyrics_map, bool with_break, bool *guitar_chordnames, bool *chordnames, int *breath_script, bool keep_beams);
void exportLilyGuitarChordnames(FILE *fp, int staff_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, bool with_break);
void exportLilyFreeChordName(FILE *fp, int staff_nr, int *last_line, unsigned int *midi_len,
NedSystem *last_system, unsigned long long end_time, bool *in_alternative, bool with_break);
void exportLilyLyrics(FILE *fp, bool last_system, int staff_nr, int voice_nr, int line_nr, unsigned long long end_time, int *sil_count);
double m_system_start;
void collectLyrics(NedLyricsEditor *leditor, int staff_nr);
void setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor, int staff_nr);
bool m_is_positioned;
private:
void drawBrace (cairo_t *cr, double leftx, double indent, double topy, double zoom_factor, double height, double toppos);
void drawBracket (cairo_t *cr, double leftx, double indent, double topy, double zoom_factor, double height, double toppos);
bool m_tempUntouched;
bool m_check_line_compression;
void do_reposit(bool use_upbeat);
void compute_extra_space(bool use_upbeat);
GList *m_staffs;
GList *m_deleted_staffs;
double m_ypos;
double m_width;
int m_system_number;
bool m_has_repeat_lines;
NedPage *m_page;
NedMeasure m_measures[MAX_MEASURES];
int m_measure_count;
double m_ori,m_netto;
double m_extra_space;
bool m_only_whole_elements;
NedMeasure *m_endMeasure;
bool m_freetexts_or_lyrics_present;
int m_special_measure_at_end; // last "measure" aith only keysig and/or tinmesig ?
};
#endif /* SYSTEM_H */
nted-1.10.18/volumesign.cpp 0000664 0010410 0000764 00000012215 11520267230 012427 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "volumesign.h"
#include "chordorrest.h"
#include "volumedialog.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#define X_POS_PAGE_REL(p) ((m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
NedVolumeSign::NedVolumeSign(int kind) : NedFreeReplaceable(), m_kind(kind) {setMidiVolume();}
NedVolumeSign::NedVolumeSign(int kind, NedChordOrRest *element) : NedFreeReplaceable(element), m_kind(kind) {setMidiVolume();}
NedVolumeSign::NedVolumeSign(int kind, NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative), m_kind(kind) {setMidiVolume();}
void NedVolumeSign::setMidiVolume() {
switch (m_kind) {
case VOL_PPP: m_midi_volume = 18; break;
case VOL_PP: m_midi_volume = 36; break;
case VOL_P: m_midi_volume = 54; break;
case VOL_MP:
case VOL_SP:
case VOL_MF:
case VOL_SF: m_midi_volume = 72; break;
case VOL_F: m_midi_volume = 91; break;
case VOL_FF: m_midi_volume = 108; break;
case VOL_FFF: m_midi_volume = 127; break;
}
}
int NedVolumeSign::determineKind(int volume) {
if (volume <= 18) return VOL_PPP;
if (volume <= 36) return VOL_PP;
if (volume <= 54) return VOL_P;
if (volume <= 72) return VOL_MF;
if (volume <= 91) return VOL_F;
if (volume <= 108) return VOL_FF;
return VOL_FFF;
}
NedFreeReplaceable *NedVolumeSign::clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area /* = NULL */,
NedMainWindow *main_window /* = NULL */) {
NedVolumeSign *newVolSig = new NedVolumeSign(m_kind, newelement, m_x, m_y, true);
return newVolSig;
}
void NedVolumeSign::adjust_pointers(struct addr_ref_str *slurlist) {
}
void NedVolumeSign::startContextDialog(GtkWidget *ref) {
bool state;
int newvolume;
NedVolumeDialog *volume_dialog = new NedVolumeDialog(GTK_WINDOW(ref), m_midi_volume, false);
volume_dialog->getValues(&state, &newvolume);
delete volume_dialog;
if (state) {
m_midi_volume = newvolume;
}
}
void NedVolumeSign::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale) {
if (m_element == NULL) return;
double xpos, ypos;
getXYPos(&xpos, &ypos);
cairo_glyph_t glyph[3];
int len = 0;
double yoffs = 0.0;
#define X_SPACE 0.2
#define FORTE_Y_OFFS 0.05
cairo_new_path(cr);
if (isActive()) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
switch(m_kind) {
case VOL_P:
glyph[0].index = BASE + 40; len = 1; break;
case VOL_PP:
glyph[0].index = glyph[1].index = BASE + 40; len = 2; break;
case VOL_PPP:
glyph[0].index = glyph[1].index = glyph[2].index = BASE + 40; len = 3; break;
case VOL_MF:
glyph[0].index = BASE + 39; glyph[1].index = BASE + 37; len = 2; yoffs = -FORTE_Y_OFFS; break;
case VOL_SF:
glyph[0].index = BASE + 38; glyph[1].index = BASE + 37; len = 2; yoffs = -FORTE_Y_OFFS; break;
case VOL_MP:
glyph[0].index = BASE + 39; glyph[1].index = BASE + 40; len = 2; break;
case VOL_SP:
glyph[0].index = BASE + 38; glyph[1].index = BASE + 40; len = 2; break;
case VOL_F:
glyph[0].index = BASE + 37; len = 1; break;
case VOL_FF:
glyph[0].index = glyph[1].index = BASE + 37; len = 2; break;
case VOL_FFF:
glyph[0].index = glyph[1].index = glyph[2].index = BASE + 37; len = 3; break;
}
glyph[0].y = Y_POS_PAGE_REL(ypos + yoffs); glyph[1].y = glyph[2].y = Y_POS_PAGE_REL(ypos);
for (int i = 0; i < len; i++) {
glyph[i].x = X_POS_PAGE_REL(xpos - (len / 2 - i) * X_SPACE);
}
cairo_show_glyphs(cr, glyph, len);
/*
cairo_move_to(cr, X_POS_PAGE_REL(xpos - 1.0), Y_POS_PAGE_REL(ypos - 1.0)) ;
cairo_line_to(cr, X_POS_PAGE_REL(xpos + 1.0), Y_POS_PAGE_REL(ypos + 1.0)) ;
cairo_move_to(cr, X_POS_PAGE_REL(xpos + 1.0), Y_POS_PAGE_REL(ypos - 1.0)) ;
cairo_line_to(cr, X_POS_PAGE_REL(xpos - 1.0), Y_POS_PAGE_REL(ypos + 1.0)) ;
*/
if (isActive()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
cairo_stroke(cr);
if (m_is_abs) {
drawConnection(cr, xpos, ypos, leftx, topy, zoom_factor);
}
}
nted-1.10.18/voice.cpp 0000664 0010410 0000764 00000430150 11520267230 011346 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "voice.h"
#include "beaming.h"
#include "staff.h"
#include "chordorrest.h"
#include "system.h"
#include "page.h"
#include "resource.h"
#include "system.h"
#include "mainwindow.h"
#include "commandlist.h"
#include "clipboard.h"
#include "beam.h"
#include "tuplet.h"
#include "note.h"
#include "commandhistory.h"
#include "insertchordorrestcommand.h"
#include "ereasechordorrestcommand.h"
#include "changechordorrestlength.h"
#include "addnoteatcommand.h"
#include "deletechordorrestgroupcommand.h"
#include "insertchordorrestgroupcommand.h"
#include "changechordorreststatus.h"
#include "deletechordcommand.h"
#include "changexpositioncommand.h"
#include "inserttiedelementcommand.h"
#include "settotupletcommand.h"
#include "insertstaffelemcommand.h"
#include "musicxmlimport.h"
#include "volumesign.h"
#include "temposign.h"
#include "freesign.h"
#include "slur.h"
#include "slurpoint.h"
#include "linepoint.h"
#include "crescendo.h"
#include "octavation.h"
#include "acceleration.h"
#include "freetext.h"
#include "freechord.h"
#include "freechordname.h"
#include "freespacer.h"
#define DEFAULT_STAFF_DIST (4 * LINE_DIST)
#define X_POS_INVERS_PAGE_REL(p) ((leftx + (p) / current_scale) / zoom_factor - getPage()->getContentXpos())
#define Y_POS_INVERS_STAFF_REL(p) ((topy + (p) / current_scale) / zoom_factor - (getSystem()->getYPos() + getStaff()->getBottomPos()))
#define X_POS_PAGE_REL(p) ((getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_STAFF_REL(p) (((p) + getSystem()->getYPos() + getStaff()->getBottomPos()) * zoom_factor - topy)
#define X_PS_POS(p) ((DEFAULT_BORDER + LEFT_RIGHT_BORDER + (p)) * PS_ZOOM)
#define Y_PS_POS_STAFF_REL(p) ((height - ((p) + getSystem()->getYPos() + getStaff()->getBottomPos())) * PS_ZOOM)
NedVoice::NedVoice(NedStaff *staff, int nr, bool start) :
m_chord_or_rests(NULL), m_beam_list(NULL), m_tuplet_list(NULL), m_voice_nr(nr), m_staff(staff), m_start_of_last_imported(NULL) {
#ifdef XXX
unsigned int rest_time = 0;
int i;
if (start) {
for (i = 0; i < START_MEASURE_COUNT; i++) {
NedChordOrRest *rest = new NedChordOrRest(this, TYPE_REST, nr > 0, 3, 0, WHOLE_NOTE, getMainWindow->getCurrentNoteHead(), 0, rest_time);
m_chord_or_rests = g_list_append(m_chord_or_rests, rest);
rest_time = rest->getStopTime();
}
}
#endif
}
NedVoice *NedVoice::clone(struct addr_ref_str **addrlist, struct addr_ref_str **slurlist, NedStaff *p_staff) {
GList *lptr;
NedVoice *voice = new NedVoice(p_staff, m_voice_nr, false);
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
voice->m_chord_or_rests = g_list_append(voice->m_chord_or_rests, ((NedChordOrRest *) lptr->data)->clone(addrlist, slurlist, voice));
}
return voice;
}
void NedVoice::adjust_pointers(struct addr_ref_str *addrlist, struct addr_ref_str *slurlist) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->adjust_pointers(addrlist, slurlist);
}
}
void NedVoice::appendWholeRest(NedCommandList *command_list) {
NedChordOrRest *rest = new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0);
if (command_list == NULL) {
m_chord_or_rests = g_list_append(m_chord_or_rests, rest);
return;
}
NedInsertChordOrRestCommand *command = new NedInsertChordOrRestCommand(this, -1, rest);
command->resetAdjustable(); // avoid ajjustment to filling wholes if undo/redo
command->execute();
command_list->addCommand(command);
}
void NedVoice::testTies() {
GList *lptr1;
for (lptr1 = g_list_first(m_chord_or_rests); lptr1; lptr1 = g_list_next(lptr1)) {
((NedChordOrRest *) lptr1->data)->testTies();
}
}
void NedVoice::setUpbeatRests(unsigned int upbeat_inverse) {
unsigned int len2;
int dotcount;
NedResource::setLengthField(upbeat_inverse);
len2 = NedResource::getPartLength(&dotcount);
while (len2) {
NedChordOrRest *rest = new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3, dotcount, len2, NORMAL_NOTE, 0, 0);
m_chord_or_rests = g_list_append(m_chord_or_rests, rest);
len2 = NedResource::getPartLength(&dotcount);
}
}
void NedVoice::appendAppropriateWholes(int start_measure) {
int meas_num = getSystem()->getMeasureCount();
for (; start_measure < meas_num; start_measure++) {
NedChordOrRest *rest = new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0);
m_chord_or_rests = g_list_append(m_chord_or_rests, rest);
}
}
int NedVoice::getPosition(NedChordOrRest *chord_or_rest) {
return g_list_index(m_chord_or_rests, chord_or_rest);
}
NedVoice::~NedVoice() {
GList *lptr;
for(lptr = g_list_first(m_beam_list); lptr; lptr = g_list_next(lptr)) {
// important: must be first
delete ((NedBeam *) lptr->data);
}
g_list_free(m_beam_list);
m_beam_list = NULL;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
delete ((NedChordOrRest *) lptr->data);
}
g_list_free(m_chord_or_rests);
m_chord_or_rests = NULL;
}
int NedVoice::getNumElements() {
return g_list_length(m_chord_or_rests);
}
void NedVoice::empty() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
delete (NedChordOrRest *) lptr->data;
}
g_list_free(m_chord_or_rests);
m_chord_or_rests = NULL;
}
NedMainWindow *NedVoice::getMainWindow() {return m_staff->getSystem()->getPage()->getMainWindow();}
NedPage *NedVoice::getPage() {return m_staff->getSystem()->getPage();}
NedSystem *NedVoice::getSystem() {return m_staff->getSystem();}
void NedVoice::draw(cairo_t *cr, bool *freetexts_or_lyrics_present) {
GList *lptr;
m_free_texts_or_lyrics_present = false;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->draw(cr, &m_free_texts_or_lyrics_present);
}
if (m_free_texts_or_lyrics_present) *freetexts_or_lyrics_present = true;
for(lptr = g_list_first(m_beam_list); lptr; lptr = g_list_next(lptr)) {
((NedBeam *) lptr->data)->draw(cr);
}
for(lptr = g_list_first(m_tuplet_list); lptr; lptr = g_list_next(lptr)) {
((NedTuplet *) lptr->data)->draw(cr);
}
/*
if (true || lyrics_present) {
for (lptr = g_list_last(m_chord_or_rests); lptr; lptr = g_list_previous(lptr)) {
((NedChordOrRest *) lptr->data)->drawlyrics(cr, last_left_bbox_edge);
last_left_bbox_edge = ((NedChordOrRest *) lptr->data)->getLeftBboxEdge();
}
}
*/
}
void NedVoice::drawTexts(cairo_t *cr, double scale) {
double last_left_bbox_edge = -1.0;
GList *lptr;
bool last = true;
if (!m_free_texts_or_lyrics_present) return;
for (lptr = g_list_last(m_chord_or_rests); lptr; lptr = g_list_previous(lptr), last = false) {
((NedChordOrRest *) lptr->data)->drawTexts(cr, scale, last_left_bbox_edge, last);
last_left_bbox_edge = ((NedChordOrRest *) lptr->data)->getLeftBboxEdge();
}
}
bool NedVoice::hasOnlyRests() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() != TYPE_REST) return false;
}
return true;
}
bool NedVoice::trySelect(double x, double y, bool only_free_placeables) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->trySelect(x, y, only_free_placeables)) {
return TRUE;
}
}
return FALSE;
}
NedChordOrRest *NedVoice::findNearestElement(double x, double y, double factor, double *mindist, double *ydist) {
GList *lptr;
double dist, yd;
NedChordOrRest *nearestElement = NULL;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->isHidden()) continue;
dist = ((NedChordOrRest *) lptr->data)->computeDistFrom(x, y, factor, &yd);
if (dist < *mindist) {
*mindist = dist;
*ydist = yd < 0 ? -yd : yd;
nearestElement = ((NedChordOrRest *) lptr->data);
}
}
return nearestElement;
}
void NedVoice::appendElementsOfMeasureLength(part *part_ptr, unsigned int meas_duration, int meas_num) {
GList *lptr;
NedChordOrRest *chord_or_rest;
NedBeam *beam;
int pos = 0, dotcount;
unsigned int len2;
bool first = true;
unsigned int duration = 0;
if (part_ptr->eof[m_voice_nr]) {
chord_or_rest = new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0);
m_chord_or_rests = g_list_append(m_chord_or_rests, chord_or_rest);
m_start_of_last_imported = g_list_find(m_chord_or_rests, chord_or_rest);
return;
}
if (part_ptr->start_of_last_taken[m_voice_nr] == NULL) {
lptr = g_list_first(part_ptr->voices[m_voice_nr]);
}
else {
lptr = g_list_next(part_ptr->end_of_last_taken[m_voice_nr]);
}
if (lptr == NULL) {
part_ptr->eof[m_voice_nr] = true;
chord_or_rest = new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0);
m_chord_or_rests = g_list_append(m_chord_or_rests, chord_or_rest);
m_start_of_last_imported = g_list_find(m_chord_or_rests, chord_or_rest);
return;
}
if (m_start_of_last_imported == NULL) {
pos = 0;
}
else {
if ((pos = g_list_position(m_chord_or_rests, m_end_of_last_imported)) < 0) {
NedResource::Abort("NedVoice::appendElementsOfMeasureLength(1)");
}
pos++;
}
for (;duration < meas_duration && lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
m_chord_or_rests = g_list_insert(m_chord_or_rests, chord_or_rest, pos++);
if (first) {
first = false;
if ((m_start_of_last_imported = g_list_nth(m_chord_or_rests, pos - 1)) == NULL) {
NedResource::Abort("NedVoice::appendElementsOfMeasureLength(4)");
}
part_ptr->start_of_last_taken[m_voice_nr] = lptr;
}
part_ptr->end_of_last_taken[m_voice_nr] = lptr;
if ((beam = chord_or_rest->getBeam()) != NULL) {
delete beam; // the beam removes itself from voice and
// sets the beam pointer of all chords to NULL
}
chord_or_rest->setVoice(this);
if ((chord_or_rest->getType() & TYPE_CHORD) != 0) {
chord_or_rest->xPositNotes();
}
chord_or_rest->computeBbox();
if ((chord_or_rest->getType() & (TYPE_CHORD | TYPE_REST)) != 0) {
duration += chord_or_rest->getDuration(meas_duration);
}
chord_or_rest->computeBbox();
chord_or_rest->reConfigure();
}
if (duration > meas_duration) {
NedResource::DbgMsg(DBG_CRITICAL, "Overflow\n");
}
if (duration < meas_duration) {
NedResource::setLengthField(meas_duration - duration);
while ((len2 = NedResource::getPartLength(&dotcount)) > 0) {
m_chord_or_rests = g_list_insert(m_chord_or_rests, new NedChordOrRest(this, TYPE_REST, len2 == WHOLE_NOTE && m_voice_nr > 0, 3,
dotcount, len2, NORMAL_NOTE, 0, 0), pos++);
}
}
if ((m_end_of_last_imported = g_list_nth(m_chord_or_rests, pos - 1)) == NULL) {
NedResource::Abort("NedVoice::appendElementsOfMeasureLength(5)");
}
if (first) {
m_start_of_last_imported = m_end_of_last_imported;
}
}
void NedVoice::copyDataOfWholeVoice() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
NedResource::m_main_clip_board = g_list_append(NedResource::m_main_clip_board, lptr->data);
}
}
void NedVoice::zoomFreeReplaceables(double zoom, double scale) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->zoomFreeReplaceables(zoom, scale);
}
}
void NedVoice::recomputeFreeReplaceables() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->recomputeFreeReplaceables();
}
}
void NedVoice::handleEmptyMeasures() {
NedMeasure *measure = NULL;
GList *lptr, *lptr2, *newmeasure = NULL, *newlist = NULL;
bool only_rests = false;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->m_measure != measure) {
if (only_rests) {
newlist = g_list_append(newlist, new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3 /* dummy */, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0 /* dummy */));
}
else {
for (lptr2 = g_list_first(newmeasure); lptr2; lptr2 = g_list_next(lptr2)) {
newlist = g_list_append(newlist, lptr2->data);
}
}
g_list_free(newmeasure);
newmeasure = NULL;
only_rests = true;
measure = ((NedChordOrRest *) lptr->data)->m_measure;
}
if (((NedChordOrRest *) lptr->data)->getType() != TYPE_REST) only_rests = false;
newmeasure = g_list_append(newmeasure, lptr->data);
}
if (only_rests) {
newlist = g_list_append(newlist, new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3 /* dummy */, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0 /* dummy */));
}
else {
for (lptr2 = g_list_first(newmeasure); lptr2; lptr2 = g_list_next(lptr2)) {
newlist = g_list_append(newlist, lptr2->data);
}
}
g_list_free(newmeasure);
g_list_free(m_chord_or_rests);
m_chord_or_rests = newlist;
assignMidiTimes();
}
void NedVoice::removeLastImported() {
GList *lptr;
GList *dellist = NULL;
NedResource::DbgMsg(DBG_TESTING, "removeLastImported\n");
if (m_start_of_last_imported == NULL) {
NedResource::DbgMsg(DBG_CRITICAL, "staff = %d, voi = %d\n", m_staff->getStaffNumber(), m_voice_nr);
NedResource::Abort("NedVoice::removeLastImported");
}
for (lptr = m_start_of_last_imported; lptr; lptr = g_list_next(lptr)) {
dellist = g_list_append(dellist, lptr->data);
}
for (lptr = g_list_first(dellist); lptr; lptr = g_list_next(lptr)) {
m_chord_or_rests = g_list_remove(m_chord_or_rests, lptr->data);
}
g_list_free(dellist);
}
bool NedVoice::handleImportedTuplets() {
GList *lptr;
unsigned int duration = 0;
NedChordOrRest *chord_or_rest, *last_tupletted_chord_or_rest = NULL;
int tupletval = -1, tupval;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
tupval = chord_or_rest->getTupletVal();
if (tupval != 0) {
duration += chord_or_rest->getDuration();
if (tupval != 0) {
if (tupletval < 0) {
tupletval = tupval;
}
else if (tupletval != tupval) {
return false;
}
if (NedResource::fittingDuration(duration)) {
chord_or_rest->setLastTupletFlag(true);
duration = 0;
tupletval = -1;
}
last_tupletted_chord_or_rest = chord_or_rest;
}
}
else if (tupletval > 0) {
if (!NedResource::fittingDuration(duration)) {NedResource::DbgMsg(DBG_TESTING, "Stelle 1: tupletval = %d, duration = %u NOTE_4 = %u\n", tupletval, duration, NOTE_4); return false;}
last_tupletted_chord_or_rest->setLastTupletFlag(true);
tupletval = -1;
duration = 0;
last_tupletted_chord_or_rest = NULL;
}
}
if (tupletval > 0) {
if (!NedResource::fittingDuration(duration)) {NedResource::DbgMsg(DBG_TESTING, "Stelle 2: duration = %u NOTE_4 = %u\n", duration, NOTE_4); return false;}
last_tupletted_chord_or_rest->setLastTupletFlag(true);
}
return true;
}
bool NedVoice::truncateAtStart(NedCommandList *command_list, unsigned long long midi_time) {
unsigned int duration = 0;
GList *list_of_elems_to_delete = NULL;
NedDeleteChordOrRestGroupCommand *del_cmd;
GList *lptr;
NedChordOrRest *element;
int pos;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
if ((element->getType() & (TYPE_CHORD | TYPE_REST)) == 0) continue;
if (element->getTupletVal() != 0) return false;
duration += element->getDuration();
list_of_elems_to_delete = g_list_append(list_of_elems_to_delete, element);
if (duration >= midi_time) {
element->testForTiesToDelete(command_list, BREAK_TIE_FORWARD);
del_cmd = new NedDeleteChordOrRestGroupCommand(this, list_of_elems_to_delete);
command_list->addCommand(del_cmd);
pos = 0;
if (duration > midi_time) {
handleGapAfterInsertion(command_list, &pos, duration - midi_time, element, 0, false, false);
}
return true;
}
}
return false;
}
void NedVoice::determineTempoInverse(NedChordOrRest *element, unsigned long long till, double *tempoinverse, bool *found) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data) == element) {
*found = true;
return;
}
if (element && ((NedChordOrRest *) lptr->data)->getMidiTime() >= till) {
return;
}
((NedChordOrRest *) lptr->data)->determineTempoInverse(tempoinverse);
}
}
void NedVoice::handleStaffElements() {
GList *lptr, *lptr2;
GList *del_objs = NULL;
NedChordOrRest *chord_or_rest;
assignMidiTimes();
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
switch (chord_or_rest->getType()) {
case TYPE_CLEF:
case TYPE_STAFF_SIGN:
case TYPE_KEYSIG: m_staff->insertStaffElement(chord_or_rest, false);
//m_chord_or_rests = g_list_delete_link(m_chord_or_rests, lptr);
//changed = true;
del_objs = g_list_append(del_objs, chord_or_rest);
break;
}
}
for (lptr = g_list_first(del_objs); lptr; lptr = g_list_next(lptr)) {
if ((lptr2 = g_list_find(m_chord_or_rests, lptr->data)) == NULL) {
NedResource::Abort("NedVoice::handleStaffElements");
}
m_chord_or_rests = g_list_delete_link(m_chord_or_rests, lptr2);
}
g_list_free(del_objs);
}
bool NedVoice::tryInsertOrErease(double x, double y, int num_midi_input_notes, int *midi_input_chord /* given if insert from midikeyboard */, NedChordOrRest **newObj, bool force_rest) {
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
int i, npitch;
GList *lptr, *lptr2;
NedChordOrRest *chord;
NedChordOrRest *last_tupleted_chord_or_rest;
NedTuplet *tuplet_ptr;
bool removed = FALSE;
staff_context_str *context;
int tuplet_val, tuplet_val_raw;
int line = 0;
NedChordOrRest *chord_or_rest = NULL;
unsigned long long end_time;
unsigned long long new_chords_midi_end_time;
char offs_array[115];
if (NedResource::getCurrentLength() < NOTE_64 && getMainWindow()->getSpecialType() < 0) {
return insertGrace(x, y, midi_input_chord != NULL ? *midi_input_chord : -1);
}
if (midi_input_chord == NULL) { // line given
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord = (NedChordOrRest *) lptr->data;
if (chord->tryErease(x, y, &removed)) {
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
chord->testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
command_list->addCommand(new NedDeleteChordCommand(chord));
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
return TRUE;
}
if (removed) {
return TRUE;
}
}
}
double current_scale = getMainWindow()->getCurrentScale();
if (midi_input_chord == NULL) { // line given
double yl = Y_POS_INVERS_STAFF_REL(y);
if (MAX_OVER_UNDER_LINES * LINE_DIST/2.0 < yl || -((MAX_OVER_UNDER_LINES + 8) * LINE_DIST/2.0) > yl) return FALSE;
double yoffs = (yl >= 0.0) ? LINE_DIST / 4.0 : -LINE_DIST / 4.0;
line = (int) ((- yl - yoffs) / (LINE_DIST/2.0));
}
double leftx = getMainWindow()->getLeftX();
double xl = X_POS_INVERS_PAGE_REL(x);
double min = 1000000.0;
double diff;
unsigned int v, sv, state;
int minpos = -1;
unsigned long long offs;
int half_offset;
int num_elements_to_delete = 1;
int clef = TREBLE_CLEF, keysig_so_far, octave_shift;
bool greater_than_last;
GList *min_pos_ptr = NULL;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
diff = ((NedChordOrRest *) lptr->data)->getXPos() - xl;
if (diff < 0) diff = -diff;
if (diff < min) {
min = diff;
min_pos_ptr = lptr;
minpos = g_list_position(m_chord_or_rests, lptr);
}
}
if (minpos < 0) {
return FALSE;
}
state = NedResource::getStatus();
if (midi_input_chord != NULL) { // pitch given
m_staff->getCurrentClefAndKeysig(((NedChordOrRest *) min_pos_ptr->data)->getMidiTime(),
&clef, &keysig_so_far, &octave_shift);
line = NedNote::pitchToLine(*midi_input_chord, clef, keysig_so_far, octave_shift, &half_offset);
memset(offs_array, 0, sizeof(offs_array));
findAccidentals(offs_array, ((NedChordOrRest *) min_pos_ptr->data)->m_measure, ((NedChordOrRest *) min_pos_ptr->data)->getMidiTime(), false);
state &= (~(ACCIDENTAL_MASK));
state |= (NedNote::determineState(*midi_input_chord, line, half_offset, offs_array, keysig_so_far) & ACCIDENTAL_MASK);
}
else {
state = NedResource::getStatus();
}
tuplet_val = ((NedChordOrRest *) min_pos_ptr->data)->getTupletVal();
tuplet_val_raw = ((NedChordOrRest *) min_pos_ptr->data)->getTupletValRaw();
if (getMainWindow()->getSpecialType() < 0 && !((NedChordOrRest *) min_pos_ptr->data)->isRest() && !(NedResource::getRestMode() || force_rest)) {
if (((NedChordOrRest *) min_pos_ptr->data)->noConflict(line)) {
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
NedAddNoteAtCommand *add_note_at_command = new NedAddNoteAtCommand(this, ((NedChordOrRest *) min_pos_ptr->data), line, NedResource::getCurrentNoteHead(), state);
command_list->addCommand(add_note_at_command);
getMainWindow()->getCommandHistory()->addCommandList(command_list);
getMainWindow()->setSelected((NedChordOrRest *) min_pos_ptr->data, add_note_at_command->getNote());
command_list->execute();
return TRUE;
}
return FALSE;
}
/*
if (((NedChordOrRest *) min_pos_ptr->data)->isRest() && (((NedChordOrRest *) min_pos_ptr->data)->isHidden())) {
return FALSE;
}
*/
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
if (midi_input_chord == NULL && getMainWindow()->getSpecialType() >= 0) {
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getXPos() > xl) break;
}
if (lptr) {
greater_than_last = false;
if (lptr == g_list_first(m_chord_or_rests)) { // avoid inserting clefs and keys at begin of staff
getMainWindow()->resetSpecialType();
return TRUE;
}
}
else { // behind last element
lptr = g_list_last(m_chord_or_rests);
greater_than_last = true;
}
switch (getMainWindow()->getSpecialType() & 0xffff) {
case TYPE_CLEF:
getStaff()->getCurrentClefAndKeysig(((NedChordOrRest *) lptr->data)->getMidiTime(), &clef, &keysig_so_far, &octave_shift);
v = getMainWindow()->getSpecialSubTypeInt();
sv = (v >> 16) & 0xffff;
sv -= 100;
chord_or_rest = new NedChordOrRest(this, getMainWindow()->getSpecialType() & 0xffff, v & 0xffff,
sv, greater_than_last ? ((NedChordOrRest *) lptr->data)->getMidiTime() + ((NedChordOrRest *) lptr->data)->getDuration() :
((NedChordOrRest *) lptr->data)->getMidiTime(), true);
break;
case TYPE_KEYSIG:
getStaff()->getCurrentClefAndKeysig(((NedChordOrRest *) lptr->data)->getMidiTime(), &clef, &keysig_so_far, &octave_shift);
if (keysig_so_far == getMainWindow()->getSpecialSubTypeInt()) {
getMainWindow()->resetSpecialType();
return TRUE;
}
chord_or_rest = new NedChordOrRest(this, getMainWindow()->getSpecialType() & 0xffff, getMainWindow()->getSpecialSubTypeInt(),
keysig_so_far, greater_than_last ? ((NedChordOrRest *) lptr->data)->getMidiTime() + ((NedChordOrRest *) lptr->data)->getDuration() :
((NedChordOrRest *) lptr->data)->getMidiTime());
break;
case TYPE_STAFF_SIGN:
chord_or_rest = new NedChordOrRest(this, getMainWindow()->getSpecialType() & 0xffff, getMainWindow()->getSpecialSubTypeInt(),
greater_than_last ? ((NedChordOrRest *) lptr->data)->getMidiTime() + ((NedChordOrRest *) lptr->data)->getDuration() :
((NedChordOrRest *) lptr->data)->getMidiTime());
break;
}
NedInsertStaffElemCommand *ins_staff_elem_cmd = new NedInsertStaffElemCommand(chord_or_rest, clef, octave_shift, m_staff,
getMainWindow()->getDoAdjust());
getMainWindow()->resetSpecialType();
ins_staff_elem_cmd->execute();
command_list->setFullReposit();
command_list->addCommand(ins_staff_elem_cmd);
getMainWindow()->setAllUnpositioned();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
getMainWindow()->reposit(command_list);
return TRUE;
}
else {
chord_or_rest = new NedChordOrRest(this, (midi_input_chord == NULL && (NedResource::getRestMode() || force_rest)) ? TYPE_REST : TYPE_CHORD, FALSE, line,
NedResource::getDotCount(), NedResource::getCurrentLength(), NedResource::getCurrentNoteHead(), state, 0);
chord_or_rest->setTupletVal(tuplet_val);
if (newObj != NULL) {
*newObj = chord_or_rest;
}
if (midi_input_chord != NULL && num_midi_input_notes > 1) {
for (i = 1; i < num_midi_input_notes; i++) {
state = NedResource::getStatus();
state &= (~(ACCIDENTAL_MASK));
line = NedNote::pitchToLine(midi_input_chord[i], clef, keysig_so_far, octave_shift, &half_offset);
state |= (NedNote::determineState(midi_input_chord[i], line, half_offset, offs_array, keysig_so_far) & ACCIDENTAL_MASK);
NedNote *note = new NedNote(chord_or_rest, line, NedResource::getCurrentNoteHead(), state);
chord_or_rest->insertNoteAt(note);
}
chord_or_rest->xPositNotes();
chord_or_rest->computeBbox();
}
}
if (!chord_or_rest->isRest()) {
getMainWindow()->setSelected(chord_or_rest, chord_or_rest->getFirstNote());
}
unsigned long long min_pos_midi_time = ((NedChordOrRest *) min_pos_ptr->data)->getMidiTime();
if ((tuplet_ptr = ((NedChordOrRest *) min_pos_ptr->data)->getTupletPtr()) != NULL) {
end_time = tuplet_ptr->getEndTime();
}
else {
//NedMeasure *measure = getSystem()->getMeasure(((NedChordOrRest *) min_pos_ptr->data)->getMidiTime());
NedMeasure *measure = ((NedChordOrRest *) min_pos_ptr->data)->m_measure;
end_time = measure->midi_end;
testForTupletEnd(min_pos_midi_time, chord_or_rest->getDuration(), &end_time);
}
new_chords_midi_end_time = min_pos_midi_time + chord_or_rest->getDuration();
if (end_time > new_chords_midi_end_time) end_time = new_chords_midi_end_time;
unsigned long long sum_of_chords_and_rests_to_delete = 0;
GList *chords_and_rests_to_delete = NULL;
GList *already_deleted_free_repleceables = NULL;
for (lptr2 = min_pos_ptr; lptr2 && ((NedChordOrRest *) lptr2->data)->getMidiTime() < end_time;
lptr2 = g_list_next(lptr2)) {
chords_and_rests_to_delete = g_list_append(chords_and_rests_to_delete, lptr2->data);
if (g_list_find(already_deleted_free_repleceables, lptr2->data) == NULL) {
((NedChordOrRest *) lptr2->data)->testForFreeReplaceablesToDelete(command_list, &already_deleted_free_repleceables);
}
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD);
sum_of_chords_and_rests_to_delete += ((NedChordOrRest *) lptr2->data)->getDuration();
}
g_list_free(already_deleted_free_repleceables);
if (sum_of_chords_and_rests_to_delete < chord_or_rest->getDuration()) {
chord_or_rest->changeDuration(sum_of_chords_and_rests_to_delete, tuplet_val);
}
if (tuplet_ptr != NULL) {
if (tuplet_ptr->getMidiStartTime() == min_pos_midi_time && chord_or_rest->getDuration() == tuplet_ptr->getDuration()) {
delete command_list;
return FALSE;
}
}
sum_of_chords_and_rests_to_delete -= chord_or_rest->getDuration();
if (chords_and_rests_to_delete != NULL) {
command_list->addCommand(new NedDeleteChordOrRestGroupCommand(this, chords_and_rests_to_delete));
num_elements_to_delete = g_list_length(chords_and_rests_to_delete);
}
command_list->addCommand(new NedInsertChordOrRestCommand(this, minpos++, chord_or_rest));
last_tupleted_chord_or_rest = chord_or_rest;
offs = ((NedChordOrRest *) min_pos_ptr->data)->getMidiTime() - (((NedChordOrRest *) min_pos_ptr->data)->m_measure)->midi_start +
chord_or_rest->getDuration();
if (sum_of_chords_and_rests_to_delete > 0) {
NedChordOrRest *chord_or_rest_to_distribute = (NedChordOrRest *) (g_list_last(chords_and_rests_to_delete)->data);
last_tupleted_chord_or_rest = handleGapAfterInsertion2(command_list, offs, &minpos, sum_of_chords_and_rests_to_delete, chord_or_rest_to_distribute, tuplet_val, false, false);
}
if (tuplet_val_raw & LAST_TUPLET_FLAG) {
last_tupleted_chord_or_rest->setLastTupletFlag(TRUE);
}
getMainWindow()->getCommandHistory()->addCommandList(command_list);
command_list->execute();
getMainWindow()->reposit(command_list, getPage(), getSystem());
context = &(getMainWindow()->m_staff_contexts[getStaff()->getStaffNumber()]);
if (midi_input_chord == NULL /* otherwise done in main */ && !chord_or_rest->isRest() && NedResource::m_midi_echo) {
npitch = chord_or_rest->getPitchOfFirstNote();
NedResource::playImmediately(context->m_midi_channel, context->voices[0].m_midi_program, 1, &npitch, context->voices[0].m_midi_volume);
}
return TRUE;
}
bool NedVoice::insertGrace(double x, double y, int pitch /* given if insert from midikeyboard */) {
GList *lptr;
NedChordOrRest *chord_or_rest;
int line = 0;
int clef = TREBLE_CLEF, keysig_so_far, octave_shift;
int half_offset;
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
double current_scale = getMainWindow()->getCurrentScale();
if (pitch < 0) { // line given
double yl = Y_POS_INVERS_STAFF_REL(y);
if (MAX_OVER_UNDER_LINES * LINE_DIST/2.0 < yl || -((MAX_OVER_UNDER_LINES + 8) * LINE_DIST/2.0) > yl) return FALSE;
line = (int) ((- yl) / (LINE_DIST/2.0) + 0.5);
}
double leftx = getMainWindow()->getLeftX();
double xl = X_POS_INVERS_PAGE_REL(x);
int minpos = -1;
GList *min_pos_ptr = NULL;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getXPos() < xl) continue;
min_pos_ptr = lptr;
minpos = g_list_position(m_chord_or_rests, lptr);
break;
}
if (minpos < 0) {
return FALSE;
}
if (pitch >= 0) { // pitch given
m_staff->getCurrentClefAndKeysig(((NedChordOrRest *) min_pos_ptr->data)->getMidiTime(), &clef, &keysig_so_far, &octave_shift);
line = NedNote::pitchToLine(pitch, clef, keysig_so_far, octave_shift, &half_offset);
}
chord_or_rest = new NedChordOrRest(this, TYPE_CHORD, FALSE, line,
0, NedResource::getCurrentLength(), NORMAL_NOTE, 0, 0);
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
command_list->addCommand(new NedInsertChordOrRestCommand(this, minpos, chord_or_rest));
getMainWindow()->getCommandHistory()->addCommandList(command_list);
getSystem()->m_is_positioned = false;
command_list->execute();
getMainWindow()->reposit(command_list, getPage(), getSystem());
getSystem()->m_is_positioned = false;
return TRUE;
}
void NedVoice::collectSelectionRectangleElements(double xp, double yp, NedBbox *sel_rect, GList **sel_group,
bool is_first_selected, bool is_last_selected) {
GList *lptr;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (is_first_selected && ((NedChordOrRest *) lptr->data)->getXPos() < xp) continue;
if (is_last_selected && ((NedChordOrRest *) lptr->data)->getXPos() > xp + sel_rect->width) continue;
*sel_group = g_list_append(*sel_group, lptr->data);
}
}
bool NedVoice::hasTupletConflict(unsigned int meas_duration, GList **elements, int from_staff, unsigned int long long midi_time) {
GList *lptr, *lptr2;
GList *tested_elements = NULL;
NedChordOrRest *element;
NedTuplet *tuplet;
unsigned long long current_midi_time;
for (lptr2 = g_list_first(m_chord_or_rests); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getMidiTime() >= midi_time) {
break;
}
}
if (lptr2 == NULL) return FALSE;
current_midi_time = ((NedChordOrRest *) lptr2->data)->getMidiTime();
for (lptr = g_list_first(*elements); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
if (element->getStaff()->getStaffNumber() != from_staff) continue;
if (element->getVoice()->m_voice_nr != m_voice_nr) continue;
tested_elements = g_list_append(tested_elements, element);
current_midi_time += element->getDuration();
if (element->getTupletVal() != 0) {
if ((tuplet = element->getTupletPtr()) == NULL) {
NedResource::Abort("NedVoice::hasTupletConflict(1)");
}
if (element->hasLastTupletFlag()) {
/* -1 is very tricky but if it ends exactly at next measure it still belongs to this measure */
if ((current_midi_time - tuplet->getDuration()) / meas_duration != (current_midi_time - 1) / meas_duration) {
/*
NedResource::DbgMsg(DBG_TESTING, "current_midi_time = %llu, tuplet->getDuration() = %u, diff = %llu, meas_duration = %u, current_midi_time = %llu, d1 = %llu, f2 = %llu\n",
current_midi_time, tuplet->getDuration(), current_midi_time - tuplet->getDuration(), meas_duration, current_midi_time,
(current_midi_time - tuplet->getDuration()) / meas_duration, current_midi_time / meas_duration);
*/
return TRUE;
}
}
}
}
for (lptr = g_list_first(tested_elements); lptr; lptr = g_list_next(lptr)) {
if ((lptr2 = g_list_find(*elements, lptr->data)) == NULL) {
NedResource::Abort("NedVoice::hasTupletConflict(2)");
}
*elements = g_list_delete_link(*elements, lptr2);
}
g_list_free(tested_elements);
return FALSE;
}
void NedVoice::pasteElements(NedCommandList *command_list, GList **elements, int from_staff, unsigned int long long midi_time) {
GList *lptr, *lptr2;
GList *copied_elements = NULL;
GList *chordsorrests_to_delete = NULL;
GList *chordsorrests_to_insert = NULL;
NedChordOrRest *element;
int idx, diff, pos;
unsigned long long duration = 0, deleted_duration;
unsigned long long current_midi_time;
unsigned int last_duration = 0, first_duration = -1;
for (lptr = g_list_first(*elements); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
if (element->getStaff()->getStaffNumber() != from_staff) continue;
if (element->getVoice()->m_voice_nr != m_voice_nr) continue;
last_duration = element->getDuration();
if (first_duration < 0) {
first_duration = element->getDuration();
}
duration += last_duration;
}
do {
for (lptr2 = g_list_first(m_chord_or_rests); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getMidiTime() >= midi_time) {
break;
}
}
if (lptr2 == NULL || duration == 0) return;
if ((idx = g_list_position(m_chord_or_rests, lptr2)) < 0) {
NedResource::Abort("NedVoice::pasteElements(1)");
}
element = (NedChordOrRest *) lptr2->data;
}
while (searchForBreakableTuplet(command_list, element->getMidiTime()));
searchForBreakableTies(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD, element->getMidiTime(), element->getMidiTime() + element->getDuration());
current_midi_time = ((NedChordOrRest *) lptr2->data)->getMidiTime();
searchForBreakableTuplet(command_list, current_midi_time + duration);
searchForBreakableTies(command_list, BREAK_TIE_FORWARD | BREAK_TIE_BACKWARD, current_midi_time + duration - last_duration, current_midi_time + duration);
assignMidiTimes(); // recompute midi times
for (lptr2 = g_list_first(m_chord_or_rests); lptr2; lptr2 = g_list_next(lptr2)) { // test again with removed tuplets
if (((NedChordOrRest *) lptr2->data)->getMidiTime() >= midi_time) {
if (((NedChordOrRest *) lptr2->data)->getMidiTime() > midi_time) {
if ((lptr2 = g_list_previous(lptr2)) == NULL) {
NedResource::Abort("NedVoice::pasteElements(2)");
}
if ((pos = g_list_position(m_chord_or_rests, lptr2)) < 0) {
NedResource::Abort("NedVoice::pasteElements(3)");
}
NedChordOrRest *chord_or_rest = ((NedChordOrRest *) lptr2->data);
int duration = chord_or_rest->getDuration();
unsigned long long start_midi_time = chord_or_rest->getMidiTime();
GList *list = NULL;
list = g_list_append(list, chord_or_rest);
NedDeleteChordOrRestGroupCommand *delete_chord_command = new NedDeleteChordOrRestGroupCommand(this, list);
delete_chord_command->execute();
int dur1 = midi_time - start_midi_time;
command_list->addCommand(delete_chord_command);
handleGapAfterInsertion(command_list, &pos, dur1, chord_or_rest, 0 , false, true);
int dur2 = duration - dur1;
handleGapAfterInsertion(command_list, &pos, dur2, NULL, 0, false, true);
command_list->setBreak();
idx = pos;
if ((lptr2 = g_list_nth(m_chord_or_rests, idx)) == NULL) {
NedResource::Abort("NedVoice::pasteElements(4)");
}
assignMidiTimes(); // recompute midi times
current_midi_time = ((NedChordOrRest *) lptr2->data)->getMidiTime();
}
break;
}
}
deleted_duration = 0;
while (deleted_duration < duration && lptr2) {
deleted_duration += ((NedChordOrRest *) lptr2->data)->getDuration();
chordsorrests_to_delete = g_list_append(chordsorrests_to_delete, lptr2->data);
lptr2 = g_list_next(lptr2);
}
diff = deleted_duration - duration;
for (lptr = g_list_first(*elements); deleted_duration > 0 && lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
if (element->getStaff()->getStaffNumber() != from_staff) continue;
if (element->getVoice()->m_voice_nr != m_voice_nr) continue;
unsigned long long midi_end_time = current_midi_time + element->getDuration();
NedMeasure *measure = getSystem()->getMeasure(current_midi_time);
if (current_midi_time < measure->midi_end && midi_end_time > measure->midi_end) {
unsigned long long t1, t2;
t1 = measure->midi_end - current_midi_time; t2 = midi_end_time - measure->midi_end;
NedResource::split_element(elements, lptr, t1, t2);
current_midi_time += t1;
}
else {
current_midi_time = midi_end_time;
}
deleted_duration -= element->getDuration();
chordsorrests_to_insert = g_list_append(chordsorrests_to_insert, element);
copied_elements = g_list_append(copied_elements, element);
}
NedDeleteChordOrRestGroupCommand *delete_command = new NedDeleteChordOrRestGroupCommand(this, chordsorrests_to_delete);
delete_command->execute();
command_list->addCommand(delete_command);
NedInsertChordOrRestGroupCommand *insert_command = new NedInsertChordOrRestGroupCommand(this, chordsorrests_to_insert, idx);
insert_command->execute();
command_list->addCommandAndSetBreak(insert_command);
if (diff > 0) {
NedChordOrRest *chord_or_rest_to_distribute = (NedChordOrRest *) g_list_last(chordsorrests_to_delete)->data;
if ((pos = g_list_index(m_chord_or_rests, g_list_last(chordsorrests_to_insert)->data)) < 0) {
NedResource::Abort("NedVoice::pasteElements(8)");
}
pos++;
handleGapAfterInsertion(command_list, &pos, diff, chord_or_rest_to_distribute, 0, false, true);
}
for (lptr = g_list_first(copied_elements); lptr; lptr = g_list_next(lptr)) {
if ((lptr2 = g_list_find(*elements, lptr->data)) == NULL) {
NedResource::Abort("NedVoice::pasteElements(9)");
}
*elements = g_list_delete_link(*elements, lptr2);
}
g_list_free(copied_elements);
assignMidiTimes();
}
bool NedVoice::findFromTo(GList *clipboard) {
GList *lptr;
NedSystem *the_system = getSystem();
NedPage *the_page = getPage();
for (lptr = g_list_first(clipboard); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getPage() != the_page) continue;
if (((NedChordOrRest *) lptr->data)->getSystem() != the_system) continue;
if (((NedChordOrRest *) lptr->data)->getStaff() != m_staff) continue;
if (((NedChordOrRest *) lptr->data)->getVoice() != this) continue;
return TRUE;
}
return FALSE;
}
bool NedVoice::findStartMeasureLimits(GList *clipboard, unsigned long long *start_midi) {
GList *start_ptr;
NedChordOrRest *element;
NedSystem *the_system = getSystem();
NedPage *the_page = getPage();
NedMeasure *measure;
for (start_ptr = g_list_first(clipboard); start_ptr; start_ptr = g_list_next(start_ptr)) {
element = (NedChordOrRest *) start_ptr->data;
if (element->isRest() && element->isHidden()) continue;
if (element->getPage() != the_page) continue;
if (element->getSystem() != the_system) continue;
if (element->getStaff() != m_staff) continue;
if (element->getVoice() != this) continue;
//measure = getSystem()->getMeasure(element->getMidiTime());
measure = element->m_measure;
if (element->getMidiTime() != measure->midi_start) continue;
if (*start_midi > element->getMidiTime()) {
*start_midi = element->getMidiTime();
return TRUE;
}
}
return FALSE;
}
bool NedVoice::findEndMeasureLimits(GList *clipboard, unsigned long long *end_midi) {
GList *end_ptr = NULL;
NedChordOrRest *element;
NedSystem *the_system = getSystem();
NedPage *the_page = getPage();
NedMeasure *measure;
for (end_ptr = g_list_last(clipboard); end_ptr; end_ptr = g_list_previous(end_ptr)) {
element = (NedChordOrRest *) end_ptr->data;
if (element->isRest() && element->isHidden()) continue;
if (element->getPage() != the_page) continue;
if (element->getSystem() != the_system) continue;
if (element->getStaff() != m_staff) continue;
if (element->getVoice() != this) continue;
//measure = getSystem()->getMeasure(element->getMidiTime());
measure = element->m_measure;
if (element->getMidiTime() + element->getDuration() != measure->midi_end) continue;
if (*end_midi < measure->midi_end) {
*end_midi = measure->midi_end;
return TRUE;
}
}
return FALSE;
}
void NedVoice::deleteItemsFromTo(NedCommandList *command_list, bool is_first, bool is_last, unsigned long long start_midi, unsigned long long end_midi) {
GList *elements_to_delete = NULL;
GList *start_ptr, *end_ptr = NULL;
NedChordOrRest *element;
start_ptr = g_list_first(m_chord_or_rests);
if (is_first) {
for (; start_ptr; start_ptr = g_list_next(start_ptr)) {
if (((NedChordOrRest *) start_ptr->data)->getMidiTime() < start_midi) continue;
break;
}
}
if (start_ptr == NULL) return;
if (is_last) {
for (end_ptr = g_list_last(m_chord_or_rests); end_ptr; end_ptr = g_list_previous(end_ptr)) {
element = (NedChordOrRest *) end_ptr->data;
if (element->getMidiTime() + element->getDuration() > end_midi) continue;
break;
}
}
if (end_ptr == NULL) return;
for (; start_ptr; start_ptr = g_list_next(start_ptr)) {
elements_to_delete = g_list_append(elements_to_delete, start_ptr->data);
if (start_ptr == end_ptr) break;
}
if (g_list_length(elements_to_delete) > 0) {
((NedChordOrRest *) g_list_first(elements_to_delete)->data)->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD, true);
((NedChordOrRest *) g_list_last(elements_to_delete)->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD, true);
NedDeleteChordOrRestGroupCommand *delete_cmd = new NedDeleteChordOrRestGroupCommand(this, elements_to_delete);
delete_cmd->execute();
command_list->addCommand(delete_cmd);
}
}
void NedVoice::removeNotesFromTo(NedCommandList *command_list, GList *items, bool is_first, bool is_last) {
GList *elements_to_delete = NULL;
GList *all_elements_to_delete = NULL;
GList *start_ptr, *end_ptr = NULL;
NedChordOrRest *element, *start_element;
NedSystem *the_system = getSystem();
NedPage *the_page = getPage();
int pos;
unsigned int duration;
NedDeleteChordOrRestGroupCommand *command;
NedMeasure *measure = NULL;
bool only_rests = true;
bool measure_start_seen = false;
start_ptr = g_list_first(items);
if (is_first) {
for (start_ptr = g_list_first(items); start_ptr; start_ptr = g_list_next(start_ptr)) {
element = (NedChordOrRest *) start_ptr->data;
if (element->isRest() && element->isHidden()) continue;
if (element->getPage() != the_page) continue;
if (element->getSystem() != the_system) continue;
if (element->getStaff() != m_staff) continue;
if (element->getVoice() != this) continue;
break;
}
}
if (start_ptr == NULL) return;
if (is_last) {
for (end_ptr = g_list_last(items); end_ptr; end_ptr = g_list_previous(end_ptr)) {
element = (NedChordOrRest *) end_ptr->data;
if (element->isRest() && element->isHidden()) continue;
if (element->getPage() != the_page) continue;
if (element->getSystem() != the_system) continue;
if (element->getStaff() != m_staff) continue;
if (element->getVoice() != this) continue;
break;
}
if (end_ptr == NULL) return;
}
duration = 0;
/*
//measure = getSystem()->getMeasure(((NedChordOrRest *) start_ptr->data)->getMidiTime());
measure = ((NedChordOrRest *) start_ptr->data)->m_measure;
if (((NedChordOrRest *) start_ptr->data)->getMidiTime() == measure->midi_start) {
measure_start_seen = true;
}
*/
for (;start_ptr; start_ptr = g_list_next(start_ptr)) {
element = (NedChordOrRest *) start_ptr->data;
if (element->isRest() && element->isHidden()) continue;
if (element->getPage() != the_page) continue;
if (element->getSystem() != the_system) continue;
if (element->getStaff() != m_staff) continue;
if (element->getVoice() != this) continue;
if (!element->isRest()) only_rests = false;
//measure = getSystem()->getMeasure(element->getMidiTime());
measure = element->m_measure;
if (element->getMidiTime() == measure->midi_start) {
if (g_list_length(elements_to_delete) > 0) {
if ((pos = g_list_index(m_chord_or_rests, g_list_first(elements_to_delete)->data)) < 0) {
NedResource::Abort("NedVoice::removeNotesFromTo(1)");
}
command = new NedDeleteChordOrRestGroupCommand(this, elements_to_delete);
command->execute();
command_list->addCommand(command);
handleGapAfterInsertion(command_list, &pos, duration, NULL, 0, measure_start_seen, true);
}
elements_to_delete = NULL;
duration = 0;
measure_start_seen = true;
}
duration += element->getDuration();
elements_to_delete = g_list_append(elements_to_delete, element);
all_elements_to_delete = g_list_append(all_elements_to_delete, element);
if (start_ptr == end_ptr) break;
}
if (g_list_length(elements_to_delete) > 0) {
if ((pos = g_list_index(m_chord_or_rests, g_list_first(elements_to_delete)->data)) < 0) {
NedResource::Abort("NedVoice::removeNotesFromTo(2)");
}
start_element = (NedChordOrRest *) g_list_first(elements_to_delete)->data;
element = (NedChordOrRest *) g_list_last(elements_to_delete)->data;
measure_start_seen = element->getMidiTime() + element->getDuration() == measure->midi_end &&
start_element->getMidiTime() == measure->midi_start;
command = new NedDeleteChordOrRestGroupCommand(this, elements_to_delete);
command->execute();
command_list->addCommand(command);
handleGapAfterInsertion(command_list, &pos, duration, NULL, 0, measure_start_seen, true);
}
if (g_list_length(elements_to_delete) > 0) {
((NedChordOrRest *) g_list_first(all_elements_to_delete)->data)->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD, true);
((NedChordOrRest *) g_list_last(all_elements_to_delete)->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD, true);
}
g_list_free(all_elements_to_delete);
}
void NedVoice::insertBlocks(NedCommandList *command_list, int blockcount, unsigned long long midi_time) {
int i;
GList *lptr;
GList *items_to_insert = NULL;
int pos;
for (lptr = g_list_first(m_chord_or_rests); lptr && ((NedChordOrRest *) lptr->data)->getMidiTime() < midi_time; lptr = g_list_next(lptr));
if (lptr) {
if ((pos = g_list_position(m_chord_or_rests, lptr)) < 0) {
NedResource::Abort("NedVoice::insertBlocks");
}
((NedChordOrRest *) lptr->data)->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD, true);
}
else {
((NedChordOrRest *) g_list_last(m_chord_or_rests)->data)->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD, true);
pos = g_list_length(m_chord_or_rests);
}
for (i = 0; i < blockcount; i++) {
items_to_insert = g_list_append(items_to_insert, new NedChordOrRest(this, TYPE_REST, m_voice_nr != 0, 3 /*dummy*/, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0 /* dummy */));
}
NedInsertChordOrRestGroupCommand *command = new NedInsertChordOrRestGroupCommand(this, items_to_insert, pos);
command->execute();
command_list->addCommand(command);
assignMidiTimes();
}
void NedVoice::testForPageBackwardTies(NedCommandList *command_list) {
((NedChordOrRest *) g_list_first(m_chord_or_rests)->data)->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD);
}
bool NedVoice::tryChangeLength(NedChordOrRest *chord_or_rest) {
GList *lptr, *lptr2;
NedChordOrRest *chord_or_rest_to_distribute;
NedChordOrRest *last_tupleted_chord_or_rest;
unsigned long long new_duration;
unsigned long long change_chords_midi_end_time;
unsigned long long end_time;
unsigned long long offs;
bool was_last_in_tuplet;
NedTuplet *tuplet_ptr;
int tuplet_val, tuplet_val_raw;
int new_dot_count = NedResource::getDotCount();
lptr = g_list_find(m_chord_or_rests, chord_or_rest);
if (lptr == NULL) {
return FALSE;
}
tuplet_val = chord_or_rest->getTupletVal();
tuplet_val_raw = chord_or_rest->getTupletValRaw();
was_last_in_tuplet = chord_or_rest->hasLastTupletFlag();
chord_or_rest->setLastTupletFlag(FALSE);
new_duration = NedChordOrRest::computeDuration(NedResource::getCurrentLength(), NedResource::getDotCount(), chord_or_rest->getTupletVal());
if (chord_or_rest->getDuration() == new_duration) return TRUE;
int pos = g_list_position(m_chord_or_rests, lptr);
unsigned long long change_pos_midi_time = ((NedChordOrRest *) lptr->data)->getMidiTime();
if ((tuplet_ptr = chord_or_rest->getTupletPtr()) != NULL) {
end_time = tuplet_ptr->getEndTime();
change_chords_midi_end_time = change_pos_midi_time + new_duration;
}
else {
NedMeasure *measure = ((NedChordOrRest *) lptr->data)->m_measure;
change_chords_midi_end_time = change_pos_midi_time + new_duration;
end_time = measure->midi_end;
if (NedResource::getCurrentLength() == WHOLE_NOTE && NedResource::getDotCount() == 0 && chord_or_rest->getMidiTime() == change_pos_midi_time) {
new_duration = chord_or_rest->m_measure->getMeasureDuration();
}
}
change_chords_midi_end_time = change_pos_midi_time + new_duration;
if (end_time > change_chords_midi_end_time) end_time = change_chords_midi_end_time;
if (tuplet_ptr != NULL && tuplet_ptr->getMidiStartTime() == change_pos_midi_time && change_chords_midi_end_time - change_pos_midi_time == tuplet_ptr->getDuration()) {
return FALSE;
}
unsigned int sum_of_chords_and_rests_to_delete = 0;
GList *chords_and_rests_to_delete = NULL;
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
if (tuplet_ptr == NULL) {
searchForBreakableTuplet(command_list, end_time);
}
((NedChordOrRest *) lptr->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD);
for (lptr2 = g_list_next( lptr ); lptr2 && ((NedChordOrRest *) lptr2->data)->getMidiTime() < end_time;
lptr2 = g_list_next(lptr2)) {
chords_and_rests_to_delete = g_list_append(chords_and_rests_to_delete, lptr2->data);
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list, BREAK_TIE_FORWARD);
sum_of_chords_and_rests_to_delete += ((NedChordOrRest *) lptr2->data)->getDuration();
}
if (chords_and_rests_to_delete != NULL) {
command_list->addCommand(new NedDeleteChordOrRestGroupCommand(this, chords_and_rests_to_delete));
}
unsigned int length = NedResource::getCurrentLength();
if (new_duration > chord_or_rest->getDuration()) {
if (new_duration - chord_or_rest->getDuration() > sum_of_chords_and_rests_to_delete) {
if (tuplet_val > 0) {
unsigned int d = sum_of_chords_and_rests_to_delete + chord_or_rest->getDuration();
d *= tuplet_val;
d /= NedResource::m_tuplet_tab[tuplet_val];
NedChordOrRest::compute_fitting_duration(d, &length, &new_dot_count);
}
else {
NedChordOrRest::compute_fitting_duration(sum_of_chords_and_rests_to_delete + chord_or_rest->getDuration(), &length, &new_dot_count);
}
new_duration = NedChordOrRest::computeDuration(length, new_dot_count, chord_or_rest->getTupletVal());
}
}
else {
sum_of_chords_and_rests_to_delete = chord_or_rest->getDuration() - new_duration;
}
if (new_duration > chord_or_rest->getDuration()) {
sum_of_chords_and_rests_to_delete -= new_duration - chord_or_rest->getDuration();
}
last_tupleted_chord_or_rest = chord_or_rest;
command_list->addCommand(new NedChangeChordOrRestLengthCommand(chord_or_rest, length, new_dot_count));
if (chords_and_rests_to_delete == NULL) {
chord_or_rest_to_distribute = NULL;
}
else {
chord_or_rest_to_distribute = (NedChordOrRest *) (g_list_last(chords_and_rests_to_delete)->data);
}
if (sum_of_chords_and_rests_to_delete > 0) {
pos++;
offs = length;
switch (new_dot_count) {
case 1: offs *= 3; offs /= 2; break;
case 2: offs *= 7; offs /= 4; break;
}
offs += chord_or_rest->getMidiTime();
handleGapAfterInsertion2(command_list, offs, &pos, sum_of_chords_and_rests_to_delete, chord_or_rest_to_distribute, tuplet_val, false, false);
}
if (was_last_in_tuplet) {
last_tupleted_chord_or_rest->setLastTupletFlag(TRUE);
}
getMainWindow()->getCommandHistory()->addCommandList(command_list);
command_list->executeAfterBreak(); // because of searchForBreakableTuplet; don't repeat actions before break
getMainWindow()->reposit(command_list, getPage(), getSystem());
return TRUE;
}
bool NedVoice::tryConvertToTuplet(int method, int tuplet_val, NedChordOrRest *templ) {
GList *lptr2;
NedChordOrRest *chord_or_rest = NULL, *last_tupleted_chord_or_rest;
int minpos;
GList *min_pos_ptr;
int num_elements_to_delete;
unsigned long long new_chords_midi_end_time;
unsigned long long ref_duration;
int num_additional_rests;
if (templ->getTupletVal() != 0 || templ->getLength() < NOTE_32) {
return FALSE;
}
if ((method == 1 && ((templ->getDuration() % 2) != 0)) || tuplet_val < 2 || (method > 0 && tuplet_val < 3)) {
return FALSE;
}
ref_duration = (method == 1) ? templ->getDuration() / 2 : templ->getDuration();
if ((min_pos_ptr = g_list_find(m_chord_or_rests, templ)) < 0) {
NedResource::Abort("NedVoice::tryConvertToTuplet(1)");
}
if ((minpos = g_list_index(m_chord_or_rests, templ)) < 0) {
NedResource::Abort("NedVoice::tryConvertToTuplet(2)");
}
if (((NedChordOrRest *) min_pos_ptr->data)->getTupletVal() != 0) {
return false;
}
minpos++;
//NedMeasure *measure = getSystem()->getMeasure(templ->getMidiTime());
NedMeasure *measure = templ->m_measure;
unsigned long long min_pos_midi_time = templ->getMidiTime();
new_chords_midi_end_time = min_pos_midi_time + NedResource::m_tuplet_tab[tuplet_val] * ref_duration;
unsigned int end_time = measure->midi_end;
if (new_chords_midi_end_time > end_time) {
return FALSE;
}
unsigned int sum_of_chords_and_rests_to_delete = 0;
GList *chords_and_rests_to_delete = NULL;
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
for (lptr2 = g_list_next(min_pos_ptr); lptr2 && ((NedChordOrRest *) lptr2->data)->getMidiTime() < new_chords_midi_end_time;
lptr2 = g_list_next(lptr2)) {
chords_and_rests_to_delete = g_list_append(chords_and_rests_to_delete, lptr2->data);
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list);
sum_of_chords_and_rests_to_delete += ((NedChordOrRest *) lptr2->data)->getDuration();
}
/*
if (sum_of_chords_and_rests_to_delete < templ->getDuration()) {
return FALSE;
}
*/
if ((NedResource::m_tuplet_tab[tuplet_val] - 1) * ref_duration <= sum_of_chords_and_rests_to_delete) {
sum_of_chords_and_rests_to_delete -= (NedResource::m_tuplet_tab[tuplet_val] - 1) * ref_duration;
}
if (chords_and_rests_to_delete != NULL) {
command_list->addCommand(new NedDeleteChordOrRestGroupCommand(this, chords_and_rests_to_delete));
num_elements_to_delete = g_list_length(chords_and_rests_to_delete);
}
command_list->addCommand(new NedSetToTupletCommand(templ, tuplet_val));
num_additional_rests = (method == 1) ? tuplet_val - 2 : tuplet_val - 1;
for (int i = 0; i < num_additional_rests; i++) {
chord_or_rest = new NedChordOrRest(this, TYPE_REST, FALSE, 0, 0, ref_duration, NORMAL_NOTE, 0, 0);
chord_or_rest->setTupletVal(tuplet_val);
command_list->addCommand(new NedInsertChordOrRestCommand(this, minpos++, chord_or_rest));
}
last_tupleted_chord_or_rest = chord_or_rest;
if (sum_of_chords_and_rests_to_delete > 0) {
NedChordOrRest *chord_or_rest_to_distribute = (NedChordOrRest *) (g_list_last(chords_and_rests_to_delete)->data);
handleGapAfterInsertion(command_list, &minpos, sum_of_chords_and_rests_to_delete, chord_or_rest_to_distribute, 0, false, false);
}
last_tupleted_chord_or_rest->setLastTupletFlag(TRUE);
getMainWindow()->getCommandHistory()->addCommandList(command_list);
command_list->execute();
getMainWindow()->reposit(command_list, getPage(), getSystem());
getSystem()->m_is_positioned = false;
return TRUE;
}
void NedVoice::removeTuplet(NedChordOrRest *element, NedCommandList *cmd_list) {
NedTuplet *tuplet = element->getTupletPtr();
NedCommandList *command_list;
NedDeleteChordOrRestGroupCommand *del_chord;
unsigned int tuplet_time;
int pos;
if (tuplet == NULL) {
NedResource::Abort("NedVoice::removeTuplet(1)");
}
tuplet_time = tuplet->getDuration();
pos = g_list_index(m_chord_or_rests, tuplet->getFirstElement());
if (pos < 0) {
NedResource::Abort("NedVoice::removeTuplet(2)");
}
if (cmd_list == NULL) {
command_list = new NedCommandList(getMainWindow(), getSystem());
}
else {
command_list = cmd_list;
}
tuplet->getFirstElement()->testForTiesToDelete(command_list, BREAK_TIE_BACKWARD, cmd_list != NULL);
tuplet->getLastElement()->testForTiesToDelete(command_list, BREAK_TIE_FORWARD, cmd_list != NULL);
command_list->addCommand(del_chord = new NedDeleteChordOrRestGroupCommand(this, tuplet->getElementList()));
if (cmd_list != NULL) {
del_chord->execute();
}
if (tuplet_time > 0) {
handleGapAfterInsertion(command_list, &pos, tuplet_time, NULL, 0, false, cmd_list != NULL);
}
if (cmd_list == NULL) {
getMainWindow()->getCommandHistory()->addCommandList(command_list);
command_list->execute();
getMainWindow()->reposit(command_list, getPage(), getSystem());
}
getSystem()->m_is_positioned = false;
}
void NedVoice::checkForElementsToSplit(NedCommandList *command_list) {
GList *lptr, *lptr2;
GList *lptr3;
int n2;
GList *elements_to_delete = NULL;
unsigned long long t1;
unsigned int len;
bool in_upbeat;
NedMeasure *measure;
NedTuplet *tuplet;
NedChordOrRest *element_to_distribute = NULL;
unsigned int overflow = 0;
NedChordOrRest *element;
NedChangeChordOrRestLengthCommand *change_length_command;
NedInsertTiedElementCommand *insert_element_command;
NedDeleteChordOrRestGroupCommand *del_group;
int pos = 0, dotcount;
int n;
for (n = 0, lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr), n++) {
element = (NedChordOrRest *) lptr->data;
measure = getSystem()->getMeasure(element->getMidiTime());
//measure = element->m_measure;
if (measure == NULL) {
int idx = g_list_position(m_chord_or_rests, lptr);
int ll = g_list_length(m_chord_or_rests);
for (n2 = 0, lptr3 = g_list_first(m_chord_or_rests); lptr3; lptr3 = g_list_next(lptr3), n2++) {
printf("%d: ", n2);
if (((NedChordOrRest *) lptr3->data)->isRest()) {
printf("r");
}
else {
printf("n");
}
printf("%u(%u, %u) ", LAUS(((NedChordOrRest *) lptr3->data)->getLength()));
if (((NedChordOrRest *) lptr3->data)->getDotCount()) {
printf("D%d ", ((NedChordOrRest *) lptr3->data)->getDotCount());
}
if (!((NedChordOrRest *) lptr3->data)->isRest()) {
printf(" %d ", ((NedChordOrRest *) lptr3->data)->getLineOfFirstNote());
}
printf("\n"); fflush(stdout);
}
printf("pag: %d, sys: %d, sta: %d, voi: %d, idx = %d n = %d, len = %d, element->getMidiTime() = %llu(%llu, %llu)\n",
getPage()->getPageNumber(), getSystem()->getSystemNumber(), m_staff->getStaffNumber(), m_voice_nr,
idx, n, ll, LAUS(element->getMidiTime())); fflush(stdout);
NedResource::Abort("NedVoice::checkForElementsToSplit(0)");
}
if (element->getTupletVal() != 0) {
tuplet = element->getTupletPtr();
if (tuplet->getMidiStartTime() < measure->midi_start &&
tuplet->getMidiStartTime() + tuplet->getDuration() > measure->midi_start) {
removeTuplet(element, command_list);
lptr = g_list_first(m_chord_or_rests);
assignMidiTimes(); // recompute midi times
}
}
}
in_upbeat = getPage()->getPageNumber() == 0 && getMainWindow()->getUpBeatInverse() > 0 &&
getSystem()->getSystemNumber() == 0;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
element = (NedChordOrRest *) lptr->data;
measure = getSystem()->getMeasure(element->getMidiTime());
//measure = element->m_measure;
if (measure == NULL) {
elements_to_delete = g_list_append(elements_to_delete, element);
continue;
}
if (overflow == 0 && element->isRest() && element->getLength() == WHOLE_NOTE && element->getMidiTime() == measure->midi_start) {
overflow = 0;
assignMidiTimes();
continue;
}
if ((!(in_upbeat && measure->getMeasureNumber() == 0) && overflow == 0) || (element_to_distribute != NULL && element_to_distribute->isRest())) {
if (element->getLength() == WHOLE_NOTE && element->isRest() && element->getMidiTime() == measure->midi_start /* &&
element->getMidiTime() + element->getDuration() == measure->midi_end */) {
overflow = 0;
assignMidiTimes();
continue;
}
}
if (overflow > measure->getMeasureDuration()) {
overflow = 0;
}
if (overflow > 0) {
NedResource::setLengthField(overflow);
len = NedResource::getPartLength(&dotcount);
while (len > 0) {
insert_element_command = new NedInsertTiedElementCommand(this, element_to_distribute, len, dotcount);
insert_element_command->execute();
command_list->addCommand(insert_element_command);
pos++;
if ((lptr2 = g_list_nth(m_chord_or_rests, pos)) == NULL) {
NedResource::Abort("checkForElementsToSplit(1)");
}
element_to_distribute = (NedChordOrRest *) lptr2->data;
len = NedResource::getPartLength(&dotcount);
}
overflow = 0;
element_to_distribute = NULL;
if ((lptr = g_list_nth(m_chord_or_rests, pos)) == NULL) {
NedResource::Abort("checkForElementsToSplit(2)");
}
assignMidiTimes();
}
overflow = 0;
if ((pos = g_list_position(m_chord_or_rests, lptr)) < 0) {
NedResource::Abort("checkForElementsToSplit(3)");
}
if (element->isRest() && element->getLength() == WHOLE_NOTE) { // i.e. was overflow into a measure with a whole rest
t1 = measure->midi_end - element->getMidiTime();
handleGapAfterInsertion(command_list, &pos, t1, NULL, 0, false, true);
assignMidiTimes();
if ((lptr = g_list_nth(m_chord_or_rests, pos)) == NULL) {
NedResource::Abort("checkForElementsToSplit(5)");
}
continue;
}
if (element->getMidiTime() < measure->midi_end && element->getMidiTime() + element->getDuration() > measure->midi_end) {
t1 = measure->midi_end - element->getMidiTime();
/*
if (!(in_upbeat && measure->getMeasureNumber() == 0) || !(element->isRest() && element->getLength() == WHOLE_NOTE)) {
overflow = element->getMidiTime() + element->getDuration() - measure->midi_end;
}
*/
overflow = element->getMidiTime() + element->getDuration() - measure->midi_end;
NedResource::setLengthField(t1);
len = NedResource::getPartLength(&dotcount);
change_length_command = new NedChangeChordOrRestLengthCommand(element, len, dotcount);
change_length_command->execute();
command_list->addCommand(change_length_command);
len = NedResource::getPartLength(&dotcount);
element_to_distribute = element;
while (len > 0) {
insert_element_command = new NedInsertTiedElementCommand(this, element_to_distribute, len, dotcount);
insert_element_command->execute();
command_list->addCommand(insert_element_command);
pos++;
if ((lptr2 = g_list_nth(m_chord_or_rests, pos)) == NULL) {
NedResource::Abort("checkForElementsToSplit(4)");
}
element_to_distribute = (NedChordOrRest *) lptr2->data;
len = NedResource::getPartLength(&dotcount);
}
if ((lptr = g_list_nth(m_chord_or_rests, pos > 0 ? pos-1 : pos)) == NULL) {
NedResource::Abort("checkForElementsToSplit(6)");
}
}
}
if (elements_to_delete != NULL) {
del_group = new NedDeleteChordOrRestGroupCommand(this, elements_to_delete);
del_group->execute();
command_list->addCommand(del_group);
}
testAllMeasuresForFillup(command_list);
}
GList *NedVoice::getFirstChordOrRest(int lyrics_line, bool lyrics_required, bool note_required) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (note_required && ((NedChordOrRest *) lptr->data)->getType() != TYPE_CHORD) continue;
if ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_REST | TYPE_CHORD)) == 0) continue;
if (lyrics_required && ((NedChordOrRest *) lptr->data)->getType() != TYPE_CHORD) continue;
if (!lyrics_required) return lptr;
if (((NedChordOrRest *) lptr->data)->getLyrics(lyrics_line) != NULL) {
return lptr;
}
}
return NULL;
}
GList *NedVoice::getLastChordOrRest(int lyrics_line, bool lyrics_required, bool note_required) {
GList *lptr;
for (lptr = g_list_last(m_chord_or_rests); lptr; lptr = g_list_previous(lptr)) {
if (note_required && ((NedChordOrRest *) lptr->data)->getType() != TYPE_CHORD) continue;
if ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_REST | TYPE_CHORD)) == 0) continue;
if (lyrics_required && ((NedChordOrRest *) lptr->data)->getType() != TYPE_CHORD) continue;
if (!lyrics_required) return lptr;
if (((NedChordOrRest *) lptr->data)->getLyrics(lyrics_line) != NULL) {
return lptr;
}
}
return NULL;
}
void NedVoice::testAllMeasuresForFillup(NedCommandList *command_list) {
int last_measure_number;
NedChordOrRest *last_element;
GList *appended_wholes = NULL;
NedMeasure *measure;
int meas_number;
unsigned int diff;
int pos;
if (m_chord_or_rests == NULL) return;
NedInsertChordOrRestGroupCommand *insert_chord_or_rest_group_command;
last_measure_number = getSystem()->getNumberOfLastMeasure();
last_element = (NedChordOrRest *) g_list_last(m_chord_or_rests)->data;
//measure = getSystem()->getMeasure(last_element->getMidiTime());
measure = last_element->m_measure;
if (measure == NULL) return;
if (measure->midi_end > last_element->getMidiTime() + last_element->getDuration()) {
diff = measure->midi_end - (last_element->getMidiTime() + last_element->getDuration());
if ((pos = g_list_index(m_chord_or_rests, last_element)) < 0) {
NedResource::Abort("NedVoice::testAllMeasuresForFillup");
}
pos++;
handleGapAfterInsertion(command_list, &pos, diff, NULL, 0, false, true);
}
else {
pos = g_list_length(m_chord_or_rests);
}
for (meas_number = measure->getMeasureNumber(); meas_number < last_measure_number; meas_number++) {
appended_wholes = g_list_append(appended_wholes, new NedChordOrRest(this, TYPE_REST, m_voice_nr > 0, 3 /* dummy */, 0, WHOLE_NOTE, NORMAL_NOTE, 0, 0));
}
if (appended_wholes != NULL) {
insert_chord_or_rest_group_command = new NedInsertChordOrRestGroupCommand(this, appended_wholes, pos);
insert_chord_or_rest_group_command->execute();
command_list->addCommand(insert_chord_or_rest_group_command);
}
}
NedChordOrRest *NedVoice::handleGapAfterInsertion(NedCommandList *command_list, int *pos /* in/out */,
int sum_of_chords_and_rests_to_delete, NedChordOrRest *chord_or_rest_to_distribute,
int tuplet_val, bool force_wholes, bool do_execute) {
unsigned int len2 = 0;
int dotcount = 0;
NedInsertChordOrRestCommand *insert_command;
NedChordOrRest *chord_or_rest, *last_tupleted_chord_or_rest = NULL, *distributed_new_sym;
if (tuplet_val > 0) {
sum_of_chords_and_rests_to_delete *= tuplet_val;
sum_of_chords_and_rests_to_delete /= NedResource::m_tuplet_tab[tuplet_val];
}
/*
if (sum_of_chords_and_rests_to_delete >= WHOLE_NOTE) {
len2 = WHOLE_NOTE;
}
else */
if (force_wholes) {
len2 = WHOLE_NOTE;
last_tupleted_chord_or_rest = chord_or_rest = new NedChordOrRest(this, TYPE_REST, FALSE, 3, dotcount, len2, NORMAL_NOTE, 0, 0);
insert_command = new NedInsertChordOrRestCommand(this, *pos, chord_or_rest);
command_list->addCommand(insert_command);
if (do_execute) {
insert_command->execute();
}
}
else {
NedResource::setLengthField(sum_of_chords_and_rests_to_delete);
len2 = NedResource::getPartLength(&dotcount);
while (len2 > 0) {
if (chord_or_rest_to_distribute == NULL) {
last_tupleted_chord_or_rest = chord_or_rest = new NedChordOrRest(this, TYPE_REST, FALSE, 3, dotcount, len2, NORMAL_NOTE, 0, 0);
chord_or_rest->setTupletVal(tuplet_val);
insert_command = new NedInsertChordOrRestCommand(this, *pos, chord_or_rest);
command_list->addCommand(insert_command);
}
else {
last_tupleted_chord_or_rest = distributed_new_sym = chord_or_rest_to_distribute->cloneWithDifferentLength(len2, dotcount);
distributed_new_sym->setTupletVal(tuplet_val);
insert_command = new NedInsertChordOrRestCommand(this, *pos, distributed_new_sym);
command_list->addCommand(insert_command);
}
if (do_execute) {
insert_command->execute();
}
len2 = NedResource::getPartLength(&dotcount);
(*pos)++;
}
}
assignMidiTimes(); // the new element(s) has no MIDI time, but needed in reposit (collect FirstMeasure)
return last_tupleted_chord_or_rest;
}
NedChordOrRest *NedVoice::handleGapAfterInsertion2(NedCommandList *command_list, unsigned long long offs, int *pos /* in/out */,
int sum_of_chords_and_rests_to_delete, NedChordOrRest *chord_or_rest_to_distribute,
int tuplet_val, bool force_wholes, bool do_execute) {
unsigned int len2 = 0;
int dotcount = 0;
NedInsertChordOrRestCommand *insert_command;
NedChordOrRest *chord_or_rest, *last_tupleted_chord_or_rest = NULL, *distributed_new_sym;
if (tuplet_val > 0) {
sum_of_chords_and_rests_to_delete *= tuplet_val;
sum_of_chords_and_rests_to_delete /= NedResource::m_tuplet_tab[tuplet_val];
offs *= tuplet_val;
offs /= NedResource::m_tuplet_tab[tuplet_val];
}
/*
if (sum_of_chords_and_rests_to_delete >= WHOLE_NOTE) {
len2 = WHOLE_NOTE;
}
else */
if (force_wholes) {
len2 = WHOLE_NOTE;
last_tupleted_chord_or_rest = chord_or_rest = new NedChordOrRest(this, TYPE_REST, FALSE, 3, dotcount, len2, NORMAL_NOTE, 0, 0);
insert_command = new NedInsertChordOrRestCommand(this, *pos, chord_or_rest);
command_list->addCommand(insert_command);
if (do_execute) {
insert_command->execute();
}
}
else {
NedResource::setLengthField2(0, offs, sum_of_chords_and_rests_to_delete);
len2 = NedResource::getPartLength2(&dotcount);
while (len2 > 0) {
if (chord_or_rest_to_distribute == NULL) {
last_tupleted_chord_or_rest = chord_or_rest = new NedChordOrRest(this, TYPE_REST, FALSE, 3, dotcount, len2, NORMAL_NOTE, 0, 0);
chord_or_rest->setTupletVal(tuplet_val);
insert_command = new NedInsertChordOrRestCommand(this, *pos, chord_or_rest);
command_list->addCommand(insert_command);
}
else {
last_tupleted_chord_or_rest = distributed_new_sym = chord_or_rest_to_distribute->cloneWithDifferentLength(len2, dotcount);
distributed_new_sym->setTupletVal(tuplet_val);
insert_command = new NedInsertChordOrRestCommand(this, *pos, distributed_new_sym);
command_list->addCommand(insert_command);
}
if (do_execute) {
insert_command->execute();
}
len2 = NedResource::getPartLength2(&dotcount);
(*pos)++;
}
}
assignMidiTimes(); // the new element(s) has no MIDI time, but needed in reposit (collect FirstMeasure)
return last_tupleted_chord_or_rest;
}
bool NedVoice::searchForBreakableTuplet(NedCommandList *command_list, unsigned long long critical_time) {
GList *lptr;
bool tuplet_broken;
bool was_broken = FALSE;
NedTuplet *tuplet;
NedChordOrRest *chord_or_rest;
int pos;
int i;
do {
tuplet_broken = FALSE;
for (i = 0, lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr), i++) {
chord_or_rest = (NedChordOrRest *) lptr->data;
if (chord_or_rest->getTupletVal() == 0) continue;
tuplet = chord_or_rest->getTupletPtr();
if (tuplet == NULL) continue; // can happen if the reposition gets tuplets from next page
/*
printf("is rest = %d, type = %d(0x%x), i = %d, pa = %d, sys = %d, sta = %d, voi = %d\n",
chord_or_rest->isRest(), chord_or_rest->getType(), chord_or_rest->getType(),i, getPage()->getPageNumber(), getSystem()->getSystemNumber(), m_staff->getStaffNumber(), m_voice_nr); fflush(stdout);
NedResource::Abort("NedVoice::searchForBreakableTuplet(1)");
}
*/
if (tuplet->getMidiStartTime() < critical_time && tuplet->getEndTime() > critical_time) {
tuplet_broken = TRUE;
pos = g_list_index(m_chord_or_rests, tuplet->getFirstElement());
if (pos < 0) {
NedResource::Abort("NedVoice::searchForBreakableTuplet(2)");
}
command_list->addCommand(new NedDeleteChordOrRestGroupCommand(this, tuplet->getElementList()));
pos++;
handleGapAfterInsertion(command_list, &pos, tuplet->getDuration(), NULL, 0, false, false);
command_list->executeAfterBreakAndSetBreak();
was_broken = TRUE;
assignMidiTimes();
break;
}
}
}
while (tuplet_broken);
return was_broken;
}
void NedVoice::searchForBreakableTies(NedCommandList *command_list, unsigned int dir, unsigned long long start_time, unsigned long long end_time) {
GList *lptr;
NedChordOrRest *chord_or_rest;
unsigned long long chord_start_time;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
chord_start_time = chord_or_rest->getMidiTime();
if (chord_start_time + chord_or_rest->getDuration() <= start_time) continue;
if (chord_start_time >= end_time) break;
if (chord_or_rest->testForTiesToDelete(command_list, dir)) {
command_list->executeAfterBreakAndSetBreak();
}
}
}
void NedVoice::testForTupletEnd(unsigned long long start_time, unsigned int duration, unsigned long long *end_time) {
GList *lptr;
NedChordOrRest *chord_or_rest;
unsigned long long chord_start_time;
unsigned long long chord_end_time;
NedTuplet *tuplet;
chord_end_time = start_time + duration;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
chord_start_time = chord_or_rest->getMidiTime();
if (chord_start_time + chord_or_rest->getDuration() <= start_time) continue;
if (chord_start_time >= *end_time) break;
if (chord_or_rest->getTupletVal() != 0) {
tuplet = chord_or_rest->getTupletPtr();
if (tuplet == NULL) {
NedResource::Abort("NedVoice::testForTupletEnd");
}
if (chord_end_time <= tuplet->getMidiStartTime()) continue;
if (chord_end_time >= tuplet->getMidiStartTime() + tuplet->getDuration()) continue;
*end_time = tuplet->getMidiStartTime();
break;
}
}
}
bool NedVoice::setNewXpos(NedChordOrRest *element, double newpos) {
GList *lptr1, *lptr2;
NedTuplet *tuplet_ptr1, *tuplet_ptr2;
int tuplet_val;
lptr1 = g_list_find(m_chord_or_rests, element);
if (lptr1 == NULL) {
NedResource::Abort("NedVoice::setNewXpos");
}
tuplet_val = ((NedChordOrRest *) lptr1->data)->getTupletVal();
if (tuplet_val == 0) {
//NedMeasure *meas_info1 = getSystem()->getMeasure(((NedChordOrRest *) lptr1->data)->getMidiTime());
NedMeasure *meas_info1 = ((NedChordOrRest *) lptr1->data)->m_measure;
for (lptr2 = g_list_first(m_chord_or_rests); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getRealXpos() > newpos) {
//NedMeasure *meas_info2 = getSystem()->getMeasure(((NedChordOrRest *) lptr2->data)->getMidiTime());
NedMeasure *meas_info2 = ((NedChordOrRest *) lptr2->data)->m_measure;
if (meas_info1 != meas_info2) {
if (meas_info2 - meas_info1 == 1) {
break;
}
return FALSE;
}
if (lptr1 == lptr2) return FALSE;
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
((NedChordOrRest *) lptr1->data)->testForTiesToDelete(command_list);
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list);
command_list->addCommand(new NedChangeXPositionCommand(&m_chord_or_rests, (NedChordOrRest *) lptr2->data, (NedChordOrRest *) lptr1->data, TRUE));
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
return TRUE;
}
}
for (lptr2 = g_list_last(m_chord_or_rests); lptr2; lptr2 = g_list_previous(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getRealXpos() < newpos) {
//NedMeasure *meas_info2 = getSystem()->getMeasure(((NedChordOrRest *) lptr2->data)->getMidiTime());
NedMeasure *meas_info2 = ((NedChordOrRest *) lptr2->data)->m_measure;
if (meas_info1 != meas_info2) return FALSE;
if (lptr1 == lptr2) return FALSE;
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
((NedChordOrRest *) lptr1->data)->testForTiesToDelete(command_list);
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list);
command_list->addCommand(new NedChangeXPositionCommand(&m_chord_or_rests, (NedChordOrRest *) lptr2->data, (NedChordOrRest *) lptr1->data, FALSE));
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
return TRUE;
}
}
}
else {
tuplet_ptr1 = ((NedChordOrRest *) lptr1->data)->getTupletPtr();
for (lptr2 = g_list_first(m_chord_or_rests); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getRealXpos() > newpos) {
tuplet_ptr2 = ((NedChordOrRest *) lptr2->data)->getTupletPtr();
if (lptr1 == lptr2 || tuplet_ptr1 != tuplet_ptr2) {
break;
}
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
((NedChordOrRest *) lptr1->data)->testForTiesToDelete(command_list);
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list);
command_list->addCommand(new NedChangeXPositionCommand(&m_chord_or_rests, (NedChordOrRest *) lptr2->data, (NedChordOrRest *) lptr1->data, TRUE));
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
return TRUE;
}
}
for (lptr2 = g_list_last(m_chord_or_rests); lptr2; lptr2 = g_list_previous(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getRealXpos() < newpos) {
NedCommandList *command_list = new NedCommandList(getMainWindow(), getSystem());
tuplet_ptr2 = ((NedChordOrRest *) lptr2->data)->getTupletPtr();
if (lptr1 == lptr2 || tuplet_ptr1 != tuplet_ptr2) {
return FALSE;
}
((NedChordOrRest *) lptr1->data)->testForTiesToDelete(command_list);
((NedChordOrRest *) lptr2->data)->testForTiesToDelete(command_list);
command_list->addCommand(new NedChangeXPositionCommand(&m_chord_or_rests, (NedChordOrRest *) lptr2->data, (NedChordOrRest *) lptr1->data, FALSE));
command_list->execute();
getMainWindow()->getCommandHistory()->addCommandList(command_list);
return TRUE;
}
}
}
return FALSE;
}
void NedVoice::searchForBeamGroups(unsigned int midi_start_time, NedChordOrRest *new_chord_or_rest /* = NULL */) {
GList *lptr, *beamlist = NULL, *lptr3 = NULL;
unsigned int beats;
bool split = false;
NedMeasure *last_measure = NULL, *measure = NULL;
bool grace_mode = false;
//unsigned int meas_duration;
while ((lptr = g_list_first(m_beam_list)) != NULL) {
// the beam removes itself from m_beam_list if deleted
// therfore we must restart from list begin in every loop
delete ((NedBeam *) lptr->data);
}
g_list_free(m_beam_list);
m_beam_list = NULL;
/*
lptr = g_list_first(m_beam_list);
while (lptr) {
NedBeam *b = (NedBeam *) lptr->data;
delete b; // includes NULL pointer in chords and removal from m_beam_list
lptr = g_list_first(m_beam_list);
}
for (lptr = g_list_first(m_beam_list); lptr; lptr = g_list_next(lptr)) {
((NedBeam *) lptr->data)->m_needed = FALSE;
}
meas_duration = getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
*/
for(lptr = g_list_first(m_chord_or_rests), lptr3 = NULL; lptr; lptr3 = lptr, lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_KEYSIG) continue; // can happen during do_import_from_other (testLineOverflow)
NedChordOrRest *chord_or_rest = (NedChordOrRest *) lptr->data;
last_measure = measure;
//measure = getSystem()->getMeasure(chord_or_rest->getMidiTime());
measure = chord_or_rest->m_measure;
split = m_staff->hasStaffElem(chord_or_rest->getMidiTime());
if (measure == NULL) {
NedResource::Abort("NedVoice::searchForBeamGroups");
}
beats = chord_or_rest->getMidiTime() - measure->midi_start;
if (last_measure != measure) {
split = true;
}
/*
if (meas_duration <= beats) {
split = true;
}
if (!split) {
split = beamEndRequired(beamlist, beats, measure) || ((NedChordOrRest *) lptr->data)->hasLastTupletFlag();
}
*/
if (!split) {
if ((chord_or_rest->getStatus() & STAT_FORCE_BEAM) == 0) {
split = beamEndRequired(beamlist, beats, measure);
}
}
if (!split && lptr3 != NULL) {
split = (chord_or_rest->getTupletVal() != ((NedChordOrRest *) lptr3->data)->getTupletVal()) || ((NedChordOrRest *) lptr3->data)->hasLastTupletFlag();
}
/*
if (lptr3 != NULL) {
split = split || (chord_or_rest->getTupletVal() != ((NedChordOrRest *) lptr3->data)->getTupletVal());
}
*/
if (chord_or_rest->getType() == TYPE_GRACE) {
if (grace_mode) {
split = false;
}
else {
split = true;
}
grace_mode = true;
}
else if (grace_mode) {
grace_mode = false;
split = true;
}
if ((split || (chord_or_rest->getStatus() & STAT_BREAK_BEAM) || (chord_or_rest->getType() & (TYPE_CHORD | TYPE_GRACE)) == 0 ||
chord_or_rest->getLength() >= NOTE_4 || chord_or_rest->getFirstNote()->getNoteHead() == GUITAR_NOTE_NO_STEM) && beamlist != NULL) {
if (g_list_length(beamlist) > 1) {
/*
inserted = FALSE;
for (zz = 0, lptr2 = g_list_first(m_beam_list); lptr2; lptr2 = g_list_next(lptr2), zz++) {
beam = (NedBeam *) lptr2->data;
beam->m_needed = beam->isEqual(beamlist, new_chord_or_rest, &newpos);
NedResource::DbgMsg(DBG_TESTING, "Beam %d --> %d\n", zz, beam->m_needed);
if (new_chord_or_rest != NULL && beam->m_needed) {
beam->insertChord(new_chord_or_rest, newpos);
inserted = TRUE;
}
else if (beam->m_needed) {
inserted = TRUE;
}
}
if (inserted) {
g_list_free(beamlist);
}
else {
*/
NedBeam *bb = new NedBeam(beamlist);
m_beam_list = g_list_append(m_beam_list, bb);
/*
}
*/
}
else {
g_list_free(beamlist);
}
beamlist = NULL;
}
if ((chord_or_rest->getType() & (TYPE_CHORD | TYPE_GRACE)) != 0 && chord_or_rest->getLength() != STROKEN_GRACE && chord_or_rest->getLength() < NOTE_4) {
beamlist = g_list_append(beamlist, chord_or_rest);
}
//measure = getSystem()->getMeasure(chord_or_rest->getMidiTime());
measure = chord_or_rest->m_measure;
/*
if (measure == NULL) {
meas_duration = getMainWindow()->getNumerator() * WHOLE_NOTE / getMainWindow()->getDenominator();
}
else {
meas_duration = getMainWindow()->getMeasureDuration(measure->getMeasureNumber());
}
*/
}
if (beamlist != NULL) {
if (g_list_length(beamlist) > 1) {
NedBeam *bb = new NedBeam(beamlist);
m_beam_list = g_list_append(m_beam_list, bb);
}
else {
g_list_free(beamlist);
beamlist = NULL;
}
}
/*
lptr = g_list_first(m_beam_list);
while (lptr) {
NedBeam *b = (NedBeam *) lptr->data;
if (b->getChordCount() < 1 || !b->m_needed) {
delete b; // includes NULL pointer in chords/rests and removal from m_beam_list
lptr = g_list_first(m_beam_list);
}
else {
lptr = g_list_next(lptr);
}
}
*/
}
void NedVoice::setBeamFlagsOf(NedCommandList *command_list, GList *selected_group, NedChordOrRest *start_elem) {
GList *sel_group_ptr, *voice_list_ptr;
void *last_touched = NULL;
NedMeasure *measure, *measure1;
unsigned int status;
NedChangeChordOrRestStatusCommand *change_status;
//measure = getSystem()->getMeasure(start_elem->getMidiTime());
measure = start_elem->m_measure;
for (sel_group_ptr = g_list_first(selected_group); sel_group_ptr; sel_group_ptr = g_list_next(sel_group_ptr)) {
if (((NedChordOrRest *) sel_group_ptr->data)->getVoice() != this) continue;
if (((NedChordOrRest *) sel_group_ptr->data)->getType() != TYPE_CHORD) continue;
if (((NedChordOrRest *) sel_group_ptr->data)->getLength() >= NOTE_4) continue;
measure1 = ((NedChordOrRest *) sel_group_ptr->data)->m_measure;
if (measure != measure1) break;
status = ((NedChordOrRest *) sel_group_ptr->data)->getStatus();
if( (status & STAT_BREAK_BEAM) || !(status & STAT_FORCE_BEAM) ){
status &= (~(STAT_BREAK_BEAM));
status |= STAT_FORCE_BEAM;
NedChangeChordOrRestStatusCommand *change_status = new NedChangeChordOrRestStatusCommand((NedChordOrRest *) sel_group_ptr->data, status);
command_list->addCommand(change_status);
change_status->execute();
}
last_touched = sel_group_ptr->data;
}
status = start_elem->getStatus();
if( (status & STAT_FORCE_BEAM) || !(status & STAT_BREAK_BEAM) ){
status &= (~(STAT_FORCE_BEAM));
status |= STAT_BREAK_BEAM;
change_status = new NedChangeChordOrRestStatusCommand(start_elem, status);
command_list->addCommand(change_status);
change_status->execute();
}
if (last_touched == NULL) return;
if ((voice_list_ptr = g_list_find(m_chord_or_rests, last_touched)) == NULL) {
NedResource::Abort("NedVoice::setBeamFlagsOf");
}
voice_list_ptr = g_list_next(voice_list_ptr);
if (voice_list_ptr == NULL) return;
measure1 = ((NedChordOrRest *) voice_list_ptr->data)->m_measure;
if (measure != measure1) return;
if (((NedChordOrRest *) voice_list_ptr->data)->getType() != TYPE_CHORD) return;
if (((NedChordOrRest *) voice_list_ptr->data)->getLength() >= NOTE_4) return;
status = ((NedChordOrRest *) voice_list_ptr->data)->getStatus();
if( (status & STAT_FORCE_BEAM) || !(status & STAT_BREAK_BEAM) ){
status &= (~(STAT_FORCE_BEAM));
status |= STAT_BREAK_BEAM;
change_status = new NedChangeChordOrRestStatusCommand((NedChordOrRest *) voice_list_ptr->data, status);
command_list->addCommand(change_status);
change_status->execute();
}
}
void NedVoice::isolate(NedCommandList *command_list, NedChordOrRest *element) {
GList *lptr;
NedBeam *beam;
unsigned int status;
NedChangeChordOrRestStatusCommand *change_status;
if (element->getBeam() == NULL) return;
if ((lptr = g_list_find(m_chord_or_rests, element)) == NULL) {
NedResource::Abort("NedVoice::isolate");
}
if ((beam = element->getBeam()) == NULL) return;
lptr = g_list_next(lptr);
if (lptr == NULL) return;
if (((NedChordOrRest *) lptr->data)->getBeam() != beam) return;
status = ((NedChordOrRest *) lptr->data)->getStatus();
status &= (~(STAT_FORCE_BEAM));
status |= STAT_BREAK_BEAM;
change_status = new NedChangeChordOrRestStatusCommand((NedChordOrRest *) lptr->data, status);
command_list->addCommand(change_status);
change_status->execute();
status = element->getStatus();
status &= (~(STAT_FORCE_BEAM));
status |= STAT_BREAK_BEAM;
change_status = new NedChangeChordOrRestStatusCommand(element, status);
command_list->addCommand(change_status);
change_status->execute();
}
bool NedVoice::findFirstElementeGreaterThan(double x, NedChordOrRest **element) {
GList *lptr;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getXPos() > x) {
*element = (NedChordOrRest *) lptr->data;
return TRUE;
}
}
return FALSE;
}
bool NedVoice::findLastElementeLessThan(double x, NedChordOrRest **element) {
GList *lptr;
for(lptr = g_list_last(m_chord_or_rests); lptr; lptr = g_list_previous(lptr)) {
if (((NedChordOrRest *) lptr->data)->getXPos() < x) {
*element = (NedChordOrRest *) lptr->data;
return TRUE;
}
}
return FALSE;
}
void NedVoice::collectChordsAndRests(NedClipBoard *board, unsigned long long midi_start, unsigned long long midi_end) {
GList *lptr;
NedClipBoardElement *element = new NedClipBoardElement();
element->from_voice = this;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getMidiTime() < midi_start || ((NedChordOrRest *) lptr->data)->getMidiTime() >= midi_end) continue;
element->chords_or_rests_to_move = g_list_append(element->chords_or_rests_to_move, lptr->data);
}
board->m_elements = g_list_append(board->m_elements, element);
}
void NedVoice::collectDestinationVoices(NedClipBoard *board) {
NedClipBoardElement *element;
if (board->element_counter == NULL) {
NedResource::Abort("NedVoice::collectDestinationVoices(1)");
}
element = ((NedClipBoardElement *) board->element_counter->data);
if (element->from_voice == NULL) {
NedResource::Abort("NedVoice::collectDestinationVoices(2)");
}
element->to_voice = this;
board->element_counter = g_list_next(board->element_counter);
}
bool NedVoice::beamEndRequired(GList *beamlist_so_far, unsigned int beats, NedMeasure *measure) {
int shortestNote = WHOLE_NOTE, dur;
GList *lptr;
struct rule_str *wild_ptr = NULL, *rule_ptr = NULL, *ptr;
int best_match = -1;
int num, denom;
for (lptr = g_list_first(beamlist_so_far); lptr; lptr = g_list_next(lptr)) {
dur = ((NedChordOrRest *) lptr->data)->getDuration();
if (dur < shortestNote) shortestNote = dur;
}
if (measure == NULL) {
num = getMainWindow()->getNumerator();
denom = getMainWindow()->getDenominator();
}
else {
num = getMainWindow()->getNumerator(measure->getMeasureNumber());
denom = getMainWindow()->getDenominator(measure->getMeasureNumber());
}
for (ptr = beam_rules_tab__; ptr->function != END_OF_TABLE; ptr++) {
if (ptr->function!= FUNC_END) continue;
if (num == ptr->time_num && denom == ptr->time_denom) {
if (ptr->notelen < 0) {
wild_ptr = ptr;
}
else if (ptr->notelen >= shortestNote) {
if (best_match < 0) {
best_match = ptr->notelen;
rule_ptr = ptr;
}
else if (best_match > ptr->notelen) {
best_match = ptr->notelen;
rule_ptr = ptr;
}
}
}
}
if ((best_match != shortestNote || rule_ptr == NULL) && wild_ptr != NULL) {
rule_ptr = wild_ptr;
}
if (rule_ptr == NULL) {
return false;
}
return ((beats % rule_ptr->duration) == 0);
}
int NedVoice::getSorting(NedChordOrRest *chord0, NedChordOrRest *chord1) {
int pos0, pos1;
if ((pos0 = g_list_index(m_chord_or_rests, chord0)) < 0) {
NedResource::Abort("NedVoice::getSorting 1");
}
if ((pos1 = g_list_index(m_chord_or_rests, chord1)) < 0) {
NedResource::Abort("NedVoice::getSorting 2");
}
if (pos0 == pos1) {
NedResource::Abort("NedVoice::getSorting 3");
}
if (pos0 + 1 == pos1) {
return SORTING_GREAT;
}
if (pos1 + 1 == pos0) {
return SORTING_LESS;
}
return SORTING_NONE;
}
bool NedVoice::isFirst(NedChordOrRest *chord) {
GList *lptr;
if ((lptr = g_list_find(m_chord_or_rests, chord)) == NULL) {
NedResource::Abort("NedVoice::isFirst");
}
return (lptr == g_list_first(m_chord_or_rests));
}
bool NedVoice::isLast(NedChordOrRest *chord) {
GList *lptr;
if ((lptr = g_list_find(m_chord_or_rests, chord)) == NULL) {
NedResource::Abort("NedVoice::isLast");
}
return (lptr == g_list_last(m_chord_or_rests));
}
int NedVoice::getBeamCount() {
return g_list_length(m_beam_list);
}
NedChordOrRest *NedVoice::getNextChordOrRest(NedChordOrRest *element) {
GList *lptr;
lptr = g_list_find(m_chord_or_rests, element);
if ((lptr = g_list_next(lptr)) == NULL) {
return NULL;
}
return (NedChordOrRest *) lptr->data;
}
void NedVoice::selectNextChord(NedChordOrRest *chord, int line, bool lyrics_required) {
GList *lptr;
NedSystem *other_system;
getMainWindow()->m_selected_chord_or_rest = NULL;
getMainWindow()->m_selected_note = NULL;
if ((lptr = g_list_find(m_chord_or_rests, chord)) == NULL) {
NedResource::Abort("NedVoice::selectNextChord");
}
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_CHORD) {
if ((!lyrics_required && !((NedChordOrRest *) lptr->data)->isTied()) || ((NedChordOrRest *) lptr->data)->getLyrics(line) != NULL) {
break;
}
}
}
if (lptr == NULL) {
other_system = getPage()->getNextSystem(getSystem());
if (other_system != NULL) {
lptr = other_system->getFirstChordOrRest(m_staff->getStaffNumber(), m_voice_nr, line, lyrics_required, true);
}
}
if (lptr == NULL) {
return;
}
getMainWindow()->m_selected_chord_or_rest = (NedChordOrRest *) lptr->data;
getMainWindow()->m_selected_note = ((NedChordOrRest *) lptr->data)->getFirstNote();
}
void NedVoice::selectPreviousChord(NedChordOrRest *chord, int line, bool lyrics_required) {
GList *lptr;
NedSystem *other_system;
getMainWindow()->m_selected_chord_or_rest = NULL;
getMainWindow()->m_selected_note = NULL;
if ((lptr = g_list_find(m_chord_or_rests, chord)) == NULL) {
NedResource::Abort("NedVoice::selectPreviousChord");
}
for (lptr = g_list_previous(lptr); lptr; lptr = g_list_previous(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_CHORD) {
if (!lyrics_required || ((NedChordOrRest *) lptr->data)->getLyrics(line) != NULL) {
break;
}
}
}
if (lptr == NULL) {
other_system = getPage()->getPreviousSystem(getSystem());
if (other_system != NULL) {
lptr = other_system->getLastChordOrRest(m_staff->getStaffNumber(), m_voice_nr, line, lyrics_required, true);
}
}
if (lptr == NULL) {
return;
}
getMainWindow()->m_selected_chord_or_rest = (NedChordOrRest *) lptr->data;
getMainWindow()->m_selected_note = ((NedChordOrRest *) lptr->data)->getFirstNote();
}
NedChordOrRest *NedVoice::getPreviousChordOrRest(NedChordOrRest *element) {
GList *lptr;
lptr = g_list_find(m_chord_or_rests, element);
if ((lptr = g_list_previous(lptr)) == NULL) {
return NULL;
}
return (NedChordOrRest *) lptr->data;
}
void NedVoice::removeBeam(NedBeam *beam) {
GList *lptr;
if ((lptr = g_list_find(m_beam_list, beam)) == NULL) {
NedResource::Abort("NedVoice::removeBeam");
}
m_beam_list = g_list_delete_link(m_beam_list, lptr);
}
void NedVoice::addBeam(NedBeam *beam) {
m_beam_list = g_list_append(m_beam_list, beam);
}
double NedVoice::findTimePos(unsigned int time) {
GList *lptr;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getTime() == time) {
return ((NedChordOrRest *) lptr->data)->getXPos();
}
else if (((NedChordOrRest *) lptr->data)->getTime() > time) {
lptr = g_list_previous(lptr);
if (lptr != NULL) {
return ((NedChordOrRest *) lptr->data)->getXPos();
}
else {
return 0;
}
}
}
return -1;
}
void NedVoice::assignMidiTimes() {
GList *lptr;
unsigned long long midi_time = (getPage()->getPageNumber() == 0 && getSystem()->getSystemNumber() == 0) ? getMainWindow()->getUpBeatInverse() : 0;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->setMidiTime(midi_time);
midi_time += ((NedChordOrRest *) lptr->data)->getDuration();
if (!((NedChordOrRest *) lptr->data)->isRest()) continue;
((NedChordOrRest *) lptr->data)->resetYPos();
}
}
int NedVoice::assignElementsToMeasures(NedMeasure *measures, int offs, bool use_upbeat) {
GList *lptr, *lptr2;
int curr_measure = 0;
bool first_measure_has_only_rests = true;
if (use_upbeat && m_voice_nr > 0) { // special handling of rests of first measure
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getMidiTime() >= measures[0].midi_end) {
if (first_measure_has_only_rests) {
for (lptr2 = g_list_first(m_chord_or_rests); lptr2 != lptr; lptr2 = g_list_next(lptr2)) {
if ((((NedChordOrRest *) lptr2->data)->getType() & TYPE_REST) != 0) {
((NedChordOrRest *) lptr2->data)->setHidden();
}
}
}
break;
}
if ((((NedChordOrRest *) lptr->data)->getType() & TYPE_REST) == 0) {
first_measure_has_only_rests = false;
}
}
}
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_KEYSIG) continue; // can happen during do_import_from_other (testLineOverflow)
while (((NedChordOrRest *) lptr->data)->getMidiTime() >= measures[curr_measure].midi_end) {
curr_measure++;
}
if (((NedChordOrRest *) lptr->data)->getMidiTime() >= measures[curr_measure].midi_end) continue;
if (use_upbeat && m_voice_nr > 0 && curr_measure == 0) {
if ((((NedChordOrRest *) lptr->data)->getType() & TYPE_REST) == 0) {
first_measure_has_only_rests = false;
}
}
if ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_CHORD | TYPE_REST)) != 0) {
measures[curr_measure].m_position_array.insertElement(
(NedChordOrRest *) lptr->data, offs, measures[curr_measure].getMeasureNumber());
}
else if ((((NedChordOrRest *) lptr->data)->getType() & TYPE_GRACE) != 0) {
measures[curr_measure].m_position_array.insertGraceElement(
(NedChordOrRest *) lptr->data, offs, measures[curr_measure].getMeasureNumber());
}
((NedChordOrRest *) lptr->data)->m_measure = &(measures[curr_measure]);
}
return curr_measure;
}
void NedVoice::insertIntoSystem(GList *chords_or_rests_to_move) {
GList *lptr;
NedBeam *b;
int pos = 0;
for (lptr = g_list_first(chords_or_rests_to_move); lptr; lptr = g_list_next(lptr)) {
if ((b = ((NedChordOrRest *) lptr->data)->getBeam()) != NULL) {
delete b;
}
((NedChordOrRest *) lptr->data)->setVoice(this);
m_chord_or_rests = g_list_insert(m_chord_or_rests, lptr->data, pos++);
}
}
void NedVoice::appendAtSystem(GList *chords_or_rests_to_move) {
GList *lptr;
NedBeam *b;
for (lptr = g_list_first(chords_or_rests_to_move); lptr; lptr = g_list_next(lptr)) {
if ((b = ((NedChordOrRest *) lptr->data)->getBeam()) != NULL) {
delete b;
}
((NedChordOrRest *) lptr->data)->setVoice(this);
m_chord_or_rests = g_list_append(m_chord_or_rests, lptr->data);
}
}
void NedVoice::deleteNoteGroup(GList *chords_or_rests_to_move) {
GList *lptr, *lptr2;
for(lptr = g_list_first(chords_or_rests_to_move); lptr; lptr = g_list_next(lptr)) {
if ((lptr2 = g_list_find(m_chord_or_rests, lptr->data)) == NULL) {
NedResource::Abort("NedVoice::deleteNoteGroup");
}
m_chord_or_rests = g_list_delete_link(m_chord_or_rests, lptr2);
}
}
#ifdef AAA
void NedVoice::computeBeams(int *lyrics_lines, double *topy, double *boty) {
GList *lptr;
double ty, by;
for(lptr = g_list_first(m_beam_list); lptr; lptr = g_list_next(lptr)) {
((NedBeam *) lptr->data)->computeBeam(m_stem_direction);
}
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->getTopBotY(lyrics_lines, &ty, &by);
if (ty < *topy) *topy = ty;
if (by > *boty) *boty = by;
}
}
#else
void NedVoice::computeBeams(int *lyrics_lines, double *topy, double *boty/* , bool *topFix, bool *botFix */, int staff_voice_offs) {
GList *lptr;
double ty, by;
for(lptr = g_list_first(m_beam_list); lptr; lptr = g_list_next(lptr)) {
((NedBeam *) lptr->data)->computeBeam(staff_voice_offs);
}
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_KEYSIG) continue; // can happen during do_import_from_other (testLineOverflow)
((NedChordOrRest *) lptr->data)->getTopBotY(lyrics_lines, &ty, &by /*, topFix, botFix*/);
if (ty < *topy) *topy = ty;
if (by > *boty) *boty = by;
}
}
#endif
void NedVoice::computeTies() {
GList *lptr;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->computeTies();
}
}
void NedVoice::computeTuplets(double *topy, double *boty) {
GList *lptr;
GList *tuplet_list = NULL;
int tuplet_val = 0;
NedTuplet *tuplet;
//double ty, by;
for(lptr = g_list_first(m_tuplet_list); lptr; lptr = g_list_next(lptr)) {
delete ((NedTuplet *) lptr->data);
}
g_list_free(m_tuplet_list);
m_tuplet_list = NULL;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getTupletVal() > 0) {
if (tuplet_val == 0) {
tuplet_val = ((NedChordOrRest *) lptr->data)->getTupletVal();
tuplet_list = g_list_append(tuplet_list, lptr->data);
}
else if (((NedChordOrRest *) lptr->data)->getTupletVal() == tuplet_val) {
tuplet_list = g_list_append(tuplet_list, lptr->data);
if (((NedChordOrRest *) lptr->data)->hasLastTupletFlag()) {
tuplet = new NedTuplet(tuplet_val, tuplet_list, topy, boty);
m_tuplet_list = g_list_append(m_tuplet_list, tuplet);
tuplet_val = 0;
tuplet_list = NULL;
}
}
else {
tuplet = new NedTuplet(tuplet_val, tuplet_list, topy, boty);
m_tuplet_list = g_list_append(m_tuplet_list, tuplet);
tuplet_val = 0;
tuplet_list = NULL;
}
}
else if (tuplet_val > 0) {
tuplet = new NedTuplet(tuplet_val, tuplet_list, topy, boty);
m_tuplet_list = g_list_append(m_tuplet_list, tuplet);
tuplet_val = 0;
tuplet_list = NULL;
}
}
/*
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->getTopBotY(&ty, &by);
if (ty < *topy) *topy = ty;
if (by > *boty) *boty = by;
}
*/
}
void NedVoice::prepareMutedReplay() {
GList *lptr;
NedChordOrRest *chord_or_rest;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
if (chord_or_rest->getType() & (TYPE_CHORD | TYPE_REST)) {
chord_or_rest->prepareMutedReplay();
}
}
}
void NedVoice::resetActiveFlags() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (!(((NedChordOrRest *) lptr->data)->getType() & (TYPE_CHORD | TYPE_GRACE))) continue;
((NedChordOrRest *) lptr->data)->resetActiveFlags();
}
}
void NedVoice::prepareReplay(int voice_idx) {
GList *lptr, *lptr2;
int clef, keysig, octave_shift;
unsigned int grace_time = 0;
NedChordOrRest *chord_or_rest;
int measurenumber = -1;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
chord_or_rest = (NedChordOrRest *) lptr->data;
//NedMeasure *measure = getSystem()->getMeasure(chord_or_rest->getMidiTime());
NedMeasure *measure = chord_or_rest->m_measure;
if (measure->getMeasureNumber() != measurenumber) {
measurenumber = measure->getMeasureNumber();
NedResource::addMeasureEntry(measure);
}
if (chord_or_rest->getType() == TYPE_CHORD) {
m_staff->getCurrentClefAndKeysig(chord_or_rest->getMidiTime(), &clef, &keysig, &octave_shift);
grace_time = 0;
for (lptr2 = g_list_next(lptr); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getType() == TYPE_GRACE) {
grace_time += GRACE_DURATION;
continue;
}
break;
}
if (grace_time > chord_or_rest->getDuration() / 2) {
grace_time = chord_or_rest->getDuration() / 2;
}
chord_or_rest->prepareReplay(clef, keysig, octave_shift, voice_idx, grace_time);
}
else if (chord_or_rest->getType() == TYPE_GRACE) {
if (grace_time == 0) {
continue;
}
m_staff->getCurrentClefAndKeysig(chord_or_rest->getMidiTime(), &clef, &keysig, &octave_shift);
chord_or_rest->prepareReplay(clef, keysig, octave_shift, voice_idx, grace_time);
if (grace_time > GRACE_DURATION) {
grace_time -= GRACE_DURATION;
}
else {
grace_time = 0;
}
}
if (chord_or_rest->getType() == TYPE_REST) {
grace_time = 0;
for (lptr2 = g_list_next(lptr); lptr2; lptr2 = g_list_next(lptr2)) {
if (((NedChordOrRest *) lptr2->data)->getType() == TYPE_GRACE) {
grace_time += ((NedChordOrRest *) lptr2->data)->getLength();
continue;
}
break;
}
if (grace_time > chord_or_rest->getDuration() / 2) {
grace_time = chord_or_rest->getDuration() / 2;
}
chord_or_rest->prepareReplay(clef, keysig, octave_shift, voice_idx, grace_time);
}
}
}
void NedVoice::setInternalPitches() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_REST) continue;
((NedChordOrRest *) lptr->data)->setInternalPitch(0);
}
}
void NedVoice::adjustAccidentals() {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_REST) continue;
((NedChordOrRest *) lptr->data)->adjustAccidentals();
}
}
void NedVoice::setInternalPitch(int pitchdist, GList *selected_group) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_REST) continue;
if (selected_group) {
if (g_list_find(selected_group, lptr->data) == NULL) continue;
}
((NedChordOrRest *) lptr->data)->setInternalPitch(pitchdist);
}
}
void NedVoice::adjustAccidentals(int pitchdist, GList *selected_group) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_REST) continue;
if (selected_group) {
if (g_list_find(selected_group, lptr->data) == NULL) continue;
}
((NedChordOrRest *) lptr->data)->adjustAccidentals();
}
}
void NedVoice::changeAccidentals(NedCommandList *command_list, int preferred_offs, GList *selected_group) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_REST) continue;
if (selected_group) {
if (g_list_find(selected_group, lptr->data) == NULL) continue;
}
((NedChordOrRest *) lptr->data)->changeAccidentals(command_list, preferred_offs);
}
}
void NedVoice::hideRests(NedCommandList *command_list, bool unhide) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->hideRest(command_list, unhide);
}
}
void NedVoice::shiftNotes(unsigned long long start_time, int linedist, unsigned long long stop_time, bool stop_at) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (stop_at) {
if (((NedChordOrRest *) lptr->data)->getMidiTime() >= stop_time) return;
}
if (((NedChordOrRest *) lptr->data)->getMidiTime() < start_time) continue;
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_REST) continue;
((NedChordOrRest *) lptr->data)->shiftNotes(linedist);
}
}
void NedVoice::removeUnneededAccidentals(GList *selected_group) {
GList *lptr;
int clef, keysig, octave_shift;
NedChordOrRest *chord_or_rest;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if (selected_group) {
if (g_list_find(selected_group, lptr->data) == NULL) continue;
}
chord_or_rest = (NedChordOrRest *) lptr->data;
if (chord_or_rest->getType() == TYPE_CHORD) {
m_staff->getCurrentClefAndKeysig(chord_or_rest->getMidiTime(), &clef, &keysig, &octave_shift);
chord_or_rest->removeUnneededAccidentals(clef, keysig, octave_shift);
}
}
}
void NedVoice::findAccidentals(char offs_array[115], NedMeasure *meas_info, unsigned long long midi_time, bool including) {
GList *lptr;
for (lptr = g_list_last(m_chord_or_rests); lptr; lptr = g_list_previous(lptr)) {
if (((NedChordOrRest *) lptr->data)->getMidiTime() < meas_info->midi_start) break;
if (including) {
if (((NedChordOrRest *) lptr->data)->getMidiTime() > midi_time) continue;
}
else {
if (((NedChordOrRest *) lptr->data)->getMidiTime() >= midi_time) continue;
}
((NedChordOrRest *) lptr->data)->setOffset(offs_array);
}
}
void NedVoice::saveVoice(FILE *fp) {
GList *lptr;
bool BEAMS_written = FALSE;
bool TIES_written = FALSE;
bool TUPLETS_written = FALSE;
bool FREE_PLACEABLES_written = FALSE;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->saveChordOrRest(fp);
}
fprintf(fp, "\n");
for(lptr = g_list_first(m_beam_list); lptr; lptr = g_list_next(lptr)) {
if (!BEAMS_written) {
fprintf(fp, "BEAMS\n");
BEAMS_written = TRUE;
}
((NedBeam *) lptr->data)->saveBeam(fp);
}
int xx;
for(xx = 0, lptr = g_list_first(m_tuplet_list); lptr; lptr = g_list_next(lptr), xx++) {
if (!TUPLETS_written) {
fprintf(fp, "TUPLETS\n");
TUPLETS_written = TRUE;
}
((NedTuplet *) lptr->data)->saveTuplet(fp);
}
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->saveTies(fp, &TIES_written);
}
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->saveFreePlaceables(fp, &FREE_PLACEABLES_written);
}
if (FREE_PLACEABLES_written) {
putc('\n', fp);
}
}
void NedVoice::restoreVoice(FILE *fp) {
char buffer[128];
bool beams_read = FALSE;
bool ties_read = FALSE;
bool tuplets_read = FALSE;
bool free_placeables_read = FALSE;
NedChordOrRest *chord_or_rest;
while (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( TUPLETS, BEAMS, TIES, FREE_PLACEABLES, VOICE, STAFF SYSTEM or PAGE expected";
return;
}
if (!strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE")) {
NedResource::unreadWord(buffer);
return;
}
if (!strcmp(buffer, "BEAMS")) {
if (beams_read) {
NedResource::m_error_message = "BEAMS twice";
return;
}
if (ties_read) {
NedResource::m_error_message = "BEAMS after TIES";
return;
}
beams_read = TRUE;
restoreBeams(fp);
if (NedResource::m_error_message != NULL) {
return;
}
continue;
}
if (!strcmp(buffer, "TIES")) {
if (ties_read) {
NedResource::m_error_message = "TIES twice";
return;
}
ties_read = TRUE;
restoreTies(fp);
if (NedResource::m_error_message != NULL) {
return;
}
continue;
}
if (!strcmp(buffer, "TUPLETS")) {
if (tuplets_read) {
NedResource::m_error_message = "TUPLETS twice";
return;
}
tuplets_read = TRUE;
restoreTuplets(fp);
if (NedResource::m_error_message != NULL) {
return;
}
continue;
}
if (!strcmp(buffer, "FREE_PLACEABLES")) {
if (free_placeables_read) {
NedResource::m_error_message = "FREE_PLACEABLES twice";
return;
}
free_placeables_read = TRUE;
restoreFreePlaceables(fp);
if (NedResource::m_error_message != NULL) {
return;
}
continue;
}
if (!strcmp(buffer, "(")) {
if (beams_read) {
NedResource::m_error_message = "Notes after BEAMS";
return;
}
if (ties_read) {
NedResource::m_error_message = "Notes after TIES";
return;
}
if ((chord_or_rest = NedChordOrRest::restoreChordOrRest(fp, this)) != NULL) {
m_chord_or_rests = g_list_append(m_chord_or_rests, chord_or_rest);
}
else {
return;
}
}
else {
NedResource::m_error_message = "( BEAMS, TIES, VOICE, STAFF SYSTEM or PAGE expected";
return;
}
}
}
void NedVoice::restoreBeams(FILE *fp) {
char buffer[128];
int marker;
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( TIES VOICE STAFF SYSTEM, FREE_PLACEABLES, or PAGE expected";
return;
}
if (!strcmp(buffer, "TUPLETS") || !strcmp(buffer, "TIES") || !strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE") ||
!strcmp(buffer, "FREE_PLACEABLES")) {
NedResource::unreadWord(buffer);
return;
}
if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( TIES VOICE STAFF SYSTEM or PAGE expected(1)";
return;
}
while (!strcmp(buffer, "(")) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "u or d expected";
return;
}
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "marker expected(1)";
return;
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = ", or ) expected";
return;
}
while (strcmp(buffer, ")")) {
if (buffer[0] != ',') {
NedResource::m_error_message = ", or ) expected";
return;
}
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "marker expected(2)";
return;
}
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = ", or ) expected";
return;
}
}
if (strcmp(buffer, ")")) {
NedResource::m_error_message = ", or ) expected";
return;
}
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( TIES VOICE STAFF SYSTEM or PAGE expected(2)";
return;
}
if (!strcmp(buffer, "TUPLETS") || !strcmp(buffer, "TIES") || !strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") ||
!strcmp(buffer, "FREE_PLACEABLES") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE")) {
NedResource::unreadWord(buffer);
return;
}
else if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( TIES VOICE STAFF SYSTEM or PAGE expected(3)";
return;
}
}
}
void NedVoice::restoreTuplets(FILE *fp) {
char buffer[128];
int marker;
int tuplet_val;
NedChordOrRest *chord_or_rest;
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( TIES VOICE STAFF SYSTEM, FREE_PLACEABLES or PAGE expected";
return;
}
if (!strcmp(buffer, "TIES") || !strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE") ||
!strcmp(buffer, "FREE_PLACEABLES")) {
NedResource::unreadWord(buffer);
return;
}
if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( TIES VOICE STAFF SYSTEM or PAGE expected(4)";
return;
}
while (!strcmp(buffer, "(")) {
if (!NedResource::readInt(fp, &tuplet_val) || tuplet_val < 2 || tuplet_val > 13) {
NedResource::m_error_message = "tuplet val expected";
return;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != ';' || buffer[1] != '\0') {
NedResource::m_error_message = "; expected";
return;
}
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "marker expected(1)";
return;
}
chord_or_rest = (NedChordOrRest *) NedResource::getAdressOfMarker(marker);
chord_or_rest->setTupletVal(tuplet_val);
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = ", or ) expected";
return;
}
while (strcmp(buffer, ")")) {
if (buffer[0] != ',') {
NedResource::m_error_message = ", or ) expected";
return;
}
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "marker expected(2)";
return;
}
chord_or_rest = (NedChordOrRest *) NedResource::getAdressOfMarker(marker);
chord_or_rest->setTupletVal(tuplet_val);
if (!NedResource::readWord(fp, buffer) || buffer[1] != '\0') {
NedResource::m_error_message = ", or ) expected";
return;
}
}
chord_or_rest->setLastTupletFlag(TRUE);
if (strcmp(buffer, ")")) {
NedResource::m_error_message = ", or ) expected";
return;
}
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( FREE_PLACEABLES TIES TUPLETS VOICE STAFF SYSTEM or PAGE expected";
return;
}
if (!strcmp(buffer, "TIES") || !strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE") || !strcmp(buffer, "FREE_PLACEABLES")) {
NedResource::unreadWord(buffer);
return;
}
else if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( FREE_PLACEABLES TIES VOICE STAFF SYSTEM or PAGE expected";
return;
}
}
}
void NedVoice::restoreTies(FILE *fp) {
char buffer[128];
int marker1, marker2;
NedNote *note1, *note2;
double tie_offs = 0.0;
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( VOICE STAFF SYSTEM, FREE_PLACEABLES, or PAGE expected";
return;
}
if (!strcmp(buffer, "TUPLETS") ||!strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE") ||
!strcmp(buffer, "FREE_PLACEABLES")) {
NedResource::unreadWord(buffer);
return;
}
if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( VOICE STAFF SYSTEM or PAGE expected";
return;
}
while (!strcmp(buffer, "(")) {
if (!NedResource::readInt(fp, &marker1)) {
NedResource::m_error_message = "address expected";
return;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != ',' || buffer[1] != '\0') {
NedResource::m_error_message = ", expected";
return;
}
if (!NedResource::readInt(fp, &marker2)) {
NedResource::m_error_message = "address expected";
return;
}
if (getMainWindow()->getFileVersion() > 8) {
if (!NedResource::readWord(fp, buffer) || buffer[0] != ',' || buffer[1] != '\0') {
NedResource::m_error_message = ", expected";
return;
}
if (!NedResource::readFloat(fp, &tie_offs)) {
NedResource::m_error_message = "tie offset expected";
return;
}
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != ')' || buffer[1] != '\0') {
NedResource::m_error_message = ") expected";
return;
}
note1 = (NedNote *) NedResource::getAdressOfMarker(marker1);
note2 = (NedNote *) NedResource::getAdressOfMarker(marker2);
NedNote::setTies(note1, note2);
note1->setTieOffset(tie_offs);
if (!NedResource::readWord(fp, buffer)) {
if (feof(fp)) return;
NedResource::m_error_message = "( VOICE STAFF SYSTEM or PAGE expected";
return;
}
if (!strcmp(buffer, "VOICE") || !strcmp(buffer, "STAFF") || !strcmp(buffer, "SYSTEM") || !strcmp(buffer, "PAGE") || !strcmp(buffer, "TUPLETS") || !strcmp(buffer, "FREE_PLACEABLES") ) {
NedResource::unreadWord(buffer);
return;
}
if (strcmp(buffer, "(")) {
NedResource::m_error_message = "( FREE_PLACEABLES TUPLETS VOICE STAFF SYSTEM or PAGE expected";
return;
}
}
}
void NedVoice::restoreFreePlaceables(FILE *fp) {
char buffer[128];
int marker, i;
double x, y;
unsigned int kind, tempo, midi_vol;
int sign_kind, midi_pgm;
char chordcode[128];
unsigned int channel;
int en_chn;
int chordname;
int dot = 0;
int chordstatus;
NedVolumeSign *volsign;
NedChordOrRest *chord_or_rest;
NedSlurPoint *sp[3];
NedLinePoint *startp, *endp, *midp = NULL;
int vol_diff, octave_shift, tempo_diff;
char ffamily[1024], xtext[1024], *xfamily;
char root_text[1024], down_text[1024], up_text[1024];
double fsize;
double fontsize = 0.5;
int en_vol, en_tpo;
int slant, weight;
int segno_sign = 0, anchor = 0;
PangoStyle cslant;
PangoWeight cweight;
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "(")) {
NedResource::m_error_message = "( expected";
return;
}
while (!strcmp(buffer, "(")) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "<")) {
NedResource::m_error_message = "< expected";
return;
}
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "address expected";
return;
}
chord_or_rest = (NedChordOrRest *) NedResource::getAdressOfMarker(marker);
if (!NedResource::readFloat(fp, &x)) {
NedResource::m_error_message = "x value expected";
return;
}
if (!NedResource::readFloat(fp, &y)) {
NedResource::m_error_message = "y value expected";
return;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ">")) {
NedResource::m_error_message = "> expected";
return;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "Free Placeable Spec expected";
return;
}
if (!strcmp(buffer, "VOLUME_SIGN")) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "Volume spec expected";
return;
}
if (!strcmp(buffer, "VOL_PPP")) {
volsign = new NedVolumeSign(VOL_PPP, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_PP")) {
volsign = new NedVolumeSign(VOL_PP, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_P")) {
volsign = new NedVolumeSign(VOL_P, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_MP")) {
volsign = new NedVolumeSign(VOL_MP, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_SP")) {
volsign = new NedVolumeSign(VOL_SP, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_MF")) {
volsign = new NedVolumeSign(VOL_MF, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_SF")) {
volsign = new NedVolumeSign(VOL_SF, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_F")) {
volsign = new NedVolumeSign(VOL_F, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_FF")) {
volsign = new NedVolumeSign(VOL_FF, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "VOL_FFF")) {
volsign = new NedVolumeSign(VOL_FFF, chord_or_rest, x, y, true);
}
else {
NedResource::m_error_message = "Wrong volume sig";
return;
}
if (getMainWindow()->getFileVersion() > 6) {
if (!NedResource::readInt(fp, (int *) &midi_vol) || midi_vol < 0 || midi_vol > 127) {
NedResource::m_error_message = "Midi volume expected";
return;
}
volsign->m_midi_volume = midi_vol;
}
}
else if (!strcmp(buffer, "TEMPO_SIGN")) {
if (!NedResource::readUnsignedInt(fp, &kind) || (kind != WHOLE_NOTE && kind != NOTE_2 &&
kind != NOTE_4 && kind != NOTE_8 && kind != NOTE_16) ) {
NedResource::m_error_message = "TEMPO kind expected";
return;
}
if (getMainWindow()->getFileVersion() > 21) {
if (!NedResource::readInt(fp, &dot) || dot < 0 || dot > 1) {
NedResource::m_error_message = "dot information expected";
return;
}
}
if (!NedResource::readUnsignedInt(fp, &tempo) || tempo < 10 || tempo > 999) {
NedResource::m_error_message = "TEMPO val expected";
return;
}
if (dot) {
kind = 3 * kind / 2;
}
new NedTempoSign(kind, tempo, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "FREE_SPACER")) {
new NedFreeSpacer(getMainWindow(), chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "FREE_CHORD")) {
if (!NedResource::readWordOfLength(fp, chordcode)) {
NedResource::m_error_message = "CHORD_CODE kind expected";
return;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != ',' || buffer[1] != '\0') {
NedResource::m_error_message = ", expected";
return;
}
if (!NedResource::readInt(fp, &chordname) || chordname < 0 || chordname > 1) {
NedResource::m_error_message = "chordname val expected";
return;
}
if (!NedResource::readWord(fp, buffer) || buffer[0] != ',' || buffer[1] != '\0') {
NedResource::m_error_message = "expected";
return;
}
if (!NedResource::readHex(fp, &chordstatus)) {
NedResource::m_error_message = "chordstatus val expected";
return;
}
new NedFreeChord(chordcode, chordname, chordstatus, getMainWindow(), chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "FREE_SIGN")) {
if (!NedResource::readInt(fp, &sign_kind) || sign_kind < SIGN_SEGNO || sign_kind > SIGN_CODA) {
NedResource::m_error_message = "SIGN kind expected";
return;
}
new NedFreeSign(sign_kind, chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "FREE_CHORD_NAME")) {
if (!NedResource::readWordOfLength(fp, root_text)) {
NedResource::m_error_message = "root text expected";
return;
}
if (!NedResource::readWordOfLength(fp, down_text)) {
NedResource::m_error_message = "down text expected";
return;
}
if (!NedResource::readWordOfLength(fp, up_text)) {
NedResource::m_error_message = "up text expected";
return;
}
fontsize = 0.5;
if (getMainWindow()->getFileVersion() > 17) {
if (!NedResource::readFloat(fp, &fontsize)) {
NedResource::m_error_message = "font size expected(2)";
return;
}
}
new NedChordName(getMainWindow()->getDrawingArea(), root_text, down_text, up_text, fontsize,
chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "FREE_TEXT")) {
if (!NedResource::readWordOfLength(fp, xtext)) {
NedResource::m_error_message = "text expected";
return;
}
if (!NedResource::readWordOfLength(fp, ffamily)) {
NedResource::m_error_message = "font family expected";
return;
}
if ((xfamily = (char *) g_try_malloc(strlen(ffamily) + 1)) == NULL) {
NedResource::Abort("NedVoice::restoreFreePlaceables: allocation failed");
}
strcpy(xfamily, ffamily);
if (!NedResource::readFloat(fp, &fsize)) {
NedResource::m_error_message = "font size expected";
return;
}
if (!NedResource::readInt(fp, &en_vol)) {
NedResource::m_error_message = "enable volume expected";
return;
}
if (!NedResource::readUnsignedInt(fp, &midi_vol)) {
NedResource::m_error_message = "volume expected";
return;
}
if (!NedResource::readInt(fp, &en_tpo)) {
NedResource::m_error_message = "enable tempo expected";
return;
}
if (!NedResource::readUnsignedInt(fp, &tempo)) {
NedResource::m_error_message = "tempo expected";
return;
}
channel = 1;
en_chn = false;
segno_sign = 0;
if (getMainWindow()->getFileVersion() > 11) {
if (!NedResource::readHex(fp, &segno_sign)) {
NedResource::m_error_message = "segno_sign expected";
return;
}
if (getMainWindow()->getFileVersion() > 20) {
if (!NedResource::readInt(fp, &midi_pgm)) {
NedResource::m_error_message = "midi_pgm expected";
return;
}
}
else midi_pgm = -1;
if (getMainWindow()->getFileVersion() > 22) {
if (!NedResource::readInt(fp, &en_chn)) {
NedResource::m_error_message = "enable channel expected";
return;
}
if (!NedResource::readUnsignedInt(fp, &channel)) {
NedResource::m_error_message = "channel expected";
return;
}
}
if (!NedResource::readInt(fp, &anchor)) {
NedResource::m_error_message = "anchor expected";
return;
}
}
if (!NedResource::readInt(fp, &slant)) {
NedResource::m_error_message = "slant expected";
return;
}
switch (slant) {
case WRITTEN_SLANT_NORMAL: cslant = PANGO_STYLE_NORMAL; break;
case WRITTEN_SLANT_ITALIC: cslant = PANGO_STYLE_ITALIC; break;
case WRITTEN_SLANT_OBLIQUE: cslant = PANGO_STYLE_OBLIQUE; break;
default: NedResource::m_error_message = "unknown slant"; return;
}
if (!NedResource::readInt(fp, &weight)) {
NedResource::m_error_message = "weight expected";
return;
}
switch (weight) {
case WRITTEN_WEIGHT_NORMAL: cweight = PANGO_WEIGHT_NORMAL; break;
case WRITTEN_WEIGHT_BOLD: cweight = PANGO_WEIGHT_BOLD; break;
default: NedResource::m_error_message = "unknown weight"; return;
}
new NedFreeText(xtext, getMainWindow()->getDrawingArea(), anchor, tempo, en_tpo != 0, midi_vol, en_vol != 0, segno_sign,
midi_pgm, channel, en_chn != 0, xfamily, fsize, cslant, cweight,
chord_or_rest, x, y, true);
}
else if (!strcmp(buffer, "SLUR")) {
sp[0] = new NedSlurPoint(NULL, 0, chord_or_rest, x, y, true);
for (i = 1; i < 3; i++) {
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "address expected";
return;
}
chord_or_rest = (NedChordOrRest *) NedResource::getAdressOfMarker(marker);
if (!NedResource::readFloat(fp, &x)) {
NedResource::m_error_message = "x value expected";
return;
}
if (!NedResource::readFloat(fp, &y)) {
NedResource::m_error_message = "y value expected";
return;
}
sp[i] = new NedSlurPoint(NULL, i, chord_or_rest, x, y, true);
}
new NedSlur(sp);
}
else if (!strncmp(buffer, "LINE_", strlen("LINE_"))) {
startp = new NedLinePoint(NULL, 0, chord_or_rest, x, y, true);
if (!strcmp(buffer, "LINE_CRESCENDO") || !strcmp(buffer, "LINE_DECRESCENDO")) {
if (!NedResource::readInt(fp, &vol_diff)) {
NedResource::m_error_message = "vol_diff expected";
return;
}
}
if (!strcmp(buffer, "LINE_ACCELERATO") || !strcmp(buffer, "LINE_RITARDANDO")) {
if (!NedResource::readInt(fp, &tempo_diff)) {
NedResource::m_error_message = "tempo_diff expected";
return;
}
}
if (!strcmp(buffer, "LINE_OCTAVATION")) {
if (!NedResource::readInt(fp, &octave_shift)) {
NedResource::m_error_message = "octave_shift expected";
return;
}
}
if (!strcmp(buffer, "LINE_ACCELERATO") || !strcmp(buffer, "LINE_RITARDANDO")) {
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "address expected";
return;
}
chord_or_rest = (NedChordOrRest *) NedResource::getAdressOfMarker(marker);
if (!NedResource::readFloat(fp, &x)) {
NedResource::m_error_message = "x value expected";
return;
}
if (!NedResource::readFloat(fp, &y)) {
NedResource::m_error_message = "y value expected";
return;
}
midp = new NedLinePoint(NULL, 1, chord_or_rest, x, y, true);
}
if (!NedResource::readInt(fp, &marker)) {
NedResource::m_error_message = "address expected";
return;
}
chord_or_rest = (NedChordOrRest *) NedResource::getAdressOfMarker(marker);
if (!NedResource::readFloat(fp, &x)) {
NedResource::m_error_message = "x value expected";
return;
}
if (!NedResource::readFloat(fp, &y)) {
NedResource::m_error_message = "y value expected";
return;
}
endp = new NedLinePoint(NULL, 1, chord_or_rest, x, y, true);
if (!strcmp(buffer, "LINE_CRESCENDO")) {
new NedCrescendo(startp, endp, false, vol_diff);
}
else if (!strcmp(buffer, "LINE_DECRESCENDO")) {
new NedCrescendo(startp, endp, true, vol_diff);
}
else if (!strcmp(buffer, "LINE_OCTAVATION")) {
new NedOctavation(startp, endp, NULL /* dummy */, octave_shift);
}
else if (!strcmp(buffer, "LINE_ACCELERATO")) {
new NedAcceleration(startp, midp, endp, false, tempo_diff);
}
else if (!strcmp(buffer, "LINE_RITARDANDO")) {
new NedAcceleration(startp, midp, endp, true, tempo_diff);
}
else {
NedResource::m_error_message = "LINE_CRESCENDO, LINE_DECRESCENDO, LINE_ACCELERATO, LINE_RITARDANDO, or LINE_OCTAVATION expected";
return;
}
}
else {
NedResource::m_error_message = "VOLUME_SIG, SLUR, TEMPO_SIGN, FREE_SIGN, FREE_TEXT, FREE_SPACER, or FREE_CHORD expected";
return;
}
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, ")")) {
NedResource::m_error_message = ") expected";
return;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "( TUPLETS, BEAMS, TIES, FREE_PLACEABLES, VOICE, STAFF SYSTEM or PAGE expected";
}
}
NedResource::unreadWord(buffer);
}
bool NedVoice::detectVoices(unsigned int *voice_mask, unsigned long long *e_time) {
GList *lptr;
bool not_empty = false;
NedMeasure *measure;
for(lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
if ((((NedChordOrRest *) lptr->data)->getType() == TYPE_REST && !((NedChordOrRest *) lptr->data)->isHidden()) || ((NedChordOrRest *) lptr->data)->getType() == TYPE_CHORD ||
((NedChordOrRest *) lptr->data)->getType() == TYPE_GRACE) {
*voice_mask |= (1 << m_voice_nr);
//measure = getSystem()->getMeasure(((NedChordOrRest *) lptr->data)->getMidiTime());
measure = ((NedChordOrRest *) lptr->data)->m_measure;
if (((NedChordOrRest *) lptr->data)->getType() == TYPE_CHORD || ((NedChordOrRest *) lptr->data)->getType() == TYPE_GRACE) {
not_empty = true;
if (measure->midi_end > *e_time) {
*e_time = measure->midi_end;
}
}
}
}
return not_empty;
}
void NedVoice::exportLilypondSpecMeasure(FILE *fp, unsigned int special, SpecialMeasure *spec_measure, bool *in_alternative, int measure_number) {
bool spec_written;
spec_written = false;
switch (special & START_TYPE_MASK) {
case REP1START: fprintf(fp, "\n\t}\n\t\\alternative {\n\t{\n\t"), *in_alternative = true; spec_written = true; break;
}
switch (special & END_TYPE_MASK) {
case REP2END: fprintf(fp, "\n\t}}\n\t"); *in_alternative = false; spec_written = true;break;
}
switch (special & REP_TYPE_MASK) {
case REPEAT_CLOSE: fprintf(fp, "\n\t}\n\t"); spec_written = true;
if ((special & START_TYPE_MASK) == REP2START) {
fprintf(fp, "\n\t{\n\t");
}
else if (*in_alternative) {
fprintf(fp, "\n\t {} }\n\t");
*in_alternative = false;
}
break;
case REPEAT_OPEN: fprintf(fp, "\n\t\\repeat volta 2 {\n\t"); spec_written = true; break;
case REPEAT_OPEN_CLOSE: fprintf(fp, "\n\t}\n\t");
if (*in_alternative) {
fprintf(fp, "\n\t {} }\n\t");
*in_alternative = false;
}
fprintf(fp, "\n\t\\repeat volta 2 {\n\t"); spec_written = true;
break;
case END_BAR: fprintf(fp, "\n\t\\bar \"|.\"\n\t"); spec_written = true; break;
case DOUBLE_BAR: fprintf(fp, "\n\t\\bar \"||\"\n\t"); spec_written = true; break;
}
switch (special & TIMESIG) {
case TIMESIG: fprintf(fp, " \\time %d/%d ", spec_measure->numerator, spec_measure->denominator);
spec_written = true;
break;
}
if (!spec_written) {
fprintf(fp, "| %% %d\n\t", measure_number);
}
}
void NedVoice::exportLilyGuitarChordnames(FILE *fp, int *last_line, unsigned int *midi_len, bool last_system,
unsigned long long end_time, bool *in_alternative, bool with_break) {
GList *lptr, *lptr2, *staff_elem_list;
bool dummy4;
NedMeasure *old_measure = NULL, *measure;
SpecialMeasure *spec_measure;
unsigned int special;
bool in_tuplet = false;
unsigned int dummy3;
NedSlur *dummy2;
int dummy5;
bool first = true;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr), first = false) {
//measure = getSystem()->getMeasure(((NedChordOrRest *) lptr->data)->getMidiTime());
measure = ((NedChordOrRest *) lptr->data)->m_measure;
if (measure != old_measure && measure->getMeasureNumber() > 1) {
spec_measure = getMainWindow()->getSpecialMeasure(measure->getMeasureNumber());
if (spec_measure != NULL && !first ) {
special = spec_measure->type;
exportLilypondSpecMeasure(fp, special, spec_measure, in_alternative, measure->getMeasureNumber());
}
else {
fprintf(fp, "| %% %d\n\t", measure->getMeasureNumber());
}
}
if (last_system && ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_REST | TYPE_CHORD)) != 0) && ((NedChordOrRest *) lptr->data)->getMidiTime() >= end_time) {
break;
}
if (m_voice_nr == 0) {
staff_elem_list = m_staff->getStaffElements(((NedChordOrRest *) lptr->data)->getMidiTime());
if (staff_elem_list != NULL) {
for (lptr2 = g_list_first(staff_elem_list); lptr2; lptr2 = g_list_next(staff_elem_list)) {
((NedChordOrRest *) lptr2->data)->exportLilyPond(fp, last_line, midi_len, &dummy2, &dummy3, &dummy4, &dummy4, &dummy5, false);
}
g_list_free(staff_elem_list);
}
}
old_measure = measure;
if (((NedChordOrRest *) lptr->data)->getTupletVal() && !in_tuplet) {
fprintf(fp, " \\times %d/%d { ", NedResource::m_tuplet_tab[((NedChordOrRest *) lptr->data)->getTupletVal()],
((NedChordOrRest *) lptr->data)->getTupletVal());
in_tuplet = true;
}
((NedChordOrRest *) lptr->data)->exportLilyGuitarChordnames(fp, last_line, midi_len);
if (((NedChordOrRest *) lptr->data)->hasLastTupletFlag()) {
fprintf(fp, " } ");
in_tuplet = false;
}
}
if (with_break) {
fprintf(fp, " \\break ");
}
measure = getSystem()->getLastMeasure();
spec_measure = getMainWindow()->getSpecialMeasure(measure->getMeasureNumber());
if (spec_measure != NULL) {
special = spec_measure->type;
exportLilypondSpecMeasure(fp, special, spec_measure, in_alternative, measure->getMeasureNumber());
}
}
void NedVoice::exportLilyFreeChordName(FILE *fp, int *last_line, unsigned int *midi_len, bool last_system,
unsigned long long end_time, bool *in_alternative, bool with_break) {
GList *lptr, *lptr2, *staff_elem_list;
bool dummy4;
NedMeasure *old_measure = NULL, *measure;
SpecialMeasure *spec_measure;
unsigned int special;
bool in_tuplet = false;
unsigned int dummy3;
NedSlur *dummy2;
int dummy5;
bool first = true;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr), first = false) {
//measure = getSystem()->getMeasure(((NedChordOrRest *) lptr->data)->getMidiTime());
measure = ((NedChordOrRest *) lptr->data)->m_measure;
if (measure != old_measure && measure->getMeasureNumber() > 1) {
spec_measure = getMainWindow()->getSpecialMeasure(measure->getMeasureNumber());
if (spec_measure != NULL && !first ) {
special = spec_measure->type;
exportLilypondSpecMeasure(fp, special, spec_measure, in_alternative, measure->getMeasureNumber());
}
else {
fprintf(fp, "| %% %d\n\t", measure->getMeasureNumber());
}
}
if (last_system && ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_REST | TYPE_CHORD)) != 0) && ((NedChordOrRest *) lptr->data)->getMidiTime() >= end_time) {
break;
}
if (m_voice_nr == 0) {
staff_elem_list = m_staff->getStaffElements(((NedChordOrRest *) lptr->data)->getMidiTime());
if (staff_elem_list != NULL) {
for (lptr2 = g_list_first(staff_elem_list); lptr2; lptr2 = g_list_next(staff_elem_list)) {
((NedChordOrRest *) lptr2->data)->exportLilyPond(fp, last_line, midi_len, &dummy2, &dummy3, &dummy4, &dummy4, &dummy5, false);
}
g_list_free(staff_elem_list);
}
}
old_measure = measure;
if (((NedChordOrRest *) lptr->data)->getTupletVal() && !in_tuplet) {
fprintf(fp, " \\times %d/%d { ", NedResource::m_tuplet_tab[((NedChordOrRest *) lptr->data)->getTupletVal()],
((NedChordOrRest *) lptr->data)->getTupletVal());
in_tuplet = true;
}
((NedChordOrRest *) lptr->data)->exportLilyFreeChordName(fp, last_line, midi_len);
if (((NedChordOrRest *) lptr->data)->hasLastTupletFlag()) {
fprintf(fp, " } ");
in_tuplet = false;
}
}
if (with_break) {
fprintf(fp, " \\break ");
}
measure = getSystem()->getLastMeasure();
spec_measure = getMainWindow()->getSpecialMeasure(measure->getMeasureNumber());
if (spec_measure != NULL) {
special = spec_measure->type;
exportLilypondSpecMeasure(fp, special, spec_measure, in_alternative, measure->getMeasureNumber());
}
}
void NedVoice::exportLilyPond(FILE *fp, int *last_line, unsigned int *midi_len, bool last_system,
unsigned long long end_time, bool *in_alternative, NedSlur **lily_slur, unsigned int *lyrics_map,
bool with_break, bool *guitar_chordnames, bool *chordname, int *breath_script, bool keep_beams) {
GList *lptr, *lptr2, *staff_elem_list;
bool dummy4;
NedMeasure *old_measure = NULL, *measure;
SpecialMeasure *spec_measure;
unsigned int special;
bool in_tuplet = false;
unsigned int dummy3;
NedSlur *dummy2;
int dummy5;
bool first = true;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr), first = false) {
//measure = getSystem()->getMeasure(((NedChordOrRest *) lptr->data)->getMidiTime());
measure = ((NedChordOrRest *) lptr->data)->m_measure;
if (measure != old_measure && measure->getMeasureNumber() > 1) {
spec_measure = getMainWindow()->getSpecialMeasure(measure->getMeasureNumber());
if (spec_measure != NULL && !first ) {
special = spec_measure->type;
exportLilypondSpecMeasure(fp, special, spec_measure, in_alternative, measure->getMeasureNumber());
}
else {
fprintf(fp, "| %% %d\n\t", measure->getMeasureNumber());
}
}
if (last_system && ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_REST | TYPE_CHORD)) != 0) && ((NedChordOrRest *) lptr->data)->getMidiTime() >= end_time) {
break;
}
if (m_voice_nr == 0) {
staff_elem_list = m_staff->getStaffElements(((NedChordOrRest *) lptr->data)->getMidiTime());
if (staff_elem_list != NULL) {
for (lptr2 = g_list_first(staff_elem_list); lptr2; lptr2 = g_list_next(lptr2)) {
((NedChordOrRest *) lptr2->data)->exportLilyPond(fp, last_line, midi_len, &dummy2, &dummy3, &dummy4, &dummy4, breath_script, keep_beams);
}
g_list_free(staff_elem_list);
}
}
old_measure = measure;
if (((NedChordOrRest *) lptr->data)->getTupletVal() && !in_tuplet) {
fprintf(fp, " \\times %d/%d { ", NedResource::m_tuplet_tab[((NedChordOrRest *) lptr->data)->getTupletVal()],
((NedChordOrRest *) lptr->data)->getTupletVal());
in_tuplet = true;
}
((NedChordOrRest *) lptr->data)->exportLilyPond(fp, last_line, midi_len, lily_slur, lyrics_map, guitar_chordnames, chordname, &dummy5, keep_beams);
if (((NedChordOrRest *) lptr->data)->hasLastTupletFlag()) {
fprintf(fp, " } ");
in_tuplet = false;
}
}
if (m_voice_nr == 0) {
staff_elem_list = m_staff->getStaffElements(getSystem()->getSystemEndTime());
if (staff_elem_list != NULL) {
for (lptr2 = g_list_first(staff_elem_list); lptr2; lptr2 = g_list_next(lptr2)) {
((NedChordOrRest *) lptr2->data)->exportLilyPond(fp, last_line, midi_len, &dummy2, &dummy3, &dummy4, &dummy4, breath_script, keep_beams);
}
g_list_free(staff_elem_list);
}
}
if (with_break) {
fprintf(fp, " \\break ");
}
measure = getSystem()->getLastMeasure();
spec_measure = getMainWindow()->getSpecialMeasure(measure->getMeasureNumber());
if (spec_measure != NULL) {
special = spec_measure->type;
exportLilypondSpecMeasure(fp, special, spec_measure, in_alternative, measure->getMeasureNumber());
}
}
void NedVoice::exportLilyLyrics(FILE *fp, bool last_system, int line_nr, unsigned long long end_time, int *sil_count) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->exportLilyLyrics(fp, line_nr, sil_count);
if (last_system && ((((NedChordOrRest *) lptr->data)->getType() & (TYPE_REST | TYPE_CHORD)) != 0) && ((NedChordOrRest *) lptr->data)->getMidiTime() >= end_time) {
break;
}
}
}
void NedVoice::collectLyrics(NedLyricsEditor *leditor) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->collectLyrics(leditor);
}
}
void NedVoice::setLyrics(NedCommandList *command_list, NedLyricsEditor *leditor) {
GList *lptr;
for (lptr = g_list_first(m_chord_or_rests); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->setLyrics(command_list, leditor);
}
}
nted-1.10.18/install-sh 0000775 0010410 0000764 00000032537 11520267230 011550 0000000 0000000 #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2009-04-28.21; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
-*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test -z "$d" && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
nted-1.10.18/dialogs/ 0000775 0010410 0000764 00000000000 11520270235 011233 5 0000000 0000000 nted-1.10.18/dialogs/chordnamedialog.h 0000664 0010410 0000764 00000004657 11520267217 014466 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef CHORD_NAME_DIALOG_H
#define CHORD_NAME_DIALOG_H
#include "config.h"
#include "resource.h"
#include
#include
class NedChordNameDialog {
public:
NedChordNameDialog(NedMainWindow *main_window, GtkWindow *parent, char *roottext, char *uptext, char *downtext,
double fontsize, double ydist, bool ydist_relenvant);
~NedChordNameDialog();
void getValues(bool *state, char **roottext, char **uptext, char **downtext, double *fontsize, double *ydist);
static bool isAlreadyActive() {return m_chord_name_dialog_active;}
private:
static bool m_chord_name_dialog_active;
static double m_chord_name_y_dist;
static void ResponseCallBack(GtkDialog *dialog, gint result, gpointer data);
static bool OnKeyRelease(GtkWidget *widget, GdkEventKey *event, gpointer data);
static void OnValueChanged(GtkSpinButton *spinbutton, gpointer data);
bool updateMainSpecial();
NedMainWindow *m_main_window;
GtkWidget *m_dialog;
GtkWidget *m_font_size_spin_box;
GtkWidget *m_ydist_spin_box;
GtkWidget *m_root_text_widget;
GtkWidget *m_up_text_widget;
GtkWidget *m_down_text_widget;
static double m_font_size;
char *m_root_text;
char *m_up_text;
char *m_down_text;
int m_state;
};
#endif /* CHORD_NAME_DIALOG_H */
nted-1.10.18/dialogs/textdialog.h 0000664 0010410 0000764 00000007266 11520267217 013511 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef TEXT_DIALOG_H
#define TEXT_DIALOG_H
#include "config.h"
#include "resource.h"
#include
#include
class NedTextDialog {
public:
NedTextDialog(GtkWindow *parent, char *text, int anchor, unsigned int tempo, bool enable_tempo, unsigned int volume, bool enable_volume,
unsigned short segno_sign, int midi_program, int channel, bool enable_channel, const char *font_family, double font_size, PangoStyle font_slant, PangoWeight font_weight);
void getValues(bool *state, char **text, int *anchor, unsigned int *tempo, bool *enable_tempo, unsigned int *volume, bool *enable_volume,
unsigned short *segno_sign, int *midi_program, unsigned int *channel, bool *enable_channel, const char **font_family, double *font_size, PangoStyle *font_slant, PangoWeight *font_weight);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
static void FontCallBack(GtkButton *button, gpointer data);
static void TempoToggled(GtkToggleButton *button, gpointer data);
static void VolumeToggled(GtkToggleButton *button, gpointer data);
static void InstrToggled(GtkToggleButton *button, gpointer data);
static void ChannelToggled(GtkToggleButton *button, gpointer data);
static gboolean OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data);
void retrieveFontParams();
GtkWidget *m_text_widget;
GtkWidget *m_font_button;
GtkWidget *m_tempo_spin_box;
GtkWidget *m_volume_spin_box;
GtkWidget *m_channel_spin_box;
GtkWidget *m_check_tempo;
GtkWidget *m_check_volume;
GtkWidget *m_check_instr;
GtkWidget *m_check_channel;
GtkWidget *m_anchor_left;
GtkWidget *m_anchor_mid;
GtkWidget *m_anchor_right;
GtkWidget *m_segno_none;
GtkWidget *m_ds_al_fine;
GtkWidget *m_ds_al_coda;
GtkWidget *m_d_capo_al_fine;
GtkWidget *m_d_capo_al_coda;
GtkWidget *m_fine;
GtkWidget *m_al_coda;
GtkWidget *m_instrument_list;
GtkObject *m_instrument_adjustment;
GtkWidget *m_main_h_box;
GtkWidget *m_instrument_scroll;
unsigned int m_tempo;
unsigned int m_volume;
bool m_enable_tempo, m_enable_volume;
unsigned short m_segno_sign;
int m_midi_program_number;
int m_channel;
bool m_enable_channel;
int m_anchor;
char *m_text;
const char *m_font_family;
double m_font_size;
PangoStyle m_font_slant;
PangoWeight m_font_weight;
bool m_state;
static const char *m_static_font_family;
static double m_static_font_size;
static PangoStyle m_static_font_slant;
static PangoWeight m_static_font_weight;
};
#endif /* TEXT_DIALOG_H */
nted-1.10.18/dialogs/volumedialog.cpp 0000664 0010410 0000764 00000005512 11520267217 014357 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "volumedialog.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
NedVolumeDialog::NedVolumeDialog(GtkWindow *parent, int volume, bool relative) {
GtkWidget *dialog;
GtkWidget *lab;
GtkWidget *hbox;
dialog = gtk_dialog_new_with_buttons(_("Set Volume"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
if (relative) {
m_volume_spin_box = gtk_spin_button_new_with_range (-127.0, 127.0, 1.0);
}
else {
m_volume_spin_box = gtk_spin_button_new_with_range (0.0, 127.0, 1.0);
}
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_volume_spin_box), volume);
lab = gtk_label_new(_("volume:"));
hbox = gtk_hbox_new(FALSE, 8);
gtk_box_pack_start(GTK_BOX(hbox), lab, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), m_volume_spin_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), hbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedVolumeDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedVolumeDialog *volume_dialog = (NedVolumeDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
volume_dialog->m_state = TRUE;
break;
default:
volume_dialog->m_state = FALSE;
break;
}
volume_dialog->m_volume = (int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(volume_dialog->m_volume_spin_box)) + 0.4);
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedVolumeDialog::getValues(bool *state, int *volume) {
*state = m_state;
*volume = m_volume;
}
nted-1.10.18/dialogs/chordnamedialog.cpp 0000664 0010410 0000764 00000021025 11520267217 015005 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "chordnamedialog.h"
#include "mainwindow.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
double NedChordNameDialog::m_font_size = 0.4;
bool NedChordNameDialog::m_chord_name_dialog_active = false;
double NedChordNameDialog::m_chord_name_y_dist = 0.4;
NedChordNameDialog::NedChordNameDialog(NedMainWindow *main_window, GtkWindow *parent, char *roottext, char *uptext, char *downtext, double fontsize,
double ydist, bool ydist_relenvant) :
m_main_window(main_window) {
if (fontsize > 0.0) {
m_font_size = fontsize;
}
if (ydist > 0.0) {
m_chord_name_y_dist = ydist;
}
GtkWidget *text_frame;
GtkWidget *size_frame;
GtkWidget *ydist_frame;
GtkWidget *main_h_box;
GtkWidget *text_h_box;
GtkWidget *spin_button_vbox;
GtkWidget *vbox;
if (m_main_window) {
m_dialog = gtk_dialog_new_with_buttons(_("Chordname"), NULL, (GtkDialogFlags) 0,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
}
else {
m_dialog = gtk_dialog_new_with_buttons(_("Chordname"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
}
gtk_window_set_transient_for(GTK_WINDOW (m_dialog), parent);
g_signal_connect(m_dialog, "response", G_CALLBACK (ResponseCallBack), (void *) this);
text_frame = gtk_frame_new(_("chordname"));
text_h_box = gtk_hbox_new(FALSE, 2);
vbox = gtk_vbox_new(FALSE, 2);
m_root_text_widget = gtk_entry_new_with_max_length(10);
if (roottext != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_root_text_widget), roottext);
}
m_up_text_widget = gtk_entry_new_with_max_length(10);
if (uptext != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_up_text_widget), uptext);
}
m_down_text_widget = gtk_entry_new_with_max_length(10);
if (downtext != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_down_text_widget), downtext);
}
size_frame = gtk_frame_new(_("size"));
m_font_size_spin_box = gtk_spin_button_new_with_range (0.3, 0.5, 0.1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_font_size_spin_box), m_font_size);
ydist_frame = gtk_frame_new(_("position"));
m_ydist_spin_box = gtk_spin_button_new_with_range (0.01, 2.0, 0.05);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_ydist_spin_box), m_chord_name_y_dist);
if (!ydist_relenvant) {
gtk_widget_set_sensitive(m_ydist_spin_box, FALSE);
}
spin_button_vbox = gtk_hbox_new(FALSE, 2);
main_h_box = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(text_h_box), m_root_text_widget, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), m_up_text_widget, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), m_down_text_widget, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(text_h_box), vbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(text_frame), text_h_box);
gtk_container_add (GTK_CONTAINER(size_frame), m_font_size_spin_box);
gtk_container_add (GTK_CONTAINER(ydist_frame), m_ydist_spin_box);
gtk_box_pack_start(GTK_BOX(main_h_box), text_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(spin_button_vbox), size_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(spin_button_vbox), ydist_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_h_box), spin_button_vbox, FALSE, FALSE, 0);
m_chord_name_dialog_active = true;
if (m_main_window) {
g_signal_connect(m_root_text_widget, "key-release-event", G_CALLBACK (OnKeyRelease), (void *) this);
g_signal_connect(m_up_text_widget, "key-release-event", G_CALLBACK (OnKeyRelease), (void *) this);
g_signal_connect(m_down_text_widget, "key-release-event", G_CALLBACK (OnKeyRelease), (void *) this);
g_signal_connect(m_font_size_spin_box, "value-changed", G_CALLBACK (OnValueChanged), (void *) this);
g_signal_connect(m_ydist_spin_box, "value-changed", G_CALLBACK (OnValueChanged), (void *) this);
}
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(m_dialog)->vbox), main_h_box);
gtk_widget_show_all (m_dialog);
gtk_dialog_run(GTK_DIALOG(m_dialog));
}
bool NedChordNameDialog::updateMainSpecial() {
const gchar *newtext;
char *newroottext, *newuptext, *newdowntext;
newtext = gtk_entry_get_text(GTK_ENTRY(m_root_text_widget));
if (strlen(newtext) > 0) {
newroottext = strdup(newtext);
newtext = gtk_entry_get_text(GTK_ENTRY(m_up_text_widget));
newuptext = NULL;
if (strlen(newtext) > 0) {
newuptext = strdup(newtext);
}
newdowntext = NULL;
newtext = gtk_entry_get_text(GTK_ENTRY(m_down_text_widget));
if (strlen(newtext) > 0) {
newdowntext = strdup(newtext);
}
m_font_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m_font_size_spin_box));
m_chord_name_y_dist = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m_ydist_spin_box));
m_main_window->setChorNameInfo(newroottext, newuptext, newdowntext, m_font_size, m_chord_name_y_dist);
return true;
}
return false;
}
void NedChordNameDialog::ResponseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedChordNameDialog *font_name_dialog = (NedChordNameDialog *) data;
const gchar *newtext;
if (font_name_dialog->m_main_window) {
switch (result) {
case GTK_RESPONSE_ACCEPT:
if (font_name_dialog->updateMainSpecial()) {
break;
} // no break is correct !!
default:
font_name_dialog->m_main_window->resetSpecialType();
delete font_name_dialog;
break;
}
return;
}
switch (result) {
case GTK_RESPONSE_ACCEPT:
font_name_dialog->m_state = TRUE;
break;
default:
font_name_dialog->m_state = FALSE;
break;
}
if (font_name_dialog->m_state) {
font_name_dialog->m_root_text = NULL;
newtext = gtk_entry_get_text(GTK_ENTRY(font_name_dialog->m_root_text_widget));
NedResource::removeNonAsciiFromUTF8String(newtext);
if (strlen(newtext) > 0) {
font_name_dialog->m_root_text = strdup(newtext);
}
else {
font_name_dialog->m_state = false;
}
font_name_dialog->m_up_text = NULL;
newtext = gtk_entry_get_text(GTK_ENTRY(font_name_dialog->m_up_text_widget));
if (strlen(newtext) > 0) {
NedResource::removeNonAsciiFromUTF8String(newtext);
if (strlen(newtext) > 0) {
font_name_dialog->m_up_text = strdup(newtext);
}
}
font_name_dialog->m_down_text = NULL;
newtext = gtk_entry_get_text(GTK_ENTRY(font_name_dialog->m_down_text_widget));
if (strlen(newtext) > 0) {
NedResource::removeNonAsciiFromUTF8String(newtext);
if (strlen(newtext) > 0) {
font_name_dialog->m_down_text = strdup(newtext);
}
}
font_name_dialog->m_font_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(font_name_dialog->m_font_size_spin_box));
font_name_dialog->m_chord_name_y_dist = gtk_spin_button_get_value(GTK_SPIN_BUTTON(font_name_dialog->m_ydist_spin_box));
}
delete font_name_dialog;
}
bool NedChordNameDialog::OnKeyRelease(GtkWidget *widget, GdkEventKey *event, gpointer data) {
NedChordNameDialog *font_name_dialog = (NedChordNameDialog *) data;
font_name_dialog->updateMainSpecial();
return FALSE;
}
void NedChordNameDialog::OnValueChanged(GtkSpinButton *spinbutton, gpointer data) {
NedChordNameDialog *font_name_dialog = (NedChordNameDialog *) data;
font_name_dialog->updateMainSpecial();
}
NedChordNameDialog::~NedChordNameDialog() {
gtk_widget_destroy (GTK_WIDGET(m_dialog));
m_chord_name_dialog_active = false;
}
void NedChordNameDialog::getValues(bool *state, char **roottext, char **uptext, char **downtext, double *fontsize, double *ydist) {
*state = m_state;
*roottext = m_root_text;
*uptext = m_up_text;
*downtext = m_down_text;
*fontsize = m_font_size;
*ydist = m_chord_name_y_dist;
}
nted-1.10.18/dialogs/linesdialog.h 0000664 0010410 0000764 00000003474 11520267217 013634 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef LINES_DIALOG_H
#define LINES_DIALOG_H
#include "config.h"
#include
#include
#include "line.h"
class NedLinesDialog {
public:
NedLinesDialog(GtkWindow *parent);
void getValues(bool *state, int *linetype);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static gboolean draw_menu(GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean change_selection (GtkWidget *widget, GdkEventButton *event, gpointer data);
bool m_state;
int m_current_row, m_current_column;
GdkGC *m_drawing_area_gc;
GdkColor m_black, m_red;
};
#endif /* LINES_DIALOG_H */
nted-1.10.18/dialogs/spacementdialog.cpp 0000664 0010410 0000764 00000005350 11520267217 015027 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "spacementdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
NedSpacementDialog::NedSpacementDialog(GtkWindow *parent, double spacement) : m_spacement(spacement) {
GtkWidget *dialog;
GtkWidget *spacement_frame;
dialog = gtk_dialog_new_with_buttons(_("Horizontal Spacement"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
spacement_frame = gtk_frame_new(_("Spacement"));
m_spacement_slider = gtk_hscale_new_with_range(MEASURE_MIN_SPREAD, MEASURE_MAX_SPREAD, MEASURE_SPREAD_STEP);
gtk_range_set_value(GTK_RANGE(m_spacement_slider), spacement);
gtk_container_add (GTK_CONTAINER(spacement_frame), m_spacement_slider);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), spacement_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedSpacementDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedSpacementDialog *space_dialog = (NedSpacementDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
space_dialog->m_state = TRUE;
break;
default:
space_dialog->m_state = FALSE;
break;
}
space_dialog->m_spacement = gtk_range_get_value(GTK_RANGE(space_dialog->m_spacement_slider));
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedSpacementDialog::getValues(bool *state, double *spacement) {
*state = m_state;
*spacement = m_spacement;
}
nted-1.10.18/dialogs/druminfo.h 0000664 0010410 0000764 00000000456 11520267217 013162 0000000 0000000 #ifndef DRUM_INFO_H
#define DRUM_INFO_H
extern struct d_info_str {
const char *name, *lily_short_name;
int pitch;
int note_head;
const char *modifier;
int line;
} default_dinfo[], current_dinfo[];
int getNumberOfDrumTabElements();
void make_default_drums_current();
#endif /* DRUM_INFO_H */
nted-1.10.18/dialogs/selectordialog.h 0000664 0010410 0000764 00000004174 11520267217 014340 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SELECTOR_DIALOG_H
#define SELECTOR_DIALOG_H
#include "config.h"
#include
#include
struct staff_context_str;
class NedSelectorDialog {
public:
NedSelectorDialog(GtkWindow *parent, bool with_transpose, bool *staff_list, bool selected, struct staff_context_str *staff_contexts, int numstaffs);
void getValues(bool *state, int *pitchdist, bool *selected);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static void OnAll(GtkButton *button, gpointer data);
static void OnNone(GtkButton *button, gpointer data);
static void OnUseSelection(GtkToggleButton *togglebutton, gpointer data);
GtkWidget *m_allbutton;
GtkWidget *m_nonebutton;
GtkWidget *m_transpose_spin_box;
GtkWidget *m_selection_checkbox;
GtkWidget **m_checkboxes;
bool m_with_transpose;
bool *m_staff_list;
bool m_selected;
bool m_state;
int m_pitch_dist;
int m_numstaffs;
};
#endif /* SELECTOR_DIALOG_H */
nted-1.10.18/dialogs/drumconfigdialog.h 0000664 0010410 0000764 00000005500 11520267217 014647 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef DRUM_CONFIG_DIALOG_H
#define DRUM_CONFIG_DIALOG_H
#include "config.h"
#include
#include
#define MAXBUTTONS 13
class NedDrumConfigDialog {
public:
NedDrumConfigDialog(GtkWindow *parent);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static gboolean OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data);
static void OnToggle(GtkToggleButton *togglebutton, gpointer data);
static gboolean OnExpose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
static void OnCursorChanged(GtkTreeView *tree_view, gpointer data);
static void OnSave (GtkButton *button, gpointer data);
static void OnLoad (GtkButton *button, gpointer data);
static void OnDefault (GtkButton *button, gpointer data);
static void OnChange (GtkButton *button, gpointer data);
static void OnPlay (GtkButton *button, gpointer data);
static gboolean OnEnter(GtkWidget *widget, GdkEventCrossing *event, gpointer data);
static gboolean OnLeave(GtkWidget *widget, GdkEventCrossing *event, gpointer data);
static gboolean OnKeyPress(GtkWidget *widget, GdkEventKey *event, gpointer data);
static void increase_line (GtkButton *button, gpointer data);
static void decrease_line (GtkButton *button, gpointer data);
static GdkPixbuf *selectDrumIcon(int note_head);
GtkListStore *m_drum_elements_list_store;
GtkObject *m_drum_elements_adjustment;
GtkWidget *m_drum_element_list;
GtkWidget *m_preview;
GtkWidget *m_drum_buttons[MAXBUTTONS];
GdkColor m_black, m_red, m_white;
int m_type, m_line;
int m_element;
bool m_inside_preview;
};
#endif /* DRUM_CONFIG_DIALOG_H */
nted-1.10.18/dialogs/drumconfigdialog.cpp 0000664 0010410 0000764 00000107413 11520267217 015210 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include
#include "drumconfigdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#include "druminfo.h"
#include "drumconfigdialog.h"
#define DRUM_ELEMENTS_WIDGET_WIDTH 440
#define DRUM_ELEMENTS_WIDGET_HEIGHT 400
#define DRUM_DEMO_XPOS 90.0
#define DRUM_DEMO_O_HH_RAD 4.0
#define DRUM_DEMO_C_HH_LEN 6.0
#define DRUM_SHOW_WIDTH 30
#define DRUM_SHOW_HIGHT 60
#define DRUM_SHOW_BORDER 10
#define DRUM_DEMO_LINE_YPOS 70.0
#define MAX_DRUM_DEMO_LINE_OVER 7
#define DRUM_DEMO_LINE_BEGIN (DRUM_DEMO_XPOS - 40.0)
#define DRUM_DEMO_LINE_END (DRUM_DEMO_XPOS + 40.0)
#define DRUM_DEMO_NOTE_LINE_BEGIN (DRUM_DEMO_XPOS - 10.0)
#define DRUM_DEMO_NOTE_LINE_END (DRUM_DEMO_XPOS + 10.0)
NedDrumConfigDialog::NedDrumConfigDialog(GtkWindow *parent) : m_type(NORMAL_NOTE), m_line(0), m_inside_preview(false) {
int i;
GtkWidget *dialog;
GtkTreeIter iter;
GtkTreeViewColumn *drum_elements_num_column;
GtkTreeViewColumn *drum_element_name_column;
GtkTreeViewColumn *drum_element_short_name_column;
GtkTreeViewColumn *drum_element_position_column;
GtkTreeViewColumn *drum_element_symbol_column;
GtkTreeViewColumn *drum_element_pitch_column;
GtkCellRenderer *drum_elements_renderer;
GtkCellRenderer *drum_symbols_renderer;
GtkWidget *bu_up;
GtkWidget *bu_down;
GtkWidget *drum_elements_scroll;
GtkWidget *elements_hbox;
GtkWidget *right_vbox;
GtkWidget *right_hbox;
GtkWidget *right_arrow_vbox;
GtkWidget *drum_buttons_grid;
GtkWidget *drums_button_frame;
GtkWidget *drums_preview_frame;
GtkWidget *buttons_frame;
GtkWidget *buttons_vbox;
GtkWidget *load_button;
GtkWidget *save_button;
GtkWidget *play_button;
GtkWidget *change_button;
GtkWidget *default_button;
GdkColor bgcolor;
m_black.pixel = 1; m_black.red = m_black.green = m_black.blue = 0;
m_red.pixel = 2; m_red.red = 65535; m_red.green = m_red.blue = 0;
m_white.pixel = 3; m_white.red = m_white.green = m_white.blue = 0xffff;
dialog = gtk_dialog_new_with_buttons(_("Config Drums"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
GTK_WIDGET_SET_FLAGS(dialog, GTK_CAN_FOCUS);
gtk_widget_add_events(dialog, GDK_KEY_PRESS_MASK);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
g_signal_connect(dialog, "key-press-event", G_CALLBACK (OnKeyPress), (void *) this);
m_drum_elements_list_store = gtk_list_store_new (6, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_INT);
struct d_info_str *dinfo_ptr;
m_line = current_dinfo[0].line;
m_type = current_dinfo[0].note_head;
for (i = 0, dinfo_ptr = current_dinfo; dinfo_ptr->name; dinfo_ptr++, i++) {
gtk_list_store_append (m_drum_elements_list_store, &iter);
gtk_list_store_set(m_drum_elements_list_store, &iter, 0, i, 1, dinfo_ptr->name, 2, dinfo_ptr->lily_short_name, 3,
dinfo_ptr->line, 4, selectDrumIcon(dinfo_ptr->note_head), 5, dinfo_ptr->pitch, -1);
}
m_drum_element_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(m_drum_elements_list_store));
drum_elements_renderer = gtk_cell_renderer_text_new ();
drum_elements_num_column = gtk_tree_view_column_new_with_attributes (_("no"), drum_elements_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_drum_element_list), drum_elements_num_column);
drum_element_name_column = gtk_tree_view_column_new_with_attributes (_("drum element name"), drum_elements_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_drum_element_list), drum_element_name_column);
drum_element_short_name_column = gtk_tree_view_column_new_with_attributes (_("short name"), drum_elements_renderer, "text", 2, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_drum_element_list), drum_element_short_name_column);
drum_element_position_column = gtk_tree_view_column_new_with_attributes (_("line"), drum_elements_renderer, "text", 3, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_drum_element_list), drum_element_position_column);
drum_symbols_renderer = gtk_cell_renderer_pixbuf_new();
drum_element_symbol_column = gtk_tree_view_column_new_with_attributes (_("symbol"), drum_symbols_renderer, "pixbuf", 4, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_drum_element_list), drum_element_symbol_column);
drum_element_pitch_column = gtk_tree_view_column_new_with_attributes (_("midi pitch"), drum_elements_renderer, "text", 5, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_drum_element_list), drum_element_pitch_column);
m_drum_elements_adjustment = gtk_adjustment_new (0.0, 0.0, i, 1.0, 10.0, 10.0);
drum_elements_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(m_drum_elements_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_drum_element_list), GTK_ADJUSTMENT(m_drum_elements_adjustment));
gtk_widget_set_size_request(m_drum_element_list, DRUM_ELEMENTS_WIDGET_WIDTH, DRUM_ELEMENTS_WIDGET_HEIGHT);
g_signal_connect(dialog, "scroll-event", G_CALLBACK (OnScroll), (void *) this);
g_signal_connect(m_drum_element_list, "cursor-changed", G_CALLBACK (OnCursorChanged), (void *) this);
drum_buttons_grid = gtk_table_new(3, 5, TRUE);
m_drum_buttons[0] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[0], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[0]), gtk_image_new_from_pixbuf(NedResource::m_drum1_icon));
m_drum_buttons[1] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[1], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[1]), gtk_image_new_from_pixbuf(NedResource::m_drum2_icon));
m_drum_buttons[2] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[2], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[2]), gtk_image_new_from_pixbuf(NedResource::m_drum3_icon));
m_drum_buttons[3] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[3], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[3]), gtk_image_new_from_pixbuf(NedResource::m_drum4_icon));
m_drum_buttons[4] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[4], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[4]), gtk_image_new_from_pixbuf(NedResource::m_drum5_icon));
m_drum_buttons[5] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[5], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[5]), gtk_image_new_from_pixbuf(NedResource::m_drum6_icon));
m_drum_buttons[6] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[6], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[6]), gtk_image_new_from_pixbuf(NedResource::m_drum7_icon));
m_drum_buttons[7] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[7], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[7]), gtk_image_new_from_pixbuf(NedResource::m_drum8_icon));
m_drum_buttons[8] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[8], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[8]), gtk_image_new_from_pixbuf(NedResource::m_drum9_icon));
m_drum_buttons[9] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[9], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[9]), gtk_image_new_from_pixbuf(NedResource::m_drum10_icon));
m_drum_buttons[10] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[10], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[10]), gtk_image_new_from_pixbuf(NedResource::m_drum11_icon));
m_drum_buttons[11] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[11], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[11]), gtk_image_new_from_pixbuf(NedResource::m_drum12_icon));
m_drum_buttons[12] = gtk_toggle_button_new();
g_signal_connect(m_drum_buttons[12], "toggled", G_CALLBACK(OnToggle), (void *) this);
gtk_button_set_image(GTK_BUTTON(m_drum_buttons[12]), gtk_image_new_from_pixbuf(NedResource::m_normal_note_icon));
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[0], 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[1], 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[2], 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[3], 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[4], 0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[5], 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[6], 2, 3, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[7], 3, 4, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[8], 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[9], 1, 2, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[10], 2, 3, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[11], 3, 4, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), m_drum_buttons[12], 0, 1, 3, 4, GTK_SHRINK, GTK_SHRINK, 0, 0);
change_button = gtk_button_new_with_label(_("change element"));
g_signal_connect (change_button, "pressed", G_CALLBACK(OnChange), (void *) this);
gtk_table_attach(GTK_TABLE(drum_buttons_grid), change_button, 1, 4, 3, 4, GTK_SHRINK, GTK_SHRINK, 0, 0);
drums_button_frame = gtk_frame_new(_("note head"));
gtk_container_add (GTK_CONTAINER(drums_button_frame), drum_buttons_grid);
m_preview = gtk_drawing_area_new ();
gtk_widget_add_events(m_preview, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
bgcolor.pixel = 1;
bgcolor.red = bgcolor.green = bgcolor.blue = 0xffff;
gtk_widget_modify_bg(GTK_WIDGET(m_preview), GTK_STATE_NORMAL, &bgcolor);
gtk_drawing_area_size(GTK_DRAWING_AREA(m_preview), DRUM_SHOW_WIDTH, DRUM_SHOW_HIGHT);
g_signal_connect (m_preview, "expose-event", G_CALLBACK (OnExpose), (void *) this);
g_signal_connect (m_preview, "enter-notify-event", G_CALLBACK (OnEnter), (void *) this);
g_signal_connect (m_preview, "leave-notify-event", G_CALLBACK (OnLeave), (void *) this);
bu_up = gtk_button_new_from_stock("my-arrow-up-icon");
g_signal_connect (bu_up, "pressed", G_CALLBACK(increase_line), (void *) this);
bu_down = gtk_button_new_from_stock ("my-arrow-down-icon");
g_signal_connect (bu_down, "pressed", G_CALLBACK(decrease_line), (void *) this);
right_arrow_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(right_arrow_vbox), bu_up, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX(right_arrow_vbox), bu_down, FALSE, FALSE, 0);
right_hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(right_hbox), m_preview, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(right_hbox), right_arrow_vbox, FALSE, FALSE, 0);
drums_preview_frame = gtk_frame_new(_("preview"));
gtk_container_add (GTK_CONTAINER(drums_preview_frame), right_hbox);
right_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(right_vbox), drums_button_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(right_vbox), drums_preview_frame, TRUE, TRUE, 0);
load_button = gtk_button_new_with_label(_("load from file"));
save_button = gtk_button_new_with_label(_("save to file"));
default_button = gtk_button_new_with_label(_("load defaults"));
play_button = gtk_button_new_with_label(_("play element"));
g_signal_connect (save_button, "pressed", G_CALLBACK(OnSave), (void *) this);
g_signal_connect (load_button, "pressed", G_CALLBACK(OnLoad), (void *) this);
g_signal_connect (default_button, "pressed", G_CALLBACK(OnDefault), (void *) this);
g_signal_connect (play_button, "pressed", G_CALLBACK(OnPlay), (void *) this);
buttons_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(buttons_vbox), load_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(buttons_vbox), save_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(buttons_vbox), default_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(buttons_vbox), play_button, FALSE, FALSE, 0);
buttons_frame = gtk_frame_new(_("file"));
gtk_container_add (GTK_CONTAINER(buttons_frame), buttons_vbox);
elements_hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(elements_hbox), buttons_frame, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(elements_hbox), m_drum_element_list, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(elements_hbox), drum_elements_scroll, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(elements_hbox), right_vbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), elements_hbox);
gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_drum_element_list), gtk_tree_path_new_from_indices (0, -1), NULL, FALSE);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
GdkPixbuf *NedDrumConfigDialog::selectDrumIcon(int note_head) {
switch(note_head) {
case CROSS_NOTE1: return NedResource::m_drum1_icon_small;
case CROSS_NOTE2: return NedResource::m_drum2_icon_small;
case RECT_NOTE1: return NedResource::m_drum3_icon_small;
case RECT_NOTE2: return NedResource::m_drum4_icon_small;
case TRIAG_NOTE1: return NedResource::m_drum5_icon_small;
case TRIAG_NOTE2: return NedResource::m_drum6_icon_small;
case CROSS_NOTE3: return NedResource::m_drum7_icon_small;
case CROSS_NOTE4: return NedResource::m_drum8_icon_small;
case TRIAG_NOTE3: return NedResource::m_drum9_icon_small;
case QUAD_NOTE2: return NedResource::m_drum10_icon_small;
case OPEN_HIGH_HAT: return NedResource::m_drum11_icon_small;
case CLOSED_HIGH_HAT: return NedResource::m_drum12_icon_small;
}
return NedResource::m_normal_note_icon_small;
}
void NedDrumConfigDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
GtkTreeSelection* selection;
GList *selected_rows;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(drum_config_dialog->m_drum_element_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &(drum_config_dialog->m_element)) != 1) {
NedResource::Abort("NedDrumConfigDialog::OnClose: error reading tree path(1)");
}
}
else {
drum_config_dialog->m_element = 0;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
gboolean NedDrumConfigDialog::OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data) {
#define SCROLL_INCR 20.0
double adjval;
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
adjval = gtk_adjustment_get_value(GTK_ADJUSTMENT(drum_config_dialog->m_drum_elements_adjustment));
if (event->direction == GDK_SCROLL_UP) {
adjval -= SCROLL_INCR;
}
else if (event->direction == GDK_SCROLL_DOWN) {
adjval += SCROLL_INCR;
}
gtk_adjustment_set_value(GTK_ADJUSTMENT(drum_config_dialog->m_drum_elements_adjustment), adjval);
return FALSE;
}
void NedDrumConfigDialog::OnToggle(GtkToggleButton *togglebutton, gpointer data) {
int i;
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
if (gtk_toggle_button_get_active(togglebutton)) {
for (i = 0; i < MAXBUTTONS; i++) {
if (GTK_TOGGLE_BUTTON(drum_config_dialog->m_drum_buttons[i]) == togglebutton) {
switch(i) {
case 0: drum_config_dialog->m_type = CROSS_NOTE1; break;
case 1: drum_config_dialog->m_type = CROSS_NOTE2; break;
case 2: drum_config_dialog->m_type = RECT_NOTE1; break;
case 3: drum_config_dialog->m_type = RECT_NOTE2; break;
case 4: drum_config_dialog->m_type = TRIAG_NOTE1; break;
case 5: drum_config_dialog->m_type = TRIAG_NOTE2; break;
case 6: drum_config_dialog->m_type = CROSS_NOTE3; break;
case 7: drum_config_dialog->m_type = CROSS_NOTE4; break;
case 8: drum_config_dialog->m_type = TRIAG_NOTE3; break;
case 9: drum_config_dialog->m_type = QUAD_NOTE2; break;
case 10: drum_config_dialog->m_type = OPEN_HIGH_HAT; break;
case 11: drum_config_dialog->m_type = CLOSED_HIGH_HAT; break;
case 12: drum_config_dialog->m_type = NORMAL_NOTE; break;
}
if (GDK_IS_WINDOW(drum_config_dialog->m_preview->window)) {
gdk_window_invalidate_rect (drum_config_dialog->m_preview->window, NULL, FALSE);
}
continue;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(drum_config_dialog->m_drum_buttons[i]), FALSE);
}
}
}
void NedDrumConfigDialog::increase_line (GtkButton *button, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
if (drum_config_dialog->m_line >= 8 + MAX_DRUM_DEMO_LINE_OVER) return;
drum_config_dialog->m_line++;
gdk_window_invalidate_rect (drum_config_dialog->m_preview->window, NULL, FALSE);
}
void NedDrumConfigDialog::decrease_line (GtkButton *button, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
if (drum_config_dialog->m_line <= -MAX_DRUM_DEMO_LINE_OVER) return;
drum_config_dialog->m_line--;
gdk_window_invalidate_rect (drum_config_dialog->m_preview->window, NULL, FALSE);
}
gboolean NedDrumConfigDialog::OnEnter(GtkWidget *widget, GdkEventCrossing *event, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
drum_config_dialog->m_inside_preview = true;
return FALSE;
}
gboolean NedDrumConfigDialog::OnLeave(GtkWidget *widget, GdkEventCrossing *event, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
drum_config_dialog->m_inside_preview = false;
return FALSE;
}
gboolean NedDrumConfigDialog::OnKeyPress(GtkWidget *widget, GdkEventKey *event, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
if (!drum_config_dialog->m_inside_preview) return FALSE;
switch (event->keyval) {
case GDK_Up: increase_line(NULL, data); return TRUE;
case GDK_Down: decrease_line(NULL, data); return TRUE;
}
return FALSE;
}
void NedDrumConfigDialog::OnCursorChanged(GtkTreeView *tree_view, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
GtkTreeSelection* selection;
GList *selected_rows;
int *idxs;
int i, bunr = 0;
selection = gtk_tree_view_get_selection (tree_view);
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
idxs = gtk_tree_path_get_indices (path);
drum_config_dialog->m_line = current_dinfo[idxs[0]].line;
drum_config_dialog->m_type = current_dinfo[idxs[0]].note_head;
switch (drum_config_dialog->m_type) {
case CROSS_NOTE1: bunr = 0; break;
case CROSS_NOTE2: bunr = 1; break;
case RECT_NOTE1: bunr = 2; break;
case RECT_NOTE2: bunr = 3; break;
case TRIAG_NOTE1: bunr = 4; break;
case TRIAG_NOTE2: bunr = 5; break;
case CROSS_NOTE3: bunr = 6; break;
case CROSS_NOTE4: bunr = 7; break;
case TRIAG_NOTE3: bunr = 8; break;
case QUAD_NOTE2: bunr = 9; break;
case OPEN_HIGH_HAT: bunr = 10; break;
case CLOSED_HIGH_HAT: bunr = 11; break;
case NORMAL_NOTE: bunr = 12; break;
}
for (i = 0; i < MAXBUTTONS; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(drum_config_dialog->m_drum_buttons[i]), bunr == i);
}
if (GDK_IS_WINDOW(drum_config_dialog->m_preview->window)) {
gdk_window_invalidate_rect (drum_config_dialog->m_preview->window, NULL, FALSE);
}
}
}
void NedDrumConfigDialog::OnSave (GtkButton *button, gpointer data) {
FILE *fp;
char *filename, *cptr;
bool ok = false;
bool extend = false;
char the_filename[4096];
GtkWidget *error_dialog;
GtkWidget *access_dialog;
GtkWidget *save_dialog;
struct d_info_str *dinfo_ptr;
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.ntddrm (Nted-Drum-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.ntddrm");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
save_dialog = gtk_file_chooser_dialog_new (_("Save drum configuration"),
//GTK_WINDOW(drum_config_dialog),
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(save_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(save_dialog), file_filter2);
if (gtk_dialog_run (GTK_DIALOG (save_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (save_dialog));
strcpy(the_filename, filename);
g_free (filename);
ok = true;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (save_dialog))) == file_filter1) {
extend = true;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".ntddrm")) {
extend = false;
}
}
if (extend) {
strcat(the_filename, ".ntddrm");
}
}
gtk_widget_destroy (save_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (NULL, //GTK_WINDOW(drum_config_dialog),
//(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
(GtkDialogFlags) 0,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = false;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((fp = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (NULL, //GTK_WINDOW(drum_config_dialog),
//(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
(GtkDialogFlags) 0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = false;
}
}
if (ok) {
fprintf(fp, "NTEDDRM version 1\n");
for (dinfo_ptr = current_dinfo; dinfo_ptr->name; dinfo_ptr++) {
fprintf(fp, "%s\t%s\t%d\t", dinfo_ptr->name, dinfo_ptr->lily_short_name, dinfo_ptr->line);
switch(dinfo_ptr->note_head) {
case CROSS_NOTE1: fprintf(fp, "CROSS_NOTE1"); break;
case CROSS_NOTE2: fprintf(fp, "CROSS_NOTE2"); break;
case RECT_NOTE1: fprintf(fp, "RECT_NOTE1"); break;
case RECT_NOTE2: fprintf(fp, "RECT_NOTE2"); break;
case TRIAG_NOTE1: fprintf(fp, "TRIAG_NOTE1"); break;
case TRIAG_NOTE2: fprintf(fp, "TRIAG_NOTE2"); break;
case CROSS_NOTE3: fprintf(fp, "CROSS_NOTE3"); break;
case CROSS_NOTE4: fprintf(fp, "CROSS_NOTE4"); break;
case TRIAG_NOTE3: fprintf(fp, "TRIAG_NOTE3"); break;
case QUAD_NOTE2: fprintf(fp, "QUAD_NOTE2"); break;
case OPEN_HIGH_HAT: fprintf(fp, "OPEN_HIGH_HAT"); break;
case CLOSED_HIGH_HAT: fprintf(fp, "CLOSED_HIGH_HAT"); break;
default: fprintf(fp, "NORMAL_NOTE"); break;
}
fprintf(fp, "\t%d\n", dinfo_ptr->pitch);
}
fclose(fp);
}
}
void NedDrumConfigDialog::OnLoad (GtkButton *button, gpointer data) {
FILE *fp;
GtkWidget *open_dialog;
GtkWidget *error_dialog;
int file_version;
char *filename = NULL;
char buffer[128];
bool ok = false;
int i;
struct d_info_str tab[getNumberOfDrumTabElements()], *dptr1, *dptr2;
NedResource::m_error_message = NULL;
NedResource::m_input_line = 1;
open_dialog = gtk_file_chooser_dialog_new (_("Open drum configuration"),
NULL, //GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.ntddrm (Nted-Drum-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.ntddrm");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(open_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(open_dialog), file_filter2);
if (gtk_dialog_run (GTK_DIALOG (open_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (open_dialog));
ok = true;
}
gtk_widget_destroy (open_dialog);
if (ok) {
if ((fp = fopen(filename, "r")) == NULL) {
error_dialog = gtk_message_dialog_new (NULL, //GTK_WINDOW(main_window->m_main_window),
//(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
(GtkDialogFlags) 0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for reading"), filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (ok) {
dptr1 = default_dinfo;
dptr2 = tab;
do {
memcpy(dptr2, dptr1, sizeof(struct d_info_str));
if (dptr1->name) {
dptr1++; dptr2++;
}
}
while(dptr1->name);
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "NTEDDRM")) {
NedResource::m_error_message = "NTEDDRM expected";
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readWord(fp, buffer) || strcmp(buffer, "version")) {
NedResource::m_error_message = "version expected";
}
}
if (NedResource::m_error_message == NULL) {
if (!NedResource::readInt(fp, &file_version) || file_version < 1 || file_version > 1) {
NedResource::m_error_message = "version number expected";
}
}
//NedResource::readTillEnd(fp, buffer);
if (NedResource::m_error_message == NULL) {
for (i = 0; i < getNumberOfDrumTabElements() - 1; i++) {
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "drum element name expected";
break;
}
if (strcmp(tab[i].name, buffer)) {
NedResource::m_error_message = "drum name clash";
break;
}
if (!NedResource::readWord(fp, buffer)) {
NedResource::m_error_message = "drum short element name expected";
break;
}
if (!NedResource::readInt(fp, &(tab[i].line)) || tab[i].line > 8 + MAX_DRUM_DEMO_LINE_OVER || tab[i].line < -MAX_DRUM_DEMO_LINE_OVER) {
printf("tab[%d].line = %d, 8 + MAX_DRUM_DEMO_LINE_OVER = %d, -MAX_DRUM_DEMO_LINE_OVER = %d\n"
, i, tab[i].line, 8 + MAX_DRUM_DEMO_LINE_OVER, -MAX_DRUM_DEMO_LINE_OVER); fflush(stdout);
NedResource::m_error_message = "line expected";
break;
}
if (!NedResource::readWordWithNum(fp, buffer)) {
NedResource::m_error_message = "drum symbol expected";
break;
}
if(!strcmp("CROSS_NOTE1", buffer)) {
tab[i].note_head = CROSS_NOTE1;
}
else if(!strcmp("CROSS_NOTE2", buffer)) {
tab[i].note_head = CROSS_NOTE2;
}
else if(!strcmp("RECT_NOTE1", buffer)) {
tab[i].note_head = RECT_NOTE1;
}
else if(!strcmp("RECT_NOTE2", buffer)) {
tab[i].note_head = RECT_NOTE2;
}
else if(!strcmp("TRIAG_NOTE1", buffer)) {
tab[i].note_head = TRIAG_NOTE1;
}
else if(!strcmp("TRIAG_NOTE2", buffer)) {
tab[i].note_head = TRIAG_NOTE2;
}
else if(!strcmp("CROSS_NOTE3", buffer)) {
tab[i].note_head = CROSS_NOTE3;
}
else if(!strcmp("CROSS_NOTE4", buffer)) {
tab[i].note_head = CROSS_NOTE4;
}
else if(!strcmp("TRIAG_NOTE3", buffer)) {
tab[i].note_head = TRIAG_NOTE3;
}
else if(!strcmp("QUAD_NOTE2", buffer)) {
tab[i].note_head = QUAD_NOTE2;
}
else if(!strcmp("OPEN_HIGH_HAT", buffer)) {
tab[i].note_head = OPEN_HIGH_HAT;
}
else if(!strcmp("CLOSED_HIGH_HAT", buffer)) {
tab[i].note_head = CLOSED_HIGH_HAT;
}
else if(!strcmp("NORMAL_NOTE", buffer)) {
tab[i].note_head = NORMAL_NOTE;
}
else {
NedResource::m_error_message = "drum symbol expected";
break;
}
NedResource::readTillEnd(fp, buffer);
}
}
if (NedResource::m_error_message != NULL) {
sprintf(buffer, "line: %d: %s", NedResource::m_input_line, NedResource::m_error_message);
NedResource::Info(buffer);
return;
}
for (dptr1 = current_dinfo, dptr2 = tab; dptr1->name; dptr1++, dptr2++) {
dptr1->note_head = dptr2->note_head;
dptr1->line = dptr2->line;
}
for (i = 0, dptr1 = current_dinfo; dptr1->name; dptr1++, i++) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
GtkTreeIter iter;
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(drum_config_dialog->m_drum_elements_list_store), &iter, gtk_tree_path_new_from_indices (i, -1))) {
printf("error getting iterator\n"); fflush(stdout);
}
gtk_list_store_set(drum_config_dialog->m_drum_elements_list_store, &iter, 0, i, 1, dptr1->name, 2, dptr1->lily_short_name, 3,
dptr1->line, 4, selectDrumIcon(dptr1->note_head), 5, dptr1->pitch, -1);
}
}
}
void NedDrumConfigDialog::OnPlay (GtkButton *button, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
GtkTreeSelection* selection;
GList *selected_rows;
int *idxs;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(drum_config_dialog->m_drum_element_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
idxs = gtk_tree_path_get_indices (path);
NedResource::playImmediately(9, 0, 1, &(current_dinfo[idxs[0]].pitch), 64);
}
}
void NedDrumConfigDialog::OnDefault (GtkButton *button, gpointer data) {
int i;
GtkTreeIter iter;
struct d_info_str *dptr;
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
make_default_drums_current();
for (i = 0, dptr = current_dinfo; dptr->name; dptr++, i++) {
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(drum_config_dialog->m_drum_elements_list_store), &iter, gtk_tree_path_new_from_indices (i, -1))) {
printf("error getting iterator\n"); fflush(stdout);
}
gtk_list_store_set(drum_config_dialog->m_drum_elements_list_store, &iter, 0, i, 1, dptr->name, 2, dptr->lily_short_name, 3,
dptr->line, 4, selectDrumIcon(dptr->note_head), 5, dptr->pitch, -1);
}
gdk_window_invalidate_rect (drum_config_dialog->m_preview->window, NULL, FALSE);
}
void NedDrumConfigDialog::OnChange (GtkButton *button, gpointer data) {
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
GtkTreeSelection* selection;
GList *selected_rows;
GtkTreeIter iter;
GtkTreePath *path;
int *idxs;
struct d_info_str *dinfo_ptr;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(drum_config_dialog->m_drum_element_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( g_list_length(selected_rows) > 0) {
path = (GtkTreePath *) g_list_first(selected_rows)->data;
idxs = gtk_tree_path_get_indices (path);
dinfo_ptr = &(current_dinfo[idxs[0]]);
dinfo_ptr->line = drum_config_dialog->m_line;
dinfo_ptr->note_head = drum_config_dialog->m_type;
if (gtk_tree_model_get_iter (GTK_TREE_MODEL(drum_config_dialog->m_drum_elements_list_store), &iter, path)) {
gtk_list_store_set(drum_config_dialog->m_drum_elements_list_store, &iter, 0, idxs[0] , 1, dinfo_ptr->name, 2, dinfo_ptr->lily_short_name, 3,
dinfo_ptr->line, 4, selectDrumIcon(dinfo_ptr->note_head), 5, dinfo_ptr->pitch, -1);
}
}
}
gboolean NedDrumConfigDialog::OnExpose(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
#define ZOOM_LEVEL 9
NedDrumConfigDialog *drum_config_dialog = (NedDrumConfigDialog *) data;
cairo_scaled_font_t *scaled_font;
cairo_glyph_t glyph;
int i;
cairo_t *cr;
cr = gdk_cairo_create (drum_config_dialog->m_preview->window);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, 0, 0, drum_config_dialog->m_preview->allocation.width, drum_config_dialog->m_preview->allocation.height);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
scaled_font = NedResource::getScaledFont(ZOOM_LEVEL);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(ZOOM_LEVEL));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
cairo_new_path(cr);
cairo_set_line_width(cr, DEMO_LINE_THICK);
for (i = 0; i < 5; i++) {
cairo_move_to(cr, DRUM_DEMO_LINE_BEGIN, DRUM_DEMO_LINE_YPOS + DEMO_LINE_DIST * i);
cairo_line_to(cr, DRUM_DEMO_LINE_END, DRUM_DEMO_LINE_YPOS + DEMO_LINE_DIST * i);
}
for (i = 10; i <= drum_config_dialog->m_line; i += 2) {
cairo_move_to(cr, DRUM_DEMO_NOTE_LINE_BEGIN, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * i);
cairo_line_to(cr, DRUM_DEMO_NOTE_LINE_END, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * i);
}
for (i = -2; i >= drum_config_dialog->m_line; i -= 2) {
cairo_move_to(cr, DRUM_DEMO_NOTE_LINE_BEGIN, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * i);
cairo_line_to(cr, DRUM_DEMO_NOTE_LINE_END, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * i);
}
cairo_stroke(cr);
cairo_new_path(cr);
glyph.index = BASE + 4;
switch (drum_config_dialog->m_type) {
case CROSS_NOTE1:
glyph.index = BASE + 21; break;
case CROSS_NOTE2:
glyph.index = BASE + 22; break;
case RECT_NOTE1:
glyph.index = BASE + 23; break;
case RECT_NOTE2:
glyph.index = BASE + 24; break;
case TRIAG_NOTE1:
glyph.index = BASE + 25; break;
case TRIAG_NOTE2:
glyph.index = BASE + 26; break;
case OPEN_HIGH_HAT:
case CLOSED_HIGH_HAT:
case CROSS_NOTE3:
glyph.index = BASE + 49; break;
case CROSS_NOTE4:
glyph.index = BASE + 50; break;
case TRIAG_NOTE3:
glyph.index = BASE + 51; break;
case QUAD_NOTE2:
glyph.index = BASE + 52; break;
}
glyph.x = DRUM_DEMO_XPOS;
glyph.y = DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * drum_config_dialog->m_line;
cairo_show_glyphs(cr, &glyph, 1);
cairo_stroke(cr);
if (drum_config_dialog->m_type == OPEN_HIGH_HAT || drum_config_dialog->m_type == CLOSED_HIGH_HAT) {
int cline = drum_config_dialog->m_line > 7 ? drum_config_dialog->m_line + 3 : 8 + 3;
cairo_new_path(cr);
cairo_arc(cr, DRUM_DEMO_XPOS, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * cline, DRUM_DEMO_O_HH_RAD, 0, 2.0 * M_PI);
if (drum_config_dialog->m_type == CLOSED_HIGH_HAT) {
cairo_move_to(cr, DRUM_DEMO_XPOS - DRUM_DEMO_C_HH_LEN, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * cline + DRUM_DEMO_C_HH_LEN);
cairo_line_to(cr, DRUM_DEMO_XPOS + DRUM_DEMO_C_HH_LEN, DRUM_DEMO_LINE_YPOS + 4 * DEMO_LINE_DIST - DEMO_LINE_DIST / 2.0 * cline - DRUM_DEMO_C_HH_LEN);
}
cairo_stroke(cr);
}
cairo_destroy (cr);
return FALSE;
}
nted-1.10.18/dialogs/measureconfigdialog.h 0000664 0010410 0000764 00000006037 11520267217 015347 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef MEASURE_CONFIGDIALOG_H
#define MEASURE_CONFIGDIALOG_H
#include "config.h"
#include
#include
class NedMeasureConfigDialog {
public:
NedMeasureConfigDialog(GtkWindow *parent, int measure_type, bool alter1, bool alter2, bool allow_alter, bool hide_following, int num, int denom, unsigned int sym);
void getValues(bool *state, int *measure_type, bool *alter1, bool *alter2, bool *hide_following, bool *timsig_state, bool *delete_timesig, int *num, int *denom, unsigned int *sym);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static void OnTimesigToggeled (GtkToggleButton *togglebutton, gpointer data);
static void OnCommButtonToggled(GtkToggleButton *togglebutton, gpointer data);
static void OnCutButtonToggled(GtkToggleButton *togglebutton, gpointer data);
static gboolean draw_measure_types(GtkWidget *widget, GdkEventExpose *event, gpointer data);
static void previous_measure_type(GtkButton *button, gpointer user_data);
static void next_measure_type(GtkButton *button, gpointer user_data);
static void alter1_checked (GtkToggleButton *togglebutton, gpointer data);
static void delete_time_sig_checked (GtkToggleButton *togglebutton, gpointer data);
GtkWidget *m_measure_type_show_window;
GtkWidget *m_meas_bu_up;
GtkWidget *m_meas_bu_down;
GtkWidget *m_alter1_check_box;
GtkWidget *m_alter2_check_box;
GtkWidget *m_hide_box;
GtkWidget *m_numerator;
GtkWidget *m_denominator;
GtkWidget *m_com_time_bu;
GtkWidget *m_cut_time_bu;
GtkWidget *m_timsig_check_box;
GtkWidget *m_delete_timsig_check_box;
bool m_state;
int m_measure_type;
int m_original_type;
int m_num, m_denom;
unsigned int m_symbol;
bool m_alter1;
bool m_alter2;
bool m_hide_following;
bool m_allow_alter;
bool m_timesig_state;
bool m_delete_timesig;
};
#endif /* MEASURE_CONFIGDIALOG_H */
nted-1.10.18/dialogs/signsdialog.h 0000664 0010410 0000764 00000003452 11520267217 013641 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SIGNS_DIALOG_H
#define SIGNS_DIALOG_H
#include "config.h"
#include
#include
class NedSignsDialog {
public:
NedSignsDialog(GtkWindow *parent);
void getValues(bool *state, int *signtype);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static gboolean draw_menu(GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean change_selection (GtkWidget *widget, GdkEventButton *event, gpointer data);
bool m_state;
int m_current_row, m_current_column;
GdkGC *m_drawing_area_gc;
GdkColor m_black, m_red;
};
#endif /* SIGNS_DIALOG_H */
nted-1.10.18/dialogs/spacementdialog.h 0000664 0010410 0000764 00000003147 11520267217 014476 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SPACEMENT_DIALOG_H
#define SPACEMENT_DIALOG_H
#include "config.h"
#include
class NedSpacementDialog {
public:
NedSpacementDialog(GtkWindow *parent, double spacement);
void getValues(bool *state, double *spacement);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_spacement_slider;
bool m_state;
double m_spacement;
};
#endif /* SPACEMENT_DIALOG_H */
nted-1.10.18/dialogs/paperconfigdialog.h 0000664 0010410 0000764 00000003743 11520267217 015016 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef PAPER_CONFIG_DIALOG_H
#define PAPER_CONFIG_DIALOG_H
#include "config.h"
#include
#define DELETE_STAFF_CMD 12
class NedPaperConfigDialog {
public:
NedPaperConfigDialog(GtkWindow *parent, const char *current_paper, bool portrait, bool with_cancel);
void getValues(bool *state, const char **paper, bool *portrait);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
const char *m_paper;
bool m_state;
bool m_portrait;
GtkWidget *m_radio_box_A5;
GtkWidget *m_radio_box_A4;
GtkWidget *m_radio_box_A3;
GtkWidget *m_radio_box_B4;
GtkWidget *m_radio_box_Letter;
GtkWidget *m_radio_box_Legal;
GtkWidget *m_radio_box_230x293;
GtkWidget *m_radio_box_portrait;
GtkWidget *m_radio_box_landspace;
};
#endif /* PAPER_CONFIG_DIALOG_H */
nted-1.10.18/dialogs/Makefile.am 0000775 0010410 0000764 00000004524 11520267217 013225 0000000 0000000 #########################################################################################
# #
# This program is free software; you can redistribute it and#or modify it under the #
# terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this #
# program; (See "COPYING"). If not, If not, see . #
# #
#---------------------------------------------------------------------------------------#
# #
# Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY #
# ja@informatik.tu-chemnitz.de #
# #
# #
#########################################################################################
AM_CPPFLAGS = $(FT2_CFLAGS) -I$(top_srcdir) $(CAIRO_CFLAGS) $(GTK_CFLAGS) $(X11_CFLAGS)
noinst_LIBRARIES = libdialogs.a
libdialogs_a_SOURCES = staffcontextdialog.cpp portchoosedialog.cpp paperconfigdialog.cpp \
printconfigdialog.cpp tupletdialog.cpp insertblockdialog.cpp measureconfigdialog.cpp \
keysigdialog.cpp scoreinfodialog.cpp clefconfigdialog.cpp volumedialog.cpp \
tempodialog.cpp mutedialog.cpp linesdialog.cpp signsdialog.cpp textdialog.cpp \
lilypondexportdialog.cpp staffselectdialog.cpp spacementdialog.cpp selectordialog.cpp \
tools.cpp scaledialog.cpp chordnamedialog.cpp midiimportdialog.cpp \
midirecordconfigdialog.cpp druminfo.cpp drumconfigdialog.cpp lyricseditor.cpp
libdialogs_a_SOURCES += clefconfigdialog.h insertblockdialog.h keysigdialog.h linesdialog.h measureconfigdialog.h \
mutedialog.h paperconfigdialog.h portchoosedialog.h printconfigdialog.h scoreinfodialog.h signsdialog.h \
staffcontextdialog.h tempodialog.h textdialog.h tupletdialog.h volumedialog.h lilypondexportdialog.h staffselectdialog.h \
spacementdialog.h selectordialog.h tools.h scaledialog.h chordnamedialog.h midiimportdialog.h \
midirecordconfigdialog.h druminfo.h drumconfigdialog.h lyricseditor.h
nted-1.10.18/dialogs/staffselectdialog.cpp 0000664 0010410 0000764 00000015234 11520267217 015355 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "staffselectdialog.h"
#include "mainwindow.h"
#include "localization.h"
#include "pangocairotext.h"
#include "resource.h"
NedStaffSelectDialog::NedStaffSelectDialog(GtkWindow *parent, const char *title, NedMainWindow *main_window, bool *selected_staves) : m_main_window(main_window), m_selected_staves(selected_staves) {
GtkWidget *dialog;
GtkTreeIter iter;
GtkListStore *position_list_store;
GtkCellRenderer *position_renderer;
GtkTreeViewColumn *position_column;
GtkTreeViewColumn *position_num_column;
GtkObject *position_adjustment;
GtkWidget *position_scroll = NULL;
GtkWidget *hbox;
GtkWidget *button_h_box;
GtkWidget *main_vbox;
GtkWidget *all_button;
GtkWidget *none_button;
int i;
dialog = gtk_dialog_new_with_buttons(title, parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
position_list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
for (i = 0; i < main_window->getStaffCount(); i++) {
gtk_list_store_append (position_list_store, &iter);
if (main_window->m_staff_contexts[i].m_staff_name != NULL && strlen(main_window->m_staff_contexts[i].m_staff_name->getText()) > 0) {
gtk_list_store_set (position_list_store, &iter, 0, main_window->m_staff_contexts[i].m_staff_name->getText() , 1, i, -1);
}
else {
gtk_list_store_set (position_list_store, &iter, 0, _("staff") , 1, i, -1);
}
}
m_position_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(position_list_store));
m_tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_position_list));
gtk_tree_selection_set_mode(m_tree_selection, GTK_SELECTION_MULTIPLE);
position_renderer = gtk_cell_renderer_text_new ();
position_column = gtk_tree_view_column_new_with_attributes (_("item"), position_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_position_list), position_column);
position_num_column = gtk_tree_view_column_new_with_attributes (_("no"), position_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_position_list), position_num_column);
position_adjustment = gtk_adjustment_new (0.0, 0.0, 4, 1.0, 10.0, 10.0);
position_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(position_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_position_list), GTK_ADJUSTMENT(position_adjustment));
gtk_widget_set_size_request(m_position_list, 150, 200);
all_button = gtk_button_new_with_label(_("All"));
g_signal_connect(all_button, "pressed", G_CALLBACK(OnAll), (void *) this);
none_button = gtk_button_new_with_label(_("None"));
g_signal_connect(none_button, "pressed", G_CALLBACK(OnNone), (void *) this);
button_h_box = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(button_h_box), all_button, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(button_h_box), none_button, TRUE, TRUE, 0);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(hbox), m_position_list, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox), position_scroll, FALSE, TRUE, 0);
main_vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(main_vbox), hbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(main_vbox), button_h_box, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), main_vbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedStaffSelectDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
GList *selected_rows;
int i;
NedStaffSelectDialog *selection_dialog = (NedStaffSelectDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
selection_dialog->m_state = TRUE;
selected_rows = gtk_tree_selection_get_selected_rows (selection_dialog->m_tree_selection, NULL);
if (g_list_length(selected_rows) > 0) {
for (i = 0; i < selection_dialog->m_main_window->getStaffCount(); selection_dialog->m_selected_staves[i++] = false);
gtk_tree_selection_selected_foreach (selection_dialog->m_tree_selection, add_staff, data);
}
else {
selection_dialog->m_state = FALSE;
}
break;
default:
selection_dialog->m_state = FALSE;
break;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedStaffSelectDialog::getValues(bool *state) {
*state = m_state;
}
void NedStaffSelectDialog::add_staff(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) {
NedStaffSelectDialog *selection_dialog = (NedStaffSelectDialog *) data;
int sel_num;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &sel_num) != 1) {
NedResource::Abort("NedStaffSelectDialog::add_staff: error reading tree path(1)");
}
if (sel_num < 0 || sel_num >= selection_dialog->m_main_window->getStaffCount()) {
NedResource::Abort("NedStaffSelectDialog::add_staff(2)");
}
selection_dialog->m_selected_staves[sel_num] = true;
}
void NedStaffSelectDialog::OnAll(GtkButton *button, gpointer data) {
NedStaffSelectDialog *selection_dialog = (NedStaffSelectDialog *) data;
int i;
gtk_tree_selection_select_all(selection_dialog->m_tree_selection);
for (i = 0; i < selection_dialog->m_main_window->getStaffCount(); selection_dialog->m_selected_staves[i++] = true);
}
void NedStaffSelectDialog::OnNone(GtkButton *button, gpointer data) {
NedStaffSelectDialog *selection_dialog = (NedStaffSelectDialog *) data;
int i;
gtk_tree_selection_unselect_all(selection_dialog->m_tree_selection);
for (i = 0; i < selection_dialog->m_main_window->getStaffCount(); selection_dialog->m_selected_staves[i++] = false);
}
nted-1.10.18/dialogs/scaledialog.h 0000664 0010410 0000764 00000003072 11520267217 013603 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SCALE_DIALOG_H
#define SCALE_DIALOG_H
#include "config.h"
#include
class NedScaleDialog {
public:
NedScaleDialog(GtkWindow *parent, int scale);
void getValues(bool *state, int *scale);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_scale_slider;
bool m_state;
int m_scale;
};
#endif /* SCALE_DIALOG_H */
nted-1.10.18/dialogs/staffcontextdialog.cpp 0000664 0010410 0000764 00000143113 11520267217 015560 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "staffcontextdialog.h"
#include "pangocairotext.h"
#include "mainwindow.h"
#include "localization.h"
#define CLEF_SHOW_WINDOW_WIDTH 90
#define CLEF_SHOW_WINDOW_HEIGHT 100
char *NedStaffContextDialog::m_keyTab[] = {
_("G flat Major; e flat minor"), _("D flat Major; b flat minor"),
_("A flat Major; f minor"), _("E flat Major; c minor"),
_("B flat Major; g minor"), _("F Major; d minor"),
_("C Major; a minor"), _("G Major; e minor"),
_("D Major; b minor"), _("A Major; f sharp minor"),
_("E Major; c sharp minor"), _("B Major; g sharp minor"),
_("F sharp Major; d sharp minor")
};
NedStaffContextDialog::NedStaffContextDialog(GtkWindow *parent, NedMainWindow *main_window, bool different_voices, bool allow_delete_system, int staff_count, int staff_pos, char *staff_name, char *staff_short_name, char *group_name, char* group_short_name, int clef_number, int octave_shift, int key_signature_number, int numerator, int demoninator, unsigned int symbol, int volume[VOICE_COUNT], int midi_program[VOICE_COUNT], int channel, int tempo, int pan[VOICE_COUNT], int chorus, int play_transposed, int reverb, bool muted[VOICE_COUNT]) :
m_different_voices(different_voices), m_octave_shift(octave_shift), m_tempo(tempo), m_chorus(chorus), m_play_transposed(play_transposed), m_reverb(reverb), m_channel_value(channel),
m_state(false), m_numerator_value(numerator), m_denominator_value(demoninator), m_symbol(symbol),
m_key_signature_number(key_signature_number), m_current_clef(clef_number), m_config_changed(false),
m_delete_staff(false), m_staff_pos(staff_pos),
m_staff_count(staff_count), m_staff_name(staff_name), m_staff_short_name(staff_short_name), m_group_name(group_name), m_group_short_name(group_short_name) {
GtkWidget *dialog;
GtkWidget *label_score;
GtkWidget *label_midi;
GtkWidget *label_position;
GtkWidget *score_hbox;
GtkWidget *midi_hbox;
GtkWidget *position_hbox;
GtkWidget *clef_hbox;
GtkWidget *clef_buttons_vbox;
GtkWidget *clef_frame;
GtkWidget *key_frame;
GtkWidget *key_frame_left_vbox;
GtkWidget *key_frame_right_vbox;
GtkWidget *radio_hbox;
GtkWidget *time_signature_frame;
GtkWidget *numerator_label;
GtkWidget *denominator_label;
GtkWidget *octave_shift_label;
GtkWidget *octave_shift_vbox;
GtkWidget *time_signature_vbox;
GtkWidget *time_signature_upper_hbox;
GtkWidget *time_signature_lower_hbox;
GtkWidget *volume_frame;
GtkWidget *tempo_frame;
GtkWidget *pan_frame;
GtkWidget *chorus_frame;
GtkWidget *play_transposed_frame;
GtkWidget *reverb_frame;
GtkWidget *instrument_scroll;
GtkListStore *instrumend_list_store;
GtkTreeIter iter;
GtkCellRenderer *instrument_renderer;
GtkTreeViewColumn *instrument_column;
GtkTreeViewColumn *instrument_num_column;
GtkWidget *channel_frame;
GtkWidget *mute_channel_vbox;
GtkWidget *mute_frame;
GtkWidget *mute_vbox;
GtkWidget *mute_hbox1;
GtkWidget *mute_hbox2;
GtkWidget *voices_frame;
GtkWidget *vrb_vbox;
GtkWidget *vrb_hbox1;
GtkWidget *vrb_hbox2;
GdkColor bgcolor;
GtkListStore *position_list_store;
GtkCellRenderer *position_renderer;
GtkTreeViewColumn *position_column;
GtkTreeViewColumn *position_num_column;
GtkTreePath *position_tree_path;
GtkObject *position_adjustment;
GtkWidget *position_scroll = NULL;
GtkWidget *staff_name_frame;
GtkWidget *staff_short_name_frame;
GtkWidget *signature_name_vbox;
GtkWidget *group_name_frame;
GtkWidget *group_short_name_frame;
GtkWidget *group_name_vbox;
bool all_muted;
int i;
char Str[128];
for (i = 0; i < VOICE_COUNT; i++) {
m_midi_program_number[i] = midi_program[i];
m_pan[i] = pan[i];
m_volume[i] = volume[i];
m_muted[i] = muted[i];
}
m_newclef = m_current_clef;
dialog = gtk_dialog_new_with_buttons(_("Staff context"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
if (staff_count > 1) {
gtk_dialog_add_button(GTK_DIALOG(dialog), "delete-staff", DELETE_STAFF_CMD);
}
if (allow_delete_system) {
gtk_dialog_add_button(GTK_DIALOG(dialog), "delete-system", DELETE_SYSTEM_CMD);
}
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
clef_frame = gtk_frame_new(_("clef"));
m_clef_show_window = gtk_drawing_area_new ();
bgcolor.pixel = 1;
bgcolor.red = bgcolor.green = bgcolor.blue = 0xffff;
gtk_widget_modify_bg(GTK_WIDGET(m_clef_show_window), GTK_STATE_NORMAL, &bgcolor);
gtk_drawing_area_size(GTK_DRAWING_AREA(m_clef_show_window), CLEF_SHOW_WINDOW_WIDTH, CLEF_SHOW_WINDOW_HEIGHT);
clef_hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(clef_hbox), m_clef_show_window, FALSE, FALSE, 0);
clef_buttons_vbox = gtk_vbox_new(FALSE, 2);
m_clef_bu_up = gtk_button_new_from_stock("my-arrow-up-icon");
g_signal_connect (m_clef_bu_up, "pressed", G_CALLBACK(decrease_clef_number), (void *) this);
m_clef_bu_down = gtk_button_new_from_stock ("my-arrow-down-icon");
g_signal_connect (m_clef_bu_down, "pressed", G_CALLBACK(increase_clef_number), (void *) this);
gtk_box_pack_start(GTK_BOX(clef_buttons_vbox), m_clef_bu_up, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(clef_buttons_vbox), m_clef_bu_down, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(clef_hbox), clef_buttons_vbox, FALSE, FALSE, 0);
octave_shift_vbox = gtk_vbox_new(FALSE, 2);
switch (m_octave_shift) {
case 12: m_octave_shift = 8; break;
case -12: m_octave_shift = -8; break;
}
m_octave_shift_spin_box = gtk_spin_button_new_with_range(-8.0, 8.0, 8.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_octave_shift_spin_box), m_octave_shift);
octave_shift_label = gtk_label_new(_("Octave shift:"));
gtk_box_pack_start (GTK_BOX (octave_shift_vbox), octave_shift_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (octave_shift_vbox), m_octave_shift_spin_box, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(clef_hbox), octave_shift_vbox, FALSE, FALSE, 0);
g_signal_connect (m_octave_shift_spin_box, "value-changed", G_CALLBACK (octave_shift_change), (void *) this);
m_adjust_check_box = gtk_check_button_new_with_label(_("adjust notes"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_adjust_check_box), TRUE);
gtk_box_pack_start (GTK_BOX (octave_shift_vbox), m_adjust_check_box, FALSE, FALSE, 0);
if (m_newclef == MINCLEF_NUMBER) {
gtk_widget_set_sensitive(m_clef_bu_up, FALSE);
}
if (m_newclef == MAXCLEF_NUMBER) {
gtk_widget_set_sensitive(m_clef_bu_down, FALSE);
}
gtk_container_add (GTK_CONTAINER(clef_frame), clef_hbox);
g_signal_connect (m_clef_show_window, "expose-event", G_CALLBACK (draw_clefs), (void *) this);
key_frame = gtk_frame_new(_("key"));
radio_hbox = gtk_hbox_new(FALSE, 2);
key_frame_left_vbox = gtk_vbox_new(FALSE, 2);
key_frame_right_vbox = gtk_vbox_new(FALSE, 2);
m_sig_radio_buttons[0] = gtk_radio_button_new_with_label (NULL, gettext(m_keyTab[0]));
gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[0], FALSE, FALSE, 0);
for (i = -5; i < 7; i++) {
m_sig_radio_buttons[i+6] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_sig_radio_buttons[0]), gettext(m_keyTab[i+6]));
if (i < 0) {
gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
}
else {
gtk_box_pack_start (GTK_BOX (key_frame_right_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
}
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_sig_radio_buttons[m_key_signature_number+6]), TRUE);
gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_left_vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_right_vbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(key_frame), radio_hbox);
time_signature_frame = gtk_frame_new(_("time signature"));
time_signature_vbox = gtk_vbox_new(FALSE, 5);
time_signature_upper_hbox = gtk_hbox_new(FALSE, 5);
time_signature_lower_hbox = gtk_hbox_new(FALSE, 5);
numerator_label = gtk_label_new(_("Numerator:"));
denominator_label = gtk_label_new(_("Denominator:"));
m_numerator = gtk_spin_button_new_with_range (1.0, 20.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), m_numerator_value);
m_denominator = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "2");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "4");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "8");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "16");
if (m_denominator_value < 4) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
}
else if (m_denominator_value < 8) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
}
else if (m_denominator_value < 16) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 2);
}
else {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 3);
}
m_com_time_bu = gtk_toggle_button_new();
gtk_button_set_image(GTK_BUTTON(m_com_time_bu), gtk_image_new_from_stock("comm-icon", GTK_ICON_SIZE_SMALL_TOOLBAR));
m_cut_time_bu = gtk_toggle_button_new();
gtk_button_set_image(GTK_BUTTON(m_cut_time_bu), gtk_image_new_from_stock("cut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR));
g_signal_connect(m_com_time_bu, "toggled", G_CALLBACK (OnCommButtonToggled), (void *) this);
g_signal_connect(m_cut_time_bu, "toggled", G_CALLBACK (OnCutButtonToggled), (void *) this);
switch (symbol) {
case TIME_SYMBOL_COMMON_TIME: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_com_time_bu), TRUE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), 4);
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
gtk_widget_set_sensitive(m_numerator, FALSE);
gtk_widget_set_sensitive(m_denominator, FALSE);
break;
case TIME_SYMBOL_CUT_TIME: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_cut_time_bu), TRUE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), 2);
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
gtk_widget_set_sensitive(m_numerator, FALSE);
gtk_widget_set_sensitive(m_denominator, FALSE);
break;
}
staff_name_frame = gtk_frame_new(_("staff name"));
m_staffname = gtk_entry_new_with_max_length(50);
if (m_staff_name != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_staffname), m_staff_name);
}
gtk_container_add (GTK_CONTAINER(staff_name_frame), m_staffname);
staff_short_name_frame = gtk_frame_new(_("staff short name"));
m_staffshortname = gtk_entry_new_with_max_length(50);
if (m_staff_short_name != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_staffshortname), m_staff_short_name);
}
gtk_container_add (GTK_CONTAINER(staff_short_name_frame), m_staffshortname);
group_name_frame = gtk_frame_new(_("group name"));
m_groupname = gtk_entry_new_with_max_length(50);
if (m_group_name != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_groupname), m_group_name);
}
gtk_container_add (GTK_CONTAINER(group_name_frame), m_groupname);
group_short_name_frame = gtk_frame_new(_("group short name"));
m_groupshortname = gtk_entry_new_with_max_length(50);
if (m_group_short_name != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_groupshortname), m_group_short_name);
}
gtk_container_add (GTK_CONTAINER(group_short_name_frame), m_groupshortname);
tempo_frame = gtk_frame_new(_("tempo"));
m_tempo_scale = gtk_vscale_new_with_range(20.0, 300.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_tempo_scale), TRUE);
gtk_range_set_value(GTK_RANGE(m_tempo_scale), m_tempo);
gtk_container_add (GTK_CONTAINER(tempo_frame), m_tempo_scale);
chorus_frame = gtk_frame_new(_("chorus"));
m_chorus_scale = gtk_vscale_new_with_range(20.0, 127.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_chorus_scale), TRUE);
gtk_range_set_value(GTK_RANGE(m_chorus_scale), m_chorus);
gtk_container_add (GTK_CONTAINER(chorus_frame), m_chorus_scale);
play_transposed_frame = gtk_frame_new(_("transp."));
m_play_transposed_scale = gtk_vscale_new_with_range(-24.0, 24.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_play_transposed_scale), TRUE);
gtk_range_set_value(GTK_RANGE(m_play_transposed_scale), m_play_transposed);
gtk_container_add (GTK_CONTAINER(play_transposed_frame), m_play_transposed_scale);
reverb_frame = gtk_frame_new(_("reverb"));
m_reverb_scale = gtk_vscale_new_with_range(20.0, 127.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_reverb_scale), TRUE);
gtk_range_set_value(GTK_RANGE(m_reverb_scale), m_reverb);
gtk_container_add (GTK_CONTAINER(reverb_frame), m_reverb_scale);
volume_frame = gtk_frame_new(_("volume"));
// see also NedStaffContextDialog::SetCurrentVoiceParamsTo
m_volume_scale = gtk_vscale_new_with_range(0.0, 127.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_volume_scale), TRUE);
gtk_container_add (GTK_CONTAINER(volume_frame), m_volume_scale);
pan_frame = gtk_frame_new(_("pan"));
m_pan_scale = gtk_vscale_new_with_range(20.0, 127.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_pan_scale), TRUE);
// see also NedStaffContextDialog::SetCurrentVoiceParamsTo
gtk_container_add (GTK_CONTAINER(pan_frame), m_pan_scale);
instrumend_list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
for (i = 0; i < NedResource::getNumInstruments(); i++) {
gtk_list_store_append (instrumend_list_store, &iter);
gtk_list_store_set (instrumend_list_store, &iter, 0, i, 1, gettext(NedResource::GM_Instruments[i]), -1);
}
m_instrument_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(instrumend_list_store));
instrument_renderer = gtk_cell_renderer_text_new ();
instrument_num_column = gtk_tree_view_column_new_with_attributes (_("no"), instrument_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_num_column);
instrument_column = gtk_tree_view_column_new_with_attributes (_("instruments"), instrument_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_column);
m_instrument_adjustment = gtk_adjustment_new (0.0, 0.0, NedResource::getNumInstruments(), 1.0, 10.0, 10.0);
instrument_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(m_instrument_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_instrument_list), GTK_ADJUSTMENT(m_instrument_adjustment));
gtk_widget_set_size_request(m_instrument_list, 150, 100);
g_signal_connect(dialog, "scroll-event", G_CALLBACK (OnScroll), (void *) this);
// see also NedStaffContextDialog::SetCurrentVoiceParamsTo
channel_frame = gtk_frame_new(_("channel"));
m_channel_spin_box = gtk_spin_button_new_with_range (1.0, 16.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_channel_spin_box), m_channel_value + 1);
gtk_container_add (GTK_CONTAINER(channel_frame), m_channel_spin_box);
mute_frame = gtk_frame_new(_("muting"));
m_mute_all_check = gtk_check_button_new_with_label (_("all"));
m_mute_1_check = gtk_check_button_new_with_label ("1");
m_mute_2_check = gtk_check_button_new_with_label ("2");
m_mute_3_check = gtk_check_button_new_with_label ("3");
m_mute_4_check = gtk_check_button_new_with_label ("4");
mute_vbox = gtk_vbox_new (FALSE, 0);
mute_hbox1 = gtk_hbox_new (FALSE, 0);
mute_hbox2 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_vbox), m_mute_all_check, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_hbox1), m_mute_1_check, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_hbox1), m_mute_2_check, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_hbox2), m_mute_3_check, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_hbox2), m_mute_4_check, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_vbox), mute_hbox1, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (mute_vbox), mute_hbox2, FALSE, FALSE, 0);
all_muted = true;
for (i = 0; i < VOICE_COUNT; i++) {
if (!muted[i]) all_muted = false;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_mute_all_check), all_muted);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_mute_1_check), muted[0]);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_mute_2_check), muted[1]);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_mute_3_check), muted[2]);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_mute_4_check), muted[3]);
gtk_container_add(GTK_CONTAINER(mute_frame), mute_vbox);
voices_frame = gtk_frame_new(_("voices"));
m_radio_all = gtk_radio_button_new_with_label(NULL, _("all"));
g_signal_connect(m_mute_all_check, "toggled", G_CALLBACK (OnAllMutedToggle), (void *) this);
m_handlrs[0] = g_signal_connect(m_mute_1_check, "toggled", G_CALLBACK (OnSingleMutedToggle), (void *) this);
m_handlrs[1] = g_signal_connect(m_mute_2_check, "toggled", G_CALLBACK (OnSingleMutedToggle), (void *) this);
m_handlrs[2] = g_signal_connect(m_mute_3_check, "toggled", G_CALLBACK (OnSingleMutedToggle), (void *) this);
m_handlrs[3] = g_signal_connect(m_mute_4_check, "toggled", G_CALLBACK (OnSingleMutedToggle), (void *) this);
m_radio_1 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_radio_all), "1");
m_radio_2 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_radio_all), "2");
m_radio_3 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_radio_all), "3");
m_radio_4 = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_radio_all), "4");
if (different_voices) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_radio_1), TRUE);
SetCurrentVoiceParamsTo(0);
m_current_voice = 0;
}
else {
SetCurrentVoiceParamsTo(-1);
m_current_voice = -1;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_radio_all), TRUE);
}
g_signal_connect(m_radio_all, "toggled", G_CALLBACK (OnVoiceToggle), (void *) this);
g_signal_connect(m_radio_1, "toggled", G_CALLBACK (OnVoiceToggle), (void *) this);
g_signal_connect(m_radio_2, "toggled", G_CALLBACK (OnVoiceToggle), (void *) this);
g_signal_connect(m_radio_3, "toggled", G_CALLBACK (OnVoiceToggle), (void *) this);
g_signal_connect(m_radio_4, "toggled", G_CALLBACK (OnVoiceToggle), (void *) this);
vrb_vbox = gtk_vbox_new (FALSE, 0);
vrb_hbox1 = gtk_hbox_new (FALSE, 0);
vrb_hbox2 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_vbox), m_radio_all, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_hbox1), m_radio_1, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_hbox1), m_radio_2, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_hbox2), m_radio_3, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_hbox2), m_radio_4, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_vbox), vrb_hbox1, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vrb_vbox), vrb_hbox2, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(voices_frame), vrb_vbox);
mute_channel_vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(mute_channel_vbox), channel_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(mute_channel_vbox), mute_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(mute_channel_vbox), voices_frame, FALSE, FALSE, 0);
if (staff_count > 1) {
position_list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
for (i = 0; i < staff_count; i++) {
gtk_list_store_append (position_list_store, &iter);
if (main_window->m_staff_contexts[i].m_staff_name != NULL && strlen(main_window->m_staff_contexts[i].m_staff_name->getText()) > 0) {
gtk_list_store_set (position_list_store, &iter, 0, main_window->m_staff_contexts[i].m_staff_name->getText() , 1, i, -1);
}
else {
gtk_list_store_set (position_list_store, &iter, 0, _("staff") , 1, i, -1);
}
}
m_position_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(position_list_store));
position_renderer = gtk_cell_renderer_text_new ();
position_column = gtk_tree_view_column_new_with_attributes (_("item"), position_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_position_list), position_column);
position_num_column = gtk_tree_view_column_new_with_attributes (_("no"), position_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_position_list), position_num_column);
position_adjustment = gtk_adjustment_new (0.0, 0.0, 4, 1.0, 10.0, 10.0);
position_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(position_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_position_list), GTK_ADJUSTMENT(position_adjustment));
gtk_widget_set_size_request(m_position_list, 150, 100);
sprintf(Str, "%d", staff_pos);
position_tree_path = gtk_tree_path_new_from_string(Str);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_position_list), position_tree_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_position_list), position_tree_path, NULL, FALSE);
}
gtk_box_pack_start (GTK_BOX (time_signature_upper_hbox), numerator_label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_com_time_bu, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_numerator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_lower_hbox), denominator_label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_cut_time_bu, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_denominator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_upper_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_lower_hbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(time_signature_frame), time_signature_vbox);
signature_name_vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(signature_name_vbox), time_signature_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(signature_name_vbox), staff_name_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(signature_name_vbox), staff_short_name_frame, FALSE, FALSE, 0);
group_name_vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(group_name_vbox), group_name_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(group_name_vbox), group_short_name_frame, FALSE, FALSE, 0);
score_hbox = gtk_hbox_new(FALSE, 2);
midi_hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(score_hbox), clef_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(score_hbox), key_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(score_hbox), signature_name_vbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(score_hbox), group_name_vbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), tempo_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), chorus_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), reverb_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), play_transposed_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), volume_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), pan_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), m_instrument_list, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), instrument_scroll, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(midi_hbox), mute_channel_vbox, FALSE, TRUE, 0);
label_score = gtk_label_new(_("Score"));
label_midi = gtk_label_new(_("MIDI"));
m_table = gtk_notebook_new();
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), score_hbox, label_score);
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), midi_hbox, label_midi);
if (staff_count > 1) {
position_hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(position_hbox), m_position_list, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(position_hbox), position_scroll, FALSE, TRUE, 0);
label_position = gtk_label_new(_("Staff position"));
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), position_hbox, label_position);
}
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), m_table);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedStaffContextDialog::SetCurrentVoiceParamsTo(int voice) {
int idx = 0;
char Str[128];
GtkTreePath* instrument_tree_path;
switch (voice) {
case -1:
case 0: idx = 0; break;
case 1: idx = 1; break;
case 2: idx = 2; break;
case 3: idx = 3; break;
default: NedResource::Abort("NedStaffContextDialog::SetCurrentVoiceParamsTo");
}
gtk_range_set_value(GTK_RANGE(m_volume_scale), m_volume[idx]);
gtk_range_set_value(GTK_RANGE(m_pan_scale), m_pan[idx]);
sprintf(Str, "%d", m_midi_program_number[idx]);
instrument_tree_path = gtk_tree_path_new_from_string(Str);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE);
}
void NedStaffContextDialog::GetCurrentVoiceParamsFrom(int voice, int volume[VOICE_COUNT], int pan[VOICE_COUNT], int instrument[VOICE_COUNT], bool *changed) {
int idx = 0;
GtkTreeSelection* selection;
GList *selected_rows;
int newvolume, newpan, newpgm;
switch (voice) {
case -1:
case 0: idx = 0; break;
case 1: idx = 1; break;
case 2: idx = 2; break;
case 3: idx = 3; break;
default: NedResource::Abort("NedStaffContextDialog::GetCurrentVoiceParamsFRom");
}
newvolume = (int) gtk_range_get_value(GTK_RANGE(m_volume_scale));
if (newvolume != volume[idx]) {
volume[idx] = newvolume;
*changed = TRUE;
}
newpan = (int) gtk_range_get_value(GTK_RANGE(m_pan_scale));
if (newpan != pan[idx]) {
pan[idx] = newpan;
*changed = TRUE;
}
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(m_instrument_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &(newpgm)) != 1) {
NedResource::Abort("NedStaffContextDialog::OnClose: error reading tree path(1)");
}
}
else {
newpgm = -1;
}
if (instrument[idx] != newpgm) {
instrument[idx] = newpgm;
*changed = true;
}
}
void NedStaffContextDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
int i;
bool newmute;
int newchannel;
int newnum, newdenom, newkeysig, newtempo;
int newchorus, newplaytransposed, newreverb, new_octave_shift;
const char *newname, *newshortname;
const char *newgroupname, *newshortgroupname;
bool diff, newdifferentvoices;
GtkTreeSelection* selection;
GList *selected_rows;
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
context_dialog->m_delete_staff = FALSE;
context_dialog->m_delete_system = FALSE;
switch (result) {
case GTK_RESPONSE_ACCEPT:
context_dialog->m_state = TRUE;
break;
case DELETE_STAFF_CMD:
context_dialog->m_delete_staff = TRUE;
context_dialog->m_state = FALSE;
break;
case DELETE_SYSTEM_CMD:
context_dialog->m_delete_system = TRUE;
context_dialog->m_state = FALSE;
break;
default:
context_dialog->m_state = FALSE;
break;
}
newkeysig = 0;
context_dialog->m_key_signature_number = 0;
for (i = 0; i < 13; i++) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (context_dialog->m_sig_radio_buttons[i]))) {
newkeysig = i - 6;
}
}
if (newkeysig != context_dialog->m_key_signature_number) {
context_dialog->m_key_signature_number = newkeysig;
context_dialog->m_config_changed = TRUE;
}
newnum = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(context_dialog->m_numerator));
if (newnum != context_dialog->m_numerator_value) {
context_dialog->m_numerator_value = newnum;
context_dialog->m_config_changed = TRUE;
}
switch (gtk_combo_box_get_active(GTK_COMBO_BOX(context_dialog->m_denominator))) {
case 0: newdenom = 2; break;
case 1: newdenom = 4; break;
case 2: newdenom = 8; break;
default: newdenom = 16; break;
}
if (newdenom != context_dialog->m_denominator_value) {
context_dialog->m_denominator_value = newdenom;
context_dialog->m_config_changed = TRUE;
}
newtempo = (int) gtk_range_get_value(GTK_RANGE(context_dialog->m_tempo_scale));
if (newtempo != context_dialog->m_tempo) {
context_dialog->m_tempo = newtempo;
context_dialog->m_config_changed = TRUE;
}
newchorus = (int) gtk_range_get_value(GTK_RANGE(context_dialog->m_chorus_scale));
if (newchorus != context_dialog->m_chorus) {
context_dialog->m_chorus = newchorus;
context_dialog->m_config_changed = TRUE;
}
newplaytransposed = (int) gtk_range_get_value(GTK_RANGE(context_dialog->m_play_transposed_scale));
if (newplaytransposed != context_dialog->m_play_transposed) {
context_dialog->m_play_transposed = newplaytransposed;
context_dialog->m_config_changed = TRUE;
}
newreverb = (int) gtk_range_get_value(GTK_RANGE(context_dialog->m_reverb_scale));
if (newreverb != context_dialog->m_reverb) {
context_dialog->m_reverb = newreverb;
context_dialog->m_config_changed = TRUE;
}
newmute = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_1_check));
if (context_dialog->m_muted[0] != newmute) {
context_dialog->m_muted[0] = newmute;
context_dialog->m_config_changed = TRUE;
}
newmute = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_2_check));
if (context_dialog->m_muted[1] != newmute) {
context_dialog->m_muted[1] = newmute;
context_dialog->m_config_changed = TRUE;
}
newmute = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_3_check));
if (context_dialog->m_muted[2] != newmute) {
context_dialog->m_muted[2] = newmute;
context_dialog->m_config_changed = TRUE;
}
newmute = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_4_check));
if (context_dialog->m_muted[3] != newmute) {
context_dialog->m_muted[3] = newmute;
context_dialog->m_config_changed = TRUE;
}
context_dialog->m_do_adjust = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_adjust_check_box));
newname = gtk_entry_get_text(GTK_ENTRY(context_dialog->m_staffname));
if (strlen(newname) < 1) {
newname = NULL;
}
diff = (newname == NULL && context_dialog->m_staff_name != NULL) ||
(newname != NULL && context_dialog->m_staff_name == NULL);
if (newname != NULL && context_dialog->m_staff_name != NULL) {
diff = diff || strcmp(newname, context_dialog->m_staff_name) != 0;
}
if (diff) {
context_dialog->m_config_changed = TRUE;
}
if (newname != NULL && strlen(newname) > 0) {
context_dialog->m_staff_name = strdup(newname);
}
else {
context_dialog->m_staff_name = NULL;
}
newshortname = gtk_entry_get_text(GTK_ENTRY(context_dialog->m_staffshortname));
diff = (newshortname == NULL && context_dialog->m_staff_short_name != NULL) ||
(newshortname != NULL && context_dialog->m_staff_short_name == NULL);
if (newshortname != NULL && context_dialog->m_staff_short_name != NULL) {
diff = diff || strcmp(newshortname, context_dialog->m_staff_short_name) != 0;
}
if (diff) {
context_dialog->m_config_changed = TRUE;
}
if (newshortname != NULL && strlen(newshortname) > 0) {
context_dialog->m_staff_short_name = strdup(newshortname);
}
else {
context_dialog->m_staff_short_name = NULL;
}
newgroupname = gtk_entry_get_text(GTK_ENTRY(context_dialog->m_groupname));
if (strlen(newgroupname) < 1) {
newgroupname = NULL;
}
diff = (newgroupname == NULL && context_dialog->m_group_name != NULL) ||
(newgroupname != NULL && context_dialog->m_group_name == NULL);
if (newgroupname != NULL && context_dialog->m_group_name != NULL) {
diff = diff || strcmp(newgroupname, context_dialog->m_group_name) != 0;
}
if (diff) {
context_dialog->m_config_changed = TRUE;
}
if (newgroupname != NULL && strlen(newgroupname) > 0) {
context_dialog->m_group_name = strdup(newgroupname);
}
else {
context_dialog->m_group_name = NULL;
}
newshortgroupname = gtk_entry_get_text(GTK_ENTRY(context_dialog->m_groupshortname));
diff = (newshortgroupname == NULL && context_dialog->m_group_short_name != NULL) ||
(newshortgroupname != NULL && context_dialog->m_group_short_name == NULL);
if (newshortgroupname != NULL && context_dialog->m_group_short_name != NULL) {
diff = diff || strcmp(newshortgroupname, context_dialog->m_group_short_name) != 0;
}
if (diff) {
context_dialog->m_config_changed = TRUE;
}
if (newshortgroupname != NULL && strlen(newshortgroupname) > 0) {
context_dialog->m_group_short_name = strdup(newshortgroupname);
}
else {
context_dialog->m_group_short_name = NULL;
}
if (context_dialog->m_staff_count > 1) {
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(context_dialog->m_position_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if (g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &(context_dialog->m_staff_pos)) != 1) {
NedResource::Abort("NedStaffContextDialog::OnClose: error reading tree path(2)");
}
}
}
new_octave_shift = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(context_dialog->m_octave_shift_spin_box));
switch (new_octave_shift) {
case 8: new_octave_shift = 12; break;
case -8: new_octave_shift = -12; break;
}
if (new_octave_shift != context_dialog->m_octave_shift) {
context_dialog->m_octave_shift = new_octave_shift;
context_dialog->m_config_changed = true;
}
newchannel = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(context_dialog->m_channel_spin_box)) - 1;
if (newchannel != context_dialog->m_channel_value) {
context_dialog->m_channel_value = newchannel;
context_dialog->m_config_changed = true;
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_com_time_bu))) {
context_dialog->m_symbol = TIME_SYMBOL_COMMON_TIME;
context_dialog->m_numerator_value = context_dialog->m_denominator_value = 4;
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_cut_time_bu))) {
context_dialog->m_symbol = TIME_SYMBOL_CUT_TIME;
context_dialog->m_numerator_value = context_dialog->m_denominator_value = 2;
}
else {
context_dialog->m_symbol = TIME_SYMBOL_NONE;
}
newdifferentvoices = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_radio_all));
if (newdifferentvoices != context_dialog->m_different_voices) {
context_dialog->m_config_changed = TRUE;
context_dialog->m_different_voices = newdifferentvoices;
}
context_dialog->GetCurrentVoiceParamsFrom(context_dialog->m_current_voice, context_dialog->m_volume, context_dialog->m_pan, context_dialog->m_midi_program_number,
&(context_dialog->m_config_changed));
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedStaffContextDialog::getValues(bool *state, bool *different_voices, bool *delete_staff, bool *delete_system, int *staff_pos, char **staff_name, char **staff_short_name, char **group_name, char **group_short_name, int *clef_number, int *octave_shift, int *key_signature_number, bool *ajdust_notes, int *numerator, int *demoninator, unsigned int *symbol, int volume[VOICE_COUNT], int midi_program[VOICE_COUNT], int *channel, int *tempo, int pan[VOICE_COUNT], int *chorus, int *play_transposed, int *reverb, bool *config_changed, bool muted[VOICE_COUNT]) {
int i;
*different_voices = m_different_voices;
*delete_staff = m_delete_staff;
*delete_system = m_delete_system;
*state = m_state;
*staff_pos = m_staff_pos;
if (m_newclef != m_current_clef) {
m_current_clef = m_newclef;
m_config_changed = TRUE;
}
*ajdust_notes = m_do_adjust;
*staff_name = m_staff_name;
*staff_short_name = m_staff_short_name;
*group_name = m_group_name;
*group_short_name = m_group_short_name;
*clef_number = m_current_clef;
*key_signature_number = m_key_signature_number;
*numerator = m_numerator_value;
*demoninator = m_denominator_value;
*tempo = m_tempo;
*chorus = m_chorus;
*play_transposed = m_play_transposed;
*reverb = m_reverb;
*octave_shift = m_octave_shift;
*channel = m_channel_value;
*muted = m_muted;
*symbol = m_symbol;
for (i = 0; i < VOICE_COUNT; i++) {
volume[i] = m_volume[i];
midi_program[i] = m_midi_program_number[i];
pan[i] = m_pan[i];
muted[i] = m_muted[i];
}
if (m_state) {
*config_changed = m_config_changed;
}
else {
*config_changed = FALSE;
}
}
gboolean NedStaffContextDialog::draw_clefs(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
#define ZOOM_LEVEL 9
NedStaffContextDialog *the_dialog = (NedStaffContextDialog *) data;
cairo_scaled_font_t *scaled_font;
cairo_glyph_t glyph;
int i;
double y_offs = 0.0, oct_y_offs = 0.0, oct_x_offs = 0.0;
bool octave_shift = false;
cairo_t *cr;
cr = gdk_cairo_create (the_dialog->m_clef_show_window->window);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, 0, 0, the_dialog->m_clef_show_window->allocation.width, the_dialog->m_clef_show_window->allocation.height);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
scaled_font = NedResource::getScaledFont(ZOOM_LEVEL);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(ZOOM_LEVEL));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
cairo_new_path(cr);
cairo_set_line_width(cr, DEMO_LINE_THICK);
for (i = 0; i < 5; i++) {
cairo_move_to(cr, DEMO_LINE_BEGIN, DEMO_LINE_YPOS + DEMO_LINE_DIST * i);
cairo_line_to(cr, DEMO_LINE_END, DEMO_LINE_YPOS + DEMO_LINE_DIST * i);
}
cairo_stroke(cr);
cairo_new_path(cr);
switch (the_dialog->m_newclef) {
case TREBLE_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_TREBLE_DIST_UP); octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_TREBLE_DIST_DOWN); octave_shift = true; break;
}
glyph.index = BASE + 2; break;
case BASS_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_BASS_DIST_UP); octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_BASS_DIST_DOWN); octave_shift = true; break;
}
glyph.index = BASE + 3; break;
case ALTO_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_UP);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_DOWN);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
}
glyph.index = BASE + 1; break;
case SOPRAN_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_UP);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_DOWN);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
}
glyph.index = BASE + 1; y_offs = 2 * DEMO_LINE_DIST; break;
case TENOR_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_UP);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_DOWN);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
}
glyph.index = BASE + 1; y_offs = -DEMO_LINE_DIST; break;
case NEUTRAL_CLEF1:
case NEUTRAL_CLEF2:
case NEUTRAL_CLEF3:
glyph.index = BASE + 27; break;
}
glyph.x = 50.0;
glyph.y = 70.0 + y_offs;
cairo_show_glyphs(cr, &glyph, 1);
switch (the_dialog->m_newclef) {
case NEUTRAL_CLEF1: glyph.index = NUMBERBASE + 1;
glyph.x = 60.0;
glyph.y = 120.0;
cairo_show_glyphs(cr, &glyph, 1);
break;
case NEUTRAL_CLEF2: glyph.index = NUMBERBASE + 2;
glyph.x = 60.0;
glyph.y = 120.0;
cairo_show_glyphs(cr, &glyph, 1);
break;
case NEUTRAL_CLEF3: glyph.index = NUMBERBASE + 3;
glyph.x = 60.0;
glyph.y = 120.0;
cairo_show_glyphs(cr, &glyph, 1);
break;
}
if (octave_shift) {
glyph.x = 50.0 + oct_x_offs;
glyph.y = 70.0 + y_offs + oct_y_offs;
glyph.index = BASE + 28;
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_destroy (cr);
return FALSE;
}
void NedStaffContextDialog::decrease_clef_number (GtkButton *button, gpointer data) {
GdkRectangle rect;
NedStaffContextDialog *the_dialog = (NedStaffContextDialog *) data;
if (the_dialog->m_newclef <= MINCLEF_NUMBER) return;
the_dialog->m_newclef--;
gtk_widget_set_sensitive(the_dialog->m_clef_bu_up, TRUE);
gtk_widget_set_sensitive(the_dialog->m_clef_bu_down, TRUE);
if (the_dialog->m_newclef == MINCLEF_NUMBER) {
gtk_widget_set_sensitive(the_dialog->m_clef_bu_up, FALSE);
}
rect.x = rect.y = 0;
rect.width = the_dialog->m_clef_show_window->allocation.width;
rect.height = the_dialog->m_clef_show_window->allocation.height;
gdk_window_invalidate_rect (the_dialog->m_clef_show_window->window, &rect, FALSE);
}
void NedStaffContextDialog::increase_clef_number (GtkButton *button, gpointer data) {
GdkRectangle rect;
NedStaffContextDialog *the_dialog = (NedStaffContextDialog *) data;
if (the_dialog->m_newclef >= MAXCLEF_NUMBER) return;
the_dialog->m_newclef++;
gtk_widget_set_sensitive(the_dialog->m_clef_bu_up, TRUE);
gtk_widget_set_sensitive(the_dialog->m_clef_bu_down, TRUE);
if (the_dialog->m_newclef >= MAXCLEF_NUMBER) {
gtk_widget_set_sensitive(the_dialog->m_clef_bu_down, FALSE);
}
rect.x = rect.y = 0;
rect.width = the_dialog->m_clef_show_window->allocation.width;
rect.height = the_dialog->m_clef_show_window->allocation.height;
gdk_window_invalidate_rect (the_dialog->m_clef_show_window->window, &rect, FALSE);
}
gboolean NedStaffContextDialog::OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data) {
#define SCROLL_INCR 20.0
double adjval;
NedStaffContextDialog *the_dialog = (NedStaffContextDialog *) data;
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(the_dialog->m_table)) != 1) return FALSE;
adjval = gtk_adjustment_get_value(GTK_ADJUSTMENT(the_dialog->m_instrument_adjustment));
if (event->direction == GDK_SCROLL_UP) {
adjval -= SCROLL_INCR;
}
else if (event->direction == GDK_SCROLL_DOWN) {
adjval += SCROLL_INCR;
}
gtk_adjustment_set_value(GTK_ADJUSTMENT(the_dialog->m_instrument_adjustment), adjval);
return FALSE;
}
void NedStaffContextDialog::octave_shift_change(GtkSpinButton *spinbutton, gpointer data) {
GdkRectangle rect;
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
context_dialog->m_octave_shift = (int) gtk_spin_button_get_value(spinbutton);
switch (context_dialog->m_octave_shift) {
case 8: context_dialog->m_octave_shift = 12; break;
case -8: context_dialog->m_octave_shift = -12; break;
}
rect.x = rect.y = 0;
rect.width = context_dialog->m_clef_show_window->allocation.width;
rect.height = context_dialog->m_clef_show_window->allocation.height;
gdk_window_invalidate_rect (context_dialog->m_clef_show_window->window, &rect, FALSE);
}
void NedStaffContextDialog::OnCommButtonToggled(GtkToggleButton *togglebutton, gpointer data) {
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_com_time_bu))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_cut_time_bu), FALSE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(context_dialog->m_numerator), 4);
gtk_combo_box_set_active(GTK_COMBO_BOX(context_dialog->m_denominator), 1);
gtk_widget_set_sensitive(context_dialog->m_numerator, FALSE);
gtk_widget_set_sensitive(context_dialog->m_denominator, FALSE);
}
else if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_cut_time_bu))) {
gtk_widget_set_sensitive(context_dialog->m_numerator, TRUE);
gtk_widget_set_sensitive(context_dialog->m_denominator, TRUE);
}
}
void NedStaffContextDialog::OnCutButtonToggled(GtkToggleButton *togglebutton, gpointer data) {
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_cut_time_bu))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_com_time_bu), FALSE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(context_dialog->m_numerator), 2);
gtk_combo_box_set_active(GTK_COMBO_BOX(context_dialog->m_denominator), 0);
gtk_widget_set_sensitive(context_dialog->m_numerator, FALSE);
gtk_widget_set_sensitive(context_dialog->m_denominator, FALSE);
}
else if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_com_time_bu))) {
gtk_widget_set_sensitive(context_dialog->m_numerator, TRUE);
gtk_widget_set_sensitive(context_dialog->m_denominator, TRUE);
}
}
void NedStaffContextDialog::OnVoiceToggle(GtkToggleButton *togglebutton, gpointer data) {
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
int oldvoice = context_dialog->m_current_voice;
if (togglebutton == GTK_TOGGLE_BUTTON(context_dialog->m_radio_all)) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_radio_all))) {
context_dialog->SetCurrentVoiceParamsTo(-1);
context_dialog->m_current_voice = -1;
}
else {
context_dialog->GetCurrentVoiceParamsFrom(-1, context_dialog->m_volume, context_dialog->m_pan,
context_dialog->m_midi_program_number, &(context_dialog->m_config_changed));
}
}
else if (togglebutton == GTK_TOGGLE_BUTTON(context_dialog->m_radio_1)) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_radio_1))) {
context_dialog->SetCurrentVoiceParamsTo(0);
context_dialog->m_current_voice = 0;
}
else {
context_dialog->GetCurrentVoiceParamsFrom(0, context_dialog->m_volume, context_dialog->m_pan,
context_dialog->m_midi_program_number, &(context_dialog->m_config_changed));
}
}
else if (togglebutton == GTK_TOGGLE_BUTTON(context_dialog->m_radio_2)) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_radio_2))) {
context_dialog->SetCurrentVoiceParamsTo(1);
context_dialog->m_current_voice = 1;
}
else {
context_dialog->GetCurrentVoiceParamsFrom(1, context_dialog->m_volume, context_dialog->m_pan,
context_dialog->m_midi_program_number, &(context_dialog->m_config_changed));
}
}
else if (togglebutton == GTK_TOGGLE_BUTTON(context_dialog->m_radio_3)) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_radio_3))) {
context_dialog->SetCurrentVoiceParamsTo(2);
context_dialog->m_current_voice = 2;
}
else {
context_dialog->GetCurrentVoiceParamsFrom(2, context_dialog->m_volume, context_dialog->m_pan,
context_dialog->m_midi_program_number, &(context_dialog->m_config_changed));
}
}
else if (togglebutton == GTK_TOGGLE_BUTTON(context_dialog->m_radio_4)) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_radio_4))) {
context_dialog->SetCurrentVoiceParamsTo(3);
context_dialog->m_current_voice = 3;
}
else {
context_dialog->GetCurrentVoiceParamsFrom(3, context_dialog->m_volume, context_dialog->m_pan,
context_dialog->m_midi_program_number, &(context_dialog->m_config_changed));
}
}
}
void NedStaffContextDialog::OnAllMutedToggle(GtkToggleButton *togglebutton, gpointer data) {
bool toggle_state;
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
toggle_state = gtk_toggle_button_get_active (togglebutton);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_1_check), toggle_state);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_2_check), toggle_state);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_3_check), toggle_state);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_4_check), toggle_state);
}
void NedStaffContextDialog::OnSingleMutedToggle(GtkToggleButton *togglebutton, gpointer data) {
int i;
bool toggle_state;
bool all_muted = true;
bool none_muted = true;
NedStaffContextDialog *context_dialog = (NedStaffContextDialog *) data;
toggle_state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_1_check));
if (toggle_state) {
none_muted = false;
}
else {
all_muted = false;
}
toggle_state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_2_check));
if (toggle_state) {
none_muted = false;
}
else {
all_muted = false;
}
toggle_state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_3_check));
if (toggle_state) {
none_muted = false;
}
else {
all_muted = false;
}
toggle_state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_4_check));
if (toggle_state) {
none_muted = false;
}
else {
all_muted = false;
}
g_signal_handler_block(context_dialog->m_mute_1_check, context_dialog->m_handlrs[0]);
g_signal_handler_block(context_dialog->m_mute_2_check, context_dialog->m_handlrs[1]);
g_signal_handler_block(context_dialog->m_mute_3_check, context_dialog->m_handlrs[2]);
g_signal_handler_block(context_dialog->m_mute_4_check, context_dialog->m_handlrs[3]);
if (none_muted) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_all_check), FALSE);
}
if (all_muted) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context_dialog->m_mute_all_check), TRUE);
}
g_signal_handler_unblock(context_dialog->m_mute_1_check, context_dialog->m_handlrs[0]);
g_signal_handler_unblock(context_dialog->m_mute_2_check, context_dialog->m_handlrs[1]);
g_signal_handler_unblock(context_dialog->m_mute_3_check, context_dialog->m_handlrs[2]);
g_signal_handler_unblock(context_dialog->m_mute_4_check, context_dialog->m_handlrs[3]);
}
nted-1.10.18/dialogs/staffselectdialog.h 0000664 0010410 0000764 00000003707 11520267217 015024 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef STAFF_SELECT_DIALOG_H
#define STAFF_SELECT_DIALOG_H
#include "config.h"
#include
class NedMainWindow;
class NedStaffSelectDialog {
public:
NedStaffSelectDialog(GtkWindow *parent, const char *title, NedMainWindow *main_window, bool *selected_staves);
void getValues(bool *state);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static void add_staff(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
static void OnAll(GtkButton *button, gpointer data);
static void OnNone(GtkButton *button, gpointer data);
GtkWidget *m_position_list;
GtkTreeSelection *m_tree_selection;
NedMainWindow *m_main_window;
bool *m_selected_staves;
bool m_state;
};
#endif /* STAFF_SELECT_DIALOG_H */
nted-1.10.18/dialogs/staffcontextdialog.h 0000664 0010410 0000764 00000012577 11520267217 015236 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef STAFF_CONTEXT_DIALOG_H
#define STAFF_CONTEXT_DIALOG_H
#include "config.h"
#include
#include
#include "resource.h"
#define DELETE_STAFF_CMD 12
#define DELETE_SYSTEM_CMD 13
class NedMainWindow;
class NedStaffContextDialog {
public:
NedStaffContextDialog(GtkWindow *parent, NedMainWindow *main_window, bool different_voices, bool allow_delete_system, int staff_count, int staff_pos, char *staff_name, char *staffshortname, char *group_name, char* group_short_name, int clef_number, int octave_shift, int key_signature_number, int numerator, int demoninator, unsigned int symbol, int volume[VOICE_COUNT], int midi_program[VOICE_COUNT], int channel, int tempo, int pan[VOICE_COUNT], int chorus, int play_transposed, int reverb, bool muted[VOICE_COUNT]);
void getValues(bool *state, bool *different_voices, bool *delete_staff, bool *delete_system, int *staff_pos, char **staff_name, char **staff_short_name, char **group_name, char **group_short_name, int *clef_number, int *octave_shift, int *key_signature_number, bool *ajdust_notes, int *numerator, int *demoninator, unsigned int *symbol, int volume[VOICE_COUNT], int midi_program[VOICE_COUNT], int *channel, int *tempo, int pan[VOICE_COUNT], int *chorus, int *play_transposed, int *reverb, bool *config_changed, bool muted[VOICE_COUNT]);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static gboolean OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data);
static gboolean draw_clefs(GtkWidget *widget,
GdkEventExpose *event, gpointer data);
static void OnCommButtonToggled(GtkToggleButton *togglebutton, gpointer data);
static void OnCutButtonToggled(GtkToggleButton *togglebutton, gpointer data);
static void OnVoiceToggle(GtkToggleButton *togglebutton, gpointer data);
static void OnAllMutedToggle(GtkToggleButton *togglebutton, gpointer data);
static void OnSingleMutedToggle(GtkToggleButton *togglebutton, gpointer data);
static void decrease_clef_number (GtkButton *button, gpointer user_data);
static void increase_clef_number (GtkButton *button, gpointer user_data);
static void octave_shift_change(GtkSpinButton *spinbutton, gpointer user_data);
void SetCurrentVoiceParamsTo(int voice);
void GetCurrentVoiceParamsFrom(int voice, int volume[VOICE_COUNT], int pan[VOICE_COUNT], int instrument[VOICE_COUNT], bool *changed);
GtkWidget *m_clef_show_window;
static char *m_keyTab[];
GtkWidget *m_sig_radio_buttons[14];
GtkWidget *m_denominator;
GtkWidget *m_numerator;
GtkWidget *m_com_time_bu;
GtkWidget *m_cut_time_bu;
GtkWidget *m_clef_bu_up;
GtkWidget *m_clef_bu_down;
GtkWidget *m_instrument_list;
GtkWidget *m_volume_scale;
GtkWidget *m_pan_scale;
GtkWidget *m_tempo_scale;
GtkWidget *m_chorus_scale;
GtkWidget *m_play_transposed_scale;
GtkWidget *m_reverb_scale;
GtkWidget *m_channel_spin_box;
GtkWidget *m_mute_all_check;
GtkWidget *m_mute_1_check;
GtkWidget *m_mute_2_check;
GtkWidget *m_mute_3_check;
GtkWidget *m_mute_4_check;
GtkWidget *m_octave_shift_spin_box;
GtkWidget *m_adjust_check_box;
GtkWidget *m_position_list;
GtkWidget *m_staffname;
GtkWidget *m_radio_all;
GtkWidget *m_radio_1;
GtkWidget *m_radio_2;
GtkWidget *m_radio_3;
GtkWidget *m_radio_4;
GtkWidget *m_staffshortname;
GtkWidget *m_groupname;
GtkWidget *m_groupshortname;
GtkWidget *m_table;
GtkObject *m_instrument_adjustment;
int m_current_voice;
bool m_different_voices;
int m_octave_shift;
int m_tempo;
int m_chorus;
int m_play_transposed;
int m_reverb;
int m_channel_value;
bool m_state;
int m_numerator_value;
int m_denominator_value;
unsigned int m_symbol;
int m_time_symbol;
int m_key_signature_number;
int m_current_clef, m_newclef;
bool m_do_adjust;
int m_midi_program_number[VOICE_COUNT];
int m_pan[VOICE_COUNT];
int m_volume[VOICE_COUNT];
bool m_config_changed;
bool m_delete_staff;
bool m_delete_system;
int m_staff_pos;
int m_staff_count;
char *m_staff_name;
char *m_staff_short_name;
char *m_group_name;
char *m_group_short_name;
bool m_muted[VOICE_COUNT];
gulong m_handlrs[VOICE_COUNT];
friend class NedKeysigDialog;
friend class NedMidiRecordConfigDialog;
};
#endif /* STAFF_CONTEXT_DIALOG_H */
nted-1.10.18/dialogs/selectordialog.cpp 0000664 0010410 0000764 00000017203 11520267217 014670 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "selectordialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#include "pangocairotext.h"
NedSelectorDialog::NedSelectorDialog(GtkWindow *parent, bool with_transpose, bool *staff_list, bool selected, struct staff_context_str *staff_contexts, int numstaffs) :
m_with_transpose(with_transpose), m_staff_list(staff_list), m_selected(selected), m_numstaffs(numstaffs) {
GtkWidget *dialog;
int i;
char Str[128];
if (with_transpose) {
dialog = gtk_dialog_new_with_buttons(_("Transpose"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
}
else {
dialog = gtk_dialog_new_with_buttons(_("Select"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
}
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
GtkWidget *transpose_frame;
GtkWidget *transpose_hbox;
GtkWidget *buttonbox;
GtkWidget *hbox;
GtkWidget *selection_frame;
buttonbox = gtk_vbox_new(FALSE, 0);
try {
m_checkboxes= new GtkWidget*[numstaffs];
}
catch(std::exception& e){
NedResource::Abort("NedSelectorDialog: allocation error");
}
for (i = 0; i < numstaffs; i++) {
if (staff_contexts[i].m_staff_name == NULL) {
sprintf(Str, _("Staff %d"), i);
m_checkboxes[i] = gtk_check_button_new_with_label(Str);
}
else {
m_checkboxes[i] = gtk_check_button_new_with_label(staff_contexts[i].m_staff_name->getText());
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkboxes[i]),
staff_contexts[i].m_midi_channel != 9);
gtk_box_pack_start(GTK_BOX(buttonbox), m_checkboxes[i], FALSE, FALSE, 0);
}
if (with_transpose) {
transpose_frame = gtk_frame_new(_("half-tones"));
}
else {
transpose_frame = gtk_frame_new(_("selection"));
}
transpose_hbox = gtk_hbox_new(FALSE, 2);
if (with_transpose) {
m_transpose_spin_box = gtk_spin_button_new_with_range(-12.0, 12.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_transpose_spin_box), 0.0);
gtk_box_pack_start(GTK_BOX(transpose_hbox), m_transpose_spin_box, FALSE, FALSE, 0);
}
m_selection_checkbox = gtk_check_button_new_with_label(_("use selection"));
gtk_box_pack_end(GTK_BOX(transpose_hbox), m_selection_checkbox, FALSE, FALSE, 0);
g_signal_connect(m_selection_checkbox, "toggled", G_CALLBACK (OnUseSelection), (void *) this);
gtk_container_add (GTK_CONTAINER(transpose_frame), transpose_hbox);
selection_frame = gtk_frame_new(_("selection"));
hbox = gtk_hbox_new(TRUE, 0);
m_allbutton = gtk_button_new_with_label(_("all"));
g_signal_connect(m_allbutton, "pressed", G_CALLBACK (OnAll), (void *) this);
m_nonebutton = gtk_button_new_with_label(_("none"));
g_signal_connect(m_nonebutton, "pressed", G_CALLBACK (OnNone), (void *) this);
gtk_box_pack_start(GTK_BOX(hbox), m_allbutton, TRUE, TRUE, 5);
gtk_box_pack_start(GTK_BOX(hbox), m_nonebutton, TRUE, TRUE, 5);
gtk_box_pack_start(GTK_BOX(buttonbox), hbox, TRUE, TRUE, 5);
gtk_container_add (GTK_CONTAINER(selection_frame), buttonbox);
if (m_selected) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_selection_checkbox), TRUE);
gtk_widget_set_sensitive(m_allbutton, FALSE);
gtk_widget_set_sensitive(m_nonebutton, FALSE);
for (i = 0; i < numstaffs; i++) {
if (staff_contexts[i].m_staff_name == NULL) {
gtk_widget_set_sensitive(m_checkboxes[i], FALSE);
}
}
}
else {
gtk_widget_set_sensitive(m_selection_checkbox, FALSE);
}
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), transpose_frame);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), selection_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedSelectorDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
int i;
double val;
bool one_checked = false;
NedSelectorDialog *selector_dialog = (NedSelectorDialog *) data;
for (i = 0; i < selector_dialog->m_numstaffs; i++) {
selector_dialog->m_staff_list[i] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(selector_dialog->m_checkboxes[i]));
if (selector_dialog->m_staff_list[i]) one_checked = true;
}
switch (result) {
case GTK_RESPONSE_ACCEPT:
if (!one_checked) {
selector_dialog->m_state = FALSE;
break;
}
selector_dialog->m_state = TRUE;
break;
default:
selector_dialog->m_state = FALSE;
break;
}
if (selector_dialog->m_with_transpose) {
val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(selector_dialog->m_transpose_spin_box));
selector_dialog->m_pitch_dist = (int) ((val > 0.0) ? (val + 0.5) : (val - 0.5));
}
gtk_widget_destroy (GTK_WIDGET(dialog));
delete[] selector_dialog->m_checkboxes;
}
void NedSelectorDialog::getValues(bool *state, int *pitchdist, bool *selected) {
*state = m_state;
if (m_with_transpose) {
*state = *state && m_pitch_dist != 0;
*pitchdist = m_pitch_dist;
}
*selected = m_selected;
}
void NedSelectorDialog::OnAll(GtkButton *button, gpointer data) {
int i;
NedSelectorDialog *selector_dialog = (NedSelectorDialog *) data;
for (i = 0; i < selector_dialog->m_numstaffs; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selector_dialog->m_checkboxes[i]), TRUE);
}
}
void NedSelectorDialog::OnNone(GtkButton *button, gpointer data) {
int i;
NedSelectorDialog *selector_dialog = (NedSelectorDialog *) data;
for (i = 0; i < selector_dialog->m_numstaffs; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selector_dialog->m_checkboxes[i]), FALSE);
}
}
void NedSelectorDialog::OnUseSelection(GtkToggleButton *togglebutton, gpointer data) {
int i;
NedSelectorDialog *selector_dialog = (NedSelectorDialog *) data;
if (gtk_toggle_button_get_active(togglebutton)) {
gtk_widget_set_sensitive(selector_dialog->m_allbutton, FALSE);
gtk_widget_set_sensitive(selector_dialog->m_nonebutton, FALSE);
for (i = 0; i < selector_dialog->m_numstaffs; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selector_dialog->m_checkboxes[i]), FALSE);
gtk_widget_set_sensitive(selector_dialog->m_checkboxes[i], FALSE);
}
}
else {
gtk_widget_set_sensitive(selector_dialog->m_allbutton, TRUE);
gtk_widget_set_sensitive(selector_dialog->m_nonebutton, TRUE);
for (i = 0; i < selector_dialog->m_numstaffs; i++) {
gtk_widget_set_sensitive(selector_dialog->m_checkboxes[i], TRUE);
}
}
for (i = 0; i < selector_dialog->m_numstaffs; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(selector_dialog->m_checkboxes[i]), TRUE);
}
}
nted-1.10.18/dialogs/scoreinfodialog.cpp 0000664 0010410 0000764 00000022511 11520267217 015035 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "scoreinfodialog.h"
#include "localization.h"
#include "resource.h"
#include "pangocairotext.h"
#include "mainwindow.h"
#include "config.h"
#define DIALOG_WIDTH 300
#define DIALOG_HEIGHT 10 // dummy
ScoreInfo::ScoreInfo() : title(NULL), subject(NULL), composer(NULL), arranger(NULL), copyright(NULL) {}
ScoreInfo::~ScoreInfo() {
if (title != NULL) {
delete title;
title = NULL;
}
if (subject != NULL) {
delete subject;
subject = NULL;
}
if (composer != NULL) {
delete composer;
composer = NULL;
}
if (arranger != NULL) {
delete arranger;
arranger = NULL;
}
if (copyright != NULL) {
delete copyright;
copyright = NULL;
}
}
#define TITLELENGTH 100
NedScoreInfoConfigDialog::NedScoreInfoConfigDialog(GtkWindow *parent, NedMainWindow *main_window, ScoreInfo *scoreinfo) :
m_scoreinfo(scoreinfo), m_main_window(main_window) {
GtkWidget *dialog;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *grid;
dialog = gtk_dialog_new_with_buttons(_("Score info"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
frame = gtk_frame_new(_("Score info"));
grid = gtk_table_new(2, 5, FALSE);
label = gtk_label_new(_("Title:"));
m_title = gtk_entry_new_with_max_length(TITLELENGTH);
if (m_scoreinfo->title != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_title), m_scoreinfo->title->getText());
}
gtk_table_attach(GTK_TABLE(grid), label, 0, 1, 0, 1, GTK_SHRINK, (GtkAttachOptions) 0, 0, 0);
gtk_table_attach(GTK_TABLE(grid), m_title, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) 0, 0, 0);
label = gtk_label_new(_("Subject:"));
m_subject = gtk_entry_new_with_max_length(TITLELENGTH);
if (m_scoreinfo->subject != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_subject), m_scoreinfo->subject->getText());
}
gtk_table_attach(GTK_TABLE(grid), label, 0, 1, 1, 2, GTK_SHRINK, (GtkAttachOptions) 0, 0, 0);
gtk_table_attach(GTK_TABLE(grid), m_subject, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) 0, 0, 0);
label = gtk_label_new(_("Composer:"));
m_composer = gtk_entry_new_with_max_length(TITLELENGTH);
if (m_scoreinfo->composer != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_composer), m_scoreinfo->composer->getText());
}
gtk_table_attach(GTK_TABLE(grid), label, 0, 1, 2, 3, GTK_SHRINK, (GtkAttachOptions) 0, 0, 0);
gtk_table_attach(GTK_TABLE(grid), m_composer, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) 0, 0, 0);
label = gtk_label_new(_("Arranger:"));
m_arranger = gtk_entry_new_with_max_length(TITLELENGTH);
if (m_scoreinfo->arranger != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_arranger), m_scoreinfo->arranger->getText());
}
gtk_table_attach(GTK_TABLE(grid), label, 0, 1, 3, 4, GTK_SHRINK, (GtkAttachOptions) 0, 0, 0);
gtk_table_attach(GTK_TABLE(grid), m_arranger, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) 0, 0, 0);
label = gtk_label_new(_("Copyright:"));
m_copyright = gtk_entry_new_with_max_length(TITLELENGTH);
if (m_scoreinfo->copyright != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_copyright), m_scoreinfo->copyright->getText());
}
gtk_table_attach(GTK_TABLE(grid), label, 0, 1, 4, 5, GTK_SHRINK, (GtkAttachOptions) 0, 0, 0);
gtk_table_attach(GTK_TABLE(grid), m_copyright, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) 0, 0, 0);
gtk_container_add (GTK_CONTAINER(frame), grid);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), frame);
gtk_window_set_default_size (GTK_WINDOW (dialog), DIALOG_WIDTH, DIALOG_HEIGHT);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedScoreInfoConfigDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedScoreInfoConfigDialog *score_config_dialog = (NedScoreInfoConfigDialog *) data;
bool diff;
const char *cptr;
switch (result) {
case GTK_RESPONSE_ACCEPT:
score_config_dialog->m_state = TRUE;
break;
default:
score_config_dialog->m_state = FALSE;
gtk_widget_destroy (GTK_WIDGET(dialog));
return;
break;
}
cptr = gtk_entry_get_text(GTK_ENTRY(score_config_dialog->m_title));
if (score_config_dialog->m_scoreinfo->title) {
diff = score_config_dialog->m_scoreinfo->title->textDiffers((char *) cptr);
}
else {
diff = (cptr != NULL && strlen(cptr) > 0);
}
if (diff) {
if (score_config_dialog->m_scoreinfo->title != NULL) {
delete score_config_dialog->m_scoreinfo->title;
score_config_dialog->m_scoreinfo->title = NULL;
}
if (cptr != NULL && strlen(cptr) > 0) {
score_config_dialog->m_scoreinfo->title = new NedPangoCairoText(score_config_dialog->m_main_window->getDrawingArea()->window,
(char *) cptr, TITLE_FONT, TITLE_FONT_SLANT, TITLE_FONT_WEIGHT, TITLE_FONT_SIZE, score_config_dialog->m_main_window->getCurrentZoomFactor(), 1.0, false);
}
}
cptr = gtk_entry_get_text(GTK_ENTRY(score_config_dialog->m_subject));
if (score_config_dialog->m_scoreinfo->subject) {
diff = score_config_dialog->m_scoreinfo->subject->textDiffers((char *) cptr);
}
else {
diff = (cptr != NULL && strlen(cptr) > 0);
}
if (diff) {
if (score_config_dialog->m_scoreinfo->subject != NULL) {
delete score_config_dialog->m_scoreinfo->subject;
score_config_dialog->m_scoreinfo->subject = NULL;
}
if (cptr != NULL && strlen(cptr) > 0) {
score_config_dialog->m_scoreinfo->subject = new NedPangoCairoText(score_config_dialog->m_main_window->getDrawingArea()->window,
(char *) cptr, SUBJECT_FONT, SUBJECT_FONT_SLANT, SUBJECT_FONT_WEIGHT, SUBJECT_FONT_SIZE, score_config_dialog->m_main_window->getCurrentZoomFactor(), 1.0, false);
}
}
cptr = gtk_entry_get_text(GTK_ENTRY(score_config_dialog->m_composer));
if (score_config_dialog->m_scoreinfo->composer) {
diff = score_config_dialog->m_scoreinfo->composer->textDiffers((char *) cptr);
}
else {
diff = (cptr != NULL && strlen(cptr) > 0);
}
if (diff) {
if (score_config_dialog->m_scoreinfo->composer != NULL) {
delete score_config_dialog->m_scoreinfo->composer;
score_config_dialog->m_scoreinfo->composer = NULL;
}
if (cptr != NULL && strlen(cptr) > 0) {
score_config_dialog->m_scoreinfo->composer = new NedPangoCairoText(score_config_dialog->m_main_window->getDrawingArea()->window,
(char *) cptr, COMPOSER_FONT, COMPOSER_FONT_SLANT, COMPOSER_FONT_WEIGHT, COMPOSER_FONT_SIZE, score_config_dialog->m_main_window->getCurrentZoomFactor(), 1.0, false);
}
}
cptr = gtk_entry_get_text(GTK_ENTRY(score_config_dialog->m_arranger));
if (score_config_dialog->m_scoreinfo->arranger) {
diff = score_config_dialog->m_scoreinfo->arranger->textDiffers((char *) cptr);
}
else {
diff = (cptr != NULL && strlen(cptr) > 0);
}
if (diff) {
if (score_config_dialog->m_scoreinfo->arranger != NULL) {
delete score_config_dialog->m_scoreinfo->arranger;
score_config_dialog->m_scoreinfo->arranger = NULL;
}
if (cptr != NULL && strlen(cptr) > 0) {
score_config_dialog->m_scoreinfo->arranger = new NedPangoCairoText(score_config_dialog->m_main_window->getDrawingArea()->window,
(char *) cptr, ARRANGER_FONT, ARRANGER_FONT_SLANT, ARRANGER_FONT_WEIGHT, ARRANGER_FONT_SIZE, score_config_dialog->m_main_window->getCurrentZoomFactor(), 1.0, false);
}
}
cptr = gtk_entry_get_text(GTK_ENTRY(score_config_dialog->m_copyright));
if (score_config_dialog->m_scoreinfo->copyright) {
diff = score_config_dialog->m_scoreinfo->copyright->textDiffers((char *) cptr);
}
else {
diff = (cptr != NULL && strlen(cptr) > 0);
}
if (diff) {
if (score_config_dialog->m_scoreinfo->copyright != NULL) {
delete score_config_dialog->m_scoreinfo->copyright;
score_config_dialog->m_scoreinfo->copyright = NULL;
}
if (cptr != NULL && strlen(cptr) > 0) {
score_config_dialog->m_scoreinfo->copyright = new NedPangoCairoText(score_config_dialog->m_main_window->getDrawingArea()->window,
(char *) cptr, COPYRIGHT_FONT, COPYRIGHT_FONT_SLANT, COPYRIGHT_FONT_WEIGHT, COPYRIGHT_FONT_SIZE, score_config_dialog->m_main_window->getCurrentZoomFactor(), 1.0, false);
}
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedScoreInfoConfigDialog::getValues(bool *state) {
*state = m_state;
}
nted-1.10.18/dialogs/tempodialog.cpp 0000664 0010410 0000764 00000023554 11520267217 014202 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "tempodialog.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
NedTempoDialog::NedTempoDialog(GtkWindow *parent, bool relative, unsigned int kind /* = NOTE_4 */, bool dot /* = false */, unsigned int tempo /* = 120 */) :
m_kind(kind), m_dot(dot), m_tempo(tempo) {
GtkWidget *dialog;
GtkWidget *lab;
GtkWidget *kind_hbox;
GtkWidget *tempo_hbox;
GtkWidget *kind_frame;
GtkWidget *tempo_frame;
GtkWidget *vbox_whole;
GtkWidget *vbox_note_2;
GtkWidget *vbox_note_2_dot;
GtkWidget *vbox_note_4;
GtkWidget *vbox_note_4_dot;
GtkWidget *vbox_note_8;
GtkWidget *vbox_note_8_dot;
GtkWidget *vbox_note_16;
GtkWidget *vbox_note_16_dot;
GtkWidget *image_whole;
GtkWidget *image_note_2;
GtkWidget *image_note_2_dot;
GtkWidget *image_note_4;
GtkWidget *image_note_4_dot;
GtkWidget *image_note_8;
GtkWidget *image_note_8_dot;
GtkWidget *image_note_16;
GtkWidget *image_note_16_dot;
dialog = gtk_dialog_new_with_buttons(_("Set Tempo"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
m_whole_kind = gtk_radio_button_new (NULL);
m_kind_2 = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_2_dot = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_4 = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_4_dot = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_8 = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_8_dot = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_16 = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
m_kind_16_dot = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (m_whole_kind));
image_whole = gtk_image_new_from_stock("fullnote_icon", GTK_ICON_SIZE_BUTTON);
image_note_2 = gtk_image_new_from_stock("halfnote-icon", GTK_ICON_SIZE_BUTTON);
image_note_2_dot = gtk_image_new_from_stock("halfnote-dot-icon", GTK_ICON_SIZE_BUTTON);
image_note_4 = gtk_image_new_from_stock("quarternote-icon", GTK_ICON_SIZE_BUTTON);
image_note_4_dot = gtk_image_new_from_stock("quarternote-dot-icon", GTK_ICON_SIZE_BUTTON);
image_note_8 = gtk_image_new_from_stock("eighthnote-icon", GTK_ICON_SIZE_BUTTON);
image_note_8_dot = gtk_image_new_from_stock("eighthnote-dot-icon", GTK_ICON_SIZE_BUTTON);
image_note_16 = gtk_image_new_from_stock("sixteenthnote-icon", GTK_ICON_SIZE_BUTTON);
image_note_16_dot = gtk_image_new_from_stock("sixteenthnote-dot-icon", GTK_ICON_SIZE_BUTTON);
vbox_whole = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_whole), m_whole_kind, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_whole), image_whole, FALSE, FALSE, 4);
vbox_note_2 = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_2), m_kind_2, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_2), image_note_2, FALSE, FALSE, 4);
vbox_note_2_dot = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_2_dot), m_kind_2_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_2_dot), image_note_2_dot, FALSE, FALSE, 4);
vbox_note_4 = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_4), m_kind_4, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_4), image_note_4, FALSE, FALSE, 4);
vbox_note_4_dot = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_4_dot), m_kind_4_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_4_dot), image_note_4_dot, FALSE, FALSE, 4);
vbox_note_8 = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_8), m_kind_8, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_8), image_note_8, FALSE, FALSE, 4);
vbox_note_8_dot = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_8_dot), m_kind_8_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_8_dot), image_note_8_dot, FALSE, FALSE, 4);
vbox_note_16 = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_16), m_kind_16, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_16), image_note_16, FALSE, FALSE, 4);
vbox_note_16_dot = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox_note_16_dot), m_kind_16_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_note_16_dot), image_note_16_dot, FALSE, FALSE, 4);
kind_hbox = gtk_hbox_new(FALSE, 8);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_whole, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_2, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_2_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_4, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_4_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_8, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_8_dot, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_16, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(kind_hbox), vbox_note_16_dot, FALSE, FALSE, 0);
kind_frame = gtk_frame_new(_("kind"));
gtk_container_add (GTK_CONTAINER(kind_frame), kind_hbox);
switch (kind) {
case WHOLE_NOTE: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_whole_kind), TRUE); break;
case NOTE_2: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_2), !m_dot);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_2_dot), m_dot); break;
case NOTE_4: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_4), !m_dot);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_4_dot), m_dot); break;
case NOTE_8: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_8), !m_dot);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_8_dot), m_dot); break;
default: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_16), !m_dot);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_kind_16_dot), TRUE); break;
}
if (relative) {
m_tempo_spin_box = gtk_spin_button_new_with_range (-999, 999.0, 1.0);
}
else {
m_tempo_spin_box = gtk_spin_button_new_with_range (10.0, 999.0, 1.0);
}
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_tempo_spin_box), tempo);
lab = gtk_label_new(_("tempo:"));
tempo_hbox = gtk_hbox_new(FALSE, 8);
gtk_box_pack_start(GTK_BOX(tempo_hbox), lab, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(tempo_hbox), m_tempo_spin_box, FALSE, FALSE, 0);
tempo_frame = gtk_frame_new(_("tempo"));
gtk_container_add (GTK_CONTAINER(tempo_frame), tempo_hbox);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), kind_frame);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), tempo_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedTempoDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedTempoDialog *tempo_dialog = (NedTempoDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
tempo_dialog->m_state = TRUE;
break;
default:
tempo_dialog->m_state = FALSE;
break;
}
tempo_dialog->m_tempo = (unsigned int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(tempo_dialog->m_tempo_spin_box)) + 0.4);
tempo_dialog->m_kind = NOTE_4;
tempo_dialog->m_dot = false;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_whole_kind))) {
tempo_dialog->m_kind = WHOLE_NOTE;
tempo_dialog->m_dot = false;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_2))) {
tempo_dialog->m_kind = NOTE_2;
tempo_dialog->m_dot = false;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_2_dot))) {
tempo_dialog->m_kind = NOTE_2;
tempo_dialog->m_dot = true;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_4))) {
tempo_dialog->m_kind = NOTE_4;
tempo_dialog->m_dot = false;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_4_dot))) {
tempo_dialog->m_kind = NOTE_4;
tempo_dialog->m_dot = true;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_8))) {
tempo_dialog->m_kind = NOTE_8;
tempo_dialog->m_dot = false;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_8_dot))) {
tempo_dialog->m_kind = NOTE_8;
tempo_dialog->m_dot = true;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_16))) {
tempo_dialog->m_kind = NOTE_16;
tempo_dialog->m_dot = false;
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tempo_dialog->m_kind_16_dot))) {
tempo_dialog->m_kind = NOTE_16;
tempo_dialog->m_dot = true;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedTempoDialog::getValues(bool *state, unsigned int *kind, bool *dot, unsigned int *tempo) {
*state = m_state;
*tempo = m_tempo;
*kind = m_kind;
*dot = m_dot;
}
nted-1.10.18/dialogs/midirecordconfigdialog.h 0000664 0010410 0000764 00000004764 11520267217 016034 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef MIDI_RECORD_CONFIG_H
#define MIDI_RECORD_CONFIG_H
#include "config.h"
#include
#include
class NedMidiRecordConfigDialog {
public:
NedMidiRecordConfigDialog(GtkWindow *parent, int num, int denom, int midi_pgm,
int tempo_inverse, int metro_volume, bool triplet, bool f_piano, bool dnt_split, int keysig);
void getValues(bool *state, int *num, int *denom, int *midi_pgm,
int *tempo_inverse, int *metro_volume, bool *triplet, bool *f_piano, bool *dnt_split, int *keysig);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static gboolean OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data);
static void OnPianoForcePressed(GtkButton *button, gpointer data);
static void OnDontSplitPressed(GtkButton *button, gpointer data);
GtkObject *m_instrument_adjustment;
GtkWidget *m_instrument_list;
GtkWidget *m_numerator;
GtkWidget *m_denominator;
GtkWidget *m_with_triplet_button;
GtkWidget *m_force_piano_button;
GtkWidget *m_dont_split_button;
GtkWidget *m_tempo_scale;
GtkWidget *m_metro_volume_scale;
GtkWidget *m_sig_radio_buttons[14];
bool m_state;
int m_num, m_denom;
int m_pgm;
int m_tempo_inverse;
int m_metro_volume;
bool m_triplet, m_f_piano, m_dnt_split;
int m_keysig;
};
#endif /* MIDI_RECORD_CONFIG_H */
nted-1.10.18/dialogs/portchoosedialog.h 0000664 0010410 0000764 00000003416 11520267217 014703 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef PORT_CHOOSE_DIALOG_H
#define PORT_CHOOSE_DIALOG_H
#include "config.h"
#include
class NedPortChooseDialog {
public:
NedPortChooseDialog(GtkWindow *parent, GList *ports, unsigned int idx, bool midi_echo, bool show_echo_box);
unsigned int getSelection() {return m_idx;}
bool getMidiEcho() {return m_midi_echo;}
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
unsigned int m_idx;
GtkWidget *m_port_list_view;
GtkWidget *m_midi_echo_check_box;
bool m_midi_echo;
bool m_with_midi_echo_box;
};
#endif /* PORT_CHOOSE_DIALOG_H */
nted-1.10.18/dialogs/tupletdialog.h 0000664 0010410 0000764 00000003207 11520267217 014031 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef TUPLET_DIALOG_H
#define TUPLET_DIALOG_H
#include "config.h"
#include
class NedTupletDialog {
public:
NedTupletDialog(GtkWindow *parent);
void getValues(bool *state, int *tupletval, int *method);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_tuplet_spin_box;
GtkWidget *m_method_check_button;
bool m_state;
int m_method;
int m_tuplet_val;
};
#endif /* TUPLET_DIALOG_H */
nted-1.10.18/dialogs/midiimportdialog.h 0000664 0010410 0000764 00000004430 11520267217 014670 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef MIDI_IMPORT_DIALOG_H
#define MIDI_IMPORT_DIALOG_H
#include "config.h"
#include
class NedMidiImportDialog {
public:
NedMidiImportDialog(GtkWindow *parent, char **folder, char **filename);
void getValues(bool *state, bool *with_triplets, int *tempo_change_density, int *volume_change_density,
bool *force_piano, bool *sort_instruments, bool *dont_split);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static void OnPianoForcePressed(GtkButton *button, gpointer data);
static void OnDontSplitPressed(GtkButton *button, gpointer data);
GtkWidget *m_with_triplet_button;
GtkWidget *m_tempo_change_density_scale;
GtkWidget *m_volume_change_density_scale;
GtkWidget *m_file_chooser;
GtkWidget *m_force_piano_button;
GtkWidget *m_sort_instruments_button;
GtkWidget *m_dont_split_button;
bool m_state;
bool m_with_triplets;
int m_tempo_change_density;
int m_volume_change_density;
bool m_force_piano;
bool m_sort_instruments;
bool m_dont_split;
gchar **m_last_folder;
gchar **m_filename;
};
#endif /* MIDI_IMPORT_DIALOG_H */
nted-1.10.18/dialogs/lilypondexportdialog.cpp 0000664 0010410 0000764 00000016472 11520267217 016153 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "lilypondexportdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#include "staffselectdialog.h"
#define LILYPOND_EXPORT_DIALOG_WIDTH 500
#define LILYPOND_EXPORT_DIALOG_HEIGHT 450
NedLilyPondExportDialog::NedLilyPondExportDialog(GtkWindow *parent, NedMainWindow *main_window, char *filename, bool *selected_staves, bool *keep_beams) : m_main_window(main_window), m_with_breaks(true),
m_filename(filename), m_selected_staves(selected_staves), m_keep_beams(keep_beams) {
GtkWidget *select_button;
GtkWidget *beam_button;
GtkWidget *hbox;
GtkWidget *param_frame;
char *cptr1, *cptr2;
bool full = false;
char fnam[4096], foldername[4096];
GtkWidget *main_vbox;
m_dialog = gtk_dialog_new_with_buttons(_("LilyPond export"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(m_dialog, "response", G_CALLBACK (OnClose), (void *) this);
m_file_chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SAVE);
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.ly (LilyPond-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.ly");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(m_file_chooser), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(m_file_chooser), file_filter2);
main_vbox = gtk_vbox_new(FALSE, 2);
param_frame = gtk_frame_new(_("export params"));
hbox = gtk_hbox_new(FALSE, 2);
m_with_break_checkbox = gtk_check_button_new_with_label(_("create line breaks"));
gtk_box_pack_start (GTK_BOX(hbox), m_with_break_checkbox, TRUE, TRUE, 0);
if (main_window->getStaffCount() > 1) {
select_button = gtk_button_new_with_label(_("select staves"));
g_signal_connect(select_button, "pressed", G_CALLBACK (OnStaffSelection), (void *) this);
gtk_box_pack_start (GTK_BOX(hbox), select_button, TRUE, TRUE, 0);
}
beam_button = gtk_button_new_with_label(_("keep beams"));
g_signal_connect(beam_button, "pressed", G_CALLBACK (OnBeamSelection), (void *) this);
gtk_box_pack_start (GTK_BOX(hbox), beam_button, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER(param_frame), hbox);
gtk_box_pack_start (GTK_BOX(main_vbox), param_frame, FALSE, FALSE, 5);
gtk_box_pack_start (GTK_BOX(main_vbox), m_file_chooser, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(m_dialog)->vbox), main_vbox);
gtk_window_set_default_size (GTK_WINDOW (m_dialog), LILYPOND_EXPORT_DIALOG_WIDTH, LILYPOND_EXPORT_DIALOG_HEIGHT);
gtk_widget_show_all (m_dialog);
if (strlen(filename) > 0) {
for (cptr1 = filename; *cptr1 != '\0'; cptr1++) {
if ((*(unsigned char *) cptr1) <= ' ') continue;
if (*cptr1 == '/') {
full = true;
break;
}
}
if (full) {
if ((cptr2 = strrchr(filename, '/')) != NULL) {
strncpy(foldername, cptr1, cptr2 - cptr1);
foldername[cptr2 - cptr1] = '\0';
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(m_file_chooser), foldername);
strcpy (fnam, cptr2 + 1);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(m_file_chooser), foldername);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_file_chooser), fnam);
}
else {
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(m_file_chooser), "/tmp");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_file_chooser), m_filename);
}
}
else {
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(m_file_chooser), "/tmp");
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_file_chooser), m_filename);
}
}
gtk_dialog_run(GTK_DIALOG(m_dialog));
}
void NedLilyPondExportDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
char *s;
char *cptr;
bool empty;
NedLilyPondExportDialog *lilyexport_dialog = (NedLilyPondExportDialog *) data;
lilyexport_dialog->m_with_breaks = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lilyexport_dialog->m_with_break_checkbox));
switch (result) {
case GTK_RESPONSE_ACCEPT:
lilyexport_dialog->m_state = TRUE;
s = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(lilyexport_dialog->m_file_chooser));
if (s == NULL) {
lilyexport_dialog->m_state = FALSE;
break;
}
empty = true;
for (cptr = s; *cptr != '\0'; cptr++) {
if ((*(unsigned char *) cptr) > ' ') {
empty = false;
break;
}
}
if (empty) {
lilyexport_dialog->m_state = FALSE;
break;
}
empty = true;
for (int i = 0; i < lilyexport_dialog->m_main_window->getStaffCount(); i++) {
if (lilyexport_dialog->m_selected_staves[i]) {
empty = false;
break;
}
}
if (empty) {
lilyexport_dialog->m_state = FALSE;
break;
}
strcpy(lilyexport_dialog->m_filename, s);
break;
default:
lilyexport_dialog->m_state = FALSE;
break;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedLilyPondExportDialog::getValues(bool *state, bool *with_break) {
*state = m_state;
*with_break = m_with_breaks;
}
void NedLilyPondExportDialog::OnStaffSelection (GtkButton *button, gpointer data) {
bool state;
NedLilyPondExportDialog *lilyexport_dialog = (NedLilyPondExportDialog *) data;
for (int i = 0; i < lilyexport_dialog->m_main_window->getStaffCount(); lilyexport_dialog->m_selected_staves[i++] = false);
NedStaffSelectDialog *staff_select_dialog = new NedStaffSelectDialog(GTK_WINDOW(lilyexport_dialog->m_dialog), _("Staff selection"),
lilyexport_dialog->m_main_window, lilyexport_dialog->m_selected_staves);
staff_select_dialog->getValues(&state);
}
void NedLilyPondExportDialog::OnBeamSelection (GtkButton *button, gpointer data) {
bool state;
NedLilyPondExportDialog *lilyexport_dialog = (NedLilyPondExportDialog *) data;
for (int i = 0; i < lilyexport_dialog->m_main_window->getStaffCount(); lilyexport_dialog->m_keep_beams[i++] = false);
NedStaffSelectDialog *staff_select_dialog = new NedStaffSelectDialog(GTK_WINDOW(lilyexport_dialog->m_dialog), _("keep beams selection"),
lilyexport_dialog->m_main_window, lilyexport_dialog->m_keep_beams);
staff_select_dialog->getValues(&state);
}
nted-1.10.18/dialogs/clefconfigdialog.h 0000664 0010410 0000764 00000004412 11520267217 014612 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef CLEF_CONTEXT_DIALOG_H
#define CLEF_CONTEXT_DIALOG_H
#include "config.h"
#include
#include
class NedClefConfigDialog {
public:
NedClefConfigDialog(GtkWindow *parent, int clef_number, int octave_shift);
void getValues(bool *state, int *clef_number, int *octave_shift, bool *adjust_notes);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static gboolean OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data);
static gboolean draw_clefs(GtkWidget *widget,
GdkEventExpose *event, gpointer data);
static void decrease_clef_number (GtkButton *button, gpointer user_data);
static void increase_clef_number (GtkButton *button, gpointer user_data);
static void octave_shift_change(GtkSpinButton *spinbutton, gpointer user_data);
GtkWidget *m_clef_show_window;
GtkWidget *m_clef_bu_up;
GtkWidget *m_clef_bu_down;
GtkWidget *m_octave_shift_spin_box;
GtkWidget *m_adjust_check_box;
int m_octave_shift;
bool m_state;
bool m_do_adjust;
int m_current_clef, m_newclef;
};
#endif /* CLEF_CONTEXT_DIALOG_H */
nted-1.10.18/dialogs/signsdialog.cpp 0000664 0010410 0000764 00000012324 11520267217 014172 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "signsdialog.h"
#include "localization.h"
#include "resource.h"
#include "freesign.h"
#include "mainwindow.h"
#define SIGN_BOX_WIDTH 40
#define SIGN_BOX_HEIGHT 40
#define RECT_OFFS 4
#define MAX_XVAL 3
#define MAX_YVAL 0
NedSignsDialog::NedSignsDialog(GtkWindow *parent) : m_current_row(-1), m_current_column(-1) {
GtkWidget *dialog;
GtkWidget *sign_frame;
GtkWidget *sign_image_widget;
m_black.pixel = 1; m_black.red = m_black.green = m_black.blue = 0;
m_red.pixel = 2; m_red.red = 65535; m_red.green = m_red.blue = 0;
dialog = gtk_dialog_new_with_buttons(_("Signs"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
sign_frame = gtk_frame_new(_("signs"));
sign_image_widget = gtk_drawing_area_new();
gtk_drawing_area_size(GTK_DRAWING_AREA(sign_image_widget), NedResource::m_lines_buf_width, NedResource::m_lines_buf_height);
g_signal_connect (sign_image_widget, "expose-event", G_CALLBACK (draw_menu), (void *) this);
gtk_container_add (GTK_CONTAINER(sign_frame), sign_image_widget);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), sign_frame);
gtk_widget_show_all (dialog);
m_drawing_area_gc = gdk_gc_new(sign_image_widget->window);
gtk_widget_add_events(sign_image_widget, GDK_BUTTON_PRESS_MASK);
g_signal_connect (sign_image_widget, "button-press-event", G_CALLBACK (change_selection), (void *) this);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedSignsDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedSignsDialog *lines_dialog = (NedSignsDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
lines_dialog->m_state = TRUE;
break;
default:
lines_dialog->m_state = FALSE;
break;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedSignsDialog::getValues(bool *state, int *signtype) {
*state = m_state && m_current_row >= 0 && m_current_column >= 0;
*signtype = 0;
if (state) {
switch (m_current_row) {
case 0: switch(m_current_column) {
case 0: *signtype = SIGN_CODA; break;
case 1: *signtype = SIGN_SEGNO; break;
case 2: *signtype = SIGN_BREATH1; break;
case 3: *signtype = SIGN_BREATH2; break;
}
break;
}
}
}
gboolean NedSignsDialog::draw_menu(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
NedSignsDialog *lines_dialog = (NedSignsDialog *) data;
gdk_gc_set_foreground(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_black));
gdk_gc_set_rgb_fg_color(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_black));
gdk_draw_pixbuf(widget->window, lines_dialog->m_drawing_area_gc, NedResource::m_signs,
0, 0, 0, 0, NedResource::m_signs_buf_width, NedResource::m_signs_buf_height, GDK_RGB_DITHER_NONE, 0, 0);
if (lines_dialog->m_current_row >= 0 && lines_dialog->m_current_column >= 0) {
gdk_gc_set_foreground(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_red));
gdk_gc_set_rgb_fg_color(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_red));
gdk_draw_rectangle(widget->window, lines_dialog->m_drawing_area_gc, false,
lines_dialog->m_current_column * SIGN_BOX_WIDTH + RECT_OFFS, lines_dialog->m_current_row * SIGN_BOX_HEIGHT + RECT_OFFS,
SIGN_BOX_WIDTH - 2 * RECT_OFFS, SIGN_BOX_HEIGHT - 2 * RECT_OFFS);
}
return FALSE;
}
gboolean NedSignsDialog::change_selection (GtkWidget *widget, GdkEventButton *event, gpointer data) {
GdkRectangle rect;
int dummy;
int newx, newy;
NedSignsDialog *signs_dialog = (NedSignsDialog *) data;
newx = (int) event->x / SIGN_BOX_WIDTH;
newy = (int) event->y / SIGN_BOX_HEIGHT;
if (newx > MAX_XVAL) return FALSE;
if (newy > MAX_YVAL) return FALSE;
signs_dialog->m_current_column = (int) event->x / SIGN_BOX_WIDTH;
signs_dialog->m_current_row = (int) event->y / SIGN_BOX_HEIGHT;
gdk_window_get_geometry(widget->window, &dummy, &dummy, &rect.width, &rect.height, &dummy);
rect.x = rect.y = 0;
gdk_window_invalidate_rect (widget->window, &rect, FALSE);
return FALSE;
}
nted-1.10.18/dialogs/mutedialog.h 0000664 0010410 0000764 00000003446 11520267217 013473 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef MUTE_CONFIGDIALOG_H
#define MUTE_CONFIGDIALOG_H
#include "config.h"
#include
#include
struct staff_context_str;
class NedMuteDialog {
public:
NedMuteDialog(GtkWindow *parent, bool *mutes, struct staff_context_str *staff_contexts, int numstaffs);
void getValues(bool *state);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static void OnAll(GtkButton *button, gpointer data);
static void OnNone(GtkButton *button, gpointer data);
GtkWidget **m_checkboxes;
bool *m_mutes;
bool m_state;
int m_numstaffs;
};
#endif /* MUTE_CONFIGDIALOG_H */
nted-1.10.18/dialogs/keysigdialog.h 0000664 0010410 0000764 00000003324 11520267217 014007 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef KEYSIG_DIALOG_H
#define KEYSIG_DIALOG_H
#include "config.h"
#include
#include
class NedKeysigDialog {
public:
NedKeysigDialog(GtkWindow *parent, int key_signature_number);
void getValues(bool *state, int *key_signature_number, bool *adjust_notes);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_sig_radio_buttons[14];
GtkWidget *m_adjust_check_box;
bool m_state;
int m_key_signature_number;
bool m_do_adjust;
};
#endif /* KEYSIG_DIALOG_H */
nted-1.10.18/dialogs/mutedialog.cpp 0000664 0010410 0000764 00000010747 11520267217 014030 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "mutedialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#include "pangocairotext.h"
NedMuteDialog::NedMuteDialog(GtkWindow *parent, bool *mutes, struct staff_context_str *staff_contexts, int numstaffs) : m_mutes(mutes), m_numstaffs(numstaffs) {
GtkWidget *dialog;
bool is_muted;
int i, j;
char Str[128];
dialog = gtk_dialog_new_with_buttons(_("Muting"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
GtkWidget *buttonbox;
GtkWidget *allbutton;
GtkWidget *nonebutton;
GtkWidget *hbox;
GtkWidget *mute_frame;
buttonbox = gtk_vbox_new(FALSE, 0);
try {
m_checkboxes= new GtkWidget*[numstaffs];
}
catch(std::exception& e){
NedResource::Abort("NedMuteDialog: allocation error1");
}
for (i = 0; i < numstaffs; i++) {
if (staff_contexts[i].m_staff_name == NULL) {
sprintf(Str, _("Staff %d"), i);
m_checkboxes[i] = gtk_check_button_new_with_label(Str);
}
else {
m_checkboxes[i] = gtk_check_button_new_with_label(staff_contexts[i].m_staff_name->getText());
}
is_muted = true;
for (j = 0; j < VOICE_COUNT; j++) {
if (!staff_contexts[i].m_muted[j]) is_muted = false;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkboxes[i]), is_muted);
gtk_box_pack_start(GTK_BOX(buttonbox), m_checkboxes[i], FALSE, FALSE, 0);
}
mute_frame = gtk_frame_new(_("muting"));
hbox = gtk_hbox_new(TRUE, 0);
allbutton = gtk_button_new_with_label(_("all"));
g_signal_connect(allbutton, "pressed", G_CALLBACK (OnAll), (void *) this);
nonebutton = gtk_button_new_with_label(_("none"));
g_signal_connect(nonebutton, "pressed", G_CALLBACK (OnNone), (void *) this);
gtk_box_pack_start(GTK_BOX(hbox), allbutton, TRUE, TRUE, 5);
gtk_box_pack_start(GTK_BOX(hbox), nonebutton, TRUE, TRUE, 5);
gtk_box_pack_start(GTK_BOX(buttonbox), hbox, TRUE, TRUE, 5);
gtk_container_add (GTK_CONTAINER(mute_frame), buttonbox);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), mute_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedMuteDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
int i;
NedMuteDialog *mute_dialog = (NedMuteDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
mute_dialog->m_state = TRUE;
break;
default:
mute_dialog->m_state = FALSE;
break;
}
for (i = 0; i < mute_dialog->m_numstaffs; i++) {
mute_dialog->m_mutes[i] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mute_dialog->m_checkboxes[i]));
}
gtk_widget_destroy (GTK_WIDGET(dialog));
delete[] mute_dialog->m_checkboxes;
}
void NedMuteDialog::getValues(bool *state) {
*state = m_state;
}
void NedMuteDialog::OnAll(GtkButton *button, gpointer data) {
int i;
NedMuteDialog *mute_dialog = (NedMuteDialog *) data;
for (i = 0; i < mute_dialog->m_numstaffs; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_dialog->m_checkboxes[i]), TRUE);
}
}
void NedMuteDialog::OnNone(GtkButton *button, gpointer data) {
int i;
NedMuteDialog *mute_dialog = (NedMuteDialog *) data;
for (i = 0; i < mute_dialog->m_numstaffs; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_dialog->m_checkboxes[i]), FALSE);
}
}
nted-1.10.18/dialogs/tools.h 0000664 0010410 0000764 00000013224 11520267217 012474 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef TOOLS_H
#define TOOLS_H
#include "config.h"
#include
#include
class NedMainWindow;
class X11buttonGroup;
#define NUM_PANELS 5
class X11button {
public:
X11button(Display *dpy, Window win, GC xgc, int screen, XImage *img[2], int xpos, int ypos, int width, int height, int column, int row, int panel, int type, int scope, bool enabled, bool default_state);
~X11button();
void draw();
void toggle();
bool handle_click(gdouble x, gdouble y);
bool handle_release(gdouble x, gdouble y);
X11buttonGroup *m_button_group;
bool m_active;
int m_type;
int m_row, m_column;
int m_panel;
private:
void notifyMainWindow(NedMainWindow *current_main_window);
Display *m_dpy;
Window m_win;
GC m_xgc;
int m_screen;
#define EMPTY_BUTTON 0
#define PUSH_BUTTON 1
#define TOGGLE_BUTTON 2
bool m_enabled;
bool m_default_state;
int m_scope;
#define SCOPE_NONE 0
#define SCOPE_NOTE_LENGTH 1
#define SCOPE_STATE 2
#define SCOPE_NOTE_STATE 3
#define SCOPE_NOTE_HEAD 4
#define SCOPE_DOTS 5
#define SCOPE_TIES 6
XImage *m_img[2];
int m_xpos, m_ypos;
int m_width, m_height;
};
class X11buttonGroup {
public:
X11buttonGroup(bool all_inactive_allowed);
void removeAllButtons();
void addX11button(X11button *button);
void removeX11button(X11button *button);
bool allowStateChange(X11button *button);
void stateChanged(X11button *button);
void resetAllButtons();
private:
GList *m_buttons;
bool m_all_inactive_allowed;
};
class NedTools {
public:
NedTools();
~NedTools();
void Show();
void getValues(bool *state);
unsigned int getCurrentLength();
int getCurrentNoteHead();
unsigned int getStatus();
bool getRestMode();
int getDotCount();
bool getTiedMode();
void setButtons(unsigned int length, int dotcount, unsigned int chord_status, unsigned int note_status, bool isRest, bool tie_forward, int note_head);
void setNoteLengthButtons(unsigned int length);
void setToolboxTransient(NedMainWindow *m_win);
void toggleButton(int nr);
void toggleRest();
void toggleTie();
void toggleDot();
void toggleSharp();
void toggleNatural();
void toggleFlat();
void resetButtons();
void resetTieButton();
void resetSomeButtons();
void updatePosition();
private:
void createButtons(Display *dpy, Window win, GC xgc, GdkGC *ggc, GdkDrawable *d, int screen);
void createMiniButtons(Display *dpy, Window win, GC xgc, GdkGC *ggc, GdkDrawable *d, int screen);
void determine_image_and_dimensions(Display *dpy, Window win, GdkGC *ggc, GdkDrawable *d, int screen, int panel, int row, int column, int bu_nr,
GdkPixbuf *buf, XImage *img[2], int *w, int *h);
void determine_mini_image_and_dimensions(Display *dpy, Window win, GdkGC *ggc, GdkDrawable *d, int screen, GdkPixbuf *buf, XImage *img[2], int type, int *w, int *h);
void testForPanelChange(X11button *button);
static bool close_toolbox(GtkWidget *widget, GdkEvent *event, gpointer data);
class button_descr {
public:
GdkPixbuf **m_pixbuf;
int m_type;
int m_scope;
bool m_default_state;
X11buttonGroup *m_button_group;
};
static button_descr m_button_descriptions[NUM_PANELS][17];
static button_descr m_mini_button_descriptions[8];
static X11button *m_button_arrays[NUM_PANELS][17];
static X11button *m_mini_button_arrays[8];
GdkGC *m_copy_gc, *m_blue_gc;
Display *m_dpy;
Window m_win;
GC m_xgc;
int m_screen;
static gboolean OnDelete(GtkWidget *widget, GdkEvent *event, gpointer data);
static gboolean key_press_handler(GtkWidget *widget, GdkEventKey *event, gpointer data);
static bool OnButtonPress(GtkWidget *widget, GdkEventButton *event, gpointer data);
static bool OnButtonRelease(GtkWidget *widget, GdkEventButton *event, gpointer data);
static gboolean draw_menu(GtkWidget *widget, GdkEventExpose *event, gpointer data);
static XImage *createX11PixmapFromGdkPixbuffer(Display *dpy, int screen, GdkDrawable *d, GdkGC *gc,
GdkPixbuf *pixbuf, int background, bool up);
GtkWidget *m_button_area;
GtkWidget *m_button_frame;
GtkWidget *m_toolbox;
GdkPixmap *m_back_pix;
static X11buttonGroup m_accidentals, m_note_length_group, m_note_head_group, m_dot_group, m_tremolo_group;
bool m_state;
int m_current_row, m_current_column;
int m_current_panel;
int m_buttons_created;
static int m_back_img_width, m_back_img_height;
static int m_back_miniimg_width, m_back_miniimg_height;
static int m_mini_spaces;
};
#endif /* TOOLS_H */
nted-1.10.18/dialogs/insertblockdialog.h 0000664 0010410 0000764 00000003142 11520267217 015031 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef INSERT_BLOCK_DIALOG_H
#define INSERT_BLOCK_DIALOG_H
#include "config.h"
#include
class NedInsertBlockDialog {
public:
NedInsertBlockDialog(GtkWindow *parent);
void getValues(bool *state, int *blockcount);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_block_spin_box;
bool m_state;
int m_blockcount;
};
#endif /* INSERT_BLOCK_DIALOG_H */
nted-1.10.18/dialogs/keysigdialog.cpp 0000664 0010410 0000764 00000010607 11520267217 014344 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "keysigdialog.h"
#include "localization.h"
#include "staffcontextdialog.h"
#include "resource.h"
NedKeysigDialog::NedKeysigDialog(GtkWindow *parent, int key_signature_number) :
m_state(false), m_key_signature_number(key_signature_number) {
int i;
GtkWidget *dialog;
GtkWidget *key_frame;
GtkWidget *key_frame_left_vbox;
GtkWidget *key_frame_right_vbox;
GtkWidget *radio_hbox;
GtkWidget *adjust_frame;
dialog = gtk_dialog_new_with_buttons(_("New keysignature"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
key_frame = gtk_frame_new(_("key"));
radio_hbox = gtk_hbox_new(FALSE, 2);
key_frame_left_vbox = gtk_vbox_new(FALSE, 2);
key_frame_right_vbox = gtk_vbox_new(FALSE, 2);
m_sig_radio_buttons[0] = gtk_radio_button_new_with_label (NULL, gettext(NedStaffContextDialog::m_keyTab[0]));
gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[0], FALSE, FALSE, 0);
for (i = -5; i < 7; i++) {
m_sig_radio_buttons[i+6] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_sig_radio_buttons[0]), gettext(NedStaffContextDialog::m_keyTab[i+6]));
if (i < 0) {
gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
}
else {
gtk_box_pack_start (GTK_BOX (key_frame_right_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
}
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_sig_radio_buttons[m_key_signature_number+6]), TRUE);
gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_left_vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_right_vbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(key_frame), radio_hbox);
adjust_frame = gtk_frame_new(_("adjust"));
m_adjust_check_box = gtk_check_button_new_with_label(_("adjust notes"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_adjust_check_box), TRUE);
gtk_container_add (GTK_CONTAINER(adjust_frame), m_adjust_check_box);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), key_frame);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), adjust_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedKeysigDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
int i;
int newkeysig;
NedKeysigDialog *keysig_dialog = (NedKeysigDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
keysig_dialog->m_state = TRUE;
break;
default:
keysig_dialog->m_state = FALSE;
break;
}
newkeysig = 0;
keysig_dialog->m_key_signature_number = 0;
for (i = 0; i < 13; i++) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (keysig_dialog->m_sig_radio_buttons[i]))) {
newkeysig = i - 6;
}
}
keysig_dialog->m_key_signature_number = newkeysig;
keysig_dialog->m_do_adjust = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(keysig_dialog->m_adjust_check_box));
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedKeysigDialog::getValues(bool *state, int *key_signature_number, bool *adjust_notes) {
*state = m_state;
*key_signature_number = m_key_signature_number;
*adjust_notes = m_do_adjust;
}
nted-1.10.18/dialogs/lyricseditor.h 0000664 0010410 0000764 00000004775 11520267217 014063 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef LYRICS_EDITOR_H
#define LYRICS_EDITOR_H
#include "config.h"
#include "resource.h"
#include
class NedMainWindow;
class NedLyricsEditor {
public:
NedLyricsEditor(GtkWindow *parent, NedMainWindow *main_window, int staff_nr);
~NedLyricsEditor();
void appendText(int num, const char *text);
char *getNextWord(int line);
bool m_newchar[MAX_LYRICS_LINES];
void addDot(int line) { number_uf_dots[line]++;}
private:
static void ResponseCallBack(GtkDialog *dialog, gint result, gpointer data);
static void OnSave (GtkButton *button, gpointer data);
static void OnLoad (GtkButton *button, gpointer data);
static gboolean OnMap1(GtkWidget *widget, GdkEvent *event, gpointer data);
static gboolean OnMap2(GtkWidget *widget, GdkEvent *event, gpointer data);
static gboolean OnMap3(GtkWidget *widget, GdkEvent *event, gpointer data);
static gboolean OnMap4(GtkWidget *widget, GdkEvent *event, gpointer data);
static gboolean OnMap5(GtkWidget *widget, GdkEvent *event, gpointer data);
int number_uf_dots[MAX_LYRICS_LINES];
GtkTextIter m_itr1[MAX_LYRICS_LINES], m_itr2[MAX_LYRICS_LINES];
GtkTextBuffer *m_buffer[MAX_LYRICS_LINES];
GtkWidget *m_dialog;
GtkWidget *m_table;
NedMainWindow *m_main_window;
char *m_last_folder;
int m_current_verse;
int m_staff_nr;
};
#endif /* LYRICS_EDITOR_H */
nted-1.10.18/dialogs/measureconfigdialog.cpp 0000664 0010410 0000764 00000061417 11520267217 015705 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "measureconfigdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#define MEASURE_SHOW_WINDOW_WIDTH 100
#define MEASURE_SHOW_WINDOW_HEIGHT 100
#define MIN_MEASRURE_TYPE 0
#define MAX_MEASURE_TYPE END_BAR
NedMeasureConfigDialog::NedMeasureConfigDialog(GtkWindow *parent, int measure_type, bool alter1, bool alter2, bool allow_alter, bool hide_following, int num, int denom, unsigned int sym) :
m_measure_type(measure_type & REP_TYPE_MASK), m_num(num), m_denom(denom), m_symbol(sym), m_hide_following(hide_following), m_allow_alter(allow_alter), m_delete_timesig(false) {
GtkWidget *dialog;
GtkWidget *hbox;
GtkWidget *measure_type_frame;
GtkWidget *measure_type_hbox;
GtkWidget *measure_type_vbox;
GtkWidget *measure_type_buttons_vbox;
GtkWidget *time_signature_frame;
GtkWidget *numerator_label;
GtkWidget *denominator_label;
GtkWidget *time_signature_vbox;
GtkWidget *time_signature_upper_hbox;
GtkWidget *time_signature_lower_hbox;
GtkWidget *alter_box;
GdkColor bgcolor;
dialog = gtk_dialog_new_with_buttons(_("Measure type"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
m_original_type = (measure_type & REP_TYPE_MASK);
hbox = gtk_hbox_new(FALSE, 5);
measure_type_hbox = gtk_hbox_new(FALSE, 5);
measure_type_frame = gtk_frame_new(_("measure type"));
m_measure_type_show_window = gtk_drawing_area_new ();
bgcolor.pixel = 1;
bgcolor.red = bgcolor.green = bgcolor.blue = 0xffff;
gtk_widget_modify_bg(GTK_WIDGET(m_measure_type_show_window), GTK_STATE_NORMAL, &bgcolor);
gtk_drawing_area_size(GTK_DRAWING_AREA(m_measure_type_show_window), MEASURE_SHOW_WINDOW_WIDTH, MEASURE_SHOW_WINDOW_HEIGHT);
gtk_container_add (GTK_CONTAINER(measure_type_hbox), m_measure_type_show_window);
measure_type_buttons_vbox = gtk_vbox_new(FALSE, 2);
m_meas_bu_up = gtk_button_new_from_stock("my-arrow-up-icon");
g_signal_connect (m_meas_bu_up, "pressed", G_CALLBACK(previous_measure_type), (void *) this);
m_meas_bu_down = gtk_button_new_from_stock ("my-arrow-down-icon");
g_signal_connect (m_meas_bu_down, "pressed", G_CALLBACK(next_measure_type), (void *) this);
gtk_box_pack_start(GTK_BOX(measure_type_buttons_vbox), m_meas_bu_up, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(measure_type_buttons_vbox), m_meas_bu_down, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(measure_type_hbox), measure_type_buttons_vbox, FALSE, FALSE, 0);
if (m_measure_type == MIN_MEASRURE_TYPE) {
gtk_widget_set_sensitive(m_meas_bu_up, FALSE);
}
if (m_measure_type == MAX_MEASURE_TYPE) {
gtk_widget_set_sensitive(m_meas_bu_down, FALSE);
}
g_signal_connect (m_measure_type_show_window, "expose-event", G_CALLBACK (draw_measure_types), (void *) this);
alter_box = gtk_vbox_new(FALSE, 5);
m_alter1_check_box = gtk_check_button_new_with_label(_("alternative 1"));
m_alter2_check_box = gtk_check_button_new_with_label(_("alternative 2"));
g_signal_connect(m_alter1_check_box, "toggled", G_CALLBACK(alter1_checked), (void *) this);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_alter1_check_box), alter1 && m_allow_alter);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_alter2_check_box), alter2 && m_allow_alter);
gtk_widget_set_sensitive(m_alter1_check_box, m_allow_alter && measure_type == REPEAT_CLOSE);
gtk_widget_set_sensitive(m_alter2_check_box, (measure_type == REPEAT_CLOSE) && alter1 && m_allow_alter);
gtk_box_pack_start(GTK_BOX(alter_box), m_alter1_check_box, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(alter_box), m_alter2_check_box, TRUE, TRUE, 0);
m_hide_box = gtk_check_button_new_with_label(_("hide following"));
gtk_widget_set_sensitive(m_hide_box, (measure_type & REP_TYPE_MASK) == END_BAR || (measure_type & REP_TYPE_MASK) == REPEAT_CLOSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_hide_box), m_hide_following);
gtk_box_pack_start(GTK_BOX(alter_box), m_hide_box, TRUE, TRUE, 0);
measure_type_vbox = gtk_vbox_new(FALSE, 2);
gtk_container_add (GTK_CONTAINER(measure_type_vbox), measure_type_hbox);
gtk_container_add (GTK_CONTAINER(measure_type_vbox), alter_box);
gtk_container_add (GTK_CONTAINER(measure_type_frame), measure_type_vbox);
gtk_container_add (GTK_CONTAINER(hbox), measure_type_frame);
time_signature_frame = gtk_frame_new(_("time signature"));
time_signature_vbox = gtk_vbox_new(FALSE, 5);
time_signature_upper_hbox = gtk_hbox_new(FALSE, 5);
time_signature_lower_hbox = gtk_hbox_new(FALSE, 5);
numerator_label = gtk_label_new(_("Numerator:"));
denominator_label = gtk_label_new(_("Denominator:"));
m_numerator = gtk_spin_button_new_with_range (1.0, 20.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), m_num);
m_denominator = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "2");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "4");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "8");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "16");
if (m_denom < 4) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
}
else if (m_denom < 8) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
}
else if (m_denom < 16) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 2);
}
else {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 3);
}
m_com_time_bu = gtk_toggle_button_new();
gtk_button_set_image(GTK_BUTTON(m_com_time_bu), gtk_image_new_from_stock("comm-icon", GTK_ICON_SIZE_SMALL_TOOLBAR));
m_cut_time_bu = gtk_toggle_button_new();
gtk_button_set_image(GTK_BUTTON(m_cut_time_bu), gtk_image_new_from_stock("cut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR));
g_signal_connect(m_com_time_bu, "toggled", G_CALLBACK (OnCommButtonToggled), (void *) this);
g_signal_connect(m_cut_time_bu, "toggled", G_CALLBACK (OnCutButtonToggled), (void *) this);
switch (sym) {
case TIME_SYMBOL_COMMON_TIME: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_com_time_bu), TRUE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), 4);
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
break;
case TIME_SYMBOL_CUT_TIME: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_cut_time_bu), TRUE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), 2);
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
break;
default: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_cut_time_bu), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_com_time_bu), FALSE);
break;
}
gtk_widget_set_sensitive(m_denominator, FALSE);
gtk_widget_set_sensitive(m_numerator, FALSE);
gtk_widget_set_sensitive(m_com_time_bu, FALSE);
gtk_widget_set_sensitive(m_cut_time_bu, FALSE);
m_timsig_check_box = gtk_check_button_new_with_label(_("enable timesig"));
g_signal_connect(m_timsig_check_box, "toggled", G_CALLBACK(OnTimesigToggeled), (void *) this);
m_delete_timsig_check_box = gtk_check_button_new_with_label(_("delete timesig"));
g_signal_connect(m_delete_timsig_check_box, "toggled", G_CALLBACK(delete_time_sig_checked), (void *) this);
gtk_widget_set_sensitive(m_delete_timsig_check_box, FALSE);
gtk_box_pack_start (GTK_BOX (time_signature_upper_hbox), numerator_label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_com_time_bu, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_numerator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_lower_hbox), denominator_label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_cut_time_bu, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_denominator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_upper_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_lower_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), m_timsig_check_box, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), m_delete_timsig_check_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(time_signature_frame), time_signature_vbox);
gtk_container_add (GTK_CONTAINER(hbox), time_signature_frame);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), hbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedMeasureConfigDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedMeasureConfigDialog *measure_type_dialog = (NedMeasureConfigDialog *) data;
measure_type_dialog->m_alter1 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_alter1_check_box));
measure_type_dialog->m_alter2 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_alter2_check_box));
measure_type_dialog->m_hide_following = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_hide_box));
switch (result) {
case GTK_RESPONSE_ACCEPT:
measure_type_dialog->m_state = TRUE;
measure_type_dialog->m_timesig_state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_timsig_check_box));
break;
default:
measure_type_dialog->m_state = FALSE;
measure_type_dialog->m_timesig_state = FALSE;
break;
}
measure_type_dialog->m_num = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(measure_type_dialog->m_numerator));
switch (gtk_combo_box_get_active(GTK_COMBO_BOX(measure_type_dialog->m_denominator))) {
case 0: measure_type_dialog->m_denom = 2; break;
case 1: measure_type_dialog->m_denom = 4; break;
case 2: measure_type_dialog->m_denom = 8; break;
default: measure_type_dialog->m_denom = 16; break;
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_com_time_bu))) {
measure_type_dialog->m_symbol = TIME_SYMBOL_COMMON_TIME;
measure_type_dialog->m_num = measure_type_dialog->m_denom = 4;
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_cut_time_bu))) {
measure_type_dialog->m_symbol = TIME_SYMBOL_CUT_TIME;
measure_type_dialog->m_num = measure_type_dialog->m_denom = 2;
}
else {
measure_type_dialog->m_symbol = TIME_SYMBOL_NONE;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedMeasureConfigDialog::OnTimesigToggeled(GtkToggleButton *togglebutton, gpointer data) {
NedMeasureConfigDialog *measure_type_dialog = (NedMeasureConfigDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_timsig_check_box))) {
gtk_widget_set_sensitive(measure_type_dialog->m_com_time_bu, TRUE);
gtk_widget_set_sensitive(measure_type_dialog->m_cut_time_bu, TRUE);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_com_time_bu))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_cut_time_bu), FALSE);
gtk_widget_set_sensitive(measure_type_dialog->m_delete_timsig_check_box, TRUE);
}
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_cut_time_bu))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_com_time_bu), FALSE);
gtk_widget_set_sensitive(measure_type_dialog->m_delete_timsig_check_box, TRUE);
}
else {
gtk_widget_set_sensitive(measure_type_dialog->m_numerator, TRUE);
gtk_widget_set_sensitive(measure_type_dialog->m_denominator, TRUE);
gtk_widget_set_sensitive(measure_type_dialog->m_delete_timsig_check_box, TRUE);
}
}
else {
gtk_widget_set_sensitive(measure_type_dialog->m_numerator, FALSE);
gtk_widget_set_sensitive(measure_type_dialog->m_denominator, FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_delete_timsig_check_box), FALSE);
gtk_widget_set_sensitive(measure_type_dialog->m_delete_timsig_check_box, FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_cut_time_bu), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(measure_type_dialog->m_com_time_bu), FALSE);
gtk_widget_set_sensitive(measure_type_dialog->m_cut_time_bu, FALSE);
gtk_widget_set_sensitive(measure_type_dialog->m_com_time_bu, FALSE);
measure_type_dialog->m_delete_timesig = false;
}
}
void NedMeasureConfigDialog::delete_time_sig_checked (GtkToggleButton *togglebutton, gpointer data) {
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
the_dialog->m_delete_timesig = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_delete_timsig_check_box));
}
void NedMeasureConfigDialog::getValues(bool *state, int *measure_type, bool *alter1, bool *alter2, bool *hide_following, bool *timsig_state, bool *delete_timesig, int *num, int *denom, unsigned int *sym ) {
*state = m_state;
*measure_type = m_measure_type;
*alter1 = m_alter1 && m_measure_type == 2;
*alter2 = m_alter2 && m_measure_type == 2;
*hide_following = m_hide_following;
*num = m_num;
*denom = m_denom;
*timsig_state = m_timesig_state;
*delete_timesig = m_delete_timesig;
*sym = m_symbol;
}
gboolean NedMeasureConfigDialog::draw_measure_types(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
#define ZOOM_FACTOR 40.0
#define LINE_XPOS 50.0
#define MINY 30.0
#define MAXY (MINY + ZOOM_FACTOR * 4 * LINE_DIST)
#define MINI_STAFF_START (LINE_XPOS - 30.0)
#define MINI_STAFF_END (MINI_STAFF_START + 60.0)
int i;
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
cairo_t *cr;
cr = gdk_cairo_create (the_dialog->m_measure_type_show_window->window);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, 0, 0, the_dialog->m_measure_type_show_window->allocation.width, the_dialog->m_measure_type_show_window->allocation.height);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
switch (the_dialog->m_measure_type) {
case REPEAT_OPEN: cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * REPEAT_MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MINY);
cairo_line_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MAXY);
cairo_stroke(cr);
cairo_new_path(cr);
cairo_arc(cr, LINE_XPOS + (REP_THICK_LINE_DIST + REP_DOTS_X_DIST) * ZOOM_FACTOR, MINY + REP_DOTS_Y1DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_arc(cr, LINE_XPOS + (REP_THICK_LINE_DIST + REP_DOTS_X_DIST) * ZOOM_FACTOR, MINY + REP_DOTS_Y2DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_fill(cr);
break;
case REPEAT_CLOSE: cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * REPEAT_MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MINY);
cairo_line_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MAXY);
cairo_stroke(cr);
cairo_new_path(cr);
cairo_arc(cr, LINE_XPOS - REP_DOTS_X_DIST * 0.8 * ZOOM_FACTOR, MINY + REP_DOTS_Y1DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_arc(cr, LINE_XPOS - REP_DOTS_X_DIST * 0.8 * ZOOM_FACTOR, MINY + REP_DOTS_Y2DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_fill(cr);
break;
case REPEAT_OPEN_CLOSE:
cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * REPEAT_MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS, MINY);
cairo_line_to(cr, LINE_XPOS, MAXY);
cairo_stroke(cr);
cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MINY);
cairo_line_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MAXY);
cairo_move_to(cr, LINE_XPOS - REP_THICK_LINE_DIST * ZOOM_FACTOR, MINY);
cairo_line_to(cr, LINE_XPOS - REP_THICK_LINE_DIST * ZOOM_FACTOR, MAXY);
cairo_stroke(cr);
cairo_new_path(cr);
cairo_arc(cr, LINE_XPOS - (REP_THICK_LINE_DIST + REP_DOTS_X_DIST) * ZOOM_FACTOR, MINY + REP_DOTS_Y1DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_arc(cr, LINE_XPOS - (REP_THICK_LINE_DIST + REP_DOTS_X_DIST) * ZOOM_FACTOR, MINY + REP_DOTS_Y2DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_fill(cr);
cairo_new_path(cr);
cairo_arc(cr, LINE_XPOS + (REP_THICK_LINE_DIST + REP_DOTS_X_DIST) * ZOOM_FACTOR, MINY + REP_DOTS_Y1DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_arc(cr, LINE_XPOS + (REP_THICK_LINE_DIST + REP_DOTS_X_DIST) * ZOOM_FACTOR, MINY + REP_DOTS_Y2DIST * ZOOM_FACTOR,
REP_DOTS_RADIUS * ZOOM_FACTOR, 0.0, 2.0 * M_PI);
cairo_fill(cr);
break;
case END_BAR: cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * REPEAT_MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MINY);
cairo_line_to(cr, LINE_XPOS + REP_THICK_LINE_DIST * ZOOM_FACTOR, MAXY);
cairo_stroke(cr);
break;
case DOUBLE_BAR:cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS - REP_DOUBLE_LINE_DIST * ZOOM_FACTOR, MINY);
cairo_line_to(cr, LINE_XPOS - REP_DOUBLE_LINE_DIST * ZOOM_FACTOR, MAXY);
cairo_stroke(cr);
break;
}
if (the_dialog->m_measure_type != REPEAT_OPEN_CLOSE) {
cairo_new_path(cr);
cairo_set_line_width(cr, ZOOM_FACTOR * MEASURE_LINE_THICK);
cairo_move_to(cr, LINE_XPOS, MINY);
cairo_line_to(cr, LINE_XPOS, MAXY);
cairo_stroke(cr);
}
cairo_set_line_width(cr, ZOOM_FACTOR * LINE_THICK);
for (i = 0; i < 5; i++) {
cairo_move_to(cr, MINI_STAFF_START, MINY + i * ZOOM_FACTOR * LINE_DIST);
cairo_line_to(cr, MINI_STAFF_END, MINY + i * ZOOM_FACTOR * LINE_DIST);
}
cairo_stroke(cr);
cairo_destroy (cr);
return FALSE;
}
void NedMeasureConfigDialog::previous_measure_type (GtkButton *button, gpointer data) {
GdkRectangle rect;
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
if (the_dialog->m_measure_type <= MIN_MEASRURE_TYPE) return;
the_dialog->m_measure_type--;
gtk_widget_set_sensitive(the_dialog->m_meas_bu_up, TRUE);
gtk_widget_set_sensitive(the_dialog->m_meas_bu_down, TRUE);
if (the_dialog->m_measure_type == MIN_MEASRURE_TYPE) {
gtk_widget_set_sensitive(the_dialog->m_meas_bu_up, FALSE);
}
if (the_dialog->m_allow_alter && the_dialog->m_measure_type == 2) {
gtk_widget_set_sensitive(the_dialog->m_alter1_check_box, TRUE);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_alter1_check_box))) {
gtk_widget_set_sensitive(the_dialog->m_alter2_check_box, TRUE);
}
}
else {
gtk_widget_set_sensitive(the_dialog->m_alter1_check_box, FALSE);
gtk_widget_set_sensitive(the_dialog->m_alter2_check_box, FALSE);
}
if ((the_dialog->m_measure_type & REP_TYPE_MASK) == END_BAR || (the_dialog->m_measure_type & REP_TYPE_MASK) == REPEAT_CLOSE) {
gtk_widget_set_sensitive(the_dialog->m_hide_box, TRUE);
if ((the_dialog->m_measure_type & REP_TYPE_MASK) != the_dialog->m_original_type) {
if ((the_dialog->m_measure_type & REP_TYPE_MASK) == END_BAR) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), TRUE);
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), FALSE);
}
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), the_dialog->m_hide_following);
}
}
else {
gtk_widget_set_sensitive(the_dialog->m_hide_box, TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), FALSE);
gtk_widget_set_sensitive(the_dialog->m_hide_box, FALSE);
}
rect.x = rect.y = 0;
rect.width = the_dialog->m_measure_type_show_window->allocation.width;
rect.height = the_dialog->m_measure_type_show_window->allocation.height;
gdk_window_invalidate_rect (the_dialog->m_measure_type_show_window->window, &rect, FALSE);
}
void NedMeasureConfigDialog::next_measure_type (GtkButton *button, gpointer data) {
GdkRectangle rect;
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
if (the_dialog->m_measure_type >= MAX_MEASURE_TYPE) return;
the_dialog->m_measure_type++;
gtk_widget_set_sensitive(the_dialog->m_meas_bu_up, TRUE);
gtk_widget_set_sensitive(the_dialog->m_meas_bu_down, TRUE);
if (the_dialog->m_measure_type >= MAX_MEASURE_TYPE) {
gtk_widget_set_sensitive(the_dialog->m_meas_bu_down, FALSE);
}
if (the_dialog->m_allow_alter && the_dialog->m_measure_type == 2) {
gtk_widget_set_sensitive(the_dialog->m_alter1_check_box, TRUE);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_alter1_check_box))) {
gtk_widget_set_sensitive(the_dialog->m_alter2_check_box, TRUE);
}
}
else {
gtk_widget_set_sensitive(the_dialog->m_alter1_check_box, FALSE);
gtk_widget_set_sensitive(the_dialog->m_alter2_check_box, FALSE);
}
if ((the_dialog->m_measure_type & REP_TYPE_MASK) == END_BAR || (the_dialog->m_measure_type & REP_TYPE_MASK) == REPEAT_CLOSE) {
gtk_widget_set_sensitive(the_dialog->m_hide_box, TRUE);
if ((the_dialog->m_measure_type & REP_TYPE_MASK) != the_dialog->m_original_type) {
if ((the_dialog->m_measure_type & REP_TYPE_MASK) == END_BAR) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), TRUE);
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), FALSE);
}
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), the_dialog->m_hide_following);
}
}
else {
gtk_widget_set_sensitive(the_dialog->m_hide_box, TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_hide_box), FALSE);
gtk_widget_set_sensitive(the_dialog->m_hide_box, FALSE);
}
rect.x = rect.y = 0;
rect.width = the_dialog->m_measure_type_show_window->allocation.width;
rect.height = the_dialog->m_measure_type_show_window->allocation.height;
gdk_window_invalidate_rect (the_dialog->m_measure_type_show_window->window, &rect, FALSE);
}
void NedMeasureConfigDialog::alter1_checked (GtkToggleButton *togglebutton, gpointer data) {
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_alter1_check_box))) {
gtk_widget_set_sensitive(the_dialog->m_alter2_check_box, TRUE);
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_alter2_check_box), FALSE);
gtk_widget_set_sensitive(the_dialog->m_alter2_check_box, FALSE);
}
}
void NedMeasureConfigDialog::OnCommButtonToggled(GtkToggleButton *togglebutton, gpointer data) {
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_com_time_bu))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_cut_time_bu), FALSE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(the_dialog->m_numerator), 4);
gtk_combo_box_set_active(GTK_COMBO_BOX(the_dialog->m_denominator), 1);
gtk_widget_set_sensitive(the_dialog->m_numerator, FALSE);
gtk_widget_set_sensitive(the_dialog->m_denominator, FALSE);
}
else if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_cut_time_bu))) {
gtk_widget_set_sensitive(the_dialog->m_numerator, TRUE);
gtk_widget_set_sensitive(the_dialog->m_denominator, TRUE);
}
}
void NedMeasureConfigDialog::OnCutButtonToggled(GtkToggleButton *togglebutton, gpointer data) {
NedMeasureConfigDialog *the_dialog = (NedMeasureConfigDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_cut_time_bu))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_com_time_bu), FALSE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(the_dialog->m_numerator), 2);
gtk_combo_box_set_active(GTK_COMBO_BOX(the_dialog->m_denominator), 0);
gtk_widget_set_sensitive(the_dialog->m_numerator, FALSE);
gtk_widget_set_sensitive(the_dialog->m_denominator, FALSE);
}
else if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_com_time_bu))) {
gtk_widget_set_sensitive(the_dialog->m_numerator, TRUE);
gtk_widget_set_sensitive(the_dialog->m_denominator, TRUE);
}
}
nted-1.10.18/dialogs/scaledialog.cpp 0000664 0010410 0000764 00000005351 11520267217 014140 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "scaledialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#define SCALE_STEPS (1.0 / (double) SCALE_GRANULARITY)
NedScaleDialog::NedScaleDialog(GtkWindow *parent, int scale) : m_scale(scale) {
GtkWidget *dialog;
GtkWidget *scale_frame;
dialog = gtk_dialog_new_with_buttons(_("Scale"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
scale_frame = gtk_frame_new(_("Scale"));
m_scale_slider = gtk_hscale_new_with_range(SCALE_MIN, SCALE_MAX, SCALE_STEPS);
gtk_range_set_value(GTK_RANGE(m_scale_slider), (double) scale / (double) SCALE_GRANULARITY);
gtk_container_add (GTK_CONTAINER(scale_frame), m_scale_slider);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), scale_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedScaleDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedScaleDialog *scale_dialog = (NedScaleDialog *) data;
double val;
switch (result) {
case GTK_RESPONSE_ACCEPT:
scale_dialog->m_state = TRUE;
break;
default:
scale_dialog->m_state = FALSE;
break;
}
val = gtk_range_get_value(GTK_RANGE(scale_dialog->m_scale_slider));
scale_dialog->m_scale = (int) (val * (double) SCALE_GRANULARITY + 0.5);
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedScaleDialog::getValues(bool *state, int *scale) {
*state = m_state;
*scale = m_scale;
}
nted-1.10.18/dialogs/clefconfigdialog.cpp 0000664 0010410 0000764 00000027020 11520267217 015145 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "clefconfigdialog.h"
#include "localization.h"
#include "resource.h"
#define CLEF_SHOW_WINDOW_WIDTH 90
#define CLEF_SHOW_WINDOW_HEIGHT 120
NedClefConfigDialog::NedClefConfigDialog(GtkWindow *parent, int clef_number, int octave_shift) :
m_octave_shift(octave_shift), m_state(false), m_current_clef(clef_number) {
GtkWidget *dialog;
GtkWidget *clef_hbox;
GtkWidget *clef_buttons_vbox;
GtkWidget *clef_frame;
GtkWidget *octave_shift_label;
GtkWidget *octave_shift_vbox;
GdkColor bgcolor;
m_newclef = m_current_clef;
dialog = gtk_dialog_new_with_buttons(_("Clef configuration"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
clef_frame = gtk_frame_new(_("clef"));
m_clef_show_window = gtk_drawing_area_new ();
bgcolor.pixel = 1;
bgcolor.red = bgcolor.green = bgcolor.blue = 0xffff;
gtk_widget_modify_bg(GTK_WIDGET(m_clef_show_window), GTK_STATE_NORMAL, &bgcolor);
gtk_drawing_area_size(GTK_DRAWING_AREA(m_clef_show_window), CLEF_SHOW_WINDOW_WIDTH, CLEF_SHOW_WINDOW_HEIGHT);
clef_hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(clef_hbox), m_clef_show_window, FALSE, FALSE, 0);
clef_buttons_vbox = gtk_vbox_new(FALSE, 2);
m_clef_bu_up = gtk_button_new_from_stock("my-arrow-up-icon");
g_signal_connect (m_clef_bu_up, "pressed", G_CALLBACK(decrease_clef_number), (void *) this);
m_clef_bu_down = gtk_button_new_from_stock ("my-arrow-down-icon");
g_signal_connect (m_clef_bu_down, "pressed", G_CALLBACK(increase_clef_number), (void *) this);
gtk_box_pack_start(GTK_BOX(clef_buttons_vbox), m_clef_bu_up, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(clef_buttons_vbox), m_clef_bu_down, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(clef_hbox), clef_buttons_vbox, FALSE, FALSE, 0);
octave_shift_vbox = gtk_vbox_new(FALSE, 2);
switch (m_octave_shift) {
case 12: m_octave_shift = 8; break;
case -12: m_octave_shift = -8; break;
}
m_octave_shift_spin_box = gtk_spin_button_new_with_range(-8.0, 8.0, 8.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_octave_shift_spin_box), m_octave_shift);
octave_shift_label = gtk_label_new(_("Octave shift:"));
gtk_box_pack_start (GTK_BOX (octave_shift_vbox), octave_shift_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (octave_shift_vbox), m_octave_shift_spin_box, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(clef_hbox), octave_shift_vbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(clef_frame), clef_hbox);
g_signal_connect (m_octave_shift_spin_box, "value-changed", G_CALLBACK (octave_shift_change), (void *) this);
m_adjust_check_box = gtk_check_button_new_with_label(_("adjust notes"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_adjust_check_box), TRUE);
gtk_box_pack_start (GTK_BOX (octave_shift_vbox), m_adjust_check_box, FALSE, FALSE, 0);
if (m_newclef == MINCLEF_NUMBER) {
gtk_widget_set_sensitive(m_clef_bu_up, FALSE);
}
if (m_newclef == MAXCLEF_NUMBER) {
gtk_widget_set_sensitive(m_clef_bu_down, FALSE);
}
g_signal_connect (m_clef_show_window, "expose-event", G_CALLBACK (draw_clefs), (void *) this);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), clef_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedClefConfigDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedClefConfigDialog *clef_dialog = (NedClefConfigDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
clef_dialog->m_state = TRUE;
break;
default:
clef_dialog->m_state = FALSE;
break;
}
clef_dialog->m_octave_shift = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(clef_dialog->m_octave_shift_spin_box));
switch (clef_dialog->m_octave_shift) {
case 8: clef_dialog->m_octave_shift = 12; break;
case -8: clef_dialog->m_octave_shift = -12; break;
default: clef_dialog->m_octave_shift = 0; break;
}
clef_dialog->m_do_adjust = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(clef_dialog->m_adjust_check_box));
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedClefConfigDialog::getValues(bool *state, int *clef_number, int *octave_shift, bool *adjust_notes) {
*state = m_state;
m_current_clef = m_newclef;
*octave_shift = m_octave_shift;
*clef_number = m_current_clef;
*adjust_notes = m_do_adjust;
}
gboolean NedClefConfigDialog::draw_clefs(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
#define ZOOM_LEVEL 9
NedClefConfigDialog *the_dialog = (NedClefConfigDialog *) data;
cairo_scaled_font_t *scaled_font;
cairo_glyph_t glyph;
int i;
double y_offs = 0.0, oct_y_offs = 0.0, oct_x_offs = 0.0;
bool octave_shift = false;
cairo_t *cr;
cr = gdk_cairo_create (the_dialog->m_clef_show_window->window);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_rectangle (cr, 0, 0, the_dialog->m_clef_show_window->allocation.width, the_dialog->m_clef_show_window->allocation.height);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
scaled_font = NedResource::getScaledFont(ZOOM_LEVEL);
#ifdef HAS_SET_SCALED_FONT
cairo_set_scaled_font (cr, scaled_font);
#else
cairo_set_font_face(cr, NedResource::getFontFace());
cairo_set_font_matrix(cr, NedResource::getFontMatrix(ZOOM_LEVEL));
cairo_set_font_options(cr, NedResource::getFontOptions());
#endif
cairo_new_path(cr);
cairo_set_line_width(cr, DEMO_LINE_THICK);
for (i = 0; i < 5; i++) {
cairo_move_to(cr, DEMO_LINE_BEGIN, DEMO_LINE_YPOS + DEMO_LINE_DIST * i);
cairo_line_to(cr, DEMO_LINE_END, DEMO_LINE_YPOS + DEMO_LINE_DIST * i);
}
cairo_stroke(cr);
cairo_new_path(cr);
switch (the_dialog->m_newclef) {
case TREBLE_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_TREBLE_DIST_UP); octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_TREBLE_DIST_DOWN); octave_shift = true; break;
}
glyph.index = BASE + 2; break;
case BASS_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_BASS_DIST_UP); octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_BASS_DIST_DOWN); octave_shift = true; break;
}
glyph.index = BASE + 3; break;
case ALTO_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_UP);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_DOWN);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
}
glyph.index = BASE + 1; break;
case SOPRAN_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_UP);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_DOWN);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
}
glyph.index = BASE + 1; y_offs = 2 * DEMO_LINE_DIST; break;
case TENOR_CLEF:
switch(the_dialog->m_octave_shift) {
case 12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_UP);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
case -12: oct_y_offs = DEMO_POS_FAK * (OCTUP_Y_ALTO_DIST_DOWN);
oct_x_offs = DEMO_POS_FAK * (OCTUP_X_ALTO_DIST);
octave_shift = true; break;
}
glyph.index = BASE + 1; y_offs = -DEMO_LINE_DIST; break;
case NEUTRAL_CLEF1:
case NEUTRAL_CLEF2:
case NEUTRAL_CLEF3:
glyph.index = BASE + 27; break;
}
glyph.x = 50.0;
glyph.y = 70.0 + y_offs;
cairo_show_glyphs(cr, &glyph, 1);
switch (the_dialog->m_newclef) {
case NEUTRAL_CLEF1: glyph.index = NUMBERBASE + 1;
glyph.x = 60.0;
glyph.y = 120.0;
cairo_show_glyphs(cr, &glyph, 1);
break;
case NEUTRAL_CLEF2: glyph.index = NUMBERBASE + 2;
glyph.x = 60.0;
glyph.y = 120.0;
cairo_show_glyphs(cr, &glyph, 1);
break;
case NEUTRAL_CLEF3: glyph.index = NUMBERBASE + 3;
glyph.x = 60.0;
glyph.y = 120.0;
cairo_show_glyphs(cr, &glyph, 1);
break;
}
if (octave_shift) {
glyph.x = 50.0 + oct_x_offs;
glyph.y = 70.0 + y_offs + oct_y_offs;
glyph.index = BASE + 28;
cairo_show_glyphs(cr, &glyph, 1);
}
cairo_destroy (cr);
return FALSE;
}
void NedClefConfigDialog::decrease_clef_number (GtkButton *button, gpointer data) {
GdkRectangle rect;
NedClefConfigDialog *the_dialog = (NedClefConfigDialog *) data;
if (the_dialog->m_newclef <= MINCLEF_NUMBER) return;
the_dialog->m_newclef--;
gtk_widget_set_sensitive(the_dialog->m_clef_bu_up, TRUE);
gtk_widget_set_sensitive(the_dialog->m_clef_bu_down, TRUE);
if (the_dialog->m_newclef == MINCLEF_NUMBER) {
gtk_widget_set_sensitive(the_dialog->m_clef_bu_up, FALSE);
}
rect.x = rect.y = 0;
rect.width = the_dialog->m_clef_show_window->allocation.width;
rect.height = the_dialog->m_clef_show_window->allocation.height;
gdk_window_invalidate_rect (the_dialog->m_clef_show_window->window, &rect, FALSE);
}
void NedClefConfigDialog::increase_clef_number (GtkButton *button, gpointer data) {
GdkRectangle rect;
NedClefConfigDialog *the_dialog = (NedClefConfigDialog *) data;
if (the_dialog->m_newclef >= MAXCLEF_NUMBER) return;
the_dialog->m_newclef++;
gtk_widget_set_sensitive(the_dialog->m_clef_bu_up, TRUE);
gtk_widget_set_sensitive(the_dialog->m_clef_bu_down, TRUE);
if (the_dialog->m_newclef >= MAXCLEF_NUMBER) {
gtk_widget_set_sensitive(the_dialog->m_clef_bu_down, FALSE);
}
rect.x = rect.y = 0;
rect.width = the_dialog->m_clef_show_window->allocation.width;
rect.height = the_dialog->m_clef_show_window->allocation.height;
gdk_window_invalidate_rect (the_dialog->m_clef_show_window->window, &rect, FALSE);
}
void NedClefConfigDialog::octave_shift_change(GtkSpinButton *spinbutton, gpointer data) {
GdkRectangle rect;
NedClefConfigDialog *context_dialog = (NedClefConfigDialog *) data;
context_dialog->m_octave_shift = (int) gtk_spin_button_get_value(spinbutton);
switch (context_dialog->m_octave_shift) {
case 8: context_dialog->m_octave_shift = 12; break;
case -8: context_dialog->m_octave_shift = -12; break;
}
rect.x = rect.y = 0;
rect.width = context_dialog->m_clef_show_window->allocation.width;
rect.height = context_dialog->m_clef_show_window->allocation.height;
gdk_window_invalidate_rect (context_dialog->m_clef_show_window->window, &rect, FALSE);
}
nted-1.10.18/dialogs/scoreinfodialog.h 0000664 0010410 0000764 00000004120 11520267217 014476 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SCORE_INFO_BLOCK_DIALOG_H
#define SCORE_INFO_BLOCK_DIALOG_H
#include "config.h"
#include
#include
class NedPangoCairoText;
class NedMainWindow;
class ScoreInfo {
public:
ScoreInfo();
~ScoreInfo();
NedPangoCairoText *title, *subject, *composer, *arranger, *copyright;
cairo_text_extents_t title_extends, subject_extends, composer_extends, arranger_extends, copyright_extends;
};
class NedScoreInfoConfigDialog {
public:
NedScoreInfoConfigDialog(GtkWindow *parent, NedMainWindow *main_window, ScoreInfo *scoreinfo);
void getValues(bool *state);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
bool m_state;
ScoreInfo *m_scoreinfo;
GtkWidget *m_title;
GtkWidget *m_subject;
GtkWidget *m_composer;
GtkWidget *m_arranger;
GtkWidget *m_copyright;
NedMainWindow *m_main_window;
};
#endif /* SCORE_INFO_BLOCK_DIALOG_H */
nted-1.10.18/dialogs/volumedialog.h 0000664 0010410 0000764 00000003132 11520267217 014020 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef VOLUME_DIALOG_H
#define VOLUME_DIALOG_H
#include "config.h"
#include
class NedVolumeDialog {
public:
NedVolumeDialog(GtkWindow *parent, int volume, bool relative);
void getValues(bool *state, int *volume);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_volume_spin_box;
bool m_state;
int m_volume;
};
#endif /* VOLUME_DIALOG_H */
nted-1.10.18/dialogs/textdialog.cpp 0000664 0010410 0000764 00000046067 11520267217 014046 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "textdialog.h"
#include "localization.h"
#include "resource.h"
#include "freetext.h"
#include "pangocairotext.h"
#include "config.h"
const char *NedTextDialog::m_static_font_family = TEXT_FONT_NAME_DEFAULT;
double NedTextDialog::m_static_font_size = TEXT_FONT_SIZE_DEFAULT;
PangoStyle NedTextDialog::m_static_font_slant = TEXT_FONT_SLANT_DEFAULT;
PangoWeight NedTextDialog::m_static_font_weight = TEXT_FONT_WEIGHT_DEFAULT;
NedTextDialog::NedTextDialog(GtkWindow *parent, char *text, int anchor, unsigned int tempo, bool enable_tempo, unsigned int volume, bool enable_volume,
unsigned short segno_sign, int midi_program, int channel, bool enable_channel,
const char *font_family, double font_size, PangoStyle font_slant, PangoWeight font_weight) :
m_tempo(tempo), m_volume(volume), m_enable_tempo(enable_tempo), m_enable_volume(enable_volume),
m_segno_sign(segno_sign), m_midi_program_number(midi_program), m_channel(channel), m_enable_channel(enable_channel), m_anchor(anchor),
m_text(text), m_font_family(font_family), m_font_size(font_size), m_font_slant(font_slant), m_font_weight(font_weight) {
GtkWidget *dialog;
GtkWidget *text_frame;
GtkWidget *font_vbox;
GtkWidget *volume_frame;
GtkWidget *volume_hbox;
GtkWidget *tempo_frame;
GtkWidget *anchor_frame;
GtkWidget *tempo_hbox;
GtkWidget *ds_frame;
GtkWidget *ds_v_box;
GtkWidget *anchor_h_box;
GtkWidget *instr_frame;
GtkWidget *channel_frame;
GtkWidget *channel_hbox;
GtkListStore *instrumend_list_store;
GtkTreeIter iter;
GtkCellRenderer *instrument_renderer;
GtkTreeViewColumn *instrument_column;
GtkTreeViewColumn *instrument_num_column;
GtkTreePath* instrument_tree_path;
GtkWidget *main_v_box;
char *fontstring;
PangoFontDescription *f_descr;
int i;
char Str[128];
dialog = gtk_dialog_new_with_buttons(_("Text"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
if (text == NULL) {
m_font_family = m_static_font_family;
m_font_slant = m_static_font_slant;
m_font_weight = m_static_font_weight;
font_size = m_static_font_size;
}
f_descr = pango_font_description_new();
pango_font_description_set_family(f_descr, m_font_family);
pango_font_description_set_style(f_descr, m_font_slant);
pango_font_description_set_weight(f_descr, m_font_weight);
pango_font_description_set_size(f_descr, PS_ZOOM * NedPangoCairoText::getInternalFactor() * font_size);
fontstring = pango_font_description_to_string(f_descr);
text_frame = gtk_frame_new(_("text"));
m_text_widget = gtk_entry_new_with_max_length(50);
if (m_text != NULL) {
gtk_entry_set_text(GTK_ENTRY(m_text_widget), m_text);
}
m_font_button = gtk_font_button_new_with_font(fontstring);
g_free(fontstring);
pango_font_description_free(f_descr);
gtk_font_button_set_title(GTK_FONT_BUTTON(m_font_button), _("select font"));
font_vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(font_vbox), m_text_widget, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(font_vbox), m_font_button, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(text_frame), font_vbox);
g_signal_connect(m_font_button, "font-set", G_CALLBACK(FontCallBack), (void *) this);
anchor_frame = gtk_frame_new(_("anchor"));
anchor_h_box = gtk_hbox_new(FALSE, 2);
m_anchor_left = gtk_radio_button_new_with_label(NULL, _("left"));
m_anchor_mid = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_anchor_left), _("mid"));
m_anchor_right = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_anchor_left), _("right"));
gtk_box_pack_start(GTK_BOX(anchor_h_box), m_anchor_left, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(anchor_h_box), m_anchor_mid, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(anchor_h_box), m_anchor_right, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(anchor_frame), anchor_h_box);
switch (m_anchor) {
case ANCHOR_LEFT: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_anchor_left), TRUE); break;
case ANCHOR_RIGHT: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_anchor_right), TRUE); break;
default: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_anchor_mid), TRUE); break;
}
volume_frame = gtk_frame_new(_("volume"));
volume_hbox = gtk_hbox_new(FALSE, 2);
m_volume_spin_box = gtk_spin_button_new_with_range (0.0, 127.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_volume_spin_box), volume);
gtk_widget_set_sensitive(m_volume_spin_box, m_enable_volume);
m_check_volume = gtk_check_button_new_with_label(_("enable volume change"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_check_volume), m_enable_volume);
gtk_box_pack_start(GTK_BOX(volume_hbox), m_check_volume, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(volume_hbox), m_volume_spin_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(volume_frame), volume_hbox);
g_signal_connect(m_check_volume, "toggled", G_CALLBACK(VolumeToggled), (void *) this);
tempo_frame = gtk_frame_new(_("tempo"));
tempo_hbox = gtk_hbox_new(FALSE, 2);
m_tempo_spin_box = gtk_spin_button_new_with_range (10.0, 999.0, 1.0);
gtk_widget_set_sensitive(m_tempo_spin_box, m_enable_tempo);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_tempo_spin_box), tempo);
m_check_tempo = gtk_check_button_new_with_label(_("enable tempo change"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_check_tempo), m_enable_tempo);
gtk_box_pack_start(GTK_BOX(tempo_hbox), m_check_tempo, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(tempo_hbox), m_tempo_spin_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(tempo_frame), tempo_hbox);
g_signal_connect(m_check_tempo, "toggled", G_CALLBACK(TempoToggled), (void *) this);
channel_frame = gtk_frame_new(_("channel"));
channel_hbox = gtk_hbox_new(FALSE, 2);
m_channel_spin_box = gtk_spin_button_new_with_range (1.0, 16.0, 1.0);
gtk_widget_set_sensitive(m_channel_spin_box, m_enable_channel);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_channel_spin_box), channel + 1);
m_check_channel = gtk_check_button_new_with_label(_("enable channel change"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_check_channel), m_enable_channel);
gtk_box_pack_start(GTK_BOX(channel_hbox), m_check_channel, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(channel_hbox), m_channel_spin_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(channel_frame), channel_hbox);
g_signal_connect(m_check_channel, "toggled", G_CALLBACK(ChannelToggled), (void *) this);
ds_frame = gtk_frame_new(_("D.S"));
ds_v_box = gtk_vbox_new(FALSE, 2);
m_segno_none = gtk_radio_button_new_with_label(NULL, _("No segno meaning"));
m_ds_al_fine = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_segno_none), _("D.S. al Fine"));
m_ds_al_coda = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_segno_none), _("D.S. al Coda"));
m_d_capo_al_fine = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_segno_none), _("D. Capo al Fine"));
m_d_capo_al_coda = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_segno_none), _("D. Capo al Coda"));
m_fine = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_segno_none), _("Fine"));
m_al_coda = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (m_segno_none), _("al Coda"));
switch(segno_sign) {
case SEGNO_D_S_AL_FINE: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_ds_al_fine), TRUE); break;
case SEGNO_D_S_AL_CODA: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_ds_al_coda), TRUE); break;
case SEGNO_D_CAPO_AL_FINE: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_d_capo_al_fine), TRUE); break;
case SEGNO_D_CAPO_AL_CODA: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_d_capo_al_coda), TRUE); break;
case SEGNO_FINE: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_fine), TRUE); break;
case SEGNO_AL_CODA: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_al_coda), TRUE); break;
default: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_segno_none), TRUE); break;
}
gtk_box_pack_start(GTK_BOX(ds_v_box), m_segno_none, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ds_v_box), m_ds_al_fine, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ds_v_box), m_ds_al_coda, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ds_v_box), m_d_capo_al_fine, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ds_v_box), m_d_capo_al_coda, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ds_v_box), m_fine, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ds_v_box), m_al_coda, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(ds_frame), ds_v_box);
instrumend_list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
for (i = 0; i < NedResource::getNumInstruments(); i++) {
gtk_list_store_append (instrumend_list_store, &iter);
gtk_list_store_set (instrumend_list_store, &iter, 0, i, 1, gettext(NedResource::GM_Instruments[i]), -1);
}
m_instrument_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(instrumend_list_store));
instrument_renderer = gtk_cell_renderer_text_new ();
instrument_num_column = gtk_tree_view_column_new_with_attributes (_("no"), instrument_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_num_column);
instrument_column = gtk_tree_view_column_new_with_attributes (_("instruments"), instrument_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_column);
m_instrument_adjustment = gtk_adjustment_new (0.0, 0.0, NedResource::getNumInstruments(), 1.0, 10.0, 10.0);
m_instrument_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(m_instrument_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_instrument_list), GTK_ADJUSTMENT(m_instrument_adjustment));
gtk_widget_set_size_request(m_instrument_list, 150, 100);
sprintf(Str, "%d", m_midi_program_number < 0 ? 0: m_midi_program_number);
instrument_tree_path = gtk_tree_path_new_from_string(Str);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE);
g_signal_connect(dialog, "scroll-event", G_CALLBACK (OnScroll), (void *) this);
if (m_midi_program_number < 0) {
gtk_widget_set_sensitive(m_instrument_list, FALSE);
gtk_widget_set_sensitive(m_instrument_scroll, FALSE);
}
instr_frame = gtk_frame_new(_("instrument"));
m_check_instr = gtk_check_button_new_with_label(_("enable instrument change"));
gtk_container_add (GTK_CONTAINER(instr_frame), m_check_instr);
main_v_box = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(main_v_box), anchor_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_v_box), text_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_v_box), volume_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_v_box), tempo_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_v_box), channel_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_v_box), instr_frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(main_v_box), ds_frame, FALSE, FALSE, 0);
m_main_h_box = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(m_main_h_box), main_v_box, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(m_main_h_box), m_instrument_scroll, TRUE, TRUE, 0);
gtk_box_pack_end(GTK_BOX(m_main_h_box), m_instrument_list, TRUE, TRUE, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_check_instr), m_midi_program_number >= 0);
g_signal_connect(m_check_instr, "toggled", G_CALLBACK(InstrToggled), (void *) this);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), m_main_h_box);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedTextDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedTextDialog *text_dialog = (NedTextDialog *) data;
const gchar *newtext;
GtkTreeSelection* selection;
GList *selected_rows;
switch (result) {
case GTK_RESPONSE_ACCEPT:
text_dialog->m_state = TRUE;
break;
default:
text_dialog->m_state = FALSE;
break;
}
if (text_dialog->m_state) {
text_dialog->m_text = NULL;
newtext = gtk_entry_get_text(GTK_ENTRY(text_dialog->m_text_widget));
if (strlen(newtext) > 0) {
text_dialog->m_text = strdup(newtext);
}
text_dialog->m_enable_tempo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(text_dialog->m_check_tempo));
text_dialog->m_enable_volume = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(text_dialog->m_check_volume));
text_dialog->m_volume = (int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(text_dialog->m_volume_spin_box)) + 0.4);
text_dialog->m_tempo = (unsigned int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(text_dialog->m_tempo_spin_box)) + 0.4);
text_dialog->m_enable_channel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(text_dialog->m_check_channel));
text_dialog->m_channel = (unsigned int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(text_dialog->m_channel_spin_box)) + 0.4) - 1;
text_dialog->retrieveFontParams();
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_ds_al_fine))) text_dialog->m_segno_sign = SEGNO_D_S_AL_FINE;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_ds_al_coda))) text_dialog->m_segno_sign = SEGNO_D_S_AL_CODA;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_d_capo_al_fine))) text_dialog->m_segno_sign = SEGNO_D_CAPO_AL_FINE;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_d_capo_al_coda))) text_dialog->m_segno_sign = SEGNO_D_CAPO_AL_CODA;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_fine))) text_dialog->m_segno_sign = SEGNO_FINE;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_al_coda))) text_dialog->m_segno_sign = SEGNO_AL_CODA;
else text_dialog->m_segno_sign = 0;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_anchor_left))) text_dialog->m_anchor = ANCHOR_LEFT;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_dialog->m_anchor_right))) text_dialog->m_anchor = ANCHOR_RIGHT;
else text_dialog->m_anchor = ANCHOR_MID;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(text_dialog->m_instrument_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(text_dialog->m_check_instr))) {
if ( g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &(text_dialog->m_midi_program_number)) != 1) {
NedResource::Abort("NedStaffContextDialog::OnClose: error reading tree path(1)");
}
}
else {
text_dialog->m_midi_program_number = -1;
}
}
else {
text_dialog->m_midi_program_number = -1;
}
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedTextDialog::getValues(bool *state, char **text, int *anchor, unsigned int *tempo, bool *enable_tempo, unsigned int *volume, bool *enable_volume,
unsigned short *segno_sign, int *midi_program, unsigned int *channel, bool *enable_channel, const char **font_family, double *font_size, PangoStyle *font_slant, PangoWeight *font_weight) {
*state = m_state;
*text = m_text;
*font_family = m_font_family;
*font_size = m_font_size;
*font_slant = m_font_slant;
*font_weight = m_font_weight;
*tempo = m_tempo;
*volume = m_volume;
*enable_tempo = m_enable_tempo;
*enable_volume = m_enable_volume;
*enable_channel = m_enable_channel;
*channel = m_channel;
*segno_sign = m_segno_sign;
*anchor = m_anchor;
*midi_program = m_midi_program_number;
if (m_state) {
m_static_font_family = m_font_family;
m_static_font_slant = m_font_slant;
m_static_font_weight = m_font_weight;
m_static_font_size = m_font_size;
}
}
void NedTextDialog::FontCallBack(GtkButton *button, gpointer data) {
NedTextDialog *text_dialog = (NedTextDialog *) data;
text_dialog->retrieveFontParams();
}
void NedTextDialog::retrieveFontParams() {
gchar *fontname;
PangoFontDescription* f_descr;
g_object_get(m_font_button, "font-name", &fontname, NULL);
f_descr = pango_font_description_from_string(fontname);
m_font_family = pango_font_description_get_family(f_descr);
m_font_size = pango_font_description_get_size(f_descr) / NedPangoCairoText::getInternalFactor() / PS_ZOOM;
m_font_slant = pango_font_description_get_style(f_descr);
m_font_weight = pango_font_description_get_weight(f_descr);
g_free (fontname);
}
void NedTextDialog::TempoToggled(GtkToggleButton *button, gpointer data) {
NedTextDialog *text_dialog = (NedTextDialog *) data;
gtk_widget_set_sensitive(text_dialog->m_tempo_spin_box, gtk_toggle_button_get_active(button));
}
void NedTextDialog::InstrToggled(GtkToggleButton *button, gpointer data) {
NedTextDialog *text_dialog = (NedTextDialog *) data;
if (gtk_toggle_button_get_active(button)) {
gtk_widget_set_sensitive(text_dialog->m_instrument_list, TRUE);
gtk_widget_set_sensitive(text_dialog->m_instrument_scroll, TRUE);
}
else {
gtk_widget_set_sensitive(text_dialog->m_instrument_list, FALSE);
gtk_widget_set_sensitive(text_dialog->m_instrument_scroll, FALSE);
}
}
void NedTextDialog::VolumeToggled(GtkToggleButton *button, gpointer data) {
NedTextDialog *text_dialog = (NedTextDialog *) data;
gtk_widget_set_sensitive(text_dialog->m_volume_spin_box, gtk_toggle_button_get_active(button));
}
void NedTextDialog::ChannelToggled(GtkToggleButton *button, gpointer data) {
NedTextDialog *text_dialog = (NedTextDialog *) data;
gtk_widget_set_sensitive(text_dialog->m_channel_spin_box, gtk_toggle_button_get_active(button));
}
gboolean NedTextDialog::OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data) {
#define SCROLL_INCR 20.0
double adjval;
NedTextDialog *text_dialog = (NedTextDialog *) data;
adjval = gtk_adjustment_get_value(GTK_ADJUSTMENT(text_dialog->m_instrument_adjustment));
if (event->direction == GDK_SCROLL_UP) {
adjval -= SCROLL_INCR;
}
else if (event->direction == GDK_SCROLL_DOWN) {
adjval += SCROLL_INCR;
}
gtk_adjustment_set_value(GTK_ADJUSTMENT(text_dialog->m_instrument_adjustment), adjval);
return FALSE;
}
nted-1.10.18/dialogs/tempodialog.h 0000664 0010410 0000764 00000003737 11520267217 013650 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef TEMPO_DIALOG_H
#define TEMPO_DIALOG_H
#include "config.h"
#include "resource.h"
#include
class NedTempoDialog {
public:
NedTempoDialog(GtkWindow *parent, bool relative, unsigned int kind = NOTE_4, bool dot = false, unsigned int tempo = 120);
void getValues(bool *state, unsigned int *kind, bool *dot, unsigned int *tempo);
private:
static void CloseCallBack(GtkDialog *dialog, gint result, gpointer data);
GtkWidget *m_tempo_spin_box;
GtkWidget *m_whole_kind;
GtkWidget *m_kind_2;
GtkWidget *m_kind_2_dot;
GtkWidget *m_kind_4;
GtkWidget *m_kind_4_dot;
GtkWidget *m_kind_8;
GtkWidget *m_kind_8_dot;
GtkWidget *m_kind_16;
GtkWidget *m_kind_16_dot;
bool m_state;
unsigned int m_kind;
bool m_dot;
unsigned int m_tempo;
};
#endif /* TEMPO_DIALOG_H */
nted-1.10.18/dialogs/tools.cpp 0000664 0010410 0000764 00000146716 11520267217 013044 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include
#include
#include "tools.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#define IS_IT(b) ((row == the_dialog->m_current_row && column == the_dialog->m_current_column) ? b[1] : b[0])
#define IS_ITV(b) (((row == the_dialog->m_current_row || row == the_dialog->m_current_row - 1) && column == the_dialog->m_current_column) ? b[1] : b[0])
#define IS_ITH(b) ((row == the_dialog->m_current_row && (column == the_dialog->m_current_column || column == the_dialog->m_current_column - 1)) ? b[1] : b[0])
#define DEFAULT_BACKGROUND 0
#define HORIZ_BACKGROUND 1
#define VERTI_BACKGROUND 2
#define MINI_BACKGROUND 3
#define MINI_BUTTON_AREA_HEIGHT (3 * m_mini_spaces + 2 * m_back_miniimg_height)
#define NOTE_64_BUTTON [0][ 2]
#define NATURAL_BUTTON [0][ 4]
#define SHARP_BUTTON [0][ 5]
#define FLAT_BUTTON [0][ 6]
#define FERMATA_BUTTON [0][ 7]
#define WHOLE_NOTE_BUTTON [0][ 8]
#define HALF_NOTE_BUTTON [0][ 9]
#define QUARTER_NOTE_BUTTON [0][10]
#define NOTE_8_BUTTON [0][11]
#define NOTE_16_BUTTON [0][12]
#define NOTE_32_BUTTON [0][13]
#define TIE_BUTTON [0][14]
#define REST_BUTTON [0][15]
#define DOT_BUTTON [0][16]
#define DFLAT_BUTTON [1][ 4]
#define DSHARP_BUTTON [1][ 5]
#define DDOT_BUTTON [1][ 6]
#define STROKEN_GRACE_BUTTON [1][ 8]
#define GRACE_8_BUTTON [1][ 9]
#define GRACE_16_BUTTON [1][10]
#define SFORZANDO_BUTTON [1][11]
#define STACCATO_BUTTON [1][12]
#define STACCATISSIMO_BUTTON [1][13]
#define SFORZATO_BUTTON [1][15]
#define TENUTO_BUTTON [1][16]
#define TURN_BUTTON [2][ 2]
#define BOW_UP_BUTTON [2][ 4]
#define BOW_DOWN_BUTTON [2][ 5]
#define PED_ON_BUTTON [2][ 6]
#define PED_OFF_BUTTON [2][ 8]
#define TRILL_BUTTON [2][ 9]
#define PRALL_BUTTON [2][10]
#define OPEN_BUTTON [2][11]
#define MORDENT_BUTTON [2][12]
#define ARPEGGIO_BUTTON [2][13]
#define REV_TURN_BUTTON [2][16]
#define O_HIGH_NOTE_BUTTON [3][ 1]
#define C_HIGH_NOTE_BUTTON [3][ 2]
#define NORMAL_NOTE_BUTTON [3][ 4]
#define CROSS_NOTE1_BUTTON [3][ 5]
#define CROSS_NOTE2_BUTTON [3][ 6]
#define RECT_NOTE1_BUTTON [3][ 7]
#define RECT_NOTE2_BUTTON [3][ 8]
#define TRIAG_NOTE1_BUTTON [3][ 9]
#define TRIAG_NOTE2_BUTTON [3][10]
#define CROSS_NOTE3_BUTTON [3][11]
#define CROSS_NOTE4_BUTTON [3][12]
#define TRIAG_NOTE3_BUTTON [3][13]
#define QUAD_NOTE2_BUTTON [3][14]
#define GUIT_STEM_BUTTON [3][15]
#define GUIT_NO_STEM_BUTTON [3][16]
#define TEMOLO1_NOTE_BUTTON [4][ 4]
#define TEMOLO2_NOTE_BUTTON [4][ 5]
#define TEMOLO3_NOTE_BUTTON [4][ 6]
#define TEMOLO4_NOTE_BUTTON [4][ 8]
X11button *NedTools::m_button_arrays[NUM_PANELS][17];
X11button *NedTools::m_mini_button_arrays[8];
X11buttonGroup NedTools::m_accidentals(true), NedTools::m_note_length_group(false), NedTools::m_note_head_group(false), NedTools::m_dot_group(true), NedTools::m_tremolo_group(true);
static GdkPixbuf *nullbuf = NULL;
NedTools::button_descr NedTools::m_mini_button_descriptions[8] = {
{&NedResource::m_quarternote_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL},
{&NedResource::m_cross_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL},
{&NedResource::m_bow_down_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL},
{&NedResource::m_drum7_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL},
{&NedResource::m_tremolo_icon2, PUSH_BUTTON, SCOPE_NONE, false, NULL},
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL},
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL},
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL}
};
NedTools::button_descr NedTools::m_button_descriptions[NUM_PANELS][17] = {
{
{ &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, { &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_64thnote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group}, {&NedResource::m_arrow_right_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_natural_icon, TOGGLE_BUTTON, SCOPE_NOTE_STATE, false, &m_accidentals}, {&NedResource::m_cross_icon, TOGGLE_BUTTON, SCOPE_NOTE_STATE, false, &m_accidentals},
{&NedResource::m_flat_icon, TOGGLE_BUTTON, SCOPE_NOTE_STATE, false, &m_accidentals}, {&NedResource::m_fermata_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_fullnote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group}, {&NedResource::m_halfnote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group},
{&NedResource::m_quarternote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, true, &m_note_length_group},
{&NedResource::m_eightnote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group}, {&NedResource::m_sixteenthnote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group},
{&NedResource::m_32ndnote_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group}, {&NedResource::m_tied_icon, TOGGLE_BUTTON, SCOPE_TIES,false, NULL},
{&NedResource::m_rest_icon, TOGGLE_BUTTON, SCOPE_NONE, false, NULL}, {&NedResource::m_dot_icon, TOGGLE_BUTTON, SCOPE_DOTS, false, &m_dot_group}
},
{
{ &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, {&NedResource::m_arrow_left_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{ &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, { &NedResource::m_arrow_right_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_dflat_icon, TOGGLE_BUTTON, SCOPE_NOTE_STATE, false, &m_accidentals}, {&NedResource::m_dcross_icon, TOGGLE_BUTTON, SCOPE_NOTE_STATE, false, &m_accidentals},
{&NedResource::m_ddot_icon, TOGGLE_BUTTON, SCOPE_DOTS, false, &m_dot_group}, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL},
{&NedResource::m_stroken_grace_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group}, {&NedResource::m_grace_eighth_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group},
{&NedResource::m_grace_sixth_icon, TOGGLE_BUTTON, SCOPE_NOTE_LENGTH, false, &m_note_length_group},
{ &NedResource::m_sforzando_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL }, {&NedResource::m_stacc_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_staccatissimo_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&nullbuf, EMPTY_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_sforzato_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&NedResource::m_tenuto_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}
},
{
{ &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, {&NedResource::m_arrow_left_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{ &NedResource::m_turn_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL }, { &NedResource::m_arrow_right_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_bow_up_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&NedResource::m_bow_down_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_ped_on_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL},
{&NedResource::m_ped_off_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&NedResource::m_trill_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_prall_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_open_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&NedResource::m_mordent_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL},
{&NedResource::m_arpeggio_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL},
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL}, {&NedResource::m_revturn_icon, TOGGLE_BUTTON, SCOPE_STATE, false, NULL}
},
{
{&NedResource::m_arrow_left_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL }, { &NedResource::m_drum11_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{ &NedResource::m_drum12_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group }, { &NedResource::m_arrow_right_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_normal_note_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, true, &m_note_head_group}, {&NedResource::m_drum1_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{&NedResource::m_drum2_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group}, {&NedResource::m_drum3_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{&NedResource::m_drum4_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group}, {&NedResource::m_drum5_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{&NedResource::m_drum6_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{&NedResource::m_drum7_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group}, {&NedResource::m_drum8_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{&NedResource::m_drum9_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group}, {&NedResource::m_drum10_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group},
{&NedResource::m_guitar_note_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group}, {&NedResource::m_guitar_note_no_stem_icon, TOGGLE_BUTTON, SCOPE_NOTE_HEAD, false, &m_note_head_group}
},
{
{ &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, {&NedResource::m_arrow_left_icon, PUSH_BUTTON, SCOPE_NONE, false, NULL },
{ &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, { &nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_tremolo_icon1, TOGGLE_BUTTON, SCOPE_STATE, false, &m_tremolo_group}, {&NedResource::m_tremolo_icon2, TOGGLE_BUTTON, SCOPE_STATE, false, &m_tremolo_group},
{&NedResource::m_tremolo_icon3, TOGGLE_BUTTON, SCOPE_STATE, false, &m_tremolo_group}, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&NedResource::m_tremolo_icon4, TOGGLE_BUTTON, SCOPE_STATE, false, &m_tremolo_group}, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL },
{&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }, {&nullbuf, EMPTY_BUTTON, SCOPE_NONE, false, NULL }
}
};
int NedTools::m_back_img_width, NedTools::m_back_img_height;
int NedTools::m_back_miniimg_width, NedTools::m_back_miniimg_height;
int NedTools::m_mini_spaces;
X11button::X11button(Display *dpy, Window win, GC xgc, int screen, XImage *img[2], int xpos, int ypos, int width, int height, int column, int row, int panel, int type, int scope, bool enabled, bool default_state) :
m_button_group(NULL), m_active(default_state), m_type(type), m_row(row), m_column(column), m_panel(panel), m_dpy(dpy), m_win(win), m_xgc(xgc), m_screen(screen),
m_enabled(enabled), m_default_state(default_state), m_scope(scope), m_xpos(xpos), m_ypos(ypos), m_width(width), m_height(height) {
m_img[0] = img[0];
m_img[1] = img[1];
}
X11button::~X11button() {
XDestroyImage(m_img[0]);
XDestroyImage(m_img[1]);
m_img[0] = NULL;
m_img[1] = NULL;
}
void X11button::draw() {
XPutImage(m_dpy, m_win, m_xgc, m_img[m_active ? 1 : 0], 0, 0, m_xpos, m_ypos, m_width, m_height);
}
void X11button::notifyMainWindow(NedMainWindow *current_main_window) {
switch (m_scope) {
case SCOPE_NOTE_LENGTH: current_main_window->changeLength(); break;
case SCOPE_STATE: current_main_window->changeState(); break;
case SCOPE_NOTE_STATE: current_main_window->changeNoteState(); break;
case SCOPE_NOTE_HEAD: current_main_window->changeNoteHead(); break;
case SCOPE_DOTS: current_main_window->changeDots(); break;
case SCOPE_TIES: current_main_window->changeTieState(); break;
}
}
bool X11button::handle_click(gdouble xd, gdouble yd) {
NedMainWindow *current_main_window;
if (!m_enabled) return false;
int x = (int) (xd + 0.5);
int y = (int) (yd + 0.5);
if (x < m_xpos) return false;
if (x > m_xpos + m_width) return false;
if (y < m_ypos) return false;
if (y > m_ypos + m_height) return false;
if (m_active && m_button_group) {
if (!m_button_group->allowStateChange(this)) return false;
}
m_active = !m_active;
if (m_button_group) {
m_button_group->stateChanged(this);
}
current_main_window = NedResource::getMainwWindowWithLastFocus();
if (current_main_window != NULL) {
notifyMainWindow(current_main_window);
}
return m_active;
}
void X11button::toggle() {
NedMainWindow *current_main_window;
if (!m_enabled) return;
if (m_type != TOGGLE_BUTTON) return;
if (m_active && m_button_group) {
if (!m_button_group->allowStateChange(this)) return;
}
m_active = !m_active;
if (m_button_group) {
m_button_group->stateChanged(this);
}
current_main_window = NedResource::getMainwWindowWithLastFocus();
if (current_main_window != NULL) {
notifyMainWindow(current_main_window);
}
}
bool X11button::handle_release(gdouble xd, gdouble yd) {
if (m_type != PUSH_BUTTON) return false;
if (!m_enabled) return false;
int x = (int) (xd + 0.5);
int y = (int) (yd + 0.5);
if (x < m_xpos) return false;
if (x > m_xpos + m_width) return false;
if (y < m_ypos) return false;
if (y > m_ypos + m_height) return false;
m_active = false;
return true;
}
X11buttonGroup::X11buttonGroup(bool all_inactive_allowed) : m_buttons(NULL), m_all_inactive_allowed(all_inactive_allowed) {}
void X11buttonGroup::removeAllButtons() {
if (m_buttons != NULL) {
/*
while ((lptr = g_list_first(m_buttons)) != NULL) {
delete (X11button *) lptr->data;
}
*/
g_list_free(m_buttons);
m_buttons = NULL;
}
}
void X11buttonGroup::addX11button(X11button *button) {
if (button->m_button_group != NULL) {
NedResource::Abort("X11buttonGroup::addX11button(1)");
}
if (g_list_find(m_buttons, button) != NULL) {
NedResource::Abort("X11buttonGroup::addX11button(2)");
}
m_buttons = g_list_append(m_buttons, button);
button->m_button_group = this;
}
void X11buttonGroup::removeX11button(X11button *button) {
GList *lptr;
if (button->m_button_group == NULL) {
NedResource::Abort("X11buttonGroup::removeX11button(1)");
}
if (button->m_button_group != this) {
NedResource::Abort("X11buttonGroup::removeX11button(2)");
}
if ((lptr = g_list_find(m_buttons, button)) == NULL) {
NedResource::Abort("X11buttonGroup::removeX11button(3)");
}
m_buttons = g_list_delete_link(m_buttons, lptr);
button->m_button_group = NULL;
}
bool X11buttonGroup::allowStateChange(X11button *button) {
GList *lptr;
int c = 0;
bool isAmongActives = false;
if (m_all_inactive_allowed) return true;
for (lptr = g_list_first(m_buttons); lptr; lptr = g_list_next(lptr)) {
if (!((X11button *) lptr->data)->m_active) continue;
c++;
if ((X11button *) lptr->data == button) isAmongActives = true;
}
if (c > 1) return true;
return false;
}
void X11buttonGroup::stateChanged(X11button *button) {
GList *lptr;
if (!button->m_active) return;
if (button->m_type == PUSH_BUTTON) return;
for (lptr = g_list_first(m_buttons); lptr; lptr = g_list_next(lptr)) {
if ((X11button *) lptr->data == button) continue;
((X11button *) lptr->data)->m_active = false;
}
}
void X11buttonGroup::resetAllButtons() {
GList *lptr;
for (lptr = g_list_first(m_buttons); lptr; lptr = g_list_next(lptr)) {
((X11button *) lptr->data)->m_active = false;
}
}
#define CREATE_X11(pixmap, back, up) createX11PixmapFromGdkPixbuffer(dpy, screen, d, ggc, gdk_pixbuf_scale_simple(pixmap, X11_ICONS_DIM, X11_ICONS_DIM, GDK_INTERP_HYPER), back, up);
#define CREATE_MINI_X11(pixmap, back, up) createX11PixmapFromGdkPixbuffer(dpy, screen, d, ggc, gdk_pixbuf_scale_simple(pixmap, X11_MINI_ICONS_DIM, X11_MINI_ICONS_DIM, GDK_INTERP_HYPER), back, up);
#define CREATE_X11_EMPTY(back, up) createX11PixmapFromGdkPixbuffer(dpy, screen, d, ggc, NULL, back, up);
#define CREATE_MINI_X11_EMPTY(back, up) createX11PixmapFromGdkPixbuffer(dpy, screen, d, ggc, NULL, back, up);
NedTools::NedTools() :
m_back_pix(NULL), m_current_row(-1), m_current_column(-1), m_current_panel(0), m_buttons_created(false), m_dpy(NULL)
{
GdkColor bgcolor;
int wx, wy;
NedMainWindow *last_main;
GdkDisplay *display = NULL;
GdkScreen *screen = NULL;
m_toolbox = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (m_toolbox), _("Toolbox"));
g_signal_connect (m_toolbox, "delete-event", G_CALLBACK (close_toolbox), this);
g_signal_connect(m_toolbox, "delete-event", G_CALLBACK (OnDelete), (void *) this);
g_signal_connect (m_toolbox, "key-press-event", G_CALLBACK (key_press_handler), (void *) this);
m_back_img_width = gdk_pixbuf_get_width(NedResource::m_background1);
m_back_img_height = gdk_pixbuf_get_height(NedResource::m_background1);
m_back_miniimg_width = gdk_pixbuf_get_width(NedResource::m_mini_background1);
m_back_miniimg_height = gdk_pixbuf_get_height(NedResource::m_mini_background1);
m_mini_spaces = (4 * m_back_img_width - 4 * m_back_miniimg_width) / 5;
if ((last_main = NedResource::getMainwWindowWithLastFocus()) != NULL) {
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
gdk_window_get_root_origin(GDK_WINDOW(last_main->getWindow()->window), &wx, &wy);
gtk_window_move(GTK_WINDOW (m_toolbox), wx + NedResource::m_toolboxX, wy + NedResource::m_toolboxY);
}
m_button_frame = gtk_frame_new(_("Toolbox"));
m_button_area = gtk_drawing_area_new ();
bgcolor.pixel = 1;
bgcolor.red = 0x0000; bgcolor.green = 0x5555; bgcolor.blue = 0xcccc;
gtk_widget_modify_bg(GTK_WIDGET(m_button_area), GTK_STATE_NORMAL, &bgcolor);
gtk_widget_set_double_buffered(m_button_area, FALSE);
gtk_drawing_area_size(GTK_DRAWING_AREA(m_button_area), 4 * m_back_img_width, MINI_BUTTON_AREA_HEIGHT + 5 * m_back_img_height);
gtk_container_add (GTK_CONTAINER(m_button_frame), m_button_area);
g_signal_connect (m_button_area, "expose-event", G_CALLBACK (draw_menu), (void *) this);
gtk_widget_add_events(m_button_area, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK);
g_signal_connect (m_button_area, "button-press-event", G_CALLBACK (OnButtonPress), (void *) this);
g_signal_connect (m_button_area, "button-release-event", G_CALLBACK (OnButtonRelease), (void *) this);
gtk_container_add (GTK_CONTAINER (m_toolbox), m_button_frame);
gtk_window_set_resizable (GTK_WINDOW(m_toolbox), FALSE);
gtk_widget_show_all (m_toolbox);
}
NedTools::~NedTools() {
int panel;
int bu_nr;
for (panel = 0; panel < NUM_PANELS; panel++) {
for (bu_nr = 0; bu_nr < 4; bu_nr++) {
delete m_button_arrays[panel][bu_nr];
m_button_arrays[panel][bu_nr] = NULL;
}
}
m_accidentals.removeAllButtons();
m_note_length_group.removeAllButtons();
m_note_head_group.removeAllButtons();
m_dot_group.removeAllButtons();
m_tremolo_group.removeAllButtons();
}
void NedTools::updatePosition() {
NedMainWindow *last_main;
int wx, wy, tx, ty;
if ((last_main = NedResource::getMainwWindowWithLastFocus()) != NULL) {
gdk_window_get_root_origin(GDK_WINDOW(last_main->getWindow()->window), &wx, &wy);
gdk_window_get_root_origin(GDK_WINDOW(m_toolbox->window), &tx, &ty);
NedResource::m_toolboxX = tx - wx;
NedResource::m_toolboxY = ty - wy;
}
}
bool NedTools::close_toolbox(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedTools *tools = (NedTools *) data;
tools->updatePosition();
return FALSE;
}
void NedTools::Show() {
gtk_widget_show_all (m_toolbox);
}
void NedTools::setToolboxTransient(NedMainWindow *m_win) {
int wx, wy;
GdkDisplay *display = NULL;
GdkScreen *screen = NULL;
gtk_window_set_transient_for(GTK_WINDOW (m_toolbox), (GTK_WINDOW (m_win->getWindow())));
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
gdk_window_get_root_origin(GDK_WINDOW(m_win->getWindow()->window), &wx, &wy);
gtk_window_move(GTK_WINDOW (m_toolbox), wx + NedResource::m_toolboxX, wy + NedResource::m_toolboxY);
}
unsigned int NedTools::getCurrentLength() {
if (m_button_arrays[0][0] == NULL) return NOTE_4;
if (m_button_arrays WHOLE_NOTE_BUTTON ->m_active) return WHOLE_NOTE;
if (m_button_arrays HALF_NOTE_BUTTON ->m_active) return NOTE_2;
if (m_button_arrays QUARTER_NOTE_BUTTON ->m_active) return NOTE_4;
if (m_button_arrays NOTE_8_BUTTON ->m_active) return NOTE_8;
if (m_button_arrays NOTE_16_BUTTON ->m_active) return NOTE_16;
if (m_button_arrays NOTE_32_BUTTON ->m_active) return NOTE_32;
if (m_button_arrays NOTE_64_BUTTON ->m_active) return NOTE_64;
if (m_button_arrays STROKEN_GRACE_BUTTON ->m_active) return STROKEN_GRACE;
if (m_button_arrays GRACE_8_BUTTON ->m_active) return GRACE_8;
if (m_button_arrays GRACE_16_BUTTON ->m_active) return GRACE_16;
return NOTE_4;
}
int NedTools::getCurrentNoteHead() {
if (m_button_arrays[0][0] == NULL) return NORMAL_NOTE;
if (m_button_arrays O_HIGH_NOTE_BUTTON ->m_active) return OPEN_HIGH_HAT;
if (m_button_arrays C_HIGH_NOTE_BUTTON ->m_active) return CLOSED_HIGH_HAT;
if (m_button_arrays NORMAL_NOTE_BUTTON ->m_active) return NORMAL_NOTE;
if (m_button_arrays CROSS_NOTE1_BUTTON ->m_active) return CROSS_NOTE1;
if (m_button_arrays CROSS_NOTE2_BUTTON ->m_active) return CROSS_NOTE2;
if (m_button_arrays RECT_NOTE1_BUTTON ->m_active) return RECT_NOTE1;
if (m_button_arrays RECT_NOTE2_BUTTON ->m_active) return RECT_NOTE2;
if (m_button_arrays TRIAG_NOTE1_BUTTON ->m_active) return TRIAG_NOTE1;
if (m_button_arrays TRIAG_NOTE2_BUTTON ->m_active) return TRIAG_NOTE2;
if (m_button_arrays CROSS_NOTE3_BUTTON ->m_active) return CROSS_NOTE3;
if (m_button_arrays CROSS_NOTE4_BUTTON ->m_active) return CROSS_NOTE4;
if (m_button_arrays TRIAG_NOTE3_BUTTON ->m_active) return TRIAG_NOTE3;
if (m_button_arrays QUAD_NOTE2_BUTTON ->m_active) return QUAD_NOTE2;
if (m_button_arrays GUIT_STEM_BUTTON ->m_active) return GUITAR_NOTE_STEM;
if (m_button_arrays GUIT_NO_STEM_BUTTON ->m_active) return GUITAR_NOTE_NO_STEM;
return NORMAL_NOTE;
}
unsigned int NedTools::getStatus() {
unsigned int status = 0;
if (m_button_arrays[0][0] == NULL) return 0;
if (m_button_arrays NATURAL_BUTTON ->m_active) status |= STAT_NATURAL;
if (m_button_arrays SHARP_BUTTON ->m_active) status |= STAT_SHARP;
if (m_button_arrays FLAT_BUTTON ->m_active) status |= STAT_FLAT;
if (m_button_arrays FERMATA_BUTTON ->m_active) status |= STAT_FERMATA;
if (m_button_arrays SFORZANDO_BUTTON ->m_active) status |= STAT_SFORZANDO;
if (m_button_arrays DFLAT_BUTTON ->m_active) status |= STAT_DFLAT;
if (m_button_arrays DSHARP_BUTTON ->m_active) status |= STAT_DSHARP;
if (m_button_arrays STACCATO_BUTTON ->m_active) status |= STAT_STACC;
if (m_button_arrays STACCATISSIMO_BUTTON ->m_active) status |= STAT_STACCATISSIMO;
if (m_button_arrays SFORZATO_BUTTON ->m_active) status |= STAT_SFORZATO;
if (m_button_arrays TENUTO_BUTTON ->m_active) status |= STAT_TENUTO;
if (m_button_arrays TURN_BUTTON ->m_active) status |= STAT_TURN;
if (m_button_arrays BOW_UP_BUTTON ->m_active) status |= STAT_BOW_UP;
if (m_button_arrays BOW_DOWN_BUTTON ->m_active) status |= STAT_BOW_DOWN;
if (m_button_arrays PED_ON_BUTTON ->m_active) status |= STAT_PED_ON;
if (m_button_arrays PED_OFF_BUTTON ->m_active) status |= STAT_PED_OFF;
if (m_button_arrays TRILL_BUTTON ->m_active) status |= STAT_TRILL;
if (m_button_arrays PRALL_BUTTON ->m_active) status |= STAT_PRALL;
if (m_button_arrays OPEN_BUTTON ->m_active) status |= STAT_OPEN;
if (m_button_arrays MORDENT_BUTTON ->m_active) status |= STAT_MORDENT;
if (m_button_arrays ARPEGGIO_BUTTON ->m_active) status |= STAT_ARPEGGIO;
if (m_button_arrays REV_TURN_BUTTON ->m_active) status |= STAT_REV_TURN;
if (m_button_arrays TEMOLO1_NOTE_BUTTON ->m_active) status |= STAT_TREMOLO1;
if (m_button_arrays TEMOLO2_NOTE_BUTTON ->m_active) status |= STAT_TREMOLO2;
if (m_button_arrays TEMOLO3_NOTE_BUTTON ->m_active) status |= STAT_TREMOLO3;
if (m_button_arrays TEMOLO4_NOTE_BUTTON ->m_active) status |= STAT_TREMOLO4;
return status;
}
bool NedTools::getRestMode() {
if (m_button_arrays[0][0] == NULL) return false;
return m_button_arrays REST_BUTTON ->m_active;
}
int NedTools::getDotCount() {
if (m_button_arrays[0][0] == NULL) return 0;
if (m_button_arrays DOT_BUTTON ->m_active) return 1;
if (m_button_arrays DDOT_BUTTON ->m_active) return 2;
return 0;
}
bool NedTools::getTiedMode() {
if (m_button_arrays[0][0] == NULL) return 0;
bool ret;
ret = m_button_arrays TIE_BUTTON ->m_active;
return ret;
}
void NedTools::setButtons(unsigned int length, int dotcount, unsigned int chord_status, unsigned int note_status, bool isRest, bool tie_forward, int note_head) {
int p, i;
if (m_button_arrays[0][0] == NULL) return;
for (p = 0; p < NUM_PANELS; p++) {
for (i = 0; i < 17; i++) {
m_button_arrays[p][i]->m_active = false;
}
}
m_button_arrays REST_BUTTON ->m_active = isRest;
switch (dotcount) {
case 2: m_button_arrays DDOT_BUTTON ->m_active = true; break;
case 1: m_button_arrays DOT_BUTTON ->m_active = true; break;
}
if (!isRest) {
switch (note_status & ACCIDENTAL_MASK) {
case STAT_NATURAL: m_button_arrays NATURAL_BUTTON ->m_active = true; break;
case STAT_DFLAT: m_button_arrays DFLAT_BUTTON ->m_active = true; break;
case STAT_FLAT: m_button_arrays FLAT_BUTTON ->m_active = true; break;
case STAT_SHARP: m_button_arrays SHARP_BUTTON ->m_active = true; break;
case STAT_DSHARP: m_button_arrays DSHARP_BUTTON ->m_active = true; break;
}
}
if (chord_status & STAT_FERMATA) m_button_arrays FERMATA_BUTTON ->m_active = true;
if (chord_status & STAT_SFORZANDO) m_button_arrays SFORZANDO_BUTTON ->m_active = true;
if (chord_status & STAT_STACC) m_button_arrays STACCATO_BUTTON ->m_active = true;
if (chord_status & STAT_STACCATISSIMO) m_button_arrays STACCATISSIMO_BUTTON ->m_active = true;
if (chord_status & STAT_SFORZATO) m_button_arrays SFORZATO_BUTTON ->m_active = true;
if (chord_status & STAT_TENUTO) m_button_arrays TENUTO_BUTTON ->m_active = true;
if (chord_status & STAT_TURN) m_button_arrays TURN_BUTTON ->m_active = true;
if (chord_status & STAT_BOW_UP) m_button_arrays BOW_UP_BUTTON ->m_active = true;
if (chord_status & STAT_BOW_DOWN) m_button_arrays BOW_DOWN_BUTTON ->m_active = true;
if (chord_status & STAT_PED_ON) m_button_arrays PED_ON_BUTTON ->m_active = true;
if (chord_status & STAT_PED_OFF) m_button_arrays PED_OFF_BUTTON ->m_active = true;
if (chord_status & STAT_TRILL) m_button_arrays TRILL_BUTTON ->m_active = true;
if (chord_status & STAT_PRALL) m_button_arrays PRALL_BUTTON ->m_active = true;
if (chord_status & STAT_OPEN) m_button_arrays OPEN_BUTTON ->m_active = true;
if (chord_status & STAT_MORDENT) m_button_arrays MORDENT_BUTTON ->m_active = true;
if (chord_status & STAT_ARPEGGIO) m_button_arrays ARPEGGIO_BUTTON ->m_active = true;
if (chord_status & STAT_REV_TURN) m_button_arrays REV_TURN_BUTTON ->m_active = true;
if ((chord_status & TREMOLO_MASK) == STAT_TREMOLO1) m_button_arrays TEMOLO1_NOTE_BUTTON ->m_active = true;
if ((chord_status & TREMOLO_MASK) == STAT_TREMOLO2) m_button_arrays TEMOLO2_NOTE_BUTTON ->m_active = true;
if ((chord_status & TREMOLO_MASK) == STAT_TREMOLO3) m_button_arrays TEMOLO3_NOTE_BUTTON ->m_active = true;
if ((chord_status & TREMOLO_MASK) == STAT_TREMOLO4) m_button_arrays TEMOLO4_NOTE_BUTTON ->m_active = true;
if (length == WHOLE_NOTE) m_button_arrays WHOLE_NOTE_BUTTON ->m_active = true;
else if (length == NOTE_2) m_button_arrays HALF_NOTE_BUTTON ->m_active = true;
else if (length == NOTE_4) m_button_arrays QUARTER_NOTE_BUTTON ->m_active = true;
else if (length == NOTE_8) m_button_arrays NOTE_8_BUTTON ->m_active = true;
else if (length == NOTE_16) m_button_arrays NOTE_16_BUTTON ->m_active = true;
else if (length == NOTE_32) m_button_arrays NOTE_32_BUTTON ->m_active = true;
else if (length == NOTE_64) m_button_arrays NOTE_64_BUTTON ->m_active = true;
else if (length == STROKEN_GRACE) m_button_arrays STROKEN_GRACE_BUTTON ->m_active = true;
else if (length == GRACE_8) m_button_arrays GRACE_8_BUTTON ->m_active = true;
else if (length == GRACE_16) m_button_arrays GRACE_16_BUTTON ->m_active = true;
else m_button_arrays QUARTER_NOTE_BUTTON ->m_active = true;
if (note_head == NORMAL_NOTE) m_button_arrays NORMAL_NOTE_BUTTON ->m_active = true;
else if (note_head == OPEN_HIGH_HAT) m_button_arrays O_HIGH_NOTE_BUTTON ->m_active = true;
else if (note_head == CLOSED_HIGH_HAT) m_button_arrays C_HIGH_NOTE_BUTTON ->m_active = true;
else if (note_head == CROSS_NOTE1) m_button_arrays CROSS_NOTE1_BUTTON ->m_active = true;
else if (note_head == CROSS_NOTE2) m_button_arrays CROSS_NOTE2_BUTTON ->m_active = true;
else if (note_head == RECT_NOTE1) m_button_arrays RECT_NOTE1_BUTTON ->m_active = true;
else if (note_head == RECT_NOTE2) m_button_arrays RECT_NOTE2_BUTTON ->m_active = true;
else if (note_head == TRIAG_NOTE1) m_button_arrays TRIAG_NOTE1_BUTTON ->m_active = true;
else if (note_head == TRIAG_NOTE2) m_button_arrays TRIAG_NOTE2_BUTTON ->m_active = true;
else if (note_head == CROSS_NOTE3) m_button_arrays CROSS_NOTE3_BUTTON ->m_active = true;
else if (note_head == CROSS_NOTE4) m_button_arrays CROSS_NOTE4_BUTTON ->m_active = true;
else if (note_head == TRIAG_NOTE3) m_button_arrays TRIAG_NOTE3_BUTTON ->m_active = true;
else if (note_head == QUAD_NOTE2) m_button_arrays QUAD_NOTE2_BUTTON ->m_active = true;
else if (note_head == GUITAR_NOTE_STEM) m_button_arrays GUIT_STEM_BUTTON ->m_active = true;
else if (note_head == GUITAR_NOTE_NO_STEM) m_button_arrays GUIT_NO_STEM_BUTTON ->m_active = true;
else m_button_arrays NORMAL_NOTE_BUTTON ->m_active = true;
m_button_arrays TIE_BUTTON ->m_active = tie_forward;
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::setNoteLengthButtons(unsigned int length) {
if (m_button_arrays[0][0] == NULL) return;
m_button_arrays WHOLE_NOTE_BUTTON ->m_active = false;
m_button_arrays HALF_NOTE_BUTTON ->m_active = false;
m_button_arrays QUARTER_NOTE_BUTTON ->m_active = false;
m_button_arrays NOTE_8_BUTTON ->m_active = false;
m_button_arrays NOTE_16_BUTTON ->m_active = false;
m_button_arrays NOTE_32_BUTTON ->m_active = false;
m_button_arrays NOTE_64_BUTTON ->m_active = false;
m_button_arrays STROKEN_GRACE_BUTTON ->m_active = false;
m_button_arrays GRACE_8_BUTTON ->m_active = false;
m_button_arrays GRACE_16_BUTTON ->m_active = false;
if (length == WHOLE_NOTE) m_button_arrays WHOLE_NOTE_BUTTON ->m_active = true;
else if (length == NOTE_2) m_button_arrays HALF_NOTE_BUTTON ->m_active = true;
else if (length == NOTE_4) m_button_arrays QUARTER_NOTE_BUTTON ->m_active = true;
else if (length == NOTE_8) m_button_arrays NOTE_8_BUTTON ->m_active = true;
else if (length == NOTE_16) m_button_arrays NOTE_16_BUTTON ->m_active = true;
else if (length == NOTE_32) m_button_arrays NOTE_32_BUTTON ->m_active = true;
else if (length == NOTE_64) m_button_arrays NOTE_64_BUTTON ->m_active = true;
else m_button_arrays QUARTER_NOTE_BUTTON ->m_active = true;
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::resetSomeButtons() {
if (m_button_arrays[0][0] == NULL) return;
m_button_arrays NATURAL_BUTTON ->m_active = false;
m_button_arrays DFLAT_BUTTON ->m_active = false;
m_button_arrays FLAT_BUTTON ->m_active = false;
m_button_arrays SHARP_BUTTON ->m_active = false;
m_button_arrays REST_BUTTON ->m_active = false;
m_button_arrays DSHARP_BUTTON ->m_active = false;
m_button_arrays DDOT_BUTTON ->m_active = false;
m_button_arrays DOT_BUTTON ->m_active = false;
m_button_arrays TIE_BUTTON ->m_active = false;
m_button_arrays FERMATA_BUTTON ->m_active = false;
m_button_arrays STACCATO_BUTTON ->m_active = false;
m_button_arrays STACCATISSIMO_BUTTON ->m_active = false;
m_button_arrays SFORZATO_BUTTON ->m_active = false;
m_button_arrays SFORZANDO_BUTTON ->m_active = false;
m_button_arrays TENUTO_BUTTON ->m_active = false;
m_button_arrays TURN_BUTTON ->m_active = false;
m_button_arrays BOW_UP_BUTTON ->m_active = false;
m_button_arrays BOW_DOWN_BUTTON ->m_active = false;
m_button_arrays PED_ON_BUTTON ->m_active = false;
m_button_arrays PED_OFF_BUTTON ->m_active = false;
m_button_arrays TRILL_BUTTON ->m_active = false;
m_button_arrays PRALL_BUTTON ->m_active = false;
m_button_arrays OPEN_BUTTON ->m_active = false;
m_button_arrays MORDENT_BUTTON ->m_active = false;
m_button_arrays ARPEGGIO_BUTTON ->m_active = false;
m_button_arrays REV_TURN_BUTTON ->m_active = false;
m_button_arrays TEMOLO1_NOTE_BUTTON ->m_active = false;
m_button_arrays TEMOLO2_NOTE_BUTTON ->m_active = false;
m_button_arrays TEMOLO3_NOTE_BUTTON ->m_active = false;
m_button_arrays TEMOLO4_NOTE_BUTTON ->m_active = false;
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::resetTieButton() {
if (m_button_arrays[0][0] == NULL) return;
m_button_arrays TIE_BUTTON ->m_active = false;
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::resetButtons() {
int p, i;
if (m_button_arrays[0][0] == NULL) return;
for (p = 0; p < NUM_PANELS; p++) {
for (i = 0; i < 17; i++) {
m_button_arrays[p][i]->m_active = m_button_descriptions[p][i].m_default_state;
}
}
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleButton(int nr) {
m_button_arrays[m_current_panel][nr]->toggle();
testForPanelChange(m_button_arrays[m_current_panel][nr]);
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleRest() {
m_button_arrays REST_BUTTON ->m_active = !(m_button_arrays REST_BUTTON ->m_active);
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleTie() {
m_button_arrays TIE_BUTTON ->m_active = !(m_button_arrays TIE_BUTTON ->m_active);
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleDot() {
m_button_arrays DOT_BUTTON ->m_active = !(m_button_arrays DOT_BUTTON ->m_active);
if (m_button_arrays DOT_BUTTON ->m_active) m_button_arrays DDOT_BUTTON ->m_active = false;
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleSharp() {
m_button_arrays SHARP_BUTTON ->m_active = !(m_button_arrays SHARP_BUTTON ->m_active);
if (m_button_arrays SHARP_BUTTON ->m_active) {
m_button_arrays FLAT_BUTTON ->m_active = false;
m_button_arrays NATURAL_BUTTON ->m_active = false;
m_button_arrays DSHARP_BUTTON ->m_active = false;
m_button_arrays DFLAT_BUTTON ->m_active = false;
}
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleNatural() {
m_button_arrays NATURAL_BUTTON ->m_active = !(m_button_arrays NATURAL_BUTTON ->m_active);
if (m_button_arrays NATURAL_BUTTON ->m_active) {
m_button_arrays FLAT_BUTTON ->m_active = false;
m_button_arrays SHARP_BUTTON ->m_active = false;
m_button_arrays DSHARP_BUTTON ->m_active = false;
m_button_arrays DFLAT_BUTTON ->m_active = false;
}
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
void NedTools::toggleFlat() {
m_button_arrays FLAT_BUTTON ->m_active = !(m_button_arrays FLAT_BUTTON ->m_active);
if (m_button_arrays FLAT_BUTTON ->m_active) {
m_button_arrays SHARP_BUTTON ->m_active = false;
m_button_arrays NATURAL_BUTTON ->m_active = false;
m_button_arrays DSHARP_BUTTON ->m_active = false;
m_button_arrays DFLAT_BUTTON ->m_active = false;
}
gdk_window_invalidate_rect(m_button_area->window, NULL, FALSE);
}
gboolean NedTools::OnDelete(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedResource::reset_tools();
return FALSE;
}
void NedTools::getValues(bool *state) {
*state = m_state;
}
gboolean NedTools::key_press_handler(GtkWidget *widget, GdkEventKey *event, gpointer data) {
NedTools *the_dialog = (NedTools *) data;
switch(event->keyval) {
case GDK_KP_Divide: the_dialog->toggleButton(1); break;
case GDK_KP_Multiply: the_dialog->toggleButton(2); break;
case GDK_KP_Subtract: the_dialog->toggleButton(3); break;
case GDK_KP_Home: the_dialog->toggleButton(4); break;
case GDK_KP_Up: the_dialog->toggleButton(5); break;
case GDK_KP_Prior: the_dialog->toggleButton(6); break;
case GDK_KP_Add: the_dialog->toggleButton(7); break;
case GDK_KP_Left: the_dialog->toggleButton(8); break;
case GDK_KP_Begin: the_dialog->toggleButton(9); break;
case GDK_KP_Right: the_dialog->toggleButton(10); break;
case GDK_KP_End: the_dialog->toggleButton(11); break;
case GDK_KP_Down: the_dialog->toggleButton(12); break;
case GDK_KP_Next: the_dialog->toggleButton(13); break;
case GDK_KP_Enter: the_dialog->toggleButton(14); break;
case GDK_KP_Insert: the_dialog->toggleButton(15); break;
case GDK_KP_Delete: the_dialog->toggleButton(16); break;
}
return FALSE;
}
void NedTools::determine_image_and_dimensions(Display *dpy, Window win, GdkGC *ggc, GdkDrawable *d, int screen, int panel, int row, int column, int bu_nr, GdkPixbuf *buf, XImage *img[2], int *w, int *h) {
if (row > 0 && column == 3) {
*w = m_back_img_width; *h = 2 * m_back_img_height;
}
else if (row == 4 && column == 0) {
*w = 2 * m_back_img_width; *h = m_back_img_height;
}
else {
*w = m_back_img_width; *h = m_back_img_height;
}
switch (m_button_descriptions[panel][bu_nr].m_type) {
case EMPTY_BUTTON:
if (row > 0 && column == 3) {
img[0] = CREATE_X11_EMPTY(VERTI_BACKGROUND, false);
img[1] = CREATE_X11_EMPTY(VERTI_BACKGROUND, true);
}
else if (row == 4 && column == 0) {
img[0] = CREATE_X11_EMPTY(HORIZ_BACKGROUND, false);
img[1] = CREATE_X11_EMPTY(HORIZ_BACKGROUND, true);
}
else {
img[0] = CREATE_X11_EMPTY(DEFAULT_BACKGROUND, false);
img[1] = CREATE_X11_EMPTY(DEFAULT_BACKGROUND, true);
}
break;
default:
if (row > 0 && column == 3) {
img[0] = CREATE_X11(buf, VERTI_BACKGROUND, false);
img[1] = CREATE_X11(buf, VERTI_BACKGROUND, true);
}
else if (row == 4 && column == 0) {
img[0] = CREATE_X11(buf, HORIZ_BACKGROUND, false);
img[1] = CREATE_X11(buf, HORIZ_BACKGROUND, true);
}
else {
img[0] = CREATE_X11(buf, DEFAULT_BACKGROUND, false);
img[1] = CREATE_X11(buf, DEFAULT_BACKGROUND, true);
}
break;
}
}
void NedTools::determine_mini_image_and_dimensions(Display *dpy, Window win, GdkGC *ggc, GdkDrawable *d, int screen, GdkPixbuf *buf, XImage *img[2], int type, int *w, int *h) {
*w = m_back_miniimg_width; *h = m_back_miniimg_height;
if (type == EMPTY_BUTTON) {
img[0] = CREATE_MINI_X11_EMPTY(MINI_BACKGROUND, false);
img[1] = CREATE_MINI_X11_EMPTY(MINI_BACKGROUND, true);
}
else {
img[0] = CREATE_MINI_X11(buf, MINI_BACKGROUND, false);
img[1] = CREATE_MINI_X11(buf, MINI_BACKGROUND, true);
}
}
void NedTools::createButtons(Display *dpy, Window win, GC xgc, GdkGC *ggc, GdkDrawable *d, int screen) {
int row, column;
int bu_nr, i;
int w, h;
XImage *img[2];
int panel;
for (panel = 0; panel < NUM_PANELS; panel++) {
row = column = bu_nr = 0;
for (i = 0; i < 4; i++) {
determine_image_and_dimensions(dpy, win, ggc, d, screen, panel, row, column, bu_nr, *(m_button_descriptions[panel][bu_nr].m_pixbuf), img, &w, &h);
m_button_arrays[panel][bu_nr] = new X11button(dpy, win, xgc, screen, img, column * m_back_img_width, MINI_BUTTON_AREA_HEIGHT + row * m_back_img_height,
w, h, column, row, panel, m_button_descriptions[panel][bu_nr].m_type, m_button_descriptions[panel][bu_nr].m_scope, m_button_descriptions[panel][bu_nr].m_type != EMPTY_BUTTON, m_button_descriptions[panel][bu_nr].m_default_state);
if (m_button_descriptions[panel][bu_nr].m_button_group != NULL) {
m_button_descriptions[panel][bu_nr].m_button_group->addX11button(m_button_arrays[panel][bu_nr]);
}
column++;
bu_nr++;
}
row++; column = 0;
for (i = 0; i < 4; i++) {
determine_image_and_dimensions(dpy, win, ggc, d, screen, panel, row, column, bu_nr, *(m_button_descriptions[panel][bu_nr].m_pixbuf), img, &w, &h);
m_button_arrays[panel][bu_nr] = new X11button(dpy, win, xgc, screen, img, column * m_back_img_width, MINI_BUTTON_AREA_HEIGHT + row * m_back_img_height,
w, h, column, row, panel, m_button_descriptions[panel][bu_nr].m_type, m_button_descriptions[panel][bu_nr].m_scope, m_button_descriptions[panel][bu_nr].m_type != EMPTY_BUTTON, m_button_descriptions[panel][bu_nr].m_default_state);
if (m_button_descriptions[panel][bu_nr].m_button_group != NULL) {
m_button_descriptions[panel][bu_nr].m_button_group->addX11button(m_button_arrays[panel][bu_nr]);
}
column++;
bu_nr++;
}
row++; column = 0;
for (i = 0; i < 3; i++) {
determine_image_and_dimensions(dpy, win, ggc, d, screen, panel, row, column, bu_nr, *(m_button_descriptions[panel][bu_nr].m_pixbuf), img, &w, &h);
m_button_arrays[panel][bu_nr] = new X11button(dpy, win, xgc, screen, img, column * m_back_img_width, MINI_BUTTON_AREA_HEIGHT + row * m_back_img_height,
w, h, column, row, panel, m_button_descriptions[panel][bu_nr].m_type, m_button_descriptions[panel][bu_nr].m_scope, m_button_descriptions[panel][bu_nr].m_type != EMPTY_BUTTON, m_button_descriptions[panel][bu_nr].m_default_state);
if (m_button_descriptions[panel][bu_nr].m_button_group != NULL) {
m_button_descriptions[panel][bu_nr].m_button_group->addX11button(m_button_arrays[panel][bu_nr]);
}
column++;
bu_nr++;
}
row++; column = 0;
for (i = 0; i < 4; i++) {
determine_image_and_dimensions(dpy, win, ggc, d, screen, panel, row, column, bu_nr, *(m_button_descriptions[panel][bu_nr].m_pixbuf), img, &w, &h);
m_button_arrays[panel][bu_nr] = new X11button(dpy, win, xgc, screen, img, column * m_back_img_width, MINI_BUTTON_AREA_HEIGHT+ row * m_back_img_height,
w, h, column, row, panel, m_button_descriptions[panel][bu_nr].m_type, m_button_descriptions[panel][bu_nr].m_scope, m_button_descriptions[panel][bu_nr].m_type != EMPTY_BUTTON, m_button_descriptions[panel][bu_nr].m_default_state);
if (m_button_descriptions[panel][bu_nr].m_button_group != NULL) {
m_button_descriptions[panel][bu_nr].m_button_group->addX11button(m_button_arrays[panel][bu_nr]);
}
column++;
bu_nr++;
}
row++; column = 0;
for (i = 0; i < 2; i++) {
determine_image_and_dimensions(dpy, win, ggc, d, screen, panel, row, column, bu_nr, *(m_button_descriptions[panel][bu_nr].m_pixbuf), img, &w, &h);
m_button_arrays[panel][bu_nr] = new X11button(dpy, win, xgc, screen, img, column * m_back_img_width, MINI_BUTTON_AREA_HEIGHT + row * m_back_img_height,
w, h, column, row, panel, m_button_descriptions[panel][bu_nr].m_type, m_button_descriptions[panel][bu_nr].m_scope, m_button_descriptions[panel][bu_nr].m_type != EMPTY_BUTTON, m_button_descriptions[panel][bu_nr].m_default_state);
if (m_button_descriptions[panel][bu_nr].m_button_group != NULL) {
m_button_descriptions[panel][bu_nr].m_button_group->addX11button(m_button_arrays[panel][bu_nr]);
}
column += 2;
bu_nr++;
}
}
}
void NedTools::createMiniButtons(Display *dpy, Window win, GC xgc, GdkGC *ggc, GdkDrawable *d, int screen) {
int column;
int w, h;
XImage *img[2];
for (column = 0; column < 4; column++) {
determine_mini_image_and_dimensions(dpy, win, ggc, d, screen, *(m_mini_button_descriptions[column].m_pixbuf), img, m_mini_button_descriptions[column].m_type, &w, &h);
m_mini_button_arrays[column] = new X11button(dpy, win, xgc, screen, img, m_mini_spaces + column * (m_mini_spaces + m_back_miniimg_width), m_mini_spaces,
w, h, column, 0, 0, m_mini_button_descriptions[column].m_type, SCOPE_NONE, m_mini_button_descriptions[column].m_type != EMPTY_BUTTON,
m_mini_button_descriptions[column].m_default_state);
}
for (column = 4; column < 8; column++) {
determine_mini_image_and_dimensions(dpy, win, ggc, d, screen, *(m_mini_button_descriptions[column].m_pixbuf), img, m_mini_button_descriptions[column].m_type, &w, &h);
m_mini_button_arrays[column] = new X11button(dpy, win, xgc, screen, img, m_mini_spaces + (column - 4) * (m_mini_spaces + m_back_miniimg_width),
m_mini_spaces + 1 * (m_mini_spaces + m_back_miniimg_height),
w, h, column, 0, 0, m_mini_button_descriptions[column].m_type, SCOPE_NONE, m_mini_button_descriptions[column].m_type != EMPTY_BUTTON,
m_mini_button_descriptions[column].m_default_state);
}
}
gboolean NedTools::draw_menu(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
NedTools *the_dialog = (NedTools *) data;
Display *dpy;
Window win;
GC xgc;
GdkColor bgcolor;
int screen;
int bu_nr;
if (m_button_arrays[0][0] == NULL) {
the_dialog->m_back_pix = gdk_pixmap_new(the_dialog->m_button_area->window,
4 * the_dialog->m_back_img_width, MINI_BUTTON_AREA_HEIGHT + 5 * the_dialog->m_back_img_height, -1);
the_dialog->m_copy_gc = gdk_gc_new(the_dialog->m_button_area->window);
the_dialog->m_blue_gc = gdk_gc_new(the_dialog->m_back_pix);
bgcolor.pixel = 1;
bgcolor.red = 0x0000; bgcolor.green = 0x5555; bgcolor.blue = 0xcccc;
gdk_gc_set_rgb_fg_color (the_dialog->m_blue_gc, &bgcolor);
dpy = gdk_x11_drawable_get_xdisplay(the_dialog->m_back_pix);
win = gdk_x11_drawable_get_xid(the_dialog->m_back_pix);
screen = DefaultScreen(dpy);
xgc = DefaultGC(dpy, screen);
the_dialog->createButtons(dpy, win, xgc, the_dialog->m_button_area->style->white_gc, the_dialog->m_back_pix, screen);
the_dialog->createMiniButtons(dpy, win, xgc, the_dialog->m_button_area->style->white_gc, the_dialog->m_back_pix, screen);
}
if (the_dialog->m_back_pix == NULL) return TRUE;
gdk_draw_rectangle(the_dialog->m_back_pix, the_dialog->m_blue_gc,
TRUE, 0, 0,
4 * the_dialog->m_back_img_width, MINI_BUTTON_AREA_HEIGHT + 5 * the_dialog->m_back_img_height);
for (bu_nr = 0; bu_nr < 17; bu_nr++) {
m_button_arrays[the_dialog->m_current_panel][bu_nr]->draw();
}
for (bu_nr = 0; bu_nr < 8; bu_nr++) {
m_mini_button_arrays[bu_nr]->draw();
}
GdkImage *img1 = gdk_drawable_get_image(the_dialog->m_back_pix, 0, 0,
4 * the_dialog->m_back_img_width, MINI_BUTTON_AREA_HEIGHT + 5 * the_dialog->m_back_img_height);
gdk_draw_image(the_dialog->m_button_area->window, the_dialog->m_copy_gc, img1, 0, 0, 0, 0,
4 * the_dialog->m_back_img_width, MINI_BUTTON_AREA_HEIGHT + 5 * the_dialog->m_back_img_height);
return TRUE;
}
XImage *NedTools::createX11PixmapFromGdkPixbuffer(Display *dpy, int screen, GdkDrawable *d, GdkGC *gc, GdkPixbuf *pixbuf, int background, bool up) {
int depth;
GdkImage *gdk_image;
GdkPixmap *gdk_pixmap;
XImage *x11_img;
int w = 0, h = 0;
if (pixbuf != NULL) {
w = gdk_pixbuf_get_width(pixbuf);
h = gdk_pixbuf_get_height(pixbuf);
}
depth = DefaultDepth(dpy, screen);
//gdk_draw_rectangle(gdk_pixmap, gc, TRUE, 0, 0, m_back_img_width, m_back_img_height);
switch (background) {
case HORIZ_BACKGROUND:
gdk_pixmap = gdk_pixmap_new(d, 2 * m_back_img_width, m_back_img_height, depth);
gdk_pixbuf_render_to_drawable (up ? NedResource::m_backgroundh1 : NedResource::m_backgroundh2, gdk_pixmap, gc,
0, 0, 0, 0, 2 * m_back_img_width, m_back_img_height, GDK_RGB_DITHER_NONE, 0, 0);
if (pixbuf != NULL) {
gdk_pixbuf_render_to_drawable (pixbuf, gdk_pixmap, gc,
0, 0, m_back_img_width - w / 2, (m_back_img_height - h) / 2, w, h, GDK_RGB_DITHER_NONE, 0, 0);
}
gdk_image = gdk_image_get(gdk_pixmap, 0, 0, 2 * m_back_img_width, m_back_img_height);
break;
case VERTI_BACKGROUND:
gdk_pixmap = gdk_pixmap_new(d, m_back_img_width, 2 * m_back_img_height, depth);
gdk_pixbuf_render_to_drawable (up ? NedResource::m_backgroundv1 : NedResource::m_backgroundv2, gdk_pixmap, gc,
0, 0, 0, 0, m_back_img_width, 2 * m_back_img_height, GDK_RGB_DITHER_NONE, 0, 0);
if (pixbuf != NULL) {
gdk_pixbuf_render_to_drawable (pixbuf, gdk_pixmap, gc,
0, 0, (m_back_img_width - w) / 2, m_back_img_height - h / 2, w, h, GDK_RGB_DITHER_NONE, 0, 0);
}
gdk_image = gdk_image_get(gdk_pixmap, 0, 0, m_back_img_width, 2 * m_back_img_height);
break;
case MINI_BACKGROUND:
gdk_pixmap = gdk_pixmap_new(d, m_back_miniimg_width, m_back_miniimg_height, depth);
gdk_pixbuf_render_to_drawable (up ? NedResource::m_mini_background1 : NedResource::m_mini_background2, gdk_pixmap, gc,
0, 0, 0, 0, m_back_miniimg_width, m_back_miniimg_height, GDK_RGB_DITHER_NONE, 0, 0);
if (pixbuf != NULL) {
gdk_pixbuf_render_to_drawable (pixbuf, gdk_pixmap, gc,
0, 0, (m_back_miniimg_width - w) / 2, (m_back_miniimg_height - h) / 2, w, h, GDK_RGB_DITHER_NONE, 0, 0);
}
gdk_image = gdk_image_get(gdk_pixmap, 0, 0, m_back_miniimg_width, m_back_miniimg_height);
break;
default:
gdk_pixmap = gdk_pixmap_new(d, m_back_img_width, m_back_img_height, depth);
gdk_pixbuf_render_to_drawable (up ? NedResource::m_background1 : NedResource::m_background2, gdk_pixmap, gc,
0, 0, 0, 0, m_back_img_width, m_back_img_height, GDK_RGB_DITHER_NONE, 0, 0);
if (pixbuf != NULL) {
gdk_pixbuf_render_to_drawable (pixbuf, gdk_pixmap, gc,
0, 0, (m_back_img_width - w) / 2, (m_back_img_height - h) / 2, w, h, GDK_RGB_DITHER_NONE, 0, 0);
}
gdk_image = gdk_image_get(gdk_pixmap, 0, 0, m_back_img_width, m_back_img_height);
break;
}
x11_img = gdk_x11_image_get_ximage(gdk_image);
//g_object_unref(gdk_pixmap);
return x11_img;
}
bool NedTools::OnButtonPress(GtkWidget *widget, GdkEventButton *event, gpointer data) {
NedTools *the_dialog = (NedTools *) data;
int bu_nr;
for (bu_nr = 0; bu_nr < 17; bu_nr++) {
m_button_arrays[the_dialog->m_current_panel][bu_nr]->handle_click(event->x, event->y);
}
for (bu_nr = 0; bu_nr < 5; bu_nr++) {
m_mini_button_arrays[bu_nr]->handle_click(event->x, event->y);
}
gdk_window_invalidate_rect(the_dialog->m_button_area->window, NULL, FALSE);
return FALSE;
}
bool NedTools::OnButtonRelease(GtkWidget *widget, GdkEventButton *event, gpointer data) {
NedTools *the_dialog = (NedTools *) data;
int bu_nr;
for (bu_nr = 0; bu_nr < 17; bu_nr++) {
if (m_button_arrays[the_dialog->m_current_panel][bu_nr]->handle_release(event->x, event->y)) {
the_dialog->testForPanelChange(m_button_arrays[the_dialog->m_current_panel][bu_nr]);
}
}
for (bu_nr = 0; bu_nr < 5; bu_nr++) {
if (m_mini_button_arrays[bu_nr]->handle_release(event->x, event->y)) {
the_dialog->m_current_panel = bu_nr;
}
}
gdk_window_invalidate_rect(the_dialog->m_button_area->window, NULL, FALSE);
return FALSE;
}
void NedTools::testForPanelChange(X11button *button) {
switch (m_current_panel) {
case 0: switch (button->m_row) {
case 0: switch (button->m_column) {
case 3: m_current_panel++;
break;
}
break;
}
break;
case 1: switch (button->m_row) {
case 0: switch (button->m_column) {
case 1: m_current_panel--;
break;
case 3: m_current_panel++;
break;
}
break;
}
break;
case 2: switch (button->m_row) {
case 0: switch (button->m_column) {
case 1: m_current_panel--;
break;
case 3: m_current_panel++;
break;
}
break;
}
break;
case 3: switch (button->m_row) {
case 0: switch (button->m_column) {
case 0: m_current_panel--;
break;
case 3: m_current_panel++;
break;
}
break;
}
break;
case 4: switch (button->m_row) {
case 0: switch (button->m_column) {
case 1: m_current_panel--;
break;
}
break;
}
break;
}
}
nted-1.10.18/dialogs/tupletdialog.cpp 0000664 0010410 0000764 00000006455 11520267217 014374 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "tupletdialog.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
NedTupletDialog::NedTupletDialog(GtkWindow *parent) {
GtkWidget *dialog;
GtkWidget *infolabel;
GtkWidget *lab1;
GtkWidget *vbox;
GtkWidget *hbox;
dialog = gtk_dialog_new_with_buttons(_("Tuplet"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
m_tuplet_spin_box = gtk_spin_button_new_with_range (2.0, 13.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_tuplet_spin_box), 3.0);
infolabel = gtk_label_new(_("Instead of using this dialog\nyou can simply press + num"));
lab1 = gtk_label_new(_("Tuplet value:"));
hbox = gtk_hbox_new(FALSE, 8);
gtk_box_pack_start(GTK_BOX(hbox), lab1, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), m_tuplet_spin_box, FALSE, FALSE, 0);
m_method_check_button = gtk_check_button_new_with_label(_("method 2"));
vbox = gtk_vbox_new(FALSE, 8);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), m_method_check_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), infolabel, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), vbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedTupletDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedTupletDialog *tuplet_dialog = (NedTupletDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
tuplet_dialog->m_state = TRUE;
break;
default:
tuplet_dialog->m_state = FALSE;
break;
}
tuplet_dialog->m_tuplet_val = (int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(tuplet_dialog->m_tuplet_spin_box)) + 0.4);
tuplet_dialog->m_method = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tuplet_dialog->m_method_check_button)) ? 1 : 0;
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedTupletDialog::getValues(bool *state, int *tupletval, int *method) {
*state = m_state;
*tupletval = m_tuplet_val;
*method = m_method;
}
nted-1.10.18/dialogs/paperconfigdialog.cpp 0000664 0010410 0000764 00000015401 11520267217 015343 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "paperconfigdialog.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
NedPaperConfigDialog::NedPaperConfigDialog(GtkWindow *parent,
const char *current_paper, bool portrait, bool with_cancel) : m_paper(current_paper), m_portrait(portrait) {
GtkWidget *dialog;
GtkWidget *paper_type_frame;
GtkWidget *paper_type_vbox;
GtkWidget *orientation_frame;
GtkWidget *orientation_vbox;
GtkWidget *hbox;
if (with_cancel) {
dialog = gtk_dialog_new_with_buttons(_("Paper"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
}
else {
dialog = gtk_dialog_new_with_buttons(_("Paper"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
}
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
paper_type_frame = gtk_frame_new(_("paper type"));
m_radio_box_A5 = gtk_radio_button_new_with_label(NULL, "A5");
m_radio_box_A4 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_A5), "A4");
m_radio_box_A3 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_A5), "A3");
m_radio_box_B4 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_A5), "B4");
m_radio_box_Letter = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_A5), "Letter");
m_radio_box_Legal = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_A5), "Legal");
m_radio_box_230x293 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_A5), "230x293");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_A4), TRUE);
if (!strcmp(current_paper, "A3")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_A3), TRUE);
}
else if (!strcmp(current_paper, "B4")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_B4), TRUE);
}
else if (!strcmp(current_paper, "Letter")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_Letter), TRUE);
}
else if (!strcmp(current_paper, "Legal")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_Legal), TRUE);
}
else if (!strcmp(current_paper, "230x293")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_230x293), TRUE);
}
paper_type_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_A5, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_A4, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_A3, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_B4, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_Letter, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_Legal, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (paper_type_vbox), m_radio_box_230x293, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(paper_type_frame), paper_type_vbox);
orientation_frame = gtk_frame_new(_("orientation"));
m_radio_box_portrait = gtk_radio_button_new_with_label(NULL, _(_("portrait")));
m_radio_box_landspace = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_radio_box_portrait), _("landscape"));
if (portrait) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_portrait), TRUE);
}
else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radio_box_landspace), TRUE);
}
orientation_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX (orientation_vbox), m_radio_box_portrait, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (orientation_vbox), m_radio_box_landspace, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(orientation_frame), orientation_vbox);
hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX (hbox), paper_type_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), orientation_frame, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), hbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedPaperConfigDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedPaperConfigDialog *paper_dialog = (NedPaperConfigDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
paper_dialog->m_state = TRUE;
break;
default:
paper_dialog->m_state = FALSE;
break;
}
paper_dialog->m_paper = "A4";
paper_dialog->m_portrait = TRUE;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_A3))) {
paper_dialog->m_paper = "A3";
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_A5))) {
paper_dialog->m_paper = "A5";
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_B4))) {
paper_dialog->m_paper = "B4";
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_Letter))) {
paper_dialog->m_paper = "Letter";
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_Legal))) {
paper_dialog->m_paper = "Legal";
}
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_230x293))) {
paper_dialog->m_paper = "230x293";
}
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (paper_dialog->m_radio_box_landspace))) {
paper_dialog->m_portrait = FALSE;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
gtk_widget_hide (GTK_WIDGET(dialog));
}
void NedPaperConfigDialog::getValues(bool *state, const char **paper, bool *portrait) {
*state = m_state;
*paper = m_paper;
*portrait = m_portrait;
}
nted-1.10.18/dialogs/midirecordconfigdialog.cpp 0000664 0010410 0000764 00000034301 11520267217 016355 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "midirecordconfigdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#include "staffcontextdialog.h"
#define INSTRUMENTS_WIDGET_WIDTH 200
#define TIMESIG_FRAME_WIDTH 100
#define MIDI_RECORD_CONFIG_SHOW_WINDOW_WIDTH (INSTRUMENTS_WIDGET_WIDTH + TIMESIG_FRAME_WIDTH)
#define MIDI_RECORD_CONFIG_SHOW_WINDOW_HEIGHT 200
NedMidiRecordConfigDialog::NedMidiRecordConfigDialog(GtkWindow *parent, int num, int denom, int midi_pgm,
int tempo_inverse, int volume, bool triplet, bool f_piano, bool dnt_split, int keysig) :
m_num(num), m_denom(denom), m_pgm(midi_pgm), m_tempo_inverse(tempo_inverse), m_metro_volume(volume), m_triplet(triplet), m_f_piano(f_piano), m_dnt_split(dnt_split), m_keysig(keysig) {
int i;
GtkWidget *dialog;
GtkWidget *time_signature_frame;
GtkWidget *numerator_label;
GtkWidget *denominator_label;
GtkWidget *time_signature_vbox;
GtkWidget *time_signature_upper_hbox;
GtkWidget *time_signature_lower_hbox;
GtkWidget *right_vbox;
GtkWidget *instrument_scroll;
GtkWidget *upper_hbox;
GtkListStore *instrumend_list_store;
GtkTreeIter iter;
GtkCellRenderer *instrument_renderer;
GtkTreeViewColumn *instrument_column;
GtkTreeViewColumn *instrument_num_column;
GtkTreePath* instrument_tree_path;
GtkWidget *tempo_frame;
GtkWidget *key_frame;
GtkWidget *key_frame_left_vbox;
GtkWidget *key_frame_right_vbox;
GtkWidget *radio_hbox;
GtkWidget *main_vbox;
GtkWidget *metro_volume_frame;
char Str[128];
dialog = gtk_dialog_new_with_buttons(_("Config Record"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
time_signature_frame = gtk_frame_new(_("time signature"));
time_signature_vbox = gtk_vbox_new(FALSE, 5);
time_signature_upper_hbox = gtk_hbox_new(FALSE, 5);
time_signature_lower_hbox = gtk_hbox_new(FALSE, 5);
numerator_label = gtk_label_new(_("Numerator:"));
denominator_label = gtk_label_new(_("Denominator:"));
m_numerator = gtk_spin_button_new_with_range (1.0, 20.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), m_num);
m_denominator = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "2");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "4");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "8");
gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "16");
if (m_denom < 4) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
}
else if (m_denom < 8) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
}
else if (m_denom < 16) {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 2);
}
else {
gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 3);
}
gtk_box_pack_start (GTK_BOX (time_signature_upper_hbox), numerator_label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_numerator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_lower_hbox), denominator_label, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_denominator, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_upper_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_lower_hbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(time_signature_frame), time_signature_vbox);
m_with_triplet_button = gtk_toggle_button_new_with_label(_("triplet recognition"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_with_triplet_button), m_triplet);
m_force_piano_button = gtk_toggle_button_new_with_label(_("force piano"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_force_piano_button), m_f_piano);
m_dont_split_button = gtk_toggle_button_new_with_label(_("don't split tracks"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_dont_split_button), m_dnt_split);
if (m_dnt_split) {
gtk_widget_set_sensitive(m_force_piano_button, FALSE);
}
else if (m_f_piano) {
gtk_widget_set_sensitive(m_dont_split_button, FALSE);
}
g_signal_connect(m_force_piano_button, "toggled", G_CALLBACK (OnPianoForcePressed), (void *) this);
g_signal_connect(m_dont_split_button, "toggled", G_CALLBACK (OnDontSplitPressed), (void *) this);
right_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(right_vbox), time_signature_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(right_vbox), m_with_triplet_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(right_vbox), m_force_piano_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(right_vbox), m_dont_split_button, FALSE, FALSE, 0);
instrumend_list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
for (i = 0; i < NedResource::getNumInstruments(); i++) {
gtk_list_store_append (instrumend_list_store, &iter);
gtk_list_store_set (instrumend_list_store, &iter, 0, i, 1, gettext(NedResource::GM_Instruments[i]), -1);
}
m_instrument_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(instrumend_list_store));
instrument_renderer = gtk_cell_renderer_text_new ();
instrument_num_column = gtk_tree_view_column_new_with_attributes (_("no"), instrument_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_num_column);
instrument_column = gtk_tree_view_column_new_with_attributes (_("instruments"), instrument_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_column);
m_instrument_adjustment = gtk_adjustment_new (0.0, 0.0, NedResource::getNumInstruments(), 1.0, 10.0, 10.0);
instrument_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(m_instrument_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_instrument_list), GTK_ADJUSTMENT(m_instrument_adjustment));
gtk_widget_set_size_request(m_instrument_list, INSTRUMENTS_WIDGET_WIDTH, MIDI_RECORD_CONFIG_SHOW_WINDOW_HEIGHT);
sprintf(Str, "%d", m_pgm);
instrument_tree_path = gtk_tree_path_new_from_string(Str);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE);
g_signal_connect(dialog, "scroll-event", G_CALLBACK (OnScroll), (void *) this);
tempo_frame = gtk_frame_new(_("tempo"));
m_tempo_scale = gtk_vscale_new_with_range(0.1 * 60.0, 2.4 * 60.0, 0.4 * 60.0);
gtk_range_set_inverted(GTK_RANGE(m_tempo_scale), TRUE);
gtk_range_set_value(GTK_RANGE(m_tempo_scale), 60.0 * (double) m_tempo_inverse / 100000.0);
gtk_container_add (GTK_CONTAINER(tempo_frame), m_tempo_scale);
metro_volume_frame = gtk_frame_new(_("volume"));
m_metro_volume_scale = gtk_vscale_new_with_range(0.0, 127.0, 1.0);
gtk_range_set_inverted(GTK_RANGE(m_metro_volume_scale), TRUE);
gtk_range_set_value(GTK_RANGE(m_metro_volume_scale), m_metro_volume);
gtk_container_add (GTK_CONTAINER(metro_volume_frame), m_metro_volume_scale);
key_frame = gtk_frame_new(_("key"));
radio_hbox = gtk_hbox_new(FALSE, 2);
key_frame_left_vbox = gtk_vbox_new(FALSE, 2);
key_frame_right_vbox = gtk_vbox_new(FALSE, 2);
m_sig_radio_buttons[0] = gtk_radio_button_new_with_label (NULL, gettext(NedStaffContextDialog::m_keyTab[0]));
gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[0], FALSE, FALSE, 0);
for (i = -5; i < 7; i++) {
m_sig_radio_buttons[i+6] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_sig_radio_buttons[0]), gettext(NedStaffContextDialog::m_keyTab[i+6]));
if (i < 0) {
gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
}
else {
gtk_box_pack_start (GTK_BOX (key_frame_right_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
}
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_sig_radio_buttons[keysig+6]), TRUE);
gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_left_vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_right_vbox, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER(key_frame), radio_hbox);
upper_hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(upper_hbox), m_instrument_list, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(upper_hbox), instrument_scroll, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(upper_hbox), right_vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(upper_hbox), tempo_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(upper_hbox), metro_volume_frame, FALSE, FALSE, 0);
main_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(main_vbox), upper_hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX(main_vbox), key_frame, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), main_vbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedMidiRecordConfigDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedMidiRecordConfigDialog *midi_record_dialog = (NedMidiRecordConfigDialog *) data;
int i;
GtkTreeSelection* selection;
GList *selected_rows;
switch (result) {
case GTK_RESPONSE_ACCEPT:
midi_record_dialog->m_state = TRUE;
break;
default:
midi_record_dialog->m_state = FALSE;
gtk_widget_destroy (GTK_WIDGET(dialog));
return;
break;
}
midi_record_dialog->m_num = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(midi_record_dialog->m_numerator));
switch (gtk_combo_box_get_active(GTK_COMBO_BOX(midi_record_dialog->m_denominator))) {
case 0: midi_record_dialog->m_denom = 2; break;
case 1: midi_record_dialog->m_denom = 4; break;
case 2: midi_record_dialog->m_denom = 8; break;
default: midi_record_dialog->m_denom = 16; break;
}
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(midi_record_dialog->m_instrument_list));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( g_list_length(selected_rows) > 0) {
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &(midi_record_dialog->m_pgm)) != 1) {
NedResource::Abort("NedMidiRecordConfigDialog::OnClose: error reading tree path(1)");
}
}
else {
midi_record_dialog->m_pgm = 0;
}
midi_record_dialog->m_triplet = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_with_triplet_button));
midi_record_dialog->m_f_piano = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_force_piano_button));
midi_record_dialog->m_dnt_split = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_dont_split_button));
midi_record_dialog->m_tempo_inverse = (int) (100000.0 * gtk_range_get_value(GTK_RANGE(midi_record_dialog->m_tempo_scale)) / 60.0);
midi_record_dialog->m_metro_volume = (int) gtk_range_get_value(GTK_RANGE(midi_record_dialog->m_metro_volume_scale));
midi_record_dialog->m_keysig = 0;
for (i = 0; i < 13; i++) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (midi_record_dialog->m_sig_radio_buttons[i]))) {
midi_record_dialog->m_keysig = i - 6;
}
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedMidiRecordConfigDialog::getValues(bool *state, int *num, int *denom, int *midi_pgm,
int *tempo_inverse, int *metro_volume, bool *triplet, bool *f_piano, bool *dnt_split, int* keysig) {
*state = m_state;
*num = m_num;
*denom = m_denom;
*midi_pgm = m_pgm;
*tempo_inverse = m_tempo_inverse;
*metro_volume = m_metro_volume;
*triplet = m_triplet;
*f_piano = m_f_piano;
*dnt_split = m_dnt_split;
*keysig = m_keysig;
}
void NedMidiRecordConfigDialog::OnPianoForcePressed(GtkButton *button, gpointer data) {
NedMidiRecordConfigDialog *midi_record_dialog = (NedMidiRecordConfigDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_force_piano_button))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_dont_split_button), FALSE);
gtk_widget_set_sensitive(midi_record_dialog->m_dont_split_button, FALSE);
}
else {
gtk_widget_set_sensitive(midi_record_dialog->m_dont_split_button, TRUE);
}
}
void NedMidiRecordConfigDialog::OnDontSplitPressed(GtkButton *button, gpointer data) {
NedMidiRecordConfigDialog *midi_record_dialog = (NedMidiRecordConfigDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_dont_split_button))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_force_piano_button), FALSE);
gtk_widget_set_sensitive(midi_record_dialog->m_force_piano_button, FALSE);
}
else {
gtk_widget_set_sensitive(midi_record_dialog->m_force_piano_button, TRUE);
}
}
gboolean NedMidiRecordConfigDialog::OnScroll(GtkWidget *widget, GdkEventScroll *event, gpointer data) {
#define SCROLL_INCR 20.0
double adjval;
NedMidiRecordConfigDialog *midi_record_dialog = (NedMidiRecordConfigDialog *) data;
adjval = gtk_adjustment_get_value(GTK_ADJUSTMENT(midi_record_dialog->m_instrument_adjustment));
if (event->direction == GDK_SCROLL_UP) {
adjval -= SCROLL_INCR;
}
else if (event->direction == GDK_SCROLL_DOWN) {
adjval += SCROLL_INCR;
}
gtk_adjustment_set_value(GTK_ADJUSTMENT(midi_record_dialog->m_instrument_adjustment), adjval);
return FALSE;
}
nted-1.10.18/dialogs/midiimportdialog.cpp 0000664 0010410 0000764 00000021467 11520267217 015234 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "midiimportdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#define MIDIIMPORT_DIALOG_WIDTH 500
#define MIDIIMPORT_DIALOG_HEIGHT 450
NedMidiImportDialog::NedMidiImportDialog(GtkWindow *parent, char **folder, char **filename) : m_with_triplets(true),
m_tempo_change_density(20), m_volume_change_density(20), m_last_folder(folder), m_filename(filename) {
GtkWidget *dialog;
GtkWidget *tempo_sensity_frame;
GtkWidget *volume_sensity_frame;
GtkWidget *main_vbox;
GtkWidget *main_hbox;
GtkWidget *left_vbox;
GtkWidget *right_vbox;
dialog = gtk_dialog_new_with_buttons(_("MIDI import"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
m_file_chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
if (*m_last_folder != NULL) {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_file_chooser), *m_last_folder);
}
if (*m_filename != NULL) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_file_chooser), *m_filename);
}
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, ".mid,.midi (MIDI-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.mid");
gtk_file_filter_add_pattern(file_filter1, "*.midi");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(m_file_chooser), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(m_file_chooser), file_filter2);
left_vbox = gtk_vbox_new(FALSE, 2);
right_vbox = gtk_vbox_new(FALSE, 2);
m_with_triplet_button = gtk_toggle_button_new_with_label(_("triplet recognition"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_with_triplet_button), TRUE);
m_sort_instruments_button = gtk_toggle_button_new_with_label(_("sort instruments"));
m_force_piano_button = gtk_toggle_button_new_with_label(_("force piano"));
m_dont_split_button = gtk_toggle_button_new_with_label(_("don't split tracks"));
g_signal_connect(m_force_piano_button, "toggled", G_CALLBACK (OnPianoForcePressed), (void *) this);
g_signal_connect(m_dont_split_button, "toggled", G_CALLBACK (OnDontSplitPressed), (void *) this);
gtk_container_add (GTK_CONTAINER(left_vbox), m_with_triplet_button);
gtk_container_add (GTK_CONTAINER(left_vbox), m_sort_instruments_button);
gtk_container_add (GTK_CONTAINER(left_vbox), m_force_piano_button);
gtk_container_add (GTK_CONTAINER(left_vbox), m_dont_split_button);
tempo_sensity_frame = gtk_frame_new(_("tempo density"));
m_tempo_change_density_scale = gtk_hscale_new_with_range(0.0, 100.0, 1.0);
gtk_range_set_value(GTK_RANGE(m_tempo_change_density_scale), 20.0);
gtk_container_add (GTK_CONTAINER(tempo_sensity_frame), m_tempo_change_density_scale);
volume_sensity_frame = gtk_frame_new(_("volume density"));
m_volume_change_density_scale = gtk_hscale_new_with_range(0.0, 100.0, 1.0);
gtk_range_set_value(GTK_RANGE(m_volume_change_density_scale), 20.0);
gtk_container_add (GTK_CONTAINER(volume_sensity_frame), m_volume_change_density_scale);
gtk_box_pack_start(GTK_BOX(right_vbox), tempo_sensity_frame, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(right_vbox), volume_sensity_frame, FALSE, TRUE, 0);
main_hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(main_hbox), left_vbox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(main_hbox), right_vbox, TRUE, TRUE, 0);
main_vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start (GTK_BOX(main_vbox), main_hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(main_vbox), m_file_chooser, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), main_vbox);
gtk_window_set_default_size (GTK_WINDOW (dialog), MIDIIMPORT_DIALOG_WIDTH, MIDIIMPORT_DIALOG_HEIGHT);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedMidiImportDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
char *s;
NedMidiImportDialog *midi_import_dialog = (NedMidiImportDialog *) data;
/*
printf("current folder = %s, filename = %s\n", gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(midi_import_dialog->m_file_chooser)),
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(midi_import_dialog->m_file_chooser)));
*/
switch (result) {
case GTK_RESPONSE_ACCEPT:
midi_import_dialog->m_state = TRUE;
if (*(midi_import_dialog->m_last_folder) != NULL) {
free(*(midi_import_dialog->m_last_folder));
*(midi_import_dialog->m_last_folder) = NULL;
}
if (*(midi_import_dialog->m_filename) != NULL) {
free(*(midi_import_dialog->m_filename));
*(midi_import_dialog->m_filename) = NULL;
}
s = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(midi_import_dialog->m_file_chooser));
if (strlen(s) > 0) {
*(midi_import_dialog->m_last_folder) = strdup(s);
}
s = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(midi_import_dialog->m_file_chooser));
if (strlen(s) > 0) {
*(midi_import_dialog->m_filename) = strdup(s);
}
break;
default:
midi_import_dialog->m_state = FALSE;
break;
}
midi_import_dialog->m_with_triplets = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_import_dialog->m_with_triplet_button));
midi_import_dialog->m_tempo_change_density = (int) gtk_range_get_value(GTK_RANGE(midi_import_dialog->m_tempo_change_density_scale));
midi_import_dialog->m_volume_change_density = (int) gtk_range_get_value(GTK_RANGE(midi_import_dialog->m_volume_change_density_scale));
midi_import_dialog->m_force_piano = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_import_dialog->m_force_piano_button));
midi_import_dialog->m_sort_instruments = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_import_dialog->m_sort_instruments_button));
midi_import_dialog->m_dont_split = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_import_dialog->m_dont_split_button));
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedMidiImportDialog::getValues(bool *state, bool *with_triplets, int *tempo_change_density, int *volume_change_density,
bool *force_piano, bool *sort_instruments, bool *dont_split) {
*state = m_state;
*with_triplets = m_with_triplets;
*force_piano = m_force_piano;
*sort_instruments = m_sort_instruments;
*dont_split = m_dont_split;
*tempo_change_density = (int)(100.0 - m_tempo_change_density);
*volume_change_density = (int)(100.0 - m_volume_change_density);
if (*tempo_change_density < 0) *tempo_change_density = 0;
if (*tempo_change_density > 100) *tempo_change_density = 100;
if (*volume_change_density < 0) *volume_change_density = 0;
if (*volume_change_density > 100) *volume_change_density = 100;
}
void NedMidiImportDialog::OnPianoForcePressed(GtkButton *button, gpointer data) {
NedMidiImportDialog *the_dialog = (NedMidiImportDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_force_piano_button))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_dont_split_button), FALSE);
gtk_widget_set_sensitive(the_dialog->m_dont_split_button, FALSE);
}
else {
gtk_widget_set_sensitive(the_dialog->m_dont_split_button, TRUE);
}
}
void NedMidiImportDialog::OnDontSplitPressed(GtkButton *button, gpointer data) {
NedMidiImportDialog *the_dialog = (NedMidiImportDialog *) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(the_dialog->m_dont_split_button))) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(the_dialog->m_force_piano_button), FALSE);
gtk_widget_set_sensitive(the_dialog->m_force_piano_button, FALSE);
}
else {
gtk_widget_set_sensitive(the_dialog->m_force_piano_button, TRUE);
}
}
nted-1.10.18/dialogs/printconfigdialog.h 0000664 0010410 0000764 00000003202 11520267217 015031 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef PRINT_CONFIG_DIALOG_H
#define PRINT_CONFIG_DIALOG_H
#include "config.h"
#include
class NedPrintConfigDialog {
public:
NedPrintConfigDialog(GtkWindow *parent, const char *print_cmd);
void getValues(bool *state, const char **print_cmd);
private:
static void CloseDialog(GtkDialog *dialog, gint result, gpointer data);
bool m_state;
const char *m_print_cmd;
GtkWidget *m_print_entry;
};
#endif /* PRINT_CONFIG_DIALOG_H */
nted-1.10.18/dialogs/insertblockdialog.cpp 0000664 0010410 0000764 00000005367 11520267217 015377 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "insertblockdialog.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
NedInsertBlockDialog::NedInsertBlockDialog(GtkWindow *parent) {
GtkWidget *dialog;
GtkWidget *lab;
GtkWidget *hbox;
dialog = gtk_dialog_new_with_buttons(_("Insert blocks"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseCallBack), (void *) this);
m_block_spin_box = gtk_spin_button_new_with_range (1.0, 20.0, 1.0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_block_spin_box), 1.0);
lab = gtk_label_new(_("block count:"));
hbox = gtk_hbox_new(FALSE, 8);
gtk_box_pack_start(GTK_BOX(hbox), lab, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), m_block_spin_box, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), hbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedInsertBlockDialog::CloseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedInsertBlockDialog *insert_dialog = (NedInsertBlockDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
insert_dialog->m_state = TRUE;
break;
default:
insert_dialog->m_state = FALSE;
break;
}
insert_dialog->m_blockcount = (int) (gtk_spin_button_get_value(GTK_SPIN_BUTTON(insert_dialog->m_block_spin_box)) + 0.4);
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedInsertBlockDialog::getValues(bool *state, int *blockcount) {
*state = m_state;
*blockcount = m_blockcount;
}
nted-1.10.18/dialogs/linesdialog.cpp 0000664 0010410 0000764 00000012243 11520267217 014161 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "linesdialog.h"
#include "localization.h"
#include "resource.h"
#include "mainwindow.h"
#define BOX_WIDTH 100
#define BOX_HEIGHT 40
#define RECT_OFFS 4
NedLinesDialog::NedLinesDialog(GtkWindow *parent) : m_current_row(-1), m_current_column(-1) {
GtkWidget *dialog;
GtkWidget *line_frame;
GtkWidget *line_image_widget;
m_black.pixel = 1; m_black.red = m_black.green = m_black.blue = 0;
m_red.pixel = 2; m_red.red = 65535; m_red.green = m_red.blue = 0;
dialog = gtk_dialog_new_with_buttons(_("Lines"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
line_frame = gtk_frame_new(_("lines"));
line_image_widget = gtk_drawing_area_new();
gtk_drawing_area_size(GTK_DRAWING_AREA(line_image_widget), NedResource::m_lines_buf_width, NedResource::m_lines_buf_height);
g_signal_connect (line_image_widget, "expose-event", G_CALLBACK (draw_menu), (void *) this);
gtk_container_add (GTK_CONTAINER(line_frame), line_image_widget);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), line_frame);
gtk_widget_show_all (dialog);
m_drawing_area_gc = gdk_gc_new(line_image_widget->window);
gtk_widget_add_events(line_image_widget, GDK_BUTTON_PRESS_MASK);
g_signal_connect (line_image_widget, "button-press-event", G_CALLBACK (change_selection), (void *) this);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedLinesDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
NedLinesDialog *lines_dialog = (NedLinesDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
lines_dialog->m_state = TRUE;
break;
default:
lines_dialog->m_state = FALSE;
break;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedLinesDialog::getValues(bool *state, int *linetype) {
*state = m_state && m_current_row >= 0 && m_current_column >= 0;
*linetype = 0;
if (state) {
switch (m_current_row) {
case 0: switch(m_current_column) {
case 0: *linetype = LINE_CRESCENDO; break;
case 1: *linetype = LINE_DECRESCENDO; break;
}
break;
case 1: switch(m_current_column) {
case 0: *linetype = LINE_OCTAVATION1; break;
case 1: *linetype = LINE_OCTAVATION_1; break;
}
break;
case 2: switch(m_current_column) {
case 0: *linetype = LINE_OCTAVATION2; break;
case 1: *linetype = LINE_OCTAVATION_2; break;
}
break;
}
}
}
gboolean NedLinesDialog::draw_menu(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
NedLinesDialog *lines_dialog = (NedLinesDialog *) data;
gdk_gc_set_foreground(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_black));
gdk_gc_set_rgb_fg_color(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_black));
gdk_draw_pixbuf(widget->window, lines_dialog->m_drawing_area_gc, NedResource::m_lines,
0, 0, 0, 0, NedResource::m_lines_buf_width, NedResource::m_lines_buf_height, GDK_RGB_DITHER_NONE, 0, 0);
if (lines_dialog->m_current_row >= 0 && lines_dialog->m_current_column >= 0) {
gdk_gc_set_foreground(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_red));
gdk_gc_set_rgb_fg_color(lines_dialog->m_drawing_area_gc, &(lines_dialog->m_red));
gdk_draw_rectangle(widget->window, lines_dialog->m_drawing_area_gc, false,
lines_dialog->m_current_column * BOX_WIDTH + RECT_OFFS, lines_dialog->m_current_row * BOX_HEIGHT + RECT_OFFS,
BOX_WIDTH - 2 * RECT_OFFS, BOX_HEIGHT - 2 * RECT_OFFS);
}
return FALSE;
}
gboolean NedLinesDialog::change_selection (GtkWidget *widget, GdkEventButton *event, gpointer data) {
GdkRectangle rect;
int dummy;
NedLinesDialog *lines_dialog = (NedLinesDialog *) data;
lines_dialog->m_current_column = (int) event->x / BOX_WIDTH;
lines_dialog->m_current_row = (int) event->y / BOX_HEIGHT;
gdk_window_get_geometry(widget->window, &dummy, &dummy, &rect.width, &rect.height, &dummy);
rect.x = rect.y = 0;
gdk_window_invalidate_rect (widget->window, &rect, FALSE);
return FALSE;
}
nted-1.10.18/dialogs/portchoosedialog.cpp 0000664 0010410 0000764 00000013067 11520267217 015241 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "portchoosedialog.h"
#include "localization.h"
#include "resource.h"
#include "config.h"
NedPortChooseDialog::NedPortChooseDialog(GtkWindow *parent, GList *ports, unsigned int idx, bool midi_echo, bool show_echo_box) :
m_idx(idx), m_midi_echo(midi_echo), m_with_midi_echo_box(show_echo_box) {
GtkWidget *dialog;
GtkWidget *port_list_hbox;
GtkWidget *vbox;
GtkObject *port_list_adjustment;
GtkWidget *port_list_scroll;
GtkListStore *port_list_store;
GtkTreeIter iter;
GtkCellRenderer *port_list_renderer;
GtkTreeViewColumn *port_list_column;
GtkTreeViewColumn *port_list_num_column;
GtkTreePath* port_list_tree_path;
GList *lptr;
char Str[128];
int i;
if (m_idx >= g_list_length(ports)) m_idx = 0;
dialog = gtk_dialog_new_with_buttons(_("MIDI ports"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);
port_list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
for (i = 0, lptr = g_list_first(ports); lptr; lptr = g_list_next(lptr), i++) {
gtk_list_store_append (port_list_store, &iter);
sprintf(Str, "%d:%d %s", ((MidiPortStruct *) lptr->data)->client, ((MidiPortStruct *) lptr->data)->port,
((MidiPortStruct *) lptr->data)->name);
gtk_list_store_set (port_list_store, &iter, 0, i + 1, 1, Str, -1);
}
m_port_list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(port_list_store));
port_list_renderer = gtk_cell_renderer_text_new ();
port_list_num_column = gtk_tree_view_column_new_with_attributes (_("no"), port_list_renderer, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_port_list_view), port_list_num_column);
port_list_column = gtk_tree_view_column_new_with_attributes (_("port"), port_list_renderer, "text", 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (m_port_list_view), port_list_column);
port_list_adjustment = gtk_adjustment_new (0.0, 0.0, g_list_length(ports), 1.0, 10.0, 10.0);
port_list_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(port_list_adjustment));
gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_port_list_view), GTK_ADJUSTMENT(port_list_adjustment));
gtk_widget_set_size_request(m_port_list_view, 200, 200);
sprintf(Str, "%d", m_idx);
port_list_tree_path = gtk_tree_path_new_from_string(Str);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_port_list_view), port_list_tree_path, NULL, FALSE, 0.0, 0.0);
gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_port_list_view), port_list_tree_path, NULL, FALSE);
port_list_hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(port_list_hbox), m_port_list_view, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(port_list_hbox), port_list_scroll, FALSE, TRUE, 0);
if (m_with_midi_echo_box) {
m_midi_echo_check_box = gtk_check_button_new_with_label(_("midi echo"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_midi_echo_check_box), m_midi_echo);
}
vbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), port_list_hbox, TRUE, TRUE, 0);
if (m_with_midi_echo_box) {
gtk_box_pack_start(GTK_BOX(vbox), m_midi_echo_check_box, TRUE, TRUE, 0);
}
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), vbox);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedPortChooseDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
GtkTreeSelection* selection;
GList *selected_rows;
NedPortChooseDialog *choose_dialog = (NedPortChooseDialog *) data;
if (result != GTK_RESPONSE_ACCEPT) {
choose_dialog->m_idx = -1;
gtk_widget_destroy (GTK_WIDGET(dialog));
return;
}
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(choose_dialog->m_port_list_view));
selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
if (g_list_length(selected_rows) < 1) {
choose_dialog->m_idx = -1;
gtk_widget_destroy (GTK_WIDGET(dialog));
return;
}
GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
char *tp = gtk_tree_path_to_string(path);
if (sscanf(tp, "%d", &(choose_dialog->m_idx)) != 1) {
NedResource::Abort("NedPortChooseDialog::OnClose: error reading tree path");
}
if (choose_dialog->m_with_midi_echo_box) {
choose_dialog->m_midi_echo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(choose_dialog->m_midi_echo_check_box));
}
else {
choose_dialog->m_midi_echo = false;
}
gtk_widget_destroy (GTK_WIDGET(dialog));
}
nted-1.10.18/dialogs/Makefile.in 0000664 0010410 0000764 00000045611 11520267353 013236 0000000 0000000 # Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
#########################################################################################
# #
# This program is free software; you can redistribute it and#or modify it under the #
# terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this #
# program; (See "COPYING"). If not, If not, see . #
# #
#---------------------------------------------------------------------------------------#
# #
# Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY #
# ja@informatik.tu-chemnitz.de #
# #
# #
#########################################################################################
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = dialogs
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LIBRARIES = $(noinst_LIBRARIES)
AR = ar
ARFLAGS = cru
libdialogs_a_AR = $(AR) $(ARFLAGS)
libdialogs_a_LIBADD =
am_libdialogs_a_OBJECTS = staffcontextdialog.$(OBJEXT) \
portchoosedialog.$(OBJEXT) paperconfigdialog.$(OBJEXT) \
printconfigdialog.$(OBJEXT) tupletdialog.$(OBJEXT) \
insertblockdialog.$(OBJEXT) measureconfigdialog.$(OBJEXT) \
keysigdialog.$(OBJEXT) scoreinfodialog.$(OBJEXT) \
clefconfigdialog.$(OBJEXT) volumedialog.$(OBJEXT) \
tempodialog.$(OBJEXT) mutedialog.$(OBJEXT) \
linesdialog.$(OBJEXT) signsdialog.$(OBJEXT) \
textdialog.$(OBJEXT) lilypondexportdialog.$(OBJEXT) \
staffselectdialog.$(OBJEXT) spacementdialog.$(OBJEXT) \
selectordialog.$(OBJEXT) tools.$(OBJEXT) scaledialog.$(OBJEXT) \
chordnamedialog.$(OBJEXT) midiimportdialog.$(OBJEXT) \
midirecordconfigdialog.$(OBJEXT) druminfo.$(OBJEXT) \
drumconfigdialog.$(OBJEXT) lyricseditor.$(OBJEXT)
libdialogs_a_OBJECTS = $(am_libdialogs_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
-o $@
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libdialogs_a_SOURCES)
DIST_SOURCES = $(libdialogs_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALSA_CFLAGS = @ALSA_CFLAGS@
ALSA_LIBS = @ALSA_LIBS@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CAIRO_CFLAGS = @CAIRO_CFLAGS@
CAIRO_LIBS = @CAIRO_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EXEEXT = @EXEEXT@
FT2_CFLAGS = @FT2_CFLAGS@
FT2_LIBS = @FT2_LIBS@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IMAGE2HEADER = @IMAGE2HEADER@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PANGO_CFLAGS = @PANGO_CFLAGS@
PANGO_LIBS = @PANGO_LIBS@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PO2XML = @PO2XML@
POSUB = @POSUB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
X11_CFLAGS = @X11_CFLAGS@
X11_LIBS = @X11_LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XML2POT = @XML2POT@
XMLTO = @XMLTO@
YELP = @YELP@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = $(FT2_CFLAGS) -I$(top_srcdir) $(CAIRO_CFLAGS) $(GTK_CFLAGS) $(X11_CFLAGS)
noinst_LIBRARIES = libdialogs.a
libdialogs_a_SOURCES = staffcontextdialog.cpp portchoosedialog.cpp \
paperconfigdialog.cpp printconfigdialog.cpp tupletdialog.cpp \
insertblockdialog.cpp measureconfigdialog.cpp keysigdialog.cpp \
scoreinfodialog.cpp clefconfigdialog.cpp volumedialog.cpp \
tempodialog.cpp mutedialog.cpp linesdialog.cpp signsdialog.cpp \
textdialog.cpp lilypondexportdialog.cpp staffselectdialog.cpp \
spacementdialog.cpp selectordialog.cpp tools.cpp \
scaledialog.cpp chordnamedialog.cpp midiimportdialog.cpp \
midirecordconfigdialog.cpp druminfo.cpp drumconfigdialog.cpp \
lyricseditor.cpp clefconfigdialog.h insertblockdialog.h \
keysigdialog.h linesdialog.h measureconfigdialog.h \
mutedialog.h paperconfigdialog.h portchoosedialog.h \
printconfigdialog.h scoreinfodialog.h signsdialog.h \
staffcontextdialog.h tempodialog.h textdialog.h tupletdialog.h \
volumedialog.h lilypondexportdialog.h staffselectdialog.h \
spacementdialog.h selectordialog.h tools.h scaledialog.h \
chordnamedialog.h midiimportdialog.h midirecordconfigdialog.h \
druminfo.h drumconfigdialog.h lyricseditor.h
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign dialogs/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign dialogs/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libdialogs.a: $(libdialogs_a_OBJECTS) $(libdialogs_a_DEPENDENCIES)
-rm -f libdialogs.a
$(libdialogs_a_AR) libdialogs.a $(libdialogs_a_OBJECTS) $(libdialogs_a_LIBADD)
$(RANLIB) libdialogs.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chordnamedialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clefconfigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drumconfigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/druminfo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insertblockdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keysigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lilypondexportdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linesdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lyricseditor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/measureconfigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/midiimportdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/midirecordconfigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutedialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/paperconfigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/portchoosedialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printconfigdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scaledialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scoreinfodialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/selectordialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signsdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spacementdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/staffcontextdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/staffselectdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tempodialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/textdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tupletdialog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/volumedialog.Po@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-noinstLIBRARIES ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
nted-1.10.18/dialogs/druminfo.cpp 0000664 0010410 0000764 00000010362 11520267217 013512 0000000 0000000 #include "druminfo.h"
#include "resource.h"
struct d_info_str default_dinfo[] = {
{"bassdrum", "bd", 36, NORMAL_NOTE, NULL, 1 },
{"sidestick", "ss", 37, CROSS_NOTE3, NULL, 5 },
{"snare", "sn", 38, NORMAL_NOTE, NULL, 5 },
{"handclap", "hc", 39, TRIAG_NOTE2, NULL, 5 },
{"lowfloortom", "tomfl",41, NORMAL_NOTE, NULL, 0 },
{"closedhihat", "hhc", 42, CLOSED_HIGH_HAT,"stopped", 7 },
{"hihat", "hh", 42, CROSS_NOTE3, NULL, 7 },
{"highfloortom", "tomfh",43, NORMAL_NOTE, NULL, 2 },
{"pedalhihat", "hhp", 44, CROSS_NOTE3, NULL, -1 },
{"lowtom", "toml", 45, NORMAL_NOTE, NULL, 3 },
{"openhihat", "hho", 46, OPEN_HIGH_HAT, "open", 7 },
{"halfopenhihat", "hhho", 46, CROSS_NOTE2, NULL, 7 },
{"lowmidtom", "tomml",47, NORMAL_NOTE, NULL, 4 },
{"himidtom", "tommh",48, NORMAL_NOTE, NULL, 6 },
{"crashcymbal", "cymc", 49, CROSS_NOTE2, NULL, 9 },
{"hightom", "tomh", 50, NORMAL_NOTE, NULL, 8 },
{"ridecymbal", "cymr", 51, CROSS_NOTE3, NULL, 9 },
{"splashcymbal", "cyms", 55, RECT_NOTE2, NULL, 9 },
{"cowbell", "cb", 56, TRIAG_NOTE2, NULL, 9 },
{"chinesecymbal", "cymch",52, RECT_NOTE1, NULL, 9 },
/* -------------------------------------------------------------- */
{"acousticbassdrum", "bda", 35, NORMAL_NOTE, NULL, 1 },
{"claves", "cl", 75, NORMAL_NOTE, NULL, 3 },
{"loagogo", "agl", 68, NORMAL_NOTE, NULL, 3 },
{"crashcymbalb", "cymcb",57, CROSS_NOTE3, NULL, 9 },
{"hitimbale", "timh", 65, NORMAL_NOTE, NULL, 3 },
{"maracas", "mar", 70, NORMAL_NOTE, NULL, 3 },
{"fivedown", "de", 52, NORMAL_NOTE, NULL, 3 },
{"electricsnare", "sne", 40, NORMAL_NOTE, NULL, 5 },
{"threeup", "uc", 65, NORMAL_NOTE, NULL, 3 },
{"acousticsnare", "sna", 38, NORMAL_NOTE, NULL, 5 },
{"mutehiconga", "cghm", 62, NORMAL_NOTE, NULL, 3 },
{"lowoodblock", "wbl", 77, NORMAL_NOTE, NULL, 3 },
{"hiconga", "cgh", 63, NORMAL_NOTE, NULL, 3 },
{"oneup", "ua", 62, NORMAL_NOTE, NULL, 3 },
{"guiro", "gui", 74, NORMAL_NOTE, NULL, 3 },
{"opencuica", "cuio", 79, NORMAL_NOTE, NULL, 3 },
{"mutehibongo", "bohm", 60, NORMAL_NOTE, NULL, 3 },
{"longguiro", "guil", 74, NORMAL_NOTE, NULL, 3 },
{"crashcymbala", "cymca",49, CROSS_NOTE2, NULL, 9 },
{"hiagogo", "agh", 67, NORMAL_NOTE, NULL, 3 },
{"hisidestick", "ssh", 37, NORMAL_NOTE, NULL, 3 },
{"openlobongo", "bolo", 61, NORMAL_NOTE, NULL, 3 },
{"mutetriangle", "trim", 80, NORMAL_NOTE, NULL, 3 },
{"opentriangle", "trio", 81, NORMAL_NOTE, NULL, 3 },
{"fiveup", "ue", 69, NORMAL_NOTE, NULL, 3 },
{"tambourine", "tamb", 54, NORMAL_NOTE, NULL, 3 },
{"longwhistle", "whl", 72, NORMAL_NOTE, NULL, 3 },
{"cabasa", "cab", 69, NORMAL_NOTE, NULL, 3 },
{"ridecymbalb", "cymrb",59, CROSS_NOTE3, NULL, 9 },
{"fourdown", "dd", 53, NORMAL_NOTE, NULL, 3 },
{"triangle", "tri", 81, NORMAL_NOTE, NULL, 3 },
{"hiwoodblock", "wbh", 76, NORMAL_NOTE, NULL, 3 },
{"onedown", "da", 59, NORMAL_NOTE, NULL, 3 },
{"twoup", "ub", 64, NORMAL_NOTE, NULL, 3 },
{"mutelobongo", "bolm", 61, NORMAL_NOTE, NULL, 3 },
{"loconga", "cgl", 64, NORMAL_NOTE, NULL, 3 },
{"openloconga", "cglo", 64, NORMAL_NOTE, NULL, 3 },
{"lobongo", "bol", 61, NORMAL_NOTE, NULL, 3 },
{"vibraslap", "vibs", 58, RECT_NOTE2, NULL, 8 },
{"mutecuica", "cuim", 78, NORMAL_NOTE, NULL, 3 },
{"losidestick", "ssl", 37, NORMAL_NOTE, NULL, 3 },
{"shortguiro", "guis", 73, NORMAL_NOTE, NULL, 3 },
{"twodown", "db", 57, NORMAL_NOTE, NULL, 3 },
{"shortwhistle", "whs", 71, NORMAL_NOTE, NULL, 3 },
{"openhibongo", "boho", 60, NORMAL_NOTE, NULL, 3 },
{"openhiconga", "cgho", 63, NORMAL_NOTE, NULL, 3 },
{"threedown", "dc", 55, NORMAL_NOTE, NULL, 3 },
{"fourup", "ud", 67, NORMAL_NOTE, NULL, 3 },
{"muteloconga", "cglm", 62, NORMAL_NOTE, NULL, 3 },
{"lotimbale", "timl", 66, NORMAL_NOTE, NULL, 3 },
{"ridecymbala", "cymra",51, CROSS_NOTE3, NULL, 9 },
{"hibongo", "boh", 60, NORMAL_NOTE, NULL, 3 },
{"ridebell", "rb", 53, NORMAL_NOTE, NULL, 9 },
{NULL, NULL, 0, NULL, NULL}
};
struct d_info_str current_dinfo[G_N_ELEMENTS(default_dinfo)];
int getNumberOfDrumTabElements() {
return G_N_ELEMENTS(default_dinfo);
}
void make_default_drums_current() {
d_info_str *dptr1, *dptr2;
dptr1 = default_dinfo;
dptr2 = current_dinfo;
do {
memcpy(dptr2, dptr1, sizeof(struct d_info_str));
if (dptr1->name) {
dptr1++; dptr2++;
}
}
while(dptr1->name);
}
nted-1.10.18/dialogs/lyricseditor.cpp 0000664 0010410 0000764 00000043354 11520267217 014412 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include
#include "lyricseditor.h"
#include "mainwindow.h"
#include "localization.h"
#include "resource.h"
#define EDITOR_WIDTH 600
#define EDITOR_HIGHT 300
#define MAX_LINE_LENGTH 80
NedLyricsEditor::NedLyricsEditor(GtkWindow *parent, NedMainWindow *main_window, int staff_nr):
m_main_window(main_window), m_last_folder(NULL), m_current_verse(0), m_staff_nr(staff_nr) {
GtkWidget *buttons_frame;
GtkWidget *buttons_vbox;
GtkWidget *main_hbox;
GtkWidget *load_button;
GtkWidget *save_button;
GtkWidget *scrolled_window1;
GtkWidget *scrolled_window2;
GtkWidget *scrolled_window3;
GtkWidget *scrolled_window4;
GtkWidget *scrolled_window5;
GtkObject* hscroll1, *vscroll1;
GtkObject* hscroll2, *vscroll2;
GtkObject* hscroll3, *vscroll3;
GtkObject* hscroll4, *vscroll4;
GtkObject* hscroll5, *vscroll5;
GtkWidget *label1;
GtkWidget *label2;
GtkWidget *label3;
GtkWidget *label4;
GtkWidget *label5;
GtkWidget *view1;
GtkWidget *view2;
GtkWidget *view3;
GtkWidget *view4;
GtkWidget *view5;
m_dialog = gtk_dialog_new_with_buttons(_("Lyrics"), parent, (GtkDialogFlags) 0,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(m_dialog, "response", G_CALLBACK (ResponseCallBack), (void *) this);
view1 = gtk_text_view_new();
view2 = gtk_text_view_new();
view3 = gtk_text_view_new();
view4 = gtk_text_view_new();
view5 = gtk_text_view_new();
m_buffer[0] = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
m_buffer[1] = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
m_buffer[2] = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view3));
m_buffer[3] = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view4));
m_buffer[4] = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view5));
label1 = gtk_label_new(_("lyrics 1"));
label2 = gtk_label_new(_("lyrics 2"));
label3 = gtk_label_new(_("lyrics 3"));
label4 = gtk_label_new(_("lyrics 4"));
label5 = gtk_label_new(_("lyrics 5"));
hscroll1 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
vscroll1 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
scrolled_window1 = gtk_scrolled_window_new(GTK_ADJUSTMENT(hscroll1), GTK_ADJUSTMENT(vscroll1));
gtk_container_add (GTK_CONTAINER(scrolled_window1), view1);
hscroll2 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
vscroll2 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
scrolled_window2 = gtk_scrolled_window_new(GTK_ADJUSTMENT(hscroll2), GTK_ADJUSTMENT(vscroll2));
gtk_container_add (GTK_CONTAINER(scrolled_window2), view2);
hscroll3 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
vscroll3 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
scrolled_window3 = gtk_scrolled_window_new(GTK_ADJUSTMENT(hscroll3), GTK_ADJUSTMENT(vscroll3));
gtk_container_add (GTK_CONTAINER(scrolled_window3), view3);
hscroll4 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
vscroll4 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
scrolled_window4 = gtk_scrolled_window_new(GTK_ADJUSTMENT(hscroll4), GTK_ADJUSTMENT(vscroll4));
gtk_container_add (GTK_CONTAINER(scrolled_window4), view4);
hscroll5 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
vscroll5 = gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 10.0, 100.0);
scrolled_window5 = gtk_scrolled_window_new(GTK_ADJUSTMENT(hscroll5), GTK_ADJUSTMENT(vscroll5));
gtk_container_add (GTK_CONTAINER(scrolled_window5), view5);
m_table = gtk_notebook_new();
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), scrolled_window1, label1);
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), scrolled_window2, label2);
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), scrolled_window3, label3);
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), scrolled_window4, label4);
gtk_notebook_append_page (GTK_NOTEBOOK(m_table), scrolled_window5, label5);
gtk_widget_set_size_request(view1, EDITOR_WIDTH, EDITOR_HIGHT);
gtk_widget_set_size_request(view2, EDITOR_WIDTH, EDITOR_HIGHT);
gtk_widget_set_size_request(view3, EDITOR_WIDTH, EDITOR_HIGHT);
gtk_widget_set_size_request(view4, EDITOR_WIDTH, EDITOR_HIGHT);
gtk_widget_set_size_request(view5, EDITOR_WIDTH, EDITOR_HIGHT);
g_signal_connect (view1, "map-event", G_CALLBACK(OnMap1), (void *) this);
g_signal_connect (view2, "map-event", G_CALLBACK(OnMap2), (void *) this);
g_signal_connect (view3, "map-event", G_CALLBACK(OnMap3), (void *) this);
g_signal_connect (view4, "map-event", G_CALLBACK(OnMap4), (void *) this);
g_signal_connect (view5, "map-event", G_CALLBACK(OnMap5), (void *) this);
load_button = gtk_button_new_with_label(_("load from file"));
save_button = gtk_button_new_with_label(_("save to file"));
g_signal_connect (save_button, "pressed", G_CALLBACK(OnSave), (void *) this);
g_signal_connect (load_button, "pressed", G_CALLBACK(OnLoad), (void *) this);
buttons_vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(buttons_vbox), load_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(buttons_vbox), save_button, FALSE, FALSE, 0);
buttons_frame = gtk_frame_new(_("file"));
gtk_container_add (GTK_CONTAINER(buttons_frame), buttons_vbox);
main_hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start (GTK_BOX(main_hbox), buttons_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(main_hbox), m_table, TRUE, TRUE, 0);
for (int i = 0; i < MAX_LYRICS_LINES; number_uf_dots[i++] = 0);
m_main_window->collectLyrics(this, staff_nr);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(m_dialog)->vbox), main_hbox);
gtk_widget_show_all (m_dialog);
gtk_dialog_run(GTK_DIALOG(m_dialog));
}
void NedLyricsEditor::ResponseCallBack(GtkDialog *dialog, gint result, gpointer data) {
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
case GTK_RESPONSE_APPLY:
for (int i = 0; i < MAX_LYRICS_LINES; i++) {
gtk_text_buffer_get_start_iter(lyrics_editor->m_buffer[i], &(lyrics_editor->m_itr1[i]));
gtk_text_buffer_get_start_iter(lyrics_editor->m_buffer[i], &(lyrics_editor->m_itr2[i]));
lyrics_editor->m_newchar[i] = TRUE;
}
lyrics_editor->m_main_window->NedMainWindow::updateLyrics(lyrics_editor, lyrics_editor->m_staff_nr);
break;
}
if (result != GTK_RESPONSE_APPLY) {
delete lyrics_editor;
}
}
NedLyricsEditor::~NedLyricsEditor() {
gtk_widget_destroy (GTK_WIDGET(m_dialog));
}
void NedLyricsEditor::appendText(int num, const char *text) {
GtkTextIter iter;
char buffer[1024];
const char *dotbuf = ". ", *dotnewbuf = ".\n";
int i;
gtk_text_buffer_get_end_iter (m_buffer[num], &iter);
for (i = 0; i < number_uf_dots[num]; i++) {
if (gtk_text_iter_get_line_offset(&iter) > MAX_LINE_LENGTH) {
gtk_text_buffer_insert(m_buffer[num], &iter, dotnewbuf, strlen(dotnewbuf));
}
else {
gtk_text_buffer_insert(m_buffer[num], &iter, dotbuf, strlen(dotbuf));
}
}
number_uf_dots[num] = 0;
if (gtk_text_iter_get_line_offset(&iter) > MAX_LINE_LENGTH) {
strcpy(buffer, "\n");
strcat(buffer, text);
}
else {
strcpy(buffer, text);
}
strcat(buffer, " ");
gtk_text_buffer_insert(m_buffer[num], &iter, buffer, strlen(buffer));
}
char *NedLyricsEditor::getNextWord(int line) {
gunichar uc;
int offs;
bool nl;
offs = gtk_text_iter_get_offset(&(m_itr2[line]));
gtk_text_iter_set_offset(&(m_itr1[line]), offs);
uc = gtk_text_iter_get_char(&(m_itr1[line]));
while (m_newchar[line] && uc <= ' ') {
m_newchar[line] = gtk_text_iter_forward_char(&(m_itr1[line]));
if (m_newchar[line]) {
uc = gtk_text_iter_get_char(&(m_itr1[line]));
}
}
if (m_newchar[line]) {
offs = gtk_text_iter_get_offset(&(m_itr1[line]));
gtk_text_iter_set_offset(&(m_itr2[line]), offs);
while (m_newchar[line] && uc > ' ' /* && uc != '-' */) {
m_newchar[line] = gtk_text_iter_forward_char(&(m_itr2[line]));
if (m_newchar[line]) {
uc = gtk_text_iter_get_char(&(m_itr2[line]));
}
else {
uc = gtk_text_iter_get_char(&(m_itr1[line]));
gtk_text_buffer_get_end_iter(m_buffer[line], &(m_itr2[line]));
nl = true;
while (nl && gtk_text_iter_compare(&(m_itr1[line]), &(m_itr2[line])) < 0 && uc < ' ') {
nl = gtk_text_iter_forward_char(&(m_itr1[line]));
}
if (nl && gtk_text_iter_compare(&(m_itr1[line]), &(m_itr2[line])) < 0) {
uc = gtk_text_iter_get_char(&(m_itr1[line]));
while (nl && gtk_text_iter_compare(&(m_itr1[line]), &(m_itr2[line])) < 0 && uc < ' ') {
nl = gtk_text_iter_backward_char(&(m_itr2[line]));
}
if (nl && gtk_text_iter_compare(&(m_itr1[line]), &(m_itr2[line])) <= 0 && uc >= ' ') {
return gtk_text_iter_get_text(&(m_itr1[line]), &(m_itr2[line]));
}
else {
return NULL;
}
}
else {
return NULL;
}
}
}
}
if (m_newchar[line]) {
return gtk_text_iter_get_text(&(m_itr1[line]), &(m_itr2[line]));
}
return NULL;
}
void NedLyricsEditor::OnSave (GtkButton *button, gpointer data) {
FILE *fp;
char *filename, *cptr;
bool ok = false;
bool extend = false;
char the_filename[4096];
char pathfoldername[1024];
DIR *the_directory;
GtkWidget *error_dialog;
GtkWidget *access_dialog;
GtkWidget *save_dialog;
int offs;
GtkTextIter itr1, itr2;
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
if (lyrics_editor->m_current_verse < 0 || lyrics_editor->m_current_verse >= MAX_LYRICS_LINES) {
NedResource::Abort("no current verse");
}
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.txt (Text-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.txt");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
save_dialog = gtk_file_chooser_dialog_new (_("Save lyrics"),
//GTK_WINDOW(drum_config_dialog),
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(save_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(save_dialog), file_filter2);
if (lyrics_editor->m_last_folder != NULL) {
if ((the_directory = opendir(lyrics_editor->m_last_folder)) != NULL) { // avoid gtk error message
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(save_dialog), lyrics_editor->m_last_folder);
closedir(the_directory);
}
else {
lyrics_editor->m_last_folder = NULL;
}
}
if (gtk_dialog_run (GTK_DIALOG (save_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (save_dialog));
strcpy(the_filename, filename);
g_free (filename);
ok = true;
}
if (ok && gtk_file_chooser_get_filter((GTK_FILE_CHOOSER (save_dialog))) == file_filter1) {
extend = true;
if ((cptr = strrchr(the_filename, '.')) != NULL) {
if (!strcmp(cptr, ".txt")) {
extend = false;
}
}
if (extend) {
strcat(the_filename, ".txt");
}
}
gtk_widget_destroy (save_dialog);
if (ok && access(the_filename, F_OK) == 0) {
access_dialog = gtk_message_dialog_new (NULL, //GTK_WINDOW(drum_config_dialog),
//(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
(GtkDialogFlags) 0,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File %s already exists. Overwrite ?"), the_filename);
if (gtk_dialog_run (GTK_DIALOG (access_dialog)) != GTK_RESPONSE_YES) {
ok = false;
}
gtk_widget_destroy (access_dialog);
}
if (ok) {
if ((fp = fopen(the_filename, "w")) == NULL) {
error_dialog = gtk_message_dialog_new (NULL, //GTK_WINDOW(drum_config_dialog),
//(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
(GtkDialogFlags) 0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for writing"), the_filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = false;
}
}
if (ok) {
if (the_filename[0] == '/' && (cptr = strrchr(the_filename, '/')) != NULL) {
strncpy(pathfoldername, the_filename, cptr - the_filename);
pathfoldername[cptr - the_filename] = '\0';
lyrics_editor->m_last_folder = strdup(pathfoldername);
}
gtk_text_buffer_get_start_iter(lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr1);
gtk_text_buffer_get_start_iter(lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr2);
gtk_text_iter_forward_line(&itr2);
while (gtk_text_iter_compare(&itr2, &itr1) > 0) {
fprintf(fp, "%s", gtk_text_iter_get_text(&itr1, &itr2));
offs = gtk_text_iter_get_offset(&itr2);
gtk_text_iter_set_offset(&itr1, offs);
gtk_text_iter_forward_line(&itr2);
}
fclose(fp);
}
}
void NedLyricsEditor::OnLoad (GtkButton *button, gpointer data) {
FILE *fp;
GtkWidget *open_dialog;
GtkWidget *error_dialog;
char *filename = NULL;
char pathfoldername[4096], *cptr;
DIR *the_directory;
char buffer[128];
bool ok = false;
int len;
GtkTextIter itr1, itr2;
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
if (lyrics_editor->m_current_verse < 0 || lyrics_editor->m_current_verse >= MAX_LYRICS_LINES) {
NedResource::Abort("no current verse");
}
open_dialog = gtk_file_chooser_dialog_new (_("Open lyrics file"),
NULL, //GTK_WINDOW(main_window->m_main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
GtkFileFilter *file_filter1 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter1, "*.txt (Text-Files)");
gtk_file_filter_add_pattern(file_filter1, "*.txt");
GtkFileFilter *file_filter2 = gtk_file_filter_new();
gtk_file_filter_set_name(file_filter2, "* (All Files)");
gtk_file_filter_add_pattern(file_filter2, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(open_dialog), file_filter1);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(open_dialog), file_filter2);
if (lyrics_editor->m_last_folder != NULL) {
if ((the_directory = opendir(lyrics_editor->m_last_folder)) != NULL) { // avoid gtk error message
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(open_dialog), lyrics_editor->m_last_folder);
closedir(the_directory);
}
else {
lyrics_editor->m_last_folder = NULL;
}
}
if (gtk_dialog_run (GTK_DIALOG (open_dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (open_dialog));
ok = true;
}
gtk_widget_destroy (open_dialog);
if (ok) {
if ((fp = fopen(filename, "r")) == NULL) {
error_dialog = gtk_message_dialog_new (NULL, //GTK_WINDOW(main_window->m_main_window),
//(GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL),
(GtkDialogFlags) 0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Cannot open %s for reading"), filename);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
ok = FALSE;
}
}
if (ok) {
if (filename[0] == '/' && (cptr = strrchr(filename, '/')) != NULL) {
strncpy(pathfoldername, filename, cptr - filename);
pathfoldername[cptr - filename] = '\0';
lyrics_editor->m_last_folder = strdup(pathfoldername);
}
gtk_text_buffer_get_start_iter(lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr1);
gtk_text_buffer_get_end_iter (lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr2);
gtk_text_buffer_delete(lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr1, &itr2);
while (1) {
if (!NedResource::readWordWithAllChars(fp, buffer)) break;
len = strlen(buffer);
gtk_text_buffer_get_end_iter (lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr2);
if (gtk_text_iter_get_line_offset(&itr2) > MAX_LINE_LENGTH) {
buffer[len] = '\n';
}
else {
buffer[len] = ' ';
}
buffer[len + 1] = '\0';
gtk_text_buffer_insert(lyrics_editor->m_buffer[lyrics_editor->m_current_verse], &itr2, buffer, strlen(buffer));
}
}
}
gboolean NedLyricsEditor::OnMap1(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
lyrics_editor->m_current_verse = 0;
return FALSE;
}
gboolean NedLyricsEditor::OnMap2(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
lyrics_editor->m_current_verse = 1;
return FALSE;
}
gboolean NedLyricsEditor::OnMap3(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
lyrics_editor->m_current_verse = 2;
return FALSE;
}
gboolean NedLyricsEditor::OnMap4(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
lyrics_editor->m_current_verse = 3;
return FALSE;
}
gboolean NedLyricsEditor::OnMap5(GtkWidget *widget, GdkEvent *event, gpointer data) {
NedLyricsEditor *lyrics_editor = (NedLyricsEditor *) data;
lyrics_editor->m_current_verse = 4;
return FALSE;
}
nted-1.10.18/dialogs/lilypondexportdialog.h 0000664 0010410 0000764 00000003775 11520267217 015622 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef LILYPOND_EXPORT_DIALOG_H
#define LILYPOND_EXPORT_DIALOG_H
#include "config.h"
#include
class NedMainWindow;
class NedLilyPondExportDialog {
public:
NedLilyPondExportDialog(GtkWindow *parent, NedMainWindow *main_window, char *filename, bool *selected_staves, bool *keep_beams);
void getValues(bool *state, bool *with_break);
private:
static void OnClose(GtkDialog *dialog, gint result, gpointer data);
static void OnStaffSelection (GtkButton *button, gpointer data);
static void OnBeamSelection (GtkButton *button, gpointer data);
NedMainWindow *m_main_window;
GtkWidget *m_dialog;
GtkWidget *m_with_break_checkbox;
GtkWidget *m_file_chooser;
bool m_state;
int m_with_breaks;
char *m_filename;
bool *m_selected_staves;
bool *m_keep_beams;
};
#endif /* LILYPOND_EXPORT_DIALOG_H */
nted-1.10.18/dialogs/printconfigdialog.cpp 0000664 0010410 0000764 00000005247 11520267217 015377 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "printconfigdialog.h"
#include "localization.h"
#include "resource.h"
NedPrintConfigDialog::NedPrintConfigDialog(GtkWindow *parent, const char *print_cmd) :
m_print_cmd(print_cmd) {
GtkWidget *dialog;
GtkWidget *print_cmd_frame;
dialog = gtk_dialog_new_with_buttons(_("Print command"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
g_signal_connect(dialog, "response", G_CALLBACK (CloseDialog), (void *) this);
print_cmd_frame = gtk_frame_new(_("print command"));
m_print_entry = gtk_entry_new_with_max_length(50);
gtk_entry_set_text(GTK_ENTRY(m_print_entry), m_print_cmd);
gtk_container_add (GTK_CONTAINER(print_cmd_frame), m_print_entry);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), print_cmd_frame);
gtk_widget_show_all (dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
}
void NedPrintConfigDialog::CloseDialog(GtkDialog *dialog, gint result, gpointer data) {
NedPrintConfigDialog *print_cmd_dialog = (NedPrintConfigDialog *) data;
switch (result) {
case GTK_RESPONSE_ACCEPT:
print_cmd_dialog->m_state = TRUE;
break;
default:
print_cmd_dialog->m_state = FALSE;
break;
}
print_cmd_dialog->m_print_cmd = strdup(gtk_entry_get_text(GTK_ENTRY(print_cmd_dialog->m_print_entry)));
gtk_widget_destroy (GTK_WIDGET(dialog));
}
void NedPrintConfigDialog::getValues(bool *state, const char **print_cmd) {
*state = m_state;
*print_cmd = m_print_cmd;
}
nted-1.10.18/midiexport.h 0000664 0010410 0000764 00000005364 11520267230 012077 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef MIDIEXPORT_H
#define MIDIEXPORT_H
#include "config.h"
#include
#include
class NedMainWindow;
class NedMidiExport {
public:
static void exportMidi(FILE *fp, NedMainWindow *main_window, char *miditext, GList *midi_events);
private:
static void writeTrack(GList *midi_events, int track_nr, int num, int denom);
static void writePgmChange(unsigned long long time, unsigned char chn, unsigned char pgm);
static void writeByte(unsigned char b);
static void writeWord(unsigned int w);
static void writeDWord(unsigned int dw);
static void writeString(char *s);
static void writeTime(unsigned long long time);
static void writeNoteOn(unsigned long long time, unsigned char ch, unsigned char ptch, unsigned char vel, unsigned char pgm);
static void writeNoteOff(unsigned long long time, unsigned char ch, unsigned char ptch, unsigned char vel);
static void writeCtlChange(unsigned long long time, unsigned char chn, unsigned char ctl, unsigned char pgm);
static void writeText(unsigned long long time, const char *s);
static void writeTrackName(unsigned long long time, const char *s);
static void writeTimeSig(unsigned long long time, int num, int denom);
static void writeKeySig(unsigned long long time, int sig);
static void writeTempo(unsigned long long time, unsigned int tempo);
static void writeCtrlTrack(char *Title, char *miditext, NedMainWindow *main_window);
static FILE *m_midiout;
static NedMainWindow *m_main_window;
static bool m_first_lyrics;
static unsigned char m_channel_pgms[16];
};
#endif // MIDIEXPORT_H
nted-1.10.18/importer.cpp 0000664 0010410 0000764 00000005652 11520267230 012107 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "importer.h"
part::part() {
init();
}
void part::init() {
int i;
id[0] = '\0';
name[0] = '\0';
divisions = 1;
current_clef = clef = TREBLE_CLEF;
clef_octave = current_clef_octave = 0;
first_clef = true;
volume = 64;
current_key_signature = key_signature = 0;
first_key_signature = true;
numerator = current_numerator = denominator = current_denominator = 4;
first_time_signature = true;
midi_pgm = 0;
midi_channel = 0;
for (i = 0; i < VOICE_COUNT; i++) {
voices[i] = NULL;
start_of_last_taken[i] = NULL;
end_of_last_taken[i] = NULL;
last_chord[i] = NULL;
eof[i] = false;
last_keysig[i] = 0;
}
}
bool part::is_eof() {
int i;
for (i = 0; i < VOICE_COUNT; i++) {
if (!eof[i]) return false;
}
return true;
}
bool part::isEmpty() {
int i;
for (i = 0; i < VOICE_COUNT; i++) {
if (g_list_length(voices[i]) > 0 ) return false;
}
return true;
}
void part::copy_from(part *other_part) {
int i;
*this = *other_part;
strcpy(id, other_part->id);
strcpy(name, other_part->name);
for (i = 0; i < VOICE_COUNT; i++) {
voices[i] = other_part->voices[i];
start_of_last_taken[i] = other_part->start_of_last_taken[i];
end_of_last_taken[i] = other_part->end_of_last_taken[i];
eof[i] = other_part->eof[i];
}
}
void part::resetTaken() {
int i;
for (i = 0; i < VOICE_COUNT; i++) {
end_of_last_taken[i] = g_list_previous(start_of_last_taken[i]);
}
}
NedImporter::NedImporter() : m_partcount(0), m_upbeat_inverse(0), m_tempo_inverse(START_TEMPO_INVERSE), m_main_window(NULL) {}
void NedImporter::resetTaken() {
int i;
for (i = 0; i < m_partcount; i++) {
m_parts[i].resetTaken();
}
}
bool NedImporter::is_eof() {
int i;
for (i = 0; i < m_partcount; i++) {
if (!m_parts[i].is_eof()) return false;
}
return true;
}
nted-1.10.18/freechord.cpp 0000664 0010410 0000764 00000015404 11520267230 012203 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "freechord.h"
#include "chordorrest.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#include "chordpainter.h"
#include "chordstruct.h"
#include "mainwindow.h"
#include "chorddialog.h"
#define X_POS_PAGE_REL(p) ((m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
#define X_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + leftx) / zoom_factor - m_element->getPage()->getContentXpos())
#define Y_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + topy - (TOP_BOTTOM_BORDER + DEFAULT_BORDER)) / zoom_factor)
NedFreeChord::NedFreeChord(char *code, int chordname, unsigned int status, NedMainWindow *main_window, NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative), m_main_window(main_window), m_chordname(chordname), m_status(status) {
m_chordptr = NedChordPainter::searchCordByCode(code);
if (m_chordptr == NULL) {
NedResource::Abort("Chord code not found");
}
strcpy(m_chord_name, NedChordPainter::roots[(m_status & ROOT_MASK)]);
strcat(m_chord_name, NedChordPainter::modies2[((m_status >> ROOT_BITS) & ((1 << MODI_BITS) - 1))]);
computeBbox();
}
NedFreeChord::NedFreeChord(struct chord_str *chordptr, int chordname, unsigned int status, NedMainWindow *main_window) :
NedFreeReplaceable(), m_chordptr(chordptr), m_main_window(main_window), m_chordname(chordname), m_status(status) {
strcpy(m_chord_name, NedChordPainter::roots[(m_status & ROOT_MASK)]);
strcat(m_chord_name, NedChordPainter::modies2[((m_status >> ROOT_BITS) & ((1 << MODI_BITS) - 1))]);
strcpy(m_chord_name, NedChordPainter::roots[(m_status & ROOT_MASK)]);
strcat(m_chord_name, NedChordPainter::modies2[((m_status >> ROOT_BITS) & ((1 << MODI_BITS) - 1))]);
computeBbox();
}
NedFreeChord::NedFreeChord(struct chord_str *chordptr, int chordname, unsigned int status, NedMainWindow *main_window, NedChordOrRest *element) :
NedFreeReplaceable(element), m_chordptr(m_chordptr), m_main_window(main_window), m_chordname(chordname), m_status(status) {
strcpy(m_chord_name, NedChordPainter::roots[(m_status & ROOT_MASK)]);
strcat(m_chord_name, NedChordPainter::modies2[((m_status >> ROOT_BITS) & ((1 << MODI_BITS) - 1))]);
computeBbox();
}
NedFreeChord::NedFreeChord(struct chord_str *chordptr, int chordname, unsigned int status, NedMainWindow *main_window, NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative), m_chordptr(m_chordptr), m_main_window(main_window), m_chordname(chordname), m_status(status) {
strcpy(m_chord_name, NedChordPainter::roots[(m_status & ROOT_MASK)]);
strcat(m_chord_name, NedChordPainter::modies2[((m_status >> ROOT_BITS) & ((1 << MODI_BITS) - 1))]);
computeBbox();
}
NedFreeReplaceable *NedFreeChord::clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area /* = NULL */, NedMainWindow *main_window /* = NULL */) {
if (main_window == NULL) {
NedResource::Abort("NedFreeChord::clone main_window == NULL");
}
NedFreeChord *newFreeChord = new NedFreeChord(m_chordptr, m_chordname, m_status, main_window, newelement, m_x, m_y, true);
return newFreeChord;
}
void NedFreeChord::adjust_pointers(struct addr_ref_str *slurlist) {
}
void NedFreeChord::computeBbox() {
#define CHORD_ZOOM 0.008
#define FEELED_TEXT_HEIGHT 0.6
if (m_status & GUITAR_CHORD_DRAW_DIAGRAM) {
m_bbox.width = GUITAR_WIDTH * CHORD_ZOOM;
m_bbox.height = F_DIST * F_COUNT * CHORD_ZOOM;
return;
}
m_bbox.width = GUITAR_WIDTH * CHORD_ZOOM;
m_bbox.height = FEELED_TEXT_HEIGHT;
}
bool NedFreeChord::trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy) {
if (m_element == NULL) return false;
double xpos, ypos;
double x = X_POS_PAGE_REL_INVERSE(xl);
double y = Y_POS_PAGE_REL_INVERSE(yl);
getXYPos(&xpos, &ypos);
if (x < xpos - m_bbox.width / 2.0 || x > xpos + m_bbox.width / 2.0 || y < ypos - m_bbox.height / 2.0 || y > ypos + m_bbox.height / 2.0) return false;
setThis();
return true;
}
void NedFreeChord::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale) {
if (m_element == NULL) return;
double xpos, ypos;
getXYPos(&xpos, &ypos);
#define CHORD_ZOOM_Z (CHORD_ZOOM * zoom_factor)
if (isActive()) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
if (m_status & GUITAR_CHORD_DRAW_DIAGRAM) {
NedChordPainter::draw_chord(cr, m_chordptr, m_chord_name, m_status, true, X_POS_PAGE_REL(xpos - m_bbox.width / 2.0 ),
Y_POS_PAGE_REL(ypos - m_bbox.height / 2.0), CHORD_ZOOM_Z, m_main_window->getCurrentZoomLevel());
}
else {
NedChordPainter::draw_chord(cr, m_chordptr, m_chord_name, m_status, true, X_POS_PAGE_REL(xpos - m_bbox.width / 2.0 ), Y_POS_PAGE_REL(ypos + 0.8 *m_bbox.height), CHORD_ZOOM_Z, m_main_window->getCurrentZoomLevel());
}
if (isActive()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
if (m_is_abs) {
drawConnection(cr, xpos, ypos, leftx, topy, zoom_factor);
}
}
const char *NedFreeChord::getCode() {
return m_chordptr->id;
}
void NedFreeChord::startContextDialog(GtkWidget *ref) {
struct chord_str *new_chord_ptr;
int new_chord_name;
bool state;
unsigned int new_status;
NedChordDialog *dialog = new NedChordDialog(GTK_WINDOW(ref), m_main_window, m_chordptr, m_status);
dialog->getValues(&state, &new_chord_ptr, &new_chord_name, &new_status);
if (!state) return;
m_chordptr = new_chord_ptr;
m_chordname = new_chord_name;
m_status = new_status;
strcpy(m_chord_name, NedChordPainter::roots[(m_status & ROOT_MASK)]);
strcat(m_chord_name, NedChordPainter::modies2[((m_status >> ROOT_BITS) & ((1 << MODI_BITS) - 1))]);
computeBbox();
}
nted-1.10.18/slurpoint.h 0000664 0010410 0000764 00000004772 11520267230 011754 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef SLUR_POINT_H
#define SLUR_POINT_H
#include "freereplaceable.h"
#include
class NedSlur;
class NedStaff;
class NedSlurPoint : public NedFreeReplaceable {
public:
NedSlurPoint(NedSlur *slur, int p_nr);
NedSlurPoint(NedSlur *slur, int p_nr, NedChordOrRest *element);
NedSlurPoint(NedSlur *slur, int p_nr, NedChordOrRest *element, double x, double y, bool relative);
void getXYPosAndStaff(double *xpos, double *ypos, NedStaff **staff);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL );
virtual void adjust_pointers(struct addr_ref_str *slurlist);
NedStaff *getStaff();
NedSlurPoint **getSlurPoints();
virtual void shift(double x, double y, double zoom_factor, double m_current_scale, double leftx, double topy);
void setSlur(NedSlur *slur) {m_slur = slur;}
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_SLUR_POINT;}
virtual void startContextDialog(GtkWidget *ref);
double computeYposRelative(NedStaff *staff);
void virtual recompute();
NedSlur *getSlur() {return m_slur;}
int m_point_number;
private:
NedSlur *m_slur;
friend class NedSlur;
};
#endif /* SLUR_POINT_H */
nted-1.10.18/FAQ 0000664 0010410 0000764 00000014515 11520267230 010072 0000000 0000000 *A.1.*
I can't hear any sound! I see the running red notes but there is no
sound! What's wrong?
**
This has nothing to do with NtEd! It is a problem of your MIDI device!
All MIDI based applications (for instance kmid (not kmidi!!!) or
pmidi) will fail!
First of all: Try to play a MIDI file with kmid (not (!!!)). As
long as kmid does not produce any sound, NtEd (and any other MIDI device
based software) will not produce any sound, too! The reason is: Either
your soundcard has no hardware MIDI synthesizer or it has a hardware
MIDI synthesizer but it is not supported by Linux.
Please refer to the ALSA project page (http://www.alsa-project.org) to
find out whether the midi device on your sound card is supported.
Before making a lot of effort to emulate the hardware synthesizer by
software you should search for a soundfont file on the CD shipped with
your soundcard. A soundfont file has the suffix ".sf2" or ".SF2". Please
make sure it is a General MIDI soundfont! If there is such a soundfont
file there is a high probability you simply have to load the soundfont
onto your soundcard.
To to this you need a programm called asfxload
http://www.alsa-project.org/~tiwai/awedrv.html#Utils
Simply type:
asfxload .sf2
But even if you cannot find a soundfont file on soundcard CD, you can
try to download a soundfont file. I recommand the soundfont mentioned at
http://alsa.opensrc.org/8MBGMSFX.SF2.
If asfxload fails your soundcard does not permit loading a soundfont.
There is still a last chance that not all needed moduls are loaded. So
as a last attempt type as root:
modprobe snd_seq_midi
and repeat the asfxload command.
If asfxload fails again you have to emulate the hardware MIDI
synthesizer by software.
This works if your computer has enough performance. Windows for
instances starts a soft synthesizer automatically if the hardware
synthesis does not work. So, be not confused if you can play MIDI files
on Windows!
Such emulation software exists for Linux, too. But it is more
complicated because:
* You have to start this software "by hand".
* These software MIDI synthesizers need a so-called soundfont, a
collection of sample tones of every instrument of a virtual
orchestra. These soundfonts are copyrighted, i.e. actually nothing
for a free system like Linux.
But there is a (relatively bulky) way! See The TiMidity server section
in NtEd documentation:
http://vsr.informatik.tu-chemnitz.de/~jan/noteedit/NTED/doc/timidity_server.html
for detailed instructions!
Note! There are more software synthesizers on Linux, which can be
tested. Among them the FluidSysth (http://fluidsynth.resonance.org/trac).
See http://www.linux-sound.org for a list.
Note
You should avoid soft synthesis if the performance of your computer is
too small! The antialiasing procedure (smoothing the symbols) of NtEd
consumes a lot of performance, and soft synthesis, too! As a result the
replay can be uneven especially during page turn over!
*A.2*
I use TiMidity but the sound is distorted and somtimes I have no sound, at all. What's wrong?
**
Check whether you have a command pulseaudio:
which pulseaudio
If you get the path of pulseaudio then follow the instructions in chapter
"pulseaudio"
*A.3.*
At program start it says: "Error in FT_Open_Face"! What's wrong!
**
You have not installed the program! Please type (as root):
make install
Refer also to INSTALL file shipped with the |nted-x.y.z.tgz| archive.
*A.4.*
I use asfxload but I get an error "sfxload: no memory left" and some instruments are missing during replay. What's wrong?
**
Don't believe the many rumours on different mailing lists!xi
I have bad news for you: You have to build a new kernel. Terrible, I know!
If you feel unable to do this then try to use the TiMidity server.
Otherwise download the kernel and change in
arch/x86/include/asm/dma.h:
#define MAX_DMA32_PFN ((4UL * 1024 * 1024 * 1024) >> PAGE_SHIFT)
against:
#define MAX_DMA32_PFN ((2UL * 1024 * 1024 * 1024) >> PAGE_SHIFT)
Then build the kernel! Refer to
https://lists.ubuntu.com/archives/universe-bugs/2009-March/068812.html
for more details!
*A.5.*
I cannot install NtEd because I have no root rights. What shall I do?
**
You can use the --prefix option to install the NtEd in an arbitrary
directory below your $HOME directory. Please refer also to INSTALL file!
Furthermore, if you want to avoid the make install command then set
an environment variable NTED_FONT_DIR to the directory where the
nted/ntedfont.pfa is situated.
For instance, assume the ntedfont.pfa is at
/home/smith/datafiles/nted/ntedfont.pfa type at command prompt:
export NTED_FONT_DIR=/home/smith/datafiles
if you have a bash or sh shell.
If you're using a csh or tcsh type:
setenv NTED_FONT_DIR /home/smith/datafiles
To find out your shell type:
echo $SHELL
at command promt.
*A.6.*
May I set lyrics as text blocks below the sheet music? How can I use the score in common texts?
**
This would require to write a musical score editor and a text editor! This is too complex! But have a look at:
http://vsr.informatik.tu-chemnitz.de/staff/jan/nted/use_nted_in_text.xhtml
There you can find some proposals about that topic.
*A.7.*
During program startup I get an error: "Cannot open ALSA MIDI sequencer -->
replay won't work ..."! What's wrong ?
**
That means you either have no ALSA sound system. Or you have an ALSA sound
system but for complicated reasons your ALSA midi sequencer is not initialized.
In many cases this is due to a missing module. Therefore try (as root):
modprobe snd-seq-midi
and restart NtEd.
*A.8.*
During make step an error occurs: /bin/sh: gdk-pixbuf-csource: command
not found|. What's wrong ?
**
You are a SuSE-Linux user! SuSE places this tool at /opt/gnome/bin.
Actually this should be in your PATH. But under certain circumstances
this is not the case. If so then make sure /opt/gnome/bin is in your
PATH. If you have a (t)csh shell type:
setenv PATH "$PATH:/opt/gnome/bin"
If you have another shell type:
export PATH=$PATH:/opt/gnome/bin
To determine your shell type:
echo $SHELL
*A.9.*
During configure step I get an error:
"configure: error: C++ compiler cannot create executables,
See `config.log' for more details.".
What's wrong!
**
Ok, you can inspect the config.log. But this is presumably superfluous,
because in most cases that means: You have no C++ compiler installed.
nted-1.10.18/localization.h 0000664 0010410 0000764 00000002474 11520267230 012402 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef LOCALIZATION_H
#define LOCALIZATION_H
#define GETTEXT_PACKAGE "nted"
#include
#endif /* LOCALIZATION_H */
nted-1.10.18/freesign.h 0000664 0010410 0000764 00000004025 11520267230 011506 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef FREE_SIGN_H
#define FREE_SIGN_H
#include "freereplaceable.h"
#define SIGN_SEGNO 1
#define SIGN_CODA 2
class NedFreeSign : public NedFreeReplaceable {
public:
NedFreeSign(int kind);
NedFreeSign(int kind, NedChordOrRest *element);
NedFreeSign(int kind, NedChordOrRest *element, double x, double y, bool relative);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL);
virtual void adjust_pointers(struct addr_ref_str *slurlist);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_SIGN;}
virtual void startContextDialog(GtkWidget *ref);
int getKind() {return m_kind;}
private:
int m_kind;
};
#endif /* FREE_SIGN_H */
nted-1.10.18/INSTALL 0000664 0010410 0000764 00000004452 11520267230 010570 0000000 0000000 Installation
------------
How to obtain NtEd
----------------------
NtEd can be found at
http://vsr.informatik.tu-chemnitz.de/staff/jan/nted/nted.xhtml
Installing from source
----------------------
Requirements for source compilation
-----------------------------------
You need the following packages:
* g++ compiler (see: http://gcc.gnu.org)
* pkgconfig (see: http://pkg-config.freedesktop.org)
* X11 (include and libraries) (see: http://wiki.x.org/wiki)
* Gtk-2.x (include and libraries) (see http://www.gtk.org)
* Cairo-1.x (include and libraries) (see: http://cairographics.org/)
* ALSA-1.x (include and libraries) (see: http://www.alsa-project.org/)
* gettext (see: http://www.gnu.org/software/gettext/gettext.html)
If you want the immediate help you need further:
* yelp Is part of the GNOME project (see: http://www.gnome.org; package gnome-extra)
* xmlto (see: http://cyberelk.net/tim/xmlto)
* xml2pot, po2xml from kdesdk package (http://www.kde.org)
GNOME users: Many distributions offer a package kdesdk-utils which includes
both programs but has (almost) no further KDE dependencies
xmlto in turn requires:
* docbook-xsl-stylesheets (see: http://wiki.docbook.org/topic/DocBookXslStylesheets)
* docbook-xml-dtd (see: http://www.docbook.org/xml)
Building
--------
tar -xvzf nted-x.y.z.tgz
cd nted-x.y.z
./configure
If you want to install NtEd in a certain directory use:
./configure --prefix=
If you want to install the docs into a special directory, add
--docdir=... and/or --htmldir=... to the configure line.
If you have trouble with the documentation creation:
./configure --without-doc
Type:
make
This should create NtEd
Type (as root):
make install
This should install NtEd
If you don't like NtEd type (as root):
make uninstall
This should remove NtEd
Then start the program type:
nted
or:
nted .ntd
This should start the score editor.
First test
----------
File-->Open examples/example1.ntd
or:
File-->Open examples/example2.ntd
Press the play button You should see running red notes ans you should
hear the music. If you hear the music the
program works :-))
If not then try to change the MIDI port (
Configure-->Configure MIDI
select a port)
If nothing helps refer to the appropriate question in FAQ.
nted-1.10.18/midirecorder.cpp 0000664 0010410 0000764 00000021414 11520267230 012710 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "midirecorder.h"
#include "idiotseditor.h"
#include "resource.h"
#include
NedMidiRecorder::NedMidiRecorder(int num, int denom, int key, int midi_pgm,
int tempo_inverse, int metro_volume, bool triplet, bool f_piano, bool dnt_split) :
NedImporter(), m_error_string(NULL), m_current_time(0), m_last_event_time(0), m_metronom_running(false), m_record_started(false),
m_num(num), m_denom(denom),
m_midi_pgm(midi_pgm), m_tempo_inverse(tempo_inverse), m_metro_volume(metro_volume), m_triplet_recognition(triplet)
{
m_intervall_long = (unsigned long long) (100000000.0 * 4.0 / (double) tempo_inverse / (double) denom );
m_metronom_intervall.tv_sec = (unsigned int) (m_intervall_long / 100000);
m_metronom_intervall.tv_usec = (unsigned int) ((m_intervall_long % 100000) * 1000);
m_idiots_editor = new NedIdiotsEditor(20, 20, f_piano, false, dnt_split);
m_idiots_editor->addTimeSigChange(0, num, denom);
m_idiots_editor->addKeySig(0, 0, key);
for (int i = 0; i < 16; m_current_midi_instrument[i++] = 0);
}
void NedMidiRecorder::startMetronom() {
int pitch;
snd_seq_event_t ev;
struct timeval now;
if (NedResource::isPlaying()) return;
if (NedResource::getMidiInSequ() == NULL || NedResource::getMidiOutSequ() == NULL) return;
snd_seq_ev_clear(&ev);
ev.type = SND_SEQ_EVENT_PGMCHANGE;
ev.data.control.channel = 0;
ev.data.control.value = m_midi_pgm;
snd_seq_ev_set_subs(&ev);
snd_seq_ev_set_direct(&ev);
snd_seq_event_output_direct(NedResource::getMidiOutSequ(), &ev);
m_number_of_midi_poll_fds = snd_seq_poll_descriptors_count(NedResource::getMidiInSequ(), POLLIN);
NedMidiRecorder::m_metronom_count = 1;
m_metronom_running = true;
m_record_started = false;
pitch = 48;
gettimeofday(&now, NULL);
timeradd(&now, &m_metronom_intervall, &m_next_metronome_tick);
NedResource::playImmediately(9, 1, 1, &pitch, m_metro_volume);
g_timeout_add(4, OnMetronomTick, this);
}
gboolean NedMidiRecorder::OnMetronomTick(void *data) {
unsigned long long midi_time;
struct timeval now, diff;
int pitch = -1;
NedMidiRecorder *recorder = (NedMidiRecorder *) data;
if (!recorder->m_metronom_running) return FALSE;
gettimeofday(&now, NULL);
if (timercmp(&now, &(recorder->m_next_metronome_tick), >=)) {
pitch = (recorder->m_metronom_count++ % recorder->m_num) ? 40 : 48;
//NedResource::playImmediately(9, 1, 1, &pitch, recorder->m_metro_volume);
if (pitch == 48 && !recorder->m_record_started) {
recorder->m_record_started = true;
recorder->m_metronom_count = 1;
}
gettimeofday(&(recorder->m_last_recorder_metronom_tick), NULL);
timeradd(&(recorder->m_last_recorder_metronom_tick), &(recorder->m_metronom_intervall), &(recorder->m_next_metronome_tick));
}
if (recorder->m_record_started) {
struct pollfd *pfd = (struct pollfd *)alloca(recorder->m_number_of_midi_poll_fds * sizeof(struct pollfd));
snd_seq_poll_descriptors(NedResource::getMidiInSequ(), pfd, recorder->m_number_of_midi_poll_fds, POLLIN);
if (poll(pfd, recorder->m_number_of_midi_poll_fds, 0) > 0) {
gettimeofday(&now, NULL);
timersub(&now, &(recorder->m_last_recorder_metronom_tick), &diff);
midi_time = recorder->m_metronom_count - 1;
midi_time *= (unsigned long long) recorder->m_metronom_intervall.tv_sec * (unsigned long long) 1000 + (unsigned long long) recorder->m_metronom_intervall.tv_usec / (unsigned long long) 1000;
midi_time += (unsigned long long) diff.tv_sec * (unsigned long long) 1000 + (unsigned long long) diff.tv_usec / (unsigned long long) 1000;
midi_time *= 4 * NOTE_4;
midi_time /= recorder->m_denom;
midi_time /= recorder->m_intervall_long;
recorder->process_midi_event(midi_time);
}
}
if (pitch >= 0) {
NedResource::playImmediately(9, 1, 1, &pitch, recorder->m_metro_volume);
}
g_timeout_add(4, OnMetronomTick, data);
return FALSE;
}
void NedMidiRecorder::stopMetronom() {
m_idiots_editor->changeChannelAndPgm(0, 0, m_midi_pgm);
m_metronom_running = false;
m_record_started = false;
}
void NedMidiRecorder::process_midi_event(unsigned long long midi_time) {
snd_seq_event_t *ev;
do {
snd_seq_event_input(NedResource::getMidiInSequ(), &ev);
switch (ev->type) {
#ifdef UUU
case SND_SEQ_EVENT_CONTROLLER:
fprintf(stderr, "Control event on Channel %2d: %5d \n",
ev->data.control.channel, ev->data.control.value);
break;
case SND_SEQ_EVENT_PITCHBEND:
fprintf(stderr, "Pitchbender event on Channel %2d: %5d \n",
ev->data.control.channel, ev->data.control.value);
break;
#endif
case SND_SEQ_EVENT_NOTEON:
#ifdef UUU
fprintf(stderr, "Note On event on Channel %2d: %5d \n",
ev->data.control.channel, ev->data.note.note);
#endif
#ifdef VVV
printf("time = %llu(%llu, %llu): Note On event on Channel %2d: %5d, volume: %d\n",
LAUS(midi_time),
ev->data.control.channel, ev->data.note.note, ev->data.note.velocity);
#endif
if (ev->data.note.velocity > 0) {
m_idiots_editor->addNote(ev->data.note.note, 64, midi_time, 0, 0);
}
else {
m_idiots_editor->closeNote(ev->data.note.note, midi_time, 0, 0);
}
if (NedResource::getMidiOutSequ()) {
ev->data.control.channel = 0;
snd_seq_ev_set_subs(ev);
snd_seq_ev_set_direct(ev);
snd_seq_event_output_direct(NedResource::getMidiOutSequ(), ev);
}
m_last_event_time = midi_time;
break;
case SND_SEQ_EVENT_NOTEOFF:
#ifdef UUU
fprintf(stderr, "Note Off event on Channel %2d: %5d \n",
ev->data.control.channel, ev->data.note.note);
#endif
#ifdef VVV
printf("time = %llu(%llu, %llu): Note Off event on Channel %2d: %5d\n",
LAUS(midi_time),
ev->data.control.channel, ev->data.note.note);
#endif
m_idiots_editor->closeNote(ev->data.note.note, midi_time, 0, 0);
if (NedResource::getMidiOutSequ()) {
ev->data.control.channel = 0;
snd_seq_ev_set_subs(ev);
snd_seq_ev_set_direct(ev);
snd_seq_event_output_direct(NedResource::getMidiOutSequ(), ev);
}
m_last_event_time = midi_time;
break;
}
snd_seq_free_event(ev);
}
while (snd_seq_event_input_pending(NedResource::getMidiInSequ(), 0) > 0);
}
bool NedMidiRecorder::import() {
int i, j;
char *cptr;
m_idiots_editor->setLastTime(m_last_event_time);
m_idiots_editor->computeTimeSigMeasureNumbers(m_main_window);
m_idiots_editor->computeTempo();
m_idiots_editor->computeVolumes();
m_idiots_editor->snapStartOfNotes();
if (m_with_triplets) {
m_idiots_editor->recognizeTriplets();
}
m_idiots_editor->trySplitInstruments();
m_tempo_inverse = m_idiots_editor->m_tempo_inverse;
m_upbeat_inverse = 0;
m_partcount = m_idiots_editor->getPartCount();
for (i = 0; i < m_partcount; i++) {
m_parts[i].voices[0] = m_idiots_editor->convertToNtEdNotes(i, 0);
for (j = 1; j < VOICE_COUNT; j++) {
m_parts[i].voices[j] = m_idiots_editor->convertToNtEdNotes(i, j);
}
strcpy(m_parts[i].id, "part1");
cptr = m_idiots_editor->getInstrumentName(i);
if (cptr == NULL) {
m_parts[i].name[0] = '\0';
}
else {
if (*cptr == '\0') {
m_parts[i].name[0] = '\0';
}
else {
strcpy(m_parts[i].name, cptr);
}
}
m_parts[i].clef = m_idiots_editor->getClef(i);
m_parts[i].clef_octave = m_idiots_editor->getOctaveShift(i);
m_parts[i].key_signature = m_idiots_editor->getKeySig(i);
m_parts[i].numerator = m_idiots_editor->getNumerator();
m_parts[i].denominator = m_idiots_editor->getDenominator();
m_parts[i].midi_pgm = m_idiots_editor->getMidiPgm(i);
m_parts[i].midi_channel = 0;
m_parts[i].volume = m_idiots_editor->getVolume(i);
}
return true;
}
NedMidiRecorder::~NedMidiRecorder() {
//printf("NedMidiRecorder::~NedMidiRecorder\n"); fflush(stdout);
delete m_idiots_editor;
}
nted-1.10.18/freechordname.cpp 0000664 0010410 0000764 00000024245 11520267230 013047 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "resource.h"
#include "freechordname.h"
#include "chordorrest.h"
#include "textdialog.h"
#include "pangocairotext.h"
#include "chordnamedialog.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#define X_POS_PAGE_REL(p) ((m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
#define X_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + leftx) / zoom_factor - m_element->getPage()->getContentXpos())
#define Y_POS_PAGE_REL_INVERSE(p) (((p) / current_scale + topy - (TOP_BOTTOM_BORDER + DEFAULT_BORDER)) / zoom_factor)
#define ROOT_FONT "Sans"
#define ROOT_FONT_SLANT PANGO_STYLE_NORMAL
#define ROOT_FONT_WEIGHT PANGO_WEIGHT_NORMAL
#define UPDOWN_FONT "Sans"
#define UPDOWN_FONT_SLANT PANGO_STYLE_NORMAL
#define UPDOWN_FONT_WEIGHT PANGO_WEIGHT_NORMAL
NedChordName::NedChordName(GtkWidget *drawing_area, char *roottext, char *uptext, char *downtext, double fontsize) :
NedFreeReplaceable(), m_root_text(NULL), m_up_text(NULL), m_down_text(NULL), m_fontsize(fontsize), m_drawing_area(drawing_area) {
if (roottext != NULL && strlen(roottext) > 0) {
m_root_text = new NedPangoCairoText(drawing_area->window, roottext, ROOT_FONT, ROOT_FONT_SLANT, ROOT_FONT_WEIGHT, m_fontsize, NedResource::getStartZoomScale(), 1.0, false);
}
if (uptext != NULL && strlen(uptext) > 0) {
m_up_text = new NedPangoCairoText(drawing_area->window, uptext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
if (downtext != NULL && strlen(downtext) > 0) {
m_down_text = new NedPangoCairoText(drawing_area->window, downtext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
}
NedChordName::NedChordName(GtkWidget *drawing_area, char *roottext, char *uptext, char *downtext, double fontsize,
NedChordOrRest *element) : NedFreeReplaceable(element), m_root_text(NULL),
m_up_text(NULL), m_down_text(NULL), m_fontsize(fontsize), m_drawing_area(drawing_area) {
if (roottext != NULL && strlen(roottext) > 0) {
m_root_text = new NedPangoCairoText(drawing_area->window, roottext, ROOT_FONT, ROOT_FONT_SLANT, ROOT_FONT_WEIGHT, m_fontsize, NedResource::getStartZoomScale(), 1.0, false);
}
if (uptext != NULL && strlen(uptext) > 0) {
m_up_text = new NedPangoCairoText(drawing_area->window, uptext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
if (downtext != NULL && strlen(downtext) > 0) {
m_down_text = new NedPangoCairoText(drawing_area->window, downtext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
}
NedChordName::NedChordName(GtkWidget *drawing_area, char *roottext, char *uptext, char *downtext, double fontsize,
NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative),
m_root_text(NULL), m_up_text(NULL), m_down_text(NULL), m_fontsize(fontsize), m_drawing_area(drawing_area) {
if (roottext != NULL && strlen(roottext) > 0) {
m_root_text = new NedPangoCairoText(drawing_area->window, roottext, ROOT_FONT, ROOT_FONT_SLANT, ROOT_FONT_WEIGHT, m_fontsize, NedResource::getStartZoomScale(), 1.0, false);
}
if (uptext != NULL && strlen(uptext) > 0) {
m_up_text = new NedPangoCairoText(drawing_area->window, uptext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
if (downtext != NULL && strlen(downtext) > 0) {
m_down_text = new NedPangoCairoText(drawing_area->window, downtext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
}
NedFreeReplaceable *NedChordName::clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area /* = NULL */,
NedMainWindow *main_window /* = NULL */) {
if (drawing_area == NULL) {
NedResource::Abort("NedChordName::clone(1)");
}
NedChordName *chordname = new NedChordName(drawing_area, m_root_text->getText(), m_up_text->getText(),
m_down_text->getText(), m_fontsize, newelement, m_x, m_y, true);
return chordname;
}
NedChordName::~NedChordName() {
if (m_root_text != NULL) {
delete m_root_text;
m_root_text = NULL;
}
if (m_up_text != NULL) {
delete m_up_text;
m_up_text = NULL;
}
if (m_down_text != NULL) {
delete m_down_text;
m_down_text = NULL;
}
}
void NedChordName::adjust_pointers(struct addr_ref_str *slurlist) {
}
void NedChordName::startContextDialog(GtkWidget *ref) {
bool state;
char *newroottext;
char *newuptext;
char *newdowntext;
double dummy;
NedChordNameDialog *dialog = new NedChordNameDialog (NULL, GTK_WINDOW(ref),
m_root_text != NULL ? m_root_text->getText() : NULL,
m_up_text != NULL ? m_up_text->getText() : NULL,
m_down_text != NULL ? m_down_text->getText() : NULL, m_fontsize, -1.5, false);
dialog->getValues(&state, &newroottext, &newuptext, &newdowntext, &m_fontsize, &dummy);
if (state) {
if (m_root_text != NULL) {
delete m_root_text;
m_root_text = NULL;
}
if (m_up_text != NULL) {
delete m_up_text;
m_up_text = NULL;
}
if (m_down_text != NULL) {
delete m_down_text;
m_down_text = NULL;
}
if (newroottext != NULL) {
if (strlen(newroottext) > 0) {
m_root_text = new NedPangoCairoText(ref->window, newroottext, ROOT_FONT, ROOT_FONT_SLANT, ROOT_FONT_WEIGHT, m_fontsize, NedResource::getStartZoomScale(), 1.0, false);
}
}
if (newuptext != NULL) {
if (strlen(newuptext) > 0) {
m_up_text = new NedPangoCairoText(ref->window, newuptext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
}
if (newdowntext != NULL) {
if (strlen(newdowntext) > 0) {
m_down_text = new NedPangoCairoText(ref->window, newdowntext, UPDOWN_FONT, UPDOWN_FONT_SLANT, UPDOWN_FONT_WEIGHT, m_fontsize * 4.0/5.0, NedResource::getStartZoomScale(), 1.0, false);
}
}
}
}
#define UP_X_OFFS 0.1
#define UP_Y_OFFS -0.15
#define DOWN_X_OFFS 0.1
#define DOWN_Y_OFFS 0.2
void NedChordName::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale) {
if (m_element == NULL) return;
double xpos, ypos;
double xx, yy;
getXYPos(&xpos, &ypos);
cairo_new_path(cr);
if (isActive()) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
if (m_root_text != NULL) {
xx = scale * X_POS_PAGE_REL(xpos);
yy = scale * Y_POS_PAGE_REL(ypos) - m_root_text->getHeight() / 2.0;
m_root_text->draw(cr, xx, yy, zoom_factor, scale);
}
if (m_up_text != NULL) {
xx = scale * X_POS_PAGE_REL(xpos + UP_X_OFFS * m_fontsize / 0.5 * 4.0/5.0) + m_root_text->getInternalWidth();
yy = scale * Y_POS_PAGE_REL(ypos + UP_Y_OFFS * m_fontsize / 0.5 * 4.0/5.0) - m_root_text->getHeight() / 2.0;
m_up_text->draw(cr, xx, yy, zoom_factor, scale);
}
if (m_down_text != NULL) {
xx = scale * X_POS_PAGE_REL(xpos + DOWN_X_OFFS * m_fontsize / 0.5 * 4.0/5.0) + m_root_text->getInternalWidth();
yy = scale * Y_POS_PAGE_REL(ypos + DOWN_Y_OFFS * m_fontsize / 0.5 * 4.0/5.0) - m_root_text->getHeight() / 2.0;
m_down_text->draw(cr, xx, yy, zoom_factor, scale);
}
if (isActive()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
if (m_is_abs) {
drawConnectionInFreeText(cr, xpos, ypos, scale, leftx, topy, zoom_factor);
}
}
bool NedChordName::trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy) {
if (m_element == NULL) return false;
double xpos, ypos;
double x = X_POS_PAGE_REL_INVERSE(xl);
double y = Y_POS_PAGE_REL_INVERSE(yl);
if (m_root_text == NULL) return false;
getXYPos(&xpos, &ypos);
if (x < xpos || x > xpos + m_root_text->getWidth() / zoom_factor || y < ypos - m_root_text->getHeight() / zoom_factor || y > ypos) return false;
setThis();
return true;
}
void NedChordName::setTexts(char *roottext, char *uptext, char *downtext, double zoom) {
if (m_root_text != NULL) {
delete m_root_text;
m_root_text = NULL;
}
if (roottext != NULL && strlen(roottext) > 0) {
m_root_text->setText(roottext, zoom, false);
}
if (m_up_text != NULL) {
delete m_up_text;
m_up_text = NULL;
}
if (uptext != NULL && strlen(uptext) > 0) {
m_up_text->setText(uptext, zoom, false);
}
if (m_down_text != NULL) {
delete m_down_text;
m_down_text = NULL;
}
if (downtext != NULL && strlen(downtext) > 0) {
m_down_text->setText(downtext, zoom, false);
}
}
void NedChordName::setZoom(double zoom, double scale) {
if (m_root_text != NULL) {
m_root_text->setZoom( zoom, scale);
}
if (m_up_text != NULL) {
m_up_text->setZoom( zoom, scale);
}
if (m_down_text != NULL) {
m_down_text->setZoom(zoom, scale);
}
}
char *NedChordName::getRootText() {
if (m_root_text == NULL) return NULL;
return m_root_text->getText();
}
char *NedChordName::getUpText() {
if (m_up_text == NULL) return NULL;
return m_up_text->getText();
}
char *NedChordName::getDownText() {
if (m_down_text == NULL) return NULL;
return m_down_text->getText();
}
nted-1.10.18/freetext.h 0000664 0010410 0000764 00000007310 11520267230 011532 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef FREE_TEXT_H
#define FREE_TEXT_H
#include "freereplaceable.h"
#include
class NedPangoCairoText;
#define ANCHOR_LEFT 0
#define ANCHOR_MID 1
#define ANCHOR_RIGHT 2
class NedFreeText : public NedFreeReplaceable {
public:
NedFreeText(char *text, GtkWidget *drawing_area, int anchor, unsigned int tempo, bool enable_tempo, unsigned int volume, bool enable_volume,
unsigned short segno_sign, int midi_pgm, unsigned int channel, bool enable_channel, const char *font_family, double font_size, PangoStyle font_slant, PangoWeight font_weight);
NedFreeText(char *text, GtkWidget *drawing_area, int anchor, unsigned int tempo, bool enable_tempo, unsigned int volume, bool enable_volume,
unsigned short segno_sign, int midi_pgm, unsigned int channel, bool enable_channel, const char *font_family, double font_size, PangoStyle font_slant, PangoWeight font_weight,
NedChordOrRest *element);
NedFreeText(char *text, GtkWidget *drawing_area, int anchor, unsigned int tempo, bool enable_tempo, unsigned int volume, bool enable_volume,
unsigned short segno_sign, int midi_pgm, unsigned int channel, bool enable_channel, const char *font_family, double font_size, PangoStyle font_slant, PangoWeight font_weight,
NedChordOrRest *element,
double x, double y, bool relative);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL);
virtual void adjust_pointers(struct addr_ref_str *slurlist);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_TEXT;}
virtual void startContextDialog(GtkWidget *ref);
virtual bool trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy);
unsigned int getTempo() {return m_tempo;}
void setTempo(unsigned int tempo) {m_tempo = tempo;}
double getTempoInverse();
unsigned int m_midi_volume;
bool m_enable_volume_change, m_enable_tempo_change;
unsigned short m_segno_sign;
int m_midi_pgm;
unsigned int m_channel;
bool m_enable_channel;
char *getText();
void getLilyText(char *s);
void setText(char *text, double zoom);
virtual void setZoom(double zoom, double scale);
const char *m_font_family;
double m_font_size;
PangoStyle m_font_slant;
PangoWeight m_font_weight;
int m_anchor;
private:
unsigned int m_tempo;
NedPangoCairoText *m_text;
GtkWidget *m_drawing_area;
};
#endif /* FREE_TEXT_H */
nted-1.10.18/tuplet.cpp 0000664 0010410 0000764 00000020734 11520267230 011561 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "tuplet.h"
#include "chordorrest.h"
#include "page.h"
#include "system.h"
#include "voice.h"
#include "mainwindow.h"
#include "staff.h"
#include "beam.h"
#define X_POS_PAGE_REL(p) ((getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_STAFF_REL(p) (((p) + getSystem()->getYPos() + getStaff()->getBottomPos()) * zoom_factor - topy)
#define Y_POS_SYS_REL(p) (((p) + getSystem()->getYPos()) * zoom_factor - topy)
#define X_PS_POS(p) ((DEFAULT_BORDER + LEFT_RIGHT_BORDER + (p)) * PS_ZOOM)
#define Y_PS_POS_STAFF_REL(p) ((height - ((p) + getSystem()->getYPos() + getStaff()->getBottomPos())) * PS_ZOOM)
NedTuplet::NedTuplet(int tuplet_val, GList *chords_list, double *topy, double *boty) :
m_chords(chords_list), m_tuplet_val(tuplet_val) {
GList *lptr;
for (lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->setTupletPtr(this);
}
computeTuplet(topy, boty);
}
NedMainWindow *NedTuplet::getMainWindow() {return ((NedChordOrRest *) g_list_first(m_chords)->data)->getStaff()->getSystem()->getPage()->getMainWindow();}
NedPage *NedTuplet::getPage() {return ((NedChordOrRest *) g_list_first(m_chords)->data)->getStaff()->getSystem()->getPage();}
NedSystem *NedTuplet::getSystem() {return ((NedChordOrRest *) g_list_first(m_chords)->data)->getStaff()->getSystem();}
NedStaff *NedTuplet::getStaff() {return ((NedChordOrRest *) g_list_first(m_chords)->data)->getStaff();}
void NedTuplet::computeTuplet(/* int stemdir */ double *topy, double *boty) {
GList *lptr;
NedBeam *b;
double marker_pos;
int ups = 0, chords = 0;
NedChordOrRest *first = (NedChordOrRest *) g_list_first(m_chords)->data;
NedChordOrRest *last = (NedChordOrRest *) g_list_last(m_chords)->data;
m_start_x = first->getXPos() + first->getBBox()->x - TUPLET_XFRONTOVER;
m_end_x = last->getXPos() + last->getBBox()->x + last->getBBox()->width /*+ TUPLET_XOVER */;
switch(last->getDotCount()) {
case 1:
m_end_x += DOT1POS;
break;
case 2:
m_end_x += DOT2POS;
break;
default:
break;
}
m_up = TRUE;
m_bracket_needed = FALSE;
for(lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->isUp()) {
ups++;
}
if (!((NedChordOrRest *) lptr->data)->isRest()) {
chords++;
}
}
m_up = ups > chords / 2;
if (m_up) {
m_start_y = m_end_y = -4 * LINE_DIST;
}
else {
m_start_y = m_end_y = 0;
}
for(lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
if (!((NedChordOrRest *) lptr->data)->isRest()) {
if (m_up) {
if (((NedChordOrRest *) lptr->data)->getTopOfChordOrRest() < m_start_y) {
m_start_y = m_end_y = ((NedChordOrRest *) lptr->data)->getTopOfChordOrRest();
}
}
else {
if (((NedChordOrRest *) lptr->data)->getBottomOfChordOrRest() > m_start_y) {
m_start_y = m_end_y = ((NedChordOrRest *) lptr->data)->getBottomOfChordOrRest();
}
}
}
if (((NedChordOrRest *) lptr->data)->isRest() || ((NedChordOrRest *) lptr->data)->getBeam() == NULL) {
m_bracket_needed = TRUE;
}
}
if (m_bracket_needed) {
if (m_up) {
m_start_x += TUPLET_XOVER;
m_end_x += TUPLET_XOVER;
marker_pos = m_start_y - TUPLET_MARKER_DIST_UP - TUPLET_BRACKET_HEIGHT - NUMNBER_GLYPH_HEIGHT;
if (marker_pos + 4 * LINE_DIST - TUPLET_MARKER_HEIGHT < *topy) *topy = marker_pos + 4 * LINE_DIST - TUPLET_MARKER_HEIGHT;
}
else {
marker_pos = m_start_y + TUPLET_MARKER_DIST_DOWN + 0.3 + TUPLET_BRACKET_HEIGHT + NUMNBER_GLYPH_HEIGHT;
if (marker_pos + TUPLET_MARKER_HEIGHT > *boty) *boty = marker_pos + TUPLET_MARKER_HEIGHT;
}
}
else {
for(lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
b = ((NedChordOrRest *) lptr->data)->getBeam();
b->setTupletMarker(m_tuplet_val, topy, boty);
}
}
}
NedTuplet::~NedTuplet() {
GList *lptr;
for (lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->setTupletPtr(NULL);
}
}
unsigned long long NedTuplet::getEndTime() {
NedChordOrRest *last = (NedChordOrRest *) g_list_last(m_chords)->data;
return last->getMidiTime() + last->getDuration();
}
void NedTuplet::reconfigureLast() {
GList *lptr, *maxmidichordorrest;
unsigned int maxmiditime;
((NedChordOrRest *) g_list_first(m_chords)->data)->getVoice()->assignMidiTimes(); //recompute MIDI Times
maxmidichordorrest = lptr = g_list_first(m_chords);
maxmiditime = ((NedChordOrRest *) lptr->data)->getMidiTime();
for (lptr = g_list_next(lptr); lptr; lptr = g_list_next(lptr)) {
if (((NedChordOrRest *) lptr->data)->getMidiTime() > maxmiditime) {
maxmiditime = ((NedChordOrRest *) lptr->data)->getMidiTime();
maxmidichordorrest = lptr;
}
}
for (lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
((NedChordOrRest *) lptr->data)->setLastTupletFlag(((NedChordOrRest *) lptr->data)->getMidiTime() == maxmiditime);
}
}
void NedTuplet::draw(cairo_t *cr) {
if (!m_bracket_needed) return;
int val = m_tuplet_val;
double topy = getMainWindow()->getTopY();
double zoom_factor = getMainWindow()->getCurrentZoomFactor();
double leftx = getMainWindow()->getLeftX();
cairo_glyph_t glyph;
if (m_up) {
glyph.y = Y_POS_STAFF_REL(m_start_y - TUPLET_MARKER_DIST_UP);
}
else {
glyph.y = Y_POS_STAFF_REL(m_start_y + TUPLET_MARKER_DIST_DOWN);
}
if (m_tuplet_val > 9) {
glyph.index = NUMBERBASE + 1;
glyph.x = X_POS_PAGE_REL(m_start_x + (m_end_x - m_start_x) / 2.0 - TRIPLET_VAL_SHIFT_X - FIRST_TUPLET_DIGIT_DIST);
cairo_show_glyphs(cr, &glyph, 1);
val -= 10;
}
glyph.index = NUMBERBASE + val;
glyph.x = X_POS_PAGE_REL(m_start_x + (m_end_x - m_start_x) / 2.0 - TRIPLET_VAL_SHIFT_X);
cairo_show_glyphs(cr, &glyph, 1);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * TUPLET_LINE_THICK);
if (m_up) {
cairo_move_to(cr, X_POS_PAGE_REL(m_start_x), Y_POS_STAFF_REL(m_start_y));
cairo_line_to(cr, X_POS_PAGE_REL(m_start_x), Y_POS_STAFF_REL(m_start_y - TUPLET_BRACKET_HEIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(m_end_x), Y_POS_STAFF_REL(m_end_y - TUPLET_BRACKET_HEIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(m_end_x), Y_POS_STAFF_REL(m_end_y));
}
else {
cairo_move_to(cr, X_POS_PAGE_REL(m_start_x), Y_POS_STAFF_REL(m_start_y));
cairo_line_to(cr, X_POS_PAGE_REL(m_start_x), Y_POS_STAFF_REL(m_start_y + TUPLET_BRACKET_HEIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(m_end_x), Y_POS_STAFF_REL(m_end_y + TUPLET_BRACKET_HEIGHT));
cairo_line_to(cr, X_POS_PAGE_REL(m_end_x), Y_POS_STAFF_REL(m_end_y));
}
cairo_stroke(cr);
}
unsigned long long NedTuplet::getMidiStartTime() {
return ((NedChordOrRest *) g_list_first(m_chords)->data)->getMidiTime();
}
NedChordOrRest *NedTuplet::getFirstElement() {
return (NedChordOrRest *) g_list_first(m_chords)->data;
}
NedChordOrRest *NedTuplet::getLastElement() {
return (NedChordOrRest *) g_list_last(m_chords)->data;
}
unsigned int NedTuplet::getDuration() {
return (((NedChordOrRest *) g_list_last(m_chords)->data)->getMidiTime() + ((NedChordOrRest *) g_list_last(m_chords)->data)->getDuration() -
((NedChordOrRest *) g_list_first(m_chords)->data)->getMidiTime());
}
void NedTuplet::saveTuplet(FILE *fp) {
GList *lptr;
int marker;
fprintf(fp, "( %d ;", m_tuplet_val);
for(lptr = g_list_first(m_chords); lptr; lptr = g_list_next(lptr)) {
marker = NedResource::getMarkerOfAddress(lptr->data);
fprintf(fp, "%d ", marker);
if (lptr != g_list_last(m_chords)) {
fprintf(fp, " , ");
}
}
fprintf(fp, ")\n");
}
nted-1.10.18/freespacer.cpp 0000664 0010410 0000764 00000005501 11520267230 012356 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "freespacer.h"
#include "chordorrest.h"
#include "page.h"
#include "mainwindow.h"
#include "resource.h"
#define X_POS_PAGE_REL(p) ((m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
NedFreeSpacer::NedFreeSpacer(NedMainWindow *main_window) :
NedFreeReplaceable(), m_main_window(main_window) {}
NedFreeSpacer::NedFreeSpacer(NedMainWindow *main_window, NedChordOrRest *element) :
NedFreeReplaceable(element), m_main_window(main_window) {}
NedFreeSpacer::NedFreeSpacer(NedMainWindow *main_window, NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative), m_main_window(main_window) {}
void NedFreeSpacer::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale) {
if (m_element == NULL) return;
if (!m_main_window->getShowHidden()) return;
double xpos, ypos;
getXYPos(&xpos, &ypos);
#define FREE_SPACER_RAD 0.5
if (isActive()) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
else {
cairo_set_source_rgb (cr, 1.0, 0.0, 1.0);
}
cairo_new_path(cr);
cairo_arc(cr, X_POS_PAGE_REL(xpos), Y_POS_PAGE_REL(ypos), FREE_SPACER_RAD * zoom_level, 0.0, 2.0 * M_PI);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
if (m_is_abs) {
drawConnection(cr, xpos, ypos, leftx, topy, zoom_factor);
}
}
bool NedFreeSpacer::trySelect(double xl, double yl, double zoom_factor, double current_scale, double leftx, double topy) {
if (!m_main_window->getShowHidden()) return false;
return NedFreeReplaceable::trySelect(xl, yl, zoom_factor, current_scale, leftx, topy);
}
nted-1.10.18/positionarray.cpp 0000664 0010410 0000764 00000067011 11520267230 013146 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include "positionarray.h"
#include "chordorrest.h"
#include "resource.h"
#include "voice.h"
#include "note.h"
#define DIVISION NOTE_8
NedPosition::NedPosition(NedChordOrRest *element, int offs, unsigned int staff_count) : m_valid(true),
m_has_notes(false), m_has_unhidden_elements(false), m_has_only_staff_members(true), m_has_only_graces(true), m_max_microshift(0.0), m_step_width(0.0), m_min_duration(8* WHOLE_NOTE), m_midi_time(element->getMidiTime()),
m_min_width_after(0.0), m_min_width_before(0.0), m_acc_dist(0.0), m_needed_width(0.0), m_min_needed_width(0.0), m_staff_count(staff_count) {
m_voice_members.setLen(VOICE_COUNT * staff_count, true);
m_staff_members.setLen(staff_count, true);
m_count_of_elements_per_staff.setLen(staff_count, true);
if (element->getType() == TYPE_KEYSIG) {
return; // TODO: this shouldn't happen (???)
NedResource::Abort("TYPE_KEYSIG(1)");
}
if ((element->getType() & (TYPE_CHORD | TYPE_REST)) != 0) {
m_voice_members.insert(offs, element);
m_has_only_staff_members = false;
m_has_only_graces = false;
m_element_has_arpeggio = ((element->getStatus() & STAT_ARPEGGIO) != 0);
}
else if ((element->getType() & TYPE_GRACE) == 0) {
m_has_only_graces = false;
m_staff_members.insert(offs, element);
}
}
void NedPosition::setNewStaffCount(unsigned int newstaffcount) {
if (newstaffcount == m_staff_count) return;
//if (newstaffcount > m_staff_count) {
m_voice_members.setLen(VOICE_COUNT * newstaffcount, true);
m_staff_members.setLen(newstaffcount, true);
m_count_of_elements_per_staff.setLen(newstaffcount, true);
//}
m_staff_count = newstaffcount;
}
bool NedPosition::hasOtherStaffElements(int type) {
NedChordOrRest **ptr;
for (ptr = m_staff_members.getFirst(); ptr; ptr = m_staff_members.getNext()) {
if ((*ptr) == NULL) continue;
if ((*ptr)->getType() != type) return true;
}
return false;
}
void NedPosition::insertElement(NedChordOrRest *element, int offs) {
unsigned char c;
m_midi_time = element->getMidiTime();
m_valid = true;
m_has_only_staff_members = false;
if (element->getType() == TYPE_KEYSIG) {
NedResource::Abort("TYPE_KEYSIG(2)");
}
if (element->getType() == TYPE_CHORD) {
m_has_unhidden_elements = m_has_notes = true;
m_has_only_graces = false;
m_element_has_arpeggio = m_element_has_arpeggio || ((element->getStatus() & STAT_ARPEGGIO) != 0);
if (element->getDuration() < m_min_duration) {
m_min_duration = element->getDuration();
}
}
else if (element->getType() == TYPE_REST) {
if (!element->isHidden() || (element->getStatus() & STAT_USER_HIDDEN_REST) == 0) {
m_has_unhidden_elements = true;
}
m_has_only_graces = false;
}
if (element->getType() != TYPE_REST || (!element->isHidden() && (element->getStatus() & STAT_USER_HIDDEN_REST) == 0)) {
if (element->getBBox()->width > m_min_needed_width) {
m_min_needed_width = element->getBBox()->width;
}
if (element->getBBox()->width + element->getBBox()->x > m_min_width_after) {
m_min_width_after = element->getBBox()->width + element->getBBox()->x;
}
if (-element->getBBox()->x > m_min_width_before) {
m_min_width_before = -element->getBBox()->x;
}
}
m_voice_members.insert(offs, element);
if (element->isRest() && (element->isHidden() || (element->getStatus() & STAT_USER_HIDDEN_REST))) return;
c = m_count_of_elements_per_staff.getAt(offs / VOICE_COUNT);
m_count_of_elements_per_staff.insert(offs / VOICE_COUNT, c + 1);
}
bool NedPosition::insertStaffElement(NedChordOrRest *element, int staff_offs) {
unsigned int c;
/*
if (m_valid) {
if (m_staff_members.getAt(staff_offs) != NULL) return false;
}
*/
m_has_only_graces = false;
m_midi_time = element->getMidiTime();
m_has_unhidden_elements =
m_valid = true;
if (element->getBBox()->width > m_min_needed_width) {
m_min_needed_width = element->getBBox()->width;
}
if (element->getBBox()->width + element->getBBox()->x > m_min_width_after) {
m_min_width_after = element->getBBox()->width + element->getBBox()->x;
}
if (-element->getBBox()->x > m_min_width_before) {
m_min_width_before = -element->getBBox()->x;
}
m_staff_members.insert(staff_offs, element);
c = m_count_of_elements_per_staff.getAt(staff_offs);
m_count_of_elements_per_staff.insert(staff_offs, c + 1);
return true;
}
bool NedPosition::isUsed(int offs) {
bool res = m_voice_members.getAt(offs) != NULL;
return res;
}
void NedPosition::empty() {
m_has_unhidden_elements = m_has_notes = m_valid = false;
m_has_only_graces = m_has_only_staff_members = true;
m_max_microshift = m_min_needed_width = m_needed_width = m_min_width_after = m_min_width_before = 0.0;
m_min_duration = 8 * WHOLE_NOTE;
m_count_of_elements_per_staff.zeroArray();
if (m_voice_members.getLen() > 0) {
m_voice_members.zeroArray();
}
if (m_staff_members.getLen() > 0) {
m_staff_members.zeroArray();
}
}
void NedPosition::placeAt(double xpos, int *v_array, struct voice_properties *v_props, int mnum, bool out) {
NedChordOrRest **ptr;
int i;
if (m_has_only_staff_members) {
for (ptr = m_staff_members.getFirst(); ptr; ptr = m_staff_members.getNext()) {
if (*ptr == NULL) continue;
(*ptr)->setXPos2(xpos);
}
return;
}
if (m_has_only_graces) {
for (ptr = m_voice_members.getFirst(); ptr; ptr = m_voice_members.getNext()) {
if (*ptr == NULL) continue;
(*ptr)->setXPos2(xpos);
}
return;
}
for (i = 0, ptr = m_voice_members.getFirst(); ptr; ptr = m_voice_members.getNext(), i++) {
if (*ptr == NULL) continue;
(*ptr)->setXPos2(xpos);
if (v_array[i / VOICE_COUNT] > 1) {
if (!(*ptr)->isRest()) {
(*ptr)->changeStemDir(v_props[i].m_stem_decision);
}
}
}
}
void NedPosition::computeAccidentalPositions(int mnum, bool out) {
NedChordOrRest **ptr;
int acc_places[4];
unsigned int i, j, offs = 0;
NedNote **notes_with_accidentals = (NedNote **) alloca(MAX_NOTES_PER_WITH_ACCIDENTALS_STAFF * m_staff_count * sizeof(NedNote *));
NedNote **nptr;
unsigned int *num_notes_with_accidentals_per_staff = (unsigned int *) alloca(m_staff_count * sizeof(unsigned int));
unsigned int accidental_columns;
double acc_d;
memset(num_notes_with_accidentals_per_staff, 0, m_staff_count * sizeof(unsigned int));
m_acc_dist = 0.0;
for (i = 0, ptr = m_voice_members.getFirst(); /* offs < m_staff_count && */ ptr; ptr = m_voice_members.getNext(), i++) {
if (*ptr != NULL) {
(*ptr)->collectNotesWithAccidentals(num_notes_with_accidentals_per_staff + offs, notes_with_accidentals + MAX_NOTES_PER_WITH_ACCIDENTALS_STAFF * offs);
}
if (((i + 1) % VOICE_COUNT) == 0) {
if (num_notes_with_accidentals_per_staff[offs] > 0) {
qsort(notes_with_accidentals + offs * MAX_NOTES_PER_WITH_ACCIDENTALS_STAFF, num_notes_with_accidentals_per_staff[offs], sizeof(NedNote *),
(int (*) (const void *, const void *)) NedNote::compare_note_lines);
}
offs++;
}
}
accidental_columns = 0;
for (i = 0; i < m_staff_count; i++) {
nptr = notes_with_accidentals + MAX_NOTES_PER_WITH_ACCIDENTALS_STAFF * i;
acc_places[0] = acc_places[1] = acc_places[2] = acc_places[3] = -10000;
for (j = 0; j < num_notes_with_accidentals_per_staff[i]; j++, nptr++) {
acc_d = (*nptr)->placeAccidental(FALSE /*all_shifted*/, acc_places, m_element_has_arpeggio, out && mnum == 1);
if (acc_d > m_acc_dist) m_acc_dist = acc_d;
}
}
}
void NedPosition::computeMicroShifts(int mnum, int pos, bool out) {
NedChordOrRest **p_staff, **p_voice1, **p_voice2;
double microshift;
for (p_staff = m_voice_members.getFirst(); p_staff; p_staff = m_voice_members.skip(VOICE_COUNT)) {
for (p_voice1 = m_voice_members.getFirst2(VOICE_COUNT); p_voice1; p_voice1 = m_voice_members.getNext2()) {
if (*p_voice1 == NULL) continue;
if ((*p_voice1)->getType() != TYPE_CHORD) continue;
(*p_voice1)->resetMicroshift();
}
for (p_voice1 = m_voice_members.getFirst2(VOICE_COUNT); p_voice1; p_voice1 = m_voice_members.getNext2()) {
if (*p_voice1 == NULL) continue;
if ((*p_voice1)->getType() != TYPE_CHORD) continue;
for (p_voice2 = m_voice_members.getFirst3(); p_voice2; p_voice2 = m_voice_members.getNext3()) {
if (*p_voice2 == NULL) continue;
if ((*p_voice2)->getType() != TYPE_CHORD) continue;
/*
if (out) {
printf("mnum = %d, voi1 = %d, voi2 = %d\n", mnum, (*p_voice1)->getVoice()->getVoiceNumber(), (*p_voice2)->getVoice()->getVoiceNumber()); fflush(stdout);
}
*/
microshift = (*p_voice1)->compute_microshift(*p_voice2, mnum, pos);
if (microshift > m_max_microshift) m_max_microshift = microshift;
}
}
}
}
void NedPosition::shiftXpos(double xshift, int mnum, int pos) {
NedChordOrRest **ptr;
if (m_has_only_staff_members) {
for (ptr = m_staff_members.getFirst(); ptr; ptr = m_staff_members.getNext()) {
if (*ptr == NULL) continue;
(*ptr)->shiftX(xshift);
}
return;
}
for (ptr = m_voice_members.getFirst(); ptr; ptr = m_voice_members.getNext()) {
if (*ptr == NULL) continue;
(*ptr)->shiftX(xshift);
}
}
bool NedPosition::hasNote() {
NedChordOrRest **ptr;
for (ptr = m_voice_members.getFirst(); ptr; ptr = m_voice_members.getNext()) {
if (*ptr == NULL) continue;
if (!(*ptr)->isRest()) return true;
}
return false;
}
void NedPosition::placeRests(struct voice_properties *vprops) {
int i, j;
NedChordOrRest **st_ptr, **ptr1, **ptr2, **pterm1, **pterm2;
unsigned int st, ii;
double shift;
int *notes_available = (int *) alloca(m_staff_count * sizeof(int));
memset(notes_available, 0, m_staff_count * sizeof(int));
for (ii = 0, ptr1 = m_voice_members.getFirst(); ptr1; ptr1 = m_voice_members.getNext(), ii++) {
if (*ptr1 == NULL) continue;
if ((*ptr1)->isRest()) continue;
notes_available[ii / VOICE_COUNT] = 1;
}
for (st = 0, st_ptr = m_voice_members.getFirst(); st_ptr; st_ptr = m_voice_members.skip(VOICE_COUNT), st++) {
if (m_count_of_elements_per_staff.getAt(st) < 2) continue;
pterm1 = st_ptr + VOICE_COUNT - 1;
pterm2 = st_ptr + VOICE_COUNT;
for (i = 0, ptr1 = st_ptr; ptr1 < pterm1; ptr1++, i++) {
if (*ptr1 == NULL) continue;
if ((*ptr1)->isRest() && ((*ptr1)->isHidden() || ((*ptr1)->getStatus() & (STAT_USER_PLACED_REST | STAT_USER_HIDDEN_REST)))) continue;
for (j = i+1, ptr2 = ptr1 + 1; ptr2 < pterm2; ptr2++, j++) {
if (*ptr2 == NULL) continue;
if (!(*ptr2)->isRest()) continue;
if ((*ptr2)->isHidden()) continue;
if ((*ptr2)->getStatus() & (STAT_USER_PLACED_REST | STAT_USER_HIDDEN_REST)) continue;
shift = (*ptr1)->compute_y_shift(*ptr2, vprops[st * VOICE_COUNT + j].m_stem_decision);
if (shift > 0.0) {
if (vprops[st * VOICE_COUNT + j].m_stem_decision == STEM_DIR_DOWN) {
(*ptr2)->shiftY(shift);
}
else {
(*ptr2)->shiftY(-shift);
}
}
}
}
for (i = VOICE_COUNT - 1, ptr1 = st_ptr + VOICE_COUNT - 1; ptr1 > st_ptr; ptr1--, i--) {
if (*ptr1 == NULL) continue;
if ((*ptr1)->isRest() && ((*ptr1)->isHidden() || ((*ptr1)->getStatus() & (STAT_USER_PLACED_REST | STAT_USER_HIDDEN_REST)))) continue;
pterm2 = notes_available[st] ? st_ptr : st_ptr + 1;
for (j = i - 1, ptr2 = ptr1 - 1; ptr2 >= st_ptr; ptr2--, j--) {
if (*ptr2 == NULL) continue;
if (!(*ptr2)->isRest()) continue;
if ((*ptr2)->isHidden()) continue;
if ((*ptr2)->getStatus() & (STAT_USER_PLACED_REST | STAT_USER_HIDDEN_REST)) continue;
shift = (*ptr1)->compute_y_shift(*ptr2, vprops[st * VOICE_COUNT + j].m_stem_decision);
if (shift > 0.0) {
if (vprops[st * VOICE_COUNT + j].m_stem_decision == STEM_DIR_DOWN) {
(*ptr2)->shiftY(shift);
}
else {
(*ptr2)->shiftY(-shift);
}
}
}
}
}
}
#ifdef UUU
bool NedPosition::print() {
unsigned int i;
bool b = false;
printf("-----------------------\n");
for (i = 0; i < m_voice_members->len; i++) {
//if (((NedChordOrRest *) m_members->pdata[i])->getType() != TYPE_CHORD) continue;
if (((NedChordOrRest *) m_voice_members->pdata[i])->getVoice()->getVoiceNumber() != 0) continue;
b = true;
printf("\t%s: TIME: %llu dur: %u pos = %f\n", ((NedChordOrRest *) m_voice_members->pdata[i])->isRest() ? "Rest" : "Note",
((NedChordOrRest *) m_voice_members->pdata[i])->getMidiTime() / DIVISION,
((NedChordOrRest *) m_voice_members->pdata[i])->getDuration() / DIVISION,
((NedChordOrRest *) m_voice_members->pdata[i])->getXPos());
}
return b;
}
#endif
NedPositionArray::NedPositionArray() : m_staff_count(0), m_min_duration(2 * WHOLE_NOTE) {}
NedPositionArray::~NedPositionArray() {
NedPosition **ptr;
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
delete (*ptr);
}
}
int NedPositionArray::compare_positions(NedPosition **pos1, NedPosition **pos2) {
if (!(*pos1)->m_valid && !(*pos2)->m_valid) return 0;
if (!(*pos1)->m_valid) return 1;
if (!(*pos2)->m_valid) return -1;
if ((*pos1)->m_midi_time == (*pos2)->m_midi_time) {
if ((*pos1)->m_has_only_staff_members && (*pos2)->m_has_only_staff_members) return 0;
if ((*pos1)->m_has_only_staff_members) return -1;
if ((*pos2)->m_has_only_staff_members) return 1;
if ((*pos1)->m_has_only_graces && (*pos2)->m_has_only_graces) return -1;
if ((*pos1)->m_has_only_graces) return -1;
if ((*pos2)->m_has_only_graces) return 1;
}
if ((*pos1)->m_midi_time < (*pos2)->m_midi_time) return -1;
return 1;
}
void NedPositionArray::insertElement(NedChordOrRest *element, int offs, int mnum) {
NedPosition *pos_ptr;
NedPosition **ptr;
struct voice_properties *np_ptr;
np_ptr = m_voice_properties.getPointerAt(offs);
if (element->getType() & TYPE_CHORD) {
np_ptr->m_note_count++;
np_ptr->m_line_sum += element->getLineOfLowestNote();
}
if ((element->getType() & TYPE_REST) && !element->isHidden() && (element->getStatus() & STAT_USER_HIDDEN_REST) == 0) {
if (np_ptr == NULL) {
printf("(element->getType() = 0x%x\n", element->getType()); fflush(stdout);
}
np_ptr->m_rests_count++;
}
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
if (!(*ptr)->m_valid) continue;
if ((*ptr)->m_has_only_staff_members) continue;
if ((*ptr)->m_has_only_graces) continue;
if ((*ptr)->m_midi_time == element->getMidiTime()) {
(*ptr)->insertElement(element, offs);
if (element->getType() == TYPE_CHORD && (*ptr)->m_min_duration < m_min_duration) {
m_min_duration = (*ptr)->m_min_duration;
}
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
return;
}
}
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
if (!(*ptr)->m_valid) {
(*ptr)->insertElement(element, offs);
if (element->getType() == TYPE_CHORD && (*ptr)->m_min_duration < m_min_duration) {
m_min_duration = (*ptr)->m_min_duration;
}
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
return;
}
}
pos_ptr = new NedPosition(element, offs, m_staff_count);
m_positions.append(pos_ptr);
if (element->getType() == TYPE_CHORD && element->getDuration() < m_min_duration) {
m_min_duration = element->getDuration();
}
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
}
void NedPositionArray::insertStaffElement(NedChordOrRest *element, int staff_offs, int mnum) {
NedPosition *pos_ptr;
NedPosition **ptr;
int type = element->getType();
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
if (!(*ptr)->m_valid) continue;
if ((*ptr)->m_has_only_graces) continue;
if (!(*ptr)->m_has_only_staff_members) continue;
if ((*ptr)->hasOtherStaffElements(type)) continue;
if ((*ptr)->m_midi_time == element->getMidiTime()) {
if (!(*ptr)->insertStaffElement(element, staff_offs)) break;
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
return;
}
}
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
if (!(*ptr)->m_valid) {
(*ptr)->insertStaffElement(element, staff_offs);
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
return;
}
}
pos_ptr = new NedPosition(element, staff_offs, m_staff_count);
m_positions.append(pos_ptr);
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
}
void NedPositionArray::insertGraceElement(NedChordOrRest *element, int offs, int mnum) {
NedPosition *pos_ptr;
NedPosition **ptr;
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
if (!(*ptr)->m_valid) continue;
if ((*ptr)->m_has_only_staff_members) continue;
if (!(*ptr)->m_has_only_graces) continue;
if ((*ptr)->m_midi_time == element->getMidiTime()) {
if ((*ptr)->isUsed(offs)) break;
(*ptr)->insertElement(element, offs);
(*ptr)->m_has_unhidden_elements = true;
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
return;
}
}
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
if (!(*ptr)->m_valid) {
(*ptr)->m_has_unhidden_elements = true;
(*ptr)->insertElement(element, offs);
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
return;
}
}
pos_ptr = new NedPosition(element, offs, m_staff_count);
m_positions.append(pos_ptr);
//m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
}
void NedPositionArray::empty() {
NedPosition **ptr;
m_min_duration = 8 * WHOLE_NOTE;
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
(*ptr)->empty();
}
m_voice_properties.zeroArray();
}
void NedPositionArray::setNewStaffCount(unsigned int newstaffcount) {
NedPosition **ptr;
if (newstaffcount > m_staff_count) {
m_voice_properties.setLen(VOICE_COUNT * newstaffcount, false);
}
m_staff_count = newstaffcount;
for (ptr = m_positions.getFirst(); ptr; ptr = m_positions.getNext()) {
(*ptr)->setNewStaffCount(newstaffcount);
}
}
double NedPositionArray::shiftXpos(double extra_space_divided, double shift, int mnum, bool out) {
NedPosition **ptr, **last = 0;
int i;
for (i = 0, ptr = m_positions.getFirst(); ptr; last = ptr, ptr = m_positions.getNext(), i++) {
if (!(*ptr)->m_valid) continue;
shift += extra_space_divided;
if (last == NULL) {
if ((*ptr)->m_acc_dist > (*ptr)->m_step_width) {
shift += (*ptr)->m_acc_dist - ((*ptr)->m_step_width);
}
}
else {
if ((*ptr)->m_acc_dist > (*ptr)->m_step_width - (*last)->m_min_width_after) {
shift += (*ptr)->m_acc_dist - ((*ptr)->m_step_width - (*last)->m_min_width_after);
}
}
//shift += (*ptr)->m_acc_dist;
(*ptr)->shiftXpos(shift, mnum, i);
}
return shift;
}
struct v_params_str{
char voice_number;
char valid;
double av;
};
double NedPositionArray::computeAndSetPositions(double start_position, int *num_elements, double *extra_space_for_accidentals, bool *measure_has_only_staff_members /* means keysig */, double timesig_space, int mnum, double spread_fac, bool out) {
NedPosition **p_first_valid = NULL, **p_last_valid, **p_next_valid;
struct voice_properties *p_vp;
struct v_params_str vparams[VOICE_COUNT];
double highest;
int h_idx = 0;
bool taken;
double last_width_after, last_micro_shifts = 0.0;
unsigned int last_duration;
unsigned int mid;
unsigned int i, j, k;
int num_distances = 0;
unsigned long long dist, mindist = 2 * WHOLE_NOTE;
double step_width, min_step_width;
int *num_voices = (int *) alloca(sizeof(int) * m_staff_count);
int *num_notes = (int *) alloca(sizeof(int) * m_staff_count);
m_positions.sort((gint (*)(const void*, const void*)) compare_positions);
memset(num_voices, 0, sizeof(int) * m_staff_count);
memset(num_notes, 0, sizeof(int) * m_staff_count);
for (i = 0; i < m_staff_count; i++) {
for (j = 0; j < VOICE_COUNT; j++) {
vparams[j].voice_number = j;
if (m_voice_properties.getAt(VOICE_COUNT * i + j).m_note_count > 0) {
num_voices[i]++;
num_notes[i]++;
}
else if (m_voice_properties.getAt(VOICE_COUNT * i + j).m_rests_count > 0) {
num_voices[i]++;
}
}
}
p_vp = m_voice_properties.getArray();
for (i = 0; i < m_staff_count; i++, p_vp += VOICE_COUNT) {
if (num_notes[i] > 1) {
for (j = 0; j < VOICE_COUNT; j++) {
vparams[j].voice_number = j;
if (p_vp[j].m_note_count > 0) {
vparams[j].av = (double) p_vp[j].m_line_sum / (double) p_vp[j].m_note_count;
vparams[j].valid = true;
}
else {
vparams[j].av = 100000.0;
vparams[j].valid = false;
}
}
mid = num_notes[i] / 2;
k = 0;
do {
taken = false;
highest = -20000.0;
for (j = 0; j < VOICE_COUNT; j++) {
if (!vparams[j].valid) continue;
if (vparams[j].av > highest) {
h_idx = j;
highest = vparams[j].av;
taken = true;
}
}
if (taken) {
if (h_idx < 0 || h_idx >= VOICE_COUNT) {
NedResource::Abort("hidx");
}
vparams[h_idx].valid = false;
p_vp[h_idx].m_stem_decision = k++ < mid ? STEM_DIR_UP : STEM_DIR_DOWN;
}
}
while (taken);
}
}
m_min_durations_dist = 0.0;
last_width_after = 0.0;
last_duration = 0;
for (p_last_valid = m_positions.getFirst(); p_last_valid; p_last_valid = m_positions.getNext()) {
if ((*p_last_valid)->m_valid) {
(*p_last_valid)->computeAccidentalPositions(mnum, out);
if ((*p_last_valid)->m_has_notes) {
last_duration = (*p_last_valid)->m_min_duration;
last_width_after = (*p_last_valid)->m_min_width_after;
}
break;
}
}
p_first_valid = p_last_valid;
p_next_valid = m_positions.getNext();
while (p_next_valid) {
if ((*p_next_valid)->m_valid) {
(*p_next_valid)->computeAccidentalPositions(mnum, out);
dist = (*p_next_valid)->m_midi_time - (*p_last_valid)->m_midi_time;
if (dist < mindist) {
mindist = dist;
}
if (last_duration == m_min_duration) {
if (last_width_after + (*p_next_valid)->m_min_width_before > m_min_durations_dist)
m_min_durations_dist = last_width_after + (*p_next_valid)->m_min_width_before;
}
if ((*p_next_valid)->m_has_notes) {
last_duration = (*p_next_valid)->m_min_duration;
last_width_after = (*p_next_valid)->m_min_width_after;
}
/*
else {
last_duration = 0;
}
*/
p_last_valid = p_next_valid;
num_distances++;
}
p_next_valid = m_positions.getNext();
}
if (num_distances == 0 && p_first_valid != NULL && (*p_first_valid) != NULL && /* staff members i.e. keysigs have teir own values */ !(*p_first_valid)->m_has_only_staff_members ) {
(*p_first_valid)->m_needed_width = 2 * WHOLE_EXTRA_SPACE;
(*p_first_valid)->m_min_needed_width = 2 * WHOLE_EXTRA_SPACE;
(*p_first_valid)->m_min_width_after = WHOLE_EXTRA_SPACE;
(*p_first_valid)->m_min_width_before = WHOLE_EXTRA_SPACE;
m_min_durations_dist = 2 * WHOLE_EXTRA_SPACE;
}
else {
#define MAX_MINDURATIONS_DIST 1.0
if (m_min_durations_dist > MAX_MINDURATIONS_DIST) m_min_durations_dist = MAX_MINDURATIONS_DIST;
}
last_width_after = last_micro_shifts = 0.0;
bool last_round_had_a_grace = false;
int pos = 0;
for (i = 0, p_next_valid = m_positions.getFirst(); p_next_valid; p_next_valid = m_positions.getNext()) {
if (!(*p_next_valid)->m_valid) continue;
(*num_elements)++;
(*p_next_valid)->computeMicroShifts(mnum, pos++, out && mnum == 1);
min_step_width = last_width_after + last_micro_shifts + (*p_next_valid)->m_min_width_before;
if (p_next_valid != NULL) {
if ((*p_next_valid)->m_has_notes) {
*measure_has_only_staff_members = false;
if (i == 0) {
step_width = 0.0; // avoid additional gap behind bar line
}
timesig_space = 0.0; // add only if staff element is at first place
step_width = 1.4 * HEAD_THICK + (double) ((*p_next_valid)->m_min_duration) / (double) (m_min_duration) * 0.2 * HEAD_THICK;
if (step_width < min_step_width) step_width = min_step_width;
if (last_round_had_a_grace) {
step_width = 1.5 * HEAD_THICK;
last_round_had_a_grace = false;
}
}
else if ((*p_next_valid)->m_has_only_staff_members) {
if (i == 0) {
step_width = 0.0; // avoid additional gap behind bar line
}
else {
step_width = min_step_width;
timesig_space = 0.0; // add only if staff element is at first place
}
last_round_had_a_grace = false;
}
else if ((*p_next_valid)->m_has_only_graces) {
step_width = 0.9 * HEAD_THICK; // rest
timesig_space = 0.0; // add only if staff element is at first place
*measure_has_only_staff_members = false;
last_round_had_a_grace = true;
}
else {
step_width = 1.4 * HEAD_THICK; // rest
timesig_space = 0.0; // add only if staff element is at first place
*measure_has_only_staff_members = false;
if (step_width < min_step_width) step_width = min_step_width;
last_round_had_a_grace = false;
}
}
else {
step_width = min_step_width;
*measure_has_only_staff_members = false;
timesig_space = 0.0; // add only if staff element is at first place
last_round_had_a_grace = false;
}
step_width *= spread_fac;
if ((*p_next_valid)->m_has_unhidden_elements) {
start_position += step_width;
}
(*p_next_valid)->placeAt(start_position, num_voices, m_voice_properties.getArray(), mnum, out);
start_position += timesig_space; // If bar has a timesig then additional space is needed after an eventuall staff element (keysig)
/*
#define EXTRA_DIST 0.01
step_width += EXTRA_DIST;
if (out) {
printf("mnum = %d, pos = %d, need = %f, step = %f\n",
mnum, i, (*p_last_valid)->m_min_needed_width, step_width);
fflush(stderr);
}
*/
(*p_next_valid)->m_step_width = step_width - last_micro_shifts;
if ((*p_next_valid)->m_acc_dist > step_width - last_micro_shifts - last_width_after) {
(*extra_space_for_accidentals) += (*p_next_valid)->m_acc_dist - (step_width - last_micro_shifts -last_width_after);
}
/*
if (out) {
printf("mnum = %d, pos = %d, m_acc_dist = %f\n",
mnum, i, (*p_last_valid)->m_acc_dist); fflush(stderr);
}
*/
//(*extra_space_for_accidentals) += (*p_last_valid)->m_acc_dist;
if ((*p_next_valid)->m_has_only_graces) {
last_round_had_a_grace = true;
}
last_width_after = (*p_next_valid)->m_min_width_after;
last_micro_shifts = (*p_next_valid)->m_max_microshift;
i++;
}
start_position += last_width_after + last_micro_shifts;
for (p_last_valid = m_positions.getFirst(); p_last_valid; p_last_valid = m_positions.getNext()) {
if (!(*p_last_valid)->m_valid) continue;
(*p_last_valid)->placeRests(m_voice_properties.getArray());
}
return start_position;
}
int NedPositionArray::getStemDirectionOfTheMeasure(int m_staff_voice_offs) {
if (m_voice_properties.getLen() < 1) return STEM_DIR_NONE;
if (m_voice_properties.getLen() <= m_staff_voice_offs / sizeof(struct voice_properties)) return STEM_DIR_NONE;
return m_voice_properties.getAt(m_staff_voice_offs).m_stem_decision;
}
#ifdef UUU
void NedPositionArray::print() {
unsigned int i;
bool b = false;
for (i = 0; i < m_positions->len; i++) {
if (((NedPosition *) m_positions->pdata[i])->m_valid) {
if (((NedPosition *) m_positions->pdata[i])->print()) {
b = true;
}
}
if (b) {
putchar('\n');
}
}
fflush(stdout);
}
#endif
nted-1.10.18/temposign.h 0000664 0010410 0000764 00000004554 11520267230 011720 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#ifndef TEMPO_SIGN_H
#define TEMPO_SIGN_H
#include "freereplaceable.h"
class NedTempoSign : public NedFreeReplaceable {
public:
NedTempoSign(unsigned int kind, unsigned int tempo);
NedTempoSign(unsigned int kind, unsigned int tempo, NedChordOrRest *element);
NedTempoSign(unsigned int kind, unsigned int tempo, NedChordOrRest *element, double x, double y, bool relative);
virtual NedFreeReplaceable *clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area = NULL, NedMainWindow *main_window = NULL);
virtual void adjust_pointers(struct addr_ref_str *slurlist);
virtual void draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale);
virtual int getType() {return FREE_PLACEABLE_TEMPO;}
unsigned int getKind() {return m_kind;}
unsigned int getTempo() {return m_tempo;}
void setTempo(unsigned int kind, unsigned int tempo);
virtual void startContextDialog(GtkWidget *ref);
double getTempoInverse();
bool getDot() {return m_dot;}
private:
void computeGlypths();
unsigned int m_kind;
unsigned int m_tempo;
cairo_glyph_t m_glyphs[3];
int m_number_len;
bool m_dot;
};
#endif /* TEMPO_SIGN_H */
nted-1.10.18/linepoint.cpp 0000664 0010410 0000764 00000013273 11520267230 012245 0000000 0000000 /****************************************************************************************/
/* */
/* This program is free software; you can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along with this */
/* program; (See "COPYING"). If not, If not, see . */
/* */
/*--------------------------------------------------------------------------------------*/
/* */
/* Copyright Joerg Anders, TU Chemnitz, Fakultaet fuer Informatik, GERMANY */
/* ja@informatik.tu-chemnitz.de */
/* */
/* */
/****************************************************************************************/
#include
#include "linepoint.h"
#include "line.h"
#include "chordorrest.h"
#include "staff.h"
#include "system.h"
#include "page.h"
#include "line3.h"
#define X_POS_PAGE_REL(p) ((m_element->getPage()->getContentXpos() + (p)) * zoom_factor - leftx)
#define Y_POS_PAGE_REL(p) ((p) * zoom_factor - topy)
NedLinePoint::NedLinePoint(NedLine *line, int p_nr) : NedFreeReplaceable(), m_point_number(p_nr), m_line(line) {}
NedLinePoint::NedLinePoint(NedLine *line, int p_nr, NedChordOrRest *element) : NedFreeReplaceable(element), m_point_number(p_nr), m_line(line) {}
NedLinePoint::NedLinePoint(NedLine *line, int p_nr, NedChordOrRest *element, double x, double y, bool relative) :
NedFreeReplaceable(element, x, y, relative), m_point_number(p_nr), m_line(line) {}
NedFreeReplaceable *NedLinePoint::clone(struct addr_ref_str **slurlist, NedChordOrRest *newelement, GtkWidget *drawing_area /*= NULL */, NedMainWindow *main_window /* = NULL */) {
return NULL;
}
void NedLinePoint::adjust_pointers(struct addr_ref_str *slurlist) {
}
void NedLinePoint::getXYPosAndStaff(double *xpos, double *ypos, NedStaff **staff) {
getXYPos(xpos, ypos);
*staff = m_element->getStaff();
}
void NedLinePoint::startContextDialog(GtkWidget *ref) {
if (m_line != NULL) {
m_line->startContextDialog(ref);
}
}
NedStaff *NedLinePoint::getStaff() {
return m_element->getStaff();
}
NedLinePoint *NedLinePoint::getLineStartPoint() {
return m_line->getLineStartPoint();
}
NedLinePoint *NedLinePoint::getLineEndPoint() {
return m_line->getLineEndPoint();
}
void NedLinePoint::draw(cairo_t *cr, double leftx, double topy, double zoom_factor, int zoom_level, double scale) {
double xpos, ypos;
if (m_element == NULL) return;
if (isActive()) {
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
}
#define RECT_D 0.1
if (m_line == NULL || m_line->isActive()) {
getXYPos(&xpos, &ypos);
cairo_new_path(cr);
cairo_set_line_width(cr, zoom_factor * LINE_THICK);
cairo_rectangle(cr, X_POS_PAGE_REL(xpos - RECT_D / 2.0) , Y_POS_PAGE_REL(ypos -RECT_D / 2.0) , zoom_factor * RECT_D, zoom_factor * RECT_D);
cairo_stroke(cr);
}
if (m_point_number == 1 && m_line != NULL) {
m_line->draw(cr, leftx, topy, zoom_factor, zoom_level);
}
if (isActive()) {
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
}
if (m_is_abs) {
drawConnection(cr, xpos, ypos, leftx, topy, zoom_factor);
}
}
void NedLinePoint::recompute() {
if (m_line) {
m_line->computeParams();
}
}
void NedLinePoint::toRel() {
if (m_line) {
m_line->setAllPointsToRel(this);
}
NedFreeReplaceable::toRel();
}
void NedLinePoint::toRel2() {
NedFreeReplaceable::toRel();
}
void NedLinePoint::shift(double x, double y, double zoom_factor, double current_scale, double leftx, double topy) {
NedLinePoint *startp, *endp, *midp;
double staffdist;
if (m_line) {
startp = m_line->getLineStartPoint();
endp = m_line->getLineEndPoint();
if (m_line->isLine3()) {
midp = ((NedLine3 *) m_line)->getLineMidPoint();
if (endp == this || startp == this) {
NedFreeReplaceable::shiftOnlyX(x, y, zoom_factor, current_scale, leftx, topy);
}
else if (midp == this) {
NedFreeReplaceable::shift(x, y, zoom_factor, current_scale, leftx, topy);
staffdist = startp->m_element->getSystem()->getYPos() + startp->m_element->getStaff()->getMidPos() - (
midp->m_element->getSystem()->getYPos() + midp->m_element->getStaff()->getMidPos());
startp->shiftOnlyY(m_element->getStaff()->getStaffNumber(), y + staffdist * zoom_factor, zoom_factor, current_scale, leftx, topy);
staffdist = endp->m_element->getSystem()->getYPos() + endp->m_element->getStaff()->getMidPos() - (
midp->m_element->getSystem()->getYPos() + midp->m_element->getStaff()->getMidPos());
endp->shiftOnlyY(m_element->getStaff()->getStaffNumber(), y + staffdist * zoom_factor, zoom_factor, current_scale, leftx, topy);
}
}
else {
if (endp == this) {
NedFreeReplaceable::shiftOnlyX(x, y, zoom_factor, current_scale, leftx, topy);
}
else if (startp == this) {
NedFreeReplaceable::shift(x, y, zoom_factor, current_scale, leftx, topy);
staffdist = endp->m_element->getSystem()->getYPos() + endp->m_element->getStaff()->getMidPos() - (
startp->m_element->getSystem()->getYPos() + startp->m_element->getStaff()->getMidPos());
endp->shiftOnlyY(m_element->getStaff()->getStaffNumber(), y + staffdist * zoom_factor, zoom_factor, current_scale, leftx, topy);
}
}
m_line->computeParams();
return;
}
NedFreeReplaceable::shift(x, y, zoom_factor, current_scale, leftx, topy);
if (m_line) {
m_line->computeParams();
}
}
nted-1.10.18/config.rpath 0000664 0010410 0000764 00000043647 11520267230 012055 0000000 0000000 #! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2007 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit , 1996
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's _LT_CC_BASENAME.
for cc_temp in $CC""; do
case $cc_temp in
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
darwin*)
case $cc_basename in
xlc*)
wl='-Wl,'
;;
esac
;;
mingw* | cygwin* | pw32* | os2*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux* | k*bsd*-gnu)
case $cc_basename in
icc* | ecc*)
wl='-Wl,'
;;
pgcc | pgf77 | pgf90)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*)
wl='-Wl,'
;;
esac
;;
esac
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
rdos*)
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3*)
wl='-Wl,'
;;
sysv4*MP*)
;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
wl='-Wl,'
;;
unicos*)
wl='-Wl,'
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we cannot use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
interix[3-9]*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
gnu* | linux* | k*bsd*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris*)
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
ld_shlibs=no
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
else
ld_shlibs=no
fi
;;
esac
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = no; then
hardcode_libdir_flag_spec=
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
;;
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
:
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
;;
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
bsdi[45]*)
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
hardcode_direct=no
if test "$GCC" = yes ; then
:
else
case $cc_basename in
xlc*)
;;
*)
ld_shlibs=no
;;
esac
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd* | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
fi
;;
hpux11*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
case $host_cpu in
hppa*64*|ia64*)
hardcode_direct=no
;;
*)
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
else
ld_shlibs=no
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
;;
sysv5* | sco3.2v5* | sco5v6*)
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
hardcode_libdir_separator=':'
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
# only about the one the linker finds when passed -lNAME. This is the last
# element of library_names_spec in libtool.m4, or possibly two of them if the
# linker has special search rules.
library_names_spec= # the last element of library_names_spec in libtool.m4
libname_spec='lib$name'
case "$host_os" in
aix3*)
library_names_spec='$libname.a'
;;
aix4* | aix5*)
library_names_spec='$libname$shrext'
;;
amigaos*)
library_names_spec='$libname.a'
;;
beos*)
library_names_spec='$libname$shrext'
;;
bsdi[45]*)
library_names_spec='$libname$shrext'
;;
cygwin* | mingw* | pw32*)
shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;;
darwin* | rhapsody*)
shrext=.dylib
library_names_spec='$libname$shrext'
;;
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd1*)
;;
freebsd* | dragonfly*)
case "$host_os" in
freebsd[123]*)
library_names_spec='$libname$shrext$versuffix' ;;
*)
library_names_spec='$libname$shrext' ;;
esac
;;
gnu*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
library_names_spec='$libname$shrext'
;;
interix[3-9]*)
library_names_spec='$libname$shrext'
;;
irix5* | irix6* | nonstopux*)
library_names_spec='$libname$shrext'
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux* | k*bsd*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
library_names_spec='$libname$shrext'
;;
netbsd*)
library_names_spec='$libname$shrext'
;;
newsos6)
library_names_spec='$libname$shrext'
;;
nto-qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
library_names_spec='$libname$shrext$versuffix'
;;
os2*)
libname_spec='$name'
shrext=.dll
library_names_spec='$libname.a'
;;
osf3* | osf4* | osf5*)
library_names_spec='$libname$shrext'
;;
rdos*)
;;
solaris*)
library_names_spec='$libname$shrext'
;;
sunos4*)
library_names_spec='$libname$shrext$versuffix'
;;
sysv4 | sysv4.3*)
library_names_spec='$libname$shrext'
;;
sysv4*MP*)
library_names_spec='$libname$shrext'
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <