It is currently Mon Dec 10, 2018 1:17 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Wed Aug 08, 2018 6:49 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10456
Location: Beyond the pale...
Unsure if this is a bug or, as an undoubted consequence of some alteration with PB or other, just an unfortunate result.

It seems that the canvas gadget now erases it's content when the gadget is resized which causes massive flicker when resizing and repainting - on Windows 7 at least.

No problems with PB 5.62.

Resize the window in the following and, under PB 5.70x64 beta 1 for Windows, massive flicker (Win 7).

Code:
Procedure winSize()
  ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0)-20, WindowHeight(0)-20)
  If StartDrawing(CanvasOutput(0))
    Circle(100, 100, 100, #Red)
    StopDrawing()
  EndIf
EndProcedure


If OpenWindow(0, 0, 0, 220, 220, "Canvas example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
  CanvasGadget(0, 10, 10, 200, 200)
  If StartDrawing(CanvasOutput(0))
    Circle(100, 100, 100, #Red)
    StopDrawing()
  EndIf
  BindEvent(#PB_Event_SizeWindow, @winSize(), 0)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf


Remove the drawing routine from the resizing procedure and you will see the circle disappear completely when the window is resized.

I understand why erasing the content might be a natural thing to do when resizing the control, but it does seem a bit of a drastic change over previous PB versions in that the control's contents are no longer always 'persistent'.

Playing merry buggery with some of my programs. :)

_________________
I may look like a mule, but I'm not a complete ass.


Last edited by srod on Thu Aug 09, 2018 8:46 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1
PostPosted: Thu Aug 09, 2018 6:20 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3302
Location: Berlin, Germany
srod wrote:
Resize the window in the following and, under PB 5.70x64 beta 1 for Windows, massive flicker (Win 7).

Interestingly enough, there is absolutely no flicker here when resizing the window, using PB 5.70 x64 beta 1 on Windows 10 (version 1803). :o

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1
PostPosted: Thu Aug 09, 2018 6:30 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 17, 2009 10:51 pm
Posts: 1305
Location: Nashville
I have no way to test this on the beta version, as I am indefinitely stuck on 5.61. However, I can confirm it works flawlessly on 5.61.

Good find srod!


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1
PostPosted: Thu Aug 09, 2018 7:02 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 738
Absolutely no flickering here

PB 5.70b1 x86
Win7 Ultimate x64

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1
PostPosted: Thu Aug 09, 2018 7:12 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 738
srod wrote:
I understand why erasing the content might be a natural thing to do when resizing the control, but it does seem a bit of a drastic change over previous PB versions in that the control's contents are no longer always 'persistent'.


The fact that the background in Pb570 is always redrawn probably has something to do with this.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1
PostPosted: Thu Aug 09, 2018 8:35 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10456
Location: Beyond the pale...
Josh wrote:
srod wrote:
I understand why erasing the content might be a natural thing to do when resizing the control, but it does seem a bit of a drastic change over previous PB versions in that the control's contents are no longer always 'persistent'.


The fact that the background in Pb570 is always redrawn probably has something to do with this.


Ah, I did wonder if the new arrangements with the background color and the like had something to do with this?

freak wrote:
I think I have a good solution now.
I changed the resize code so that if you bind a callback to the #PB_EventType_Resize event for the CanvasGadget, you get a chance to update the content before the resized content is drawn to the screen. This way there is no flicker, even if you draw stuff into the resized area.


Confirmed that the flicker is mostly gone if I take advantage of this. However, because the canvas resizing event procedure is being explicitly called outside of the main event loop, before the ResizeGadget() function returns, I cannot easily make use of this. This will take some reworking and rehashing of my code! :)

Thanks Josh. That was the heads up I needed.

*EDIT : code was surprisingly easy to edit and rehash and all flicker has now gone! :)

This resizing 'issue' needs a word in the manual because the canvas gadget has now changed, albeit in a quite subtle manner. Must admit that I never understood those who asked to be able to set the background color of a canvas gadget as this was always going to be a problem when then resizing the control. inmo, this was always best left to the host app.

@Freak : why not as part of the resize, simply create a new image, fill it with the background color and then blit across the old image? Enlarged parts of the original image would then just show the back color and the old image remains intact (as far as the new dimensions will allow) and there should be no flicker. This way we have the best of both worlds in that whether we choose to repaint in the resizing procedure or after the resize has completed will not introduce much in the way of flicker. Or perhaps instead add an optional flag, something like : #PB_Canvas_NoEraseBackground etc?
I must admit, having the underlying bitmap resized before the resize event fires is very handy as the canvas resizing event was pretty much useless before this. :)

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Thu Aug 09, 2018 1:26 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2755
Location: Boston, MA
The new v57b1 behavior definitely breaks my v562 code.Thanks srod for the smaller snippet to show the problem. How are you saying "resolved" if the manual claims canvasgadget is persistent?
Your code(without redrawing canvas contents) in v562 does not clear the canvas on resize.
In v57b1 the canvas is cleared :shock:

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Thu Aug 09, 2018 4:08 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10456
Location: Beyond the pale...
I say 'resolved' because, as you can see from the quote from Freak, this behaviour is now expected and is a consequence of the way the background is now automatically painted by PB when the gadget is resized - discarding any existing content in the process. I thus cannot claim this is a bug; as much as I don't like this behaviour! **EDIT : on Ubuntu qt subsytem, the image is persistent even after the resize! Some slight inconsistency here.

It is not that you wouldn't expect to repaint the content following a resize, it is just that I had gotten into the habit of doing this, not in the canvas resize event (as this was buggy up to now), but after the ResizeGadget() function had returned. Doing this now, yields the flicker because of the aforementioned automatic background refresh. I am guessing that, like yourself, this is going to impact quite a few people.

I just think that it would be better to implement the background refresh in the way I outlined above. That way, everyone is happy and the canvas gadget then remains persistent in all cases. :)

_________________
I may look like a mule, but I'm not a complete ass.


Last edited by srod on Thu Aug 09, 2018 10:09 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Thu Aug 09, 2018 4:27 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2755
Location: Boston, MA
Yes, your code points to the new effect. My example confused me, since the splittergadget was forcing the canvasgadget to clear. I can see they are related.

Soapbox: Purebasic often claims resistance to breaking existing code with incremental versions. Why now?

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Thu Aug 09, 2018 4:32 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10456
Location: Beyond the pale...
skywalk wrote:
Soapbox: Purebasic often claims resistance to breaking existing code with incremental versions. Why now?


Well, a lot of people were asking to be able to set the background color in a canvas gadget which is what has led to this.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Thu Aug 09, 2018 4:37 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2755
Location: Boston, MA
True, but offering background color should not break canvasgadget persistence.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Thu Aug 09, 2018 5:07 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2755
Location: Boston, MA
Arrg, I have complicated images that change sizes dynamically based on user settings.
So, I draw the image, stopdrawing(), and then resize the canvasgadget to the new outline.
I have to rearrange the flow entirely to avoid blanking my canvasgadget. :evil:

And, there is wasted time redrawing when all the user wants to do is slide the splitter closed to obscure the canvas. Sliding back to full view shows the canvasgadget unaltered.

This kinda sucks.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas gadget refresh PB 5.70 Beta 1 / RESOLVED
PostPosted: Fri Aug 10, 2018 6:38 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 24, 2006 3:29 am
Posts: 153
Affecting my canvas based project in the same flickery way :)

Waiting to see if there is a fix before changing everything to track #PB_EventType_Resize.

_________________
Proud supporter of PB! * Musician * C64/6502 Freak


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye