deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / Common / GUI / guicrucial / StringGui.sc
blobe0e7691a18a17b5d5421bd7d919b7c79535c765b
1 // just a label with the name of the object
3 StringGui : ObjectGui {
5         writeName {}
6         gui { arg parent, bounds ... args;
7                 var layout,string,font;
8                 var width,height;
9                 layout=this.guify(parent,bounds);
10                 font = GUI.font.new(*GUI.skin.fontSpecs);
11                 if(model.isString,{
12                         string = " "++model;
13                 },{
14                         // floats, integers, symbols will show more clearly what they are
15                         string = " "++model.asCompileString;
16                 });
17                 if(string.size > 1024,{
18                         string = string.copyRange(0,1024) ++ "...";
19                 });
20                 if(bounds.notNil,{
21                         bounds = bounds.asRect;
22                 },{
23                         bounds = Rect(0,0,
24                                                 string.bounds.width(font).max(30),
25                                                 GUI.skin.buttonHeight);
26                 });
27                 this.view = GUI.staticText.new(layout,bounds)
28                         .stringColor_(GUI.skin.fontColor)
29                         .font_(font)
30                         .background_(GUI.skin.background)
31                         .align_(\left)
32                         .object_(string);
34                 if(parent.isNil,{
35                         layout.resizeToFit;
36                         layout.front
37                 });
38         }