gui - scroll through multiple images

Post Reply
farbstoff-fabrik

gui - scroll through multiple images

Post by farbstoff-fabrik »

Hi there,

I was wondering if there is a possibility to be able to scroll though a few images useing left-right-buttons in the gui?

What i like to achieve is that there are two increment buttons (left and right) that control different oscillator shapes. I like to display those oscillator shapes useing the increment buttons. So in other words you use left/right buttons to cycle through multiple images.

Thanks in advance!

-Matt
creart
Posts: 59
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: gui - scroll through multiple images

Post by creart »

hey Matt
Would those Images need to be scrolling really or just switch from on to the other?

If just switching, I would make an array holding the image objects and then use the value of the knob as index to set the visibility of the image...

Real scrolling would be trickier - you’d need to use a mask on top of a strip of images to do that, while changing the location of the imagestrip behind the mask..
If that will work depends on the amount of available space ....

This is just of the top of my head- haven’t tried yet...
Hope that helps?

Cheers Hans
Request for Music
creart
Posts: 59
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: gui - scroll through multiple images

Post by creart »

Code: Select all

INITIALIZE
	// add your own code here
	fillImageArray();
	positionImages(myImages);


NOTIFY
case Knob_Changed:   // doubleValue is the new VoltageKnob value
	{
		if(component==wave){			
			setImage(myImages);
		}
	}
break;

USER VARIABLES
/*******************************************
	First needed to create the array 
	and then fill it in ititialze()
	Strangely enough it would not work
	if I initialize and fill at the same time
	********************************************/
	VoltageImage[] myImages = new VoltageImage[5];
	
	public void positionImages(VoltageImage[] arr){
	/****************************************
	I actually just dropped all of the images on the screen somewhere
	and then placed them from this function on required place
	and with proper size etc.
	I also had to make sure that they were on top of the knob....
	************************************************/	 
		for(int i=0; i<arr.length; i++){
			arr[i].SetPosition(40,105);
			arr[i].SetSize(64,64);
			arr[i].SetVisible(false);
			arr[i].SetZOrder(-1);
			}
	}
	public void setImage(VoltageImage[] arr){
		// go through array and set to knob value
		for(int i=0; i<arr.length; i++){
			if(i==(int) wave.GetValue()){
				arr[i].SetVisible(true);
			}else{
				arr[i].SetVisible(false);
			}	
		}
	}
	public void fillImageArray(){
	// did not want to clutter INITIALIZE, so placed separately
		myImages[0]=image1;
		myImages[1]=image2;
		myImages[2]=image3;
		myImages[3]=image4;
		myImages[4]=image5;
	}

Hope this helps Matt
Request for Music
creart
Posts: 59
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: gui - scroll through multiple images

Post by creart »

I used the image of the wave on top of the knob, that's why I needed the ZOrder...
And here I used a knob instead of left/right buttons but in that case you increment or decrement a value and use that as the array index...

Here a link to a screenrecording:
http://www.requestformusic.com/RFM-VM/knobImage.mp4
Attachments
Schermafbeelding 2021-02-15 om 12.06.54.png
Schermafbeelding 2021-02-15 om 12.06.54.png (504.78 KiB) Viewed 2750 times
Request for Music
farbstoff-fabrik

Re: gui - scroll through multiple images

Post by farbstoff-fabrik »

Exactly! Thanks heaps. Is an array a strip of images?

I am not at the coding part of modules, only the visual aspect of them 😁

Cheers

- Matt
creart
Posts: 59
Joined: Sat Dec 19, 2020 12:13 pm
Location: Netherlands
Contact:

Re: gui - scroll through multiple images

Post by creart »

Now I see... Matthijs!!!
Hoi.. even Nederlands... een array is een 'genummerde lijst' - in die lijst kun je objecten plaatsen en dan op basis van het nummer daar iets uit halen... if that makes sense :-)
Anders misschien via Zoom of Skype wat afspreken - dan kan ik je er doorheen loodsen

grtz Hans
Request for Music
Post Reply

Return to “Module Designer”