Skip to content

Instantly share code, notes, and snippets.

@madskjeldgaard
Last active July 22, 2021 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madskjeldgaard/63ba93402ca9f818cf1a5b0409433b5a to your computer and use it in GitHub Desktop.
Save madskjeldgaard/63ba93402ca9f818cf1a5b0409433b5a to your computer and use it in GitHub Desktop.
A number of overwrites to make JITLib gui (especially NdefGui) more readable on HiDPI screens + responsive to local specs
// Some patches to make JitLib gui stuff more easy on the eyes. Mostly: Larger!
// Also: Make it respond to local specs if defined using the NamedControl style
// FIX: Change font size, button heights and color scheme
+ JITGui {
*initClass {
Class.initClassTree(GUI);
GUI.skins.put(\jit, (
fontSpecs: ["Helvetica", 16],
fontColor: Color.black,
background: Color.grey(0.90),
foreground: Color.grey(0.95),
onColor: Color.green(1.0, 0.15),
onColor2: Color.green(1.0, 0.15),
offColor: Color.grey(0.9, 0.5),
hiliteColor: Color.green(1.0, 0.25),
margin: 0@0,
buttonHeight: 32,
headHeight: 32
)
);
}
}
// FIX: Look up Ndef's local spec when making GUI
+ EnvirGui {
getSpec { |key, value|
var spec = object.specs.at(key) ?? specs[key] ?? { key.asSpec };
if (spec.isNil) {
spec = Spec.guess(key, value);
specs.put(key, spec);
};
^spec
}
}
// FIX: Increase GUI buttons' size
+ NdefGui{
*initClass {
Class.initClassTree(Spec);
Spec.add(\ampx4, [0, 4, \amp]);
Spec.add(\fadePx, [0, 100, \amp, 0, 0.02]);
buttonSizes = (
name: 70, type: 40, CLR: 50, reset: 50, scope: 50, doc: 40, end: 40, fade: 80,
monitor: 200, monitorM: 250, monitorL: 300, play: 100, pausR: 50, sendR: 50,
ed: 30, rip: 40, poll: 50, wake: 50
);
this.makeButFuncs;
}
makeFadeBox { |width = 60, height = 18|
fadeBox = EZNumber(zone, width@height, \fade, \fadePx,
{ |num| try { object.fadeTime_(num.value) } },
try { object.fadeTime } ? 0.02,
labelWidth: width / 2,
numberWidth: width / 2
);
fadeBox.labelView.font_(font)
.background_(skin.background)
.stringColor_(skin.fontColor);
fadeBox.numberView.font_(font)
.background_(skin.background)
.stringColor_(skin.fontColor)
.refresh;
}
}
+ NdefParamGui{
makeViews {
var sinkWidth = 20;
var height = skin.buttonHeight;
specs = ();
replaceKeys = ();
prevState = ( settings: [], overflow: 0, keysRotation: 0, editKeys: []);
labelWidth = zone.bounds.width * 0.15;
#drags, paramViews = { |i|
var drag = DragBoth(zone, Rect(0, 0, sinkWidth, skin.buttonHeight))
.string_("-").align_(\center)
.visible_(false)
.font_(font)
.action_(this.dragAction(i));
var parView = ParamView(zone, Rect(0, 0, bounds.width - sinkWidth - 20, height))
// .resize_(2)
.background_(skin.background)
.useRanger_({ this.useRanger });
// parView.textview.textField.align_(\right);
// parView.textview.textField.background_(Color.green);
parView.zone.visible_(false);
[drag, parView];
}.dup(numItems).flop;
zone.decorator.reset.shift(zone.bounds.width - 16, 0);
scroller = EZScroller(zone,
Rect(0, 0, 12, numItems * height),
numItems, numItems,
{ |sc|
keysRotation = sc.value.asInteger.max(0);
prevState.put(\dummy, \dummy);
}
).visible_(false);
scroller.slider.resize_(3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment