First, the offset of the gadgets added to the Canvas is incorrect.
Second, the gadgets are clipped to the original size of the canvas (after it has been automatically resized by the splitter)
Neither of these two bugs occurs in Windows.
Here is some source code to demonstrate:
Code: Select all
If OpenWindow(0, 0, 0, 520, 220, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, 200, 200, #PB_Canvas_Container)
ButtonGadget(1, 10, 10, 80, 30, "Clean up")
CloseGadgetList()
ButtonGadget(2,0,0,0,0,"other gadget") ; *** these two lines have been added to the standard demo to put the canvas inside a splitter
SplitterGadget(3,0,0,520,220,0,2,#PB_Splitter_Vertical)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
ResizeGadget(1,x,y,#PB_Ignore,#PB_Ignore) ; *** this line has been added to show that the offset of the gadget is incorrect if inside a splitter
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
Case 1
If StartDrawing(CanvasOutput(0))
Box(0, 0, 200, 200, #White)
StopDrawing()
EndIf
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Now draw and you should see the button moves with the cursor, draw to the right and you should see that although the canvas is extended because of the splitter, the button image is clipped to the original 'creation' size of the canvas.
In fact the canvas gadgets are clipped to the original size even if you use ResizeGadget, see:
Code: Select all
If OpenWindow(0, 0, 0, 520, 220, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, 200, 200, #PB_Canvas_Container)
ButtonGadget(1, 10, 10, 80, 30, "Clean up")
CloseGadgetList()
ResizeGadget(0,#PB_Ignore,#PB_Ignore,500,#PB_Ignore) ; the canvas' gadgets will be clipped on a resize
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
ResizeGadget(1,x,y,#PB_Ignore,#PB_Ignore) ; *** this line has been added to show that the offset of the gadget is incorrect if inside a splitter
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
Case 1
If StartDrawing(CanvasOutput(0))
Box(0, 0, 200, 200, #White)
StopDrawing()
EndIf
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf