A Factory for Rotated Text…Almost
-
I was trying to create a factory for rotated text, but the main problem is that you can't use the interface designer to set the properties. I made a button to force a repaint so at least I could find out the parameters I wanted for a given instance, but that was way too much work. The other problem is that the sizing seems to not be rotated. Any ideas? I'm thinking this widget would be useful for lots of folks.
EDIT: I'm thinking a helper function?
namespace RotatedLabel { /////////////////////////////// WIDGET FACTORY ///////////////////////////////////// // // Create a factory function to produce widgets. The size is a single // variable because the widget will be square. inline function createWidget(name, x, y, size) { // ------------- Creating the Panel // Call HISE's API to create a panel. local widget = Content.addPanel(name, x, y); // Assign these built-in parameters to the panel. Content.setPropertiesFromJSON(name, { "width": size, "height": size, }); // ------------- Creating Public Variables widget.data.cornerData = 3; widget.data.borderWidth = 1; widget.data.textAngle = 270; widget.data.fontSize = 18; widget.data.textColour = 0xFAFFFFFF; widget.data.bgColour; // This is the paint routine for the panel, which draws the widget. widget.setPaintRoutine(function(g) { g.rotate(Math.toRadians(this.data.textAngle), [this.getWidth()/2, this.getHeight()/2]); g.setColour(this.data.bgColour); g.fillRoundedRectangle([0,0,this.getWidth(),this.getHeight()],this.data.cornerData); g.setFont(DEFAULT_MEDIUMFONT, 18); g.setColour(this.data.textColour); g.drawText(this.get("text"), [0,0, this.getWidth(), this.getHeight()]); }); // Return our completed widget now that it has been constructed. return widget; }; };
-
What's the problem with using the property editor?
-
@d-healey (Thank you for your question - I'm on deadline - will follow up when I have a chance.)
-
Why this Shows me errors?
const var TestLabel = RotatedLabel.createRotatedLabel("TestLabel", 0, 2);
How to use this Widget?
-
@Natan
createRotatedLabel
Where did you get this from? -
@d-healey Not sure, Just wanted to add panels, and Vertical Texts
How it supposed to work?
-
@Natan Read the code, the instructions are there