Explorar el Código

Merge remote-tracking branch 'origin/develop' into develop

Mark Sibly hace 8 años
padre
commit
9c1ccf17d6

+ 18 - 1
modules/std/audio/audioformat.monkey2

@@ -1,13 +1,31 @@
 
 Namespace std.audio
 
+#rem monkeydoc Audio formats.
+
+| AudioFormat	| Description
+|:--------------|:-----------
+| `Unknown`		| Unknown format.
+| `Mono8`		| 8 bit mono.
+| `Mono16`		| 16 bit mono.
+| `Stereo8`		| 8 bit stereo.
+| `Stereo16`	| 16 bit stereo.
+#end
 Enum AudioFormat
+	Unknown=0
 	Mono8=1
 	Mono16=2
 	Stereo8=3
 	Stereo16=4
 End
 
+#rem monkeydoc Number of bytes per audio sample.
+
+Returns the number of bytes per audio sample for the given audio format.
+
+@param format The audio format.
+
+#end
 Function BytesPerSample:Int( format:AudioFormat )
 	Select format
 	Case AudioFormat.Mono8 Return 1
@@ -17,4 +35,3 @@ Function BytesPerSample:Int( format:AudioFormat )
 	End
 	Return 0
 End
-

+ 43 - 0
modules/std/requesters/examples/requestfile.monkey2

@@ -0,0 +1,43 @@
+
+Namespace myapp
+
+#Import "<std>"
+#Import "<mojo>"
+
+Using std..
+Using mojo..
+
+Class MyWindow Extends Window
+
+	Method New()
+		
+		'Open file requester...
+		'
+		Local openname:=RequestFile( "Open file...","image files:png,jpg;audio files:waw,ogg" )
+		If openname
+			Notify( "RequestFile example","filename selected="+openname )
+		Else
+			Notify( "RequestFile example","No filename selected" )
+		Endif
+
+		'Save file requester...
+		'
+		Local savename:=RequestFile( "Save file...","image files:png,jpg;audio files:wav,ogg",True,openname )
+		If savename
+			Notify( "RequestFile example","filename selected="+savename )
+		Else
+			Notify( "RequestFile example","No filename selected" )
+		Endif
+		
+	End
+
+End
+
+Function Main()
+
+	New AppInstance
+	
+	New MyWindow
+	
+	App.Run()
+End

+ 42 - 14
modules/std/requesters/native/requesters.mm

@@ -103,36 +103,63 @@ bbString bbRequesters::RequestFile( bbString title,bbString filter,bbBool save,b
 
 	if( filter.length() ){
 	
-		allowOthers=false;
-	
 		nsfilter=[NSMutableArray arrayWithCapacity:10];
 		
-		int i0=0;
-		while( i0<filter.length() ){
+		allowOthers=false;
 		
-			int i1=filter.find( ":",i0 )+1;
-			if( !i1 ) break;
+		if( filter.find( ":" )!=-1 ){
+
+			int i0=0;
+			while( i0<filter.length() ){
 			
-			int i2=filter.find( ";",i1 );
-			if( i2==-1 ) i2=filter.length();
+				int i1=filter.find( ":",i0 );
+				if( i1==-1 ) break;
+				i1+=1;
+				
+				int i2=filter.find( ";",i1 );
+				if( i2==-1 ) i2=filter.length();
+				
+				while( i1<i2 ){
+				
+					int i3=filter.find( ",",i1 );
+					if( i3==-1 ) i3=i2;
+					
+					bbString ext=filter.slice( i1,i3 );
+					if( ext==BB_T("*") ){
+						allowOthers=true;
+					}else{
+						[nsfilter addObject:ConvString( ext )];
+					}
+					i1=i3+1;
+				}
+				i0=i2+1;
+			}
 			
-			while( i1<i2 ){
+		}else{
+		
+			int i0=0;
+			while( i0<filter.length() ){
 			
-				int i3=filter.find( ",",i1 );
-				if( i3==-1 ) i3=i2;
+				int i1=filter.find( ",",i0 );
+				if( i1==-1 ) i1=filter.length();
 				
-				bbString ext=filter.slice( i1,i3 );
+				bbString ext=filter.slice( i0,i1 );
 				if( ext==BB_T("*") ){
 					allowOthers=true;
 				}else{
 					[nsfilter addObject:ConvString( ext )];
 				}
-				i1=i3+1;
+				
+				i0=i1+1;
 			}
-			i0=i2+1;
 		}
 	}
 
+	if( ![nsfilter count] ){
+		nsfilter=0;
+		allowOthers=true;
+	}
+	
 	NSString *nsdir=0;
 	NSString *nsfile=0;
 	NSString *nstitle=0;
@@ -215,3 +242,4 @@ void bbRequesters::OpenUrl( bbString url ){
 		CFRelease( cfurl );
 	}
 }
+

+ 61 - 1
modules/std/requesters/requesters.monkey2

@@ -24,36 +24,96 @@ Namespace std.requesters
 
 Extern
 
+#rem monkeydoc Activates a modal notification dialog.
+
+Notify activates a simple modal dialog informing the user of an event. The optional `serious` flag can be used to indicate a 'critical' event.
+
+#end
 Function Notify:Void( title:String,text:String,serious:Bool=False )="bbRequesters::Notify"
 
+#rem monkeydoc Activates a simple modal Yes/No dialog.
+
+Confirm activates a simple modal dialog requesting the user to select between Yes and No options. If the user selects Yes, then Confirm returns true. Otherwise, false is returned.
+
+#end
 Function Confirm:Bool( title:String,text:String,serious:Bool=False )="bbRequesters::Confirm"
 
+#rem monkeydoc Activates a modal Yes/No/Cancel dialog.
+
+Proceed activates a simple modal dialog requesting the user to select between Yes, No and Cancel options. If the user selects Yes, then Proceed return 1. If the user selects No, then Proceed returns 0. Otherwise, Proceed returns -1.
+
+#end
 Function Proceed:Int( title:String,text:String,serious:Bool=False )="bbRequesters::Proceed"
 
+#rem monkeydoc Activate a modal file requester dialog.
+
+RequestFile activates a modal file requester dialog.
+
+The optional filters string can either be a comma separated list of file extensions or, as in the following example, groups of extensions that begin with a "group:" label and are separated by a semicolon. For example:
+
+"Image files:png,jpg;Audio files:was,ogg;All files:*"
+
+The save parameter should be true to create a save-style requester, false to create a load-style requester.
+
+The `path` parameter can be used to specify an initial file path.
+
+Returns selected file path, or an empty string if dialog was cancelled.
+
+#end
 Function RequestFile:String( title:String,filter:String="",save:Bool=False,file:String="" )="bbRequesters::RequestFile"
 
+#rem monkeydoc Activates a modal directory path dialog.
+
+RequestDir activates a modal directory path dialog.
+
+The `dir` parameter can be used to specify an initial directory path.
+
+Returns selected directory path, or an empty string if dialog was cancelled.
+
+#end
 Function RequestDir:String( title:String,dir:String="" )="bbRequesters::RequestDir"
 
+#rem monkeydoc Opens a URL using the desktop manager.
+
+Opens a URL using the desktop manager.
+
+The behavior of OpenURL is highly target dependent, but in general it should at least be able to open web pages for you!
+
+#end
 Function OpenUrl( url:String )="bbRequesters::OpenUrl"
 
 #else
 
+#rem
+
+#rem monkeydoc @hidden
+#end
 Function Notify:Void( title:String,text:String,serious:Bool=False )
 End
 
+#rem monkeydoc @hidden
+#end
 Function Confirm:Bool( title:String,text:String,serious:Bool=False )
 	Return False
 End
 
+#rem monkeydoc @hidden
+#end
 Function RequestFile:String( title:String,filter:String="",save:Bool=False,file:String="" )
 	Return ""
 End
 
+#rem monkeydoc @hidden
+#end
 Function RequestDir:String( title:String,dir:String="" )
 	Return ""
 End
 
+#rem monkeydoc @hidden
+#end
 Function OpenUrl( url:String )
 End
 
-#endif
+#end
+
+#Endif