Пример #1
0
    def __init__(self, parent, width=400):
        super(LayersWindow, self).__init__(parent, 'Layers')
        self.setLayout(GridLayout(orientation=Orientation.Vertical))

        self.layers_scroll = VScrollPanel(self)
        self.layers_scroll.setFixedSize((width, 600))

        self.layers = LayersList(self.layers_scroll)
        self.redraw_spec_cb = None

        right_align = Widget(self)
        right_align.setLayout(GridLayout())
        TOOLS_WIDTH = 130
        TOOLS_HEIGHT = 15

        spacer = Widget(right_align)
        spacer.setSize((width - TOOLS_WIDTH, TOOLS_HEIGHT))

        tools = Widget(right_align)
        tools.setLayout(BoxLayout(Orientation.Horizontal, spacing=6))
        tools.setFixedSize((TOOLS_WIDTH, TOOLS_HEIGHT))

        # ToolButton(tools, entypo.ICON_CONTROLLER_FAST_FORWARD)
        ToolButton(tools, entypo.ICON_COMPASS)
        tb = ToolButton(tools, entypo.ICON_ADD_TO_LIST)

        def cb():
            valid = [('mp3', ''), ('wav', '')]
            file_path = nanogui.file_dialog(valid, False)
            song = open_song_from_file(file_path)
            layer = self.layers.add_layer('New Layer')
            if self.redraw_spec_cb:
                self.redraw_spec_cb()

        tb.setCallback(cb)
        ToolButton(tools, entypo.ICON_TRASH)

        self.setPosition((960, TOOLS_HEIGHT))
        self.setSize((width, 800))
        self.setLayout(GridLayout(Orientation.Vertical, resolution=2))
Пример #2
0
    half_width = width // 2
    height = 800

    # create a fixed size screen with one window
    screen = Screen((width, height), "NanoGUI Icons", False)
    window = Window(screen, "All Icons")
    window.setPosition((0, 0))
    window.setFixedSize((width, height))

    # attach a vertical scroll panel
    vscroll = VScrollPanel(window)
    vscroll.setFixedSize((width, height))

    # vscroll should only have *ONE* child. this is what `wrapper` is for
    wrapper = Widget(vscroll)
    wrapper.setFixedSize((width, height))
    wrapper.setLayout(GridLayout())  # defaults: 2 columns

    # NOTE: don't __dict__ crawl in real code!
    # this is just because it's more convenient to do this for enumerating all
    # of the icons -- see cpp example for alternative...
    for key in entypo.__dict__.keys():
        if key.startswith("ICON_"):
            b = Button(wrapper, "entypo.{0}".format(key), entypo.__dict__[key])
            b.setIconPosition(Button.IconPosition.Left)
            b.setFixedWidth(half_width)

    screen.performLayout()
    screen.drawAll()
    screen.setVisible(True)
Пример #3
0
class QTE_Gui:
    # Main screen.
    screen = None

    # Main window.
    main_wnd = None
    # Settings window.
    settings_wnd = None

    # Window size.
    main_width = 280
    main_height = 420

    # Images.
    icons = None

    def __init__(self, screen):
        self.screen = screen

    def MainWindow(self, show=True):
        '''
		Main window.
		'''
        self.icons = nanogui.loadImageDirectory(self.screen.nvgContext(),
                                                "icons")

        self.main_wnd = Widget(self.screen)
        layout = GroupLayout()
        layout.setMargin(3)
        self.main_wnd.setLayout(layout)
        self.main_wnd.setFixedSize((self.main_width, self.main_height))

        b = Button(self.main_wnd, "Export")
        b.setFixedHeight(25)
        b.setCallback(ps_act.ExportFiles)

        # Slots.
        slots = Widget(self.main_wnd)
        slots.setPosition((20, 60))
        slots.setFixedHeight(345)

        self.DrawSlots(slots)

        # Tools.
        self.Tools(self.main_wnd)

        # Final draw.
        self.screen.setBackground(backgr_color)
        self.screen.drawAll()
        self.screen.drawContents()
        self.screen.performLayout()

    def SettingsWindow(self, show=True):

        self.screen.setBackground(backgr_color)
        self.screen.drawAll()
        self.screen.drawContents()
        self.screen.performLayout()

    def Tools(self, parent):
        '''
		Draw tools widget.
		'''
        tools = Widget(parent)
        tools.setPosition((20, 420))
        layout = BoxLayout(Orientation.Horizontal, Alignment.Middle, 0, 2)
        tools.setLayout(layout)

        tools2 = Widget(tools)
        tools2.setFixedWidth(150)

        b_size = (28, 28)
        b = Button(tools, "", entypo.ICON_ADD_TO_LIST)
        b.setFixedSize(b_size)

        def add():
            print("Add")

        b.setCallback(add)

        # Settings.
        b = Button(tools, "", entypo.ICON_ADJUST)
        b.setFixedSize(b_size)

        def settings():
            print("Add")
            self.main_wnd.setVisible(False)

        b.setCallback(settings)

        #
        b = Button(tools, "", entypo.ICON_ALIGN_BOTTOM)
        b.setFixedSize(b_size)

        # Save.
        b = Button(tools, "", entypo.ICON_INSTALL)
        b.setFixedSize(b_size)

    def GetImage(self, name):
        for img in self.icons:
            if (img[1] == name): return img

        return None

    def DrawSlots(self, parent):
        images = Widget(parent)
        images.setLayout(GroupLayout())

        vscroll = VScrollPanel(images)
        vscroll.setFixedHeight(300)
        vscroll.setFixedWidth(240)
        vscroll.setLayout(GroupLayout())

        self.DrawAllSlots(vscroll)

    def DrawAllSlots(self, parent):
        images = Widget(parent)
        images.setLayout(
            BoxLayout(Orientation.Vertical, Alignment.Middle, 0, 1))

        for i in range(10):
            slot = Slot(images, self.GetImage("icons/slot_bg"))
        slot = Slot(images, self.GetImage("icons/slot_bg"))
        slot = Slot(images, self.GetImage("icons/slot_bg"))