bazaar: AutoScroller scope simplification, CtrlFinder filter bugfix, CtrlPos: filter bugfix and SPACE key deselection

git-svn-id: svn://ultimatepp.org/upp/trunk@3859 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
kohait 2011-09-13 16:45:17 +00:00
parent a03524c5d3
commit 0e787eb5f6
10 changed files with 48 additions and 12 deletions

View file

@ -27,9 +27,9 @@ public:
void OnScroll();
Callback WhenScrolled;
ScrollBars scroll;
protected:
ScrollBars scroll;
Ptr<Ctrl> pane;
};

View file

@ -6,7 +6,7 @@
template<class C>
AutoScroller<C>::AutoScroller()
{
EnableScroll();
C::AddFrame(scroll);
scroll.AutoHide();
scroll.WhenScroll = THISBACK(OnScroll);
}
@ -40,9 +40,6 @@ void AutoScroller<C>::Layout()
template<class C>
void AutoScroller<C>::EnableScroll(bool b)
{
if(scroll.x.InFrame() || scroll.y.InFrame()) return;
if(b) C::AddFrame(scroll);
else C::RemoveFrame(scroll);
scroll.x.Enable(b);
scroll.y.Enable(b);
}

View file

@ -103,7 +103,8 @@ void CtrlFinder::LeftDown(Point p, dword keyflags)
{
if(!pctrl) return;
Point pt(p);
ctrl = GetCtrl(*pctrl, pt, flags, filter);
int f(flags);
ctrl = GetCtrl(*pctrl, pt, f, filter);
if(!ctrl) ctrl = pctrl;
if(!ctrl) return;
WhenLeftDown(*ctrl, p, keyflags);
@ -113,7 +114,8 @@ void CtrlFinder::RightDown(Point p, dword keyflags)
{
if(!pctrl) return;
Point pt(p);
ctrl = GetCtrl(*pctrl, pt, flags, filter);
int f(flags);
ctrl = GetCtrl(*pctrl, pt, f, filter);
if(!ctrl) ctrl = pctrl;
if(!ctrl) return;
WhenRightDown(*ctrl, p, keyflags);
@ -121,3 +123,4 @@ void CtrlFinder::RightDown(Point p, dword keyflags)
if(WhenBar)
MenuBar::Execute(WhenBar);
}

View file

@ -27,7 +27,7 @@ public:
DEF = VISIBLE | INVISIBLE | ENABLED | DISABLED | VIEW | FRAME | DEEP,
};
CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)) {}
CtrlFinder() : flags(DEF), filter(STDBACK(StdCtrlFilter)) { WantFocus(); }
virtual void LeftDown(Point p, dword keyflags);
virtual void RightDown(Point p, dword keyflags);

View file

@ -68,7 +68,11 @@ void CtrlPos::DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color&
Ctrl* c = q.GetFirstChild();
while(c)
{
if(c->InView())
Ctrl* e(c);
Point p; p.Clear();
int f(flags);
filter(e, p, f);
if(e && c->InView())
{
Rect r = c->GetRect();
if(c->InView())
@ -78,7 +82,8 @@ void CtrlPos::DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color&
r.Inflate(1);
RectCtrl::DrawHandleFrame(w, r, hintcol, 1);
}
DrawHintFrame(w, g, *c, hintcol);
if(f & CtrlFinder::DEEP)
DrawHintFrame(w, g, *c, hintcol);
c = c->GetNext();
}
}
@ -166,7 +171,8 @@ void CtrlPos::LeftDown(Point p, dword keyflags)
if(pctrl)
{
Point pt(p);
ctrl = CtrlFinder::GetCtrl(*pctrl, pt, flags, filter);
int f(flags);
ctrl = CtrlFinder::GetCtrl(*pctrl, pt, f, filter);
if(ctrl)
{
if(ctrl->InFrame()) //may not move base nor frames
@ -328,6 +334,18 @@ void CtrlPos::LeftDouble(Point p, dword flags)
WhenLeftDouble();
}
bool CtrlPos::Key(dword key, int count)
{
if(key == K_SPACE)
{
ClearCtrl();
Action();
Refresh();
return true;
}
return false;
}
void CtrlPos::Updated()
{
//refresh the view of the currently selected ctrl
@ -338,6 +356,7 @@ CtrlPos::CtrlPos()
: pressed(false), moving(false), mode(RectCtrl::NONE), g(4,4)
{
BackPaint();
NoIgnoreMouse();
style = &RectCtrl::StyleDefault();
//xpos.SetNull();
xp.SetNull();

View file

@ -31,6 +31,7 @@ public:
virtual void RightDown(Point p, dword keyflags);
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
virtual void LeftDouble(Point p, dword flags);
virtual bool Key(dword key, int count);
virtual void Updated();
virtual Rect GetVoidRect() const { return Ctrl::GetVoidRect(); }
@ -38,7 +39,7 @@ public:
static void DrawAlignHandle(Draw& w, const Rect& _r, const Rect& r, const Ctrl::LogPos& pos, const Color& col);
static bool GetAlignMode(const Rect& _r, const Rect& r, const Point& pp, Ctrl::LogPos& pos, int handsize);
static void DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color& hintcol);
void DrawHintFrame(Draw& w, const Ctrl& g, const Ctrl& q, const Color& hintcol);
Callback WhenLeftDouble;

View file

@ -15,6 +15,8 @@ public:
typedef CtrlPosTest CLASSNAME;
CtrlPosTest();
virtual void Activate();
void VisitCB();
void ClearCB();
void EnableCB();

View file

@ -24,6 +24,7 @@ void CtrlPosTest::ClearCB()
void CtrlPosTest::EnableCB()
{
hk.Enable();
hk.SetFocus();
}
void CtrlPosTest::DisableCB()
{
@ -90,6 +91,12 @@ CtrlPosTest::CtrlPosTest()
hk.WhenLeftDown = THISBACK(OnSelect);
hk.SetSource(&vis);
hk.SetFocus();
}
void CtrlPosTest::Activate()
{
hk.SetFocus();
}
GUI_APP_MAIN

View file

@ -16,6 +16,7 @@ public:
typedef CtrlPosTest2 CLASSNAME;
CtrlPosTest2();
virtual void Activate();
//keep the visiting control separated from the CtrlFinder (aka CtrlPos)
//so simply visiting this TopWindow is not possible (cause of Ctrl Tree search from bottom)

View file

@ -12,6 +12,12 @@ CtrlPosTest2::CtrlPosTest2()
sc.AddPane(vis);
sc.WhenScrolled = callback(&hk, &CtrlPos::UpdateRefresh);
hk.SetSource(&vis); //will add itself to vis->GetParent --> to this TopWindow with same vis.GetPos to cover it perfectly.
hk.SetFocus();
}
void CtrlPosTest2::Activate()
{
hk.SetFocus();
}
GUI_APP_MAIN