Example #1
0
	def __init__(self, parent=None, showHitRects=False):
		self.keepActiveLook = False
		self._fake_disability = False
		self._hideBorder = None
		
		super().__init__(parent, showHitRects=showHitRects)
		
		# Set some default text, so we can see the widget.
		if not self.text():
			self.setText('Button')
		
		self.theme = theme('dark') #Gotta provide a default, both clickMarginColor and theme update style and both need to be set.
		self.clickMarginColor = f"rgba({randint(0, 32)}, {randint(0, 32)}, {randint(128, 255)}, {randint(32,96)})"
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		self.jogWheelLowResolutionRotation.connect(lambda delta, pressed: 
			not pressed and self.selectWidget(delta) )
		self.jogWheelClick.connect(lambda: self.injectKeystrokes(Qt.Key_Space))
		
		# Focus ring effect.
		self.jogWheelDown.connect(lambda: self.window().focusRing.focusIn(amount=.25)) #Small click effect.
		self.jogWheelUp.connect(lambda: self.window().focusRing.focusOut())
		self.jogWheelLongPress.connect(lambda: self.window().focusRing.focusOut(speed=.04))
		
		# Jog wheel highlight button on click effect.
		self.jogWheelDown.connect(lambda: (self.__setattr__('keepActiveLook', True), self.refreshStyle()))
		self.jogWheelUp.connect(lambda: (self.__setattr__('keepActiveLook', False), self.refreshStyle()))
		self.jogWheelLongPress.connect(lambda: (self.__setattr__('keepActiveLook', False), self.refreshStyle()))
		self.jogWheelCancel.connect(lambda: (self.__setattr__('keepActiveLook', False), self.refreshStyle()))
Example #2
0
	def __init__(self, parent=None, showHitRects=False):
		super().__init__(parent, showHitRects=showHitRects)
		
		self.theme = theme('dark')
		self.clickMarginColor = f"rgba({randint(128, 255)}, {randint(0, 32)}, {randint(0, 32)}, {randint(32,96)})"
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		def onLowResRotate(delta, pressed):
			if pressed:
				self.injectKeystrokes(Qt.Key_Up if delta < 0 else Qt.Key_Down)
			else:
				self.selectWidget(delta)
		self.jogWheelLowResolutionRotation.connect(onLowResRotate)
		
		self.jogWheelClick.connect(lambda: self.injectKeystrokes(Qt.Key_Space))
		
		#Set up the custom list view (larger, accepts tap etc)
		self.dropdown = ScrollList()
		self.setView(self.dropdown)
		
		self.__nativeDropdownSize = None
Example #3
0
	def __init__(self, parent=None, showHitRects=False):
		super().__init__(parent, showHitRects=showHitRects)
		
		self.setCorrectionMode(self.CorrectToNearestValue)
		
		self.theme = theme('dark')
		self.clickMarginColor = f"rgba({randint(0, 32)}, {randint(128, 255)}, {randint(128, 255)}, {randint(32,96)})"
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		self.isFocused = False
		self.inputMode = '' #Set to empty, 'jogWheel', or 'touch'. Used for defocus event handling behaviour.
		
		self.jogWheelClick.connect(self.jogWheelClicked)
		self.jogWheelLowResolutionRotation.connect(self.onLowResRotate)
		
		self.touchEnd.connect(self.editTapped)
		self.findChild(QLineEdit).installEventFilter(self) #Make touchEnd fire when our sub-edit is tapped. Otherwise, the keyboard only opens when the touch margins are tapped. The event filter itself is inherited from FocusablePlugin.
		self.doneEditing.connect(self.doneEditingCallback)
		
		#When we tap an input, we deselect selected text. But we want to
		#select all text. So, select it again after we've tapped it. Note:
		#This only applies if the keyboard hasn't bumped the text out of the
		#way first.
		self.selectAllTimer = QTimer()
		self.selectAllTimer.timeout.connect(self.selectAll)
		self.selectAllTimer.setSingleShot(True)
		
		valueChangedTap = signalTap(lambda val:
			(val * self.unitValue[self.siUnit],) )
		self.valueChanged.connect(valueChangedTap.emit)
		self.valueChanged = valueChangedTap
Example #4
0
	def __init__(self, parent=None, showHitRects=False):
		super().__init__(parent)
		self.theme = theme('dark') #Gotta provide a default, both clickMarginColor and theme update style and both need to be set.
		self._customStyleSheet = self.styleSheet() #always '' for some reason
		self._showHitRects = showHitRects
		self.refreshStyle()
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
Example #5
0
	def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		
		self.setAttribute(Qt.WA_TransparentForMouseEvents)
		self.setFocusPolicy(Qt.NoFocus)
		
		self._paddingMultiplier = 1
		self._paddingMultiplierDelta = .1 #Set later.
		self._paddingMinMultiplier = 0.
		self._paddingMaxMultiplier = 1.
		self._currentPadding = self.unfocussedPadding
		self.isFocussedIn = False
		self._focussedOn = None
		
		self.focusInOutTimer = QTimer()
		self.focusInOutTimer.timeout.connect(self._updateFocusRingPadding)
		self.focusInOutTimer.setInterval(16)
		
		self.theme = None
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyleSheet(self._currentPadding)
		))
		
		self.hide()
		def __init__(self, parent, severity, timeout, message):
			super().__init__(parent)
			self.severity = severity
			self.laidOut = False
			
			self.theme = theme('dark')
			settings.observe('theme', 'dark', lambda name: (
				setattr(self, 'theme', theme(name)),
				self.refreshStyle(),
			))
			
			if timeout > 0:
				QTimer.singleShot(timeout * 1000, self.timedOut.emit)
			
			self.setText(severity + ': ' + message)
			self.show()
Example #7
0
	def __init__(self, parent=None, showHitRects=False):
		self.keepActiveLook = False

		super().__init__(parent, showHitRects=showHitRects)
		
		self.hintList = []
		
		# Set some default text, so we can see the widget.
		if not self.text():
			self.setText('text input')
		
		self.setCursorMoveStyle(Qt.LogicalMoveStyle) #Left moves left, right moves right. Defaults is right arrow key moves left under rtl writing systems.
		
		self.theme = theme('dark')
		self.clickMarginColor = f"rgba({randint(128, 255)}, {randint(64, 128)}, {randint(0, 32)}, {randint(32,96)})"
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		if self.isClearButtonEnabled():
			clearButton = self.findChild(QToolButton)
			clearButtonGeom = clearButton.geometry()
			clearButtonGeom.moveLeft(clearButtonGeom.left() - self.touchMargins['left'])
			clearButton.setGeometry(clearButtonGeom)
		
		self.inputMode = '' #Set to empty, 'jogWheel', or 'touch'. Used for defocus event handling behaviour.
		
		self.jogWheelLowResolutionRotation.connect(self.handleJogWheelRotation)
		self.jogWheelClick.connect(self.jogWheelClicked)
		
		self.touchEnd.connect(self.editTapped)
		
		self.doneEditing.connect(self.doneEditingCallback)
		
		#When we tap an input, we deselect selected text. But we want to
		#select all text. So, select it again after we've tapped it.
		#Note: This only applies if the keyboard hasn't bumped the text
		#out of the way first.
		self.selectAllTimer = QTimer()
		self.selectAllTimer.timeout.connect(self.selectAll)
		self.selectAllTimer.setSingleShot(True)
		
		delay(self, 0, #Must be delayed until after creation for isClearButtonEnabled to be set.
			self.__hackMoveClearButtonToCompensateForIncreasedMargin )
Example #8
0
	def __init__(self, parent=None, showHitRects=False):
		super().__init__(parent)
		
		self.setAttribute(Qt.WA_OpaquePaintEvent, True)
		
		self.theme = theme('dark')
		self.showHitRects = showHitRects
		
		self.clickMarginColorSlider = f"rgba({randint(0, 32)}, {randint(128, 255)}, {randint(0, 32)}, {randint(32,96)})"
		self.clickMarginColorHandle = f"rgba({randint(0, 32)}, {randint(128, 255)}, {randint(0, 32)}, {randint(32,96)})"
		
		self.baseStyleSheet = self.styleSheet()
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		self.isFocused = False
		self.jogWheelClick.connect(self.toggleFocussed)
		self.jogWheelLowResolutionRotation.connect(self.onLowResRotate)
		
		self.debounce = Slider.Debounce()
		
		self._userGeneratedEvent = False #Set to true when sliderMoved happens.
		def updateUserGeneratedEvent():
			self._userGeneratedEvent = True
		self.sliderMoved.connect(updateUserGeneratedEvent)
		
		self.beingHeld = False #Set to true when sliderMoved happens.
		def tapPressed():
			self.beingHeld = True
		self.sliderPressed.connect(tapPressed)
		def tapReleased():
			self.beingHeld = False
		self.sliderReleased.connect(tapReleased)
		
		self.__lastValue = self.value()
		self._fpsMonitorLastFrame = time.perf_counter()
		
		self.setContentsMargins(30, 10, 30, 10) #rough guess, good enough?
		
		#Move the focus ring with the slider.
		self.rangeChanged.connect(self.tryRefocus)
		self.focusGeometryNudge = (0,0,0,0) #xywh tuple to move the focus ring to be aligned. Different sliders have different nudges, and I can't figure out why.
		def setZoomLabelStyle(name):
			theme_ = theme(name)
			self.zoomLabel.setStyleSheet(f"""
				color: {theme_.text};
				background-color: {theme_.interactiveVideoArea.chickletBackground};
				border: 1px solid {theme_.border};
				margin: 10px 5px;
				padding: 5px 10px;
				border-radius: 17px;
			""")
Example #10
0
	def __init__(self, parent=None, showHitRects=False):
		super().__init__(parent, showHitRects=showHitRects)
		
		self.theme = theme('dark')
		self._clickMarginRight = MarginWidth.none
		self.clickMarginColor = f"rgba({randint(128, 255)}, {randint(128, 255)}, {randint(0, 32)}, {randint(32,96)})"
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		self.jogWheelLowResolutionRotation.connect(lambda delta, pressed: 
			not pressed and self.selectWidget(delta) )
		self.jogWheelClick.connect(lambda: self.injectKeystrokes(Qt.Key_Space))
		
		# Focus ring effect.
		self.jogWheelDown.connect(lambda: self.window().focusRing.focusIn(amount=.25)) #Small click effect.
		self.jogWheelUp.connect(lambda: self.window().focusRing.focusOut())
		self.jogWheelLongPress.connect(lambda: self.window().focusRing.focusOut(speed=.04))
Example #11
0
	def __init__(self, parent=None, showHitRects=False):
		super().__init__(parent)
		
		self.theme = theme('dark')
		self._customStyleSheet = ''
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		self.setWordWrap(True)
		self.setAlignment(Qt.AlignTop | Qt.AlignLeft)
		
		# Set some default text, so we can see the widget.
		if not self.text():
			self.showError('«error message will go here»')
		
		if not showHitRects:
			self.hide()
			
		self._hideMessageTimer = QTimer()
		self._hideMessageTimer.timeout.connect(self.hide)
Example #12
0
	def __init__(self, parent=None):
		super().__init__(parent)
		self._customStyleSheet = ''
		self._useInlineSelectMode = False
		self.setStyle(QStyleFactory.create('Fusion')) #Fix bug where scrollbar background is stippled.
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		#Set up scroll on jogwheel.
		self.setMouseTracking(False) #Something do do with the scroller?
		self.setUniformItemSizes(True) #This enables the view to do some optimizations for performance purposes.
		self.setHorizontalScrollMode(self.ScrollPerPixel) #Make grab gesture work, otherwise moves dropdown 1 entry per pixel dragged.
		self.setVerticalScrollMode(self.ScrollPerPixel)
		self.setAttribute(Qt.WA_AcceptTouchEvents, True) #Enable touch gestures according to http://doc.qt.io/qt-5/qtouchevent.html#enabling-touch-events, which appears to be lieing.
		self.setDragDropMode(self.NoDragDrop)
		self.setMovement(self.Static)
		
		#Only works in Qt ≥ v5.10.
		#self.jogWheelClick.connect(lambda: self.injectKeystrokes(Qt.Key_Enter))
		
		self.jogWheelClick.connect(self.onJogWheelClick)
		self.jogWheelLowResolutionRotation.connect(self.onJogWheelRotate)
		
		#Add drag-to-scroll to dropdown menus.
		QScroller.grabGesture(self.viewport(), QScroller.LeftMouseButtonGesture) #DDR 2019-01-15: Defaults to TouchGesture - which should work, according to WA_AcceptTouchEvents, but doesn't.
		scroller = QScroller.scroller(self.viewport())
		properties = scroller.scrollerProperties()
		properties.setScrollMetric(properties.AxisLockThreshold, 0.0)
		properties.setScrollMetric(properties.DragStartDistance, 0.010) #default: 0.005 - Set to 0.010, since if the scroll starts horizontally it goes into a weird selection mode. Initially tweaked for "feel" to 0.003, before knowledge of this issue.
		properties.setScrollMetric(properties.OvershootDragDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollTime, 0.5) #default: 0.7
		scroller.setScrollerProperties(properties)
Example #13
0
    def __init__ (self, workgroup, parent, attribs = None, id = wx.ID_ANY \
                  , pos=wx.DefaultPosition, size=wx.Size(400,400) \
                 , theme=theme()):
        if not attribs:
            attribs = [WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24]
        frame = wx.Frame(parent = parent, id = wx.ID_ANY,
                    title="Viewer",
                    pos = pos, size = size)
        GLCanvas.__init__(self, frame, id, attribList = attribs)
        self.context = GLContext(self)
        self.frame = frame
        self.WorkGroup = workgroup
        self.init   = False
        self.width  = 0
        self.height = 0
        self._theme = theme
        # Display event handlers
        self.Bind(wx.EVT_PAINT      , self.OnPaint)
        self.Bind(wx.EVT_SIZE       , self.OnSize)
        # Mouse handlers
        self.Bind(wx.EVT_MOUSEWHEEL , self.OnMouseWheel)
        self.Bind(wx.EVT_LEFT_DOWN  , self.OnMouseLeftDown)
        self.Bind(wx.EVT_LEFT_UP    , self.OnMouseLeftUp)
        self.Bind(wx.EVT_MOTION     , self.OnMouseMotion)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightMouseClick)
        # keyboard handlers
        self.Bind(wx.EVT_CHAR       , self.key)
        self.Bind(wx.EVT_KEY_DOWN   , self.onKeyPressDown)
        self.Bind(wx.EVT_KEY_UP     , self.onKeyPressUp)

        # viewer 2D or 3D mode
        self.active2D = True
        # show/hide  grid
        self.showGrid = False
        # the grid can be drawn as lines or points
        self.showGridLines = True

        # steps used for mesh Evaluator
        self.evaluator_steps            = [2,2,2]

        # Wheel sensitivity used for Zoom
        self.WheelSensitivity = 0.5
        # TODO must be updated when zooming
        self.unit = 3.

        # cutCurveFreq used for the frequency sampling when moving the cursor
        self.cutCurveFreq   = 5
        self.CutCurvePoints = []

        # handles viewer eye/...
        self.lookAt = LookAt()

        # initial mouse position
        self.lastx = self.x = 30
        self.lasty = self.y = 30

        # used for the 2D grid
        self.rowmin = -5. ; self.rowmax = 5.
        self.colmin = -5. ; self.colmax = 5.
        self.hx = 1.; self.hy = 1.

        # used for selection mode
        self.cornerx = None
        self.cornery = None

        # Data Selection
        self.EnabledSelectionMode = False
        # Look At => define a viewing transformation
        self.EnabledLookAtMode = False
        # Marker points
        self.EnabledMarkerMode = False
        # EnabledLookAtModeID = 0 ==> update center position
        # EnabledLookAtModeID = 1 ==> update the up vector
        # Otherwise ==> nothing to do
        self.EnabledLookAtModeID = -1

        # cut Curve Mode
        self.EnabledCutCurveMode = False

        # contains the list of marker points, picked directly on the viewer
        # TODO use numpy array rather than a list
        self.MarkerPoints = []
        self.fixMarkers = False
        # contains the list of selected points, picked directly on the viewer
        # list_SelectedPoints is a list of SelectedPoints class
        self.list_SelectedPoints = []

        self.SetFocus()

        self.statusbar = self.frame.CreateStatusBar()
        self.statusbar.SetStatusText('Ready')

        self.menu_titles = ["2D view", "3D view" \
                            , "Show Grid", "Hide Grid"\
                            , "Grid as Points", "Grid as Lines"\
                            , "Clear Markers", "Clear Selected Points" \
                            , "Fixed Markers", "Floating Markers"\
                            , "Add Marker"\
                            , "Import Markers"\
                            , "Export Markers"\
                            , "Print", "Preferences" ]

        self.menu_title_by_id = {}
        for title in self.menu_titles:
            self.menu_title_by_id[ wx.NewId() ] = title
Example #14
0
                'fontStyle': 'italic'
            },
            # gitgutter colors.
            {
                'name': 'gitgutter deleted',
                'scope': 'markup.deleted.git_gutter',
                'foreground': scarlet_red.medium,
            },
            {
                'name': 'gitgutter inserted',
                'scope': 'markup.inserted.git_gutter',
                'foreground': chameleon.medium,
            },
            {
                'name': 'gitgutter changed',
                'scope': 'markup.changed.git_gutter',
                'foreground': butter.medium,
            },
        ],
    }

    output = theme(style)

    # with open('tamriel.tmTheme', 'w+') as theme_file:
    #     theme_file.write(output)


    from zipfile import ZipFile
    with ZipFile('tamriel.sublime-package', 'w') as fo:
        fo.writestr('tamriel.tmTheme', output.encode('utf-8'))
Example #15
0
import sys
from mainwindow import *
from theme import theme

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app = theme(app)

    wnd = MainWindow()

    wnd.show()

    app.exec_()
Example #16
0
def test_1():
    roleinfos=theme().login()
    assert roleinfos == u"区域用户"
Example #17
0
    def __init__ (self, workgroup, parent, attribs = None, id = wx.ID_ANY \
                  , pos=wx.DefaultPosition, size=wx.Size(400,400) \
                 , theme=theme()):
        if not attribs:
            attribs = [WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24]
        frame = wx.Frame(parent = parent, id = wx.ID_ANY,
                    title="Viewer",
                    pos = pos, size = size)
        GLCanvas.__init__(self, frame, id, attribList = attribs)
        self.context = GLContext(self)
        self.frame = frame
        self.WorkGroup = workgroup
        self.init   = False
        self.width  = 0
        self.height = 0
        self._theme = theme
        # Display event handlers
        self.Bind(wx.EVT_PAINT      , self.OnPaint)
        self.Bind(wx.EVT_SIZE       , self.OnSize)
        # Mouse handlers
        self.Bind(wx.EVT_MOUSEWHEEL , self.OnMouseWheel)
        self.Bind(wx.EVT_LEFT_DOWN  , self.OnMouseLeftDown)
        self.Bind(wx.EVT_LEFT_UP    , self.OnMouseLeftUp)
        self.Bind(wx.EVT_MOTION     , self.OnMouseMotion)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightMouseClick)
        # keyboard handlers
        self.Bind(wx.EVT_CHAR       , self.key)
        self.Bind(wx.EVT_KEY_DOWN   , self.onKeyPressDown)
        self.Bind(wx.EVT_KEY_UP     , self.onKeyPressUp)

        # viewer 2D or 3D mode
        self.active2D = True
        # show/hide  grid
        self.showGrid = False
        # the grid can be drawn as lines or points
        self.showGridLines = True

        # steps used for mesh Evaluator
        self.evaluator_steps            = [2,2,2]

        # Wheel sensitivity used for Zoom
        self.WheelSensitivity = 0.5
        # TODO must be updated when zooming
        self.unit = 3.

        # cutCurveFreq used for the frequency sampling when moving the cursor
        self.cutCurveFreq   = 5
        self.CutCurvePoints = []

        # handles viewer eye/...
        self.lookAt = LookAt()

        # initial mouse position
        self.lastx = self.x = 30
        self.lasty = self.y = 30

        # used for the 2D grid
        self.rowmin = -5. ; self.rowmax = 5.
        self.colmin = -5. ; self.colmax = 5.
        self.hx = 1.; self.hy = 1.

        # used for selection mode
        self.cornerx = None
        self.cornery = None

        # Data Selection
        self.EnabledSelectionMode = False
        # Look At => define a viewing transformation
        self.EnabledLookAtMode = False
        # Marker points
        self.EnabledMarkerMode = False
        # EnabledLookAtModeID = 0 ==> update center position
        # EnabledLookAtModeID = 1 ==> update the up vector
        # Otherwise ==> nothing to do
        self.EnabledLookAtModeID = -1

        # cut Curve Mode
        self.EnabledCutCurveMode = False

        # contains the list of marker points, picked directly on the viewer
        # TODO use numpy array rather than a list
        self.MarkerPoints = []
        self.fixMarkers = False
        # contains the list of selected points, picked directly on the viewer
        # list_SelectedPoints is a list of SelectedPoints class
        self.list_SelectedPoints = []

        self.SetFocus()

        self.statusbar = self.frame.CreateStatusBar()
        self.statusbar.SetStatusText('Ready')

        self.menu_titles = ["2D view", "3D view" \
                            , "Show Grid", "Hide Grid"\
                            , "Grid as Points", "Grid as Lines"\
                            , "Clear Markers", "Clear Selected Points" \
                            , "Fixed Markers", "Floating Markers"\
                            , "Add Marker"\
                            , "Import Markers"\
                            , "Export Markers"\
                            , "Print", "Preferences" ]

        self.menu_title_by_id = {}
        for title in self.menu_titles:
            self.menu_title_by_id[ wx.NewId() ] = title