WIP: Initial commit of prototype real drop hit test code
This commit is contained in:
parent
6d8f598312
commit
b0f56c070d
5 changed files with 84 additions and 12 deletions
|
|
@ -42,6 +42,12 @@ ParentTrack::get_child_track_list()
|
||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ParentTrack::can_host_children() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ParentTrack::remove_child_track(const boost::shared_ptr<Track> track)
|
ParentTrack::remove_child_track(const boost::shared_ptr<Track> track)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ public:
|
||||||
lumiera::observable_list< boost::shared_ptr<Track> >&
|
lumiera::observable_list< boost::shared_ptr<Track> >&
|
||||||
get_child_track_list();
|
get_child_track_list();
|
||||||
|
|
||||||
|
bool can_host_children() const;
|
||||||
|
|
||||||
bool remove_child_track(const boost::shared_ptr<Track> track);
|
bool remove_child_track(const boost::shared_ptr<Track> track);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,13 @@ Track::set_name(const std::string &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Track::remove_child_track(const boost::shared_ptr<Track> track)
|
Track::can_host_children() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Track::remove_child_track(const boost::shared_ptr<Track> /*track*/)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ public:
|
||||||
|
|
||||||
void set_name(const std::string &name);
|
void set_name(const std::string &name);
|
||||||
|
|
||||||
|
virtual bool can_host_children() const;
|
||||||
|
|
||||||
virtual bool remove_child_track(const boost::shared_ptr<Track> track);
|
virtual bool remove_child_track(const boost::shared_ptr<Track> track);
|
||||||
|
|
||||||
std::string print_branch();
|
std::string print_branch();
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ using namespace std;
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace lumiera;
|
using namespace lumiera;
|
||||||
using namespace util;
|
using namespace util;
|
||||||
|
using namespace gui::util;
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
@ -178,23 +179,78 @@ TimelineLayoutHelper::drag_to_point(const Gdk::Point &point)
|
||||||
|
|
||||||
// Search the headers
|
// Search the headers
|
||||||
TrackTree::pre_order_iterator iterator;
|
TrackTree::pre_order_iterator iterator;
|
||||||
for(iterator = ++layoutTree.begin(); // ++ so we miss out the root sequence
|
|
||||||
|
for(iterator = ++layoutTree.begin();
|
||||||
iterator != layoutTree.end();
|
iterator != layoutTree.end();
|
||||||
iterator++)
|
iterator++)
|
||||||
{
|
{
|
||||||
// Hit test the rectangle
|
// Skip the dragging branch
|
||||||
const weak_ptr<timeline::Track> track =
|
if(iterator == draggingTrackIter)
|
||||||
lookup_timeline_track(*iterator);
|
|
||||||
|
|
||||||
if(util::pt_in_rect(dragPoint, headerBoxes[track]))
|
|
||||||
{
|
{
|
||||||
// Relocate the header
|
iterator.skip_children();
|
||||||
draggingTrackIter = layoutTree.move_after(
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the rectangle and the next rectangle
|
||||||
|
const shared_ptr<model::Track> model_track(*iterator);
|
||||||
|
REQUIRE(model_track);
|
||||||
|
const weak_ptr<timeline::Track> timeline_track =
|
||||||
|
lookup_timeline_track(model_track);
|
||||||
|
const Gdk::Rectangle &rect = headerBoxes[timeline_track];
|
||||||
|
const int half_height = rect.get_height() / 2;
|
||||||
|
const int y = rect.get_y();
|
||||||
|
const int y_mid = y + half_height;
|
||||||
|
const int full_width = TimelineWidget::HeaderWidth;
|
||||||
|
const int x_mid = rect.get_x() + rect.get_width() / 2;
|
||||||
|
|
||||||
|
// Is our track being dragged before this header?
|
||||||
|
if(pt_in_rect(dragPoint,
|
||||||
|
Gdk::Rectangle(0, y, full_width, half_height)))
|
||||||
|
{
|
||||||
|
draggingTrackIter = layoutTree.move_before(
|
||||||
iterator, draggingTrackIter);
|
iterator, draggingTrackIter);
|
||||||
update_layout();
|
break;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if(model_track->can_host_children() &&
|
||||||
|
model_track->get_child_tracks().empty())
|
||||||
|
{
|
||||||
|
// Is our track being dragged after this header?
|
||||||
|
if(pt_in_rect(dragPoint,
|
||||||
|
Gdk::Rectangle(0, y_mid, x_mid, half_height)))
|
||||||
|
{
|
||||||
|
draggingTrackIter = layoutTree.move_after(
|
||||||
|
iterator, draggingTrackIter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(pt_in_rect(dragPoint,
|
||||||
|
Gdk::Rectangle(x_mid, y_mid,
|
||||||
|
full_width - x_mid, half_height)))
|
||||||
|
{
|
||||||
|
// Insert a place-holder in the tree
|
||||||
|
const TrackTree::pre_order_iterator placeholder =
|
||||||
|
layoutTree.append_child(
|
||||||
|
iterator, shared_ptr<model::Track>());
|
||||||
|
|
||||||
|
// Replace it with the relocated branch
|
||||||
|
draggingTrackIter = layoutTree.move_ontop(
|
||||||
|
placeholder, draggingTrackIter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(pt_in_rect(dragPoint,
|
||||||
|
Gdk::Rectangle(0, y_mid, full_width, half_height)))
|
||||||
|
{
|
||||||
|
draggingTrackIter = layoutTree.move_after(
|
||||||
|
iterator, draggingTrackIter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue