VocalEasel/Sources/VLLayout.h

74 lines
1.8 KiB
C
Raw Normal View History

2007-12-23 12:45:17 +00:00
//
// File: VLLayout.h - Dimensions for lead sheet layout
//
// Author(s):
//
// (MN) Matthias Neeracher
//
2011-09-11 02:03:22 +00:00
// Copyright © 2007-2011 Matthias Neeracher
2007-12-23 12:45:17 +00:00
//
2011-09-11 00:03:19 +00:00
#include "VLModel.h"
2007-12-23 12:45:17 +00:00
#include <vector>
class VLSystemLayout {
public:
2007-12-23 23:07:27 +00:00
VLSystemLayout(const VLProperties & prop, float width, int maxMeas);
2007-12-23 12:45:17 +00:00
float ClefKeyWidth() const { return fClefKeyWidth; }
float MeasureWidth() const { return fMeasureWidth; }
float MeasurePosition(int m) const { return fClefKeyWidth+m*fMeasureWidth; }
float SystemWidth() const { return MeasurePosition(fNumMeasures); }
int Divisions() const { return fDivisions; }
int NumGroups() const { return fNumGroups; }
int DivPerGroup() const { return fDivPerGroup; }
int NumMeasures() const { return fNumMeasures; }
private:
float fClefKeyWidth;
float fMeasureWidth;
int fDivisions;
int fNumGroups;
int fDivPerGroup;
int fNumMeasures;
};
class VLLayout : public std::vector<VLSystemLayout> {
public:
VLLayout(const VLSong & song, float width);
int FirstMeasure(int system) const;
int SystemForMeasure(int measure) const;
2011-09-11 02:03:22 +00:00
int NumSystems() const { return static_cast<int>(size()); }
2007-12-23 12:45:17 +00:00
float MeasurePosition(int measure) const;
2011-09-11 02:03:22 +00:00
float NotePosition(VLLocation at) const;
2007-12-23 12:45:17 +00:00
};
class VLFontHandler {
public:
2008-05-29 18:54:30 +00:00
virtual void Draw(float x, float y,
const char * utf8Text, bool highlight) = 0;
virtual float Width(const char * utf8Text) = 0;
virtual ~VLFontHandler();
};
struct VLLayoutSyll : public VLSyllable {
float fX;
2008-05-29 18:54:30 +00:00
bool fHighlight;
};
class VLTextLayout {
public:
VLTextLayout(VLFontHandler * regular, VLFontHandler * narrow);
2008-05-29 18:54:30 +00:00
void AddSyllable(const VLSyllable & syll, float x, bool highlight);
void DrawLine(float y);
private:
VLFontHandler * fRegularFont;
VLFontHandler * fNarrowFont;
std::vector<VLLayoutSyll> fSyllables;
};
2007-12-23 12:45:17 +00:00
// Local Variables:
// mode:C++
// End: