|
From: <pst...@us...> - 2013-04-07 22:07:10
|
Revision: 1012
http://sourceforge.net/p/jazzplusplus/code/1012
Author: pstieber
Date: 2013-04-07 22:07:07 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
Added a new rhythm array control.
Added Paths:
-----------
trunk/jazz/src/RhythmArrayControl.cpp
trunk/jazz/src/RhythmArrayControl.h
Added: trunk/jazz/src/RhythmArrayControl.cpp
===================================================================
--- trunk/jazz/src/RhythmArrayControl.cpp (rev 0)
+++ trunk/jazz/src/RhythmArrayControl.cpp 2013-04-07 22:07:07 UTC (rev 1012)
@@ -0,0 +1,92 @@
+//*****************************************************************************
+// The JAZZ++ Midi Sequencer
+//
+// Copyright (C) 2013 Peter J. Stieber
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//*****************************************************************************
+
+#include "RhythmArrayControl.h"
+
+#include "Random.h"
+
+#include <wx/dc.h>
+
+#include <sstream>
+
+using namespace std;
+
+//*****************************************************************************
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZRhythmArrayControl::JZRhythmArrayControl(
+ wxWindow* pParent,
+ wxWindowID Id,
+ const JZRndArray& RandomArray,
+ const wxPoint& Position,
+ const wxSize& Size,
+ long WindowStyle)
+ : JZArrayControl(pParent, Id, RandomArray, Position, Size, WindowStyle),
+ mStepsPerCount(4),
+ mCountPerBar(4)
+{
+ mStyleBits |= ARED_RHYTHM;
+
+ SetXMinMax(1, mStepsPerCount * mCountPerBar);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZRhythmArrayControl::SetMeter(
+ int StepsPerCount,
+ int CountPerBar,
+ int BarCount)
+{
+ mStepsPerCount = StepsPerCount;
+ mCountPerBar = CountPerBar;
+ mpRandomArray->Resize(StepsPerCount * CountPerBar * BarCount);
+ SetXMinMax(1, StepsPerCount * CountPerBar * BarCount);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZRhythmArrayControl::DrawXTicks(wxDC& Dc)
+{
+ if (!(mStyleBits & ARED_RHYTHM))
+ {
+ JZArrayControl::DrawXTicks(Dc);
+ return;
+ }
+
+ assert(mStepsPerCount && mCountPerBar);
+
+ Dc.SetFont(*wxSMALL_FONT);
+
+ int TextWidth, TextHeight;
+ for (int i = 0; i < mpRandomArray->Size(); i += mStepsPerCount)
+ {
+ int Mark = (i / mStepsPerCount) % mCountPerBar + 1;
+ ostringstream Oss;
+ Oss << Mark;
+ int YPosition = mY + mHeight;
+ int XPosition = (int)(mX + (i + 0.5) * mWidth / mpRandomArray->Size());
+ Dc.GetTextExtent(Oss.str(), &TextWidth, &TextHeight);
+ XPosition -= (int)(TextWidth / 2.0);
+ Dc.DrawText(Oss.str(), XPosition, YPosition);
+ }
+
+ Dc.SetFont(*wxNORMAL_FONT);
+}
Property changes on: trunk/jazz/src/RhythmArrayControl.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/jazz/src/RhythmArrayControl.h
===================================================================
--- trunk/jazz/src/RhythmArrayControl.h (rev 0)
+++ trunk/jazz/src/RhythmArrayControl.h 2013-04-07 22:07:07 UTC (rev 1012)
@@ -0,0 +1,49 @@
+//*****************************************************************************
+// The JAZZ++ Midi Sequencer
+//
+// Copyright (C) 2013 Peter J. Stieber
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//*****************************************************************************
+
+#pragma once
+
+#include "ArrayControl.h"
+
+//*****************************************************************************
+//*****************************************************************************
+class JZRhythmArrayControl : public JZArrayControl
+{
+ public:
+
+ JZRhythmArrayControl(
+ wxWindow* pParent,
+ wxWindowID Id,
+ const JZRndArray& RandomArray,
+ const wxPoint& Position = wxDefaultPosition,
+ const wxSize& Size = wxSize(40, 40),
+ long WindowStyle = wxNO_BORDER);
+
+ void SetMeter(int StepsPerCount, int CountPerBar, int BarCount);
+
+ protected:
+
+ virtual void DrawXTicks(wxDC& Dc);
+
+ private:
+
+ int mStepsPerCount;
+ int mCountPerBar;
+};
Property changes on: trunk/jazz/src/RhythmArrayControl.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|