update pyglet
This commit is contained in:
parent
c79a0dbbb4
commit
76d591f2d9
@ -44,11 +44,14 @@ import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
#: The release version
|
||||
version = '2.0.dev20'
|
||||
version = '2.0.dev22'
|
||||
__version__ = version
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
raise Exception('pyglet %s requires Python 3.6 or newer.' % version)
|
||||
MIN_PYTHON_VERSION = 3, 7
|
||||
MIN_PYTHON_VERSION_STR = '.'.join([str(v) for v in MIN_PYTHON_VERSION])
|
||||
|
||||
if sys.version_info < MIN_PYTHON_VERSION:
|
||||
raise Exception(f"pyglet {version} requires Python {MIN_PYTHON_VERSION_STR} or newer.")
|
||||
|
||||
if 'sphinx' in sys.modules:
|
||||
setattr(sys, 'is_pyglet_doc_run', True)
|
||||
|
@ -65,11 +65,13 @@ class Win32Screen(Screen):
|
||||
self._handle = handle
|
||||
|
||||
def get_matching_configs(self, template):
|
||||
canvas = Win32Canvas(self.display, 0, _user32.GetDC(0))
|
||||
hdc = _user32.GetDC(0)
|
||||
canvas = Win32Canvas(self.display, 0, hdc)
|
||||
configs = template.match(canvas)
|
||||
# XXX deprecate config's being screen-specific
|
||||
for config in configs:
|
||||
config.screen = self
|
||||
_user32.ReleaseDC(0, hdc)
|
||||
return configs
|
||||
|
||||
def get_device_name(self):
|
||||
|
@ -35,6 +35,7 @@ except OSError as err:
|
||||
|
||||
_debug_font = debug_print('debug_font')
|
||||
|
||||
|
||||
def DWRITE_MAKE_OPENTYPE_TAG(a, b, c, d):
|
||||
return ord(d) << 24 | ord(c) << 16 | ord(b) << 8 | ord(a)
|
||||
|
||||
@ -121,13 +122,13 @@ DWRITE_MEASURING_MODE_GDI_CLASSIC = 1
|
||||
DWRITE_MEASURING_MODE_GDI_NATURAL = 2
|
||||
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_ALL = DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_CFF | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_COLR | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_SVG | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_PNG | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_JPEG | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_TIFF | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_CFF | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_COLR | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_SVG | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_PNG | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_JPEG | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_TIFF | \
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8
|
||||
|
||||
DWRITE_FONT_STYLE = UINT
|
||||
DWRITE_FONT_STYLE_NORMAL = 0
|
||||
@ -171,8 +172,6 @@ class D2D1_COLOR_F(Structure):
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
class DWRITE_TEXT_METRICS(ctypes.Structure):
|
||||
_fields_ = (
|
||||
('left', FLOAT),
|
||||
@ -316,6 +315,7 @@ class DWRITE_GLYPH_RUN(ctypes.Structure):
|
||||
('bidiLevel', UINT32),
|
||||
)
|
||||
|
||||
|
||||
DWRITE_SCRIPT_SHAPES = UINT
|
||||
DWRITE_SCRIPT_SHAPES_DEFAULT = 0
|
||||
|
||||
@ -1061,6 +1061,21 @@ class LegacyCollectionLoader(com.COMObject):
|
||||
IID_IDWriteFactory = com.GUID(0xb859ee5a, 0xd838, 0x4b5b, 0xa2, 0xe8, 0x1a, 0xdc, 0x7d, 0x93, 0xdb, 0x48)
|
||||
|
||||
|
||||
class IDWriteRenderingParams(com.pIUnknown):
|
||||
_methods_ = [
|
||||
('GetGamma',
|
||||
com.METHOD(FLOAT)),
|
||||
('GetEnhancedContrast',
|
||||
com.METHOD(FLOAT)),
|
||||
('GetClearTypeLevel',
|
||||
com.METHOD(FLOAT)),
|
||||
('GetPixelGeometry',
|
||||
com.METHOD(UINT)),
|
||||
('GetRenderingMode',
|
||||
com.METHOD(UINT)),
|
||||
]
|
||||
|
||||
|
||||
class IDWriteFactory(com.pIUnknown):
|
||||
_methods_ = [
|
||||
('GetSystemFontCollection',
|
||||
@ -1078,11 +1093,11 @@ class IDWriteFactory(com.pIUnknown):
|
||||
('CreateFontFace',
|
||||
com.STDMETHOD()),
|
||||
('CreateRenderingParams',
|
||||
com.STDMETHOD()),
|
||||
com.STDMETHOD(POINTER(IDWriteRenderingParams))),
|
||||
('CreateMonitorRenderingParams',
|
||||
com.STDMETHOD()),
|
||||
('CreateCustomRenderingParams',
|
||||
com.STDMETHOD()),
|
||||
com.STDMETHOD(FLOAT, FLOAT, FLOAT, UINT, UINT, POINTER(IDWriteRenderingParams))),
|
||||
('RegisterFontFileLoader',
|
||||
com.STDMETHOD(c_void_p)), # Ambigious as newer is a pIUnknown and legacy is IUnknown.
|
||||
('UnregisterFontFileLoader',
|
||||
@ -1116,7 +1131,7 @@ class IDWriteFactory1(IDWriteFactory, com.pIUnknown):
|
||||
_methods_ = [
|
||||
('GetEudcFontCollection',
|
||||
com.STDMETHOD()),
|
||||
('CreateCustomRenderingParams',
|
||||
('CreateCustomRenderingParams1',
|
||||
com.STDMETHOD()),
|
||||
]
|
||||
|
||||
@ -1139,7 +1154,7 @@ class IDWriteFactory2(IDWriteFactory1, com.pIUnknown):
|
||||
com.STDMETHOD()),
|
||||
('TranslateColorGlyphRun',
|
||||
com.STDMETHOD()),
|
||||
('CreateCustomRenderingParams',
|
||||
('CreateCustomRenderingParams2',
|
||||
com.STDMETHOD()),
|
||||
('CreateGlyphRunAnalysis',
|
||||
com.STDMETHOD()),
|
||||
@ -1191,7 +1206,7 @@ class IDWriteFactory3(IDWriteFactory2, com.pIUnknown):
|
||||
_methods_ = [
|
||||
('CreateGlyphRunAnalysis',
|
||||
com.STDMETHOD()),
|
||||
('CreateCustomRenderingParams',
|
||||
('CreateCustomRenderingParams3',
|
||||
com.STDMETHOD()),
|
||||
('CreateFontFaceReference',
|
||||
com.STDMETHOD()),
|
||||
@ -1207,7 +1222,7 @@ class IDWriteFactory3(IDWriteFactory2, com.pIUnknown):
|
||||
com.STDMETHOD()),
|
||||
('GetFontDownloadQueue',
|
||||
com.STDMETHOD()),
|
||||
#('GetSystemFontSet',
|
||||
# ('GetSystemFontSet',
|
||||
# com.STDMETHOD()),
|
||||
]
|
||||
|
||||
@ -1220,10 +1235,12 @@ class IDWriteColorGlyphRunEnumerator1(com.pIUnknown):
|
||||
com.STDMETHOD()),
|
||||
]
|
||||
|
||||
|
||||
class IDWriteFactory4(IDWriteFactory3, com.pIUnknown):
|
||||
_methods_ = [
|
||||
('TranslateColorGlyphRun4', # Renamed to prevent clash from previous factories.
|
||||
com.STDMETHOD(D2D_POINT_2F, DWRITE_GLYPH_RUN, c_void_p, DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_MEASURING_MODE, c_void_p, UINT32, POINTER(IDWriteColorGlyphRunEnumerator1))),
|
||||
com.STDMETHOD(D2D_POINT_2F, DWRITE_GLYPH_RUN, c_void_p, DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_MEASURING_MODE,
|
||||
c_void_p, UINT32, POINTER(IDWriteColorGlyphRunEnumerator1))),
|
||||
('ComputeGlyphOrigins_',
|
||||
com.STDMETHOD()),
|
||||
('ComputeGlyphOrigins',
|
||||
@ -1259,7 +1276,6 @@ class IDWriteFactory5(IDWriteFactory4, IDWriteFactory3, IDWriteFactory2, IDWrite
|
||||
]
|
||||
|
||||
|
||||
|
||||
DWriteCreateFactory = dwrite_lib.DWriteCreateFactory
|
||||
DWriteCreateFactory.restype = HRESULT
|
||||
DWriteCreateFactory.argtypes = [DWRITE_FACTORY_TYPE, com.REFIID, POINTER(com.pIUnknown)]
|
||||
@ -1424,7 +1440,7 @@ class ID2D1RenderTarget(ID2D1Resource, com.pIUnknown):
|
||||
('GetTransform',
|
||||
com.STDMETHOD()),
|
||||
('SetAntialiasMode',
|
||||
com.STDMETHOD()),
|
||||
com.METHOD(c_void, D2D1_TEXT_ANTIALIAS_MODE)),
|
||||
('GetAntialiasMode',
|
||||
com.STDMETHOD()),
|
||||
('SetTextAntialiasMode',
|
||||
@ -1432,7 +1448,7 @@ class ID2D1RenderTarget(ID2D1Resource, com.pIUnknown):
|
||||
('GetTextAntialiasMode',
|
||||
com.STDMETHOD()),
|
||||
('SetTextRenderingParams',
|
||||
com.STDMETHOD()),
|
||||
com.STDMETHOD(IDWriteRenderingParams)),
|
||||
('GetTextRenderingParams',
|
||||
com.STDMETHOD()),
|
||||
('SetTags',
|
||||
@ -1444,7 +1460,7 @@ class ID2D1RenderTarget(ID2D1Resource, com.pIUnknown):
|
||||
('PopLayer',
|
||||
com.STDMETHOD()),
|
||||
('Flush',
|
||||
com.STDMETHOD()),
|
||||
com.STDMETHOD(c_void_p, c_void_p)),
|
||||
('SaveDrawingState',
|
||||
com.STDMETHOD()),
|
||||
('RestoreDrawingState',
|
||||
@ -1535,6 +1551,7 @@ if not wic_decoder:
|
||||
class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
antialias_mode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT
|
||||
draw_options = D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT
|
||||
measuring_mode = DWRITE_MEASURING_MODE_NATURAL
|
||||
|
||||
def __init__(self, font):
|
||||
self._render_target = None
|
||||
@ -1679,7 +1696,6 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
font_face.GetDesignGlyphMetrics(indices, count, glyph_metrics, False)
|
||||
|
||||
metrics_out = []
|
||||
i = 0
|
||||
for metric in glyph_metrics:
|
||||
glyph_width = (metric.advanceWidth - metric.leftSideBearing - metric.rightSideBearing)
|
||||
|
||||
@ -1696,7 +1712,6 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
advance_width = metric.advanceWidth
|
||||
|
||||
metrics_out.append((glyph_width, glyph_height, lsb, advance_width, bsb))
|
||||
i += 1
|
||||
|
||||
return metrics_out
|
||||
|
||||
@ -1721,7 +1736,7 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
run,
|
||||
None,
|
||||
DWRITE_GLYPH_IMAGE_FORMATS_ALL,
|
||||
DWRITE_MEASURING_MODE_NATURAL,
|
||||
self.measuring_mode,
|
||||
None,
|
||||
0,
|
||||
enumerator)
|
||||
@ -1735,7 +1750,7 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
|
||||
def render_single_glyph(self, font_face, indice, advance, offset, metrics):
|
||||
"""Renders a single glyph using D2D DrawGlyphRun"""
|
||||
glyph_width, glyph_height, lsb, font_advance, bsb = metrics # We use a shaped advance instead of the fonts.
|
||||
glyph_width, glyph_height, glyph_lsb, glyph_advance, glyph_bsb = metrics # We use a shaped advance instead of the fonts.
|
||||
|
||||
# Slicing an array turns it into a python object. Maybe a better way to keep it a ctypes value?
|
||||
new_indice = (UINT16 * 1)(indice)
|
||||
@ -1748,19 +1763,24 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
new_advance, # advance,
|
||||
pointer(offset), # offset,
|
||||
False,
|
||||
False
|
||||
0
|
||||
)
|
||||
|
||||
# If it's colored, return to render it using layout.
|
||||
if self.draw_options & D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT and self.is_color_run(run):
|
||||
return None
|
||||
|
||||
render_width = int(math.ceil((glyph_width) * self.font.font_scale_ratio))
|
||||
render_offset_x = int(math.floor(abs(lsb * self.font.font_scale_ratio)))
|
||||
if lsb < 0:
|
||||
# Negative LSB: we shift the layout rect to the right
|
||||
# Otherwise we will cut the left part of the glyph
|
||||
render_offset_x = -(render_offset_x)
|
||||
# Use the glyph's advance as a width as bitmap width.
|
||||
# Some characters such as diacritics (̃) may have 0 advance width. In that case, just use glyph_width
|
||||
if glyph_advance:
|
||||
render_width = int(math.ceil(glyph_advance * self.font.font_scale_ratio))
|
||||
else:
|
||||
render_width = int(math.ceil(glyph_width * self.font.font_scale_ratio))
|
||||
|
||||
render_offset_x = 0
|
||||
if glyph_lsb < 0:
|
||||
# Negative LSB: we shift the offset, otherwise the glyph will be cut off.
|
||||
render_offset_x = glyph_lsb * self.font.font_scale_ratio
|
||||
|
||||
# Create new bitmap.
|
||||
# TODO: We can probably adjust bitmap/baseline to reduce the whitespace and save a lot of texture space.
|
||||
@ -1769,11 +1789,9 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
int(math.ceil(self.font.max_glyph_height)))
|
||||
|
||||
# Glyphs are drawn at the baseline, and with LSB, so we need to offset it based on top left position.
|
||||
# Offsets are actually based on pixels somehow???
|
||||
baseline_offset = D2D_POINT_2F(-render_offset_x - offset.advanceOffset,
|
||||
self.font.ascent + offset.ascenderOffset)
|
||||
|
||||
|
||||
self._render_target.BeginDraw()
|
||||
|
||||
self._render_target.Clear(transparent)
|
||||
@ -1781,17 +1799,17 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
self._render_target.DrawGlyphRun(baseline_offset,
|
||||
run,
|
||||
self._brush,
|
||||
DWRITE_MEASURING_MODE_NATURAL)
|
||||
self.measuring_mode)
|
||||
|
||||
self._render_target.EndDraw(None, None)
|
||||
image = wic_decoder.get_image(self._bitmap)
|
||||
|
||||
glyph = self.font.create_glyph(image)
|
||||
|
||||
glyph.set_bearings(self.font.descent, render_offset_x,
|
||||
advance * self.font.font_scale_ratio,
|
||||
offset.advanceOffset * self.font.font_scale_ratio,
|
||||
offset.ascenderOffset * self.font.font_scale_ratio)
|
||||
glyph.set_bearings(-self.font.descent, render_offset_x,
|
||||
advance,
|
||||
offset.advanceOffset,
|
||||
offset.ascenderOffset)
|
||||
|
||||
return glyph
|
||||
|
||||
@ -1829,7 +1847,17 @@ class DirectWriteGlyphRenderer(base.GlyphRenderer):
|
||||
image = wic_decoder.get_image(self._bitmap)
|
||||
|
||||
glyph = self.font.create_glyph(image)
|
||||
glyph.set_bearings(self.font.descent, 0, int(math.ceil(layout_metrics.width)))
|
||||
glyph.set_bearings(-self.font.descent, 0, int(math.ceil(layout_metrics.width)))
|
||||
return glyph
|
||||
|
||||
def create_zero_glyph(self):
|
||||
"""Zero glyph is a 1x1 image that has a -1 advance. This is to fill in for ligature substitutions since
|
||||
font system requires 1 glyph per character in a string."""
|
||||
self._create_bitmap(1, 1)
|
||||
image = wic_decoder.get_image(self._bitmap)
|
||||
|
||||
glyph = self.font.create_glyph(image)
|
||||
glyph.set_bearings(-self.font.descent, 0, -1)
|
||||
return glyph
|
||||
|
||||
def _create_bitmap(self, width, height):
|
||||
@ -1878,6 +1906,7 @@ class Win32DirectWriteFont(base.Font):
|
||||
|
||||
_glyph_renderer = None
|
||||
_empty_glyph = None
|
||||
_zero_glyph = None
|
||||
|
||||
glyph_renderer_class = DirectWriteGlyphRenderer
|
||||
texture_internalformat = pyglet.gl.GL_RGBA
|
||||
@ -1973,10 +2002,10 @@ class Win32DirectWriteFont(base.Font):
|
||||
|
||||
self.font_scale_ratio = (self._real_size / self._font_metrics.designUnitsPerEm)
|
||||
|
||||
self.ascent = self._font_metrics.ascent * self.font_scale_ratio
|
||||
self.descent = self._font_metrics.descent * self.font_scale_ratio
|
||||
|
||||
self.ascent = math.ceil(self._font_metrics.ascent * self.font_scale_ratio)
|
||||
self.descent = -round(self._font_metrics.descent * self.font_scale_ratio)
|
||||
self.max_glyph_height = (self._font_metrics.ascent + self._font_metrics.descent) * self.font_scale_ratio
|
||||
|
||||
self.line_gap = self._font_metrics.lineGap * self.font_scale_ratio
|
||||
|
||||
self._fallback = None
|
||||
@ -1986,7 +2015,6 @@ class Win32DirectWriteFont(base.Font):
|
||||
else:
|
||||
assert _debug_font("Windows 8.1+ is required for font fallback. Colored glyphs cannot be omitted.")
|
||||
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
@ -2015,21 +2043,19 @@ class Win32DirectWriteFont(base.Font):
|
||||
new_glyph.set_bearings(
|
||||
glyph.baseline,
|
||||
glyph.lsb,
|
||||
advance * self.font_scale_ratio,
|
||||
offset.advanceOffset * self.font_scale_ratio,
|
||||
offset.ascenderOffset * self.font_scale_ratio
|
||||
advance,
|
||||
offset.advanceOffset,
|
||||
offset.ascenderOffset
|
||||
)
|
||||
return new_glyph
|
||||
|
||||
def _render_layout_glyph(self, text_buffer, i, clusters, check_color=True):
|
||||
formatted_clusters = clusters[:]
|
||||
|
||||
# Some glyphs can be more than 1 char. We use the clusters to determine how many of an index exist.
|
||||
text_length = formatted_clusters.count(i)
|
||||
text_length = clusters.count(i)
|
||||
|
||||
# Amount of glyphs don't always match 1:1 with text as some can be substituted or omitted. Get
|
||||
# actual text buffer index.
|
||||
text_index = formatted_clusters.index(i)
|
||||
text_index = clusters.index(i)
|
||||
|
||||
# Get actual text based on the index and length.
|
||||
actual_text = text_buffer[text_index:text_index + text_length]
|
||||
@ -2125,25 +2151,48 @@ class Win32DirectWriteFont(base.Font):
|
||||
if not self._glyph_renderer:
|
||||
self._glyph_renderer = self.glyph_renderer_class(self)
|
||||
self._empty_glyph = self._glyph_renderer.render_using_layout(" ")
|
||||
self._zero_glyph = self._glyph_renderer.create_zero_glyph()
|
||||
|
||||
text_buffer, actual_count, indices, advances, offsets, clusters = self._glyph_renderer.get_string_info(text, self.font_face)
|
||||
text_buffer, actual_count, indices, advances, offsets, clusters = self._glyph_renderer.get_string_info(text,
|
||||
self.font_face)
|
||||
|
||||
metrics = self._glyph_renderer.get_glyph_metrics(self.font_face, indices, actual_count)
|
||||
|
||||
formatted_clusters = list(clusters)
|
||||
|
||||
# Convert to real sizes.
|
||||
for i in range(actual_count):
|
||||
advances[i] *= self.font_scale_ratio
|
||||
|
||||
for i in range(actual_count):
|
||||
offsets[i].advanceOffset *= self.font_scale_ratio
|
||||
offsets[i].ascenderOffset *= self.font_scale_ratio
|
||||
|
||||
glyphs = []
|
||||
|
||||
# Pyglet expects 1 glyph for every string. However, ligatures can combine 1 or more glyphs, leading
|
||||
# to issues with multilines producing wrong output.
|
||||
substitutions = {}
|
||||
for idx in clusters:
|
||||
ct = formatted_clusters.count(idx)
|
||||
if ct > 1:
|
||||
substitutions[idx] = ct-1
|
||||
|
||||
for i in range(actual_count):
|
||||
indice = indices[i]
|
||||
|
||||
if indice == 0:
|
||||
# If an indice is 0, it will return no glyph. In this case we attempt to render leveraging
|
||||
# the built in text layout from MS. Which depending on version can use fallback fonts and other tricks
|
||||
# to possibly get something of use.
|
||||
glyph = self._render_layout_glyph(text_buffer, i, clusters)
|
||||
glyph = self._render_layout_glyph(text_buffer, i, formatted_clusters)
|
||||
glyphs.append(glyph)
|
||||
else:
|
||||
advance_key = (indice, advances[i], offsets[i].advanceOffset, offsets[i].ascenderOffset)
|
||||
|
||||
# Glyphs can vary depending on shaping. We will cache it by indice, advance, and offset.
|
||||
# Possible to just cache without offset and set them each time. This may be faster?
|
||||
if indice in self.glyphs:
|
||||
advance_key = (indice, advances[i], offsets[i].advanceOffset, offsets[i].ascenderOffset)
|
||||
if advance_key in self._advance_cache:
|
||||
glyph = self._advance_cache[advance_key]
|
||||
else:
|
||||
@ -2153,14 +2202,18 @@ class Win32DirectWriteFont(base.Font):
|
||||
glyph = self._glyph_renderer.render_single_glyph(self.font_face, indice, advances[i], offsets[i],
|
||||
metrics[i])
|
||||
if glyph is None: # Will only return None if a color glyph is found. Use DW to render it directly.
|
||||
glyph = self._render_layout_glyph(text_buffer, i, clusters, check_color=False)
|
||||
glyph = self._render_layout_glyph(text_buffer, i, formatted_clusters, check_color=False)
|
||||
glyph.colored = True
|
||||
|
||||
self.glyphs[indice] = glyph
|
||||
self._advance_cache[(indice, advances[i], offsets[i].advanceOffset, offsets[i].ascenderOffset)] = glyph
|
||||
self._advance_cache[advance_key] = glyph
|
||||
|
||||
glyphs.append(glyph)
|
||||
|
||||
if i in substitutions:
|
||||
for _ in range(substitutions[i]):
|
||||
glyphs.append(self._zero_glyph)
|
||||
|
||||
return glyphs
|
||||
|
||||
def create_text_layout(self, text):
|
||||
@ -2367,4 +2420,4 @@ no_offset = D2D_POINT_2F(0, 0)
|
||||
|
||||
# If we are not shaping, monkeypatch to no shape function.
|
||||
if pyglet.options["win32_disable_shaping"]:
|
||||
Win32DirectWriteFont.get_glyphs = Win32DirectWriteFont.get_glyphs_no_shape
|
||||
Win32DirectWriteFont.get_glyphs = Win32DirectWriteFont.get_glyphs_no_shape
|
||||
|
@ -120,7 +120,18 @@ class FreeTypeGlyphRenderer(base.GlyphRenderer):
|
||||
'A',
|
||||
self._data,
|
||||
abs(self._pitch))
|
||||
glyph = self.font.create_glyph(img)
|
||||
|
||||
# HACK: Get text working in GLES until image data can be converted properly
|
||||
# GLES don't support coversion during pixel transfer so we have to
|
||||
# force specify the glyph format to be GL_ALPHA. This format is not
|
||||
# supported in 3.3+ core, but are present in ES because of pixel transfer
|
||||
# limitations.
|
||||
if pyglet.gl.current_context.get_info().get_opengl_api() == "gles":
|
||||
GL_ALPHA = 0x1906
|
||||
glyph = self.font.create_glyph(img, fmt=GL_ALPHA)
|
||||
else:
|
||||
glyph = self.font.create_glyph(img)
|
||||
|
||||
glyph.set_bearings(self._baseline, self._lsb, self._advance_x)
|
||||
if self._pitch > 0:
|
||||
t = list(glyph.tex_coords)
|
||||
|
@ -824,14 +824,14 @@ class Controller(EventDispatcher):
|
||||
|
||||
# Input Event types:
|
||||
|
||||
def on_stick_motion(self, controller, axis, xvalue, yvalue):
|
||||
def on_stick_motion(self, controller, stick, xvalue, yvalue):
|
||||
"""The value of a controller analogue stick changed.
|
||||
|
||||
:Parameters:
|
||||
`controller` : `Controller`
|
||||
The controller whose analogue stick changed.
|
||||
`axis` : string
|
||||
The name of the axis that changed.
|
||||
`stick` : string
|
||||
The name of the stick that changed.
|
||||
`xvalue` : float
|
||||
The current x axis value, normalized to [-1, 1].
|
||||
`yvalue` : float
|
||||
|
@ -55,12 +55,13 @@ To query which GameControllers are available, call :py:func:`get_controllers`.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
import os
|
||||
import os as _os
|
||||
import warnings as _warnings
|
||||
|
||||
from .controller_db import mapping_list
|
||||
|
||||
|
||||
_env_config = os.environ.get('SDL_GAMECONTROLLERCONFIG')
|
||||
_env_config = _os.environ.get('SDL_GAMECONTROLLERCONFIG')
|
||||
if _env_config:
|
||||
# insert at the front of the list
|
||||
mapping_list.insert(0, _env_config)
|
||||
@ -101,12 +102,11 @@ def _parse_mapping(mapping_string):
|
||||
if ':' not in item:
|
||||
continue
|
||||
|
||||
key, relation_string = item.split(':')
|
||||
key, relation_string, *etc = item.split(':')
|
||||
|
||||
if key not in valid_keys:
|
||||
continue
|
||||
|
||||
inverted = False
|
||||
# Look for specific flags to signify inverted axis:
|
||||
if "+" in relation_string:
|
||||
relation_string = relation_string.strip('+')
|
||||
@ -114,9 +114,11 @@ def _parse_mapping(mapping_string):
|
||||
elif "-" in relation_string:
|
||||
relation_string = relation_string.strip('-')
|
||||
inverted = True
|
||||
if "~" in relation_string:
|
||||
elif "~" in relation_string:
|
||||
relation_string = relation_string.strip('~')
|
||||
inverted = True
|
||||
else:
|
||||
inverted = False
|
||||
|
||||
# All relations will be one of (Button, Axis, or Hat).
|
||||
if relation_string.startswith("b"): # Button
|
||||
@ -141,7 +143,11 @@ def get_mapping(guid):
|
||||
"""
|
||||
for mapping in mapping_list:
|
||||
if mapping.startswith(guid):
|
||||
return _parse_mapping(mapping)
|
||||
try:
|
||||
return _parse_mapping(mapping)
|
||||
except ValueError:
|
||||
_warnings.warn(f"Unable to parse Controller mapping: {mapping}")
|
||||
continue
|
||||
|
||||
|
||||
def add_mappings_from_file(filename) -> None:
|
||||
|
@ -2,7 +2,7 @@ from pyglet import compat_platform
|
||||
|
||||
|
||||
# This file is automatically generated by 'pyglet/tools/gen_controller_db.py'
|
||||
# Generated on: Thu Jul 7 09:31:08 2022
|
||||
# Generated on: Wed Aug 3 10:51:56 2022
|
||||
|
||||
if compat_platform.startswith("linux"):
|
||||
mapping_list = [
|
||||
@ -27,6 +27,10 @@ if compat_platform.startswith("linux"):
|
||||
"05000000203800000900000000010000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00002038000000010000,8BitDo NES30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00002038000000010000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000660000011010000,8BitDo Pro 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000660000011010000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00000660000000010000,8BitDo Pro 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00000660000000010000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00000061000000010000,8BitDo SF30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00000061000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000102800000900000000010000,8BitDo SFC30 Gamepad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
@ -105,6 +109,8 @@ if compat_platform.startswith("linux"):
|
||||
"030000000d0f00005001000009040000,HORI Fighting Commander OCTA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000000d0f00008400000011010000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008500000010010000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008800000011010000,HORI Fighting Stick mini 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008700000011010000,HORI Fighting Stick mini 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,rightshoulder:b5,rightstick:b11,righttrigger:a4,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f0000d800000072056800,HORI Real Arcade Pro S,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
|
||||
"030000000d0f0000aa00000011010000,HORI Real Arcade Pro,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
"030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
@ -171,8 +177,26 @@ if compat_platform.startswith("linux"):
|
||||
"03000000790000004318000010010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000790000004318000010010000,Nintendo GameCube Controller,a:b1,b:b0,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,",
|
||||
"050000004c69632050726f20436f6e00,Nintendo Switch Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000004c69632050726f20436f6e00,Nintendo Switch Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000620000001800000,Nintendo Switch Joy-Con (L),a:b15,b:b16,guide:b4,leftshoulder:b6,leftstick:b12,leftx:a1,lefty:a0~,rightshoulder:b8,start:b9,x:b17,y:b14,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000620000001800000,Nintendo Switch Joy-Con (L),a:b16,b:b15,guide:b4,leftshoulder:b6,leftstick:b12,leftx:a1,lefty:a0~,rightshoulder:b8,start:b9,x:b14,y:b17,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"060000007e0500000620000000000000,Nintendo Switch Joy-Con (L/R),a:b1,b:b0,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"060000007e0500000620000000000000,Nintendo Switch Joy-Con (L/R),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"060000007e0500000820000000000000,Nintendo Switch Joy-Con (L/R),a:b1,b:b0,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"060000007e0500000820000000000000,Nintendo Switch Joy-Con (L/R),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000720000001800000,Nintendo Switch Joy-Con (R),a:b2,b:b1,guide:b9,leftshoulder:b4,leftstick:b10,leftx:a1~,lefty:a0,rightshoulder:b6,start:b8,x:b3,y:b0,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000720000001800000,Nintendo Switch Joy-Con (R),a:b1,b:b2,guide:b9,leftshoulder:b4,leftstick:b10,leftx:a1~,lefty:a0,rightshoulder:b6,start:b8,x:b0,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000d620000013a7000011010000,Nintendo Switch PowerA Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000d620000013a7000011010000,Nintendo Switch PowerA Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000d620000011a7000011010000,Nintendo Switch PowerA Core Plus Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000d620000011a7000011010000,Nintendo Switch PowerA Core Plus Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,misc1:b4,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,misc1:b4,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000920000001800000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500000920000001800000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,",
|
||||
"05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
|
||||
"030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,",
|
||||
@ -338,6 +362,8 @@ elif compat_platform.startswith("darwin"):
|
||||
"03000000022000000090000001000000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000203800000900000000010000,8BitDo NES30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000203800000900000000010000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000660000000020000,8BitDo Pro 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000660000000020000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000102800000900000000000000,8BitDo SFC30 Gamepad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000102800000900000000000000,8BitDo SFC30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00001290000001000000,8BitDo SN30 Gamepad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
@ -375,6 +401,8 @@ elif compat_platform.startswith("darwin"):
|
||||
"03000000d11800000094000000010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
|
||||
"030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008800000000010000,HORI Fighting Stick mini 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008700000000010000,HORI Fighting Stick mini 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f0000aa00000072050000,HORI Real Arcade Pro,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
"030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
@ -490,6 +518,8 @@ elif compat_platform.startswith("win"):
|
||||
"03000000203800000900000000000000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00002038000000000000,8BitDo NES30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00002038000000000000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000660000000000000,8BitDo Pro 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000660000000000000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000060000000000000,8BitDo SF30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000060000000000000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000061000000000000,8BitDo SF30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
@ -554,8 +584,6 @@ elif compat_platform.startswith("win"):
|
||||
"03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,",
|
||||
"03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,",
|
||||
"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,",
|
||||
"03000000151900004000000000000000,Flydigi Vader 2,a:b11,b:b10,back:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,leftstick:b1,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b0,righttrigger:b4,rightx:a3,righty:a4,start:b2,x:b9,y:b8,",
|
||||
"03000000b40400001124000000000000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b4,paddle2:b5,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b2,y:b3,",
|
||||
@ -582,6 +610,8 @@ elif compat_platform.startswith("win"):
|
||||
"03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,",
|
||||
"030000000d0f00008400000000000000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008500000000000000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00008800000000000000,HORI Fighting Stick mini 4 (PS3),a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,",
|
||||
"030000000d0f00008700000000000000,HORI Fighting Stick mini 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -123,7 +123,7 @@ class AudioData:
|
||||
length (int): Size of sample data, in bytes.
|
||||
timestamp (float): Time of the first sample, in seconds.
|
||||
duration (float): Total data duration, in seconds.
|
||||
events (List[:class:`pyglet.media.events.MediaEvent`]): List of events
|
||||
events (List[:class:`pyglet.media.drivers.base.MediaEvent`]): List of events
|
||||
contained within this packet. Events are timestamped relative to
|
||||
this audio packet.
|
||||
"""
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -356,6 +356,7 @@ class Caret:
|
||||
m2 = len(self._layout.document.text)
|
||||
else:
|
||||
m2 = m2.start()
|
||||
|
||||
self._position = m2
|
||||
self._update(line=line)
|
||||
self._next_attributes.clear()
|
||||
@ -436,6 +437,7 @@ class Caret:
|
||||
elif self._position > 0:
|
||||
self._position -= 1
|
||||
self._layout.document.delete_text(self._position, self._position + 1)
|
||||
self._update()
|
||||
elif motion == key.MOTION_DELETE:
|
||||
if self.mark is not None:
|
||||
self._delete_selection()
|
||||
|
@ -347,7 +347,7 @@ class _GlyphBox(_AbstractBox):
|
||||
v2 += x1
|
||||
v1 += y + baseline
|
||||
v3 += y + baseline
|
||||
vertices.extend(map(int, [v0, v1, v2, v1, v2, v3, v0, v3]))
|
||||
vertices.extend(map(round, [v0, v1, v2, v1, v2, v3, v0, v3]))
|
||||
t = glyph.tex_coords
|
||||
tex_coords.extend(t)
|
||||
x1 += glyph.advance
|
||||
@ -412,17 +412,19 @@ class _GlyphBox(_AbstractBox):
|
||||
if background_vertices:
|
||||
background_indices = []
|
||||
bg_count = len(background_vertices) // 2
|
||||
for glyph_idx in range(bg_count):
|
||||
background_indices.extend([element + (glyph_idx * 4) for element in [0, 1, 2, 0, 2, 3]])
|
||||
decoration_program = get_default_decoration_shader()
|
||||
for bg_idx in range(bg_count):
|
||||
background_indices.extend([element + (bg_idx * 4) for element in [0, 1, 2, 0, 2, 3]])
|
||||
|
||||
background_list = program.vertex_list_indexed(bg_count, GL_TRIANGLES, background_indices,
|
||||
background_list = decoration_program.vertex_list_indexed(bg_count * 4, GL_TRIANGLES, background_indices,
|
||||
layout.batch, layout.background_decoration_group,
|
||||
position=('f', background_vertices),
|
||||
colors=('Bn', background_colors))
|
||||
context.add_list(background_list)
|
||||
|
||||
if underline_vertices:
|
||||
underline_list = program.vertex_list(len(underline_vertices) // 2, GL_LINES,
|
||||
decoration_program = get_default_decoration_shader()
|
||||
underline_list = decoration_program.vertex_list(len(underline_vertices) // 2, GL_LINES,
|
||||
layout.batch, layout.foreground_decoration_group,
|
||||
position=('f',underline_vertices),
|
||||
colors=('Bn', underline_colors))
|
||||
@ -778,6 +780,14 @@ class ScrollableTextDecorationGroup(graphics.Group):
|
||||
glDisable(GL_BLEND)
|
||||
self.program.stop()
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.__class__.__name__}(scissor={self.scissor_area})"
|
||||
|
||||
def __eq__(self, other):
|
||||
return self is other
|
||||
|
||||
def __hash__(self):
|
||||
return id(self)
|
||||
|
||||
class IncrementalTextDecorationGroup(ScrollableTextDecorationGroup):
|
||||
# Subclass so that the scissor_area isn't shared with the
|
||||
@ -1797,6 +1807,9 @@ class ScrollableTextLayout(TextLayout):
|
||||
for group in self.group_cache.values():
|
||||
group.scissor_area = area
|
||||
|
||||
self.background_decoration_group.scissor_area = area
|
||||
self.foreground_decoration_group.scissor_area = area
|
||||
|
||||
def _update(self):
|
||||
super()._update()
|
||||
self._update_scissor_area()
|
||||
@ -1951,6 +1964,8 @@ class IncrementalTextLayout(TextLayout, EventDispatcher):
|
||||
area = self._get_left(), self._get_bottom(self._get_lines()), self._width, self._height
|
||||
for group in self.group_cache.values():
|
||||
group.scissor_area = area
|
||||
self.background_decoration_group.scissor_area = area
|
||||
self.foreground_decoration_group.scissor_area = area
|
||||
|
||||
def _init_document(self):
|
||||
assert self._document, 'Cannot remove document from IncrementalTextLayout'
|
||||
@ -2532,7 +2547,7 @@ class IncrementalTextLayout(TextLayout, EventDispatcher):
|
||||
position -= box.length
|
||||
x += box.advance
|
||||
|
||||
return x + self._translate_x, line.y + self._translate_y + baseline
|
||||
return x - self._translate_x, line.y + self._translate_y + baseline
|
||||
|
||||
def get_line_from_point(self, x, y):
|
||||
"""Get the closest line index to a point.
|
||||
@ -2610,6 +2625,8 @@ class IncrementalTextLayout(TextLayout, EventDispatcher):
|
||||
:rtype: int
|
||||
"""
|
||||
line = self.lines[line]
|
||||
|
||||
x += self._translate_x
|
||||
x -= self._x
|
||||
|
||||
if x < line.x:
|
||||
@ -2659,6 +2676,8 @@ class IncrementalTextLayout(TextLayout, EventDispatcher):
|
||||
X coordinate
|
||||
|
||||
"""
|
||||
x += self.view_x - self._x
|
||||
|
||||
if x <= self.view_x + 10:
|
||||
self.view_x = x - 10
|
||||
elif x >= self.view_x + self.width:
|
||||
|
@ -321,6 +321,7 @@ class Win32Window(BaseWindow):
|
||||
return
|
||||
|
||||
_user32.DestroyWindow(self._hwnd)
|
||||
_user32.UnregisterClassW(self._view_window_class.lpszClassName, 0)
|
||||
_user32.UnregisterClassW(self._window_class.lpszClassName, 0)
|
||||
|
||||
self._window_class = None
|
||||
|
Loading…
Reference in New Issue
Block a user