Exemple #1
0
/*****************************************************************************
 * DragSortableListView::MouseMoved
 *****************************************************************************/
void
DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
{
    if ( msg && ( msg->what == B_SIMPLE_DATA || msg->what == MSG_SOUNDPLAY ) )
    {
        bool replaceAll = !msg->HasPointer("list") && !(modifiers() & B_SHIFT_KEY);
        switch ( transit )
        {
            case B_ENTERED_VIEW:
                // remember drag message
                // this is needed to react on modifier changes
                fDragMessageCopy = *msg;
            case B_INSIDE_VIEW:
            {
                if ( replaceAll )
                {
                    BRect r( Bounds() );
                    r.bottom--;    // compensate for scrollbar offset
                    _SetDropAnticipationRect( r );
                    fDropIndex = -1;
                }
                else
                {
                    // offset where by half of item height
                    BRect r( ItemFrame( 0 ) );
                    where.y += r.Height() / 2.0;
    
                    int32 index = IndexOf( where );
                    if ( index < 0 )
                        index = CountItems();
                    _SetDropIndex( index );
                }
                break;
            }
            case B_EXITED_VIEW:
                // forget drag message
                fDragMessageCopy.what = 0;
            case B_OUTSIDE_VIEW:
                _RemoveDropAnticipationRect();
                break;
        }
    }
    else
    {
        _RemoveDropAnticipationRect();
        BListView::MouseMoved(where, transit, msg);
        fDragMessageCopy.what = 0;
    }
}
Exemple #2
0
// MouseMoved
void
DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
{
	if (msg && AcceptDragMessage(msg)) {
		switch (transit) {
			case B_ENTERED_VIEW:
			case B_INSIDE_VIEW: {
				// remember drag message
				// this is needed to react on modifier changes
				_SetDragMessage(msg);
				// set drop target through virtual function
				SetDropTargetRect(msg, where);
				// go into autoscrolling mode
				BRect r = Bounds();
				r.InsetBy(0.0, r.Height() * SCROLL_AREA);
				SetAutoScrolling(!r.Contains(where));
				break;
			}
			case B_EXITED_VIEW:
				// forget drag message
				_SetDragMessage(NULL);
				SetAutoScrolling(false);
				// fall through
			case B_OUTSIDE_VIEW:
				_RemoveDropAnticipationRect();
				break;
		}
	} else {
		_RemoveDropAnticipationRect();
		BListView::MouseMoved(where, transit, msg);
		_SetDragMessage(NULL);
		SetAutoScrolling(false);

		BCursor cursor(B_HAND_CURSOR);
		SetViewCursor(&cursor, true);
	}
	fLastMousePos = where;
}