ImpulseAdventure / GUIslice-Builder

Cross-platform drag & drop GUI builder for GUIslice
Other
163 stars 34 forks source link

Request: Project Screen Size change with change of all existed elements size. #192

Closed nadjet09 closed 2 years ago

nadjet09 commented 2 years ago

Describe the solution you'd like It would be so helpful to be able to change the screen size and all lines, boxes, text, images, or any existed element in the project would shrink to the same ratio of the new display.

Additional context after getting so deep in creating a GuiSlice project with hundreds of elements it become nightmare to go and change every element to the new size (for example I went from 320x240 to 480x320 and I did the changes manually before, now I need another project from 480x320 to 320x240), while it would be done by mathematical equation and scan of of all element to set to new height/width and X/Y position.

Pconti31 commented 2 years ago

@nadjet09 Fonts seem complicated since they are not scaled and not all sizes exist. You might have to select new font(s) mappings yourself inside a dialog that takes the new screen size.

So what mathematical equation are you thinking of?

Paul--

nadjet09 commented 2 years ago

that's ok if end up just manually changing the fonts size, font may only be moved to the new X/Y position and manually change the font size.

I'm not a java coder, but I was thinking of: ratio = new_screen_resolutions/ old_screen_resolution; or maybe: ratio_X = new_TFT_width/ old_TFT_Width; ratio_Y = new_TFT_Height/ old_TFT_Height; single_time_Scan_fun(elem) { elem.height = elem.height ratio_Y; elem.width = elem.width ratio_X; elem.x = elem.x ratio_X; elem.y = elem.y ratio_Y; etc...with some adjustment offset when ratio roundup or roundDown decimal value. } that function might be a one time scan of all existed elements x/y height/width and update with the new ration values, right after confirming the new resolutions. it could be a mapping function maybe where it will scan all

Pconti31 commented 2 years ago

@nadjet09 Ok, sounds good. I'll see what i can do. Paul--

Pconti31 commented 2 years ago

@nadjet09 Fixed in Release 0.17.b07. Not much testing done so let me know if any problems occur. You need to first go to the Project options, change display size and then select the Page Layout tab->Scale answer questions of the previous screen size and select OK.

WARNING! If shrinking screen size do not leave Project Options with the new display height and width without first going to Page Layout and choosing the new Scale command or you may crash and burn due to existing elements being placed beyond screen limits. I tried to trap these cases but as I said very little testing.

I'll close this if you notify me of things working or if a few days go by without any feedback. Paul--

nadjet09 commented 2 years ago

it keep crashing for me, I included a short clip showing what I did in the following link. https://www.youtube.com/watch?v=TzwbClV-aJs

these are the logs builder.log 20220215_143008.txt 20220215_143007.txt

nadjet09 commented 2 years ago

I tried again and it seemed working with some pages. in this clip I showed E_PG_Pup2 as a popup page and E_PG_Main as a page before changes, and after I did the changes the E_PG_Pup2 was resized, but when I clicked on the E_PG_Main tab, the GUISlice crashed. could that be related to the page type or too many elements in one page cause the issue? https://youtu.be/pAYSJq_VVbA

Pconti31 commented 2 years ago

@nadjet09 The first set of crashes are being caused by a Line Element on your page. No idea why.

Any chance you could post a zip of your project folder and .prj so I can try and debug the .prj file? I don't need to deal with any output files.

Are you growing or shrinking your display?

Paul--

nadjet09 commented 2 years ago

I'm shrinking the display now from 320x480 to 240x320

Pconti31 commented 2 years ago

@nadjet09 Ok, I see the problem. It's with the Line Element model. It is broken. Only showed up because of the scaling. Basically I rip through all elements and call base functions in the superclass Widget Model to change x,y,height and width. Problem is that Line Element model starts on duplicate subscripts for length of line with Y, is Vertical with width, and Fill color with Height. So when setting those values at the superclass I was wiping those values out. Ugh! I need to cut back on my drinking! I need to work out a way to upgrade existing Line Elements. I'll post a update 0.17.b08 tomorrow sometime. Paul--

nadjet09 commented 2 years ago

that sounds great, I had a look at the source code yesterday and I can slightly relate to what you described, but it still looks too deep for me to jump in and do some work in it.

Pconti31 commented 2 years ago

@nadjet09 Ok, I think things are working correctly now. I was able to provide scaling for fonts although manual changes may still be needed. The Builtin (GLCD) fonts are ignored and if no font can be found that comes close to the proper scaling ratio I just leave it alone. Let me know if it works better for you now and I'll close this issue. If you like the way it works don't forget to add a star to the repository. People tend to forget my project is different from the API. Paul--

nadjet09 commented 2 years ago

Hi @Pconti31, It's performing better now, I didn't have crashes. but there is some height scaling issue. I noticed the width changes according to scale but the height still bit out of the frame. some text in the bottom when they still out of the frame, their height convert to over 600pixel. in this clip I tried to demonstrate what I described. https://youtu.be/9MNgYy7DxSI thank you so much for all the effort

nadjet09 commented 2 years ago

Well According to what I noticed here, is the ratio of width 240/320 = 0.75 and 320/480 = 0.66667, so those ratio looks good for the width/height change but the x/y are both calculated based on 0.75

nadjet09 commented 2 years ago

I don't know if you saw my prev. comments but just wanted mention this if it could help at Pagepane.java line 1182 I saw this ratioX used for both X/Y newX = (int)(((double)m.getX() ratioX) + 0.5); newY = (int)(((double)m.getY() ratioX) + 0.5);

Pconti31 commented 2 years ago

@nadjet09 Yes, that would do it. Third time is the charm! 0.17.b09 coming up.

Pconti31 commented 2 years ago

@nadjet09 Release 0.17.b09 is ready. Hopefully this is it.

nadjet09 commented 2 years ago

It worked for me, thank you so much

Pconti31 commented 2 years ago

No problem. I'm happy it now working for you.