Page 1 of 2
Counting pixels ??
Posted: Thu Oct 23, 2025 1:44 am
by RogerTunnicliffe
This code places 5 buttons inside a container that has a height of 28px
The buttons have a height of 26px and are located 1 pixel down from the top of the container
and yet...
they overlap the container at the bottom unless I make the container 30px deep.
What am I doing wrong ?
Code: Select all
FullGadgetHeight = WindowHeight(Window_0) - MenuHeight() - 2
Container_ExplorerButtons = ContainerGadget(#PB_Any, 1, FullGadgetHeight-28, 300, 28, #PB_Container_BorderLess)
B_Edit = ButtonGadget(#B_Edit, 4, 1, 50, 26, "F4-Edit")
B_Copy = ButtonGadget(#B_Copy, 56, 1, 50, 26, "F5-Copy")
B_Move = ButtonGadget(#B_Move, 108, 1, 50, 26, "F6-Move")
B_MkDir = ButtonGadget(#B_MkDir, 160, 1, 50, 26, "F7-Mkdir")
B_Delete = ButtonGadget(#B_Delete, 213, 1, 50, 26, "F8-Delete")
CloseGadgetList()
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 2:46 am
by Olli
You select the source code line containing the container.
You delete the line.
And you write here your opinion, after this update.
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 3:31 am
by RogerTunnicliffe
Not sure what you expect here.
I delete this line : - Container_ExplorerButtons = ContainerGadget(#PB_Any, 1, FullGadgetHeight-28, 300, 28, #PB_Container_BorderLess)
and all the buttons move to the top of the screen (1 px down) the container disappears leaving no way to tell if it has overflowed past the container ??
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 3:49 am
by kenmo
First, what PB version and especially what OS?
Second, please always post runnable example code, so anyone reading can quickly confirm and diagnose your issue.
Both of these will help you get better, faster answers from more people...
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 3:51 am
by RogerTunnicliffe
The latest version (6.21)
Debian 11
and... You want me to post 300 lines of code ? (Happy to do it if that is what you want)
Here's another example
Editor_2 = EditorGadget(#PB_Any, 1, FullGadgetHeight-27, 592, 2)
although the editor height is 2px it overflows thru the bottom of the Form ?
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 4:04 am
by kenmo
300 lines of code, no. Just enough to make it compile and run.
It only takes you a minute to edit it once, rather than expecting everyone reading to edit the example code to test it.
It's just friendly advice. More people will help if they can directly paste and test!
On PB 6.21 and Ubuntu-based Linux, I do see the bottom overlap
But in my case, it seems to be because the Container has a visual border, despite the #PB_Container_BorderLess flag
If you see a border too, perhaps that's the real bug?
Code: Select all
OpenWindow(0, 0, 0, 640, 240, "Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
FullGadgetHeight = WindowHeight(0) - 2
Container = ContainerGadget(#PB_Any, 1, FullGadgetHeight-28, 300, 28, #PB_Container_BorderLess)
B_Edit = ButtonGadget(#PB_Any, 4, 1, 50, 26, "F4-Edit")
B_Copy = ButtonGadget(#PB_Any, 56, 1, 50, 26, "F5-Copy")
B_Move = ButtonGadget(#PB_Any, 108, 1, 50, 26, "F6-Move")
B_MkDir = ButtonGadget(#PB_Any, 160, 1, 50, 26, "F7-Mkdir")
B_Delete = ButtonGadget(#PB_Any, 213, 1, 50, 26, "F8-Delete")
Debug "Requested height 28"
Debug "Got height " + Str(GadgetHeight(Container))
Debug ""
Debug "Requested height 26"
Debug "Got height " + Str(GadgetHeight(B_Delete))
CloseGadgetList()
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 4:09 am
by RogerTunnicliffe
Thanks for that quick response.
I think your example shows exactly what I am talking about.
and yes... "#PB_Container_BorderLess" and yet we have a border
To further complicate things....
I ask for Editor_2 to have a height of 2px, it reports it as 2 pixels but it's certainly a lot bigger than that ??
Code: Select all
OpenWindow(0, 0, 0, 640, 240, "Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
FullGadgetHeight = WindowHeight(0) - 2
Editor_2 = EditorGadget(#PB_Any, 4, FullGadgetHeight-100, 300, 2)
Container = ContainerGadget(#PB_Any, 1, FullGadgetHeight-28, 300, 28, #PB_Container_BorderLess)
B_Edit = ButtonGadget(#PB_Any, 4, 1, 50, 26, "F4-Edit")
B_Copy = ButtonGadget(#PB_Any, 56, 1, 50, 26, "F5-Copy")
B_Move = ButtonGadget(#PB_Any, 108, 1, 50, 26, "F6-Move")
B_MkDir = ButtonGadget(#PB_Any, 160, 1, 50, 26, "F7-Mkdir")
B_Delete = ButtonGadget(#PB_Any, 213, 1, 50, 26, "F8-Delete")
Debug "Requested height 28"
Debug "Got height " + Str(GadgetHeight(Container))
Debug ""
Debug "Requested height 26"
Debug "Got height " + Str(GadgetHeight(B_Delete))
Debug ""
Debug "Requested height 2"
Debug "Got height " + Str(GadgetHeight(Editor_2))
CloseGadgetList()
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 5:27 am
by TI-994A
Works as expected on PureBasic v6.21 running on MacOS and Windows 11.
It does not display the border, there's no overlap, and even the gadget height of 2 renders correctly.

Re: Counting pixels ??
Posted: Thu Oct 23, 2025 6:29 am
by RogerTunnicliffe
and..... How does that help me ?
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 6:58 am
by infratec
It helps, that the users know that the bug exists only in linux
And your fault diagnostig in the first post is wrong.
The problem is that the container is showing a border.
So you can place a bug report in the linux section.
You can try a CanvasGadget() with #PB_Canvas_Container set.
Maybe this solves your current problem.
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 7:16 am
by infratec
To avoid the white background of the CanvasGadget():
Code: Select all
OpenWindow(0, 0, 0, 640, 240, "Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
FullGadgetHeight = WindowHeight(0) - 2
If StartDrawing(WindowOutput(0))
Color = Point(0, 0)
StopDrawing()
EndIf
Container = CanvasGadget(#PB_Any, 1, FullGadgetHeight-28, 300, 28, #PB_Canvas_Container)
If StartDrawing(CanvasOutput(Container))
Box(0, 0, 300, 200, Color)
StopDrawing()
EndIf
B_Edit = ButtonGadget(#PB_Any, 4, 1, 50, 26, "F4-Edit")
B_Copy = ButtonGadget(#PB_Any, 56, 1, 50, 26, "F5-Copy")
B_Move = ButtonGadget(#PB_Any, 108, 1, 50, 26, "F6-Move")
B_MkDir = ButtonGadget(#PB_Any, 160, 1, 50, 26, "F7-Mkdir")
B_Delete = ButtonGadget(#PB_Any, 213, 1, 50, 26, "F8-Delete")
Debug "Requested height 28"
Debug "Got height " + Str(GadgetHeight(Container))
Debug ""
Debug "Requested height 26"
Debug "Got height " + Str(GadgetHeight(B_Delete))
CloseGadgetList()
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 8:28 am
by RogerTunnicliffe
Ok, so that does work...but does that mean that everywhere the UI is messed up I have to code that work-around.
also ... How do I have the colors in my editor gadget
Code: Select all
OpenWindow(0, 0, 0, 640, 240, "Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
If StartDrawing(WindowOutput(0))
Color = Point(0, 0)
StopDrawing()
EndIf
FullGadgetHeight = WindowHeight(0) - 2
Container_Editor2 = CanvasGadget(#PB_Any, 1, FullGadgetHeight-26, 592, 23, #PB_Canvas_Container)
If StartDrawing(CanvasOutput(Container_Editor2))
Box(1, FullGadgetHeight-26, 592, 23)
StopDrawing()
EndIf
Editor_2 = EditorGadget(#PB_Any, 1, FullGadgetHeight-26, 592, 23)
SetGadgetColor(Editor_2, #PB_Gadget_BackColor, #Black) <------ This no longer works
SetGadgetColor(Editor_2, #PB_Gadget_FrontColor, #White) <------ This no longer works
CloseGadgetList()
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 8:34 am
by mk-soft
There are minimum sizes for Linux gadgets ...
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 8:37 am
by infratec
Your EditorGadget coordinates are far away from visible, so you can not see and do anything.
The Gadget is inside of the container, which is 23 pixel high, but you place the Editor Gadget at WindowHeight() - 28
Re: Counting pixels ??
Posted: Thu Oct 23, 2025 9:23 am
by TI-994A
Here's a working POC of your code,
implementing a string gadget to circumvent Linux's larger minimum height for the editor gadget.
Code: Select all
OpenWindow(0, 0, 0, 640, 500, "Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
container_width = 514
container_height = 52
If StartDrawing(WindowOutput(0))
match_window_colour = Point(10, 10)
StopDrawing()
EndIf
Container = CanvasGadget(#PB_Any, 1, WindowHeight(0) - 52, container_width, container_height, #PB_Canvas_Container)
If StartDrawing(CanvasOutput(Container))
Box(0, 0, container_width, container_height, match_window_colour)
StopDrawing()
EndIf
Editor_2 = StringGadget(#PB_Any, 1, 1, 512, 23, "")
SetGadgetColor(Editor_2, #PB_Gadget_BackColor, #Black)
SetGadgetColor(Editor_2, #PB_Gadget_FrontColor, #White)
B_Edit = ButtonGadget(#PB_Any, 4, 25, 100, 26, "F4-Edit")
B_Copy = ButtonGadget(#PB_Any, 106, 25, 100, 26, "F5-Copy")
B_Move = ButtonGadget(#PB_Any, 208, 25, 100, 26, "F6-Move")
B_MkDir = ButtonGadget(#PB_Any, 310, 25, 100, 26, "F7-Mkdir")
B_Delete = ButtonGadget(#PB_Any, 412, 25, 100, 26, "F8-Delete")
CloseGadgetList()
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Alternatively, if you don't need these gadgets to be in a container,
simply render them directly onto the window itself:
Code: Select all
OpenWindow(0, 0, 0, 640, 500, "Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
editor_y = WindowHeight(0) - 52
button_y = WindowHeight(0) - 28
Editor_2 = StringGadget(#PB_Any, 1, editor_y, 512, 23, "")
SetGadgetColor(Editor_2, #PB_Gadget_BackColor, #Black)
SetGadgetColor(Editor_2, #PB_Gadget_FrontColor, #White)
B_Edit = ButtonGadget(#PB_Any, 4, button_y, 100, 26, "F4-Edit")
B_Copy = ButtonGadget(#PB_Any, 106, button_y, 100, 26, "F5-Copy")
B_Move = ButtonGadget(#PB_Any, 208, button_y, 100, 26, "F6-Move")
B_MkDir = ButtonGadget(#PB_Any, 310, button_y, 100, 26, "F7-Mkdir")
B_Delete = ButtonGadget(#PB_Any, 412, button_y, 100, 26, "F8-Delete")
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
I hope it helps.