Reorganised set_parent in header container

This commit is contained in:
Joel Holdsworth 2009-01-10 10:50:44 +00:00
parent d02ce9b283
commit dbc36cf727
3 changed files with 18 additions and 36 deletions

View file

@ -296,11 +296,6 @@ TimelineWidget::update_tracks()
// Create timeline tracks from all the model tracks
create_timeline_tracks();
// Update the header container
REQUIRE(headerContainer != NULL);
headerContainer->show_all_children();
headerContainer->update_headers();
// Update the layout helper
layoutHelper.clone_tree_from_sequence();
layoutHelper.update_layout();
@ -316,6 +311,10 @@ TimelineWidget::create_timeline_tracks()
BOOST_FOREACH(shared_ptr<model::Track> child,
sequence->get_child_tracks())
create_timeline_tracks_from_branch(child);
// Update the header container
REQUIRE(headerContainer != NULL);
headerContainer->update_headers();
}
void

View file

@ -75,9 +75,20 @@ TimelineHeaderContainer::TimelineHeaderContainer(
void
TimelineHeaderContainer::update_headers()
{
// Add fresh headers
BOOST_FOREACH( shared_ptr<model::Track> model_track, get_tracks() )
set_parent_recursive(model_track);
// Ensure headers are parented correctly
pair<shared_ptr<model::Track>, shared_ptr<timeline::Track> > pair;
BOOST_FOREACH( pair, timelineWidget.trackMap )
{
// Set the header's parent widget
Widget &widget = lookup_timeline_track(pair.first)->
get_header_widget();
const Container *parent = widget.get_parent();
if(parent == NULL) // Is the header unparented?
widget.set_parent(*this);
ENSURE(widget.get_parent() == this);
}
}
void
@ -382,26 +393,6 @@ TimelineHeaderContainer::layout_headers()
queue_draw ();
}
void
TimelineHeaderContainer::set_parent_recursive(
boost::shared_ptr<model::Track> model_track)
{
// Set the header's parent widget
Widget &widget = lookup_timeline_track(model_track)->
get_header_widget();
const Container *parent = widget.get_parent();
if(parent == NULL) // Is the header unparented?
widget.set_parent(*this);
else if(parent != this) // The header is parented by another container
widget.reparent(*this);
// Recurse through all the children
BOOST_FOREACH( shared_ptr<model::Track> child,
model_track->get_child_tracks() )
set_parent_recursive(child);
}
void
TimelineHeaderContainer::forall_vfunc_recursive(
shared_ptr<model::Track> model_track, GtkCallback callback,

View file

@ -152,14 +152,6 @@ private:
* stacking etc.
*/
void layout_headers();
/**
* Recursively sets all the track header widgets to be child widgets
* of this widget.
* @param track The parent track object which will be recursed into.
**/
void set_parent_recursive(boost::shared_ptr<model::Track> const
model_track);
/**
* Recursively calls a callback on all the header widgets in a branch.