FR: Module Designer

Post Reply
andro
Posts: 114
Joined: Mon Apr 06, 2020 4:45 am

FR: Module Designer

Post by andro » Sat Apr 25, 2020 2:41 am

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.

User avatar
honki-bobo
Posts: 83
Joined: Sat Nov 09, 2019 1:18 pm

Re: FR: Module Designer

Post by honki-bobo » Sat Apr 25, 2020 10:45 am

+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 :!:
Image
Monkey Business Audio
Modules - Forum

User avatar
nekomatic
Posts: 64
Joined: Mon Jul 08, 2019 8:52 pm

Re: FR: Module Designer

Post by nekomatic » 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
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

User avatar
honki-bobo
Posts: 83
Joined: Sat Nov 09, 2019 1:18 pm

Re: FR: Module Designer

Post by honki-bobo » Wed Apr 29, 2020 12:23 pm

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?
Image
Monkey Business Audio
Modules - Forum

arbuxMusic
Posts: 30
Joined: Sun Aug 25, 2019 10:26 am

Re: FR: Module Designer

Post by arbuxMusic » Mon Jun 22, 2020 9:53 am

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 :)

Post Reply