def enable_drag_mode(self, collection, obj):
        """Set drag mode behaviours and perform setups.

        Parameters
        ==========
        collection (List2D instance)
            list of items containing the item to be
            dragged.
        obj (Object2D instance)
            item to be dragged.
        """
        ### set GUD methods to behaviours that correspond
        ### the the drag mode

        self.handle_input = CallList(
            [
                self.drag_mode_handle_events,
                self.handle_keyboard_input,
            ]
        )

        self.update = self.drag_obj
        self.draw = self.drag_mode_draw

        ### set the mouse visibility off
        SERVICES_NS.set_mouse_visibility(False)

        ###

        if collection is self.items:

            ### find the index of the object to be dragged
            ### and pop it out of the list

            index = collection.index(obj)
            collection.pop(index)

            ### alias the obj as the dragged obj
            self.dragged_obj = obj

            ### if after the operation, the list still has
            ### objects, find the index of the object
            ### nearest to the one we just popped out
            ### and reposition the items of the list
            ### according to the position of that object

            if collection:

                clamped = max(min(len(collection) - 1, index), 0)

                nearest_obj = collection[clamped]

                self.reposition_list(
                    collection,
                    nearest_obj,
                )

            ### if dragged objects wasn't the first or last
            ### object in the list, move it a bit up, so
            ### isn't in front of the remaining objects
            ### (since, if there are those, they were
            ### realigned in the previous step and there
            ### should be gap between them left by the
            ### popped out object)
            if index not in (0, len(collection)):
                self.dragged_obj.rect.move_ip(0, -27)

        else:

            new_obj = Object2D.from_surface(
                surface=obj.image,
                value=obj.value,
            )

            new_obj.rect.center = obj.rect.center

            ### alias the new obj as the dragged obj
            self.dragged_obj = new_obj

        ### store the difference between the mouse position
        ### and the center of the object to be dragged
        ### across the screen

        self.dragged_offset = (
            self.dragged_obj.rect.center
            - Vector2(SERVICES_NS.get_mouse_pos())
        )
Set drag mode behaviours and perform setups.

        Parameters
        ==========
        collection (List2D instance)
            list of items containing the item to be
            dragged.
        obj (Object2D instance)
            item to be dragged.
        
nodezator/our3rdlibs/sortingeditor/modes.py