Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

ruby setViewSize and module display window

For general discussion related FlowStone

ruby setViewSize and module display window

Postby pshannon » Wed Apr 01, 2020 12:15 am

Hey everyone,

I have been trying to figure out a way in ruby to actually set the screen size and not related to the view port. The problem I am trying to resolve is dynamically correct the screen when switching from a vertical view to a horizontal view orientation. Another idea to describe this, if you take a bitmap picture in portrait and you rotated to landscape the window should change to the bitmap dimensions of x,y, width,height and not the bitmap scale to fit the the window. This is easy in visual studio, but I couldn't find much detail for ruby except setViewSize=[0,0,8,8] in the user manual which didn't appear to do anything. The FS version I am using is skylark 3.08.

Thanks
User avatar
pshannon
 
Posts: 144
Joined: Fri Jan 02, 2015 3:08 am

Re: ruby setViewSize and module display window

Postby tulamide » Wed Apr 01, 2020 4:16 am

pshannon wrote:Hey everyone,

I have been trying to figure out a way in ruby to actually set the screen size and not related to the view port. The problem I am trying to resolve is dynamically correct the screen when switching from a vertical view to a horizontal view orientation. Another idea to describe this, if you take a bitmap picture in portrait and you rotated to landscape the window should change to the bitmap dimensions of x,y, width,height and not the bitmap scale to fit the the window. This is easy in visual studio, but I couldn't find much detail for ruby except setViewSize=[0,0,8,8] in the user manual which didn't appear to do anything. The FS version I am using is skylark 3.08.

Thanks

Without using Flowstone's Win32API extension, you won't be able to access Flowstone's window. I'm not even sure if you can when using the extension.

setViewSize is a method of the View class and is used to set the position and dimension of the current view in its parent view. Both, setViewSize and setShowInParent, are only available in 3.0.8, not in 3.0.6, but I wouldn't recommend using 3.0.8 (has been discussed very often, why you should avoid using it). The alpha of course also supports both methods.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: ruby setViewSize and module display window

Postby pshannon » Wed Apr 01, 2020 2:10 pm

tulamide wrote:
pshannon wrote:Hey everyone,

I have been trying to figure out a way in ruby to actually set the screen size and not related to the view port. The problem I am trying to resolve is dynamically correct the screen when switching from a vertical view to a horizontal view orientation. Another idea to describe this, if you take a bitmap picture in portrait and you rotated to landscape the window should change to the bitmap dimensions of x,y, width,height and not the bitmap scale to fit the the window. This is easy in visual studio, but I couldn't find much detail for ruby except setViewSize=[0,0,8,8] in the user manual which didn't appear to do anything. The FS version I am using is skylark 3.08.

Thanks

Without using Flowstone's Win32API extension, you won't be able to access Flowstone's window. I'm not even sure if you can when using the extension.

setViewSize is a method of the View class and is used to set the position and dimension of the current view in its parent view. Both, setViewSize and setShowInParent, are only available in 3.0.8, not in 3.0.6, but I wouldn't recommend using 3.0.8 (has been discussed very often, why you should avoid using it). The alpha of course also supports both methods.


Tula thanks for your response:
3.0.8 I have used for a long time and I have not ran into issues. I have been out of the scene a long time and I did not look for issues related to skylark. I will consider moving back to 3.0.6. The whole process to downgrade was a pain last time I did this years ago. I did get burned with the beta years ago. I want to make sure I am clear on what I am trying to ask.
I only want to change the window dimensions size of a single module and not the the main window. From what I think I am hearing from you, this is not possible without the api, which surprised me considering this is inside flowstone and not something the OS or api outside of flowstone would control. If it is not possible I will take your answer. If it can be done in combination with a prim with ruby. Again this is to resize modules and not full flowstone window. Thanks
User avatar
pshannon
 
Posts: 144
Joined: Fri Jan 02, 2015 3:08 am

Re: ruby setViewSize and module display window

Postby tulamide » Thu Apr 02, 2020 1:03 am

We need to get even on the terms so that we don't talk past each other :lol:

"window" - an area provided by windows for a program that wants to display things. Example, Flowstone is in a window, a plugin is in a window

"view" - an area within a Flowstone module that defines a space to display graphics

If you want to change the dimensions of a view, you can do that in its parent's view, when using FS 3.0.8. Example: you have a module that displays a level meter. But this meter can be vertically or horizontally.

You enable a view of a module by placing a MGUI prim inside the module. Here it will probably be routed to a Ruby module that does the drawing. But an MGUI also has a view input. This input is used to tell the module to which parent module's view it belongs.

The top view in your schematic will become a plugin window. So, to display a meter horizontally and vertically, based on settings, and have the view dimensions in which the meter is drawn, fit to the orientation, you hook that view to a parent view (here the top view, that becomes a plugin window) and change its dimensions everytime, the setting changes from horizontal to vertical and vice versa.

I can't provide you with a schematic, because I use 3.0.6, but if you look at other modules, it should become clear. Start Flowstone, and drag the stock "ADSR" module into the schematic. Currently this module now holds the top view. Now double click on it to look inside the module. You will see 6 "Knob static" modules, each with their own view. Those are the child views. If you right click on one of them, you will see a menu with the entry "Show in parent panel" being checked. If you uncheck it, and leave the module, you will see that on the top view one knob is now missing. Go back into the module and check "Show in parent panel" again.

Congratulations! What you just did manually, that's what the method View.setShowInParent in Ruby is for. It does in code what you just did manually! ;)

Now double-click on the knob module to look inside. You will see another module with a view, called "Knob". A right click reveals that this one also has "Show in parent panel" checked. Double click on that module to look iside it. You will find a MGUI, which has a wireless input connected to its view input. This simple wireless input is responsible for displaying the knob on higher layers. If you remove the connection to the view input, no knob will be displayed on the top layer. That is, because all 6 "Knob" modules in the schematic are sync'ed. Any change to one of them will be done to all of them. Connect it again, so that all knobs are displayed on the top view again. Leave the "Knob" module. Leave the "Knob static" module. Right click on the "Knob static" module and select "Edit front panel" from the menu. Resize the module. You will notice that the view automatically resizes as well. But they are not one and the same. The view is independend on the module. If you move the mouse over the thick dark grey outline of the view, the cursor changes. You now can click and drag to change the size of the view independently from the modules size. This feature is what allows you to set a view's dimensions in the parent view as well. You will notice that in this view there is the knob from the child "Knob" module. Around it is a white dashed outline. This shows the current dimensions of the "Knob" module's view inside of the the "Knob static" module's view. You can click on the outline to activate it, then move the mouse to the light blue corner of the otherwise white outline. The cursor changes and you can now click and drag to change the size of the "Knob" module's view. Or you just click somewhere within the outline and drag to set a new position for the "Knob" module's view.

Congratulations! What you just did manually, that's what the method View.setViewSize in Ruby is for. It does in code, what you just did manually! ;)

I know this was a lot of text. But if you took the time to follow it, while doing what I asked for in Flowstone, I think it has become obvious now.

Regarding 3.0.8, just remember that the changes to the code led to a faulty implementation of the Ruby thread. Basically you are running Ruby at half speed. If you don't encounter any of the bugs and are fine with a half-speed Ruby, there is no reason to switch to 3.0.6
If you want to switch, that's easy. Spogg also was hesitant, until I convinced him. He noticed the improvements right away and nver regretted the step back to 3.0.6. Just backup your toolbox, do a clear de-install (incl removing manually any leftovers). Then install 3.0.6 and all is good :mrgreen:
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: ruby setViewSize and module display window

Postby Spogg » Thu Apr 02, 2020 7:58 am

I wish I could have read that 6 years ago tulamide!

View handling was a great puzzle to me when I started. Essentially I learned by trial and error (mostly the latter).

You explain things so well and I hope people appreciate just how much time such a text takes to create, especially in a "foreign" language.

Cheers

Spogg
User avatar
Spogg
 
Posts: 3358
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: ruby setViewSize and module display window

Postby pshannon » Thu Apr 02, 2020 1:11 pm

Tula,

Thanks for taking the extra time in responding in such detail. I look forward to trying this step by step process you created. I now feel like the person on the other end of the IT phone support call. In my very early years of my career you would talk to that old guy on the other end of the phone trying to tell them how to turn on a computer. How did I get to that point with FS? Like I tried to say earlier, this is easy in visual studio languages like C++, visual basic or even delphi. I even learned how to do this in ruby outside of FS. But inside of FS the full ruby language is a little different. From here on out, I will be careful on how I respond or correct you related to security. ;) Because here in this blog, I am no expert. lol
"Congratulations, you did this manually?" Is one of those moments you are thinking dumb a**. haha
BTW Your comment of 3.0.6 vs 3.0.8? They appear to be compatible. The beta 3.0.9 is not. Everything I have posted is in 3.0.8 and I have opened everything on this site without any issues using 3.0.8. I have not looked at the blog to see what the issues/bugs are, but as for versions back and forward, it appears to be fine.
Thanks again.

Spog,

Tula has been writing this in a different language this whole time? Now I have a whole new respect for his responses. I bet he is smacking his head from germany and saying stupid Americans? haha
Is there a way to take this explanation and put it in the tutorial?
Last edited by pshannon on Thu Apr 02, 2020 4:35 pm, edited 1 time in total.
User avatar
pshannon
 
Posts: 144
Joined: Fri Jan 02, 2015 3:08 am

Re: ruby setViewSize and module display window

Postby Spogg » Thu Apr 02, 2020 2:41 pm

pshannon wrote:...Tula has been writing this in a different language this whole time? ...
Is there a way to take this explanation and put it in the tutorial?


Yes he’s German and I know he likes to go through his text meticulously and tries to get it perfect, and normally succeeds. This is why he puts so much effort and time in for all our benefit. He’s a great guy!

I’m not sure what you mean by “the tutorial”. Tulamide and many others have created mini tutorials in the past, but sadly they are scattered throughout the forum. It would be lovely if someone could collate them or if you come across one we could start a tutorials post with links or copies.

Cheers

Spogg
User avatar
Spogg
 
Posts: 3358
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: ruby setViewSize and module display window

Postby pshannon » Thu Apr 02, 2020 4:33 pm

Spogg wrote:
pshannon wrote:...Tula has been writing this in a different language this whole time? ...
Is there a way to take this explanation and put it in the tutorial?


Yes he’s German and I know he likes to go through his text meticulously and tries to get it perfect, and normally succeeds. This is why he puts so much effort and time in for all our benefit. He’s a great guy!

I’m not sure what you mean by “the tutorial”. Tulamide and many others have created mini tutorials in the past, but sadly they are scattered throughout the forum. It would be lovely if someone could collate them or if you come across one we could start a tutorials post with links or copies.

Cheers

Spogg


Exactly my point for “the tutorial”, take good stuff and put it in a tutorial like section so it is not scattered through out the blog. There is already a section for that which it appears the admin has posted mostly in it. It was just a thought for added value. You spent a lot of time on this exact method I was asking. I know we are not the only ones. I am thankful for his efforts in writing this up and everyone else which is to many to list to thank for their insight and responses. This is why it would be nice to have an easy thumbs up so the blog is not cluttered with thank you. :)

Tula,
I missed the part about speed, for what I am doing, I need ruby speed as much as I can get for graphics and loops etc. Thanks again. Still playing with your great process and now trying it in code.
User avatar
pshannon
 
Posts: 144
Joined: Fri Jan 02, 2015 3:08 am

Re: ruby setViewSize and module display window

Postby pshannon » Fri Apr 17, 2020 2:12 am

I forgot to upload the simplest form of a dynamic module view. Thanks Tula for describing in such details earlier in this post. My bad causing confusion related to terminology. I am used to window, viewport, scaleview, scanline & canvas. Did I cover most of it?

Ver: 3.0.6 as Tula pointed out.
Attachments
dynamically set the module view size.fsm
(5.32 KiB) Downloaded 951 times
User avatar
pshannon
 
Posts: 144
Joined: Fri Jan 02, 2015 3:08 am

Re: ruby setViewSize and module display window

Postby tulamide » Fri Apr 17, 2020 2:04 pm

I'm not quite sure, why you would want to apply it in edittime, as you can just use your mouse to resize. But the application itself is valid of course. For better readability, I would advise (although not necessary) to call the method with self ("self.setViewSize"), because you call it from within the draw method. With self added it becomes immediately clear that it is a method of RubyEdit, not the view class.

But that's nitpicking, as I admit :lol:

Did you notice, how I simply ignored the minor faults in my longer description a few posts above? But I can't keep it that way: I obviously was wrong that the method belongs to the View class. And you can (I really didn't know it) apparently use setViewSize in 3.0.6 as well. Hrmph. I hate it when such little errors slip in.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Next

Return to General

Who is online

Users browsing this forum: No registered users and 75 guests