Put the code to Extract a replicant into its own function.
BShelf::_AddReplicant() is finally getting acceptable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23182 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -101,6 +101,8 @@ class BShelf : public BHandler {
|
|||||||
status_t _DeleteReplicant(BPrivate::replicant_data* replicant);
|
status_t _DeleteReplicant(BPrivate::replicant_data* replicant);
|
||||||
status_t _AddReplicant(BMessage* data,
|
status_t _AddReplicant(BMessage* data,
|
||||||
BPoint* location, uint32 uniqueID);
|
BPoint* location, uint32 uniqueID);
|
||||||
|
BView *_GetReplicant(BMessage *data, BView *view, const BPoint &point,
|
||||||
|
BDragger *&dragger, BDragger::relation &relation);
|
||||||
_BZombieReplicantView_ *_CreateZombie(BMessage *data, BDragger *&dragger);
|
_BZombieReplicantView_ *_CreateZombie(BMessage *data, BDragger *&dragger);
|
||||||
|
|
||||||
status_t _GetProperty(BMessage* message, BMessage* reply);
|
status_t _GetProperty(BMessage* message, BMessage* reply);
|
||||||
|
|||||||
@@ -1142,11 +1142,6 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BDragger* dragger = NULL;
|
|
||||||
BView* replicant = NULL;
|
|
||||||
BDragger::relation relation = BDragger::TARGET_UNKNOWN;
|
|
||||||
_BZombieReplicantView_* zombie = NULL;
|
|
||||||
|
|
||||||
// Instantiate the object, if this fails we have a zombie
|
// Instantiate the object, if this fails we have a zombie
|
||||||
image_id image;
|
image_id image;
|
||||||
@@ -1157,58 +1152,16 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
return send_reply(data, B_ERROR, uniqueID);
|
return send_reply(data, B_ERROR, uniqueID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BDragger* dragger = NULL;
|
||||||
|
BView* replicant = NULL;
|
||||||
|
BDragger::relation relation = BDragger::TARGET_UNKNOWN;
|
||||||
|
_BZombieReplicantView_* zombie = NULL;
|
||||||
if (view != NULL) {
|
if (view != NULL) {
|
||||||
BPoint point;
|
const BPoint point = location ? *location : view->Frame().LeftTop();
|
||||||
if (location)
|
replicant = _GetReplicant(data, view, point, dragger, relation);
|
||||||
point = *location;
|
if (replicant == NULL)
|
||||||
else
|
send_reply(data, B_ERROR, uniqueID);
|
||||||
point = view->Frame().LeftTop();
|
|
||||||
|
|
||||||
// TODO: test me -- there seems to be lots of bugs parked here!
|
|
||||||
|
|
||||||
_GetReplicantData(data, view, replicant, dragger, relation);
|
|
||||||
|
|
||||||
if (dragger != NULL)
|
|
||||||
dragger->_SetShelf(this);
|
|
||||||
|
|
||||||
BRect frame;
|
|
||||||
if (relation == BDragger::TARGET_IS_CHILD)
|
|
||||||
frame = dragger->Frame().OffsetToCopy(point);
|
|
||||||
else {
|
|
||||||
frame = replicant->Frame().OffsetToCopy(point);
|
|
||||||
fContainerView->AddChild(replicant);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CanAcceptReplicantView(frame, replicant, data)) {
|
|
||||||
// the view has not been accepted
|
|
||||||
|
|
||||||
if (relation == BDragger::TARGET_IS_PARENT
|
|
||||||
|| relation == BDragger::TARGET_IS_SIBLING) {
|
|
||||||
replicant->RemoveSelf();
|
|
||||||
delete replicant;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relation == BDragger::TARGET_IS_CHILD
|
|
||||||
|| relation == BDragger::TARGET_IS_SIBLING) {
|
|
||||||
dragger->RemoveSelf();
|
|
||||||
delete dragger;
|
|
||||||
}
|
|
||||||
|
|
||||||
return send_reply(data, B_ERROR, uniqueID);
|
|
||||||
}
|
|
||||||
|
|
||||||
BPoint adjust = AdjustReplicantBy(frame, data);
|
|
||||||
|
|
||||||
// TODO: that's probably not correct for all relations (or any?)
|
|
||||||
// At least, commenting this line fixes a bug in BSnow
|
|
||||||
view->MoveTo(point + adjust);
|
|
||||||
|
|
||||||
// if it's a sibling or a child, we need to add the dragger
|
|
||||||
if (relation == BDragger::TARGET_IS_SIBLING
|
|
||||||
|| relation == BDragger::TARGET_IS_CHILD)
|
|
||||||
fContainerView->AddChild(dragger);
|
|
||||||
|
|
||||||
replicant->AddFilter(new ReplicantViewFilter(this, replicant));
|
|
||||||
} else if (fDisplayZombies && fAllowZombies)
|
} else if (fDisplayZombies && fAllowZombies)
|
||||||
zombie = _CreateZombie(data, dragger);
|
zombie = _CreateZombie(data, dragger);
|
||||||
|
|
||||||
@@ -1233,6 +1186,60 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView *
|
||||||
|
BShelf::_GetReplicant(BMessage *data, BView *view, const BPoint &point,
|
||||||
|
BDragger *&dragger, BDragger::relation &relation)
|
||||||
|
{
|
||||||
|
// TODO: test me -- there seems to be lots of bugs parked here!
|
||||||
|
BView *replicant = NULL;
|
||||||
|
_GetReplicantData(data, view, replicant, dragger, relation);
|
||||||
|
|
||||||
|
if (dragger != NULL)
|
||||||
|
dragger->_SetShelf(this);
|
||||||
|
|
||||||
|
BRect frame;
|
||||||
|
if (relation == BDragger::TARGET_IS_CHILD)
|
||||||
|
frame = dragger->Frame().OffsetToCopy(point);
|
||||||
|
else {
|
||||||
|
frame = replicant->Frame().OffsetToCopy(point);
|
||||||
|
fContainerView->AddChild(replicant);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CanAcceptReplicantView(frame, replicant, data)) {
|
||||||
|
// the view has not been accepted
|
||||||
|
|
||||||
|
if (relation == BDragger::TARGET_IS_PARENT
|
||||||
|
|| relation == BDragger::TARGET_IS_SIBLING) {
|
||||||
|
replicant->RemoveSelf();
|
||||||
|
delete replicant;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relation == BDragger::TARGET_IS_CHILD
|
||||||
|
|| relation == BDragger::TARGET_IS_SIBLING) {
|
||||||
|
dragger->RemoveSelf();
|
||||||
|
delete dragger;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BPoint adjust = AdjustReplicantBy(frame, data);
|
||||||
|
|
||||||
|
// TODO: that's probably not correct for all relations (or any?)
|
||||||
|
// At least, commenting this line fixes a bug in BSnow
|
||||||
|
view->MoveTo(point + adjust);
|
||||||
|
|
||||||
|
// if it's a sibling or a child, we need to add the dragger
|
||||||
|
if (relation == BDragger::TARGET_IS_SIBLING
|
||||||
|
|| relation == BDragger::TARGET_IS_CHILD)
|
||||||
|
fContainerView->AddChild(dragger);
|
||||||
|
|
||||||
|
replicant->AddFilter(new ReplicantViewFilter(this, replicant));
|
||||||
|
|
||||||
|
return replicant;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_BZombieReplicantView_ *
|
_BZombieReplicantView_ *
|
||||||
BShelf::_CreateZombie(BMessage *data, BDragger *&dragger)
|
BShelf::_CreateZombie(BMessage *data, BDragger *&dragger)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user