コード例 #1
0
ファイル: scrollable.py プロジェクト: baccenfutter/pyglet-gui
    def layout(self):
        Wrapper.layout(self)
        # Work out the adjusted content width and height
        y = self.y
        if self._hscrollbar is not None:
            self._hscrollbar.set_position(self.x, self.y)
            y += self._hscrollbar.height
        if self._vscrollbar is not None:
            self._vscrollbar.set_position(self.x + self._content_width, y)

        # Set the scissor group
        self.root_group.x, self.root_group.y = self.x - 1, y - 1
        self.root_group.width = self._content_width + 1
        self.root_group.height = self._content_height + 1

        # Work out the content layout
        self._content_x, self._content_y = self.x, y
        left = self.x
        top = y + self._content_height - self.content.height
        if self._hscrollbar:
            left -= self._hscrollbar.get_knob_pos()
        if self._vscrollbar:
            top += self._vscrollbar.get_knob_pos()

        self.content.set_position(left, top)
コード例 #2
0
    def layout(self, loadWrapper=True):

        if loadWrapper:
            Wrapper.layout(self)
        # Work out the adjusted content width and height
        y = self.y + (self.height - self._content_height)
        if self._hscrollbar is not None:
            self._hscrollbar.set_position(self.x, self.y)
            y += self._hscrollbar.height
        if self._vscrollbar is not None:
            self._vscrollbar.set_position(self.x + self._content_width, y)
        #print str(int(time()*1000-t1))
        # Set the scissor group
        self.root_group.x, self.root_group.y = self.x - 1, y - 1
        self.root_group.width = self._content_width + 1
        self.root_group.height = self._content_height + 1

        # Work out the content layout
        self._content_x, self._content_y = self.x, y
        left = self.x
        top = y + self._content_height - self.content.height
        #t1 = time()*1000
        if self._hscrollbar:
            left -= self._hscrollbar.get_knob_pos()
        if self._vscrollbar:
            top += self._vscrollbar.get_knob_pos()
        #t1 = time()*1000

        self.content.set_position(left, top)
コード例 #3
0
    def __init__(self,
                 content=None,
                 width=None,
                 height=None,
                 is_fixed_size=False):
        if is_fixed_size:
            assert width is not None and height is not None
        Wrapper.__init__(self, content)
        ControllerManager.__init__(self)
        self.max_width = width
        self.max_height = height
        self.is_fixed_size = is_fixed_size

        self._hscrollbar = None
        self._vscrollbar = None
        self._content_width = 0
        self._content_height = 0
        self._content_x = 0
        self._content_y = 0

        # We emulate some aspects of Manager here.
        self._theme = None
        self.batch = None
        self.root_group = None
        self.group = {
            'panel': None,
            'background': None,
            'foreground': None,
            'highlight': None
        }
コード例 #4
0
 def load_graphics(self):
     Wrapper.load_graphics(self)
     theme = self.theme[self.get_path()]
     if self._frame is None:
         template = theme[self._image_name]
         self._frame = template.generate(theme['gui_color'],
                                         **self.get_batch('panel'))
コード例 #5
0
    def layout(self):
        Wrapper.layout(self)
        # Work out the adjusted content width and height
        y = self.y
        if self._hscrollbar is not None:
            self._hscrollbar.set_position(self.x, self.y)
            y += self._hscrollbar.height
        if self._vscrollbar is not None:
            self._vscrollbar.set_position(self.x + self._content_width, y)

        # Set the scissor group
        self.root_group.x, self.root_group.y = self.x - 1, y - 1
        self.root_group.width = self._content_width + 1
        self.root_group.height = self._content_height + 1

        # Work out the content layout
        self._content_x, self._content_y = self.x, y
        left = self.x
        top = y + self._content_height - self.content.height
        if self._hscrollbar:
            left -= self._hscrollbar.get_knob_pos()
        if self._vscrollbar:
            top += self._vscrollbar.get_knob_pos()

        self.content.set_position(left, top)
コード例 #6
0
ファイル: scrollable.py プロジェクト: baccenfutter/pyglet-gui
 def unload_graphics(self):
     Wrapper.unload_graphics(self)
     if self._hscrollbar is not None:
         self._hscrollbar.unload()
         self._hscrollbar = None
     if self._vscrollbar is not None:
         self._vscrollbar.unload()
         self._vscrollbar = None
コード例 #7
0
 def unload_graphics(self):
     Wrapper.unload_graphics(self)
     if self._hscrollbar is not None:
         self._hscrollbar.unload()
         self._hscrollbar = None
     if self._vscrollbar is not None:
         self._vscrollbar.unload()
         self._vscrollbar = None
コード例 #8
0
ファイル: gui.py プロジェクト: sakkee/Spurdola-client
 def __init__(self, content, path=None, image_name='image',
              is_expandable=False, anchor=ANCHOR_CENTER):
     Wrapper.__init__(self, content, is_expandable=is_expandable, anchor=anchor)
     # private
     self._frame = None
     if path is None:
         self._path = ['frame']
     else:
         self._path = [path]
     self._image_name = image_name
コード例 #9
0
ファイル: gui.py プロジェクト: JStation/omphalos
    def __init__(self, content, path=None, image_name='image',
                 is_expandable=False, anchor=ANCHOR_CENTER):
        Wrapper.__init__(self, content, is_expandable=is_expandable, anchor=anchor)

        # private
        self._frame = None
        if path is None:
            self._path = ['frame']
        else:
            self._path = path
        self._image_name = image_name
コード例 #10
0
ファイル: scrollable.py プロジェクト: baccenfutter/pyglet-gui
    def __init__(self, content=None, width=None, height=None, is_fixed_size=False):
        if is_fixed_size:
            assert width is not None and height is not None
        Wrapper.__init__(self, content)
        ControllerManager.__init__(self)
        self.max_width = width
        self.max_height = height
        self.is_fixed_size = is_fixed_size

        self._hscrollbar = None
        self._vscrollbar = None
        self._content_width = 0
        self._content_height = 0
        self._content_x = 0
        self._content_y = 0

        # We emulate some aspects of Manager here.
        self._theme = None
        self.batch = None
        self.root_group = None
        self.group = {'panel': None, 'background': None, 'foreground': None, 'highlight': None}
コード例 #11
0
ファイル: manager.py プロジェクト: Norberg/pyglet-gui
 def delete(self):
     Wrapper.delete(self)
     if self._window is not None:
         self._window.remove_handlers(self)
         self._window = None
     self._batch._draw_list_dirty = True  # forces resorting groups
コード例 #12
0
ファイル: manager.py プロジェクト: brucepc/pyglet-gui
 def delete(self):
     Wrapper.delete(self)
     if self._window is not None:
         self._window.remove_handlers(self)
         self._window = None
     self._batch._draw_list_dirty = True  # forces resorting groups
コード例 #13
0
 def unload_graphics(self):
     if self._frame is not None:
         self._frame.unload()
         self._frame = None
     Wrapper.unload_graphics(self)
コード例 #14
0
    def __init__(self, *, window, **kwargs):
        self.vertex_list = None
        batch = pyglet.graphics.Batch()
        controller.window = window
        controller.manager = self

        with open('theme/theme.json') as f:
            theme = Theme(load(f), resources_path='./theme')

        super().__init__(VerticalContainer([
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Map Tablet to MIDI outputs"),
                        HorizontalContainer([
                            Label("Controller tablet"),
                            binding_devices.bind(
                                Dropdown(controller.tablet_names), 'tablet'),
                        ]),
                        HorizontalContainer([
                            Label("Map pointer"),
                            bind_tablet_key.bind(
                                Dropdown(controller.tablet_cursor_names),
                                'cursor'),
                            Label("with"),
                            Label("active button"),
                            bind_tablet_key.bind(
                                Dropdown(controller.tablet_button_names),
                                'button'),
                            Label("as:")
                        ]),
                        GridContainer([
                            [
                                bind_tablet_x.bind(Button("X"), 'enabled'),
                                Label("to channel"),
                                bind_tablet_x.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_tablet_x.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_tablet_x.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_tablet_x.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_tablet_x.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_tablet_x.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_tablet_x.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                            [
                                bind_tablet_y.bind(Button("Y"), 'enabled'),
                                Label("to channel"),
                                bind_tablet_y.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_tablet_y.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_tablet_y.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_tablet_y.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_tablet_y.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_tablet_y.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_tablet_y.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                            [
                                bind_tablet_p.bind(Button("Pressure"),
                                                   'enabled'),
                                Label("to channel"),
                                bind_tablet_p.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_tablet_p.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_tablet_p.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_tablet_p.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_tablet_p.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_tablet_p.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_tablet_p.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=1.0,
                                                     steps=20), 'threshold'),
                            ],
                        ]),
                    ]))),
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Map Mouse to MIDI outputs"),
                        HorizontalContainer([
                            Label("Map mouse with active button"),
                            bind_mouse_key.bind(
                                Dropdown(controller.mouse_button_names),
                                'button'),
                            Label("as:"),
                        ]),
                        GridContainer([
                            [
                                bind_mouse_x.bind(Button("X"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_x.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_x.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_x.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_x.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_x.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_x.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_mouse_x.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                            [
                                bind_mouse_y.bind(Button("Y"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_y.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_y.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_y.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_y.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_y.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_y.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_mouse_y.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                        ]),
                        HorizontalContainer([
                            Label("Map mouse wheel as:"),
                        ]),
                        GridContainer([
                            [
                                bind_mouse_wheel_x.bind(
                                    Button("X"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_wheel_x.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_wheel_x.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_wheel_x.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_wheel_x.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_wheel_x.bind(
                                    TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_wheel_x.bind(
                                    TextInput(), 'range_to'),
                                Label("step"),
                                bind_mouse_wheel_x.bind(TextInput(), 'step'),
                                Label("value"),
                                bind_mouse_wheel_x.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'value'),
                                bind_mouse_wheel_x.bind(
                                    Checkbox('pull back'), 'pull_back'),
                            ],
                            [
                                bind_mouse_wheel_y.bind(
                                    Button("Y"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_wheel_y.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_wheel_y.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_wheel_y.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_wheel_y.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_wheel_y.bind(
                                    TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_wheel_y.bind(
                                    TextInput(), 'range_to'),
                                Label("step"),
                                bind_mouse_wheel_y.bind(TextInput(), 'step'),
                                Label("value"),
                                bind_mouse_wheel_y.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'value'),
                                bind_mouse_wheel_y.bind(
                                    Checkbox('pull back'), 'pull_back'),
                            ],
                        ]),
                    ]))),
            HorizontalContainer([
                binding_buttons.bind(Button(label="Tablet Input On"),
                                     'tablet_on'),
                binding_buttons.bind(Button(label="Mouse Input On"),
                                     'mouse_on'),
                Button(label="Fullscreen",
                       on_press=controller.toggle_fullscreen),
                OneTimeButton('All Notes Off',
                              on_release=controller.midi_all_notes_off),
                OneTimeButton('Hide', on_release=controller.toggle_gui)
            ]),
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Output Device"),
                        GridContainer([
                            [
                                Label("Output MIDI port"),
                                binding_devices.bind(
                                    Dropdown(controller.midi_ports),
                                    'output_midi_port_name'),
                            ],
                        ]),
                        HorizontalContainer([
                            binding_buttons.bind(
                                Button(label="MIDI Output On"),
                                'midi_output_on'),
                            binding_buttons.bind(Button(label="Log Output"),
                                                 'log_output_on'),
                            binding_buttons.bind(Button(label="Log Input"),
                                                 'log_input_on'),
                        ]),
                    ]))),
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Status"),
                        Label("Input:", bold=True),
                        binding_labels.bind(Label("---"), 'touch_status'),
                        binding_labels.bind(Label("---"), 'mouse_status'),
                        Label("Output:", bold=True),
                        binding_labels.bind(Label("---"), 'output_status'),
                    ]))),
        ]),
                         theme=theme,
                         window=window,
                         batch=batch,
                         **kwargs)

        controller.start_listen_bindings()
        controller.update_widgets()

        @window.event
        def on_resize(width, height):
            controller.clear_scale_cache()
            controller.note_labels.clear()
            controller.calculate_grid()

        # if __debug__:
        #     fps_display = pyglet.clock.ClockDisplay()

        @window.event
        def on_draw():
            window.clear()

            if self.vertex_list:
                self.vertex_list.draw(pyglet.gl.GL_QUADS)

            if controller.gui_visible:
                batch.draw()

            for label in controller.note_labels:
                label.draw()

            # if __debug__:
            #     fps_display.draw()

        @window.event
        def on_text(text):
            controller.on_keyboard_input(text)
コード例 #15
0
ファイル: scrollable.py プロジェクト: baccenfutter/pyglet-gui
 def delete(self):
     Wrapper.delete(self)
     ControllerManager.delete(self)
コード例 #16
0
ファイル: gui.py プロジェクト: JStation/omphalos
 def load_graphics(self):
     Wrapper.load_graphics(self)
     theme = self.theme[self.get_path()]
     if self._frame is None:
         template = theme[self._image_name]
         self._frame = template.generate(theme['gui_color'], **self.get_batch('panel'))
コード例 #17
0
 def delete(self):
     Wrapper.delete(self)
     ControllerManager.delete(self)
コード例 #18
0
ファイル: gui.py プロジェクト: JStation/omphalos
 def unload_graphics(self):
     if self._frame is not None:
         self._frame.unload()
         self._frame = None
     Wrapper.unload_graphics(self)