void Ctrl::ScrollRefresh(const Rect& r, int dx, int dy) { GuiLock __; if(!IsOpen() || !IsVisible() || r.IsEmpty()) return; int tdx = tabs(dx), tdy = tabs(dy); if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height())); if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy)); }
void Ctrl::ScrollRefresh(const Rect& r, int dx, int dy) { sCheckGuiLock(); GuiLock __; // Beware: Even if we have ThreadHasGuiLock ASSERT, we still can be the main thread! LLOG("ScrollRefresh " << r << " " << dx << " " << dy); if(!IsOpen() || !IsVisible() || r.IsEmpty()) return; int tdx = tabs(dx), tdy = tabs(dy); if(dx) WndInvalidateRect(RectC(dx >= 0 ? r.left : r.right - tdx, r.top - tdy, tdx, r.Height())); if(dy) WndInvalidateRect(RectC(r.left - tdx, dy >= 0 ? r.top : r.bottom - tdy, r.Width(), tdy)); }
void Ctrl::RefreshFrame(const Rect& r) { GuiLock __; if(!IsOpen() || !IsVisible() || r.IsEmpty()) return; LTIMING("RefreshFrame"); LLOG("RefreshRect " << Name() << ' ' << r); #ifdef PLATFORM_WIN32 if(isdhctrl) { InvalidateRect(((DHCtrl *)this)->GetHWND(), r, false); return; } #endif if(!top) { if(InFrame()) parent->RefreshFrame(r + GetRect().TopLeft()); else parent->Refresh(r + GetRect().TopLeft()); } else { LLOG("WndInvalidateRect: " << r << ' ' << Name()); LTIMING("RefreshFrame InvalidateRect"); WndInvalidateRect(r); #ifdef PLATFORM_WIN32 LLOG("UpdateRect: " << GetWndUpdateRect() << ' ' << Name()); #endif } }
bool Ctrl::AddScroll(const Rect& sr, int dx, int dy) { GuiLock __; if(!top) return true; for(int i = 0; i < top->scroll.GetCount(); i++) { Scroll& sc = top->scroll[i]; if(sc.rect == sr && sgn(dx) == sgn(sc.dx) && sgn(dy) == sgn(sc.dy)) { sc.dx += dx; sc.dy += dy; ScrollRefresh(sc.rect, sc.dx, sc.dy); return false; } if(sc.rect.Intersects(sr)) { sc.rect |= sr; sc.dx = sc.dy = 0; WndInvalidateRect(sc.rect); return true; } } Scroll& sc = top->scroll.Add(); sc.rect = sr; sc.dx = dx; sc.dy = dy; ScrollRefresh(sc.rect, sc.dx, sc.dy); return false; }
void Ctrl::RefreshFrame(const Rect& r) { GuiLock __; if(!IsOpen() || !IsVisible() || r.IsEmpty()) return; LTIMING("RefreshFrame"); LLOG("RefreshRect " << Name() << ' ' << r); if(GuiPlatformRefreshFrameSpecial(r)) return; if(!top) { if(InFrame()) parent->RefreshFrame(r + GetRect().TopLeft()); else parent->Refresh(r + GetRect().TopLeft()); } else { LLOG("WndInvalidateRect: " << r << ' ' << Name()); LTIMING("RefreshFrame InvalidateRect"); WndInvalidateRect(r); } }
void Ctrl::RefreshFrame(const Rect& r) { sCheckGuiLock(); GuiLock __; // Beware: Even if we have ThreadHasGuiLock ASSERT, we still can be the main thread! if(!IsOpen() || !IsVisible() || r.IsEmpty()) return; LTIMING("RefreshFrame"); LLOG("RefreshRect " << Name() << ' ' << r); if(GuiPlatformRefreshFrameSpecial(r)) return; if(!top) { if(InFrame()) parent->RefreshFrame(r + GetRect().TopLeft()); else parent->Refresh(r + GetRect().TopLeft()); } else { LLOG("WndInvalidateRect: " << r << ' ' << Name()); LTIMING("RefreshFrame InvalidateRect"); WndInvalidateRect(r); } }
void Ctrl::SyncScroll() { GuiLock __; if(!top) return; Vector<Scroll> scroll = top->scroll; top->scroll.Clear(); if(IsFullRefresh()) return; for(int i = 0; i < scroll.GetCount(); i++) { Scroll& sc = scroll[i]; if(abs(sc.dx) > 3 * sc.rect.Width() / 4 || abs(sc.dy) > 3 * sc.rect.Height() / 4) { LLOG("Sync scroll Invalidate rect" << sc.rect); WndInvalidateRect(sc.rect); } else if(sc.dx || sc.dy) { LLOG("WndScrollView " << sc.rect); WndScrollView(sc.rect, sc.dx, sc.dy); } } }
void Ctrl::WndScrollView(const Rect& r, int dx, int dy) { GuiLock __; LLOG("ScrollView " << rect); WndInvalidateRect(r); }