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

[sc-dev] SF.net SVN: supercollider:[8236] trunk/build/SCClassLibrary/Common/GUI/Base



Revision: 8236
          http://supercollider.svn.sourceforge.net/supercollider/?rev=8236&view=rev
Author:   jmfuo
Date:     2008-12-21 23:36:42 +0000 (Sun, 21 Dec 2008)

Log Message:
-----------
Mockup of a better EZClass structure

Modified Paths:
--------------
    trunk/build/SCClassLibrary/Common/GUI/Base/EZListView.sc
    trunk/build/SCClassLibrary/Common/GUI/Base/EZPopUpMenu.sc

Added Paths:
-----------
    trunk/build/SCClassLibrary/Common/GUI/Base/EZgui.sc

Modified: trunk/build/SCClassLibrary/Common/GUI/Base/EZListView.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/Base/EZListView.sc	2008-12-21 22:36:11 UTC (rev 8235)
+++ trunk/build/SCClassLibrary/Common/GUI/Base/EZListView.sc	2008-12-21 23:36:42 UTC (rev 8236)
@@ -1,12 +1,5 @@
-EZListView{
-	var   <>globalAction, <>labelView, <items, widget, <view, <gap, <labelPosition, labelSize;
+EZListView : EZlists{
 	
-	*new { arg parentView, bounds, label,items, globalAction, initVal=0, 
-			initAction=false, labelWidth=80, labelHeight=20, labelPosition=\top, gap=4;
-			
-		^super.new.init(parentView, bounds, label, items, globalAction, initVal, 
-			initAction, labelWidth,labelHeight,labelPosition, gap);
-			}
 
 	init { arg parentView, bounds, label, argItems, argGlobalAction, initVal, 
 			initAction, labelWidth, labelHeight, arglabelPosition,  argGap;
@@ -26,7 +19,7 @@
 				w.front;
 				bounds=bounds.asRect;
 				bounds=Rect(4,4,bounds.width-8,bounds.height-24);
-				view=GUI.compositeView.new(parentView,bounds).relativeOrigin_(true).resize_(5);
+				view=GUI.compositeView.new(parentView,bounds).resize_(5).relativeOrigin_(true);
 			}{
 			
 			bounds=bounds.asRect;
@@ -70,148 +63,6 @@
 	
 	listView{^widget}
 	
-	value{ ^widget.value }
-	
-	value_{|val| widget.value_(val)}
-	
-	valueAction_{|val| this.value_(val); this.doAction}
-	
-	items_{arg assocArray; 
-		items=assocArray;
-		widget.items=assocArray.collect({|item| item.key});
-	}	
-		
-	addItem{arg name, action;
-		this.insertItem(nil, name, action);
-	}
-	
-	insertItem{ arg index, name, action;
-		var temp;
-		index = index ? items.size;
-		this.items=items.insert(index, name.asSymbol -> action);
-	 }
-	
-	removeItemAt{ arg index;
-		var temp;
-		items.removeAt(index);
-		this.items_(items)
-	
-	}
-	
-	doAction {items.at(this.value).value.value(this); globalAction.value}
-
-	label_{ arg string;
-	
-		labelView.isNil.if{
-			labelSize=80@20;
-			if(labelPosition==\top, {
-				labelView = GUI.staticText.new(view, view.bounds.width@ labelSize.y);
-				labelView.align = \left;
-			},{
-				labelView = GUI.staticText.new(view, labelSize.x @ view.bounds.height);
-				labelView.align = \right;
-			});
-			labelView.string = string;
-	 		this.bounds_(view.bounds); //recalculate bounds
-		}{
-		
-	 	labelView.string_(string)
-	 	};
-	 	
-	}
-	
-	label { arg label, items, globalAction;
-	 	labelView.string;
-	}
-		
-	visible { ^view.getProperty(\visible) }
-	visible_ { |bool|  view.setProperty(\visible,bool)  }
-	
-	enabled {  ^widget.enabled } 
-	enabled_ { |bool| widget.enabled_(bool) }
-	
-	remove { [widget, labelView].do(_.remove) }
-	
-	bounds{^view.bounds}
-	
-	bounds_{arg rect;
-		var labelBounds, listBounds;
-		view.bounds=rect;
-		# labelBounds,listBounds = this.prSubViewBounds(view.bounds, labelView.notNil);
-		
-		labelView.notNil.if{labelView.bounds=labelBounds};
-		widget.bounds=listBounds;
-	
-	}
-	
-	labelHeight{
-		^ labelSize.y
-	}
-	
-	labelHeight_{arg height;
-		labelSize.y=height;
-		this.bounds_(view.bounds); 	
-	}
-	labelWidth{
-		^ labelSize.x
-	}
-	
-	labelWidth_{arg width;
-		labelSize.x=width;
-		this.bounds_(view.bounds); 	
-	}
-	
-	labelPosition_{arg pos;
-		labelPosition=pos;
-		labelSize=80@20;
-		labelView.notNil.if{
-			(labelPosition==\top).if{
-			labelView.align=\left;
-			labelView.resize_(2);
-			}{
-			labelView.align=\right;
-			labelView.resize_(4);
-			};
-		};
-		
-		this.bounds_(view.bounds); 	
-	}
-	
-	gap_{arg val;
-		gap=val;
-		this.bounds_(this.view.bounds);
-		
-	}
-	
-	prSubViewBounds{arg rect, hasLabel=true;
-		var listBounds,labelBounds, tempGap;
-		tempGap=gap;	
-		hasLabel.not.if{tempGap=0; labelSize=0@0};
-		
-		if (labelPosition==\top,{
-			listBounds= Rect(
-					0,
-					labelSize.y+tempGap,
-					view.bounds.width,  
-					view.bounds.height-labelSize.y-tempGap
-					);
-			labelBounds=Rect(0,0,listBounds.width,labelSize.y);
-		},{
-			listBounds= Rect(
-					labelSize.x+tempGap,
-					0,
-					view.bounds.width-labelSize.x-tempGap,  
-					view.bounds.height
-					);
-			labelBounds=Rect(0,0, labelSize.x ,listBounds.height );
-		});
-		
-		^[labelBounds, listBounds]
-	}
-	
-	
-	
-	
 }
 
 

Modified: trunk/build/SCClassLibrary/Common/GUI/Base/EZPopUpMenu.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/Base/EZPopUpMenu.sc	2008-12-21 22:36:11 UTC (rev 8235)
+++ trunk/build/SCClassLibrary/Common/GUI/Base/EZPopUpMenu.sc	2008-12-21 23:36:42 UTC (rev 8236)
@@ -1,12 +1,5 @@
-EZPopUpMenu{
-	var   <>globalAction, <>labelView, <items, <widget, <view, <gap, <labelPosition, labelSize;
+EZPopUpMenu : EZlists{
 	
-	*new { arg parentView, bounds, label,items, globalAction, initVal=0, 
-			initAction=false, labelWidth=80, labelHeight=20, labelPosition=\left, gap=4;
-			
-		^super.new.init(parentView, bounds, label, items, globalAction, initVal, 
-			initAction, labelWidth,labelHeight,labelPosition, gap);
-			}
 
 	init { arg parentView, bounds, label, argItems, argGlobalAction, initVal, 
 			initAction, labelWidth, labelHeight, arglabelPosition,  argGap;
@@ -69,148 +62,6 @@
 	}	
 	
 	menu {^ widget}
-	value{ ^widget.value }
-	
-	value_{|val| widget.value_(val)}
-	
-	valueAction_{|val| this.value_(val); this.doAction}
-	
-	items_{arg assocArray; 
-		items=assocArray;
-		widget.items=assocArray.collect({|item| item.key});
-	}	
-		
-	addItem{arg name, action;
-		this.insertItem(nil, name, action);
-	}
-	
-	insertItem{ arg index, name, action;
-		var temp;
-		index = index ? items.size;
-		this.items=items.insert(index, name.asSymbol -> action);
-	 }
-	
-	removeItemAt{ arg index;
-		var temp;
-		items.removeAt(index);
-		this.items_(items)
-	
-	}
-	
-	doAction {items.at(this.value).value.value(this); globalAction.value}
-
-	label_{ arg string;
-	
-		labelView.isNil.if{
-			labelSize=80@20;
-			if(labelPosition==\top, {
-				labelView = GUI.staticText.new(view, view.bounds.width@ labelSize.y);
-				labelView.align = \left;
-			},{
-				labelView = GUI.staticText.new(view, labelSize.x @ view.bounds.height);
-				labelView.align = \right;
-			});
-			labelView.string = string;
-	 		this.bounds_(view.bounds); //recalculate bounds
-		}{
-		
-	 	labelView.string_(string)
-	 	};
-	 	
-	}
-	
-	label { arg label, items, globalAction;
-	 	labelView.string;
-	}
-		
-	visible { ^view.getProperty(\visible) }
-	visible_ { |bool|  view.setProperty(\visible,bool)  }
-	
-	enabled {  ^widget.enabled } 
-	enabled_ { |bool| widget.enabled_(bool) }
-	
-	remove { [widget, labelView].do(_.remove) }
-	
-	bounds{^view.bounds}
-	
-	bounds_{arg rect;
-		var labelBounds, listBounds;
-		view.bounds=rect;
-		# labelBounds,listBounds = this.prSubViewBounds(view.bounds, labelView.notNil);
-		
-		labelView.notNil.if{labelView.bounds=labelBounds};
-		widget.bounds=listBounds;
-	
-	}
-	
-	labelHeight{
-		^ labelSize.y
-	}
-	
-	labelHeight_{arg height;
-		labelSize.y=height;
-		this.bounds_(view.bounds); 	
-	}
-	labelWidth{
-		^ labelSize.x
-	}
-	
-	labelWidth_{arg width;
-		labelSize.x=width;
-		this.bounds_(view.bounds); 	
-	}
-	
-	labelPosition_{arg pos;
-		labelPosition=pos;
-		labelSize=80@20;
-		labelView.notNil.if{
-			(labelPosition==\top).if{
-			labelView.align=\left;
-			labelView.resize_(2);
-			}{
-			labelView.align=\right;
-			labelView.resize_(4);
-			};
-		};
-		
-		this.bounds_(view.bounds); 	
-	}
-	
-	gap_{arg val;
-		gap=val;
-		this.bounds_(this.view.bounds);
-		
-	}
-	
-	prSubViewBounds{arg rect, hasLabel=true;
-		var listBounds,labelBounds, tempGap;
-		tempGap=gap;	
-		hasLabel.not.if{tempGap=0; labelSize=0@0};
-		
-		if (labelPosition==\top,{
-			listBounds= Rect(
-					0,
-					labelSize.y+tempGap,
-					view.bounds.width,  
-					view.bounds.height-labelSize.y-tempGap
-					);
-			labelBounds=Rect(0,0,listBounds.width,labelSize.y);
-		},{
-			listBounds= Rect(
-					labelSize.x+tempGap,
-					0,
-					view.bounds.width-labelSize.x-tempGap,  
-					view.bounds.height
-					);
-			labelBounds=Rect(0,0, labelSize.x ,listBounds.height );
-		});
-		
-		^[labelBounds, listBounds]
-	}
-	
-	
-	
-	
 }
 
 

Added: trunk/build/SCClassLibrary/Common/GUI/Base/EZgui.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/Base/EZgui.sc	                        (rev 0)
+++ trunk/build/SCClassLibrary/Common/GUI/Base/EZgui.sc	2008-12-21 23:36:42 UTC (rev 8236)
@@ -0,0 +1,170 @@
+EZgui{
+	var <>labelView, <widget, <view, <gap, <labelPosition, labelSize, value;
+
+	/////////////////////////
+	
+	label_{ arg string;
+	
+		labelView.isNil.if{
+			labelSize=80@20;
+			if(labelPosition==\top, {
+				labelView = GUI.staticText.new(view, view.bounds.width@ labelSize.y);
+				labelView.align = \left;
+			},{
+				labelView = GUI.staticText.new(view, labelSize.x @ view.bounds.height);
+				labelView.align = \right;
+			});
+			labelView.string = string;
+	 		this.bounds_(view.bounds); //recalculate bounds
+		}{
+		
+	 	labelView.string_(string)
+	 	};
+	 	
+	}
+	
+	label { arg label, items, globalAction;
+	 	labelView.string;
+	}
+		
+	visible { ^view.getProperty(\visible) }
+	visible_ { |bool|  view.setProperty(\visible,bool)  }
+	
+	enabled {  ^widget.enabled } 
+	enabled_ { |bool| widget.enabled_(bool) }
+	
+	remove { [widget, labelView].do(_.remove) }
+	
+	bounds{^view.bounds}
+	
+	bounds_{arg rect;
+		var labelBounds, listBounds;
+		view.bounds=rect;
+		# labelBounds,listBounds = this.prSubViewBounds(view.bounds, labelView.notNil);
+		
+		labelView.notNil.if{labelView.bounds=labelBounds};
+		widget.bounds=listBounds;
+	
+	}
+	
+	labelHeight{
+		^ labelSize.y
+	}
+	
+	labelHeight_{arg height;
+		labelSize.y=height;
+		this.bounds_(view.bounds); 	
+	}
+	labelWidth{
+		^ labelSize.x
+	}
+	
+	labelWidth_{arg width;
+		labelSize.x=width;
+		this.bounds_(view.bounds); 	
+	}
+	
+	labelPosition_{arg pos;
+		labelPosition=pos;
+		labelSize=80@20;
+		labelView.notNil.if{
+			(labelPosition==\top).if{
+			labelView.align=\left;
+			labelView.resize_(2);
+			}{
+			labelView.align=\right;
+			labelView.resize_(4);
+			};
+		};
+		
+		this.bounds_(view.bounds); 	
+	}
+	
+	gap_{arg val;
+		gap=val;
+		this.bounds_(this.view.bounds);
+		
+	}
+	
+	prSubViewBounds{arg rect, hasLabel=true;
+		var listBounds,labelBounds, tempGap;
+		tempGap=gap;	
+		hasLabel.not.if{tempGap=0; labelSize=0@0};
+		
+		if (labelPosition==\top,{
+			listBounds= Rect(
+					0,
+					labelSize.y+tempGap,
+					view.bounds.width,  
+					view.bounds.height-labelSize.y-tempGap
+					);
+			labelBounds=Rect(0,0,listBounds.width,labelSize.y);
+		},{
+			listBounds= Rect(
+					labelSize.x+tempGap,
+					0,
+					view.bounds.width-labelSize.x-tempGap,  
+					view.bounds.height
+					);
+			labelBounds=Rect(0,0, labelSize.x ,listBounds.height );
+		});
+		
+		^[labelBounds, listBounds]
+	}
+	
+
+	
+
+	
+	
+	/////////////////////////	
+}
+
+
+EZlists : EZgui{
+	var <items, <>globalAction ; 
+	
+	*new { arg parentView, bounds, label,items, globalAction, initVal=0, 
+			initAction=false, labelWidth=80, labelHeight=20, labelPosition=\top, gap=4;
+			
+		^super.new.init(parentView, bounds, label, items, globalAction, initVal, 
+			initAction, labelWidth,labelHeight,labelPosition, gap);
+			}
+	
+	value{ ^widget.value }
+	
+	value_{|val| widget.value_(val)}
+	
+	valueAction_{|val| this.value_(val); this.doAction}
+		
+	doAction {items.at(this.value).value.value(this); globalAction.value}
+
+	items_{arg assocArray; 
+		items=assocArray;
+		widget.items=assocArray.collect({|item| item.key});
+	}	
+		
+	addItem{arg name, action;
+		this.insertItem(nil, name, action);
+	}
+	
+	insertItem{ arg index, name, action;
+		var temp;
+		index = index ? items.size;
+		this.items=items.insert(index, name.asSymbol -> action);
+	 }
+	
+	removeItemAt{ arg index;
+		var temp;
+		items.removeAt(index);
+		this.items_(items)
+	
+	}
+
+
+}
+
+EZValues : EZgui{
+ /// EZSlider, EZRanger EZNumber support
+
+}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/