HISE Logo Forum
    • Categories
    • Register
    • Login

    Images in a Viewport

    Scheduled Pinned Locked Moved General Questions
    25 Posts 2 Posters 1.2k 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.
    • DanHD
      DanH @d.healey
      last edited by

      @d-healey would a button pack be a good choice for this?

      https://docs.hise.audio/scripting/scripting-in-hise/scriptpanel.html#a-buttonpack

      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
      https://dhplugins.com/ | https://dcbreaks.com/
      London, UK

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

        @DanH I'd use a panel in the viewport and child panels for each list item

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

        DanHD 2 Replies Last reply Reply Quote 0
        • DanHD
          DanH @d.healey
          last edited by

          @d-healey actually maybe there's no need for the names.... just images would be nicer. I'll give it a go but if you know of any examples that would be very welcome!

          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
          https://dhplugins.com/ | https://dcbreaks.com/
          London, UK

          1 Reply Last reply Reply Quote 0
          • DanHD
            DanH @d.healey
            last edited by

            @d-healey getting somewhere. There's a lot of panel with images in. Can I create a for loop to manage their callbacks rather than writing out one for each panel / image?

            const var SHAPEARRAY = [Content.getComponent("SHAPE1"), Content.getComponent("SHAPE2")];
            
            /// Panel Callbacks
            SHAPE1.setMouseCallback(function(event)
            {
            	if (event.clicked)
            	{
            		PresetList.setValue(0);
            		PresetList.changed();
            	}
            
            });
            
            SHAPE2.setMouseCallback(function(event)
            {
            	if (event.clicked)
            	{
            		PresetList.setValue(1);
            		PresetList.changed();
            	}
            
            });
            
            

            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
            https://dhplugins.com/ | https://dcbreaks.com/
            London, UK

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

              @DanH said in Images in a Viewport:

              Can I create a for loop to manage their callbacks rather than writing out one for each panel / image?

              You absolutely should do this. Start with 3 in a little test project to get the hang of it. They should all use the same callback function and probably the same paint routine.

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

              DanHD 1 Reply Last reply Reply Quote 0
              • DanHD
                DanH @d.healey
                last edited by

                @d-healey any chance of a hand with this please?! 😆

                Getting confused on how to write the g.loadImage line... Getting the error: Interface:! Image ts[Array] not found... I mean I could be on totally the wrong path 😆

                const var SHAPE1 = Content.getComponent("SHAPE1");
                const var SHAPE2 = Content.getComponent("SHAPE2");
                const var SHAPE3 = Content.getComponent("SHAPE3");
                
                const var SHAPESIMAGESARRAY = [
                                               Content.getComponent("SHAPE1"),
                                               Content.getComponent("SHAPE2"),
                                               Content.getComponent("SHAPE3")];
                
                SHAPE1.loadImage("{PROJECT_FOLDER}AGAIN.png", "ts1");
                SHAPE2.loadImage("{PROJECT_FOLDER}AMA.png", "ts2");
                SHAPE3.loadImage("{PROJECT_FOLDER}ANTIDOTE.png", "ts3");
                
                for (i = 0; i < 4; i++)
                {
                	SHAPESIMAGESARRAY[i].setPaintRoutine(function(g)
                	{
                		g.drawImage(("ts" + [i]), [0, 0, 100, 50], 0, 0);
                	});
                }
                
                

                DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                https://dhplugins.com/ | https://dcbreaks.com/
                London, UK

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

                  @DanH I'll put an example together, give me a few minutes

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

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

                    Here's an example project.

                    viewport_image_demo.zip

                    Peek 2024-05-28 17-24.gif

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

                    DanHD 1 Reply Last reply Reply Quote 0
                    • DanHD
                      DanH @d.healey
                      last edited by

                      @d-healey ok this looks good, thanks :)

                      How can I create it so there's 3 columns and set the width of each column?

                      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                      https://dhplugins.com/ | https://dcbreaks.com/
                      London, UK

                      d.healeyD 2 Replies Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @DanH
                        last edited by

                        @DanH said in Images in a Viewport:

                        How can I create it so there's 3 columns and set the width of each column?

                        Any more requirements I should know about before I answer this?

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

                        DanHD 1 Reply Last reply Reply Quote 0
                        • DanHD
                          DanH @d.healey
                          last edited by

                          @d-healey Can I create gaps between each child panel if they look better with them? And each child panel requires a callback. Sorry, haven't used panels and script like this before so not sure what's possible! Many thanks

                          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                          https://dhplugins.com/ | https://dcbreaks.com/
                          London, UK

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

                            @DanH said in Images in a Viewport:

                            Can I create gaps between each child panel if they look better with them?

                            Yes - they are just panels, it is no different to what you can do when you manually add panels in the interface designer.

                            @DanH said in Images in a Viewport:

                            And each child panel requires a callback

                            Does the callback need to be different for each child panel? If so, why?

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

                            DanHD 1 Reply Last reply Reply Quote 0
                            • DanHD
                              DanH @d.healey
                              last edited by

                              @d-healey the callbacks just need to set the value of another viewport according to their number. So childpanel / img01 should set the other viewport to 1.

                              +.changed(); of course.

                              DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                              https://dhplugins.com/ | https://dcbreaks.com/
                              London, UK

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

                                @DanH So for that you just need one callback that all the child panels will share.

                                Modify the addListItem function

                                inline function addListItem(panel, index)
                                {
                                	local p = panel.addChildPanel();
                                	p.data.index = index; // Set the index here so the child panel knows its own index
                                	p.loadImage("{PROJECT_FOLDER}img" + index + ".jpg", "img");
                                	p.set("allowCallbacks", "All Callbacks");
                                	p.setPosition(0, panel.data.rowHeight * index, panel.getWidth(), panel.data.rowHeight);
                                
                                	p.setPaintRoutine(function(g)
                                	{
                                		var a = this.getLocalBounds(0);
                                		g.drawImage("img", a, 0, 0);
                                	});
                                	
                                	p.setMouseCallback(function(event)
                                	{		
                                		if (!event.clicked)
                                			return;
                                
                                		// Do the thing
                                		Console.print(this.data.index);
                                	});	
                                }
                                

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

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

                                  @DanH said in Images in a Viewport:

                                  How can I create it so there's 3 columns and set the width of each column?

                                  For this you need to draw a grid of child panels in the container panel (pnlList).

                                  So create a new project and place a grid of panels in the interface designer. Look at their X/Y positions. Now try to come up with a formula that will place the panels in those positions for you (dare I say ChatGPT might be useful here... might).

                                  Then try it with child panels.

                                  Then try it with different widths for each column.

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

                                  1 Reply Last reply Reply Quote 0
                                  • DanHD
                                    DanH @d.healey
                                    last edited by

                                    @d-healey do I need to set the child panels' callbacks to include clicks?

                                    DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                    https://dhplugins.com/ | https://dcbreaks.com/
                                    London, UK

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

                                      @DanH

                                      5a93d86e-5690-44bb-9c79-eb0e00013e17-image.png

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

                                      DanHD 2 Replies Last reply Reply Quote 0
                                      • DanHD
                                        DanH @d.healey
                                        last edited by

                                        @d-healey lol, missed that!

                                        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                        https://dhplugins.com/ | https://dcbreaks.com/
                                        London, UK

                                        1 Reply Last reply Reply Quote 0
                                        • DanHD
                                          DanH @d.healey
                                          last edited by

                                          @d-healey why this?

                                          inline function removeAllChildPanels(panel)
                                          {
                                          	for (x in panel.getChildPanelList())
                                          		x.removeFromParent();
                                          }
                                          

                                          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                          https://dhplugins.com/ | https://dcbreaks.com/
                                          London, UK

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

                                            @DanH Go to where I'm calling that function, there's a comment

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

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

                                            14

                                            Online

                                            2.0k

                                            Users

                                            12.7k

                                            Topics

                                            110.2k

                                            Posts