SF.net SVN: supercollider: [7669] trunk/build/SCClassLibrary

View: New views
1 Messages — Rating Filter:   Alert me  

SF.net SVN: supercollider: [7669] trunk/build/SCClassLibrary

by cruxxial :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Revision: 7669
          http://svn.sourceforge.net/supercollider/?rev=7669&view=rev
Author:   cruxxial
Date:     2008-07-09 11:44:10 -0700 (Wed, 09 Jul 2008)

Log Message:
-----------
SCWindow:setBoundsTopLeft - set bounds via a rect in the standard way of thinking where origin is top left.

Rect.right_ and Rect.bottom_ setters

MultiPageLayout - allow auto center on create.  this should actually be an SCWindow method : center

ObjectGui, StringGui, AbstractPlayerGui center the window by default

Modified Paths:
--------------
    trunk/build/SCClassLibrary/Common/GUI/osx/Base/GUIScreen.sc
    trunk/build/SCClassLibrary/Common/Geometry/Rect.sc
    trunk/build/SCClassLibrary/crucial/Gui/ObjectGui.sc
    trunk/build/SCClassLibrary/crucial/Gui/PageLayout.sc
    trunk/build/SCClassLibrary/crucial/Gui/StringGui.sc
    trunk/build/SCClassLibrary/crucial/Players/AbstractPlayerGui.sc

Modified: trunk/build/SCClassLibrary/Common/GUI/osx/Base/GUIScreen.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/osx/Base/GUIScreen.sc 2008-07-09 13:32:57 UTC (rev 7668)
+++ trunk/build/SCClassLibrary/Common/GUI/osx/Base/GUIScreen.sc 2008-07-09 18:44:10 UTC (rev 7669)
@@ -108,9 +108,18 @@
  name = argName;
  this.prSetName(argName);
  }
+ // bounds are relative to the bottom left corner origin
  bounds_ { arg argBounds;
  this.prSetBounds(argBounds);
  }
+ // set bounds relative to top left corner
+ setTopLeftBounds { |rect,menuSpacer=45|
+ rect = rect.copy;
+ // 45 is the height of the mac os menu
+ // if you are in full screen mode you would want to pass in 0
+ rect.top = SCWindow.screenBounds.height - rect.height - rect.top - menuSpacer;
+ this.bounds = rect
+ }
  setInnerExtent { arg w,h; // resize window keeping top left corner fixed
  var b;
  b = this.bounds;

Modified: trunk/build/SCClassLibrary/Common/Geometry/Rect.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Geometry/Rect.sc 2008-07-09 13:32:57 UTC (rev 7668)
+++ trunk/build/SCClassLibrary/Common/Geometry/Rect.sc 2008-07-09 18:44:10 UTC (rev 7669)
@@ -44,7 +44,9 @@
  center_ { arg center; ^this.class.aboutPoint(center, width * 0.5, height * 0.5) }
 
  bottom { ^top + height }
+ bottom_ { |b| top = top - (this.bottom - b) }
  right { ^left + width }
+ right_ { |r| left = left - (this.right - r) }
 
  leftTop { ^Point.new(this.left, this.top) }
  rightTop { ^Point.new(this.right, this.top) }

Modified: trunk/build/SCClassLibrary/crucial/Gui/ObjectGui.sc
===================================================================
--- trunk/build/SCClassLibrary/crucial/Gui/ObjectGui.sc 2008-07-09 13:32:57 UTC (rev 7668)
+++ trunk/build/SCClassLibrary/crucial/Gui/ObjectGui.sc 2008-07-09 18:44:10 UTC (rev 7669)
@@ -1,50 +1,29 @@
 
-ObjectGui : SCViewHolder { // aka AbstractController
-
+ObjectGui : SCViewHolder {
+ /*
+ this is a controller class. it creates the views and implements the relationship between them and the model
+ model: the object for which this is a graphical user interface
+ view: this.view is the flow view (aka the arg layout) that is passed to guiBody
+ individual views/widgets are placed in it and their actions talk to either this object or the model
+ */
  var <model,<dragSource;
 
  guiBody { arg layout;
- // override this in your gui subclass
+ /* implement this method in your gui subclass */
 
- // or if you are lazy then just implement guiBody in the MODEL
+ // if your model implement guiBody then call that
  if(model.respondsTo(\guiBody) and: {model.isKindOf(ObjectGui).not},{
  model.guiBody(layout)
  },{
- // or by default we make a gui showing variables that the class allows
+ /*
+ or by default we make a gui showing variables that the class allows
+ see instVarsForGui
+ by default this is NO variables at all.
+ */
  ObjectGui.guiInstVarsOf(model,layout)
- //ObjectGui.guiVarsOf(model,layout);
  })
  }
 
- // classes return instVarsForGui : a list of \symbols
- // by default empty : don't display any variables
- *guiInstVarsOf { arg object,layout;
- var varNames,maxWidth=50,font;
- font = GUI.font.new(*GUI.skin.fontSpecs);
- object.class.instVarsForGui.do({ |ivar,i|
- var width;
- //if(object.respondsTo(ivar),{ // has getter
- varNames = varNames.add([ivar,object.instVarAt(ivar)]);
- width = ivar.asString.bounds(font).width + 5;
- if(width > maxWidth,{ maxWidth = width; });
- //})
- });
- varNames.do({ |namevar|
- var guis;
- layout.startRow;
- VariableNameLabel(namevar[0],layout,maxWidth);
- // a safety check so as not to annoy
- // if there already exists a gui for the object, the simply put a Tile
- guis = namevar[1].dependants.select({|dep| dep.isKindOf(ObjectGui) and: dep.class !== StringGui });
- if(guis.size == 0,{
- namevar[1].gui(layout);
- },{
- Tile(namevar[1],layout);
- });
- });
- }
-
-
  *new { arg model;
  var new;
  new = super.new;
@@ -53,7 +32,7 @@
  }
  guify { arg layout,bounds,title;
  if(layout.isNil,{
- layout = MultiPageLayout(title ?? {model.asString.copyRange(0,50)},bounds);
+ layout = MultiPageLayout(title ?? {model.asString.copyRange(0,50)},bounds,front:false);
  },{
  layout = layout.asPageLayout(title,bounds);
  });
@@ -63,8 +42,10 @@
  }
  viewDidClose {
  model.removeDependant(this);
+ model = nil;
  super.viewDidClose;
  }
+
  gui { arg lay, bounds ... args;
  var layout;
  layout=this.guify(lay,bounds);
@@ -74,8 +55,8 @@
  this.performList(\guiBody,[layout] ++ args);
  },bounds).background_(this.background);
  //if you created it, front it
- if(lay.isNil,{
- layout.resizeToFit(true).front
+ if(lay.isNil,{
+ layout.resizeToFit(true,true).front
  });
  }
  topGui { arg ... args;
@@ -83,7 +64,7 @@
  }
 
  background { ^Color.clear }//^Color.yellow(0.2,0.08) }
-
+
  writeName { |layout|
  this.prWriteName(layout,model.asString)
  }
@@ -100,7 +81,7 @@
  .background_(Color.white)
  .align_(\left)
  .beginDragAction_({ model })
- .object_(string);
+ .object_(string);
  InspectorLink.icon(model,layout);
  }
  model_ { |newModel|
@@ -115,11 +96,40 @@
  })
  }
 
-
  saveConsole { arg layout;
  ^SaveConsole(model,"",layout).save.saveAs.print;
  }
-
+
+
+ *guiInstVarsOf { arg object,layout;
+ // this is an easy default gui system
+ // each class returns instVarsForGui, a list of \symbols
+ // by default an empty array : "don't display any variables"
+ // some classes (Pattern so far) can return all of their instance var names
+ // and thus gui all of their internal vars
+ var varNames,maxWidth=50,font;
+ font = GUI.font.new(*GUI.skin.fontSpecs);
+ object.class.instVarsForGui.do({ |ivar,i|
+ var width;
+ varNames = varNames.add([ivar,object.instVarAt(ivar)]);
+ width = ivar.asString.bounds(font).width + 5;
+ if(width > maxWidth,{ maxWidth = width; });
+ });
+ varNames.do({ |namevar|
+ var guis;
+ layout.startRow;
+ VariableNameLabel(namevar[0],layout,maxWidth);
+ // a safety check so as not to annoy
+ // if there already exists a gui for the object, the simply put a Tile
+ guis = namevar[1].dependants.select({|dep| dep.isKindOf(ObjectGui) and: dep.class !== StringGui });
+ if(guis.size == 0,{
+ namevar[1].gui(layout);
+ },{
+ Tile(namevar[1],layout);
+ });
+ });
+ }
+
 }
 
 ModelImplementsGuiBody : ObjectGui {

Modified: trunk/build/SCClassLibrary/crucial/Gui/PageLayout.sc
===================================================================
--- trunk/build/SCClassLibrary/crucial/Gui/PageLayout.sc 2008-07-09 13:32:57 UTC (rev 7668)
+++ trunk/build/SCClassLibrary/crucial/Gui/PageLayout.sc 2008-07-09 18:44:10 UTC (rev 7669)
@@ -112,33 +112,32 @@
  autoRemoves = autoRemoves.add(dependant);
  }
 
- resizeToFit { arg reflow=false;
- //var fs;
- //fs = GUI.window.screenBounds;
+ resizeToFit { arg reflow=false,center=false;
+ var fs, b,wb,wbw,wbh;
 
- var b,wb,wbw,wbh;
- if(this.view.isNil,{ this.insp });
  b = this.view.resizeToFit(reflow);
+ wbw = b.width + 4;
+ wbh = b.height + 17;
+ window.setInnerExtent(wbw,wbh);
 
- window.setInnerExtent(wbw = b.width + 4, wbh = b.height + 17);
- /*
- auto-place the window.  but we need to know if you explicitly passed in bounds.
- */
- /*
- if(boundsWereExplicit.not,{
- wb = windows.at(vi).innerExtent;
- // if height is less than 80% of full screen
- if(wbh <= (fs.height * 0.8),{
- // move its top to be level at golden ratio
+ if(center) {
+ // this should be a window method
+ fs = GUI.window.screenBounds;
+ wb = window.bounds;
+ // bounds are inaccurate until the end of the code cycle/refresh
+ wb.width = wbw;
+ wb.height = wbh;
+ // if height is less than 60% of full screen
+ if(wbh <= (fs.height * 0.6),{
+ // then move its top to be level at golden ratio
  wb.top = fs.height - (fs.height / 1.6180339887);
  },{
  wb.top = 0;
  });
- // move its left corner to be centered
+ // center it horizontally
  wb.left = (fs.width - wbw) / 2;
- windows.at(vi).bounds = wb;
- }); */
-
+ window.setTopLeftBounds(wb);
+ }
  }
 
  reflowAll {

Modified: trunk/build/SCClassLibrary/crucial/Gui/StringGui.sc
===================================================================
--- trunk/build/SCClassLibrary/crucial/Gui/StringGui.sc 2008-07-09 13:32:57 UTC (rev 7668)
+++ trunk/build/SCClassLibrary/crucial/Gui/StringGui.sc 2008-07-09 18:44:10 UTC (rev 7669)
@@ -34,7 +34,7 @@
  .align_(\left)
  .object_(string);
 
- if(lay.isNil,{ layout.resizeToFit.front });
+ if(lay.isNil,{ layout.resizeToFit(center:true).front });
  }
 
 }

Modified: trunk/build/SCClassLibrary/crucial/Players/AbstractPlayerGui.sc
===================================================================
--- trunk/build/SCClassLibrary/crucial/Players/AbstractPlayerGui.sc 2008-07-09 13:32:57 UTC (rev 7668)
+++ trunk/build/SCClassLibrary/crucial/Players/AbstractPlayerGui.sc 2008-07-09 18:44:10 UTC (rev 7669)
@@ -22,7 +22,7 @@
  this.enableKeyDowns;
 
  if(lay.isNil,{
- layout.resizeToFit.front;
+ layout.resizeToFit(center:true).front;
  view.focus;
  })
  }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
sc-dev mailing list
sc-dev@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-dev