CanvasGadget Container in a splitter

Mac OSX specific forum
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

CanvasGadget Container in a splitter

Post by DoubleDutch »

There are two bugs that occur on OSX with a CanvasGadget that has the #PB_Canvas_Container flag when the Canvas is in a Splitter.

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
First click in the Canvas - you will see that although the button gadget has been programmed to be at the same position as the cursor, instead it's offset is wrong (slightly shifted down & right). When it's not in a splitter it is correct (at the same position as the cursor).

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
As mentioned, everything works perfectly in Windows, this just seems to affect OSX (not tested on Linux).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: CanvasGadget Container in a splitter

Post by DoubleDutch »

If I surround the canvas with a container then the offset problem seems to go away, this might be a clue as to what is happening?If

Code: Select all

OpenWindow(0, 0, 0, 520, 220, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	
	ContainerGadget(4,0,0,200,300) ; *** add this to fix the offset issue?
    CanvasGadget(0, 0, 0, 200, 200, #PB_Canvas_Container)
    ButtonGadget(1, 0, 0, 80, 30, "Clean up")

    CloseGadgetList()
  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,4,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

          Case 4
          	If EventType()=#PB_EventType_Resize
;          		ResizeGadget(0,#PB_Ignore,#PB_Ignore,GadgetWidth(4),GadgetHeight(4)) ; *** offset issue comes back if you resize the canvas!  Uncomment this to see...
          	EndIf
        EndSelect
      EndIf
    
    Until Event = #PB_Event_CloseWindow
  EndIf
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: CanvasGadget Container in a splitter

Post by DoubleDutch »

In the last example, with the resize line uncommented (so it will do the resize), change these lines from: ContainerGadget(4,0,0,200,300)

Code: Select all

ContainerGadget(4,0,0,200,300)
    CanvasGadget(0, 0, 0, 200, 200, #PB_Canvas_Container)
    ButtonGadget(1, 0, 0, 80, 30, "Clean up")

    CloseGadgetList()
CloseGadgetList()
to

Code: Select all

ContainerGadget(4,0,0,200,300)
    CanvasGadget(0, 0, 0, 200, 300, #PB_Canvas_Container)
    ButtonGadget(1, 0, 0, 80, 30, "Clean up")

    CloseGadgetList()
  CloseGadgetList()
For a negative offset on the gadgets!
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: CanvasGadget Container in a splitter

Post by Fred »

I don't see the issues here, can anybody else confirm ?
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: CanvasGadget Container in a splitter

Post by DoubleDutch »

Can you not see it?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: CanvasGadget Container in a splitter

Post by mk-soft »

The mouse position from canvas gadget not right

Code: Select all

                x = GetGadgetAttribute(0, #PB_Canvas_MouseX) - 2 ; Offset correction
                y = GetGadgetAttribute(0, #PB_Canvas_MouseY) - 2 ; Offset correction
                Debug x
                
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: CanvasGadget Container in a splitter

Post by DoubleDutch »

Is this my fault or pb ?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: CanvasGadget Container in a splitter

Post by Fred »

It seems right here (i can use the whole canvas)
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: CanvasGadget Container in a splitter

Post by DoubleDutch »

Maybe it depends on the OS version? I was using the latest OSX, also mk-soft appears to notice the problem too.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: CanvasGadget Container in a splitter

Post by mk-soft »

I thing MacOS...

Same problem with DesktopMouseXY.

The actual mouse position is the blank mouse cursor without the white border.

Hardware: Mac-Mini Late 2012 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
Monitor: Benq GL2460
MacOS: 10.12.6
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: CanvasGadget Container in a splitter

Post by Fred »

I don't want to offset the cursor as it's the black arrow which count, not the white border and i you set another cursor it will be wrong. The button is offseted becaus it gots transparent borders. Try with a ListViewGadget() and it will be right.
Post Reply