From: <sag...@us...> - 2010-02-23 15:53:19
|
Revision: 509 http://modplug.svn.sourceforge.net/modplug/?rev=509&view=rev Author: saga-games Date: 2010-02-23 15:53:10 +0000 (Tue, 23 Feb 2010) Log Message: ----------- [New] Instrument Editor: Envelope zooming. Might still look very weird (especially the first tick and around loop points). Includes two new keyboard shortcuts. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/mptrack/res/envbar.bmp trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2010-02-22 20:53:09 UTC (rev 508) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2010-02-23 15:53:10 UTC (rev 509) @@ -2565,7 +2565,17 @@ commands[kcPatternEditPCNotePlugin].isDummy = false; commands[kcPatternEditPCNotePlugin].Message = "Edit plugin assigned to PC note"; - #ifdef _DEBUG + commands[kcInstrumentEnvelopeZoomIn].UID = 1837; + commands[kcInstrumentEnvelopeZoomIn].isHidden = false; + commands[kcInstrumentEnvelopeZoomIn].isDummy = false; + commands[kcInstrumentEnvelopeZoomIn].Message = "Zoom In"; + + commands[kcInstrumentEnvelopeZoomOut].UID = 1838; + commands[kcInstrumentEnvelopeZoomOut].isHidden = false; + commands[kcInstrumentEnvelopeZoomOut].isDummy = false; + commands[kcInstrumentEnvelopeZoomOut].Message = "Zoom Out"; + +#ifdef _DEBUG for (int i=0; i<kcNumCommands; i++) { if (commands[i].UID != 0) { // ignore unset UIDs for (int j=i+1; j<kcNumCommands; j++) { Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2010-02-22 20:53:09 UTC (rev 508) +++ trunk/OpenMPT/mptrack/CommandSet.h 2010-02-23 15:53:10 UTC (rev 509) @@ -550,6 +550,8 @@ kcInstrumentLoad=kcStartInstrumentMisc, kcInstrumentSave, kcInstrumentNew, + kcInstrumentEnvelopeZoomIn, + kcInstrumentEnvelopeZoomOut, kcInstrumentEnvelopePointPrev, kcInstrumentEnvelopePointNext, kcInstrumentEnvelopePointMoveLeft, Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2010-02-22 20:53:09 UTC (rev 508) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2010-02-23 15:53:10 UTC (rev 509) @@ -319,6 +319,10 @@ IIMAGE_NOFILTERSWITCH, IIMAGE_SAMPLEMAP, IIMAGE_GRID, + IIMAGE_ZOOMIN, + IIMAGE_NOZOOMIN, + IIMAGE_ZOOMOUT, + IIMAGE_NOZOOMOUT, }; Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2010-02-22 20:53:09 UTC (rev 508) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2010-02-23 15:53:10 UTC (rev 509) @@ -12,7 +12,9 @@ #include ".\view_ins.h" #include "midi.h" -#define ENV_ZOOM 4 +#define ENV_ZOOM 4.0f +#define ENV_MIN_ZOOM 2.0f +#define ENV_MAX_ZOOM 100.0f #define ENV_DRAGLOOPSTART (MAX_ENVPOINTS + 1) #define ENV_DRAGLOOPEND (MAX_ENVPOINTS + 2) #define ENV_DRAGSUSTAINSTART (MAX_ENVPOINTS + 3) @@ -45,6 +47,8 @@ ID_SEPARATOR, ID_ENVELOPE_VIEWGRID, //rewbs.envRowGrid ID_SEPARATOR, + ID_ENVELOPE_ZOOM_IN, + ID_ENVELOPE_ZOOM_OUT, }; @@ -81,6 +85,8 @@ ON_COMMAND(ID_ENVELOPE_PITCH, OnEnvPitchChanged) ON_COMMAND(ID_ENVELOPE_FILTER, OnEnvFilterChanged) ON_COMMAND(ID_ENVELOPE_VIEWGRID, OnEnvToggleGrid) //rewbs.envRowGrid + ON_COMMAND(ID_ENVELOPE_ZOOM_IN, OnEnvZoomIn) + ON_COMMAND(ID_ENVELOPE_ZOOM_OUT, OnEnvZoomOut) ON_COMMAND(ID_ENVSEL_VOLUME, OnSelectVolumeEnv) ON_COMMAND(ID_ENVSEL_PANNING, OnSelectPanningEnv) ON_COMMAND(ID_ENVSEL_PITCH, OnSelectPitchEnv) @@ -118,7 +124,7 @@ m_GridScrollPos = -1; //end rewbs.envRowGrid m_nDragItem = 1; - + m_fZoom = ENV_ZOOM; } @@ -142,9 +148,9 @@ SIZE sizeTotal, sizePage, sizeLine; UINT ntickmax = EnvGetTick(EnvGetLastPoint()); - sizeTotal.cx = (ntickmax + 2) * ENV_ZOOM; + sizeTotal.cx = (INT)((ntickmax + 2) * m_fZoom); sizeTotal.cy = 1; - sizeLine.cx = ENV_ZOOM; + sizeLine.cx = (INT)m_fZoom; sizeLine.cy = 2; sizePage.cx = sizeLine.cx * 4; sizePage.cy = sizeLine.cy; @@ -625,7 +631,7 @@ int CViewInstrument::TickToScreen(int nTick) const //------------------------------------------------ { - return ((nTick+1) * ENV_ZOOM) - GetScrollPos(SB_HORZ); + return ((int)((nTick + 1) * m_fZoom)) - GetScrollPos(SB_HORZ); } int CViewInstrument::PointToScreen(int nPoint) const @@ -638,14 +644,14 @@ int CViewInstrument::ScreenToTick(int x) const //-------------------------------------------- { - return (GetScrollPos(SB_HORZ) + x + 1 - ENV_ZOOM) / ENV_ZOOM; + return (int)(((float)GetScrollPos(SB_HORZ) + (float)x + 1 - m_fZoom) / m_fZoom); } int CViewInstrument::QuickScreenToTick(int x, int cachedScrollPos) const //---------------------------------------------------------------------- { - return (cachedScrollPos + x + 1 - ENV_ZOOM) / ENV_ZOOM; + return (int)(((float)cachedScrollPos + (float)x + 1 - m_fZoom) / m_fZoom); } int CViewInstrument::ScreenToValue(int y) const @@ -745,6 +751,8 @@ case ID_ENVELOPE_FILTER: if (!(pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else if (EnvGetFilterEnv()) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_VIEWGRID: if (m_bGrid) dwStyle |= NCBTNS_CHECKED; break; + case ID_ENVELOPE_ZOOM_IN: if (m_fZoom >= ENV_MAX_ZOOM) dwStyle |= NCBTNS_DISABLED; break; + case ID_ENVELOPE_ZOOM_OUT: if (m_fZoom <= ENV_MIN_ZOOM) dwStyle |= NCBTNS_DISABLED; break; } if (m_nBtnMouseOver == i) { @@ -884,10 +892,10 @@ // Drawing Loop Start/End if (EnvGetLoop()) { - int x1 = PointToScreen(EnvGetLoopStart()) - (ENV_ZOOM/2); + int x1 = PointToScreen(EnvGetLoopStart()) - (int)(m_fZoom / 2); m_dcMemMain.MoveTo(x1, 0); m_dcMemMain.LineTo(x1, m_rcClient.bottom); - int x2 = PointToScreen(EnvGetLoopEnd()) + (ENV_ZOOM/2); + int x2 = PointToScreen(EnvGetLoopEnd()) + (int)(m_fZoom / 2); m_dcMemMain.MoveTo(x2, 0); m_dcMemMain.LineTo(x2, m_rcClient.bottom); } @@ -897,12 +905,12 @@ m_dcMemMain.SelectObject(CMainFrame::penHalfDarkGray); int nspace = m_rcClient.bottom/4; int n1 = EnvGetSustainStart(); - int x1 = PointToScreen(n1) - (ENV_ZOOM/2); + int x1 = PointToScreen(n1) - (int)(m_fZoom / 2); int y1 = ValueToScreen(EnvGetValue(n1)); m_dcMemMain.MoveTo(x1, y1 - nspace); m_dcMemMain.LineTo(x1, y1+nspace); int n2 = EnvGetSustainEnd(); - int x2 = PointToScreen(n2) + (ENV_ZOOM/2); + int x2 = PointToScreen(n2) + (int)(m_fZoom / 2); int y2 = ValueToScreen(EnvGetValue(n2)); m_dcMemMain.MoveTo(x2, y2-nspace); m_dcMemMain.LineTo(x2, y2+nspace); @@ -916,7 +924,7 @@ UINT releaseNode = EnvGetReleaseNode(); for (UINT i=0; i<=maxpoint; i++) { - int x = (EnvGetTick(i) + 1) * ENV_ZOOM - nScrollPos; + int x = (int)((EnvGetTick(i) + 1) * m_fZoom) - nScrollPos; int y = ValueToScreen(EnvGetValue(i)); rect.left = x - 3; rect.top = y - 3; @@ -1222,6 +1230,8 @@ case ID_ENVELOPE_FILTER: nImage = (dwStyle & NCBTNS_DISABLED) ? IIMAGE_NOFILTERSWITCH : IIMAGE_FILTERSWITCH; break; case ID_INSTRUMENT_SAMPLEMAP: nImage = IIMAGE_SAMPLEMAP; break; case ID_ENVELOPE_VIEWGRID: nImage = IIMAGE_GRID; break; + case ID_ENVELOPE_ZOOM_IN: nImage = (dwStyle & NCBTNS_DISABLED) ? IIMAGE_NOZOOMIN : IIMAGE_ZOOMIN; break; + case ID_ENVELOPE_ZOOM_OUT: nImage = (dwStyle & NCBTNS_DISABLED) ? IIMAGE_NOZOOMOUT : IIMAGE_ZOOMOUT; break; } pDC->Draw3dRect(rect.left-1, rect.top-1, ENV_LEFTBAR_CXBTN+2, ENV_LEFTBAR_CYBTN+2, c3, c4); pDC->Draw3dRect(rect.left, rect.top, ENV_LEFTBAR_CXBTN, ENV_LEFTBAR_CYBTN, c1, c2); @@ -1467,12 +1477,12 @@ if (pt.x <= 0) { UpdateScrollSize(); - OnScrollBy(CSize(pt.x-ENV_ZOOM, 0), TRUE); + OnScrollBy(CSize(pt.x - (int)m_fZoom, 0), TRUE); } if (pt.x >= m_rcClient.right-1) { UpdateScrollSize(); - OnScrollBy(CSize(ENV_ZOOM+pt.x-m_rcClient.right, 0), TRUE); + OnScrollBy(CSize((int)m_fZoom + pt.x - m_rcClient.right, 0), TRUE); } pModDoc->SetModified(); pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_ENVELOPE, NULL); @@ -1487,7 +1497,7 @@ rect.top = ValueToScreen(EnvGetValue(EnvGetSustainStart())) - nspace; rect.bottom = rect.top + nspace * 2; rect.right = PointToScreen(EnvGetSustainStart()) + 1; - rect.left = rect.right - ENV_ZOOM*2; + rect.left = rect.right - (int)(m_fZoom * 2); if (rect.PtInRect(pt)) { bSplitCursor = TRUE; // ENV_DRAGSUSTAINSTART; @@ -1496,7 +1506,7 @@ rect.top = ValueToScreen(EnvGetValue(EnvGetSustainEnd())) - nspace; rect.bottom = rect.top + nspace * 2; rect.left = PointToScreen(EnvGetSustainEnd()) - 1; - rect.right = rect.left + ENV_ZOOM*2; + rect.right = rect.left + (int)(m_fZoom *2); if (rect.PtInRect(pt)) bSplitCursor = TRUE; // ENV_DRAGSUSTAINEND; } } @@ -1505,14 +1515,14 @@ rect.top = m_rcClient.top; rect.bottom = m_rcClient.bottom; rect.right = PointToScreen(EnvGetLoopStart()) + 1; - rect.left = rect.right - ENV_ZOOM*2; + rect.left = rect.right - (int)(m_fZoom * 2); if (rect.PtInRect(pt)) { bSplitCursor = TRUE; // ENV_DRAGLOOPSTART; } else { rect.left = PointToScreen(EnvGetLoopEnd()) - 1; - rect.right = rect.left + ENV_ZOOM*2; + rect.right = rect.left + (int)(m_fZoom * 2); if (rect.PtInRect(pt)) bSplitCursor = TRUE; // ENV_DRAGLOOPEND; } } @@ -1564,7 +1574,7 @@ rect.top = ValueToScreen(EnvGetValue(EnvGetSustainStart())) - nspace; rect.bottom = rect.top + nspace * 2; rect.right = PointToScreen(EnvGetSustainStart()) + 1; - rect.left = rect.right - ENV_ZOOM*2; + rect.left = rect.right - (int)(m_fZoom * 2); if (rect.PtInRect(pt)) { m_nDragItem = ENV_DRAGSUSTAINSTART; @@ -1573,7 +1583,7 @@ rect.top = ValueToScreen(EnvGetValue(EnvGetSustainEnd())) - nspace; rect.bottom = rect.top + nspace * 2; rect.left = PointToScreen(EnvGetSustainEnd()) - 1; - rect.right = rect.left + ENV_ZOOM*2; + rect.right = rect.left + (int)(m_fZoom * 2); if (rect.PtInRect(pt)) m_nDragItem = ENV_DRAGSUSTAINEND; } } @@ -1582,14 +1592,14 @@ rect.top = m_rcClient.top; rect.bottom = m_rcClient.bottom; rect.right = PointToScreen(EnvGetLoopStart()) + 1; - rect.left = rect.right - ENV_ZOOM * 2; + rect.left = rect.right - (int)(m_fZoom * 2); if (rect.PtInRect(pt)) { m_nDragItem = ENV_DRAGLOOPSTART; } else { rect.left = PointToScreen(EnvGetLoopEnd()) - 1; - rect.right = rect.left + ENV_ZOOM*2; + rect.right = rect.left + (int)(m_fZoom * 2); if (rect.PtInRect(pt)) m_nDragItem = ENV_DRAGLOOPEND; } } @@ -1813,7 +1823,7 @@ //rewbs.envRowGrid void CViewInstrument::OnEnvToggleGrid() -//---------------------------------------- +//------------------------------------- { m_bGrid = !m_bGrid; if (m_bGrid) @@ -1862,7 +1872,7 @@ void CViewInstrument::PlayNote(UINT note) -//----------------------------------------------------------------- +//--------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CModDoc *pModDoc = GetDocument(); @@ -2187,6 +2197,8 @@ case kcInstrumentNew: SendCtrlMessage(IDC_INSTRUMENT_NEW); return wParam; // envelope editor + case kcInstrumentEnvelopeZoomIn: OnEnvZoomIn(); return wParam; + case kcInstrumentEnvelopeZoomOut: OnEnvZoomOut(); return wParam; case kcInstrumentEnvelopePointPrev: EnvKbdSelectPrevPoint(); return wParam; case kcInstrumentEnvelopePointNext: EnvKbdSelectNextPoint(); return wParam; case kcInstrumentEnvelopePointMoveLeft: EnvKbdMovePointLeft(); return wParam; @@ -2242,6 +2254,17 @@ } +void CViewInstrument::EnvSetZoom(float fNewZoom) +//---------------------------------------------- +{ + m_fZoom = fNewZoom; + Limit(m_fZoom, ENV_MIN_ZOOM, ENV_MAX_ZOOM); + InvalidateRect(NULL, FALSE); + UpdateScrollSize(); + UpdateNcButtonState(); +} + + //////////////////////////////////////// // Envelope Editor - Keyboard actions Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2010-02-22 20:53:09 UTC (rev 508) +++ trunk/OpenMPT/mptrack/View_ins.h 2010-02-23 15:53:10 UTC (rev 509) @@ -6,7 +6,7 @@ #define INSSTATUS_SPLITCURSOR 0x04 // Non-Client toolbar buttons -#define ENV_LEFTBAR_BUTTONS 17 +#define ENV_LEFTBAR_BUTTONS 19 //========================================== class CViewInstrument: public CModScrollView @@ -34,6 +34,8 @@ CDC m_dcMemMain; CBitmap m_bmpMemMain; CBitmap* oldBitmap; + + float m_fZoom; //rewbs.envRowGrid public: @@ -133,6 +135,10 @@ void PlayNote(UINT note); //rewbs.customKeys void DrawGrid(CDC *memDC, UINT speed); //rewbs.envRowGrid + void OnEnvZoomIn() { EnvSetZoom(m_fZoom + 1); }; + void OnEnvZoomOut() { EnvSetZoom(m_fZoom - 1); }; + void EnvSetZoom(float fNewZoom); + public: //{{AFX_VIRTUAL(CViewInstrument) virtual void OnDraw(CDC *); Modified: trunk/OpenMPT/mptrack/res/envbar.bmp =================================================================== (Binary files differ) Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2010-02-22 20:53:09 UTC (rev 508) +++ trunk/OpenMPT/mptrack/resource.h 2010-02-23 15:53:10 UTC (rev 509) @@ -1203,6 +1203,8 @@ #define ID_NOTEMAP_TRANS_UP 60446 #define ID_NOTEMAP_TRANS_DOWN 60447 #define ID_PATTERN_EDIT_PCNOTE_PLUGIN 60448 +#define ID_ENVELOPE_ZOOM_IN 60449 +#define ID_ENVELOPE_ZOOM_OUT 60450 // Next default values for new objects // @@ -1210,7 +1212,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 526 -#define _APS_NEXT_COMMAND_VALUE 60449 +#define _APS_NEXT_COMMAND_VALUE 60451 #define _APS_NEXT_CONTROL_VALUE 2427 #define _APS_NEXT_SYMED_VALUE 901 #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |