Ejemplo n.º 1
0
class QConnectionView(QWidget):
    def __init__(self, parent=None):
        '''Initialization of the QMatrixView.

        Arguments
        ---------
        parent : QWidget
            The parent argument is sent to the QWidget constructor.
        '''
        super().__init__(parent)

        self._inputScrollBar = QScrollBar(Qt.Vertical)
        self._inputScrollBar.setFocusPolicy(Qt.StrongFocus)
        self._inputScrollBar.setMaximum(0)
        self._inputScrollBar.setValue(0)

        self._connections = QConnectionDisplay()

        self._outputScrollBar = QScrollBar(Qt.Vertical)
        self._outputScrollBar.setFocusPolicy(Qt.StrongFocus)
        self._outputScrollBar.setMaximum(0)
        self._outputScrollBar.setValue(0)

        layout = QHBoxLayout()
        layout.addWidget(self._inputScrollBar)
        layout.addWidget(self._connections)
        layout.addWidget(self._outputScrollBar)

        self.setLayout(layout)

        self._inputScrollBar.valueChanged.connect(
            self._connections.setInputOffset)

    def setActivation(self, input: np.ndarray, output: np.ndarray) -> None:
        self._connections.setActivation(input, output)
        self._inputScrollBar.setMaximum(
            max(
                self._connections.getInputHeight() -
                self._connections.height(), 0))
        self._inputScrollBar.setValue(self._connections.getInputOffset())
        self._inputScrollBar.setPageStep(self._connections.height())
Ejemplo n.º 2
0
class Slider(QWidget):
    def __init__(self, parent, name):
        super().__init__(parent)
        self.name = name
        self.layout = QHBoxLayout(self)
        self.setLayout(self.layout)

        self.slider = QScrollBar(self)
        self.spin_box = QDoubleSpinBox(self)
        self.spin_box.setMaximumWidth(70)
        self.layout.addWidget(self.slider)
        self.layout.addWidget(self.spin_box)

        self.slider.setOrientation(QtCore.Qt.Horizontal)
        self.slider.setPageStep(1)

        self._slider_mult = 1

        self._spin_val = QtPropertyVar(self.spin_box, 'value')
        self._slider_val = QtPropertyVar(self.slider, 'value')

        self._var = None
        self.set_from_value = None

        self._step = None
        self._min = None
        self._max = None

        self.var = Var(name='var')

    def _uses_integer(self):
        return isinstance(self._slider_mult, int)

    @reactive
    def _set_all_to(self, value):
        #print("set all to ", value)
        if self._min is not None and self._max is not None and self._min > self._max:
            set_if_inequal(self._var, None)
            return

        if self._uses_integer() and value is not None:
            value = int(round(value))
        set_if_inequal(self._slider_val, value * self._slider_mult)
        set_if_inequal(self._spin_val, value)
        set_if_inequal(self._var, value)

    @property
    def var(self):
        return self._var

    @var.setter
    def var(self, var):
        with ScopedName(name=self.name):
            self._var = var if var is not None else Var(name='var')
            self.set_from_value = volatile(self._set_all_to(self._var))

    def set_params(self, min, max, step=1):
        self._step = step
        self._min = min
        self._max = max

        if isinstance(min, float) or isinstance(max, float) or isinstance(
                step, float):
            self._slider_mult = 1.0 / step
            self.spin_box.setDecimals(int(ceil(-log10(step))))
        else:
            self._slider_mult = 1
            self.spin_box.setDecimals(0)
        self.slider.setRange(int(min * self._slider_mult),
                             int(max * self._slider_mult))
        self.slider.setSingleStep(int(step * self._slider_mult))
        self.spin_box.setRange(min, max)
        self.spin_box.setSingleStep(step)
        with ScopedName(name=self.name):
            self.refs = [
                volatile(self._set_all_to(self._spin_val)),
                volatile(self._set_all_to(self._slider_val /
                                          self._slider_mult))
            ]

        val = unwrap_def(self._var, None)

        self.fix_value(max, min, val)

    def fix_value(self, max, min, val):
        if min > max:
            new_val = None
        elif val is None:
            new_val = min
        elif val > max:
            new_val = max
        elif val < min:
            new_val = min
        else:
            return

        set_if_inequal(self._var, new_val)

    def dump_state(self):
        return dict(
            #            min=self._min,
            #            max=self._max,
            #            step=self._step,
            value=unwrap(self._var))

    def load_state(self, state: dict):
        #        self.set_params(state['min'], state['max'], state['step'])
        value = state['value']
        if self._uses_integer() and value is not None:
            value = int(round(value))

        self._var.set(value)
Ejemplo n.º 3
0
class OrpheusLibrarySearch(QWidget):
    
    def __init__(self):
        super().__init__()
        self.initUI()
        self.populateList()
        
    def initUI(self):
        #palette = QPalette()
        #palette.setColor(QPalette.Background, QColor('#383C4A'))        
        #palette.setColor(QPalette.WindowText, QColor('#C1C1C1'))        
        #self.setPalette(palette)
        
        self.setMaximumSize(492, 653)
        self.setMinimumSize(492, 653)
        
        le = QLineEdit(self)
        le.textChanged[str].connect(self.onChanged)
        le.returnPressed.connect(self.onActivation)
        le.setClearButtonEnabled(True)
        le.setPlaceholderText('Start typing to search...')
        self.lw = QListWidget()
        self.visibleLw = QListWidget()
        #palette.setColor(QPalette.Base, QColor('#383C4A'))                        
        #self.visibleLw.setPalette(palette)        
        self.visibleLw.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.visibleLw.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)        
        self.visibleLw.itemActivated.connect(self.onActivation)
        self.scrollBar = QScrollBar()
        self.visibleLw.verticalScrollBar().valueChanged.connect(self.scrollBar.setValue)
        self.scrollBar.valueChanged.connect(self.visibleLw.verticalScrollBar().setValue)
        vbox = QVBoxLayout()
        vbox.setSpacing(3)
        #vbox.setContentsMargins(3, 3, 3, 3)
        vbox.setContentsMargins(0, 4, 0, 0)        
        vbox.addWidget(le)       
        hbox = QHBoxLayout()
        hbox.setSpacing(0)
        #hbox.setContentsMargins(0, 0, 0, 0)                
        hbox.addWidget(self.visibleLw)
        hbox.addWidget(self.scrollBar)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
        
        self.setWindowTitle('Music Library')
        
        icon = QIcon.fromTheme('musique')
        self.setWindowIcon(icon)
        
    def populateList(self):
        self.client = MPDClient()
        self.client.connect('localhost', 6600)        
        self.playlistinfo = self.client.playlistinfo()
        self.client.disconnect()
                
        self.playlist = []
        
        #backgroundColor = QColor('#383C4A')
        #foregroundColor = QColor('#C1C1C1')
        
        for i in self.playlistinfo:
            row = ''
            if 'album' in i:
                row = row + i['album'] + ' - '
            if 'title' in i:
                if isinstance(i['title'], str):
                    row = row + i['title']
                else:
                    row = row + i['title'][0]
            if 'artist' in i:
                row = row + ' - ' + i['artist']
            self.playlist.append(row)
            #newRow = QListWidgetItem(row)
            #newRow.setBackground(backgroundColor)
            #newRow.setForeground(foregroundColor)
            #self.lw.addItem(newRow)
        self.visibleLw.addItems(self.playlist)
        self.visibleLw.setCurrentRow(0)
        
    def get_matches(self, pattern):
        self.visibleLw.clear()
        pattern = '.*' + pattern.replace(' ', '.*').lower()
        regexp = re.compile(pattern)
        for i in self.playlist:
            if regexp.match(i.lower()):
                self.visibleLw.addItem(i)                
                
    def formatScrollBar(self):            
        self.scrollBar.setMaximum(self.visibleLw.verticalScrollBar().maximum())                    
        self.scrollBar.setPageStep(self.visibleLw.verticalScrollBar().pageStep())
        
    def onChanged(self, text):
        self.get_matches(text)
        self.visibleLw.setCurrentRow(0)
        self.scrollBar.setMaximum(self.visibleLw.verticalScrollBar().maximum())        
        if self.visibleLw.verticalScrollBar().maximum() == 0:
            self.scrollBar.setVisible(False)
        else:
            self.scrollBar.setVisible(True)

    def onActivation(self):
        selected_song = self.visibleLw.currentItem().text()
        for i in range(0, len(self.playlist)):
            if selected_song == self.playlist[i]:
                self.client.connect('localhost', 6600)
                self.client.play(i)
                self.client.disconnect()       
        
    def keyPressEvent(self, e):
        if e.key() == Qt.Key_Down:
            self.visibleLw.setFocus()
        elif e.key() == Qt.Key_Escape:
            self.close()
Ejemplo n.º 4
0
class PreviewWidgetStyle(QGroupBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTitle(self.tr("Preview"))
        self.setMaximumHeight(220)
        self.setObjectName("groupBox")

        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = QTabWidget(self)
        self.tabWidget.setObjectName("tabWidgetPreview")

        self.tab = QWidget()
        self.tab.setObjectName("tab")

        self.horizontalLayout = QHBoxLayout(self.tab)
        self.horizontalLayout.setObjectName("horizontalLayout")

        self.groupBox = QGroupBox(self.tab)
        self.groupBox.setTitle(self.tr("Group Box"))
        self.groupBox.setObjectName("groupBox")

        self.verticalLayout_2 = QVBoxLayout(self.groupBox)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.radioButton = QRadioButton(self.groupBox)
        self.radioButton.setText(self.tr("Radio Button"))
        self.radioButton.setChecked(True)
        self.radioButton.setObjectName("radioButton")
        self.verticalLayout_2.addWidget(self.radioButton)

        self.radioButton_2 = QRadioButton(self.groupBox)
        self.radioButton_2.setText(self.tr("Radio Button"))
        self.radioButton_2.setObjectName("radioButton_2")
        self.verticalLayout_2.addWidget(self.radioButton_2)

        self.line = QFrame(self.groupBox)
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_2.addWidget(self.line)

        self.checkBox = QCheckBox(self.groupBox)
        self.checkBox.setText(self.tr("Check Box"))
        self.checkBox.setChecked(True)
        self.checkBox.setObjectName("checkBox")
        self.verticalLayout_2.addWidget(self.checkBox)

        self.horizontalLayout.addWidget(self.groupBox)

        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")

        self.progressBar = QProgressBar(self.tab)
        self.progressBar.setProperty("value", 75)
        self.progressBar.setObjectName("progressBar")
        self.verticalLayout_3.addWidget(self.progressBar)

        self.horizontalSlider = QSlider(self.tab)
        self.horizontalSlider.setProperty("value", 45)
        self.horizontalSlider.setSliderPosition(45)
        self.horizontalSlider.setOrientation(Qt.Horizontal)
        self.horizontalSlider.setObjectName("horizontalSlider")
        self.verticalLayout_3.addWidget(self.horizontalSlider)

        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")

        self.spinBox = QSpinBox(self.tab)
        self.spinBox.setObjectName("spinBox")
        self.horizontalLayout_2.addWidget(self.spinBox)

        self.pushButton = QPushButton(self.tab)
        self.pushButton.setText(self.tr("Button"))
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout_2.addWidget(self.pushButton)

        self.verticalLayout_3.addLayout(self.horizontalLayout_2)

        self.comboBox = QComboBox(self.tab)
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem(self.tr("Combo Box"))
        self.verticalLayout_3.addWidget(self.comboBox)

        self.horizontalLayout.addLayout(self.verticalLayout_3)

        self.verticalScrollBar = QScrollBar(self.tab)
        self.verticalScrollBar.setPageStep(50)
        self.verticalScrollBar.setOrientation(Qt.Vertical)
        self.verticalScrollBar.setObjectName("verticalScrollBar")
        self.horizontalLayout.addWidget(self.verticalScrollBar)
        self.tabWidget.addTab(self.tab, self.tr("Tab 1"))

        self.tab_2 = QWidget()
        self.tab_2.setObjectName("tab_2")
        self.tabWidget.addTab(self.tab_2, self.tr("Tab 2"))

        self.verticalLayout.addWidget(self.tabWidget)

        self.pushButton.installEventFilter(self)
        self.pushButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton.installEventFilter(self)
        self.radioButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton_2.installEventFilter(self)
        self.radioButton_2.setFocusPolicy(Qt.NoFocus)
        self.checkBox.installEventFilter(self)
        self.checkBox.setFocusPolicy(Qt.NoFocus)
        self.comboBox.installEventFilter(self)
        self.comboBox.setFocusPolicy(Qt.NoFocus)
        self.spinBox.installEventFilter(self)
        self.spinBox.setFocusPolicy(Qt.NoFocus)
        self.horizontalSlider.installEventFilter(self)
        self.horizontalSlider.setFocusPolicy(Qt.NoFocus)
        self.verticalScrollBar.installEventFilter(self)
        self.verticalScrollBar.setFocusPolicy(Qt.NoFocus)
        self.tab.installEventFilter(self)
        self.tab.setFocusPolicy(Qt.NoFocus)
        self.tab_2.installEventFilter(self)
        self.tab_2.setFocusPolicy(Qt.NoFocus)
        self.tabWidget.installEventFilter(self)
        self.tabWidget.setFocusPolicy(Qt.NoFocus)

        self.tabWidget.currentChanged.connect(self.noClick)

    def noClick(self, x):
        self.tabWidget.setCurrentIndex(0)

    def eventFilter(self, obj, event):
        if self.pushButton:
            if event.type() == QEvent.MouseButtonRelease:
                return True
            elif event.type() == QEvent.MouseButtonPress:
                return True
            elif event.type() == QEvent.MouseButtonDblClick:
                return True
            else:
                return False
        else:
            super().eventFilter(obj, event)
Ejemplo n.º 5
0
class PreviewWidgetStyle(QGroupBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTitle(self.tr("Preview"))
        self.setMaximumHeight(220)
        self.setObjectName("groupBox")

        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = QTabWidget(self)
        self.tabWidget.setObjectName("tabWidgetPreview")

        self.tab = QWidget()
        self.tab.setObjectName("tab")

        self.horizontalLayout = QHBoxLayout(self.tab)
        self.horizontalLayout.setObjectName("horizontalLayout")

        self.groupBox = QGroupBox(self.tab)
        self.groupBox.setTitle(self.tr("Group Box"))
        self.groupBox.setObjectName("groupBox")


        self.verticalLayout_2 = QVBoxLayout(self.groupBox)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.radioButton = QRadioButton(self.groupBox)
        self.radioButton.setText(self.tr("Radio Button"))
        self.radioButton.setChecked(True)
        self.radioButton.setObjectName("radioButton")
        self.verticalLayout_2.addWidget(self.radioButton)

        self.radioButton_2 = QRadioButton(self.groupBox)
        self.radioButton_2.setText(self.tr("Radio Button"))
        self.radioButton_2.setObjectName("radioButton_2")
        self.verticalLayout_2.addWidget(self.radioButton_2)

        self.line = QFrame(self.groupBox)
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_2.addWidget(self.line)

        self.checkBox = QCheckBox(self.groupBox)
        self.checkBox.setText(self.tr("Check Box"))
        self.checkBox.setChecked(True)
        self.checkBox.setObjectName("checkBox")
        self.verticalLayout_2.addWidget(self.checkBox)

        self.horizontalLayout.addWidget(self.groupBox)


        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")

        self.progressBar = QProgressBar(self.tab)
        self.progressBar.setProperty("value", 75)
        self.progressBar.setObjectName("progressBar")
        self.verticalLayout_3.addWidget(self.progressBar)

        self.horizontalSlider = QSlider(self.tab)
        self.horizontalSlider.setProperty("value", 45)
        self.horizontalSlider.setSliderPosition(45)
        self.horizontalSlider.setOrientation(Qt.Horizontal)
        self.horizontalSlider.setObjectName("horizontalSlider")
        self.verticalLayout_3.addWidget(self.horizontalSlider)

        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")

        self.spinBox = QSpinBox(self.tab)
        self.spinBox.setObjectName("spinBox")
        self.horizontalLayout_2.addWidget(self.spinBox)

        self.pushButton = QPushButton(self.tab)
        self.pushButton.setText(self.tr("Button"))
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout_2.addWidget(self.pushButton)

        self.verticalLayout_3.addLayout(self.horizontalLayout_2)

        self.comboBox = QComboBox(self.tab)
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem(self.tr("Combo Box"))
        self.verticalLayout_3.addWidget(self.comboBox)

        self.horizontalLayout.addLayout(self.verticalLayout_3)

        self.verticalScrollBar = QScrollBar(self.tab)
        self.verticalScrollBar.setPageStep(50)
        self.verticalScrollBar.setOrientation(Qt.Vertical)
        self.verticalScrollBar.setObjectName("verticalScrollBar")
        self.horizontalLayout.addWidget(self.verticalScrollBar)
        self.tabWidget.addTab(self.tab, self.tr("Tab 1"))


        self.tab_2 = QWidget()
        self.tab_2.setObjectName("tab_2")
        self.tabWidget.addTab(self.tab_2, self.tr("Tab 2"))

        self.verticalLayout.addWidget(self.tabWidget)

        self.pushButton.installEventFilter(self)
        self.pushButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton.installEventFilter(self)
        self.radioButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton_2.installEventFilter(self)
        self.radioButton_2.setFocusPolicy(Qt.NoFocus)
        self.checkBox.installEventFilter(self)
        self.checkBox.setFocusPolicy(Qt.NoFocus)
        self.comboBox.installEventFilter(self)
        self.comboBox.setFocusPolicy(Qt.NoFocus)
        self.spinBox.installEventFilter(self)
        self.spinBox.setFocusPolicy(Qt.NoFocus)
        self.horizontalSlider.installEventFilter(self)
        self.horizontalSlider.setFocusPolicy(Qt.NoFocus)
        self.verticalScrollBar.installEventFilter(self)
        self.verticalScrollBar.setFocusPolicy(Qt.NoFocus)
        self.tab.installEventFilter(self)
        self.tab.setFocusPolicy(Qt.NoFocus)
        self.tab_2.installEventFilter(self)
        self.tab_2.setFocusPolicy(Qt.NoFocus)
        self.tabWidget.installEventFilter(self)
        self.tabWidget.setFocusPolicy(Qt.NoFocus)

        self.tabWidget.currentChanged.connect(self.noClick)

    def noClick(self, x):
        self.tabWidget.setCurrentIndex(0)

    def eventFilter(self, obj, event):
        if self.pushButton:
            if event.type() == QEvent.MouseButtonRelease:
                return True
            elif event.type() == QEvent.MouseButtonPress:
                return True
            elif event.type() == QEvent.MouseButtonDblClick:
                return True
            else:
                return False
        else:
            super().eventFilter(obj, event)
Ejemplo n.º 6
0
class EditorMapComponent:

    current = None

    def __init__(self, tabbed=True, parent=None):
        EditorMapComponent.current = self

        self.workspace = Workspace()
        self.gc_state = GraphicContextState()

        if tabbed:
            self.tab_widget = QTabWidget(parent)
            self.widget = QWidget(self.tab_widget)
            self.tab_widget.addTab(self.widget, "A Label")
        else:
            self.tab_widget = None
            self.widget = QWidget(parent)

        self.layout = QGridLayout(self.widget)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setHorizontalSpacing(0)
        self.layout.setVerticalSpacing(0)

        self.scroll_horz = QScrollBar(Qt.Horizontal)
        self.scroll_vert = QScrollBar(Qt.Vertical)
        self.editormap_widget = EditorMapWidget(self, None)

        self.scroll_horz.valueChanged.connect(self.move_to_x)
        self.scroll_vert.valueChanged.connect(self.move_to_y)

        self.layout.addWidget(self.editormap_widget, 0, 0)
        self.layout.addWidget(self.scroll_horz, 1, 0)
        self.layout.addWidget(self.scroll_vert, 0, 1)

        self.sig_drop = Signal()
        self.editormap_widget.sig_drop.connect(self.on_drop)

    def on_drop(self, data, pos):
        """sends (brush, pos)"""
        brush_id = pickle.loads(data)
        brush = ObjectSelector.current.get_brush(brush_id)
        return self.sig_drop(brush, pos)

    def get_workspace(self):
        return self.workspace

    def grab_mouse(self):
        self.editormap_widget.grabMouse()

    def release_mouse(self):
        self.editormap_widget.releaseMouse()

    # ifdef GRUMBEL
    # void
    # EditorMapComponentImpl::on_key_down(const CL_InputEvent& event)
    # {
    #   if (event.id >= 0 && event.id < 256)
    #   {
    #     Rect rect = parent.get_position()
    #     key_bindings[event.id](CL_Mouse::get_x() - rect.left,
    #                            CL_Mouse::get_y() - rect.top)
    #   }

    #   if (event.repeat_count == 0)
    #   {
    #     Rect rect = parent.get_position()
    #     CL_InputEvent ev2 = event
    #     ev2.mouse_pos = Point(CL_Mouse::get_x() - rect.left,
    #                           CL_Mouse::get_y() - rect.top)
    #     workspace.key_down(InputEvent(ev2))
    #   }
    # }

    # void
    # EditorMapComponentImpl::on_key_up(const CL_InputEvent& event)
    # {
    #   Rect rect = parent.get_position()
    #   CL_InputEvent ev2 = event
    #   ev2.mouse_pos = Point(CL_Mouse::get_x() - rect.left,
    #                         CL_Mouse::get_y() - rect.top)
    #   workspace.key_up(InputEvent(ev2))
    # }

    # void
    # EditorMapComponentImpl::draw ()
    # {
    #   if (workspace.get_map().is_null()) return

    #   Display::push_cliprect(parent.get_screen_rect())

    #   Display::push_modelview()
    #   Display::add_translate(parent.get_screen_x(), parent.get_screen_y())

    #   // Update scrollbars (FIXME: move me to function)
    #   scrollbar_v.set_range(0, workspace.get_map().get_bounding_rect().height)
    #   scrollbar_v.set_pagesize(parent.height/gc_state.get_zoom())
    #   scrollbar_v.set_pos(gc_state.get_pos().y)

    #   scrollbar_h.set_range(0, workspace.get_map().get_bounding_rect().width)
    #   scrollbar_h.set_pagesize(parent.width/gc_state.get_zoom())
    #   scrollbar_h.set_pos(gc_state.get_pos().x)

    #   gc_state.push()
    #   {
    #     GraphicContext gc(gc_state, CL_Display::get_current_window().get_gc())
    #     workspace.draw(gc)
    #   }
    #   gc_state.pop()

    #   Display::pop_modelview()
    #   Display::pop_cliprect()
    # }
    # endif

    def screen2world(self, pos):
        return self.gc_state.screen2world(pos)

    def set_zoom(self, z):
        self.gc_state.set_zoom(z)

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def zoom_out(self, pos):
        self.gc_state.set_zoom(self.gc_state.get_zoom() / 1.25,
                               Pointf(pos.x, pos.y))

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def zoom_in(self, pos):
        self.gc_state.set_zoom(self.gc_state.get_zoom() * 1.25,
                               Pointf(pos.x, pos.y))

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def zoom_to(self, rect):
        self.gc_state.zoom_to(rect)

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def get_clip_rect(self):
        return self.gc_state.get_clip_rect()

    def move_to(self, x, y):
        self.gc_state.set_pos(Pointf(x, y))

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def move_to_x(self, x):

        self.gc_state.set_pos(Pointf(x, self.gc_state.get_pos().y))

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def move_to_y(self, y):
        self.gc_state.set_pos(Pointf(self.gc_state.get_pos().x, y))

        self.editormap_widget.repaint()
        self.update_scrollbars()

    def sig_on_key(self, keyseq_str):
        key_sequence = QKeySequence(keyseq_str)
        if key_sequence.isEmpty():
            raise RuntimeError("invalid key binding: '%s'" % keyseq_str)

        shortcut = QShortcut(key_sequence, self.editormap_widget)
        signal = Signal()

        def on_key(*args):
            pos = self.editormap_widget.mapFromGlobal(QCursor.pos())
            # pos = self.gc_state.screen2world(Point.from_qt(pos))
            signal(pos.x(), pos.y())

        shortcut.activated.connect(on_key)

        return signal

    def get_gc_state(self):
        return self.gc_state

    def get_widget(self):
        return self.tab_widget or self.widget

    def update_scrollbars(self):
        rect = self.workspace.get_map().get_bounding_rect()
        border = 128

        self.scroll_horz.setMinimum(rect.left - border)
        self.scroll_horz.setMaximum(rect.right + border)
        self.scroll_horz.setPageStep(self.editormap_widget.width())
        self.scroll_horz.setSliderPosition(int(self.gc_state.get_pos().x))

        self.scroll_vert.setMinimum(rect.top - border)
        self.scroll_vert.setMaximum(rect.bottom + border)
        self.scroll_vert.setPageStep(self.editormap_widget.height())
        self.scroll_vert.setSliderPosition(int(self.gc_state.get_pos().y))

    def set_sector_tab_label(self, index, text):
        self.tab_widget.setTabText(index, "Sector \"%s\"" % text)