176 lines
4.7 KiB
C++
176 lines
4.7 KiB
C++
#ifndef _GUITAR_GUIFRETBOARD_HPP_
|
|
#define _GUITAR_GUIFRETBOARD_HPP_
|
|
#ifndef _COMMON_ARRAY_HPP_
|
|
#include <common/array.hpp>
|
|
#endif
|
|
#ifndef _COMMON_PUREDEVICE_HPP_
|
|
#include <common/purehdc.hpp>
|
|
#endif
|
|
#ifndef _COMMON_SMARTPOINTER_HPP_
|
|
#include <common/pointer.hpp>
|
|
#endif
|
|
#ifndef _COMMON_DIBITMAP_HPP_
|
|
#include <common/dib.hpp>
|
|
#endif
|
|
#ifndef _COMMON_BRUSH_HPP_
|
|
#include <common/brush.hpp>
|
|
#endif
|
|
#ifndef _COMMON_FONT_HPP_
|
|
#include <common/font.hpp>
|
|
#endif
|
|
#ifndef _COMMON_CALLBACK_HPP_
|
|
#include <common/callback.hpp>
|
|
#endif
|
|
#ifndef _COMMON_POINT_HPP_
|
|
#include <common/point.hpp>
|
|
#endif
|
|
#ifndef _BSPTREE_BTREE_HPP_
|
|
#include <bsptree/btree.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_FRETTEDBOUNDINGNOTE_HPP_
|
|
#include <guitar/FrettedBoundingNote.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_TUNING_HPP_
|
|
#include <guitar/tuning.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_SEQUENCER_HPP_
|
|
#include <guitar/sequencer.hpp>
|
|
#endif
|
|
#ifndef _MUSIC_CHORD_HPP_
|
|
#include <music/chord.hpp>
|
|
#endif
|
|
|
|
class GUIWindow;
|
|
class TabEntry;
|
|
class ResBitmap;
|
|
class Scale;
|
|
|
|
typedef Array<FrettedBoundingNote> GuitarString;
|
|
typedef Array<GuitarString> VirtualFretboard;
|
|
|
|
class GUIFretboard : public VirtualFretboard
|
|
{
|
|
public:
|
|
enum{DefaultFrets=24,DefaultStrings=6};
|
|
GUIFretboard(GUIWindow &parent,const Tuning &tuning=Tuning(),int frets=DefaultFrets);
|
|
virtual ~GUIFretboard();
|
|
const Tuning &getTuning(void)const;
|
|
void setTuning(const Tuning &tuning);
|
|
int getFrets(void)const;
|
|
void draw(PureDevice &device);
|
|
bool isNoteSet(const GDIPoint &clickPoint);
|
|
bool unsetNote(const GDIPoint &clickPoint);
|
|
void setNote(int string,int fret,bool clear=true,bool play=false);
|
|
void setNote(const TabEntry &entry,bool clear=true,bool play=false);
|
|
void setNote(const Note ¬e,bool clear=true,bool play=false);
|
|
void setNote(const Scale &scale,bool play=false);
|
|
void setNote(const Music::Chord &chord,bool play=false);
|
|
void setNote(const FrettedNotes &frettedNotes,bool play=false);
|
|
void setNote(Block<FrettedNote> &frettedNotes,bool play=false);
|
|
void getNotes(TabEntry &entry);
|
|
void clearNotes(void);
|
|
void setShowNotes(bool showNotes);
|
|
bool getShowNotes(void)const;
|
|
void showAllPositions(void);
|
|
void cut(void);
|
|
void copy(void);
|
|
void paste(void);
|
|
private:
|
|
enum{RightBorder=10,BottomBorder=30,Radius=5,ClickTolerance=1};
|
|
enum{KeyDown=0x28,KeyLeft=0x25,KeyRight=0x27,KeyUp=0x26,CtrlKey=0x11};
|
|
CallbackData::ReturnType sizeHandler(CallbackData &callbackData);
|
|
CallbackData::ReturnType leftButtonDownHandler(CallbackData &callbackData);
|
|
CallbackData::ReturnType keyDownHandler(CallbackData &callbackData);
|
|
CallbackData::ReturnType keyUpHandler(CallbackData &callbackData);
|
|
CallbackData::ReturnType setFocusHandler(CallbackData &callbackData);
|
|
CallbackData::ReturnType killFocusHandler(CallbackData &callbackData);
|
|
|
|
void createVirtualFretboard(void);
|
|
void refreshNotes(void);
|
|
void getSequencer(void);
|
|
Point getPoint(int string,int fret)const;
|
|
Rect getBoundingRect(int string,int fret)const;
|
|
void prepareDevice(PureDevice &device,bool prepare);
|
|
void prepareDevice(PureDevice &device,const RGBColor &brushColor,const RGBColor &textColor=RGBColor(255,255,255),bool prepare=true);
|
|
void drawNote(FrettedBoundingNote &currFret,PureDevice &device);
|
|
bool setNote(const GDIPoint &clickPoint,bool clear=true,bool play=false);
|
|
Brush &getBrush(const RGBColor &brushColor);
|
|
|
|
Tuning mTuning;
|
|
SmartPointer<DIBitmap> mDIBitmap;
|
|
SmartPointer<ResBitmap> mResBitmap;
|
|
SmartPointer<GUIWindow> mParent;
|
|
SmartPointer<Sequencer> mSequencer;
|
|
|
|
Callback<GUIFretboard> mSizeHandler;
|
|
Callback<GUIFretboard> mLeftButtonDownHandler;
|
|
Callback<GUIFretboard> mKeyDownHandler;
|
|
Callback<GUIFretboard> mKeyUpHandler;
|
|
Callback<GUIFretboard> mSetFocusHandler;
|
|
Callback<GUIFretboard> mKillFocusHandler;
|
|
BTree<FrettedBoundingNote> mActiveFrets;
|
|
|
|
bool mShowNotes;
|
|
bool mClearNotes;
|
|
int mCurrFret;
|
|
int mCurrString;
|
|
|
|
Brush mGreenBrush;
|
|
Brush mRedBrush;
|
|
Brush mWhiteBrush;
|
|
Brush mLtGreenBrush;
|
|
Brush mBlueBrush;
|
|
Font mTextFont;
|
|
|
|
HGDIOBJ mPrevBrush;
|
|
HGDIOBJ mPrevFont;
|
|
int mPrevBkMode;
|
|
RGBColor mPrevTextColor;
|
|
|
|
static RGBColor smColorBlack;
|
|
static RGBColor smColorLtGreen;
|
|
static RGBColor smColorWhite;
|
|
static RGBColor smColorRed;
|
|
static RGBColor smColorGreen;
|
|
static RGBColor smColorBlue;
|
|
};
|
|
|
|
inline
|
|
const Tuning &GUIFretboard::getTuning(void)const
|
|
{
|
|
return mTuning;
|
|
}
|
|
|
|
inline
|
|
void GUIFretboard::setTuning(const Tuning &tuning)
|
|
{
|
|
mTuning=tuning;
|
|
createVirtualFretboard();
|
|
}
|
|
|
|
inline
|
|
int GUIFretboard::getFrets(void)const
|
|
{
|
|
return DefaultFrets;
|
|
}
|
|
|
|
inline
|
|
void GUIFretboard::setShowNotes(bool showNotes)
|
|
{
|
|
mShowNotes=showNotes;
|
|
}
|
|
|
|
inline
|
|
bool GUIFretboard::getShowNotes(void)const
|
|
{
|
|
return mShowNotes;
|
|
}
|
|
|
|
inline
|
|
void GUIFretboard::getSequencer(void)
|
|
{
|
|
if(mSequencer.isOkay())return;
|
|
mSequencer=::new Sequencer();
|
|
mSequencer.disposition(PointerDisposition::Delete);
|
|
}
|
|
#endif |