|
From: <sag...@us...> - 2009-09-23 11:57:27
|
Revision: 377
http://modplug.svn.sourceforge.net/modplug/?rev=377&view=rev
Author: saga-games
Date: 2009-09-23 11:57:10 +0000 (Wed, 23 Sep 2009)
Log Message:
-----------
[New] Pattern Editor: Sticky channels that always remain on the left side of the pattern editor. Still very buggy and a lot has to be done. Help is appreciated.
Modified Paths:
--------------
branches/devBranch_1_17_04/mptrack/Draw_pat.cpp
branches/devBranch_1_17_04/mptrack/View_pat.cpp
branches/devBranch_1_17_04/mptrack/View_pat.h
branches/devBranch_1_17_04/mptrack/resource.h
branches/devBranch_1_17_04/soundlib/Sndfile.cpp
branches/devBranch_1_17_04/soundlib/Sndfile.h
Modified: branches/devBranch_1_17_04/mptrack/Draw_pat.cpp
===================================================================
--- branches/devBranch_1_17_04/mptrack/Draw_pat.cpp 2009-09-23 11:51:18 UTC (rev 376)
+++ branches/devBranch_1_17_04/mptrack/Draw_pat.cpp 2009-09-23 11:57:10 UTC (rev 377)
@@ -446,16 +446,24 @@
HDC hdc;
UINT xofs, yofs, nColumnWidth, ncols, nrows, ncolhdr;
int xpaint, ypaint, mixPlug;
+ static CHANNELINDEX nOldChannels;
+ if ((pModDoc = GetDocument()) == nullptr) return;
+ pSndFile = pModDoc->GetSoundFile();
+ if(pSndFile != nullptr && nOldChannels != pSndFile->m_nChannels)
+ {
+ // number of channels changed -> recalc
+ ResetStickyChannels();
+ nOldChannels = pSndFile->m_nChannels;
+ }
+
ASSERT(pDC);
UpdateSizes();
- if ((pModDoc = GetDocument()) == NULL) return;
GetClientRect(&rcClient);
hdc = pDC->m_hDC;
oldpen = ::SelectObject(hdc, CMainFrame::penDarkGray);
xofs = GetXScrollPos();
yofs = GetYScrollPos();
- pSndFile = pModDoc->GetSoundFile();
nColumnWidth = m_szCell.cx;
nrows = (pSndFile->Patterns[m_nPattern]) ? pSndFile->PatternSize[m_nPattern] : 0;
ncols = pSndFile->GetNumChannels();
@@ -475,16 +483,22 @@
rect.SetRect(xpaint, ypaint, xpaint+nColumnWidth, ypaint + m_szHeader.cy);
if (ncolhdr < ncols)
{
+ CHANNELINDEX nRealChannel;
+ if(ncolhdr - xofs < m_nStickyChannelCount) // sticky channel
+ nRealChannel = m_nChannelOrder[ncolhdr - xofs];
+ else
+ nRealChannel = m_nChannelOrder[ncolhdr]; // normal channel
+ ASSERT(nRealChannel < MAX_BASECHANNELS);
// -> CODE#0012
// -> DESC="midi keyboard split"
- const char *pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]? "[Channel %d]" : "Channel %d";
+ const char *pszfmt = pSndFile->m_bChannelMuteTogglePending[nRealChannel]? "[Channel %d]" : "Channel %d";
// const char *pszfmt = pModDoc->IsChannelRecord(ncolhdr) ? "Channel %d " : "Channel %d";
// -! NEW_FEATURE#0012
- if ((pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) && ((BYTE)pSndFile->ChnSettings[ncolhdr].szName[0] >= 0x20))
- pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]?"%d: [%s]":"%d: %s";
- else if (m_nDetailLevel < 2) pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]?"[Ch%d]":"Ch%d";
- else if (m_nDetailLevel < 3) pszfmt = pSndFile->m_bChannelMuteTogglePending[ncolhdr]?"[Chn %d]":"Chn %d";
- wsprintf(s, pszfmt, ncolhdr+1, pSndFile->ChnSettings[ncolhdr].szName);
+ if ((pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) && ((BYTE)pSndFile->ChnSettings[nRealChannel].szName[0] >= 0x20))
+ pszfmt = pSndFile->m_bChannelMuteTogglePending[nRealChannel]?"%d: [%s]":"%d: %s";
+ else if (m_nDetailLevel < 2) pszfmt = pSndFile->m_bChannelMuteTogglePending[nRealChannel]?"[Ch%d]":"Ch%d";
+ else if (m_nDetailLevel < 3) pszfmt = pSndFile->m_bChannelMuteTogglePending[nRealChannel]?"[Chn %d]":"Chn %d";
+ wsprintf(s, pszfmt, nRealChannel + 1, pSndFile->ChnSettings[nRealChannel].szName);
// -> CODE#0012
// -> DESC="midi keyboard split"
// DrawButtonRect(hdc, &rect, s,
@@ -492,15 +506,15 @@
// ((m_bInItemRect) && ((m_nDragItem & DRAGITEM_MASK) == DRAGITEM_CHNHEADER) && ((m_nDragItem & 0xFFFF) == ncolhdr)) ? TRUE : FALSE, DT_CENTER);
// rect.bottom = rect.top + COLHDR_HEIGHT;
DrawButtonRect(hdc, &rect, s,
- (pSndFile->ChnSettings[ncolhdr].dwFlags & CHN_MUTE) ? TRUE : FALSE,
- ((m_bInItemRect) && ((m_nDragItem & DRAGITEM_MASK) == DRAGITEM_CHNHEADER) && ((m_nDragItem & 0xFFFF) == ncolhdr)) ? TRUE : FALSE,
- pModDoc->IsChannelRecord(ncolhdr) ? DT_RIGHT : DT_CENTER);
+ (pSndFile->ChnSettings[nRealChannel].dwFlags & CHN_MUTE) ? TRUE : FALSE,
+ ((m_bInItemRect) && ((m_nDragItem & DRAGITEM_MASK) == DRAGITEM_CHNHEADER) && ((m_nDragItem & 0xFFFF) == nRealChannel)) ? TRUE : FALSE,
+ pModDoc->IsChannelRecord(nRealChannel) ? DT_RIGHT : DT_CENTER);
rect.bottom = rect.top + COLHDR_HEIGHT;
CRect insRect;
insRect.SetRect(xpaint, ypaint, xpaint+nColumnWidth / 8 + 3, ypaint + 16);
// if (MultiRecordMask[ncolhdr>>3] & (1 << (ncolhdr&7)))
- if (pModDoc->IsChannelRecord1(ncolhdr))
+ if (pModDoc->IsChannelRecord1(nRealChannel))
{
// rect.DeflateRect(1, 1);
// InvertRect(hdc, &rect);
@@ -512,7 +526,7 @@
DrawButtonRect(hdc, &insRect, s, FALSE, FALSE, DT_CENTER);
FrameRect(hdc,&insRect,CMainFrame::brushBlack);
}
- else if (pModDoc->IsChannelRecord2(ncolhdr))
+ else if (pModDoc->IsChannelRecord2(nRealChannel))
{
FrameRect(hdc,&rect,CMainFrame::brushGray);
InvertRect(hdc, &rect);
@@ -525,8 +539,8 @@
if (m_dwStatus & PATSTATUS_VUMETERS)
{
- OldVUMeters[ncolhdr] = 0;
- DrawChannelVUMeter(hdc, rect.left + 1, rect.bottom, ncolhdr);
+ OldVUMeters[nRealChannel] = 0;
+ DrawChannelVUMeter(hdc, rect.left + 1, rect.bottom, nRealChannel);
rect.top+=VUMETERS_HEIGHT;
rect.bottom+=VUMETERS_HEIGHT;
}
@@ -534,14 +548,14 @@
{
rect.top+=PLUGNAME_HEIGHT;
rect.bottom+=PLUGNAME_HEIGHT;
- mixPlug=pSndFile->ChnSettings[ncolhdr].nMixPlugin;
+ mixPlug=pSndFile->ChnSettings[nRealChannel].nMixPlugin;
if (mixPlug) {
wsprintf(s, "%d: %s", mixPlug, (pSndFile->m_MixPlugins[mixPlug-1]).pMixPlugin?(pSndFile->m_MixPlugins[mixPlug-1]).Info.szName:"[empty]");
} else {
wsprintf(s, "---");
}
DrawButtonRect(hdc, &rect, s, FALSE,
- ((m_bInItemRect) && ((m_nDragItem & DRAGITEM_MASK) == DRAGITEM_PLUGNAME) && ((m_nDragItem & 0xFFFF) == ncolhdr)) ? TRUE : FALSE, DT_CENTER);
+ ((m_bInItemRect) && ((m_nDragItem & DRAGITEM_MASK) == DRAGITEM_PLUGNAME) && ((m_nDragItem & 0xFFFF) == nRealChannel)) ? TRUE : FALSE, DT_CENTER);
}
} else break;
ncolhdr++;
@@ -797,7 +811,13 @@
MODCOMMAND *m;
int x, bk_col, tx_col, col_sel, fx_col;
- m = (pPattern) ? &pPattern[row*ncols+col] : &m0;
+ CHANNELINDEX nRealChannel;
+ if(col - xofs < m_nStickyChannelCount) // sticky channel
+ nRealChannel = m_nChannelOrder[col - xofs];
+ else // normal channel
+ nRealChannel = m_nChannelOrder[col];
+
+ m = (pPattern) ? &pPattern[row*ncols+nRealChannel] : &m0;
dwSpeedUpMask = 0;
if ((bSpeedUp) && (bColSel[col] & 0x40) && (pPattern) && (row))
{
Modified: branches/devBranch_1_17_04/mptrack/View_pat.cpp
===================================================================
--- branches/devBranch_1_17_04/mptrack/View_pat.cpp 2009-09-23 11:51:18 UTC (rev 376)
+++ branches/devBranch_1_17_04/mptrack/View_pat.cpp 2009-09-23 11:57:10 UTC (rev 377)
@@ -66,6 +66,7 @@
ON_COMMAND(ID_EDIT_SPLITRECSELECT, OnSplitRecordSelect)
// -! NEW_FEATURE#0012
ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
+ ON_COMMAND(ID_PATTERN_CHNTOGGLESTICKY, OnChannelTogglySticky)
ON_COMMAND(ID_PATTERN_CHNRESET, OnChannelReset)
ON_COMMAND(ID_PATTERN_MUTE, OnMuteFromClick) //rewbs.customKeys
ON_COMMAND(ID_PATTERN_SOLO, OnSoloFromClick) //rewbs.customKeys
@@ -133,6 +134,7 @@
m_nDetailLevel = 4;
m_pEditWnd = NULL;
m_pGotoWnd = NULL;
+ memset(m_nChannelOrder, 0, sizeof(m_nChannelOrder));
m_Dib.Init(CMainFrame::bmpNotes);
UpdateColors();
}
@@ -147,6 +149,7 @@
// -> DESC="midi keyboard split"
memset(splitActiveNoteChannel, 0xFF, sizeof(splitActiveNoteChannel));
memset(activeNoteChannel, 0xFF, sizeof(activeNoteChannel));
+ ResetStickyChannels();
oldrow = -1;
oldchn = -1;
oldsplitchn = -1;
@@ -1405,6 +1408,17 @@
}
}
+void CViewPattern::OnChannelTogglySticky()
+//---------------------------------------
+{
+ // Toggle "sticky" state (channel will always be visible)
+ const CHANNELINDEX nChn = GetChanFromCursor(m_nMenuParam);
+ CSoundFile* pSndFile;
+ if(GetDocument() == nullptr || (pSndFile = GetDocument()->GetSoundFile()) == nullptr) return;
+ pSndFile->ChnSettings[nChn].bIsSticky = !pSndFile->ChnSettings[nChn].bIsSticky;
+ ResetStickyChannels();
+}
+
void CViewPattern::OnChannelReset()
//---------------------------------
{
@@ -3006,8 +3020,8 @@
}
-ModCommandPos CViewPattern::GetEditPos(CSoundFile& rSf, const bool bLiveRecord) const
-//-----------------------------------------------------------------------------------
+ModCommandPos CViewPattern::GetEditPos(CSoundFile& rSf, const bool bLiveRecord)
+//-----------------------------------------------------------------------------
{
ModCommandPos editpos;
if(bLiveRecord)
@@ -4658,6 +4672,8 @@
AppendMenu(hMenu, MF_STRING, ID_PATTERN_CHNRESET, "Reset Channel\t" + ih->GetKeyTextFromCommand(kcChannelReset));
+ AppendMenu(hMenu, MF_STRING | (pSndFile->ChnSettings[nChn].bIsSticky ? MF_CHECKED : 0), ID_PATTERN_CHNTOGGLESTICKY, "Sticky Channel");
+
return true;
}
@@ -4984,7 +5000,7 @@
ROWINDEX CViewPattern::GetRowFromCursor(DWORD cursor) {return cursor >> 16;}
//---------------------------------------------------
-CHANNELINDEX CViewPattern::GetChanFromCursor(DWORD cursor) {return static_cast<CHANNELINDEX>((cursor & 0xFFFF) >> 3);}
+CHANNELINDEX CViewPattern::GetChanFromCursor(DWORD cursor) {return m_nChannelOrder[(cursor & 0xFFFF) >> 3];}
//-------------------------------------------------------
UINT CViewPattern::GetColTypeFromCursor(DWORD cursor) {return cursor & 0x07;}
@@ -5141,3 +5157,33 @@
iRow = m_nRow;
}
}
+
+void CViewPattern::ResetStickyChannels()
+//--------------------------------------
+{
+ // precalc sticky channels, i.e. channels that are always visible
+ CSoundFile *pSndFile;
+ if(GetDocument() == nullptr || (pSndFile = GetDocument()->GetSoundFile()) == nullptr) return;
+
+ CHANNELINDEX iChn = 0;
+ for(CHANNELINDEX i = 0; i < pSndFile->m_nChannels; i++)
+ {
+ if(pSndFile->ChnSettings[i].bIsSticky == true)
+ {
+ m_nChannelOrder[iChn] = i;
+ iChn++;
+ }
+ }
+ m_nStickyChannelCount = iChn;
+ for(CHANNELINDEX i = 0; i < pSndFile->m_nChannels; i++)
+ {
+ if(pSndFile->ChnSettings[i].bIsSticky == false)
+ {
+ m_nChannelOrder[iChn] = i;
+ iChn++;
+ }
+ }
+ ASSERT(iChn == pSndFile->m_nChannels);
+ InvalidateChannelsHeaders();
+ InvalidatePattern();
+}
\ No newline at end of file
Modified: branches/devBranch_1_17_04/mptrack/View_pat.h
===================================================================
--- branches/devBranch_1_17_04/mptrack/View_pat.h 2009-09-23 11:51:18 UTC (rev 376)
+++ branches/devBranch_1_17_04/mptrack/View_pat.h 2009-09-23 11:57:10 UTC (rev 377)
@@ -110,6 +110,9 @@
int oldrow,oldchn,oldsplitchn;
// -! NEW_FEATURE#0012
+ CHANNELINDEX m_nChannelOrder[MAX_BASECHANNELS]; // for sticky channels
+ CHANNELINDEX m_nStickyChannelCount;
+
// -> CODE#0018
// -> DESC="route PC keyboard inputs to midi in mechanism"
int ignorekey;
@@ -240,6 +243,7 @@
afx_msg void OnEditGoto();
afx_msg void OnEditFindNext();
afx_msg void OnEditUndo();
+ afx_msg void OnChannelTogglySticky();
afx_msg void OnChannelReset();
afx_msg void OnMuteFromClick(); //rewbs.customKeys
afx_msg void OnSoloFromClick(); //rewbs.customKeys
@@ -331,9 +335,9 @@
UINT GetSelectionEndChan();
UINT ListChansWhereColSelected(UINT colType, CArray<UINT,UINT> &chans);
- static ROWINDEX GetRowFromCursor(DWORD cursor);
- static CHANNELINDEX GetChanFromCursor(DWORD cursor);
- static UINT GetColTypeFromCursor(DWORD cursor);
+ ROWINDEX GetRowFromCursor(DWORD cursor);
+ CHANNELINDEX GetChanFromCursor(DWORD cursor);
+ UINT GetColTypeFromCursor(DWORD cursor);
bool IsInterpolationPossible(UINT startRow, UINT endRow, UINT chan, UINT colType, CSoundFile* pSndFile);
void Interpolate(UINT type);
@@ -350,7 +354,7 @@
const ROWINDEX iRowCandidate, const PATTERNINDEX iPatCandidate) const;
// Returns edit position.
- ModCommandPos GetEditPos(CSoundFile& rSf, const bool bLiveRecord) const;
+ ModCommandPos GetEditPos(CSoundFile& rSf, const bool bLiveRecord);
// Returns pointer to modcommand at given position. If the position is not valid, returns pointer
// to a dummy command.
@@ -360,6 +364,8 @@
//Like IsEditingEnabled(), but shows some notification when editing is not enabled.
bool IsEditingEnabled_bmsg();
+
+ void ResetStickyChannels();
public:
Modified: branches/devBranch_1_17_04/mptrack/resource.h
===================================================================
--- branches/devBranch_1_17_04/mptrack/resource.h 2009-09-23 11:51:18 UTC (rev 376)
+++ branches/devBranch_1_17_04/mptrack/resource.h 2009-09-23 11:57:10 UTC (rev 377)
@@ -1124,6 +1124,7 @@
#define ID_NOTEMAP_COPY_NOTE 59227
#define ID_CLEANUP_REARRANGESAMPLES 59228
#define ID_ORDERLIST_RENDER 59229
+#define ID_PATTERN_CHNTOGGLESTICKY 59230
// Next default values for new objects
//
@@ -1131,7 +1132,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 521
-#define _APS_NEXT_COMMAND_VALUE 59230
+#define _APS_NEXT_COMMAND_VALUE 59231
#define _APS_NEXT_CONTROL_VALUE 2391
#define _APS_NEXT_SYMED_VALUE 901
#endif
Modified: branches/devBranch_1_17_04/soundlib/Sndfile.cpp
===================================================================
--- branches/devBranch_1_17_04/soundlib/Sndfile.cpp 2009-09-23 11:51:18 UTC (rev 376)
+++ branches/devBranch_1_17_04/soundlib/Sndfile.cpp 2009-09-23 11:57:10 UTC (rev 377)
@@ -1418,7 +1418,7 @@
}
-bool CSoundFile::InitChannel(UINT nch)
+bool CSoundFile::InitChannel(CHANNELINDEX nch)
//-------------------------------------
{
if(nch >= MAX_BASECHANNELS) return true;
@@ -1427,6 +1427,7 @@
ChnSettings[nch].nVolume = 64;
ChnSettings[nch].dwFlags = 0;
ChnSettings[nch].nMixPlugin = 0;
+ ChnSettings[nch].bIsSticky = false;
ChnSettings[nch].szName[0] = 0;
ResetChannelState(nch, CHNRESET_TOTAL);
@@ -1608,8 +1609,8 @@
return static_cast<CHANNELINDEX>(m_nChannels);
}
-bool CSoundFile::MoveChannel(UINT chnFrom, UINT chnTo)
-//-----------------------------------------------------
+bool CSoundFile::MoveChannel(CHANNELINDEX chnFrom, CHANNELINDEX chnTo)
+//--------------------------------------------------------------------
{
//Implementation of move channel using ReArrangeChannels(...). So this function
//only creates correct newOrder-vector used in the ReArrangeChannels(...).
@@ -1630,7 +1631,7 @@
if(chnFrom < chnTo)
{
CHANNELINDEX temp = newOrder[chnFrom];
- for(UINT i = chnFrom; i<chnTo; i++)
+ for(CHANNELINDEX i = chnFrom; i<chnTo; i++)
{
newOrder[i] = newOrder[i+1];
}
@@ -1639,7 +1640,7 @@
else //case chnFrom > chnTo(can't be equal, since it has been examined earlier.)
{
CHANNELINDEX temp = newOrder[chnFrom];
- for(UINT i = chnFrom; i>=chnTo+1; i--)
+ for(CHANNELINDEX i = chnFrom; i>=chnTo+1; i--)
{
newOrder[i] = newOrder[i-1];
}
Modified: branches/devBranch_1_17_04/soundlib/Sndfile.h
===================================================================
--- branches/devBranch_1_17_04/soundlib/Sndfile.h 2009-09-23 11:51:18 UTC (rev 376)
+++ branches/devBranch_1_17_04/soundlib/Sndfile.h 2009-09-23 11:57:10 UTC (rev 377)
@@ -259,10 +259,11 @@
struct MODCHANNELSETTINGS
{
- UINT nPan;
- UINT nVolume;
- DWORD dwFlags;
+ UINT nPan; // 0...256
+ UINT nVolume; // 0...64
+ DWORD dwFlags; // Suround/Mute
UINT nMixPlugin;
+ bool bIsSticky; // Channel will always be visible in the pattern editor
CHAR szName[MAX_CHANNELNAME];
};
@@ -668,9 +669,9 @@
BOOL SetPatternName(UINT nPat, LPCSTR lpszName);
BOOL GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize=MAX_PATTERNNAME) const;
CHANNELINDEX ReArrangeChannels(const vector<CHANNELINDEX>& fromToArray);
- bool MoveChannel(UINT chn_from, UINT chn_to);
+ bool MoveChannel(CHANNELINDEX chnFrom, CHANNELINDEX chnTo);
- bool InitChannel(UINT nch);
+ bool InitChannel(CHANNELINDEX nch);
void ResetChannelState(CHANNELINDEX chn, BYTE resetStyle);
// Module Loaders
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|