Page 1 of 1

FR: Module Designer

Posted: Sat Apr 25, 2020 2:41 am
by andro
Here's my feature request. It would be great to have an align function for items on a panel, such as found in most graphics programs. Would save a lot of fiddling and getting things wrong by one or two pixels.

Re: FR: Module Designer

Posted: Sat Apr 25, 2020 10:45 am
by honki-bobo
+1

Also, I would like to
- check if a module is running in demo mode
- change or manipulate the background image of a module at runtime
- change the color of a GUI element to any color at runtime (those are SVGs if I'm not mistaken, so it shouldn't be too hard)
- read an exhaustive JavaDoc-alike documentation of the API :!:

Re: FR: Module Designer

Posted: Sat Apr 25, 2020 11:49 am
by nekomatic
honki-bobo wrote: Sat Apr 25, 2020 10:45 am - change or manipulate the background image of a module at runtime
You can use an image component at the bottom , this is what I've done in my Digital Vocoder
honki-bobo wrote: Sat Apr 25, 2020 10:45 am - change the color of a GUI element to any color at runtime (those are SVGs if I'm not mistaken, so it shouldn't be too hard)
You can create your own component skins and swap them at runtime

Re: FR: Module Designer

Posted: Wed Apr 29, 2020 12:23 pm
by honki-bobo
nekomatic wrote: Sat Apr 25, 2020 11:49 am
honki-bobo wrote: Sat Apr 25, 2020 10:45 am - change or manipulate the background image of a module at runtime
You can use an image component at the bottom , this is what I've done in my Digital Vocoder
Thanks for the hint. I've experimented with this a bit and I found a way to manipulate the background image the way I want to, though it is not very convenient. I had to write the manipulated pixel data to a BufferedImage (with all the bit shifting and bitwise or), use ImageIO to write the pixel data as a PNG into a ByteArrayOutputStream and finally add the byte array from that stream to the VoltageImage after clearing it. Also, I still have to add the screws as extra images. It would be much easier if a VoltageImage (or the VoltageModule for that matter) had a method that takes ARGB image data as an int or byte array and just displays it, similar to the setRGB(int x, int y, int rgb) method of a BufferedImage.
nekomatic wrote: Sat Apr 25, 2020 11:49 am
honki-bobo wrote: Sat Apr 25, 2020 10:45 am - change the color of a GUI element to any color at runtime (those are SVGs if I'm not mistaken, so it shouldn't be too hard)
You can create your own component skins and swap them at runtime
This is still on my to-try list :) , though I would love to have setXXXColor(Color color) methods for all GUI elements where appropriate.

Besides, according to the thread Extra Resources in Designer not loading via GetBinaryResource I had to add a underscore at the end of the file extension for VMD to recognize it as a binary file and not an image, otherwise I could not load the extra resource. This is still an issue, right?

Re: FR: Module Designer

Posted: Mon Jun 22, 2020 9:53 am
by arbuxMusic
I just did a quick test of loading a PNG image from the VMD resources function in VMD 2.0.17. Great news - There was no need to add an underscore to the resource file type. (Note that I have changed the filename for this code as I was using slightly different code for my module). Let me know if there are any issues.

After adding a resource named "Background.jpg" to the VMD module "Extra Resources" property, the following code was in the module initialise.

Code: Select all

// Module property
private BufferedImage backgroundImage;

// Added to the initialise function
var byteBuffer = GetBinaryResource("Background.png");
byte[] imageBytes= new byte[byteBuffer.remaining()];
byteBuffer.get(imageBytes);
InputStream in = new ByteArrayInputStream(imageBytes);
backgroundImage = ImageIO.read(in);
Log("Oscilloscope background width: "+ backgroundImage.getWidth() + " height:" + backgroundImage.getHeight());

// Paint method:
Graphics2D g = canvas.GetGraphics();
g = canvas.GetGraphics();
g.drawImage(backgroundImage, 0, 0, null);
g.dispose(); // don't forget this :)