Permalink
Browse files

SC3 iPhone port, lang and server

  • Loading branch information...
1 parent 2828678 commit 97f38f8fed9eb4711d46da579335c24c320b119d Axel Balley committed Jul 17, 2009
Showing with 14,196 additions and 68 deletions.
  1. +2 −1 Headers/app/DrawBackground.h
  2. +5 −0 Headers/app/SCGeom.h
  3. +70 −0 Headers/app/iPhone/iPhoneSCGraphView.h
  4. +498 −0 Headers/app/iPhone/iPhoneSCView.h
  5. +1 −1 Headers/common/SC_Endian.h
  6. +1 −1 Headers/common/SC_StandAloneInfo_Darwin.h
  7. +299 −0 Headers/common/SC_VFP11.h
  8. +5 −0 Headers/plugin_interface/SC_InterfaceTable.h
  9. +3 −0 Headers/plugin_interface/SC_PlugIn.h
  10. +2 −2 Headers/plugin_interface/SC_WorldOptions.h
  11. +6 −0 Headers/plugin_interface/clz.h
  12. +1 −1 Headers/server/SC_ComPort.h
  13. +52 −0 Headers/server/SC_CoreAudio.h
  14. +10 −0 README IPHONE
  15. +6 −1 Source/app/DrawBackground.M
  16. +30 −0 Source/app/iPhone/LiveCodingView.h
  17. +102 −0 Source/app/iPhone/LiveCodingView.mm
  18. +299 −0 Source/app/iPhone/iPhoneGUIPrimitives.mm
  19. +870 −0 Source/app/iPhone/iPhoneSCGraphView.mm
  20. +46 −0 Source/app/iPhone/iPhoneSCNSWindow.h
  21. +72 −0 Source/app/iPhone/iPhoneSCNSWindow.mm
  22. +2,477 −0 Source/app/iPhone/iPhoneSCView.mm
  23. +53 −0 Source/app/iPhone/iSCLangController.h
  24. +620 −0 Source/app/iPhone/iSCLangController.mm
  25. +20 −0 Source/app/iPhone/isclangAppDelegate.h
  26. +31 −0 Source/app/iPhone/isclangAppDelegate.m
  27. +17 −0 Source/app/iPhone/isclang_main.m
  28. +39 −17 Source/common/SC_DirUtils.cpp
  29. +2 −2 Source/common/SC_StandAloneInfo_Darwin.cpp
  30. +9 −1 Source/common/dtoa.c
  31. +64 −0 Source/common/iPhone/DirBrowserView.h
  32. +436 −0 Source/common/iPhone/DirBrowserView.mm
  33. +15 −1 Source/common/sc_popen.cpp
  34. +5 −2 Source/lang/LangPrimSource/PyrPrimitive.cpp
  35. +5 −0 Source/lang/LangPrimSource/PyrUnixPrim.cpp
  36. +1 −1 Source/lang/LangPrimSource/SC_ComPort.cpp
  37. +7 −5 Source/plugins/BinaryOpUGens.cpp
  38. +2 −1 Source/plugins/ChaosUGens.cpp
  39. +1 −1 Source/plugins/DelayUGens.cpp
  40. +1 −1 Source/plugins/DemandUGens.cpp
  41. +1 −1 Source/plugins/DiskIO_UGens.cpp
  42. +1 −1 Source/plugins/DynNoiseUGens.cpp
  43. +1 −2 Source/plugins/FilterUGens.cpp
  44. +2 −1 Source/plugins/GendynUGens.cpp
  45. +1 −1 Source/plugins/GrainUGens.cpp
  46. +88 −2 Source/plugins/IOUGens.cpp
  47. +1 −1 Source/plugins/LFUGens.cpp
  48. +11 −3 Source/plugins/MulAddUGens.cpp
  49. +1 −1 Source/plugins/NoiseUGens.cpp
  50. +48 −6 Source/plugins/OscUGens.cpp
  51. +1 −1 Source/plugins/PanUGens.cpp
  52. +1 −1 Source/plugins/PhysicalModelingUGens.cpp
  53. +1 −1 Source/plugins/ReverbUGens.cpp
  54. +1 −1 Source/plugins/TestUGens.cpp
  55. +1 −1 Source/plugins/TriggerUGens.cpp
  56. +1 −1 Source/plugins/UnaryOpUGens.cpp
  57. +228 −0 Source/plugins/iPhoneUGens.mm
  58. +4 −1 Source/server/SC_ComPort.cpp
  59. +599 −0 Source/server/SC_CoreAudio.cpp
  60. +48 −1 Source/server/SC_Lib_Cintf.cpp
  61. +1 −1 Source/server/SC_World.cpp
  62. +48 −0 Source/server/iPhone/iSCSynthController.h
  63. +205 −0 Source/server/iPhone/iSCSynthController.mm
  64. +20 −0 Source/server/iPhone/iscsynthAppDelegate.h
  65. +31 −0 Source/server/iPhone/iscsynthAppDelegate.m
  66. +17 −0 Source/server/iPhone/iscsynthmain.m
  67. +16 −0 build/SCClassLibrary/Common/Audio/iPhoneUGens.sc
  68. +273 −0 build/SCClassLibrary/Common/GUI/iphone/Base/GUIScreen.sc
  69. +40 −0 build/SCClassLibrary/Common/GUI/iphone/Base/SCFont.sc
  70. +1,006 −0 build/SCClassLibrary/Common/GUI/iphone/Base/SCView.sc
  71. +2 −1 build/SCClassLibrary/DefaultLibrary/Main.sc
  72. +4 −0 build/SCClassLibrary/Platform/iphone/extMain.sc
  73. +26 −0 build/SCClassLibrary/Platform/iphone/extString.sc
  74. +106 −0 build/SCClassLibrary/Platform/iphone/iPhoneGUI.sc
  75. +34 −0 build/SCClassLibrary/Platform/iphone/iPhonePlatform.sc
  76. +30 −0 iPhone Resources/SuperCollider.plist
  77. +302 −0 iPhone Resources/SuperCollider_Browser.xib
  78. +284 −0 iPhone Resources/SuperCollider_FileTransfer.xib
  79. +874 −0 iPhone Resources/SuperCollider_MainWindow.xib
  80. BIN iPhone Resources/icon.png
  81. +30 −0 iPhone Resources/iscsynth.plist
  82. +941 −0 iPhone Resources/iscsynth_MainWindow.xib
  83. +23 −0 iPhone Resources/patches/accelerometer.rtf
  84. +31 −0 iPhone Resources/patches/acid.rtf
  85. +19 −0 iPhone Resources/patches/buffer.rtf
  86. +21 −0 iPhone Resources/patches/klank.rtf
  87. +23 −0 iPhone Resources/patches/pitch.rtf
  88. +27 −0 iPhone Resources/patches/reverb.rtf
  89. +21 −0 iPhone Resources/patches/sines.rtf
  90. +18 −0 iPhone Resources/patches/window.rtf
  91. BIN iPhone Resources/sounds/a11wlk01.wav
  92. +1,244 −0 iPhone_Language.xcodeproj/project.pbxproj
  93. +1,254 −0 iPhone_Synth.xcodeproj/project.pbxproj
View
3 Headers/app/DrawBackground.h
@@ -72,6 +72,7 @@ class HiliteGradientBackground : public GradientBackground
};
// SCImageBackground
+#ifndef SC_IPHONE
@class SCImage;
class SCImageBackground : public DrawBackground
@@ -93,7 +94,7 @@ class SCImageBackground : public DrawBackground
float mSwappedYOrigin;
float mOriginalYOrigin;
};
-
+#endif
/*
class TiledBackground : public DrawBackground
{
View
5 Headers/app/SCGeom.h
@@ -18,7 +18,12 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifdef SC_DARWIN
#import <Carbon/Carbon.h>
+#endif
+#ifdef SC_IPHONE
+#import <UIKit/UIKit.h>
+#endif
#include "SC_BoundsMacros.h"
struct SCColor {
View
70 Headers/app/iPhone/iPhoneSCGraphView.h
@@ -0,0 +1,70 @@
+/*
+ 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
+*/
+
+#import <UIKit/UIKit.h>
+#import "iPhoneSCView.h"
+
+@interface SCGraphView : UIView
+{
+ struct PyrObject *mWindowObj;
+ SCTopView *mTopView;
+ bool mDragStarted;
+ SCView* mMenuView;
+ bool windowShouldClose;
+ bool acceptsClickThrough;
+ bool autoScrolls;
+}
+
+- (void)drawRect: (CGRect)bounds;
+/*
+- (void) keyDown: (NSEvent*) event;
+- (void) keyUp: (NSEvent*) event;
+- (void) mouseDown: (NSEvent*) event;
+- (void) mouseMoved:(NSEvent*) theEvent; //jan t
+*/
+- (void)setSCObject: (struct PyrObject*)inObject;
+- (struct PyrObject*)getSCObject;
+- (BOOL)isFlipped;
+- (BOOL)mouseDownCanMoveWindow;
+
+- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
+
+- (void)setSCTopView: (SCTopView*)inView;
+//- (void)dealloc;
+- (void)closeWindow;
+- (void)willClose;
+- (void)setWindowShouldClose:(BOOL)boo;
+- (BOOL)windowShouldClose;
+- (void)setAcceptsClickThrough:(BOOL)boo;
+- (void)setAutoScrolls:(BOOL)boo;
+- (void) beginDragFrom: (CGPoint)where of: (PyrSlot*)slot string:(NSString*) string;
+
+//- (NSMenu*) menuForEvent:(NSEvent*)event;
+- (void)startMenuTracking: (SCView*) inView;
+
+- (IBAction) toggleUIEditMode: (id) sender;
+- (void)scrollViewResized:(NSNotification *)notification;
+- (void)userScrolled:(NSNotification *)notification;
+- (void)setFrameSizeToMinimum;
+
+@end
View
498 Headers/app/iPhone/iPhoneSCView.h
@@ -0,0 +1,498 @@
+/*
+ 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
+*/
+
+#import "DrawBackground.h"
+#include "PyrObject.h"
+
+enum {
+ layout_NoResize,
+ layout_Resize
+};
+
+enum {
+ // mHResize
+ layout_FixedLeft = -1,
+ layout_HElastic,
+ layout_FixedRight,
+};
+enum {
+ // mVResize
+ layout_FixedTop = -1,
+ layout_VElastic,
+ layout_FixedBottom
+};
+
+enum {
+ view_ResizeConstructionMode,
+ view_PositionConstructionMode,
+};
+
+struct Layout
+{
+ Layout();
+
+ // layout params for dynamic layout views
+ float mMinWidth, mMaxWidth, mMinHeight, mMaxHeight;
+ float mWeight;
+ bool mShouldResize;
+ SCRect bounds; //relative Bounds in SCCompositeView
+ // layout params for composite views
+ char mHResize, mVResize;
+};
+
+
+
+class SCView;
+class SCContainerView;
+class SCTopView;
+
+typedef SCView* (*SCViewCtor)(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+
+struct SCViewMaker
+{
+ SCViewMaker(const char* inName, SCViewCtor inCtor);
+ static SCView* MakeSCView(PyrObject* inObj, SCContainerView *inParent, SCRect inBounds, const char* classname);
+
+ SCViewMaker *mNext;
+ SCViewCtor mCtor;
+ const char* mName;
+};
+
+extern SCViewMaker *gSCViewMakers;
+extern SCView *gAnimatedViews;
+
+class SCView
+{
+public:
+ SCView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCView();
+
+ virtual void draw(SCRect inDamage);
+ virtual void drawFocus(SCRect inDamage);
+ virtual void drawDisabled(SCRect inDamage);
+ virtual void drawDragHilite(SCRect inDamage);
+ virtual void drawIfNecessary(SCRect inDamage);
+ virtual void touchBeginTrack(SCPoint where, UITouch *touch);
+ virtual void touchTrack(SCPoint where, UITouch *touch);
+ virtual void touchEndTrack(SCPoint where, UITouch *touch);
+ virtual void touchOver(SCPoint where, UITouch *touch);
+ virtual void draggingEntered (SCPoint where);
+ virtual void draggingUpdated (SCPoint where);
+ virtual void keyDown(int character, int modifiers, unsigned short keycode);
+ virtual void keyUp(int character, int modifiers, unsigned short keycode);
+ virtual void keyModifiersChanged(int modifiers);
+ virtual void touchDownAction(SCPoint where, UITouch *touch);
+ virtual void touchMoveAction(SCPoint where, UITouch *touch);
+ virtual void touchUpAction(SCPoint where, UITouch *touch);
+ void doConstructionMove(SCPoint where);
+ void setConstructionModeFromPoint(SCPoint where);
+ virtual bool shouldDim();
+ void beginDrag(SCPoint where);
+
+ virtual bool canReceiveDrag();
+ virtual void receiveDrag();
+
+ bool isFocus() const;
+ bool hit(SCPoint p) const;
+ void refresh();
+ virtual void refreshInRect(SCRect b);
+ void refreshFocus();
+ void setDragHilite(bool inFlag);
+
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+
+ virtual void setVisibleFromParent() { } // does nothing, needed for Cocoa views
+
+ virtual bool isDragSource() const;
+ virtual SCView* findView(SCPoint where);
+ virtual SCView* findViewByID(int32 inID);
+ virtual void makeFocus(bool focus);
+ virtual SCView* nextFocus(bool *foundFocus, bool canFocus);
+ virtual SCView* prevFocus(SCView **prevView, bool canFocus);
+ virtual bool canFocus();
+ //virtual NSView* focusResponder();
+
+ void sendMessage(PyrSymbol *method, int numargs, PyrSlot *args, PyrSlot *result);
+
+ virtual void setBounds(SCRect inBounds);
+ virtual SCRect getBounds();
+ virtual SCRect getDrawBounds(); //relative to ContainerView
+ virtual Layout getLayout();
+// virtual void setLayout(Layout inLayout);
+
+
+ SCView* next() { return mNext; }
+ SCContainerView* parent() { return mParent; }
+
+ //virtual NSMenu* contextMenu(SCPoint inPoint);
+
+ virtual void setMenuItemChosen(int inItem) {}
+
+ PyrObject* GetSCObj() { return mObj; }
+ SCView* NextAnimatedView() const { return mNextAnimatedView; }
+
+ void startAnimation();
+ void stopAnimation();
+ virtual void animate() { refresh(); }
+
+ virtual bool isScroller() { return false; }
+ virtual bool isSubViewScroller() { return false; }
+ virtual bool isContainer() { return false; }
+ virtual SCRect checkMinimumSize() { return mBounds; }
+ virtual bool relativeOrigin() {return false;}
+
+ bool isTopContainer(){ return (!mParent);};
+
+protected:
+ friend class SCContainerView;
+ friend class SCScrollView;
+
+ SCView *mNext;
+ SCView *mNextAnimatedView;
+ SCView *mPrevAnimatedView;
+ SCContainerView *mParent;
+ SCTopView *mTop;
+ PyrObject* mObj;
+ SCRect mBounds;
+ Layout mLayout;
+ DrawBackground* mBackground;
+ DrawBackground* mBackgroundImage;
+ bool mVisible;
+ bool mEnabled;
+ bool mCanFocus;
+ bool mDragHilite;
+ int32 mID;
+ int mConstructionMode;
+ SCColor mFocusColor;
+ NSString *mDragLabel;
+
+};
+
+
+class SCContainerView : public SCView
+{
+public:
+ SCContainerView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCContainerView();
+
+ virtual void drawIfNecessary(SCRect inDamage);
+
+ virtual void add(SCView *inChild);
+ virtual void remove(SCView *inChild);
+ virtual SCView* findView(SCPoint where);
+ virtual SCView* findViewByID(int32 inID);
+ virtual void makeFocus(bool focus);
+ virtual SCView* nextFocus(bool *foundFocus, bool canFocus);
+ virtual SCView* prevFocus(SCView **prevView, bool canFocus);
+ virtual bool canFocus();
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual SCRect checkMinimumSize();
+ virtual void setVisibleFromParent();
+ virtual bool isVisible() {return mVisible && mParent->isVisible(); }
+ virtual bool relativeOrigin() {return mRelativeOrigin;}
+ virtual bool isContainer() { return true; }
+
+protected:
+ SCView *mChildren;
+ int mNumChildren;
+ bool mRelativeOrigin;
+};
+
+class SCCompositeView : public SCContainerView
+{
+public:
+ SCCompositeView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCCompositeView();
+
+ virtual void setBounds(SCRect inBounds);
+protected:
+};
+
+class SCLayoutView : public SCContainerView
+{
+public:
+ SCLayoutView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCLayoutView();
+
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual void add(SCView *inChild);
+
+protected:
+ float mSpacing;
+};
+
+class SCHLayoutView : public SCLayoutView
+{
+public:
+ SCHLayoutView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCHLayoutView();
+
+ virtual void setBounds(SCRect inBounds);
+
+protected:
+};
+
+class SCVLayoutView : public SCLayoutView
+{
+public:
+ SCVLayoutView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCVLayoutView();
+
+ virtual void setBounds(SCRect inBounds);
+
+protected:
+};
+
+// tell host to draw stuff.
+typedef void (*DamageCallback)(SCRect inRect, void *inData);
+typedef void (*DragCallback)(SCPoint where, PyrSlot* inSlot, NSString* inString, NSString* label, void *inData);
+
+class SCTopView : public SCCompositeView
+{
+public:
+ SCTopView(PyrObject* inObj, SCRect inBounds);
+
+ SCView *focusView() {
+ if(isSubViewScroller()) {
+ return mTop->focusView();
+ } else {
+ return mFocusView;
+ }
+ }
+
+ void forgetView(SCView *view);
+
+ void resetFocus();
+ void addDamage(SCRect inRect);
+ void beginDragCallback(SCPoint where, PyrSlot* slot, NSString* string, NSString* label);
+
+ void setDamageCallback(DamageCallback inFunc, void *inHostData)
+ { mDamageCallback = inFunc; mHostData = inHostData; }
+ void setDragCallback(DragCallback inFunc)
+ { mDragCallback = inFunc; }
+
+ void tabNextFocus();
+ void tabPrevFocus();
+ void setDragView(SCView *inView);
+
+ UIView* GetUIView() { return mUIView; }
+ void SetUIView(UIView* inView) { mUIView = inView; }
+
+ bool ConstructionMode() { return mConstructionMode; }
+ void SetConstructionMode(bool inFlag) { mConstructionMode = inFlag; }
+
+ virtual void drawFocus(SCRect inDamage);
+ virtual bool canReceiveDrag();
+ virtual void receiveDrag();
+ virtual void setInternalBounds(SCRect internalBounds);
+ virtual bool isVisible() {return mVisible; }
+protected:
+ friend class SCView;
+ void focusIs(SCView *inView) {
+ if(isSubViewScroller()) {
+ mTop->focusIs(inView);
+ } else {
+ mFocusView = inView;
+ }
+ }
+
+ DamageCallback mDamageCallback;
+ DragCallback mDragCallback;
+ void *mHostData;
+ SCView *mFocusView;
+ SCView *mDragView;
+ UIView *mUIView;
+
+ bool mConstructionMode;
+};
+
+/*
+ SCScrollTopView and SCScrollView by Scott Wilson
+ Development funded in part by the Arts and Humanites Research Council http://www.ahrc.ac.uk/
+ */
+
+class SCScrollTopView : public SCTopView
+{
+public:
+ SCScrollTopView(PyrObject* inObj, SCRect inBounds);
+
+ UIScrollView* GetScrollView() { return mUIScrollView; }
+ void SetUIScrollView(UIScrollView* inView) { mUIScrollView = inView; }
+
+ virtual bool isScroller() { return true; }
+
+ virtual SCRect getDrawBounds();
+ virtual void setInternalBounds(SCRect inBounds);
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual SCRect checkMinimumSize();
+ virtual void add(SCView *inChild);
+ virtual void remove(SCView *inChild);
+ bool isInSetClipViewOrigin() { return mInSetClipViewOrigin; }
+ void setInSetClipViewOrigin(bool flag) { mInSetClipViewOrigin = flag; }
+
+protected:
+ UIScrollView *mUIScrollView;
+ bool mInSetClipViewOrigin;
+};
+
+class SCScrollView : public SCScrollTopView
+{
+public:
+ SCScrollView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCScrollView();
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual void setVisibleFromParent();
+ //virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+
+ virtual void setBounds(SCRect inBounds);
+ virtual SCRect getBounds();
+ virtual void add(SCView *inChild);
+// virtual void remove(SCView *inChild);
+
+ virtual bool isSubViewScroller() { return true; }
+
+ virtual void drawIfNecessary(SCRect inDamage);
+ virtual void drawSubViewIfNecessary(SCRect inDamage);
+ virtual bool isVisible() {return mVisible && mParent->isVisible(); }
+ virtual bool relativeOrigin() {return false;}
+};
+
+inline bool SCView::isFocus() const { return mTop->focusView() == this; }
+
+class SCSlider : public SCView
+{
+public:
+ SCSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+
+ virtual void draw(SCRect inDamage);
+ virtual void touchTrack(SCPoint where, UITouch *touch);
+
+ 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);
+ void calcThumbRect(SCRect bounds);
+
+ SCRect mThumbRect;
+ double mValue, mStepSize, mStepScale;
+ DrawBackground* mKnob;
+ float mThumbSize;
+};
+SCView* NewSCSlider(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+
+
+const int kLabelSize = 64;
+struct SCButtonState
+{
+ char mLabel[kLabelSize];
+ SCColor mLabelColor;
+ SCColor mButtonColor;
+};
+
+const int kFontNameSize = 80;
+
+class SCButton : public SCView
+{
+public:
+ SCButton(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCButton();
+
+ virtual void draw(SCRect inDamage);
+ virtual void touchTrack(SCPoint where, UITouch *touch);
+ virtual void touchEndTrack(SCPoint where, UITouch *touch);
+
+ bool setValue(int inValue, bool send, int modifiers);
+
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+
+ virtual bool canReceiveDrag();
+ virtual void receiveDrag();
+
+protected:
+
+ int mValue;
+ char mFontName[kFontNameSize];
+ float mFontSize;
+ int mNumStates;
+ SCButtonState *mStates;
+ bool mPushed;
+};
+SCView* NewSCButton(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+
+enum {
+ kSCAlignLeft = -1,
+ kSCAlignCenter,
+ kSCAlignRight
+};
+
+class SCStaticText : public SCView
+{
+public:
+ SCStaticText(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCStaticText();
+
+ virtual void draw(SCRect inDamage);
+ virtual bool shouldDim();
+
+ virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+
+protected:
+ virtual void drawString(SCRect bounds);
+
+ char *mString;
+ char mFontName[kFontNameSize];
+ float mFontSize;
+ SCColor mStringColor;
+ int mAlignment;
+
+};
+SCView* NewSCStaticText(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+
+class SCNumberBox : public SCStaticText
+{
+public:
+ SCNumberBox(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
+ virtual ~SCNumberBox();
+
+ virtual void draw(SCRect inDamage);
+ virtual bool shouldDim();
+
+ virtual void touchTrack(SCPoint where, UITouch *touch);
+ //virtual void mouseEndTrack(SCPoint where, int modifiers);
+
+ //virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
+ //virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
+
+ virtual bool canReceiveDrag();
+ virtual void receiveDrag();
+};
+SCView* NewSCNumberBox(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
View
2 Headers/common/SC_Endian.h
@@ -31,7 +31,7 @@
#ifndef SC_ENDIAN_H_INCLUDED
#define SC_ENDIAN_H_INCLUDED
-#ifdef SC_DARWIN
+#if defined(SC_DARWIN) || defined(SC_IPHONE)
# include <machine/endian.h>
View
2 Headers/common/SC_StandAloneInfo_Darwin.h
@@ -1,4 +1,4 @@
-#ifdef SC_DARWIN
+#if defined(SC_DARWIN) || defined(SC_IPHONE)
#ifndef _SC_StandAloneInfo_
#define _SC_StandAloneInfo_
View
299 Headers/common/SC_VFP11.h
@@ -0,0 +1,299 @@
+#ifndef _SC_VFP11_
+#define _SC_VFP11_
+
+#include <TargetConditionals.h>
+
+#define IPHONE_VEC
+
+
+
+inline void initVFP()
+{
+#if !TARGET_IPHONE_SIMULATOR
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [tmp] "=&r" (tmp)
+ :
+ : "cc", "memory");
+#endif
+}
+
+inline void releaseVFP()
+{
+#if !TARGET_IPHONE_SIMULATOR
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [tmp] "=&r" (tmp)
+ :
+ : "cc", "memory");
+#endif
+}
+
+
+inline void vfill(float *dest, float val, int len)
+{
+#if !TARGET_IPHONE_SIMULATOR
+ float t[4] = {val, val, val, val};
+ float *v = (float *) t;
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+
+ "fldmias %[src1], {s8-s11}\n\t"
+ "1:\n\t"
+ "subs %[len], %[len], #16\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmiasge %[dst]!, {s8-s11}\n\t"
+ "fstmiasge %[dst]!, {s8-s11}\n\t"
+ "bgt 1b\n\t"
+
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [dst] "+&r" (dest), [src1] "+&r" (v), [len] "+&r" (len), [tmp] "=&r" (tmp)
+ :
+ : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+ "cc", "memory");
+#endif
+}
+
+
+// a + b*c
+inline void vmuladd(float *dest, float *a, float *b, float *c, int len)
+{
+#if !TARGET_IPHONE_SIMULATOR
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+
+ "fldmias %[src2]!, {s0-s3}\n\t"
+ "fldmias %[src1]!, {s8-s11}\n\t"
+ "fldmias %[src3]!, {s24-s27}\n\t"
+ "fldmias %[src2]!, {s4-s7}\n\t"
+ "fldmias %[src1]!, {s12-s15}\n\t"
+ "fldmias %[src3]!, {s28-s31}\n\t"
+ "fmacs s8, s0, s24\n\t"
+ "1:\n\t"
+ "subs %[len], %[len], #16\n\t"
+ "fmacs s12, s4, s28\n\t"
+ "fldmiasge %[src2]!, {s0-s3}\n\t"
+ "fldmiasge %[src1]!, {s16-s19}\n\t"
+ "fldmiasge %[src3]!, {s24-s27}\n\t"
+ "fldmiasge %[src2]!, {s4-s7}\n\t"
+ "fldmiasge %[src1]!, {s20-s23}\n\t"
+ "fldmiasge %[src3]!, {s28-s31}\n\t"
+ "fmacsge s16, s0, s24\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmias %[dst]!, {s12-s15}\n\t"
+ "fmacsge s20, s4, s28\n\t"
+ "fldmiasgt %[src2]!, {s0-s3}\n\t"
+ "fldmiasgt %[src1]!, {s8-s11}\n\t"
+ "fldmiasgt %[src3]!, {s24-s27}\n\t"
+ "fldmiasgt %[src2]!, {s4-s7}\n\t"
+ "fldmiasgt %[src1]!, {s12-s15}\n\t"
+ "fldmiasgt %[src3]!, {s28-s31}\n\t"
+ "fmacsge s8, s0, s24\n\t"
+ "fstmiasge %[dst]!, {s16-s19}\n\t"
+ "fstmiasge %[dst]!, {s20-s23}\n\t"
+ "bgt 1b\n\t"
+
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [dst] "+&r" (dest), [src1] "+&r" (a), [src2] "+&r" (b), [src3] "+&r" (c), [len] "+&r" (len), [tmp] "=&r" (tmp)
+ :
+ : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+ "cc", "memory");
+#endif
+}
+
+inline void vscalarmul(float *dest, float scalar, float *b, int len)
+{
+#if !TARGET_IPHONE_SIMULATOR
+ float t[4] = {scalar, scalar, scalar, scalar};
+ float *s = t;
+ int tmp;
+
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+
+ "fldmias %[src1], {s0-s3}\n\t"
+ "fldmias %[src2]!, {s8-s11}\n\t"
+ "fldmias %[src2]!, {s12-s15}\n\t"
+ "fmuls s8, s8, s0\n\t"
+ "1:\n\t"
+ "subs %[len], %[len], #16\n\t"
+ "fmuls s12, s12, s0\n\t"
+ "fldmiasge %[src2]!, {s24-s27}\n\t"
+ "fldmiasge %[src2]!, {s28-s31}\n\t"
+ "fmulsge s24, s24, s0\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmias %[dst]!, {s12-s15}\n\t"
+ "fmulsge s28, s28, s0\n\t"
+ "fldmiasgt %[src2]!, {s8-s11}\n\t"
+ "fldmiasgt %[src2]!, {s12-s15}\n\t"
+ "fmulsge s8, s8, s0\n\t"
+ "fstmiasge %[dst]!, {s24-s27}\n\t"
+ "fstmiasge %[dst]!, {s28-s31}\n\t"
+ "bgt 1b\n\t"
+
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [dst] "+&r" (dest), [src1] "+&r" (s), [src2] "+&r" (b), [len] "+&r" (len), [tmp] "=&r" (tmp)
+ :
+ : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+ "cc", "memory");
+#endif
+}
+
+inline void vmul(float *dest, float *a, const float *b, int len)
+{
+#if !TARGET_IPHONE_SIMULATOR
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+
+ "fldmias %[src1]!, {s0-s3}\n\t"
+ "fldmias %[src2]!, {s8-s11}\n\t"
+ "fldmias %[src1]!, {s4-s7}\n\t"
+ "fldmias %[src2]!, {s12-s15}\n\t"
+ "fmuls s8, s0, s8\n\t"
+ "1:\n\t"
+ "subs %[len], %[len], #16\n\t"
+ "fmuls s12, s4, s12\n\t"
+ "fldmiasge %[src1]!, {s16-s19}\n\t"
+ "fldmiasge %[src2]!, {s24-s27}\n\t"
+ "fldmiasge %[src1]!, {s20-s23}\n\t"
+ "fldmiasge %[src2]!, {s28-s31}\n\t"
+ "fmulsge s24, s16, s24\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmias %[dst]!, {s12-s15}\n\t"
+ "fmulsge s28, s20, s28\n\t"
+ "fldmiasgt %[src1]!, {s0-s3}\n\t"
+ "fldmiasgt %[src2]!, {s8-s11}\n\t"
+ "fldmiasgt %[src1]!, {s4-s7}\n\t"
+ "fldmiasgt %[src2]!, {s12-s15}\n\t"
+ "fmulsge s8, s0, s8\n\t"
+ "fstmiasge %[dst]!, {s24-s27}\n\t"
+ "fstmiasge %[dst]!, {s28-s31}\n\t"
+ "bgt 1b\n\t"
+
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [dst] "+&r" (dest), [src1] "+&r" (a), [src2] "+&r" (b), [len] "+&r" (len), [tmp] "=&r" (tmp)
+ :
+ : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+ "cc", "memory");
+#endif
+}
+
+
+inline void vadd(float *dest, float *a, const float *b, int len)
+{
+#if !TARGET_IPHONE_SIMULATOR
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+
+ "fldmias %[src1]!, {s0-s3}\n\t"
+ "fldmias %[src2]!, {s8-s11}\n\t"
+ "fldmias %[src1]!, {s4-s7}\n\t"
+ "fldmias %[src2]!, {s12-s15}\n\t"
+ "fadds s8, s0, s8\n\t"
+ "1:\n\t"
+ "subs %[len], %[len], #16\n\t"
+ "fadds s12, s4, s12\n\t"
+ "fldmiasge %[src1]!, {s16-s19}\n\t"
+ "fldmiasge %[src2]!, {s24-s27}\n\t"
+ "fldmiasge %[src1]!, {s20-s23}\n\t"
+ "fldmiasge %[src2]!, {s28-s31}\n\t"
+ "faddsge s24, s16, s24\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmias %[dst]!, {s12-s15}\n\t"
+ "faddsge s28, s20, s28\n\t"
+ "fldmiasgt %[src1]!, {s0-s3}\n\t"
+ "fldmiasgt %[src2]!, {s8-s11}\n\t"
+ "fldmiasgt %[src1]!, {s4-s7}\n\t"
+ "fldmiasgt %[src2]!, {s12-s15}\n\t"
+ "faddsge s8, s0, s8\n\t"
+ "fstmiasge %[dst]!, {s24-s27}\n\t"
+ "fstmiasge %[dst]!, {s28-s31}\n\t"
+ "bgt 1b\n\t"
+
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [dst] "+&r" (dest), [src1] "+&r" (a), [src2] "+&r" (b), [len] "+&r" (len), [tmp] "=&r" (tmp)
+ :
+ : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+ "cc", "memory");
+#endif
+}
+
+inline void vcopy(float *dest, float *a, int len)
+{
+#if !TARGET_IPHONE_SIMULATOR
+ int tmp;
+ __asm__ __volatile__(
+ "fmrx %[tmp], fpscr\n\t"
+ "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
+ "fmxr fpscr, %[tmp]\n\t"
+
+ "fldmias %[src1]!, {s8-s11}\n\t"
+ "fldmias %[src1]!, {s12-s15}\n\t"
+ "1:\n\t"
+ "subs %[len], %[len], #16\n\t"
+ "fldmiasge %[src1]!, {s24-s27}\n\t"
+ "fldmiasge %[src1]!, {s28-s31}\n\t"
+ "fstmias %[dst]!, {s8-s11}\n\t"
+ "fstmias %[dst]!, {s12-s15}\n\t"
+ "fldmiasgt %[src1]!, {s8-s11}\n\t"
+ "fldmiasgt %[src1]!, {s12-s15}\n\t"
+ "fstmiasge %[dst]!, {s24-s27}\n\t"
+ "fstmiasge %[dst]!, {s28-s31}\n\t"
+ "bgt 1b\n\t"
+
+ "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
+ "fmxr fpscr, %[tmp]\n\t"
+ : [dst] "+&r" (dest), [src1] "+&r" (a), [len] "+&r" (len), [tmp] "=&r" (tmp)
+ :
+ : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
+ "cc", "memory");
+#endif
+}
+
+
+
+#endif
View
5 Headers/plugin_interface/SC_InterfaceTable.h
@@ -175,5 +175,10 @@ typedef struct InterfaceTable InterfaceTable;
(*ft->fDefineUnit)(#name, sizeof(name), (UnitCtorFunc)&name##_Ctor, \
(UnitDtorFunc)&name##_Dtor, kUnitDef_CantAliasInputsToOutputs);
+#ifdef STATIC_PLUGINS
+#define PluginLoad(name) void name##_Load(InterfaceTable *inTable)
+#else
+#define PluginLoad(name) void load(InterfaceTable *inTable)
+#endif
#endif
View
3 Headers/plugin_interface/SC_PlugIn.h
@@ -33,6 +33,9 @@
#include "clz.h"
#include "sc_msg_iter.h"
#include "SC_Altivec.h"
+#ifdef SC_IPHONE
+#include "SC_VFP11.h"
+#endif
#include <stdlib.h>
#ifdef SC_WIN32
View
4 Headers/plugin_interface/SC_WorldOptions.h
@@ -25,7 +25,7 @@
#include <stdarg.h>
#include "SC_Types.h"
-#ifdef SC_DARWIN
+#if defined(SC_DARWIN) || defined(SC_IPHONE)
#include <CoreFoundation/CFString.h>
#endif
@@ -123,7 +123,7 @@ extern "C" {
SC_DLLEXPORT void World_NonRealTimeSynthesis(struct World *inWorld, WorldOptions *inOptions);
SC_DLLEXPORT int World_OpenUDP(struct World *inWorld, int inPort);
SC_DLLEXPORT int World_OpenTCP(struct World *inWorld, int inPort, int inMaxConnections, int inBacklog);
-#ifdef SC_DARWIN
+#if defined(SC_DARWIN) || defined(SC_IPHONE)
SC_DLLEXPORT void World_OpenMachPorts(struct World *inWorld, CFStringRef localName, CFStringRef remoteName);
#endif
SC_DLLEXPORT void World_WaitForQuit(struct World *inWorld);
View
6 Headers/plugin_interface/clz.h
@@ -83,6 +83,12 @@ static __inline__ int32 CLZ(int32 arg) {
return arg;
}
+#elif defined(SC_IPHONE)
+static __inline__ int32 CLZ(int32 arg)
+{
+ return __builtin_clz(arg);
+}
+
#else
# error "clz.h: Unsupported architecture"
#endif
View
2 Headers/server/SC_ComPort.h
@@ -143,7 +143,7 @@ class SC_TcpConnectionPort : public SC_ComPort
//////////////////////////////////////////////////////////////////////////////////////////////////////////
-#ifdef SC_DARWIN
+#if defined(SC_DARWIN) || defined(SC_IPHONE)
#include <CoreFoundation/CFMessagePort.h>
View
52 Headers/server/SC_CoreAudio.h
@@ -33,6 +33,7 @@
#define SC_AUDIO_API_JACK 2
#define SC_AUDIO_API_PORTAUDIO 3
#define SC_AUDIO_API_AUDIOUNITS 4
+#define SC_AUDIO_API_COREAUDIOIPHONE 5
#ifdef SC_WIN32
@@ -43,6 +44,10 @@
# endif
#endif
+#ifdef SC_IPHONE
+#define SC_AUDIO_API SC_AUDIO_API_COREAUDIOIPHONE
+#endif
+
#ifndef SC_AUDIO_API
# define SC_AUDIO_API SC_AUDIO_API_COREAUDIO
#endif // SC_AUDIO_API
@@ -52,6 +57,14 @@
# include <CoreAudio/HostTime.h>
#endif
+#if SC_AUDIO_API == SC_AUDIO_API_COREAUDIOIPHONE
+#include <AudioUnit/AudioUnit.h>
+#include <AudioToolbox/AudioToolbox.h>
+#include <AudioToolbox/AudioConverter.h>
+#include <AudioToolbox/AUGraph.h>
+#endif
+
+
#if SC_AUDIO_API == SC_AUDIO_API_PORTAUDIO
#include "portaudio.h"
#endif
@@ -215,6 +228,45 @@ class SC_CoreAudioDriver : public SC_AudioDriver
#endif
+#if SC_AUDIO_API == SC_AUDIO_API_COREAUDIOIPHONE
+class SC_iCoreAudioDriver : public SC_AudioDriver
+{
+ AUGraph graph;
+
+ AudioStreamBasicDescription inputStreamDesc; // info about the default device
+ AudioStreamBasicDescription outputStreamDesc; // info about the default device
+
+protected:
+ // Driver interface methods
+ virtual bool DriverSetup(int* outNumSamplesPerCallback, double* outSampleRate);
+ virtual bool DriverStart();
+ virtual bool DriverStop();
+
+public:
+ SC_iCoreAudioDriver(struct World *inWorld);
+ virtual ~SC_iCoreAudioDriver();
+
+ void Run(const AudioBufferList* inInputData, AudioBufferList* outOutputData, int64 oscTime);
+
+ AudioBufferList * buflist;
+ AudioBufferList * floatInputList;
+ AudioBufferList * floatOutputList;
+ AudioConverterRef converter_in_to_F32;
+ AudioConverterRef converter_F32_to_out;
+ AudioConverterRef converter_in_to_out;
+ int *converter_buffer;
+
+ int receivedIn;
+ AudioUnit inputUnit;
+
+
+};
+
+inline SC_AudioDriver* SC_NewAudioDriver(struct World *inWorld)
+{
+ return new SC_iCoreAudioDriver(inWorld);
+}
+#endif // SC_AUDIO_API_COREAUDIOIPHONE
#if SC_AUDIO_API == SC_AUDIO_API_PORTAUDIO
View
10 README IPHONE
@@ -0,0 +1,10 @@
+If you are a subscribed iPhone Developer, you know what to do.
+If you're not, download and install the SDK from developer.apple.com (free download, it's the actual developer certificates that cost money), then follow the instructions at :
+http://blog.paulbetts.org/index.php/2008/07/22/running-your-iphone-sdk-app-on-iphone-without-the-app-store/
+
+Patches should be stored in iPhone Resources/patches
+
+
+--
+Thanks to James McCartney, for making this great piece of audio
+software publicly and freely available.
View
7 Source/app/DrawBackground.M
@@ -18,9 +18,12 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifndef SC_IPHONE
#import <Cocoa/Cocoa.h>
-#import "DrawBackground.h"
#import "SCImage.h"
+#endif
+
+#import "DrawBackground.h"
DrawBackground::DrawBackground()
{
@@ -113,6 +116,7 @@ void HiliteGradientBackground::drawSelf(CGContextRef cgc, CGRect inRect)
}
// SCImageBackground
+#ifndef SC_IPHONE
void ScaleRectInRect( NSRect *bounds, NSSize *origSize, NSRect *destRect );
inline void ScaleRectInRect( NSRect *bounds, NSSize *origSize, NSRect *destRect )
@@ -324,6 +328,7 @@ SCImageBackground::~SCImageBackground()
#endif
[mSCImage release];
}
+#endif
#if 0
View
30 Source/app/iPhone/LiveCodingView.h
@@ -0,0 +1,30 @@
+//
+// LiveCodingView.h
+// isclang
+//
+// Created by Axel Balley on 30/10/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface LiveCodingView : UIView <UITextViewDelegate>
+{
+ IBOutlet UITextField *textField;
+ IBOutlet UITextView *textView;
+ IBOutlet UIButton *doneButton;
+ IBOutlet UIButton *lineButton;
+ IBOutlet UIButton *blockButton;
+
+ id target;
+ SEL selector;
+}
+- (void) setTarget:(id)t withSelector:(SEL)s;
+- (void) loadFile:(NSString *)file;
+- (void) showButtons: (BOOL)state;
+- (IBAction) triggerDone: (id)sender;
+- (IBAction) triggerLine: (id)sender;
+- (IBAction) triggerBlock: (id)sender;
+- (IBAction) triggerExecute: (id)sender;
+
+@end
View
102 Source/app/iPhone/LiveCodingView.mm
@@ -0,0 +1,102 @@
+//
+// LiveCodingView.m
+// isclang
+//
+// Created by Axel Balley on 30/10/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "LiveCodingView.h"
+
+extern void rtf2txt(char *txt);
+
+@implementation LiveCodingView
+
+
+- (id)initWithFrame:(CGRect)frame {
+ if (self = [super initWithFrame:frame])
+ {
+ target = 0;
+ selector = 0;
+ }
+ return self;
+}
+
+- (void) awakeFromNib
+{
+ [textView setAutocapitalizationType:UITextAutocapitalizationTypeNone];
+ [textView setAutocorrectionType:UITextAutocorrectionTypeNo];
+ [self showButtons:NO];
+}
+
+- (void)drawRect:(CGRect)rect {
+ [super drawRect:rect];
+}
+
+- (void) setTarget:(id)t withSelector:(SEL)s
+{
+ target = t;
+ selector = s;
+}
+
+- (void) loadFile:(NSString *)file
+{
+ NSString *contents = [NSString stringWithContentsOfFile:file encoding:NSASCIIStringEncoding error:nil];
+ int length = [contents length];
+ char *buf = (char *) malloc(length+1);
+ [contents getCString:buf maxLength:length+1 encoding:NSASCIIStringEncoding];
+ rtf2txt(buf);
+ while (*buf=='\n') buf++;
+
+ [textView setText:[NSString stringWithCString:buf encoding:NSASCIIStringEncoding]];
+}
+
+- (void) showButtons: (BOOL)state
+{
+ [doneButton setHidden:!state];
+ [lineButton setHidden:!state];
+ [blockButton setHidden:!state];
+}
+
+- (void) textViewDidBeginEditing: (UITextView *)theView
+{
+ [self showButtons:YES];
+}
+
+- (IBAction) triggerDone: (id)sender
+{
+ [textView resignFirstResponder];
+ [self showButtons:NO];
+}
+
+- (IBAction) triggerLine: (id)sender
+{
+ NSRange range = [textView selectedRange];
+ NSString *text = [textView text];
+ NSUInteger start, end;
+ [text getLineStart:&start end:&end contentsEnd:nil forRange:range];
+ NSString *line = [text substringWithRange:NSMakeRange(start, end-start)];
+
+ if (target && [target respondsToSelector:selector]) [target performSelector:selector withObject:line];
+
+ [textView resignFirstResponder];
+ [self showButtons:NO];
+}
+
+- (IBAction) triggerBlock: (id)sender
+{
+ [textView resignFirstResponder];
+ [self showButtons:NO];
+}
+
+- (IBAction) triggerExecute: (id)sender
+{
+ if (target && [target respondsToSelector:selector]) [target performSelector:selector withObject:[textView text]];
+}
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+
+@end
View
299 Source/app/iPhone/iPhoneGUIPrimitives.mm
@@ -0,0 +1,299 @@
+/*
+ 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
+*/
+
+#import <UIKit/UIKit.h>
+#include "PyrPrimitive.h"
+#include "PyrObject.h"
+#include "PyrKernel.h"
+#include "VMGlobals.h"
+#include "SC_RGen.h"
+
+#import "iPhoneSCGraphView.h"
+#import "ChangeCounter.h"
+#import "GC.h"
+#import "iPhoneSCNSWindow.h"
+#import "iSCLangController.h"
+//#import "SCTextView.h"
+//#import "SCCocoaView.h"
+
+extern ChangeCounter gUIChangeCounter;
+//extern NSTextView* gPostView;
+PyrSymbol *s_draw;
+PyrSymbol *s_font;
+PyrSymbol *s_closed;
+PyrSymbol *s_tick;
+PyrSymbol *s_doaction;
+PyrSymbol *s_didBecomeKey;
+PyrSymbol *s_didResignKey;
+
+extern bool docCreatedFromLang;
+int slotColorVal(PyrSlot *slot, SCColor *sccolor);
+
+
+int slotGetCGRect(PyrSlot* a, CGRect *r)
+{
+ PyrSlot *slots = a->uo->slots;
+ int err;
+ err = slotFloatVal(slots+0, &r->origin.x);
+ if (err) return err;
+ err = slotFloatVal(slots+1, &r->origin.y);
+ if (err) return err;
+ err = slotFloatVal(slots+2, &r->size.width);
+ if (err) return err;
+ err = slotFloatVal(slots+3, &r->size.height);
+ if (err) return err;
+
+ return errNone;
+}
+
+int slotGetQDRect(PyrSlot* a, Rect *r)
+{
+ PyrSlot *slots = a->uo->slots;
+ int err;
+ float x, y, width, height;
+
+ err = slotFloatVal(slots+0, &x);
+ if (err) return err;
+ err = slotFloatVal(slots+1, &y);
+ if (err) return err;
+ err = slotFloatVal(slots+2, &width);
+ if (err) return err;
+ err = slotFloatVal(slots+3, &height);
+ if (err) return err;
+
+ r->left = (int)x;
+ r->right = (int)(x + width);
+ r->top = (int)(y - height);
+ r->bottom = (int)y;
+
+ return errNone;
+}
+
+int slotGetPoint(PyrSlot* a, CGPoint *p)
+{
+ PyrSlot *slots = a->uo->slots;
+ int err;
+ err = slotFloatVal(slots+0, &p->x);
+ if (err) return err;
+ err = slotFloatVal(slots+1, &p->y);
+ if (err) return err;
+
+ return errNone;
+}
+
+
+int prSCWindow_New(struct VMGlobals *g, int numArgsPushed);
+int prSCWindow_New(struct VMGlobals *g, int numArgsPushed)
+{
+ if (!g->canCallOS) return errCantCallOS;
+
+ PyrSlot *args = g->sp - 6;
+ PyrSlot *a = args + 0;
+ PyrSlot *b = args + 1; // name
+ PyrSlot *c = args + 2; // bounds
+ PyrSlot *d = args + 3; // resizable
+ PyrSlot *e = args + 4; // border
+ PyrSlot *f = args + 6; // view
+ PyrSlot *h = args + 5; // scroll
+ PyrSlot *j = args + 7; // is this app modal? (Doesn't matter for sheets as they have no close button)
+
+ if (!(isKindOfSlot(b, class_string))) return errWrongType;
+ if (!(isKindOfSlot(c, s_rect->u.classobj))) return errWrongType;
+
+ CGRect bounds;
+ int err = slotGetCGRect(c, &bounds);
+ if (err) return err;
+
+ PyrString *string = b->uos;
+ NSString *title = [NSString stringWithCString: string->s length: string->size];
+
+ SCNSWindow *window = [[SCNSWindow alloc] initWithFrame: bounds];
+ [window setTitle: title];
+ [window setHasBorders: YES];
+
+ iSCLangController *controller = [iSCLangController sharedInstance];
+ SCGraphView* view = [[SCGraphView alloc] initWithFrame: bounds];
+ [view setSCObject: a->uo];
+ SetPtr(a->uo->slots + 0, view);
+ [controller insertWindow:window];
+ [window setSCGraphView: view];
+
+ if(IsTrue(h)) {
+/*
+ SCScrollTopView* scrollTopView = (SCScrollTopView*)(f->uo->slots[0].ui);
+ [view setSCTopView: scrollTopView];
+
+ NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame: bounds];
+ [scrollView setHasVerticalScroller:YES];
+ [scrollView setHasHorizontalScroller:YES];
+ [scrollView setAutohidesScrollers:YES];
+ [[scrollView horizontalScroller] setControlSize:NSSmallControlSize];
+ [[scrollView verticalScroller] setControlSize:NSSmallControlSize];
+ [[scrollView horizontalScroller] setControlTint:NSGraphiteControlTint];
+ [[scrollView verticalScroller] setControlTint:NSGraphiteControlTint];
+
+ [scrollView setBackgroundColor:[NSColor clearColor]];
+ [scrollView setDrawsBackground:NO];
+ // configure the scroller to have no visible border
+ [scrollView setBorderType:NSNoBorder];
+ [scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
+ [scrollView setDocumentView:view];
+
+ [scrollView setPostsFrameChangedNotifications: YES]; // we need this to resize the SCGraphView if the scroll view exceeds its bounds
+ [[NSNotificationCenter defaultCenter] addObserver:view
+ selector:@selector(scrollViewResized:)
+ name:@"NSViewFrameDidChangeNotification"
+ object:scrollView];
+
+ NSClipView *contentView = [scrollView contentView];
+ [contentView setPostsBoundsChangedNotifications:YES];
+ [[NSNotificationCenter defaultCenter] addObserver:view
+ selector:@selector(userScrolled:)
+ name:@"NSViewBoundsDidChangeNotification"
+ object:contentView];
+
+ scrollTopView->SetNSScrollView(scrollView);
+ [view autorelease];
+
+ [window setContentView: scrollView];
+ [scrollView autorelease];
+*/
+ } else {
+ [view setSCTopView: (SCTopView*)(f->uo->slots[0].ui)];
+ [window addSubview: view];
+ [view autorelease];
+ }
+ //[window makeFirstResponder: view];
+ //[window setFrameOrigin: bounds.origin];
+
+
+ return errNone;
+}
+
+
+int prSCWindow_Refresh(struct VMGlobals *g, int numArgsPushed);
+int prSCWindow_Refresh(struct VMGlobals *g, int numArgsPushed)
+{
+ if (!g->canCallOS) return errCantCallOS;
+
+ PyrSlot *a = g->sp;
+ SCGraphView* view = (SCGraphView*)a->uo->slots[0].ui;
+ if (!view) return errNone;
+
+ SEL sel = @selector(setNeedsDisplay:);
+ NSMethodSignature *sig = [UIView instanceMethodSignatureForSelector: sel];
+
+ NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature: sig];
+ iSCLangController* controller = [iSCLangController sharedInstance];
+ [anInvocation setTarget: view];
+ [anInvocation setSelector: sel];
+ BOOL flag = YES;
+ [anInvocation setArgument: &flag atIndex: 2];
+ [controller defer: anInvocation];
+
+ return errNone;
+}
+
+int prSCWindow_Close(struct VMGlobals *g, int numArgsPushed);
+int prSCWindow_Close(struct VMGlobals *g, int numArgsPushed)
+{
+ if (!g->canCallOS) return errCantCallOS;
+
+ PyrSlot *a = g->sp;
+ SCGraphView* view = (SCGraphView*)a->uo->slots[0].ui;
+ if (!view) return errNone;
+
+ SCNSWindow *window = (SCNSWindow *) [view superview];
+
+ SEL sel = @selector(closeWindow:);
+ NSMethodSignature *sig = [iSCLangController instanceMethodSignatureForSelector: sel];
+
+ NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature: sig];
+ iSCLangController* controller = [iSCLangController sharedInstance];
+ [anInvocation setTarget: controller];
+ [anInvocation setSelector: sel];
+ [anInvocation setArgument: &window atIndex: 2];
+ [controller defer: anInvocation];
+
+ return errNone;
+/*
+ PyrSlot *a = g->sp;
+ SCGraphView* view = (SCGraphView*)a->uo->slots[0].ui;
+ if (!view) return errNone;
+
+ SEL sel = @selector(closeWindow);
+ NSMethodSignature *sig = [SCGraphView instanceMethodSignatureForSelector: sel];
+
+ NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature: sig];
+ iSCLangController* controller = [iSCLangController sharedInstance];
+ [anInvocation setTarget: view];
+ [anInvocation setSelector: sel];
+ [controller defer: anInvocation];
+
+ return errNone;
+*/
+}
+
+
+int prSCWindow_ToFront(struct VMGlobals *g, int numArgsPushed);
+int prSCWindow_ToFront(struct VMGlobals *g, int numArgsPushed)
+{
+ if (!g->canCallOS) return errCantCallOS;
+
+ PyrSlot *a = g->sp;
+ SCGraphView* view = (SCGraphView*)a->uo->slots[0].ui;
+ if (!view) return errNone;
+
+ SCNSWindow *window = (SCNSWindow *) [view superview];
+
+ SEL sel = @selector(makeWindowFront:);
+ NSMethodSignature *sig = [iSCLangController instanceMethodSignatureForSelector: sel];
+
+ NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature: sig];
+ iSCLangController* controller = [iSCLangController sharedInstance];
+ [anInvocation setTarget: controller];
+ [anInvocation setSelector: sel];
+ [anInvocation setArgument: &window atIndex: 2];
+ [controller defer: anInvocation];
+
+ return errNone;
+}
+
+void initGUIPrimitives()
+{
+ int base, index;
+
+ s_draw = getsym("draw");
+ s_font = getsym("SCFont");
+ s_closed = getsym("closed");
+ s_tick = getsym("tick");
+ s_doaction = getsym("doAction");
+ s_didBecomeKey = getsym("didBecomeKey");
+ s_didResignKey = getsym("didResignKey");
+
+ base = nextPrimitiveIndex();
+ index = 0;
+
+ definePrimitive(base, index++, "_SCWindow_New", prSCWindow_New, 7, 0);
+ definePrimitive(base, index++, "_SCWindow_Refresh", prSCWindow_Refresh, 1, 0);
+ definePrimitive(base, index++, "_SCWindow_Close", prSCWindow_Close, 1, 0);
+ definePrimitive(base, index++, "_SCWindow_ToFront", prSCWindow_ToFront, 1, 0);
+}
+
View
870 Source/app/iPhone/iPhoneSCGraphView.mm
@@ -0,0 +1,870 @@
+/*
+ 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
+*/
+
+#import "iPhoneSCGraphView.h"
+#import "iSCLangController.h"
+#include "PyrKernel.h"
+#include "PyrMessage.h"
+#include "VMGlobals.h"
+#include "PyrSched.h"
+#include "SC_BoundsMacros.h"
+#include "GC.h"
+#import <UIKit/UIKit.h>
+
+extern PyrSymbol *s_draw;
+extern PyrSymbol *s_scview;
+extern PyrSymbol *s_closed;
+extern PyrSymbol *s_callDrawHook;
+extern PyrSymbol *s_toggleEditMode;
+
+@implementation SCGraphView
+
+- (void)setAcceptsClickThrough:(BOOL)boo
+{
+ acceptsClickThrough = boo;
+}
+
+- (void)setAutoScrolls:(BOOL)boo;
+{
+ autoScrolls = boo;
+}
+/*
+- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
+{
+ return acceptsClickThrough;
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+- (BOOL)mouseDownCanMoveWindow
+{
+ return NO;
+}
+
+//eat all key Events might add this
+- (BOOL)performKeyEquivalent:(NSEvent *)event
+{
+// NSString *characters = [event characters];
+ unsigned int modifiers = [event modifierFlags];
+ //control tab/escape doesn't get passed here at all ?
+ if(modifiers & NSCommandKeyMask) // allow cmd-key only
+ [self keyDown: event];
+ return NO; //for now pass on the event
+}
+
+- (void)flagsChanged:(NSEvent *)event
+{
+ unsigned int modifiers = [event modifierFlags];
+// NSLog(@" modifiers %d %08X",modifiers, modifiers);
+ if (mTopView) {
+ SCView *view = mTopView->focusView();
+ if (view) {
+ view->keyModifiersChanged(modifiers);
+ } else {
+ mTopView->keyModifiersChanged(modifiers);
+ }
+ }
+}
+- (void) keyDown: (NSEvent*) event
+{
+ NSString *characters = [event characters];
+ unsigned int modifiers = [event modifierFlags];
+ unichar character = 0;
+ if([characters length] > 0) {
+ character = [characters characterAtIndex: 0];
+ }
+ //control tab/escape doesn't get passed here at all ?
+ // NSLog(@"unicode %d length:%d clength:%d mTopView %08X modifiers %d %08X",
+// character,[characters length],[characters cStringLength], mTopView, modifiers, modifiers);
+
+ if (mTopView) {
+ // for some reason modifiers becomes 256 on my machine with no keys pressed. So need to mask against known keys.
+ uint32 allKnownModifiers = NSAlphaShiftKeyMask | NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask
+ | NSAlternateKeyMask | NSHelpKeyMask | NSFunctionKeyMask | NSCommandKeyMask;
+ if(character == 9 && ((modifiers & allKnownModifiers) == 0)) {
+ mTopView->tabPrevFocus();
+ return;
+ } else if (character == 25 && ((modifiers & allKnownModifiers) == NSShiftKeyMask)) {
+ mTopView->tabNextFocus();
+ return;
+ } // other tab keys avail for user
+ SCView *view = mTopView->focusView();
+ if (view) {
+ view->keyDown(character, modifiers,[event keyCode]);
+ } else {
+ mTopView->keyDown(character,modifiers,[event keyCode]);
+ }
+ }
+}
+
+
+- (void) keyUp: (NSEvent*) event
+{
+ NSString *characters = [event characters];
+ unsigned int modifiers = [event modifierFlags];
+ unichar character = 0;
+ if([characters length] > 0) {
+ character = [characters characterAtIndex: 0];
+ }
+// NSLog(@"keyUp: unicode %d length:%d clength:%d mTopView %08X modifiers %d %08X",
+// character,[characters length],[characters cStringLength], mTopView, modifiers, modifiers);
+ if (mTopView) {
+
+ uint32 allKnownModifiers = NSAlphaShiftKeyMask | NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask
+ | NSAlternateKeyMask | NSHelpKeyMask | NSFunctionKeyMask;
+ if(character == 9 && ((modifiers & allKnownModifiers) == 0)) {
+ return;
+ } else if (character == 25 && ((modifiers & allKnownModifiers) == NSShiftKeyMask)) {
+ return;
+ } // other tab keys avail for user
+
+ SCView *view = mTopView->focusView();
+ if (view) {
+ view->keyUp(character, modifiers,[event keyCode]);
+ } else {
+ mTopView->keyUp(character,modifiers,[event keyCode]);
+ }
+ }
+}
+*/
+
+static CGRect SCtoCGRect(SCRect screct)
+{
+ CGRect nsrect;
+ nsrect.origin.x = screct.x;
+ nsrect.origin.y = screct.y;
+ nsrect.size.width = screct.width;
+ nsrect.size.height = screct.height;
+ return nsrect;
+}
+
+static NSString *sSCObjType = @"SuperCollider object address";
+
+- (id)initWithFrame: (CGRect) frame
+{
+ [super initWithFrame: frame];
+ //[self registerForDraggedTypes: [NSArray arrayWithObjects: sSCObjType, NSStringPboardType, nil]];
+ mDragStarted = NO;
+ mMenuView = 0;
+ mWindowObj = 0;
+ mTopView = 0;
+ windowShouldClose = YES;
+ acceptsClickThrough = YES;
+ autoScrolls = YES;
+ [self setBackgroundColor:[UIColor whiteColor]];
+ return self;
+}
+
+- (void) touch:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ for (UITouch *touch in touches)
+ {
+ CGPoint mouseLoc;
+ if (!mTopView) return;
+ mouseLoc = [touch locationInView:self];
+ SCPoint scpoint = SCMakePoint(mouseLoc.x, mouseLoc.y);
+ SCView *view = mTopView->findView(scpoint);
+ if (view)
+ {
+ mDragStarted = NO;
+ mMenuView = 0;
+ view->makeFocus(true);
+ bool constructionmode = mTopView->ConstructionMode();
+ if(!constructionmode)
+ {
+ UITouchPhase phase = [touch phase];
+ if (phase==UITouchPhaseBegan)
+ {
+ view->touchDownAction(scpoint, touch);
+ view->touchBeginTrack(scpoint, touch);
+ }
+ else if (phase==UITouchPhaseMoved)
+ {
+ view->touchTrack(scpoint, touch);
+ view->touchMoveAction(scpoint, touch);
+ }
+ else if (phase==UITouchPhaseEnded)
+ {
+ view->touchUpAction(scpoint, touch);
+ view->touchEndTrack(scpoint, touch);
+ }
+ }
+ }
+ }
+
+
+
+
+ //else view->setConstructionModeFromPoint(scpoint);
+
+ //[self displayIfNeeded];
+ /*
+ while (keepOn && !mDragStarted && !mMenuView) {
+ theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |NSRightMouseUp | NSOtherMouseUp |
+ NSLeftMouseDraggedMask | NSRightMouseDragged | NSOtherMouseDragged
+ | NSKeyDownMask | NSKeyUpMask
+ ];
+ mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ //isInside = [self mouse:mouseLoc inRect:[self bounds]];
+ scpoint = SCMakePoint(mouseLoc.x, mouseLoc.y);
+ int evtype = [theEvent type];
+ switch ([theEvent type]) {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ if(constructionmode)
+ {
+ view->doConstructionMove(scpoint);
+ mTopView->refresh();
+ }else
+ view->mouseDownAction(scpoint, modifiers,theEvent);
+// post("down \n");
+ break;
+ case NSLeftMouseDragged:
+ if(autoScrolls) [self autoscroll:theEvent];
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ if(constructionmode)
+ {
+ view->doConstructionMove(scpoint);
+ mTopView->refresh();
+ }else
+ view->mouseTrack(scpoint, modifiers,theEvent);
+ view->mouseMoveAction(scpoint, modifiers,theEvent);
+// post("drag \n");
+ break;
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ if(constructionmode)
+ {
+ // view->doConstructionMove(scpoint);
+ mTopView->refresh();
+ }else
+ {
+// if(!view.GetSCObj()) break;
+ view->mouseUpAction(scpoint, modifiers,theEvent);
+ view->mouseEndTrack(scpoint, modifiers,theEvent);
+ }
+ keepOn = NO;
+ break;
+ default:
+ post("evtype %d %4.4s\n", evtype, (char*)&evtype);
+ break;
+ }
+// display:
+ //[self displayIfNeeded];
+ flushPostBuf();
+ }
+*/
+ mMenuView = 0;
+ return;
+}
+
+- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ [self touch:touches withEvent:event];
+}
+
+- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
+{
+ [self touch:touches withEvent:event];
+}
+
+- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
+{
+ [self touch:touches withEvent:event];
+}
+
+- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
+{
+ printf("touches cancelled\n");
+}
+
+
+
+/*
+- (NSMenu*) menuForEvent:(NSEvent*)theEvent;
+{
+ NSPoint mouseLoc;
+ mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ SCPoint scpoint = SCMakePoint(mouseLoc.x, mouseLoc.y);
+ if (!mTopView) return 0;
+ SCView *view = mTopView->findView(scpoint);
+ if (!view) return 0;
+ return view->contextMenu(scpoint);
+}
+
+-(void)rightMouseDown:(NSEvent*)theEvent { [self mouseDown:theEvent]; }
+-(void)otherMouseDown:(NSEvent*)theEvent { [self mouseDown:theEvent]; }
+- (void)mouseDown:(NSEvent *)theEvent
+{
+// NSLog(@"SCGraphView MOUSEDOWN");
+ BOOL keepOn = YES;
+ //BOOL isInside = YES;
+ NSPoint mouseLoc;
+ //NSLog(@"Click count: %i", [theEvent clickCount]);
+ //if([theEvent clickCount] == 2) return;
+ if (!mTopView) return;
+ unsigned int modifiers = [theEvent modifierFlags];
+ mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ SCPoint scpoint = SCMakePoint(mouseLoc.x, mouseLoc.y);
+ SCView *view = mTopView->findView(scpoint);
+ if (view) {
+ mDragStarted = NO;
+ mMenuView = 0;
+ view->makeFocus(true);
+ bool constructionmode = mTopView->ConstructionMode();
+ if(!constructionmode)
+ {
+ view->mouseDownAction(scpoint, modifiers,theEvent);
+ view->mouseBeginTrack(scpoint, modifiers,theEvent);
+ }else
+ view->setConstructionModeFromPoint(scpoint);
+
+ [self displayIfNeeded];
+
+ while (keepOn && !mDragStarted && !mMenuView) {
+ theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |NSRightMouseUp | NSOtherMouseUp |
+ NSLeftMouseDraggedMask | NSRightMouseDragged | NSOtherMouseDragged
+ | NSKeyDownMask | NSKeyUpMask
+ ];
+ mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ //isInside = [self mouse:mouseLoc inRect:[self bounds]];
+ scpoint = SCMakePoint(mouseLoc.x, mouseLoc.y);
+ int evtype = [theEvent type];
+ switch ([theEvent type]) {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ if(constructionmode)
+ {
+ view->doConstructionMove(scpoint);
+ mTopView->refresh();
+ }else
+ view->mouseDownAction(scpoint, modifiers,theEvent);
+// post("down \n");
+ break;
+ case NSLeftMouseDragged:
+ if(autoScrolls) [self autoscroll:theEvent];
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ if(constructionmode)
+ {
+ view->doConstructionMove(scpoint);
+ mTopView->refresh();
+ }else
+ view->mouseTrack(scpoint, modifiers,theEvent);
+ view->mouseMoveAction(scpoint, modifiers,theEvent);
+// post("drag \n");
+ break;
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ if(constructionmode)
+ {
+ // view->doConstructionMove(scpoint);
+ mTopView->refresh();
+ }else
+ {
+// if(!view.GetSCObj()) break;
+ view->mouseUpAction(scpoint, modifiers,theEvent);
+ view->mouseEndTrack(scpoint, modifiers,theEvent);
+ }
+ keepOn = NO;
+ break;
+ case NSKeyDown:
+ if(!constructionmode)
+ {
+ [self keyDown:theEvent];
+ }
+ break;
+ case NSKeyUp:
+ if(!constructionmode)
+ {
+ [self keyUp:theEvent];
+ }
+ break;
+ default:
+ post("evtype %d %4.4s\n", evtype, (char*)&evtype);
+ break;
+ }
+// display:
+ [self displayIfNeeded];
+ flushPostBuf();
+ }
+ }
+ mMenuView = 0;
+ return;
+}
+
+-(void)mouseMoved:(NSEvent*)theEvent
+{
+ NSPoint mouseLoc;
+ if (!mTopView) return;
+ unsigned int modifiers = [theEvent modifierFlags];
+ mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ SCPoint scpoint = SCMakePoint(mouseLoc.x, mouseLoc.y);
+ SCView *view = mTopView->findView(scpoint);
+ if (view) {
+ mDragStarted = NO;
+ mMenuView = 0;
+// view->makeFocus(true);
+ view->mouseOver(scpoint, modifiers, theEvent);
+ }
+}
+*/
+//scrollWheel:(NSEvent*)theEvent;
+
+- (void)setSCObject: (struct PyrObject*)inObject;
+{
+ mWindowObj = inObject;
+}
+
+- (struct PyrObject*)getSCObject
+{
+ return mWindowObj;
+}
+
+void damageFunc(SCRect inRect, void* inData)
+{
+ SCGraphView *view = (SCGraphView*)inData;
+
+ [view setNeedsDisplayInRect: SCtoCGRect(inRect)];
+}
+
+void dragFunc(SCPoint where, PyrSlot *inSlot, NSString* inString, NSString* label, void* inData)
+{
+ SCGraphView *view = (SCGraphView*)inData;
+ CGPoint point = CGPointMake(where.x, where.y);
+ [view beginDragFrom: point of: inSlot string: inString label: label];
+}
+
+
+/*
+- (unsigned int)draggingSourceOperationMaskForLocal: (BOOL)flag
+{
+ return flag ? NSDragOperationEvery : NSDragOperationNone;
+}
+*/
+
+- (void)setSCTopView: (SCTopView*)inView
+{
+ mTopView = inView;
+ mTopView->setDamageCallback(damageFunc, (void*)self);
+ mTopView->setDragCallback(dragFunc);
+ mTopView->SetUIView(self);
+}
+
+- (void)dealloc
+{
+ //printf("dealloc %08X mTopView %08X\n", self, mTopView);
+ delete mTopView;
+ mTopView = 0;
+ [super dealloc];
+}
+
+
+- (void)closeWindow
+{
+ SCNSWindow *w = [self superview];
+ [w close];
+}
+
+- (void)removeFromSuperview
+{
+ [[iSCLangController sharedInstance] removeDeferredOperationsFor: self];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super removeFromSuperview];
+}
+
+- (void)willClose
+{
+ [[iSCLangController sharedInstance] removeDeferredOperationsFor: self];
+ [[iSCLangController sharedInstance] removeDeferredOperationsFor: [self window]];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ pthread_mutex_lock (&gLangMutex);
+ if (mWindowObj) {
+ SetPtr(mWindowObj->slots + 0, self);
+ VMGlobals *g = gMainVMGlobals;
+ g->canCallOS = true;
+ ++g->sp; SetObject(g->sp, mWindowObj); // push window obj
+ runInterpreter(g, s_closed, 1);
+ g->canCallOS = false;
+ mWindowObj = 0;
+ }
+ pthread_mutex_unlock (&gLangMutex);
+
+ delete mTopView;
+ mTopView = 0;
+}
+
+/* from command-w, scvm is the delegate */
+- (void)setWindowShouldClose:(BOOL)boo
+{
+ windowShouldClose = boo;
+}
+
+- (BOOL)windowShouldClose
+{
+ return windowShouldClose;
+}
+
+const int circDiam = 20;
+
+//static int ivxGUIScreen_frameNumber = 11;
+
+- (void)drawRect: (CGRect)drawBounds
+{
+ if (mTopView) {
+
+ SCRect screct;
+
+ CGRect bounds = [self bounds];
+ screct.x = bounds.origin.x;
+ screct.y = bounds.origin.y;
+ screct.width = bounds.size.width;
+ screct.height = bounds.size.height;
+ mTopView->setInternalBounds(screct);
+
+ screct.x = drawBounds.origin.x;
+ screct.y = drawBounds.origin.y;
+ screct.width = drawBounds.size.width;
+ screct.height = drawBounds.size.height;
+
+/*
+ Rect qdrect = {(int)screct.x, (int)screct.y,
+ (int)(screct.x + screct.width), (int)(screct.y + screct.height)};
+ ClipRect(&qdrect);
+*/
+ if(mTopView->isSubViewScroller()) {
+ ((SCScrollView*)mTopView)->drawSubViewIfNecessary(screct);
+ } else {
+ mTopView->drawIfNecessary(screct);
+ }
+ }
+ pthread_mutex_lock (&gLangMutex);
+ if (mWindowObj && NotNil(mWindowObj->slots+6)) {
+ CGRect cgrect = *(CGRect*)&drawBounds;
+ CGContextRef cgc = (CGContextRef)UIGraphicsGetCurrentContext();
+ CGContextSaveGState(cgc);
+ CGContextClipToRect(cgc, cgrect);
+
+ VMGlobals *g = gMainVMGlobals;
+ g->canCallOS = true;
+ ++g->sp; SetObject(g->sp, mWindowObj); // push window obj
+ runInterpreter(g, s_callDrawHook, 1);
+ g->canCallOS = false;
+
+ CGContextRestoreGState(cgc);
+ }
+ pthread_mutex_unlock (&gLangMutex);
+}
+
+/*
+NSDictionary *makeFontAttrDict(char *cFontName, float fontSize, SCColor sccolor)
+{
+ NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+
+ NSString *fontName = [NSString stringWithCString: cFontName];
+
+ UIFont *font = [UIFont fontWithName: fontName size: fontSize];
+ if (!font) return 0;
+
+
+ UIColor *nscolor = [UIColor colorWithRed: sccolor.red
+ green: sccolor.green
+ blue: sccolor.blue
+ alpha: sccolor.alpha];
+ [dict setObject: font forKey: NSFontAttributeName ];
+ [dict setObject: nscolor forKey: NSForegroundColorAttributeName ];
+ return dict;
+}
+*/
+
+int nsStringDrawInRect(NSString *nsstring, SCRect screct, char *cFontName, float fontSize, SCColor sccolor)
+{
+/*
+ NSDictionary* dict = makeFontAttrDict(cFontName, fontSize, sccolor);
+ if (!dict) return errFailed;
+
+ [nsstring drawInRect: NSRectToCGRect(SCtoNSRect(screct)) withAttributes: dict];
+*/
+ int len = [nsstring length];
+ char *buf = (char *) malloc(len+1);
+ [nsstring getCString:buf maxLength:len+1 encoding:NSASCIIStringEncoding];
+
+ CGRect drawBounds = SCtoCGRect(screct);
+
+ CGRect cgrect = *(CGRect*)&screct;
+ CGContextRef cgc = (CGContextRef)UIGraphicsGetCurrentContext();
+ CGContextSaveGState(cgc);
+ CGContextClipToRect(cgc, cgrect);
+