Purebasic 5.70 Beta 1x64. Ubuntu 18.04.
qt subsystem.The following shows that when using a #PB_EventType_Resize bound event with a canvas gadget, the underlying bitmap has not been resized prior to the event procedure firing. GadgetWidth() and GadgetHeight() seem correct. We had a similar problem under Windows before PB 5.70 beta 1.
This problem can hide itself within the StartDrawing() bug reported previously since if we are drawing within the resize event procedure, the StartDrawing() can fail if the bitmap still has 0 width, for example, because of this resizing issue; and the StartDrawing() bug then kicks in. Two bugs for the price of one!
Run the code and resize the window.
Code:
Procedure winSize()
ResizeGadget(0, #PB_Ignore, #PB_Ignore, 100, WindowHeight(0)-20)
EndProcedure
Procedure ResizeOne()
If StartDrawing (CanvasOutput(0))
Debug "Drawing output width = " + Str(OutputWidth()) + ", SHOULD BE 100!"
Debug "Canvas gadget width = " + Str(GadgetWidth(0))
Debug "Canvas gadget height = " + Str(GadgetHeight(0))
StopDrawing()
End
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 220, 220, "Canvas example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
CanvasGadget(0, 10, 10, 50, 200)
BindEvent(#PB_Event_SizeWindow, @winSize(), 0)
BindGadgetEvent(0, @ResizeOne(), #PB_EventType_Resize)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf