HISE Logo Forum
    • Categories
    • Register
    • Login

    A Factory for Rotated Text…Almost

    Scheduled Pinned Locked Moved Unsolved Scripting
    7 Posts 3 Posters 320 Views
    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.
    • clevername27C
      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.healeyD
        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

        clevername27C 1 Reply Last reply Reply Quote 1
        • clevername27C
          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
          • NatanN
            Natan
            last edited by

            Why this Shows me errors?
            const var TestLabel = RotatedLabel.createRotatedLabel("TestLabel", 0, 2);

            How to use this Widget?

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @Natan
              last edited by

              @Natan createRotatedLabel Where did you get this from?

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

              NatanN 1 Reply Last reply Reply Quote 0
              • NatanN
                Natan @d.healey
                last edited by

                @d-healey 😅 Not sure, Just wanted to add panels, and Vertical Texts

                How it supposed to work?

                d.healeyD 1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey @Natan
                  last edited by

                  @Natan Read the code, the instructions are there

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

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

                  44

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  101.9k

                  Posts