Structure-Change: now able to turn the widgets within DisplayFrame into ViewHooked

...and implemented the base case (=Recursion) of the corresponding ViewHook(s)
This commit is contained in:
Fischlurch 2019-12-21 23:57:53 +01:00
parent c5d0ddb01b
commit e4049534fa
7 changed files with 593 additions and 1030 deletions

View file

@ -278,7 +278,7 @@ namespace util {
* in any sequential collection */
template <typename SEQ>
inline typename SEQ::iterator
removeall (SEQ& coll, typename SEQ::value_type& val)
removeall (SEQ& coll, typename SEQ::value_type const& val)
{
typename SEQ::iterator collEnd = coll.end();
return coll.erase (std::remove (coll.begin(), collEnd, val),

View file

@ -95,24 +95,17 @@ namespace timeline {
}
void
TrackBody::attachSubTrack (TrackBody* subBody)
{
REQUIRE (subBody);
subTracks_.push_back (subBody); /////////////////////////////////////////////////////TICKET #1199 : this can not possibly work; we need a way to retain the order of tracks, and we need to detach tracks...
// detect changes of the track structure
subBody->signalStructureChange_ = signalStructureChange_;
signalStructureChange_(); // this _is_ such a change
}
/* ==== Interface: ViewHook ===== */
void
TrackBody::hook (TrackBody& subBody, int xPos, int yPos)
{
UNIMPLEMENTED ("attach sub-TrackBody");
REQUIRE (xPos==0 && yPos==0, "arbitrary positioning of TrackBody contradicts the concept of track-profile."); ///TODO remove that API
subTracks_.push_back (&subBody);
// notify presentation code of the changed structure
subBody.signalStructureChange_ = signalStructureChange_;
signalStructureChange_(); // this _is_ such a change
}
void
@ -124,13 +117,16 @@ namespace timeline {
void
TrackBody::remove (TrackBody& subBody)
{
UNIMPLEMENTED ("detach sub-TrackBody");
util::removeall (subTracks_, &subBody);
signalStructureChange_();
}
void
TrackBody::rehook (ViewHooked<TrackBody>& subBody) noexcept
{
UNIMPLEMENTED ("re-attach sub-TrackBody");
util::removeall (subTracks_, &subBody);
subTracks_.push_back (&subBody);
signalStructureChange_();
}

View file

@ -114,7 +114,6 @@ namespace timeline {
void setTrackName (cuString&);
uint establishTrackSpace (TrackProfile&);
void attachSubTrack (TrackBody*);
uint calcRulerHeight();
uint calcHeight();

View file

@ -94,15 +94,31 @@ namespace timeline {
* the whole structure has to be re-built accordingly.
*/
void
TrackHeadWidget::injectSubFork (TrackHeadWidget& subForkHead)
TrackHeadWidget::attachSubFork (TrackHeadWidget& subForkHead)
{
++childCnt_;
this->attach (subForkHead, 1, childCnt_, 1,1);
}
/**
* @internal remove a complete sub-fork from display.
* @remarks due to the automatic ref-counting system of GTK+, it is sufficient
* just to remove the entry from the `Gtk::Container` baseclass, which
* automatically decrements the refcount; alternatively we could as well
* destroy the Gtkmm wrapper-Object (i.e. the `Gtk::Widget` subclass),
* since this also destroys the underlying `gobj` and automatically
* detaches it from any container.
*/
void
TrackHeadWidget::detachSubFork (TrackHeadWidget& subForkHead)
{
--childCnt_;
this->remove (subForkHead);
}
void
TrackHeadWidget::clearSubFork()
TrackHeadWidget::clearFork()
{
while (childCnt_ > 0)
{
@ -117,7 +133,8 @@ namespace timeline {
void
TrackHeadWidget::hook (TrackHeadWidget& subHead, int xPos, int yPos)
{
UNIMPLEMENTED ("attach sub-TrackHead");
REQUIRE (xPos==0 && yPos==0, "selection of arbitrary row not yet implemented");
attachSubFork (subHead);
}
void
@ -129,13 +146,22 @@ namespace timeline {
void
TrackHeadWidget::remove (TrackHeadWidget& subHead)
{
UNIMPLEMENTED ("detach sub-TrackHead");
detachSubFork (subHead);
}
/** @remark This implementation will not interfere with the widget's lifecycle.
* The widget with all its children is just detached from presentation (leaving an
* empty grid cell), and immediately re-attached into the "bottom most" cell, as
* given by the current childCnt_
* @note in theory it is possible to end up with several widgets in a single cell,
* and GTK can handle that. Given our actual usage of these functions, such should
* never happen, since we manage all widgets as slave of the model::Tangible in charge.
*/
void
TrackHeadWidget::rehook (ViewHooked<TrackHeadWidget>& hookedSubHead) noexcept
{
UNIMPLEMENTED ("re-attach sub-TrackHead");
detachSubFork (hookedSubHead);
attachSubFork (hookedSubHead);
}

View file

@ -91,14 +91,15 @@ namespace timeline {
~TrackHeadWidget();
void setTrackName (cuString&);
/** Integrate the control area for a nested sub track fork. */
void injectSubFork (TrackHeadWidget& subForkHead);
/** Discard all nested sub track display widgets. */
void clearSubFork();
private:/* ===== Internals ===== */
/** Integrate the control area for a nested sub track fork. */
void attachSubFork (TrackHeadWidget& subForkHead);
void detachSubFork (TrackHeadWidget& subForkHead);
/** Discard all nested sub track display widgets. */
void clearFork();
};

View file

@ -131,8 +131,8 @@ namespace timeline {
, public DisplayViewHooks
, public CanvasOffsetHook
{
TrackHeadWidget head_;
TrackBody body_;
ViewHooked<TrackHeadWidget> head_;
ViewHooked<TrackBody> body_;
/* ==== Interface: DisplayViewHooks===== */
@ -149,8 +149,8 @@ namespace timeline {
public:
DisplayFrame (DisplayViewHooks& displayAnchor)
: CanvasOffsetHook{displayAnchor.getClipHook()}
, head_{}
, body_{}
, head_{displayAnchor.getHeadHook()}
, body_{displayAnchor.getBodyHook()}
{ }
void
@ -159,13 +159,6 @@ namespace timeline {
head_.setTrackName (name);
body_.setTrackName (name); ///////////////////////////////////TICKET #1017 -- TODO 11/18 : not clear yet if TrackBody needs to know its name
}
void
injectSubTrack (TrackHeadWidget& subHead, TrackBody& subBody)
{
head_.injectSubFork (subHead);
body_.attachSubTrack (&subBody);
}
vector<unique_ptr<RulerTrack>>&
bindRulers()

File diff suppressed because it is too large Load diff