implement the generic expand/collapse mechanism

This commit is contained in:
Fischlurch 2015-12-25 03:53:26 +01:00
parent a9552ceace
commit 3a287bf134
3 changed files with 70 additions and 14 deletions

View file

@ -93,5 +93,40 @@ namespace model {
}
/**
* Expand this element and remember the expanded state.
* This is a generic Slot to connect UI signals against.
*/
void
Tangible::slotExpand()
{
this->doExpand(true);
uiBus_.note (GenNode("expand", true));
}
/**
* Collapse or minimise this element and remember the collapsed state.
* This is a generic Slot to connect UI signals against.
*/
void
Tangible::slotCollapse()
{
this->doExpand(false);
uiBus_.note (GenNode("expand", false));
}
/**
* @todo not clear yet what needs to be done
*/
void
Tangible::slotReveal(ID child)
{
this->doReveal(child);
this->doRevealYourself();
}
}} // namespace gui::model

View file

@ -92,8 +92,10 @@ namespace model {
void prepareCommand (Cmd const& prototype, Rec&& arguments);
void issueCommand (Cmd const& preparedAction);
void slotExpand() { this->doExpand(); }
void slotReveal() { this->doReveal(); }
void slotExpand();
void slotCollapse();
void slotReveal(ID child);
void markMsg (string m) { this->doMsg(m); }
void markErr (string e) { this->doErr(e); }
@ -102,8 +104,9 @@ namespace model {
protected:
virtual void doReset() =0;
virtual void doExpand() =0;
virtual void doReveal() =0;
virtual void doExpand (bool yes) =0;
virtual void doReveal (ID child) =0;
virtual void doRevealYourself () =0;
virtual void doMsg (string) =0;
virtual void doErr (string) =0;

View file

@ -88,43 +88,61 @@ namespace test{
EventLog log_{this};
bool virgin_{true};
bool expanded_{false};
/* ==== Tangible interface ==== */
virtual void doReset() override
virtual void
doReset() override
{
log_.call(this->identify(), "reset");
expanded_ = false;
virgin_ = true;
log_.event("reset");
}
virtual void doExpand() override
virtual void
doExpand (bool yes) override
{
UNIMPLEMENTED ("mock doExpand");
log_.call(this->identify(), "expand", yes);
virgin_ = false;
expanded_ = yes;
log_.event(expanded_? "expanded" : "collapsed");
}
virtual void doReveal() override
virtual void
doReveal (ID child) override
{
UNIMPLEMENTED ("mock doReveal");
}
virtual void doMsg (string text) override
virtual void
doRevealYourself() override
{
UNIMPLEMENTED ("mock doRevealYourself");
}
virtual void
doMsg (string text) override
{
UNIMPLEMENTED ("mock doMsg");
}
virtual void doErr (string text) override
virtual void
doErr (string text) override
{
UNIMPLEMENTED ("mock doErr");
}
virtual void doFlash() override
virtual void
doFlash() override
{
UNIMPLEMENTED ("mock doFlash");
}
virtual void doMark (GenNode const& mark) override
virtual void
doMark (GenNode const& mark) override
{
UNIMPLEMENTED ("mock doMark");
}
@ -172,13 +190,13 @@ namespace test{
bool
isTouched() const
{
UNIMPLEMENTED ("pristine status");
return not virgin_;
}
bool
isExpanded() const
{
UNIMPLEMENTED ("UI element expansion status");
return expanded_;
}