예제 #1
0
    def add_new_window(self, window: IWindowInterface):
        """
        Adds a window to the top of the stack.

        :param window: The window to add.

        """
        new_layer = (self.stack[-1].get_top_layer() if len(self.stack) > 0 else
                     self.root_container.get_top_layer())
        window.change_layer(new_layer)
        self.stack.append(window)
예제 #2
0
    def move_window_to_front(self, window_to_front: IWindowInterface):
        """
        Moves the passed in window to the top of the window stack and resorts the other windows
        to deal with the change.

        :param window_to_front: the window to move to the front.

        """
        if window_to_front not in self.stack or window_to_front == self.stack[
                -1]:
            return
        popped_windows_to_add_back = []
        window = self.stack.pop()
        while window != window_to_front:
            popped_windows_to_add_back.append(window)
            window = self.stack.pop()

        popped_windows_to_add_back.reverse()
        for old_window in popped_windows_to_add_back:
            self.add_new_window(old_window)

        self.add_new_window(window_to_front)
        window_to_front.on_moved_to_front()