[Implemented] Canvas background color
Posted: Sun Aug 13, 2017 6:55 pm
It would be handy if we could choose the initial background color, possibly avoiding to draw it twice.
http://www.purebasic.com
https://www.purebasic.fr/english/
I also noticed the redrawing when resizing. But four years have passed..IdeasVacuum wrote:+1 It would make a difference
http://www.purebasic.fr/english/viewtop ... =3&t=54195
Code: Select all
Procedure ResizeAll()
ActWinWidth = WindowWidth(0)
ActWinHeight = WindowHeight(0)
ResizeGadget(0,#PB_Ignore, #PB_Ignore, ActWinWidth - 10, ActWinHeight - 10)
; Redraw Canvas Gadget
If StartDrawing(CanvasOutput(0))
Box(0,0,ActWinWidth - 10, ActWinHeight - 10, $080808)
Ellipse(ActWinWidth / 2 - 5, ActWinHeight / 2 - 5, ActWinWidth / 2 - 20, ActWinHeight / 2 - 20, $ff8888)
StopDrawing()
EndIf
EndProcedure
OpenWindow(0,0,0,600,400,"Resize me ...",#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
SetWindowColor(0, $080808)
CanvasGadget(0,5,5,5,5)
ResizeAll()
BindEvent(#PB_Event_SizeWindow, @ResizeAll())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Hmmm, I can't see any white BG, even if I resize as quick as I can.Justin wrote:It is not exactly a flickering, but if i make the window big and resize it quickly i cleary see the white background on the resized edge.
Code: Select all
XIncludeFile "Module_DeFlicker.pbi" ; Available here: http://www.purebasic.fr/english/viewtopic.php?f=12&t=65364&hilit=deflicker
Procedure ResizeAll()
ActWinWidth = WindowWidth(0)
ActWinHeight = WindowHeight(0)
DeFlicker::StartResize(0) ; <--------------------------------
ResizeGadget(0,#PB_Ignore, #PB_Ignore, ActWinWidth - 10, ActWinHeight - 10)
; Redraw Canvas Gadget
If StartDrawing(CanvasOutput(0))
Box(0,0,ActWinWidth - 10, ActWinHeight - 10, $080808)
Ellipse(ActWinWidth / 2 - 5, ActWinHeight / 2 - 5, ActWinWidth / 2 - 20, ActWinHeight / 2 - 20, $ff8888)
StopDrawing()
EndIf
DeFlicker::EndResize() ; <--------------------------------
EndProcedure
OpenWindow(0,0,0,600,400,"Resize me ...",#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
SetWindowColor(0, $080808)
CanvasGadget(0,5,5,5,5)
ResizeAll()
BindEvent(#PB_Event_SizeWindow, @ResizeAll())
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Code: Select all
SetWindowLongPtr_(WindowID(#MyWindow), #GWL_EXSTYLE, #WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(#MyWindow), RGB(124, 109, 146), #Null, #LWA_COLORKEY)
Code: Select all
Procedure ResizeAll()
If StartDrawing (CanvasOutput (1))
Box(0, 0, GadgetWidth (1), GadgetHeight (1), #Red)
StopDrawing()
EndIf
If StartDrawing (CanvasOutput (2))
Box(0, 0, GadgetWidth (2), GadgetHeight (2), #Green)
StopDrawing()
EndIf
EndProcedure
OpenWindow (0, 0, 0, 300, 600, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget (1, 0, 0, 0, 0)
CanvasGadget (2, 0, 0, 0, 0)
SplitterGadget (0, 1, 1, 298, 598, 1, 2)
ResizeAll()
BindGadgetEvent (1, @ResizeAll())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow