From: <rel...@us...> - 2008-10-18 21:21:33
|
Revision: 232 http://modplug.svn.sourceforge.net/modplug/?rev=232&view=rev Author: relabsoluness Date: 2008-10-18 21:21:29 +0000 (Sat, 18 Oct 2008) Log Message: ----------- (Patches from Jojo, merged with some fixes) + In sample view: Status bar now displays offset value at given sample point. . Small fixes to sample trimming usability. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2008-10-18 12:35:46 UTC (rev 231) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2008-10-18 21:21:29 UTC (rev 232) @@ -20,6 +20,12 @@ #define MIN_ZOOM 0 #define MAX_ZOOM 8 +// Defines the minimum length for selection for which +// trimming will be done. This is the minimum value for +// selection difference, so the minimum length of result +// of trimming is nTrimLengthMin + 1. +const uint8 nTrimLengthMin = 16; + const UINT cLeftBarButtons[SMP_LEFTBAR_BUTTONS] = { ID_SAMPLE_ZOOMUP, @@ -1176,9 +1182,32 @@ pSndFile = pModDoc->GetSoundFile(); if (m_rcClient.PtInRect(point)) { - LONG x = ScreenToSample(point.x); - wsprintf(s, "Cursor: %d", x); + const DWORD x = ScreenToSample(point.x); + wsprintf(s, "Cursor: %u", x); UpdateIndicator(s); + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + + if (pMainFrm && m_dwEndSel <= m_dwBeginSel) + { + if(m_nSample > 0 && m_nSample < MAX_SAMPLES && x < pSndFile->Ins[m_nSample].nLength ) + { + const DWORD xLow = (x / 0x100) % 0x100; + const DWORD xHigh = x / 0x10000; + const char cOffsetChar = (pSndFile->TypeIsS3M_IT_MPT()) ? gszS3mCommands[CMD_OFFSET] : gszModCommands[CMD_OFFSET]; + const bool bHasHighOffset = (pSndFile->TypeIsS3M_IT_MPT() || (pSndFile->GetType() == MOD_TYPE_XM)); + const char cHighOffsetChar = (pSndFile->TypeIsS3M_IT_MPT()) ? gszS3mCommands[CMD_S3MCMDEX] : gszModCommands[CMD_XFINEPORTAUPDOWN]; + + if(xHigh == 0) + wsprintf(s, "Offset: %c%02X", cOffsetChar, xLow); + else if(bHasHighOffset && xHigh < 0x10) + wsprintf(s, "Offset: %c%02X, %cA%X", cOffsetChar, xLow, cHighOffsetChar, xHigh); + else + wsprintf(s, "Beyond offset range"); + pMainFrm->SetInfoText(s); + } + else + pMainFrm->SetInfoText(""); + } } else UpdateIndicator(NULL); if (m_dwStatus & SMPSTATUS_MOUSEDRAG) { @@ -1332,13 +1361,19 @@ // "Trim" menu item is responding differently if there's no selection, // but a loop present: "trim around loop point"! (jojo in topic 2258) std::string sTrimMenuText = "Trim"; - bool bIsGrayed = (m_dwEndSel<=m_dwBeginSel); + bool bIsGrayed = ( (m_dwEndSel<=m_dwBeginSel) || (m_dwEndSel - m_dwBeginSel < nTrimLengthMin) + || (m_dwEndSel - m_dwBeginSel == pins->nLength) + ); if ((m_dwBeginSel == m_dwEndSel) && (pins->nLoopStart < pins->nLoopEnd)) { // no selection => use loop points sTrimMenuText += " around loop points"; - bIsGrayed = false; + // Check whether trim menu item can be enabled (loop not too short or long for trimming). + if( (pins->nLoopEnd <= pins->nLength) && + (pins->nLoopEnd - pins->nLoopStart >= nTrimLengthMin) && + (pins->nLoopEnd - pins->nLoopStart < pins->nLength) ) + bIsGrayed = false; } sTrimMenuText += "\t" + ih->GetKeyTextFromCommand(kcSampleTrim); @@ -1862,7 +1897,7 @@ UINT nStart = m_dwBeginSel; UINT nEnd = m_dwEndSel - m_dwBeginSel; - if ((pins->pSample) && (nStart+nEnd <= pins->nLength) && (nEnd >= 16)) + if ((pins->pSample) && (nStart+nEnd <= pins->nLength) && (nEnd >= nTrimLengthMin)) { BEGIN_CRITICAL(); { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2008-10-18 12:35:46 UTC (rev 231) +++ trunk/OpenMPT/soundlib/Sndfile.h 2008-10-18 21:21:29 UTC (rev 232) @@ -973,6 +973,8 @@ BOOL Destroy(); MODTYPE GetType() const { return m_nType; } inline bool TypeIsIT_MPT() const {return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0;} + inline bool TypeIsS3M_IT_MPT() const {return (m_nType & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0;} + inline bool TypeIsXM_MOD() const {return (m_nType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0;} CModDoc* GetpModDoc() {return m_pModDoc;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |