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
This commit is contained in:
cxl 2009-08-16 13:41:22 +00:00
parent d81b16c030
commit 72d276642f
2 changed files with 42 additions and 35 deletions

View file

@ -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);

View file

@ -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);
}
}