MaxGUI Scaling gadgets/windows

BlitzMax Forums/MaxGUI Module/MaxGUI Scaling gadgets/windows

degac(Posted 2015) [#1]
Hi

I have a little 'problem'.
I've created some applications with fixed windows sizes (ie: 400x300).
On my old screen (1024x768) everything is ok.
Some of my colleagues have changed their monitor to something bigger (19" -- 22") and they now works in higher resolution (1920x1080!)

When they run my apps, they see 'small' gadgets/textfields and so on.
I've rewritten some of these apps to allow windows resizing, but some of them have many gadgets/fields to manually change.

I've added a lot of SetGadgetLayout, I've used SetGadgetFont to change the font size of gadgets, and I think I've resolved the problem.

Of course I dont' like the idea to re-write code just to fit my app to run in a different resolution.

Anyone know a possible solution that allows automatic 'scaling' in MaxGUI?


cps(Posted 2015) [#2]
Temp1=DesktopWidth()
If Temp1=640 then screensize%=1
If Temp1=800 then screensize%=2 etc
Use var screensize% to adjust x,y,width,height,font of gadget
Is the only solution that I've found, but it maybe what you are trying to avoid
Have fun cps


xlsior(Posted 2015) [#3]
If you are going to rewrite things: Be aware that even 1920x1080 is old hat by now, 4K monitors are gaining pupularity -- meaning desktop resolutions of 3840x2160 or thereabouts.

Just keep that in mind or a newly rewritten 1920x1080 version will still look puny on some new PCs.


degac(Posted 2015) [#4]
@CPS

Well, I've already done some tests about Desktop resolution checking, this is not the problem: I can find a 'correction ratio' for W/H for window and gadgets (and font size) and apply to them.
To be honest I'm not very satisfied with the results at the moment, but it seems to works.
It involves some calling to SetGadgetShape, BUT I've discovered that it needs SetGadgetLayout to keep 'things' in order.

This is a small example I've tested.
Of course I can determine the 'scale factor' comparing the area and dimensions of my app's window to a default desktop screen (in my case 1024x768).
In this example I've skipped this.



I'm still looking a way to find the 'default' GUI font size to apply the correction to it. Of course any gadget can have different font and different size... and I'm quite sure that there is not a such command to retrieve the font used in a gadget (something like GetGadgetFont(gadget)).


What I'm looking, is something automatic and reliable (if it exists of course! I'm quite sure I havent' found an 'elastic' GUI)

@xlsior: well, I think I will have a 4K monitor in about 10 years! considering that the monitors had changed ONLY after 12 years! Probably GUI will be anachronistic in 10 years! :P


Henri(Posted 2015) [#5]
Hi degac,

I'm quite sure that there is not a such command to retrieve the font used in a gadget
No there isn't , but could be easily added. GadgetFont would be in par with GadgetText and other 'getters'.

-Henri


Brucey(Posted 2015) [#6]
What I'm looking, is something automatic and reliable (if it exists of course! I'm quite sure I havent' found an 'elastic' GUI)

Which is why I prefer frameworks like wxWidgets, because they come with flexible, self-adjusting layout engines.

Of course, you can always write your own! That's what makes programming so much fun ;-)


degac(Posted 2015) [#7]
So wxWidgets are 'auto scaling'? Interesting... but I dont' like the idea to redesign all the apps :/!

I will try to find a solution! (I agree, it is fun!)


Henri(Posted 2015) [#8]
wxWidget has sizers which control the layout and 'gadgets' can grow to utilize empty space according to predefined rules, but fontsize is fixed as far as I know.

In theory you could make a function to go though every gadget after they have been created (but still hidden) and use SetGadgetShape to scale them with fixed ratio depending on desktop height like:
Local ratio:Float = 1.2

SetGadgetShape( <gadget>, GadgetX(<gadget>), GadgetY(<gadget>), Int( GadgetWidth(<gadget>) * ratio), Int( GadgetHeight(<gadget>) * ratio) )

-Henri


cps(Posted 2015) [#9]
Maybe late but this might help ( It's not my work, found it in the forum )
but only for windows based progs.

Local DefaultFontName$ = "Arial"
Local DefaultFontSize:Float = 9.12
TWindowsGUIDriver(maxgui_driver).GDIFont= TWindowsFont(LoadGuiFont(DefaultFontName,DefaultFontSize))

Other thought is have you tried fixed width fonts ( monofonts ) there are two that come with windows ones 'Courier new' the other I've forgotten.

Other than that look at the TK or FX methods (ruby, python etc) that use grids and define gadget size by number of letters. I'm still sticking to forcing a user to pick a screen size and preventing resizing. Have fun Cps


Henri(Posted 2015) [#10]
Hi cps,

nice find there.

-Henri


degac(Posted 2015) [#11]
thanks Cps!
I'm still experimenting some different solutions - nothing I'm really satisfied with at the moment.
The 'problem' is the alignment of gadgets: every time I 'rescale' (with SetGadgetShape) the gadgets their position is 'recalculated' considering the GadgetLayout assigned. I'm looking to bypass this behaviour.
I mean: a gadget at 10,10 and 100,30 of sizes, with a 2x multiplicator, should be at 20,20 and 200,60 (for example): at the moment its position is changed...

Well, in any case I hacked MaxGUI to manage 'default behaviours'.
When you set SetColor (in gfx mode) the 'color' is the same for all the following operations.
I did something similar for MaxGUI: foregroundcolor,backcolor, alignment etc.
Not really what I'm looking for initially, but a nice collateral effect I think!


cps(Posted 2015) [#12]
I see the problem with the Blitz window resize repositioning objects in the window but not resizing them. Solution seems to be to store object data before window resize then apply resize translation to objects. This may be a repeat of what you have allready done but thats what the code below does. I'd add a font resizer but don't know if you use one size throughout or multiple sizes. ie change default or each object font size.

This is a version without font resizing, have fun Cps


cps(Posted 2015) [#13]
Oops my mistake not use to the forum codes, should have used the preview button. You live and learn. Hope the code is useful.


degac(Posted 2015) [#14]
Hi CPS

interesting solution.

In my case I decided to keep a 'default-screen-size' and based on this, scaling everything in the 'right' way automatically. So if I run the application on a 1980x1024 desktop, the window should keep the same ratio and rescale it (and its content) to the same ration as the default one (in my case 640x480 for example).
I'm experimenting adding a WINDOW_AUTOSCALE const parameter and hacking here and there MaxGUI :P

But I like your idea to 'scale' manually everything, based on the user choice. I should consider to implement some sort of command, like SetGadgetScale(window,scale#).

Another thing to put in my to-do list (I hope to have time this weekend to complete it!)

Thank you again.


cps(Posted 2015) [#15]
This is the same as previous but with a cheap and cheerful font resizer included.Have fun Cps



degac(Posted 2015) [#16]
At the end I decided to don't hack MaxGUI to support 'automatic' scaling.
Too much mess around! :D

So I followed the CPS's idea to 'save' the gadgets info (with a command SaveGadgets(window) and then call SetWindowScale(window,scale_factor) when needed.

I still would like an automatic way to do things... but not now!


cps(Posted 2015) [#17]
I've altered the code to provide a resize without changing font size and one with a simple font resizer. Please post if you ever get time to develop an automatic version. Have fun Cps.


degac(Posted 2015) [#18]
Hi

I've implemented something similar about gadget font resize (in my case I specify the scale_factor).
The only thing I still haven't found a proper solution is how to retrieve the default/current font size... I need to investigate more.

The 'automatic' version is still in my to-do list, if and when I have time I will try to implement it in MaxGUI.

Cheers