Page 1 of 1

gui - scroll through multiple images

Posted: Fri Feb 12, 2021 2:10 pm
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

Re: gui - scroll through multiple images

Posted: Mon Feb 15, 2021 7:25 am
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

Re: gui - scroll through multiple images

Posted: Mon Feb 15, 2021 10:33 am
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

Re: gui - scroll through multiple images

Posted: Mon Feb 15, 2021 11:09 am
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

Re: gui - scroll through multiple images

Posted: Mon Feb 15, 2021 7:01 pm
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

Re: gui - scroll through multiple images

Posted: Mon Feb 15, 2021 7:57 pm
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