From 9d72f2f462bc7ea25aacba0a6a60f00804a65483 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 16 Aug 2009 13:41:22 +0000 Subject: [PATCH] CtrCore: Fixed ScrollView corner-case with sibling widget interescting scrolled area git-svn-id: svn://ultimatepp.org/upp/trunk@1511 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/CtrlCore.h | 1 + uppsrc/CtrlCore/CtrlDraw.cpp | 76 +++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index fdb35720e..203c4d2ee 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -561,6 +561,7 @@ private: bool AddScroll(const Rect& sr, int dx, int dy); Rect GetClippedView(); void ScrollRefresh(const Rect& r, int dx, int dy); + void ScrollCtrl(Top *top, Ctrl *q, const Rect& r, Rect cr, int dx, int dy); void SyncScroll(); void PaintCaret(SystemDraw& w); void CtrlPaint(SystemDraw& w, const Rect& clip); diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index e098a69e4..04d3af59d 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -117,6 +117,41 @@ Rect Ctrl::GetClippedView() return view - GetScreenRect().TopLeft(); } +void Ctrl::ScrollCtrl(Top *top, Ctrl *q, const Rect& r, Rect cr, int dx, int dy) +{ + if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs + Rect to = cr; + GetTopRect(to, false); + if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs + Rect from = cr.Offseted(-dx, -dy); + GetTopRect(from, false); + MoveCtrl *m = FindMoveCtrlPtr(top->move, q); + if(m && m->from == from && m->to == to) { + LLOG("ScrollView Matched " << from << " -> " << to); + m->ctrl = NULL; + return; + } + } + + if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs + Rect from = to; + to = cr.Offseted(dx, dy); + GetTopRect(to, false); + MoveCtrl& m = top->scroll_move.Add(q); + m.from = from; + m.to = to; + m.ctrl = q; + LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to); + return; + } + cr &= r; + if(!cr.IsEmpty()) { + Refresh(cr); + Refresh(cr + Point(dx, dy)); + } + } +} + void Ctrl::ScrollView(const Rect& _r, int dx, int dy) { GuiLock __; @@ -142,41 +177,12 @@ void Ctrl::ScrollView(const Rect& _r, int dx, int dy) LTIMING("ScrollCtrls1"); Top *top = GetTopCtrl()->top; for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) - if(q->InView()) { - Rect cr = q->GetRect(); - if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs - Rect to = cr; - GetTopRect(to, false); - if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs - Rect from = cr.Offseted(-dx, -dy); - GetTopRect(from, false); - MoveCtrl *m = FindMoveCtrlPtr(top->move, q); - if(m && m->from == from && m->to == to) { - LLOG("ScrollView Matched " << from << " -> " << to); - m->ctrl = NULL; - goto done; - } - } - - if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs - Rect from = to; - to = cr.Offseted(dx, dy); - GetTopRect(to, false); - MoveCtrl& m = top->scroll_move.Add(q); - m.from = from; - m.to = to; - m.ctrl = q; - LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to); - goto done; - } - cr &= r; - if(!cr.IsEmpty()) { - Refresh(cr); - Refresh(cr + Point(dx, dy)); - } - done:; - } - } + if(q->InView()) + ScrollCtrl(top, q, r, q->GetRect(), dx, dy); + if(parent) + for(Ctrl *q = parent->GetFirstChild(); q; q = q->GetNext()) + if(q->InView() && q != this) + ScrollCtrl(top, q, r, q->GetScreenRect() - GetScreenView().TopLeft(), dx, dy); } }