AlexK17 Posted September 29, 2021 Report Share Posted September 29, 2021 Hi I have the following problem. After creating an object, its coordinates and size can be changed by 1 or 2 points. Why? Part program from gui.c // ghPBChangeSpeed wi.g.show = TRUE; wi.g.x = 32; wi.g.y = 135; wi.g.width = 205; wi.g.height = 120; wi.g.parent = ghPageContainerTermTestPage; wi.text = ""; wi.customDraw = FRNone; wi.customParam = 0; wi.customStyle = 0; ghPBChangeSpeed = gwinButtonCreate(0, &wi); Data from debuger in attached file. Almost all objects undergo coordinate changes. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted September 29, 2021 Report Share Posted September 29, 2021 What's the size of the parent container? It's possible that the window manager is resizing the button widget to fit into the container. The container API provides gwinGetInnerWidth() and gwinGetInnerHeight() to retrieve the inner height & width of the container. Link to comment Share on other sites More sharing options...
AlexK17 Posted September 29, 2021 Author Report Share Posted September 29, 2021 Hi. Thanks for assist. Size parent container is 240x320. See attachment. Best regards. Link to comment Share on other sites More sharing options...
inmarket Posted September 30, 2021 Report Share Posted September 30, 2021 Some adjustments are made by the window manager for things like borders. There is also a difference between inner and outer dimensions. The particular details I can't remember off the top of my head. Have a look through the code to see. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted September 30, 2021 Report Share Posted September 30, 2021 Yes, the window manager will resize a widget to fit into the parent. This is where the inner size (inner width & inner height) come into play. Check the return values of gwinGetInnerWidth() and gwinGetInnerHeight() of the parent container. This will most likely return the values you initially reported. The WM has no other option but to resize the widget to fit those dimensions. If your child needs to have those exact dimensions, either make the parent container larger or implement a container which handles this the way you need it. I think the default built-in container has a border vs. no-border option (check the docs). I think if you disable the border the inner size will not be reduced by the border size. Link to comment Share on other sites More sharing options...
AlexK17 Posted October 1, 2021 Author Report Share Posted October 1, 2021 Hi. In file gwin_container.c i found this #define BORDER_WIDTH 2 and change his value to zero. Coordinate displacement and resizing is not happening, but I'm not sure if I won't have problems in the future. I got problems because I tried to combine the background image in the main container and the buttons to speed up the work. Best regards. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted October 1, 2021 Report Share Posted October 1, 2021 As long as you can avoid modifying library code that's certainly the way to go. Can you share the code of how you create the container? See the section regarding "Border": https://wiki.ugfx.io/index.php/Container#Border Link to comment Share on other sites More sharing options...
AlexK17 Posted October 1, 2021 Author Report Share Posted October 1, 2021 Hi. Code for all container generate by ugfx studio 0.24.1. // Page container wi.g.show = FALSE; wi.g.x = 0; wi.g.y = 0; wi.g.width = 240; wi.g.height = 320; wi.g.parent = 0; wi.text = "Container"; wi.customDraw = background_OtherTestPageBg; wi.customParam = 0; wi.customStyle = &TextWhiteWS; ghPageContainerTermTestPage = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); and 5 more similar containers as project pages. If i redefine GWIN_CONTAINER_BORDER to zero in giu.c Coordinate and size still is good. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now