flick problem

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flick problem

Post by doublemax »

I now use wxAutoBufferedPaintDC, u mean that it internally creates a bitmap each time?
Yes. Unless the underlying OS performs double buffering by default.

You can use a static bitmap as buffer only with wxBufferedPaintDC.

Code: Select all

// assumes wxBitmap m_buffer; as member variable of ImagePanel:
void ImagePanel::OnPaint(wxPaintEvent &WXUNUSED(event))
{
  wxSize size = GetClientSize();
  // recreate bitmap if the size of the window has changed
  if( m_buffer.IsOk()==false || m_buffer.GetWidth()!=size.x || m_buffer.GetHeight()!=size.y)
  {
    m_buffer.Create(size);
  }

  wxBufferedPaintDC dc(this, m_buffer);

  // drawing code here
}
Use the source, Luke!
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

I tried this method, for both the big panel and small panel. It's better and faster rendering when fast move the panel, but still have that "dragging" appearance when move the big panel...
and I am really comfused that why the 1st big panel I add on the wxScrollWindow is always perfect, but when I add the 2nd panel, and drag the 2nd it's worse, while move the 1st one it's still perfect! and the more i add, the latter one looks worse....
ps.another problem is that I now use Refresh() everywhere I need to refresh, for wxScrollWindow, big panel, small panel...might it be another problem? and what is the difference of it from Update, InvalidateRect? which one is more efficient?
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flick problem

Post by doublemax »

I tried this method, for both the big panel and small panel. It's better and faster rendering when fast move the panel, but still have that "dragging" appearance when move the big panel...
Any chance you can make a video of this? Because i can't really imaging what you're seeing.
I am really comfused that why the 1st big panel I add on the wxScrollWindow is always perfect, but when I add the 2nd panel, and drag the 2nd it's worse, while move the 1st one it's still perfect! and the more i add, the latter one looks worse....
I have no idea about this. Do these big panels overlap? wxWidgets doesn't support overlapping siblings, which could lead to some redraw issues.
and what is the difference of it from Update, InvalidateRect? which one is more efficient?
Refresh() invalidates the whole window which will then receive a paint event later. Update() forces an immediate redraw of the invalidated parts of the window. Of course it's more efficient to invalidate only the parts of the window that have actually changed, but don't think this would improve the performance very much in your case.
Use the source, Luke!
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

ok, I will make a video. May I send it to ur email ? I found upload file here is very slow...
and I found when move the panel, if I call the panel's Update instead of Refresh(), it's better, but the semi-transparent backgound is wrong cause of no refresh...
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flick problem

Post by doublemax »

May I send it to ur email ?
Make a private youtube video and post the link.
Use the source, Luke!
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

i tried, but upload was failed..it's 27M.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flick problem

Post by doublemax »

I saw the video, i know what you mean now. What OS is that? If it's Windows7 or 8, can you try on a XP machine? I'm wondering if the internal double buffering of Windows7/8 somehow interferes.
Use the source, Luke!
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

win 8
well, I compiled wxWidgets using DLL_DEBUG in vs2013, i guess it is defaut 64bit, so can't run on winXP...
jingyu9575
In need of some credit
In need of some credit
Posts: 7
Joined: Sun Mar 30, 2014 3:39 am

Re: flick problem

Post by jingyu9575 »

gpu wrote:win 8
well, I compiled wxWidgets using DLL_DEBUG in vs2013, i guess it is defaut 64bit, so can't run on winXP...
Hi,
vs2013 builds to 32bit EXE by default, but it uses new API so it won't run on XP. To get a XP-compatible build, right click your project and select "Properties", then "Configuration Properties" -> "General", change "Platform Toolset" to "Visual Studio 2013 - Windows XP (v120_xp)" and rebuild.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flick problem

Post by doublemax »

I don't have many ideas about this anyway. Could you show the code where you move the panel?
Use the source, Luke!
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

doublemax wrote:I don't have many ideas about this anyway. Could you show the code where you move the panel?
ok

Code: Select all

void MyPanel::MouseMove(wxMouseEvent& event)
{
  if(IsDragging)
  {
    //get the position
    ...
    this->Move(pos);

    MyFrame* frame = wxDynamicCast(GetParent(), MyFrame);
    if(frame != NULL)
    {
      frame->Refresh();
    }
    
    Refresh();
  }
}
void MyPanel::LeftDown(...)
{
CaptureMouse();
IsDragging = true;
}
void MyPanel::LeftUp(...)
{
ReleaseMouse();
IsDragging = false;
}
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

and the Render func is like what we disscussed before, for big panel and small panel, first call parent->Render(), then draw its own bitmap and others. the frame is the big panel's parent, and the big panel is the small panel's parent. for the frame, in its Render(), just do its own drawings.
and all of them use wxBufferPaintDC.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flick problem

Post by doublemax »

Code: Select all

    MyFrame* frame = wxDynamicCast(GetParent(), MyFrame);
    if(frame != NULL)
    {
      frame->Refresh();
    }
   
    Refresh();
Did you check if these Redraw calls are needed? Refreshing the panel itself shouldn't be necessary at all and under normal circumstances redrawing the frame shouldn't be needed either.
Use the source, Luke!
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

I all tired...
Last edited by gpu on Wed Sep 17, 2014 8:31 am, edited 1 time in total.
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: flick problem

Post by gpu »

I all tired...
but the two Refresh are both nessesary.
if no Refresh for the frame, the linked lines will not refresh...
if no Refresh for the panel, the panel's background will not right......
Post Reply