WIP: Gave dragging a more immediate feeling
This commit is contained in:
parent
d209e0e2f2
commit
78e0f9bbe6
2 changed files with 46 additions and 10 deletions
|
|
@ -42,6 +42,7 @@ namespace timeline {
|
||||||
TimelineLayoutHelper::TimelineLayoutHelper(TimelineWidget &owner) :
|
TimelineLayoutHelper::TimelineLayoutHelper(TimelineWidget &owner) :
|
||||||
timelineWidget(owner),
|
timelineWidget(owner),
|
||||||
totalHeight(0),
|
totalHeight(0),
|
||||||
|
dragBranchHeight(0),
|
||||||
animating(false)
|
animating(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -146,6 +147,7 @@ TimelineLayoutHelper::begin_dragging_track(
|
||||||
const shared_ptr<model::Track> model_track =
|
const shared_ptr<model::Track> model_track =
|
||||||
draggingTrack->get_model_track();
|
draggingTrack->get_model_track();
|
||||||
draggingTrackIter = iterator_from_track(model_track);
|
draggingTrackIter = iterator_from_track(model_track);
|
||||||
|
dragBranchHeight = measure_branch_height(draggingTrackIter);
|
||||||
|
|
||||||
return draggingTrack;
|
return draggingTrack;
|
||||||
}
|
}
|
||||||
|
|
@ -206,11 +208,10 @@ TimelineLayoutHelper::drag_to_point(const Gdk::Point &point)
|
||||||
const int x_mid = rect.get_x() + rect.get_width() / 2;
|
const int x_mid = rect.get_x() + rect.get_width() / 2;
|
||||||
|
|
||||||
// Do hit test
|
// Do hit test
|
||||||
if(attempt_drop_upper(iterator, dragPoint,
|
if(attempt_drop_upper(iterator, y, full_width, half_height))
|
||||||
y, full_width, half_height))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(attempt_drop_lower(iterator, dragPoint,
|
if(attempt_drop_lower(iterator,
|
||||||
x_mid, full_width, y_mid, half_height))
|
x_mid, full_width, y_mid, half_height))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -220,9 +221,13 @@ TimelineLayoutHelper::drag_to_point(const Gdk::Point &point)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TimelineLayoutHelper::attempt_drop_upper(
|
TimelineLayoutHelper::attempt_drop_upper(
|
||||||
TrackTree::pre_order_iterator target, const Gdk::Point &point,
|
TrackTree::pre_order_iterator target, const int y,
|
||||||
const int y, const int full_width, const int half_height)
|
const int full_width, const int half_height)
|
||||||
{
|
{
|
||||||
|
const Gdk::Point point(dragPoint.get_x(),
|
||||||
|
dragPoint.get_y() - dragStartOffset.get_y() +
|
||||||
|
dragBranchHeight);
|
||||||
|
|
||||||
if(pt_in_rect(point, Gdk::Rectangle(0, y, full_width, half_height)))
|
if(pt_in_rect(point, Gdk::Rectangle(0, y, full_width, half_height)))
|
||||||
{
|
{
|
||||||
draggingTrackIter = layoutTree.move_before(
|
draggingTrackIter = layoutTree.move_before(
|
||||||
|
|
@ -232,16 +237,18 @@ TimelineLayoutHelper::attempt_drop_upper(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TimelineLayoutHelper::attempt_drop_lower(
|
TimelineLayoutHelper::attempt_drop_lower(
|
||||||
TrackTree::pre_order_iterator target, const Gdk::Point &point,
|
TrackTree::pre_order_iterator target,
|
||||||
const int x_mid, const int full_width, const int y_mid,
|
const int x_mid, const int full_width, const int y_mid,
|
||||||
const int half_height)
|
const int half_height)
|
||||||
{
|
{
|
||||||
const shared_ptr<model::Track> model_track(*target);
|
const shared_ptr<model::Track> model_track(*target);
|
||||||
REQUIRE(model_track);
|
REQUIRE(model_track);
|
||||||
|
|
||||||
|
const Gdk::Point point(dragPoint.get_x(),
|
||||||
|
dragPoint.get_y() - dragStartOffset.get_y());
|
||||||
|
|
||||||
if(!pt_in_rect(point, Gdk::Rectangle(0, y_mid,
|
if(!pt_in_rect(point, Gdk::Rectangle(0, y_mid,
|
||||||
full_width, half_height)))
|
full_width, half_height)))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -324,6 +331,31 @@ TimelineLayoutHelper::iterator_from_track(
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
TimelineLayoutHelper::measure_branch_height(
|
||||||
|
TrackTree::iterator_base parent_iterator)
|
||||||
|
{
|
||||||
|
shared_ptr<timeline::Track> parent_track =
|
||||||
|
lookup_timeline_track(*parent_iterator);
|
||||||
|
|
||||||
|
int branch_height = parent_track->get_height() +
|
||||||
|
TimelineWidget::TrackPadding;
|
||||||
|
|
||||||
|
TrackTree::sibling_iterator iterator;
|
||||||
|
for(iterator = layoutTree.begin(parent_iterator);
|
||||||
|
iterator != layoutTree.end(parent_iterator);
|
||||||
|
iterator++)
|
||||||
|
{
|
||||||
|
shared_ptr<timeline::Track> child_track =
|
||||||
|
lookup_timeline_track(*iterator);
|
||||||
|
|
||||||
|
if(child_track->get_expanded())
|
||||||
|
branch_height += measure_branch_height(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
return branch_height;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineLayoutHelper::update_layout()
|
TimelineLayoutHelper::update_layout()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,8 @@ public:
|
||||||
**/
|
**/
|
||||||
TrackTree::pre_order_iterator iterator_from_track(
|
TrackTree::pre_order_iterator iterator_from_track(
|
||||||
boost::shared_ptr<model::Track> model_track);
|
boost::shared_ptr<model::Track> model_track);
|
||||||
|
|
||||||
|
int measure_branch_height(TrackTree::iterator_base parent_iterator);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
@ -221,11 +223,11 @@ protected:
|
||||||
bool on_animation_tick();
|
bool on_animation_tick();
|
||||||
|
|
||||||
bool
|
bool
|
||||||
attempt_drop_upper(TrackTree::pre_order_iterator target, const Gdk::Point &point, const int y, const int full_width, const int half_height);
|
attempt_drop_upper(TrackTree::pre_order_iterator target, const int y, const int full_width, const int half_height);
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
attempt_drop_lower(TrackTree::pre_order_iterator target, const Gdk::Point &point, const int x_mid, const int full_width, const int y_mid, const int half_height);
|
attempt_drop_lower(TrackTree::pre_order_iterator target, const int x_mid, const int full_width, const int y_mid, const int half_height);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
@ -264,6 +266,8 @@ protected:
|
||||||
|
|
||||||
Gdk::Point dragPoint;
|
Gdk::Point dragPoint;
|
||||||
|
|
||||||
|
int dragBranchHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The connection to the animation timer.
|
* The connection to the animation timer.
|
||||||
* @see begin_animation()
|
* @see begin_animation()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue