PureBasic Forum
https://www.purebasic.fr/english/

SplitterGadget
https://www.purebasic.fr/english/viewtopic.php?f=24&t=72654
Page 1 of 1

Author:  wombats [ Tue Apr 16, 2019 10:43 am ]
Post subject:  SplitterGadget

I'm not entirely sure this is a bug, but it doesn't happen on Windows.

When you resize the leftmost splitter, the containers on the very right fire events, despite them not actually changing size. This causes a lot of slowdown in my application.
Code:
Enumeration
  #RightTopContainer
  #RightBottomContainer
  #RightSplitter
  #LeftTopContainer
  #LeftBottomContainer
  #LeftSplitter
  #Container
  #MiddleSplitter
  #MainSplitter
EndEnumeration

Global NewList containers.i()
AddElement(containers()) : containers() = #Container
AddElement(containers()) : containers() = #LeftTopContainer
AddElement(containers()) : containers() = #LeftBottomContainer
AddElement(containers()) : containers() = #RightTopContainer
AddElement(containers()) : containers() = #RightBottomContainer

Procedure OnContainerResized()
  ForEach containers()
    If EventGadget() = containers()
      SetGadgetColor(containers(), #PB_Gadget_BackColor, RGB(255, 0, 0))
    Else
      SetGadgetColor(containers(), #PB_Gadget_BackColor, RGB(0, 0, 0))
    EndIf
  Next
EndProcedure

Procedure OnWindowSized()
  ResizeGadget(#MainSplitter, 0, 0, WindowWidth(0), WindowHeight(0))
EndProcedure

OpenWindow(0, 0, 0, 640, 480, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)

BindEvent(#PB_Event_SizeWindow, @OnWindowSized(), 0)

ContainerGadget(#RightTopContainer, 0, 0, 0, 0, #PB_Container_Single) : CloseGadgetList()
ContainerGadget(#RightBottomContainer, 0, 0, 0, 0, #PB_Container_Single) : CloseGadgetList()
SplitterGadget(#RightSplitter, 0, 0, 100, 100, #RightTopContainer, #RightBottomContainer)

ContainerGadget(#LeftTopContainer, 0, 0, 0, 0, #PB_Container_Single) : CloseGadgetList()
ContainerGadget(#LeftBottomContainer, 0, 0, 0, 0, #PB_Container_Single) : CloseGadgetList()
SplitterGadget(#LeftSplitter, 0, 0, 100, 100, #LeftTopContainer, #LeftBottomContainer)

ContainerGadget(#Container, 0, 0, 100, 100, #PB_Container_Single) : CloseGadgetList()

SplitterGadget(#MiddleSplitter, 0, 0, 640, 480, #Container, #RightSplitter, #PB_Splitter_Vertical | #PB_Splitter_SecondFixed)

SplitterGadget(#MainSplitter, 0, 0, 640, 480, #LeftSplitter, #MiddleSplitter, #PB_Splitter_Vertical)

SetGadgetState(#MiddleSplitter, 100)
SetGadgetState(#LeftSplitter, 100)

BindGadgetEvent(#RightTopContainer, @OnContainerResized(), #PB_EventType_Resize)
BindGadgetEvent(#RightBottomContainer, @OnContainerResized(), #PB_EventType_Resize)
BindGadgetEvent(#LeftTopContainer, @OnContainerResized(), #PB_EventType_Resize)
BindGadgetEvent(#LeftBottomContainer, @OnContainerResized(), #PB_EventType_Resize)
BindGadgetEvent(#Container, @OnContainerResized(), #PB_EventType_Resize)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Author:  Fred [ Tue Apr 16, 2019 2:04 pm ]
Post subject:  Re: SplitterGadget

Is this a regression ?

Author:  wombats [ Tue Apr 16, 2019 3:04 pm ]
Post subject:  Re: SplitterGadget

No, it was the same in 5.70. I just gave up on trying to solve it, haha.

Author:  Fred [ Tue Apr 16, 2019 3:44 pm ]
Post subject:  Re: SplitterGadget

Nice, because I changed some code in splitter so I wondered !

Author:  wombats [ Sat Oct 05, 2019 10:28 pm ]
Post subject:  Re: SplitterGadget

Were you ever able to take a look at this, Fred? It is causing a lot of slowdown when using the splitter, which looks unprofessional. I don't think the #RightTopContainer and #RightBottomContainer gadgets should be firing events when the left-hand splitter is moved.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/