Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions platforms/win32/src/Direct2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class yystring : public std::wstring
public:

// Constructors
yystring::yystring() : std::wstring()
yystring() : std::wstring()
{
}
yystring(const char* v, int CP = CP_UTF8)
Expand Down Expand Up @@ -184,7 +184,7 @@ inline VGColor VGColorX(const D2D1_COLOR_F& f)

class Direct2DSystem;

inline std::tuple<float, float> MeasureString(IDWriteFactory* pWriteFactory, IDWriteTextFormat* ffo, const wchar_t* txt, int l = -1)
inline std::tuple<float, float> MeasureStringDD(IDWriteFactory* pWriteFactory, IDWriteTextFormat* ffo, const wchar_t* txt, int l = -1)
{
CComPtr<IDWriteTextLayout> lay = 0;
pWriteFactory->CreateTextLayout(txt, l == -1 ? (UINT32)wcslen(txt) : l, ffo, 1000, 1000, &lay);
Expand All @@ -201,13 +201,13 @@ inline std::tuple<float, float> MeasureString(IDWriteFactory* pWriteFactory, IDW
return std::make_tuple<float, float>(std::forward<float>(wi), std::forward<float>(he));
}

CComPtr<ID2D1SolidColorBrush> GetD2SolidBrush(ID2D1RenderTarget* p, D2D1_COLOR_F cc)
/*CComPtr<ID2D1SolidColorBrush> GetD2SolidBrush(ID2D1RenderTarget* p, D2D1_COLOR_F cc)
{
CComPtr<ID2D1SolidColorBrush> b = 0;
p->CreateSolidColorBrush(cc, &b);
return b;
}

*/
inline CComPtr<IDWriteFontCollection> PrivateGuidoFonts;

class Direct2DFont : public VGFont
Expand Down Expand Up @@ -270,7 +270,7 @@ inline void Direct2DFont::GetExtent(int c, float* outWidth, float* outHeight, VG
inline void Direct2DFont::GetExtent(const char* s, int inCharCount, float* outWidth, float* outHeight, VGDevice* context) const
{
yystring y = s;
auto strs = MeasureString(sys->WriteFactory, Text, y.c_str(), inCharCount);
auto strs = MeasureStringDD(sys->WriteFactory, Text, y.c_str(), inCharCount);

*outWidth = std::get<0>(strs);
*outHeight = std::get<1>(strs);
Expand All @@ -280,7 +280,7 @@ inline void Direct2DFont::GetExtent(const char* s, int inCharCount, float* outW
class Direct2DDevice : public VGDevice
{
public:
Direct2DSystem* mSys;
Direct2DSystem* mSys = 0;
Direct2DFont mCurrTextFont;
Direct2DFont mCurrMusicFont;

Expand Down Expand Up @@ -521,15 +521,21 @@ class Direct2DDevice : public VGDevice
// - Coordinate services ------------------------------------------------
D2D1_POINT_2F Origin = { 0,0 };
D2D1_POINT_2F Scl = { 1.0f,1.0f };
D2D1::Matrix3x2F org = D2D1::Matrix3x2F::Identity();
D2D1::Matrix3x2F cur = D2D1::Matrix3x2F::Identity();
D2D1_POINT_2F OrgScl = { 1.0f,1.0f };

void Trs()
{
mSys->rt->SetTransform(D2D1::Matrix3x2F::Identity());
D2D1::Matrix3x2F scl = D2D1::Matrix3x2F::Scale(Scl.x,Scl.y);
D2D1::Matrix3x2F trans = D2D1::Matrix3x2F::Translation(Origin.x*Scl.x,Origin.y*Scl.y);
mSys->rt->SetTransform(scl*trans);

D2D1::Matrix3x2F res = scl * trans;
D2D1::Matrix3x2F res2 = org * res;
mSys->rt->SetTransform(res2);
}


virtual void SetScale(float x, float y)
{
Scl.x = x;
Expand All @@ -538,14 +544,14 @@ class Direct2DDevice : public VGDevice
}
virtual void SetOrigin(float x, float y)
{
Origin.x = x;
Origin.y = y;
Origin.x = x * OrgScl.x;
Origin.y = y * OrgScl.y;
Trs();
}
virtual void OffsetOrigin(float x, float y)
{
Origin.x += x;
Origin.y += y;
Origin.x += x * OrgScl.x;
Origin.y += y * OrgScl.y;
Trs();
}

Expand All @@ -570,7 +576,7 @@ class Direct2DDevice : public VGDevice
EnsureBrush();
CComPtr< IDWriteTextLayout> tl;

auto ty = MeasureString(mSys->WriteFactory, F.Text, s,(UINT32)wcslen(s));
auto ty = MeasureStringDD(mSys->WriteFactory, F.Text, s,(UINT32)wcslen(s));
D2D1_RECT_F ly = {};
ly.left = x;
ly.top = y;
Expand Down Expand Up @@ -652,13 +658,16 @@ class Direct2DDevice : public VGDevice
mCurrMusicFont.a1 = a1;
mCurrMusicFont.a2 = a2;

if (mCurrMusicFont.Text && mCurrTextFont.Text)
if (mCurrMusicFont.Text)
{
mCurrTextFont.Text->SetTextAlignment(a1);
mCurrMusicFont.Text->SetTextAlignment(a1);
mCurrTextFont.Text->SetParagraphAlignment(a2);
mCurrMusicFont.Text->SetParagraphAlignment(a2);
}
if (mCurrTextFont.Text)
{
mCurrTextFont.Text->SetTextAlignment(a1);
mCurrTextFont.Text->SetParagraphAlignment(a2);
}
}
virtual unsigned int GetFontAlign() const
{
Expand Down
10 changes: 10 additions & 0 deletions src/engine/devices/AbstractDevice.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these includes? which are moreover platform specific and hard coded!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What includes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in src/engine/devices/AbstractDevice.cpp
(unless I've misread the PR)

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@

#ifdef WIN32
# pragma warning (disable : 4996)

#include "F:\\guidolib\\midisharelight\\src\\MidiShareLight.cpp"
#include "F:\\guidolib\\midisharelight\\src\\msEvents.cpp"
#include "F:\\guidolib\\midisharelight\\src\\msFields.cpp"
#include "F:\\guidolib\\midisharelight\\src\\msMemory.cpp"
#include "F:\\guidolib\\midisharelight\\src\\msSeq.cpp"
#include "F:\\guidolib\\midisharelight\\src\\lifo.cpp"
#include "F:\\guidolib\\midisharelight\\src\\midifile.cpp"


#endif

#include <stdio.h>
Expand Down
7 changes: 7 additions & 0 deletions src/engine/graphic/GRDynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ const GRDynamics::TXSegment* GRDynamics::getSegment(const GRSystem* system) cons
}


void GRDynamics::GetMap(GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const
{
if (sel == kDynSel)
SendMap(f, getRelativeTimePosition(), getDuration(), kDyn, infos);
}


//---------------------------------------------------------------------------------
void GRDynamics::DrawDynamic( VGDevice & hdc, bool cresc) const
{
Expand Down
1 change: 1 addition & 0 deletions src/engine/graphic/GRDynamics.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class GRDynamics : public GRPTagARNotationElement
virtual void accept (GRVisitor& visitor);

virtual const GRDynamics * isGRDynamic() const { return this; }
virtual void GetMap(GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const;

protected:
typedef struct TXSegment {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/graphic/GRHarmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void GRHarmony::DrawHarmonyString (VGDevice & hdc, const VGFont* font, const str
if (!mfont) mfont = FontManager::gFontScriab;

float ratio = font->GetSize() / 150.f; // 150 is the default font size for harmony (20 pt)
int fsize = mfont->GetSize() * ratio;
int fsize = (int)(mfont->GetSize() * ratio);

const VGFont* mBigFont = FontManager::FindOrCreateFont( int(fsize * 1.3), mfont->GetName(), "");
const VGFont* mSmallFont = FontManager::FindOrCreateFont( int(fsize * 0.8), mfont->GetName(), "");
Expand Down
14 changes: 14 additions & 0 deletions src/engine/graphic/GRKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,18 @@ void GRKey::getOctArray(int * OctArray)
mykey->getOctArray(OctArray);
}

void GRKey::GetMap(GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const
{
if (sel == kKeySel)
SendMap(f, getRelativeTimePosition(), getDuration(), kKey, infos);
}


void GRKey::setHPosition( GCoord nx)
{
setPosition( NVPoint( nx,mPosition.y ));


}

/** Update the the x-coordinates of the accidentals,
Expand Down Expand Up @@ -132,6 +140,12 @@ void GRKey::setPosition( const NVPoint & inPos )
newPos.x += e->getRightSpace();
}
updateBoundingBox();

mMapping.left = mPosition.x;
mMapping.top = mPosition.y;
mMapping.right = mPosition.x + mBoundingBox.right;
mMapping.bottom = mPosition.y + mBoundingBox.bottom;

}

//____________________________________________________________________________________
Expand Down
1 change: 1 addition & 0 deletions src/engine/graphic/GRKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class GRKey : public GRARCompositeNotationElement, public GRTag

virtual void OnDraw(VGDevice & dev ) const;
virtual void recalcVerticalPosition();
virtual void GetMap(GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const;

protected:
int mNatural;
Expand Down
12 changes: 12 additions & 0 deletions src/engine/graphic/GRText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ void GRText::OnDraw( VGDevice & hdc ) const
// DrawBoundingBox(hdc, VGColor(0,0,255));
}

void GRText::GetMap(GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const
{
if (sel == kTextSel)
SendMap(f, getRelativeTimePosition(), getDuration(), kText, infos);
}

const VGColor GRText::startDraw( VGDevice & hdc, unsigned int& fontalign ) const
{
hdc.SetTextFont( fFont );
Expand Down Expand Up @@ -277,6 +283,12 @@ void GRText::setHPosition( GCoord nx )
dx = arText->getDX()->getValue( LSPACE );
mPosition.x += dx;


mMapping.left = mPosition.x;
mMapping.top = mPosition.y;
mMapping.right = mPosition.x + st->boundingBox.right;
mMapping.bottom = mPosition.y + st->boundingBox.bottom;

st->position.x = nx;
}

Expand Down
1 change: 1 addition & 0 deletions src/engine/graphic/GRText.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class GRText : public GRPTagARNotationElement
virtual bool checkCollisionWith() const { return true; }
virtual bool isLyrics() const;
virtual const GRText* isText() const { return this; }
virtual void GetMap(GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const;

protected:
virtual const VGColor startDraw( VGDevice & hdc, unsigned int& fontalign ) const;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/include/GUIDOScoreMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
//------------------------------------------------------------------------------
// graphic elements selector definitions
typedef enum {
kGuidoPage, kGuidoSystem, kGuidoSystemSlice, kGuidoStaff, /*kGuidoMeasure,*/ kGuidoBar, kGuidoBarAndEvent, kGuidoEvent, kClefSel, kMeterSel,
kGuidoPage, kGuidoSystem, kGuidoSystemSlice, kGuidoStaff, /*kGuidoMeasure,*/ kGuidoBar, kGuidoBarAndEvent, kGuidoEvent, kClefSel, kMeterSel, kTextSel, kKeySel, kDynSel,
kGuidoScoreElementEnd
} GuidoElementSelector;

// graphic elements type definitions
typedef enum {
kNote = 1, kRest, kEmpty, kBar, kRepeatBegin, kRepeatEnd, kStaff, kSystemSlice, kSystem, kPage, kGraceNote, kClef, kMeter
kNote = 1, kRest, kEmpty, kBar, kRepeatBegin, kRepeatEnd, kStaff, kSystemSlice, kSystem, kPage, kGraceNote, kClef, kMeter, kText, kKey, kDyn
} GuidoElementType;


Expand Down