1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
/*************************************************
* The PMW Music Typesetter - 3rd incarnation *
*************************************************/
/* Copyright (c) Philip Hazel, 1991 - 2008 */
/* Written by Philip Hazel, starting November 1991 */
/* This file last modified: September 2008 */
/* This file contains code for outputting nth time bar markings */
#include "pmwhdr.h"
#include "outhdr.h"
#include "pagehdr.h"
/*************************************************
* Deal with start of nth time bar *
*************************************************/
/* This function remembers the data for the start.
Arguments:
nb the data for the start
x the x coordinate of the start
miny minimum y coordinate - used to align multiple such markings
Returns: nothing
*/
void
out_setstartnbar(b_nbarstr *nb, int x, int miny)
{
nbarstr *nbb = store_Xget(sizeof(nbarstr));
nbb->next = NULL;
nbb->nbar = nb;
nbb->x = x;
nbb->maxy = -BIGNUMBER;
nbb->miny = miny;
bar_cont->nbar = nbb;
}
/*************************************************
* Free store for an nth time marking *
*************************************************/
/* This frees all the remembered data.
Arguments: none
Returns: nothing
*/
void
out_freenbar(void)
{
nbarstr *nb = bar_cont->nbar;
while (nb != NULL)
{
nbarstr *next = nb->next;
store_free(nb);
nb = next;
}
bar_cont->nbar = NULL;
}
/*************************************************
* Draw an nth time marking *
*************************************************/
/* The yield is the unmagnified y level, which is set as a minimum for a
subsequent marking. We don't free the data here, as sometimes nothing is drawn
(e.g. when bar lines descend), so the freeing happens elsewhere.
Arguments:
rightjog TRUE if a right jog is required
x1 the x coordinate of the end of the mark
Returns: the y level
*/
int
out_drawnbar(BOOL rightjog, int x1)
{
int x[4], y[4];
int n = 0;
nbarstr *nb = bar_cont->nbar;
b_nbarstr *b = nb->nbar;
int yield;
int x0 = nb->x;
int yy = (nb->maxy > 18000)? nb->maxy + 11000 : 29000;
/* Minimum y keeps it aligned with previous if this is not the first */
if (yy < nb->miny) yy = nb->miny;
/* Add in manual adjustment and scale to stave */
yield = yy + b->y;
yy = (yield * main_stavemagn)/1000;
/* Sort out the left hand end at the start of a system */
if (x0 == 0)
x0 = out_sysblock->firstnoteposition - 2000 + out_sysblock->xjustify;
/* Start of a new iteration; set up for a jog and output the text(s) */
else
{
uschar buff[80];
uschar *p = buff;
uschar *comma = US"";
x0 += 1500 + b->x;
x[n] = x0;
y[n++] = yy - 10*main_stavemagn;
while (nb != NULL)
{
b = nb->nbar;
if (b->s == NULL)
p += sprintf(CS p, "%s%d", comma, b->n);
else
p += sprintf(CS p, "%s%s", comma, b->s);
comma = US", ";
nb = nb->next;
}
out_string(buff, curmovt->font_repeat,
mac_muldiv((curmovt->fontsizes)->fontsize_repno, main_stavemagn, 1000),
x0 + 4000, out_ystave - yy + 9*main_stavemagn, 0);
}
/* Draw the lines and return the basic level */
x[n] = x0;
y[n++] = yy;
x[n] = x1;
y[n++] = yy;
if (rightjog)
{
x[n] = x1;
y[n++] = yy - 10*main_stavemagn;
}
ps_lines(x, y, n, 400);
return yield;
}
/* End of setnbar.c */
|