[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sc-devel] SCKnob



Hello all,
I am attaching the primitive files for SCKnob.
For now it looks exactly like Knob since I did a really fast port of
the pen methods. The drawing code can and will be optimized lots.
let me know if you want me to commit this.

initial benchmark results are not surprising (since its the same as
Knob _for_ now):
//SCKnob
(
{
	250000.do {
		k.value_( rrand(0,100) * 0.01 );
	}
}.bench
)
time to run: 1.222836244 seconds.
1.222836244


//Knob
(
{
	250000.do {
		m.value_( rrand(0,100) * 0.01 );
	}
}.bench
)
time to run: 1.272859799 seconds.
1.272859799


cheers,

x
/*
	SuperCollider real time audio synthesis system
    Copyright (c) 2002 James McCartney. All rights reserved.
	http://www.audiosynth.com

    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include "SCView.h"

// blackrain.sc dot gmail dot com - 1205
class SCKnob : public SCView
{
public:	
	SCKnob(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds); 

	virtual void draw(SCRect inDamage);
	virtual void mouseBeginTrack(SCPoint where, int modifiers, NSEvent *theEvent);
	virtual void mouseTrack(SCPoint where, int modifiers, NSEvent *theEvent);
	
	double value() { return mValue; }
	bool setValue(double inValue, bool send);

	virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
	virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);

	virtual bool canReceiveDrag();
	virtual void receiveDrag();

protected:
	virtual void setValueFromPoint(SCPoint point, int modifiers);
	
	double mValue, mStepSize, mStepScale, mStep;
	int mTrackMode, mStyle;
	SCPoint mHit;
	bool mCentered;
	CGPoint center;
	SCColor mColors[4];
};

Attachment: SCKnob.M
Description: Binary data

Attachment: SCKnob design.scd
Description: Binary data

Attachment: SCKnob.sc
Description: Binary data