Forum

    • Register
    • Login
    • Search
    • Categories

    Unsolved A Factory for Rotated Text…Almost

    Scripting Forum
    2
    3
    42
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • clevername27
      clevername27 last edited by clevername27

      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;
      	};
      };
      
      1 Reply Last reply Reply Quote 0
      • d.healey
        d.healey last edited by

        What's the problem with using the property editor?

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        clevername27 1 Reply Last reply Reply Quote 1
        • clevername27
          clevername27 @d.healey last edited by

          @d-healey (Thank you for your question - I'm on deadline - will follow up when I have a chance.)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          9
          Online

          1.1k
          Users

          6.8k
          Topics

          62.3k
          Posts