[Implemented] Canvas background color
[Implemented] Canvas background color
It would be handy if we could choose the initial background color, possibly avoiding to draw it twice.
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Canvas background color
+1 It would make a difference
http://www.purebasic.fr/english/viewtop ... =3&t=54195
http://www.purebasic.fr/english/viewtop ... =3&t=54195
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Canvas background color
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
Re: Canvas background color
I understand why you ask for this feature, and I've tried to write a little Program to see the flicker-effect.
But .. I can not see any flicker in my example.
Is it, because I do something wrong?
Or is it, because I've done the resizing and redrawing right and maybe you've done something wrong?
Or maybe my PC is just to fast to see any flickering?
Here is my test-code:
Can you see any flickering?
But .. I can not see any flicker in my example.
Is it, because I do something wrong?
Or is it, because I've done the resizing and redrawing right and maybe you've done something wrong?
Or maybe my PC is just to fast to see any flickering?
Here is my test-code:
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
Last edited by PureLust on Sun Aug 13, 2017 11:50 pm, edited 2 times in total.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Re: Canvas background color
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.
Re: Canvas background color
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.
I've made some small changes to the code above, to tint the window-BG dark.
This is to make sure it's not the white Window-Background you see.
Can you pls. test again?
What's your System specs, you are testing on?
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Canvas background color
It often depends on the complexity of the graphics on the Canvas as to how much flicker there is. However, there are occasions when the Canvas would not require a redraw on resize, if only the background colour was predefined - just like the window client area, a container gadget etc.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Canvas background color
The pre defined white color for the canvas !
I self can absolutely not understand the reason, its simple for nothing good
I self can absolutely not understand the reason, its simple for nothing good
Re: Canvas background color
Ok, on a large Screen I was now able to see the initial white BG when resizing the CanvasGadget.
Even though it's not the white background fix you've asked for, you can use my DeFlicker-Modul to get rid of this effect (as a bonus you will eliminate 95% of all other resizing-flicker as well):
You can copy/paste the DeFlicker Module from THIS THREAD.
Even though it's not the white background fix you've asked for, you can use my DeFlicker-Modul to get rid of this effect (as a bonus you will eliminate 95% of all other resizing-flicker as well):
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
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Canvas background color
JHP defined a Windows API solution to flicker:
http://www.purebasic.fr/english/viewtop ... 5&start=15
RGB(124, 109, 146) .... set unique colour.
http://www.purebasic.fr/english/viewtop ... 5&start=15
Code: Select all
SetWindowLongPtr_(WindowID(#MyWindow), #GWL_EXSTYLE, #WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(#MyWindow), RGB(124, 109, 146), #Null, #LWA_COLORKEY)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Canvas background color
With a simple CanvasGadget in the window it seems to work, but already with two simple CanvasGadget in one splitter an unpleasant effect occurs.
With a SetGadgetColor () this could be avoided. In addition, creating images would be easier in some cases because I don't have to worry about the size of the gadget.
+10
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
+10
sorry for my bad english
Re: Canvas background color
Deleted, was a double posting
Last edited by Josh on Mon Oct 30, 2017 4:48 pm, edited 1 time in total.
sorry for my bad english
Re: Canvas background color
This flicker problem is real
It's ugly and unnecessary
But, unfortunately, I don't think we're going to get this simple but nice feature, and I don't think there's an answer why not
I've had enough of this soon, it's just not fun anymore
It's ugly and unnecessary
But, unfortunately, I don't think we're going to get this simple but nice feature, and I don't think there's an answer why not
I've had enough of this soon, it's just not fun anymore