This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/ObjectGui.schelp is in supercollider-common 1:3.8.0~repack-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
CLASS:: ObjectGui
summary:: Controller class for MVC architecture, superclass for all XYZGui classes
related:: Reference/gui
categories:: GUI

DESCRIPTION::
In the MVC architecture this is the Controller, which creates Views for manipulating the properties of your Model, and receives messages from the View and enacts the changes on the Model.

Each class specifies its Gui class via the guiClass method.

The default guiClass for an Object is ObjectGui.  So if a class does not implement guiClass at all, then at least there is a default ObjectGui that will display the name.

Many subclasses override the guiClass method to specify a different class, one that subclasses ObjectGui.

It is the simplest display, it is just the object asString.

The .gui method is called on your model:

code::
// standard usage
theModel.gui( parent, bounds )

// this results in these steps:
guiClass = theModel.guiClass;
gui = guiClass.new( theModel );
gui.gui( parent, bounds );
::

In addition to those steps the model/gui dependencies are managed, defaults (nil parent or nil bounds) are managed and when the window or parent view is closed then dependencies are safely managed.


CLASSMETHODS::

METHOD:: new
Create a gui controller object but does not yet create the views / window.  Call .gui to create the views.

argument:: model
The model is the object that the GUI is a graphical interface for.

returns:: the ObjectGui or subclass object


INSTANCEMETHODS::

METHOD:: guiBody
When implementing subclasses this is the primary and often the only method that needs to be implemented.  The ObjectGui parent class takes care of setting up all windows and dependencies and then the guiBody method adds views to the layout.  It is normal to declare instance variables in the ObjectGui subclass that are used to store the widgets so they can be updated later.

argument:: layout
Usually a FlowView : a parent view with a FlowLayout to add views to.

argument:: bounds
nil or a Rect.

argument:: ... args
More args may be passed here.

returns:: this

METHOD:: update
When the model is changed and the .changed method is called then .update is called on all dependants including this gui object.  Update the views you have placed in the guiBody.

argument:: changed
The model.  Within your gui class the model is already in the instance variable 'model'.

argument:: changer
Depends on the conventions of how .changed was called.  If an object called someModel.changed(this) then it is supplying itself as the changer and will be passed through here.  Sometimes a flag is used: someModel.changed('points') and the gui may know of and participate in that convention.  Sometimes no changer is passed in.


METHOD:: gui
The standard method to create a view / window.  Usually you call yourModel.gui(parent,bounds) and this creates the gui (of the related ObjectGui subclass) and then theObjectGui.gui(parent,bounds) is called, forwarding the arguments.  So this method is what receives the forwarded (parent,bounds) from the initial call to theModel.gui(parent,bounds). Usually you do not call this manually and would avoid reimplementing it.

argument:: parent
parent view : nil, a Window, a FlowView or any other usable container view.

argument:: bounds
nil or a Rect.  The default of nil will offer the entire bounds to the guiBody method and then shrink the view size afterwards to the exact size of the contents that were actually added.

argument::  ... args
More args may be passed into theModel.gui(parent,bounds,anArg,moreArg) and will be forwarded to guiBody.

returns:: this

METHOD:: guify
This converts a supplied parent and bounds into a usable parent container view on a window.  It creates a window if needed.

argument:: parent
parent view or nil

argument:: bounds
desired bounds or nil

argument:: title
window title IF a new window is being created.  if there is a parent view then title is ignored.

returns:: converted parent


METHOD:: model
set a new model. This allows to use a single gui and dynamically swap in a different model of the same class.  The old model releases the gui as a dependant and the new model adds the gui as a dependent.  Then the views are updated.

argument:: newModel
The new object

returns:: (returnvalue)

METHOD:: dragSource
The default implementation of writeName places a nameplate on the gui that is draggable.  This method is an accessor for that dragSource object.

returns:: a GUi.dragSource

METHOD:: viewDidClose
This is called when the parent view closes. It releases dependants.

returns:: this

METHOD:: background
Each ObjectGui subclass may implement a default background color.

returns:: a color

METHOD:: writeName
ObjectGui by default makes a nameplate with the name of the model.  Implement this in subclasses if a different name style or no nameplate is desired.  Note: this may change in the near future.  So many classes override this to shut off the name.

argument:: layout
The layout to place the nameplate on.  Probably the same as is being passed to guiBody

METHOD:: prWriteName
The default write name implementation.  You could call this from a subclass if you are primarily implementing writeName to customize what name is shown or to add other items to that area.

argument:: layout
the layout

argument:: name
the string to display


EXAMPLES::

code::

YourSimpleGuiClass : ObjectGui {

	guiBody { arg layout;
	
		// we refer to the model and
		// access its variable howFast.
		// if its a simple number, it will display
		// using the default ObjectGui class, which
		// will simply show its value as a string.
		model.howFast.gui(layout);
	}
}


// more complex
YourGuiClass : ObjectGui {
	
	var numberEditor;
	
	//for example
	guiBody { arg layout;
		var r;
		// the object you are making a gui for is referred to as the model
		
		// display some param on screen.
		// here we assume that someParam is something that
		//  has a suitable gui class
		// implemented, or that the default ObjectGui is sufficient.
		model.someParam.gui(layout);
		
		// using non 'gui' objects
		r = layout.layRight(300,300); // allocate yourself some space
		Button(layout.win,r)
			.action_({ arg butt;
				model.goApeShit;
			});
		
		// note: NumberEditor is a cruciallib class
		// which is itself a model (its an editor of a value)
		// and has its own gui class that creates and manages the NumberBox view
		numberEditor = NumberEditor(model.howFast,[0,100])
			.action_({ arg val; 
				model.howFast = val; 
				model.changed(this); 
				// tell the model that this gui changed it
			});
		numberEditor.gui(layout);
	}
	
	// your gui object will have update called any time the .changed message
	// is sent to your model
	update { arg changed,changer;
	
		if(changer !== this,{ 
			/* if it is this gui object that changed the value
				using the numberEditor, then we already have a correct
				display and don't need to waste cpu to update it.
				if anyone else changed anything about the model,
				we will update ourselves here.
			*/
			numberEditor.value = model.howFast;
			/*
				note that 
					numberEditor.value = model.howFast;
				is passive, and does not fire the numberEditor's action.	

				numberEditor.activeValue = model.howFast
				would fire the action as well, resulting in a loop that would
				probably crash your machine.
			*/
		}
	}

}
::