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))
class PlaybackWindow(Window): def __init__(self, parent, engine): super(PlaybackWindow, self).__init__(parent, 'Playback') self.setPosition((15, 330)) self.setLayout(GroupLayout()) self.setFixedSize((400, 400)) self.engine = engine Label(self, 'Location', 'sans-bold') panel = Widget(self) panel.setLayout( BoxLayout(Orientation.Horizontal, Alignment.Middle, 0, 0)) self.frametb = TextBox(panel) self.frametb.setFixedSize((100, 25)) self.frametb.setValue('0') self.frametb.setFontSize(14) self.frametb.setAlignment(TextBox.Alignment.Right) self.frametb.setEditable(True) label = Label(panel, ' ', 'sans-bold') label.setFixedSize((15, 15)) label = Label(panel, '/', 'sans-bold') label.setFixedSize((20, 15)) self.total_framestb = TextBox(panel) self.total_framestb.setFixedSize((100, 25)) self.total_framestb.setValue('1000') self.total_framestb.setFontSize(14) self.total_framestb.setAlignment(TextBox.Alignment.Right) self.total_framestb.setEditable(True) Label(self, 'Controls', 'sans-bold') panel = Widget(self) panel.setLayout( BoxLayout(Orientation.Horizontal, Alignment.Minimum, 0, 0)) self.fbw_button = ToolButton(panel, entypo.ICON_CONTROLLER_FAST_BACKWARD) self.fbw_button.setFlags(Button.Flags.NormalButton) self.fbw_button.setCallback(lambda: self._fbw_cb()) self.stop_button = ToolButton(panel, entypo.ICON_CONTROLLER_STOP) self.stop_button.setFlags(Button.Flags.NormalButton) self.stop_button.setCallback(lambda: self._stop_cb()) self.play_button = ToolButton(panel, entypo.ICON_CONTROLLER_PLAY) self.play_button.setFlags(Button.Flags.NormalButton) self.play_button.setCallback(lambda: self._play_cb()) self.ffw_button = ToolButton(panel, entypo.ICON_CONTROLLER_FAST_FORWARD) self.ffw_button.setFlags(Button.Flags.NormalButton) self.ffw_button.setCallback(lambda: self._ffw_cb()) # Label(self, 'View Params', 'sans-bold') Label(self, 'Gamma', 'sans-bold') # panel = Widget(self) sub_panel = Widget(self) sub_panel.setLayout( BoxLayout(Orientation.Horizontal, Alignment.Minimum, 0, 0)) self.gslider = Slider(sub_panel) self.gslider.setFixedSize((180, 20)) self.gslider.setValue((1.0 / 6.0) * 2.0) self.gtb = TextBox(sub_panel) self.gtb.setFixedSize((100, 25)) self.gtb.setValue('2.0') def cb(value): # print (value) self.gtb.setValue('{:.2f}'.format(value * 6.0)) self.engine.set_gamma(value * 6.0) self.gslider.setCallback(cb) def _fbw_cb(self): self.engine.jump_to_frame(max(self.engine.get_cursor() - FFW_AMOUNT, 0)) def _ffw_cb(self): self.engine.jump_to_frame( min(self.engine.get_cursor() + FFW_AMOUNT, self.engine.get_total_frames())) def _play_cb(self): print('Play/Pause') if self.engine.is_playing: self.engine.pause() self.play_button.setIcon(entypo.ICON_CONTROLLER_PLAY) else: self.engine.play() self.play_button.setIcon(entypo.ICON_CONTROLLER_PAUS) def _stop_cb(self): print('Stop') self.engine.pause() self.engine.jump_to_frame(0) self.play_button.setIcon(entypo.ICON_CONTROLLER_PLAY)