Esempio n. 1
0
    def on_transform_with_touch(self, touch):
        super(TaskItem, self).on_transform_with_touch(touch)
        # this method triggers when the task object is moved with the mouse
        mycursor = win32api.LoadCursor(0,win32con.IDC_HAND)
        win32api.SetCursor(mycursor)

        # we get the closest absc in the columns absc
        theclosest = NumOperation.takeClosest(
                                myList = self.project.days_dataframe.absc,
                                myNumber = touch.x - self.width/2
                                                )

        # the object is moved to this column absc
        self.x = theclosest[0]

        # And we save the new beginning day in the task dataframe
        self.update_task_attr_in_dtf(
                                    'task_start',
                                    self.project.days_dataframe.loc[
                                            theclosest[1],
                                            'date'
                                                                   ]
                                    )

        # we pos the object on the y absc
        self.y_positionning()

        # we update the y pos of all the other task objects according to
        for wid in self.parent.children:
            wid.y_positionning()
Esempio n. 2
0
    def resized(self):

        # we update the dtf we the new days value
        self.update_task_attr_in_dtf(
                                'task_days',
                                NumOperation.takeClosest(
                                    myList = self.project.days_dataframe.absc,
                                    myNumber = self.splitter.width
                                                         )[1]
                                    )
        # and we update the width accordinf to the dtf
        self.upd_width_from_dtf()

        # we pos the object on the y absc
        self.y_positionning()

        # we update the y pos of all the other task objects according to
        for wid in self.parent.children:
            wid.y_positionning()
Esempio n. 3
0
    def on_transform_with_touch(self, touch):
        super(HeaderItem, self).on_transform_with_touch(touch)
        # this method is triggered when the header is moved

        # Trigger of the moveflag
        self.move_flag = True

        # We get the list of possible new position for the header
        address_list = self.parnt.address_list[:]
        my_id_in_list = self.parnt.place_id_list.index(self.place_id)
        # and we delete the actual one inside the list
        del address_list[my_id_in_list]

        # we add a colored line in the header container to display the
        # new position of the header if the touch is released
        self.parnt.add_movline()

        # we get the closest y in the y address list
        theclosest = NumOperation.takeClosest(
                                myList = address_list,
                                myNumber = touch.y
                                                )
        # And we move the moveline to this y
        self.parnt.movline.y =  theclosest[0] - self.parnt.padd/2
Esempio n. 4
0
    def on_transform_with_touch(self, touch):
        super(NoteItem, self).on_transform_with_touch(touch)
        # this method is triggered when the note item is moved

        # at the first trigger of this method, meaning at the very beginning
        # of the move, we take this scatter out of the note list to be able
        # to move it in the notetool
        if self.move_flag == False:

            # then we add a widget in the container to simulate the
            # position of the noteitem if the touch is released
            # ref
            self.new_place_noteitem = NewPlaceNoteItem(self)
            # add
            self.notecontainer.add_widget(self.new_place_noteitem)

            self.memy = self.y

            # First we move ourself form the note container to the
            # note tool, in order to be able to move ourself in the window
            self.parent.clear_widgets([self])
            # ref
            self.notetool.moving_noteitem = self
            # add
            self.notetool.add_widget(self)

            # Trigger of the moveflag
            self.move_flag = True

            return
############ Need to detect what is the container hoveredd in here ############
        hovered_container = self.get_hovered_container(touch)
############ Need to detect what is the container hoveredd in here ############

        # get the place_id the closest from the touch in the hovered_container
        # We get the adress list of this container
        address_list = hovered_container.address_list[:]

        inside_y = hovered_container.to_widget(*self.pos)[1]
        # explanation of the to_widget...:
        # we want the coordinates in the container space, they will
        # be used to compare with the y addresses of the noteitems
        # inside this container

        theclosest = NumOperation.takeClosest(
                                myList = address_list,
                                myNumber = inside_y + self.height
                                             )

        # we get the new id wanted
        new_place_id = hovered_container.place_id_list[theclosest[1]] + 1
        # We +1 because if we get "1" as the new_place_id, it means that we
        # want to be AFTER the place_id "1" => place_id "2"

        # if the container which is hovered is the same as before
        if self.new_place_noteitem.notecontainer == hovered_container:
            # and if the new place id is the same as before or the same as
            # before + 1
            # explanation: if the touch indicates that we want to be after
            # ourself or after the one before us. In both cases, it
            # indicates that we don't want to move.
            if self.new_place_noteitem.place_id in [new_place_id]:
                # then we stop
                return
            elif inside_y > self.memy and self.new_place_noteitem.place_id < new_place_id:
                return
            elif inside_y < self.memy and self.new_place_noteitem.place_id > new_place_id:
                return

        # we need to delete the new_place_noteitem from its container
        self.new_place_noteitem.notecontainer.clear_noteitem(noteitem = self.new_place_noteitem)
        # we increment all the noteitem place_ids >= to the new item place id
        hovered_container.increment_place_ids_after(new_place_id)
        # and add it in the new one
        hovered_container.add_noteitem(noteitem = self.new_place_noteitem, note_place_id = new_place_id)

        self.memy = inside_y
        # self.stop = True

        self.new_place_noteitem.notecontainer = hovered_container
        self.new_place_noteitem.notelist_id = hovered_container.notelistitem.notelist_id
Esempio n. 5
0
    def on_transform_with_touch(self, touch):

        # we check that it's not a noteitem wich is being moved
        if self.do_translation == (False, False):
            # if it is we stop
            return

        super(NoteListItem, self).on_transform_with_touch(touch)
        # this method is triggered when the note item is moved

        # at the first trigger of this method, meaning at the very beginning
        # of the move, we take this scatter out of the note list to be able
        # to move it in the notetool
        if self.move_flag == False:

            # then we add a widget in the container to simulate the
            # position of the notelistitem if the touch is released
            # ref
            self.new_place_notelistitem = NewPlaceNoteListItem(self)
            # add
            self.parent.add_widget(self.new_place_notelistitem)

            self.memx = self.x

            # First we move ourself from the notelist container to the
            # notetool, in order to be able to move ourself in the window
            self.parent.clear_widgets([self])
            # ref
            self.notetool.moving_notelistitem = self
            # add
            self.notetool.add_widget(self)

            # Trigger of the moveflag
            self.move_flag = True

            Cursor().update('grab')
            Cursor().block()

            return

        # get the place_id the closest from the touch in the notetool
        # We get the adress list
        address_list = self.get_x_address_list()

        # Alors pour le comprendre celui la faut s'accrocher...
        # inside_x = self.notetool.notelistcontaineritem.to_widget(
        #                                             self.x, self.y, True
        #                                                         )[0] + Window.width - self.notetool.x
        inside_x = self.notetool.notelistcontaineritem.to_widget(
                                                    self.x, self.y, True
                                                                )[0] + self.notetool.x
        # explanation of the to_widget...:
        # we want the coordinates in the container space, they will
        # be used to compare with the y addresses of the notelistitems
        # inside this container

        print('x dans le ref container: ' + str(self.notetool.notelistcontaineritem.to_widget(
                                                    self.x, self.y, True
                                                                )[0]))
        print('Window.width: ' + str(Window.width))
        print('pos du notetool: ' + str(self.notetool.x))
        print('inside_x : ' + str(inside_x))
        print('###############################################')

        # we get the closest x in the x address list
        theclosest = NumOperation.takeClosest(
                                myList = address_list,
                                myNumber = inside_x
                                             )

        # we get the new id wanted
        new_place_id = theclosest[1] + 1

        # and if the new place id is the same as before we don't want to move.
        if self.new_place_notelistitem.place_id == new_place_id:
            # then we stop
            return

        # we need to delete the new_place_noteitem
        self.notetool.notelistcontaineritem.clear_notelistitem(notelistitem = self.new_place_notelistitem)

        # we increment all the notelistitems place_ids >= to the new item place id
        self.notetool.notelistcontaineritem.increment_place_ids_after(new_place_id)

        # and add it in the new one
        self.notetool.notelistcontaineritem.add_notelistitem(
                                notelistitem = self.new_place_notelistitem,
                                notelist_place_id = new_place_id
                                                            )

        self.memx = inside_x