Forum
    • Categories
    • Register
    • Login

    How to implement GUI scaling / resizing in HISE plugins? (like Waves-style zoom)

    Scheduled Pinned Locked Moved AI discussion
    19 Posts 3 Posters 133 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.
    • David HealeyD
      David Healey @the red_1
      last edited by

      @the-red_1 Looks like it's a FL Studio specific issue then, you'll have to play around with the script and see if you can find the cause of the issue.

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - Public HISE tutorials
      My Patreon - HISE tutorials

      T 1 Reply Last reply Reply Quote 1
      • T
        the red_1 @David Healey
        last edited by

        @David-Healey I changed the code in ZoomHandler.js to allowZoom(ZoomPanel, !IS_PLUGIN). Is this correct?

        // Author: Christoph Hart
        // License: Public Domain
        namespace ZoomHandler
        {
        	const var MIN_ZOOM = 0.65;
        	const var MAX_ZOOM = 2.0;
        	const var ZOOM_STEP = 0.10;
        	const var INTERFACE_WIDTH = 918;
        	const var INTERFACE_HEIGHT = 581;
        	const var ZoomPanel = Content.getComponent("pnlZoom");
        	const var IS_PLUGIN = Engine.isPlugin();
        	
        	const var draggerData = [110,109,143,130,218,67,147,216,145,66,108,147,216,145,66,143,130,218,67,108,0,0,0,0,143,130,218,67,108,143,130,218,67,0,0,0,0,108,143,130,218,67,147,216,145,66,99,109,143,130,218,67,139,140,96,67,108,139,140,96,67,143,130,218,67,108,66,160,23,67,143,
        	130,218,67,108,143,130,218,67,66,160,23,67,108,143,130,218,67,139,140,96,67,99,109,143,130,218,67,102,22,188,67,108,102,22,188,67,143,130,218,67,108,66,160,151,67,143,130,218,67,108,143,130,218,67,66,160,151,67,108,143,130,218,67,102,22,188,67,99,101,
        	0,0];
        		
        	const var draggerPath = Content.createPath();
        		
        	draggerPath.loadFromData(draggerData);
        	
        	ZoomPanel.setPaintRoutine(function(g)
        	{
        		g.setColour(Colours.withAlpha(Colours.white, (this.data.hover && this.data.allowDrag) ? 0.8 : 0.2));
        		g.fillPath(draggerPath, [0, 0, 10, 10]);
        	});
        	
        	inline function allowZoom(panel, on)
        	{
        		panel.data.allowDrag = on;
        		panel.setMouseCursor(on ?"BottomRightCornerResizeCursor" : "NormalCursor", Colours.white, [0, 0]);
        		panel.repaint();
        	}
        	
        	allowZoom(ZoomPanel, !IS_PLUGIN);
        	
        	ZoomPanel.setMouseCallback(function(event)
        	{
        		this.data.hover = event.hover;
        		
        		if(event.clicked)
        		{
        			this.data.zoomStart = Settings.getZoomLevel();
        		}
        		if(event.mouseUp)
        		{
        			return;
        		}
        	
        		if(event.drag)
        		{
        			if(!this.data.allowDrag)
        				return;
        	
        			var diagonal = Math.sqrt(INTERFACE_WIDTH*INTERFACE_WIDTH + INTERFACE_HEIGHT*INTERFACE_HEIGHT);
        			var currentZoom = Settings.getZoomLevel();
        			var dragPixel = 0;
        			
        			if(event.dragX > event.dragY)
        				dragPixel = (event.dragX * currentZoom) / INTERFACE_WIDTH;
        			else
        				dragPixel = (event.dragY * currentZoom) / INTERFACE_HEIGHT;
        			
        			var maxScaleFactor = Content.getScreenBounds(false)[3] / INTERFACE_HEIGHT;
        			var diagonalDrag = this.data.zoomStart + dragPixel;
        			
        			diagonalDrag += (ZOOM_STEP / 2);
        			
        			diagonalDrag = Math.min(diagonalDrag, maxScaleFactor);
        			
        			diagonalDrag -= Math.fmod(diagonalDrag, ZOOM_STEP);
        			diagonalDrag = Math.range(diagonalDrag, MIN_ZOOM, MAX_ZOOM);
        			
        			var zoomToUse = diagonalDrag;
        			if (currentZoom != zoomToUse)
        				Settings.setZoomLevel(zoomToUse);
        		}
        		
        		this.repaint();
        	});
        }
        
        David HealeyD 1 Reply Last reply Reply Quote 0
        • David HealeyD
          David Healey @the red_1
          last edited by

          @the-red_1 said in How to implement GUI scaling / resizing in HISE plugins? (like Waves-style zoom):

          Is this correct?

          What does correct mean to you?

          Free HISE Bootcamp Full Course for beginners.
          YouTube Channel - Public HISE tutorials
          My Patreon - HISE tutorials

          T 1 Reply Last reply Reply Quote 0
          • T
            the red_1 @David Healey
            last edited by

            @David-Healey Can it work like this?

            David HealeyD 1 Reply Last reply Reply Quote 0
            • David HealeyD
              David Healey @the red_1
              last edited by

              @the-red_1 The zoom functionality will be disabled in the plugin but will be enabled in the standalone.

              Free HISE Bootcamp Full Course for beginners.
              YouTube Channel - Public HISE tutorials
              My Patreon - HISE tutorials

              T 1 Reply Last reply Reply Quote 0
              • T
                the red_1 @David Healey
                last edited by

                @David-Healey Can you give me the solution or advice?

                David HealeyD 1 Reply Last reply Reply Quote 0
                • David HealeyD
                  David Healey @the red_1
                  last edited by

                  @the-red_1 Without knowing what causes it I can't offer a solution. I don't use FL Studio so it's not something I've encountered.

                  Start with a minimal test plugin - completely empty project with just the zoom handler. See if that works.

                  Free HISE Bootcamp Full Course for beginners.
                  YouTube Channel - Public HISE tutorials
                  My Patreon - HISE tutorials

                  T 1 Reply Last reply Reply Quote 1
                  • T
                    the red_1 @David Healey
                    last edited by

                    @David-Healey Haha, I made a silly mistake 😅. I had an old version of the VST in Program Files and a new version as a .dll in my DAW FL Studio. FL Studio was detecting both of them, and that’s what caused the problem. Now everything is fine. Thanks for the time you gave me!

                    David HealeyD 1 Reply Last reply Reply Quote 2
                    • David HealeyD
                      David Healey @the red_1
                      last edited by

                      @the-red_1 Aha great to know it works :)

                      Free HISE Bootcamp Full Course for beginners.
                      YouTube Channel - Public HISE tutorials
                      My Patreon - HISE tutorials

                      1 Reply Last reply Reply Quote 0
                      • xxxX
                        xxx
                        last edited by

                        does it work even with images in the gui?

                        or does it have to be all laf?

                        David HealeyD 1 Reply Last reply Reply Quote 0
                        • David HealeyD
                          David Healey @xxx
                          last edited by

                          @xxx Images will distort when their size is changed, but it will work.

                          Free HISE Bootcamp Full Course for beginners.
                          YouTube Channel - Public HISE tutorials
                          My Patreon - HISE tutorials

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

                          13

                          Online

                          2.2k

                          Users

                          13.6k

                          Topics

                          118.0k

                          Posts