Ajout du GUI
This commit is contained in:
21
kivy/lib/__init__.py
Normal file
21
kivy/lib/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
'''
|
||||
External libraries
|
||||
==================
|
||||
|
||||
Kivy comes with other python/C libraries:
|
||||
|
||||
* :mod:`~kivy.lib.ddsfile` - used for parsing and saving
|
||||
`DDS <https://en.wikipedia.org/wiki/DirectDraw_Surface>`_ files.
|
||||
* :mod:`~kivy.lib.osc` - a modified/optimized version of PyOSC for using
|
||||
the `Open Sound Control <https://en.wikipedia.org/wiki/Open_Sound_Control>`_
|
||||
protocol.
|
||||
* :mod:`~kivy.lib.mtdev` - provides support for the
|
||||
`Kernel multi-touch transformation library <https://launchpad.net/mtdev>`_.
|
||||
|
||||
.. warning::
|
||||
|
||||
Even though Kivy comes with these external libraries, we do not provide any
|
||||
support for them and they might change in the future.
|
||||
Don't rely on them in your code.
|
||||
|
||||
'''
|
||||
BIN
kivy/lib/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
kivy/lib/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
kivy/lib/__pycache__/ddsfile.cpython-310.pyc
Normal file
BIN
kivy/lib/__pycache__/ddsfile.cpython-310.pyc
Normal file
Binary file not shown.
BIN
kivy/lib/__pycache__/mtdev.cpython-310.pyc
Normal file
BIN
kivy/lib/__pycache__/mtdev.cpython-310.pyc
Normal file
Binary file not shown.
419
kivy/lib/ddsfile.py
Normal file
419
kivy/lib/ddsfile.py
Normal file
@@ -0,0 +1,419 @@
|
||||
'''
|
||||
DDS File library
|
||||
================
|
||||
|
||||
This library can be used to parse and save DDS
|
||||
(`DirectDraw Surface <https://en.wikipedia.org/wiki/DirectDraw_Surface>`)
|
||||
files.
|
||||
|
||||
The initial version was written by::
|
||||
|
||||
Alexey Borzenkov (snaury@gmail.com)
|
||||
|
||||
All the initial work credits go to him! Thank you :)
|
||||
|
||||
This version uses structs instead of ctypes.
|
||||
|
||||
|
||||
DDS Format
|
||||
----------
|
||||
|
||||
::
|
||||
|
||||
[DDS ][SurfaceDesc][Data]
|
||||
|
||||
[SurfaceDesc]:: (everything is uint32)
|
||||
Size
|
||||
Flags
|
||||
Height
|
||||
Width
|
||||
PitchOrLinearSize
|
||||
Depth
|
||||
MipmapCount
|
||||
Reserved1 * 11
|
||||
[PixelFormat]::
|
||||
Size
|
||||
Flags
|
||||
FourCC
|
||||
RGBBitCount
|
||||
RBitMask
|
||||
GBitMask
|
||||
BBitMask
|
||||
ABitMask
|
||||
[Caps]::
|
||||
Caps1
|
||||
Caps2
|
||||
Reserved1 * 2
|
||||
Reserverd2
|
||||
|
||||
.. warning::
|
||||
|
||||
This is an external library and Kivy does not provide any support for it.
|
||||
It might change in the future and we advise you don't rely on it in your
|
||||
code.
|
||||
|
||||
'''
|
||||
# flake8: noqa
|
||||
|
||||
from struct import pack, unpack, calcsize
|
||||
|
||||
# DDSURFACEDESC2 dwFlags
|
||||
DDSD_CAPS = 0x00000001
|
||||
DDSD_HEIGHT = 0x00000002
|
||||
DDSD_WIDTH = 0x00000004
|
||||
DDSD_PITCH = 0x00000008
|
||||
DDSD_PIXELFORMAT = 0x00001000
|
||||
DDSD_MIPMAPCOUNT = 0x00020000
|
||||
DDSD_LINEARSIZE = 0x00080000
|
||||
DDSD_DEPTH = 0x00800000
|
||||
|
||||
# DDPIXELFORMAT dwFlags
|
||||
DDPF_ALPHAPIXELS = 0x00000001
|
||||
DDPF_FOURCC = 0x00000004
|
||||
DDPF_RGB = 0x00000040
|
||||
DDPF_LUMINANCE = 0x00020000
|
||||
|
||||
# DDSCAPS2 dwCaps1
|
||||
DDSCAPS_COMPLEX = 0x00000008
|
||||
DDSCAPS_TEXTURE = 0x00001000
|
||||
DDSCAPS_MIPMAP = 0x00400000
|
||||
|
||||
# DDSCAPS2 dwCaps2
|
||||
DDSCAPS2_CUBEMAP = 0x00000200
|
||||
DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400
|
||||
DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800
|
||||
DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000
|
||||
DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000
|
||||
DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000
|
||||
DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000
|
||||
DDSCAPS2_VOLUME = 0x00200000
|
||||
|
||||
# Common FOURCC codes
|
||||
DDS_DXTN = 0x00545844
|
||||
DDS_DXT1 = 0x31545844
|
||||
DDS_DXT2 = 0x32545844
|
||||
DDS_DXT3 = 0x33545844
|
||||
DDS_DXT4 = 0x34545844
|
||||
DDS_DXT5 = 0x35545844
|
||||
|
||||
def dxt_to_str(dxt):
|
||||
if dxt == DDS_DXT1:
|
||||
return 's3tc_dxt1'
|
||||
elif dxt == DDS_DXT2:
|
||||
return 's3tc_dxt2'
|
||||
elif dxt == DDS_DXT3:
|
||||
return 's3tc_dxt3'
|
||||
elif dxt == DDS_DXT4:
|
||||
return 's3tc_dxt4'
|
||||
elif dxt == DDS_DXT5:
|
||||
return 's3tc_dxt5'
|
||||
elif dxt == 0:
|
||||
return 'rgba'
|
||||
elif dxt == 1:
|
||||
return 'alpha'
|
||||
elif dxt == 2:
|
||||
return 'luminance'
|
||||
elif dxt == 3:
|
||||
return 'luminance_alpha'
|
||||
|
||||
def str_to_dxt(dxt):
|
||||
if dxt == 's3tc_dxt1':
|
||||
return DDS_DXT1
|
||||
if dxt == 's3tc_dxt2':
|
||||
return DDS_DXT2
|
||||
if dxt == 's3tc_dxt3':
|
||||
return DDS_DXT3
|
||||
if dxt == 's3tc_dxt4':
|
||||
return DDS_DXT4
|
||||
if dxt == 's3tc_dxt5':
|
||||
return DDS_DXT5
|
||||
if dxt == 'rgba':
|
||||
return 0
|
||||
if dxt == 'alpha':
|
||||
return 1
|
||||
if dxt == 'luminance':
|
||||
return 2
|
||||
if dxt == 'luminance_alpha':
|
||||
return 3
|
||||
|
||||
def align_value(val, b):
|
||||
return val + (-val % b)
|
||||
|
||||
def check_flags(val, fl):
|
||||
return (val & fl) == fl
|
||||
|
||||
def dxt_size(w, h, dxt):
|
||||
w = max(1, w // 4)
|
||||
h = max(1, h // 4)
|
||||
if dxt == DDS_DXT1:
|
||||
return w * h * 8
|
||||
elif dxt in (DDS_DXT2, DDS_DXT3, DDS_DXT4, DDS_DXT5):
|
||||
return w * h * 16
|
||||
return -1
|
||||
|
||||
class QueryDict(dict):
|
||||
def __getattr__(self, attr):
|
||||
try:
|
||||
return self.__getitem__(attr)
|
||||
except KeyError:
|
||||
try:
|
||||
return super(QueryDict, self).__getattr__(attr)
|
||||
except AttributeError:
|
||||
raise KeyError(attr)
|
||||
|
||||
def __setattr__(self, attr, value):
|
||||
self.__setitem__(attr, value)
|
||||
|
||||
class DDSException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class DDSFile(object):
|
||||
fields = (
|
||||
('size', 0), ('flags', 1), ('height', 2),
|
||||
('width', 3), ('pitchOrLinearSize', 4), ('depth', 5),
|
||||
('mipmapCount', 6), ('pf_size', 18), ('pf_flags', 19),
|
||||
('pf_fourcc', 20), ('pf_rgbBitCount', 21), ('pf_rBitMask', 22),
|
||||
('pf_gBitMask', 23), ('pf_bBitMask', 24), ('pf_aBitMask', 25),
|
||||
('caps1', 26), ('caps2', 27))
|
||||
|
||||
def __init__(self, filename=None):
|
||||
super(DDSFile, self).__init__()
|
||||
self._dxt = 0
|
||||
self._fmt = None
|
||||
self.meta = meta = QueryDict()
|
||||
self.count = 0
|
||||
self.images = []
|
||||
self.images_size = []
|
||||
for field, index in DDSFile.fields:
|
||||
meta[field] = 0
|
||||
if filename:
|
||||
self.load(filename)
|
||||
|
||||
def load(self, filename):
|
||||
self.filename = filename
|
||||
with open(filename, 'rb') as fd:
|
||||
data = fd.read()
|
||||
|
||||
if data[:4] != b'DDS ':
|
||||
raise DDSException('Invalid magic header {}'.format(data[:4]))
|
||||
|
||||
# read header
|
||||
fmt = 'I' * 31
|
||||
fmt_size = calcsize(fmt)
|
||||
pf_size = calcsize('I' * 8)
|
||||
header, data = data[4:4+fmt_size], data[4+fmt_size:]
|
||||
if len(header) != fmt_size:
|
||||
raise DDSException('Truncated header in')
|
||||
|
||||
# depack
|
||||
header = unpack(fmt, header)
|
||||
meta = self.meta
|
||||
for name, index in DDSFile.fields:
|
||||
meta[name] = header[index]
|
||||
|
||||
# check header validity
|
||||
if meta.size != fmt_size:
|
||||
raise DDSException('Invalid header size (%d instead of %d)' %
|
||||
(meta.size, fmt_size))
|
||||
if meta.pf_size != pf_size:
|
||||
raise DDSException('Invalid pixelformat size (%d instead of %d)' %
|
||||
(meta.pf_size, pf_size))
|
||||
if not check_flags(meta.flags,
|
||||
DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT):
|
||||
raise DDSException('Not enough flags')
|
||||
if not check_flags(meta.caps1, DDSCAPS_TEXTURE):
|
||||
raise DDSException('Not a DDS texture')
|
||||
|
||||
self.count = 1
|
||||
if check_flags(meta.flags, DDSD_MIPMAPCOUNT):
|
||||
if not check_flags(meta.caps1, DDSCAPS_COMPLEX | DDSCAPS_MIPMAP):
|
||||
raise DDSException('Invalid mipmap without flags')
|
||||
self.count = meta.mipmapCount
|
||||
|
||||
hasrgb = check_flags(meta.pf_flags, DDPF_RGB)
|
||||
hasalpha = check_flags(meta.pf_flags, DDPF_ALPHAPIXELS)
|
||||
hasluminance = check_flags(meta.pf_flags, DDPF_LUMINANCE)
|
||||
bpp = None
|
||||
dxt = block = pitch = 0
|
||||
if hasrgb or hasalpha or hasluminance:
|
||||
bpp = meta.pf_rgbBitCount
|
||||
|
||||
if hasrgb and hasluminance:
|
||||
raise DDSException('File have RGB and Luminance')
|
||||
|
||||
if hasrgb:
|
||||
dxt = 0
|
||||
elif hasalpha and not hasluminance:
|
||||
dxt = 1
|
||||
elif hasluminance and not hasalpha:
|
||||
dxt = 2
|
||||
elif hasalpha and hasluminance:
|
||||
dxt = 3
|
||||
elif check_flags(meta.pf_flags, DDPF_FOURCC):
|
||||
dxt = meta.pf_fourcc
|
||||
if dxt not in (DDS_DXT1, DDS_DXT2, DDS_DXT3, DDS_DXT4, DDS_DXT5):
|
||||
raise DDSException('Unsupported FOURCC')
|
||||
else:
|
||||
raise DDSException('Unsupported format specified')
|
||||
|
||||
if bpp:
|
||||
block = align_value(bpp, 8) // 8
|
||||
pitch = align_value(block * meta.width, 4)
|
||||
|
||||
if check_flags(meta.flags, DDSD_LINEARSIZE):
|
||||
if dxt in (0, 1, 2, 3):
|
||||
size = pitch * meta.height
|
||||
else:
|
||||
size = dxt_size(meta.width, meta.height, dxt)
|
||||
|
||||
w = meta.width
|
||||
h = meta.height
|
||||
images = self.images
|
||||
images_size = self.images_size
|
||||
for i in range(self.count):
|
||||
if dxt in (0, 1, 2, 3):
|
||||
size = align_value(block * w, 4) * h
|
||||
else:
|
||||
size = dxt_size(w, h, dxt)
|
||||
image, data = data[:size], data[size:]
|
||||
if len(image) < size:
|
||||
raise DDSException('Truncated image for mipmap %d' % i)
|
||||
images_size.append((w, h))
|
||||
images.append(image)
|
||||
if w == 1 and h == 1:
|
||||
break
|
||||
w = max(1, w // 2)
|
||||
h = max(1, h // 2)
|
||||
|
||||
if len(images) == 0:
|
||||
raise DDSException('No images available')
|
||||
if len(images) < self.count:
|
||||
raise DDSException('Not enough images')
|
||||
|
||||
self._dxt = dxt
|
||||
|
||||
def save(self, filename):
|
||||
if len(self.images) == 0:
|
||||
raise DDSException('No images to save')
|
||||
|
||||
fields = dict(DDSFile.fields)
|
||||
fields_keys = list(fields.keys())
|
||||
fields_index = list(fields.values())
|
||||
mget = self.meta.get
|
||||
header = []
|
||||
for idx in range(31):
|
||||
if idx in fields_index:
|
||||
value = mget(fields_keys[fields_index.index(idx)], 0)
|
||||
else:
|
||||
value = 0
|
||||
header.append(value)
|
||||
|
||||
with open(filename, 'wb') as fd:
|
||||
fd.write('DDS ')
|
||||
fd.write(pack('I' * 31, *header))
|
||||
for image in self.images:
|
||||
fd.write(image)
|
||||
|
||||
def add_image(self, level, bpp, fmt, width, height, data):
|
||||
assert(bpp == 32)
|
||||
assert(fmt in ('rgb', 'rgba', 'dxt1', 'dxt2', 'dxt3', 'dxt4', 'dxt5'))
|
||||
assert(width > 0)
|
||||
assert(height > 0)
|
||||
assert(level >= 0)
|
||||
|
||||
meta = self.meta
|
||||
images = self.images
|
||||
if len(images) == 0:
|
||||
assert(level == 0)
|
||||
|
||||
# first image, set defaults !
|
||||
for k in meta.keys():
|
||||
meta[k] = 0
|
||||
|
||||
self._fmt = fmt
|
||||
meta.size = calcsize('I' * 31)
|
||||
meta.pf_size = calcsize('I' * 8)
|
||||
meta.pf_flags = 0
|
||||
meta.flags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT
|
||||
meta.width = width
|
||||
meta.height = height
|
||||
meta.caps1 = DDSCAPS_TEXTURE
|
||||
|
||||
meta.flags |= DDSD_LINEARSIZE
|
||||
meta.pitchOrLinearSize = len(data)
|
||||
|
||||
meta.pf_rgbBitCount = 32
|
||||
meta.pf_rBitMask = 0x00ff0000
|
||||
meta.pf_gBitMask = 0x0000ff00
|
||||
meta.pf_bBitMask = 0x000000ff
|
||||
meta.pf_aBitMask = 0xff000000
|
||||
|
||||
if fmt in ('rgb', 'rgba'):
|
||||
assert(True)
|
||||
assert(bpp == 32)
|
||||
meta.pf_flags |= DDPF_RGB
|
||||
meta.pf_rgbBitCount = 32
|
||||
meta.pf_rBitMask = 0x00ff0000
|
||||
meta.pf_gBitMask = 0x0000ff00
|
||||
meta.pf_bBitMask = 0x000000ff
|
||||
meta.pf_aBitMask = 0x00000000
|
||||
if fmt == 'rgba':
|
||||
meta.pf_flags |= DDPF_ALPHAPIXELS
|
||||
meta.pf_aBitMask = 0xff000000
|
||||
else:
|
||||
meta.pf_flags |= DDPF_FOURCC
|
||||
if fmt == 'dxt1':
|
||||
meta.pf_fourcc = DDS_DXT1
|
||||
elif fmt == 'dxt2':
|
||||
meta.pf_fourcc = DDS_DXT2
|
||||
elif fmt == 'dxt3':
|
||||
meta.pf_fourcc = DDS_DXT3
|
||||
elif fmt == 'dxt4':
|
||||
meta.pf_fourcc = DDS_DXT4
|
||||
elif fmt == 'dxt5':
|
||||
meta.pf_fourcc = DDS_DXT5
|
||||
|
||||
images.append(data)
|
||||
else:
|
||||
assert(level == len(images))
|
||||
assert(fmt == self._fmt)
|
||||
|
||||
images.append(data)
|
||||
|
||||
meta.flags |= DDSD_MIPMAPCOUNT
|
||||
meta.caps1 |= DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
|
||||
meta.mipmapCount = len(images)
|
||||
|
||||
def __repr__(self):
|
||||
return '<DDSFile filename=%r size=%r dxt=%r len(images)=%r>' % (
|
||||
self.filename, self.size, self.dxt, len(self.images))
|
||||
|
||||
def _get_size(self):
|
||||
meta = self.meta
|
||||
return meta.width, meta.height
|
||||
def _set_size(self, size):
|
||||
self.meta.update({'width': size[0], 'height': size[1]})
|
||||
size = property(_get_size, _set_size)
|
||||
|
||||
def _get_dxt(self):
|
||||
return dxt_to_str(self._dxt)
|
||||
def _set_dxt(self, dxt):
|
||||
self._dxt = str_to_dxt(dxt)
|
||||
dxt = property(_get_dxt, _set_dxt)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) == 1:
|
||||
print('Usage: python ddsfile.py <file1> <file2> ...')
|
||||
sys.exit(0)
|
||||
for filename in sys.argv[1:]:
|
||||
print('=== Loading', filename)
|
||||
try:
|
||||
dds = DDSFile(filename=filename)
|
||||
print(dds)
|
||||
dds.save('bleh.dds')
|
||||
except IOError as e:
|
||||
print('ERR>', e)
|
||||
except DDSException as e:
|
||||
print('DDS>', e)
|
||||
27
kivy/lib/gstplayer/__init__.py
Normal file
27
kivy/lib/gstplayer/__init__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
'''
|
||||
GstPlayer
|
||||
=========
|
||||
|
||||
.. versionadded:: 1.8.0
|
||||
|
||||
`GstPlayer` is a media player implemented specifically for Kivy with Gstreamer
|
||||
1.0. It doesn't use Gi at all and is focused on what we want: the ability
|
||||
to read video and stream the image in a callback, or read an audio file.
|
||||
Don't use it directly but use our Core providers instead.
|
||||
|
||||
This player is automatically compiled if you have `pkg-config --libs --cflags
|
||||
gstreamer-1.0` working.
|
||||
|
||||
.. warning::
|
||||
|
||||
This is an external library and Kivy does not provide any support for it.
|
||||
It might change in the future and we advise you don't rely on it in your
|
||||
code.
|
||||
'''
|
||||
|
||||
import os
|
||||
if 'KIVY_DOC' in os.environ:
|
||||
GstPlayer = get_gst_version = glib_iteration = None
|
||||
else:
|
||||
from kivy.lib.gstplayer._gstplayer import (
|
||||
GstPlayer, get_gst_version, glib_iteration)
|
||||
BIN
kivy/lib/gstplayer/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
kivy/lib/gstplayer/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
254
kivy/lib/mtdev.py
Normal file
254
kivy/lib/mtdev.py
Normal file
@@ -0,0 +1,254 @@
|
||||
'''
|
||||
Python mtdev
|
||||
============
|
||||
|
||||
The mtdev module provides Python bindings to the `Kernel multi-touch
|
||||
transformation library <https://launchpad.net/mtdev>`_, also known as mtdev
|
||||
(MIT license).
|
||||
|
||||
The mtdev library transforms all variants of kernel MT events to the
|
||||
slotted type B protocol. The events put into mtdev may be from any MT
|
||||
device, specifically type A without contact tracking, type A with
|
||||
contact tracking, or type B with contact tracking. See the kernel
|
||||
documentation for further details.
|
||||
|
||||
.. warning::
|
||||
|
||||
This is an external library and Kivy does not provide any support for it.
|
||||
It might change in the future and we advise you don't rely on it in your
|
||||
code.
|
||||
'''
|
||||
# flake8: noqa
|
||||
|
||||
import os
|
||||
import time
|
||||
from ctypes import cdll, Structure, c_ulong, c_int, c_ushort, \
|
||||
c_void_p, pointer, POINTER, byref
|
||||
|
||||
# load library
|
||||
if 'KIVY_DOC' not in os.environ:
|
||||
libmtdev = cdll.LoadLibrary('libmtdev.so.1')
|
||||
|
||||
# from linux/input.h
|
||||
MTDEV_CODE_SLOT = 0x2f # MT slot being modified
|
||||
MTDEV_CODE_TOUCH_MAJOR = 0x30 # Major axis of touching ellipse
|
||||
MTDEV_CODE_TOUCH_MINOR = 0x31 # Minor axis (omit if circular)
|
||||
MTDEV_CODE_WIDTH_MAJOR = 0x32 # Major axis of approaching ellipse
|
||||
MTDEV_CODE_WIDTH_MINOR = 0x33 # Minor axis (omit if circular)
|
||||
MTDEV_CODE_ORIENTATION = 0x34 # Ellipse orientation
|
||||
MTDEV_CODE_POSITION_X = 0x35 # Center X ellipse position
|
||||
MTDEV_CODE_POSITION_Y = 0x36 # Center Y ellipse position
|
||||
MTDEV_CODE_TOOL_TYPE = 0x37 # Type of touching device
|
||||
MTDEV_CODE_BLOB_ID = 0x38 # Group a set of packets as a blob
|
||||
MTDEV_CODE_TRACKING_ID = 0x39 # Unique ID of initiated contact
|
||||
MTDEV_CODE_PRESSURE = 0x3a # Pressure on contact area
|
||||
MTDEV_CODE_ABS_X = 0x00
|
||||
MTDEV_CODE_ABS_Y = 0x01
|
||||
MTDEV_CODE_ABS_Z = 0x02
|
||||
MTDEV_CODE_BTN_DIGI = 0x140
|
||||
MTDEV_CODE_BTN_TOOL_PEN = 0x140
|
||||
MTDEV_CODE_BTN_TOOL_RUBBER = 0x141
|
||||
MTDEV_CODE_BTN_TOOL_BRUSH = 0x142
|
||||
MTDEV_CODE_BTN_TOOL_PENCIL = 0x143
|
||||
MTDEV_CODE_BTN_TOOL_AIRBRUSH = 0x144
|
||||
MTDEV_CODE_BTN_TOOL_FINGER = 0x145
|
||||
MTDEV_CODE_BTN_TOOL_MOUSE = 0x146
|
||||
MTDEV_CODE_BTN_TOOL_LENS = 0x147
|
||||
MTDEV_CODE_BTN_TOUCH = 0x14a
|
||||
MTDEV_CODE_BTN_STYLUS = 0x14b
|
||||
MTDEV_CODE_BTN_STYLUS2 = 0x14c
|
||||
MTDEV_CODE_BTN_TOOL_DOUBLETAP = 0x14d
|
||||
MTDEV_CODE_BTN_TOOL_TRIPLETAP = 0x14e
|
||||
MTDEV_CODE_BTN_TOOL_QUADTAP = 0x14f # Four fingers on trackpad
|
||||
|
||||
MTDEV_TYPE_EV_ABS = 0x03
|
||||
MTDEV_TYPE_EV_SYN = 0x00
|
||||
MTDEV_TYPE_EV_KEY = 0x01
|
||||
MTDEV_TYPE_EV_REL = 0x02
|
||||
MTDEV_TYPE_EV_ABS = 0x03
|
||||
MTDEV_TYPE_EV_MSC = 0x04
|
||||
MTDEV_TYPE_EV_SW = 0x05
|
||||
MTDEV_TYPE_EV_LED = 0x11
|
||||
MTDEV_TYPE_EV_SND = 0x12
|
||||
MTDEV_TYPE_EV_REP = 0x14
|
||||
MTDEV_TYPE_EV_FF = 0x15
|
||||
MTDEV_TYPE_EV_PWR = 0x16
|
||||
MTDEV_TYPE_EV_FF_STATUS = 0x17
|
||||
|
||||
MTDEV_ABS_TRACKING_ID = 9
|
||||
MTDEV_ABS_POSITION_X = 5
|
||||
MTDEV_ABS_POSITION_Y = 6
|
||||
MTDEV_ABS_TOUCH_MAJOR = 0
|
||||
MTDEV_ABS_TOUCH_MINOR = 1
|
||||
MTDEV_ABS_WIDTH_MAJOR = 2
|
||||
MTDEV_ABS_WIDTH_MINOR = 3
|
||||
MTDEV_ABS_ORIENTATION = 4
|
||||
MTDEV_ABS_SIZE = 11
|
||||
|
||||
class timeval(Structure):
|
||||
_fields_ = [
|
||||
('tv_sec', c_ulong),
|
||||
('tv_usec', c_ulong)
|
||||
]
|
||||
|
||||
class input_event(Structure):
|
||||
_fields_ = [
|
||||
('time', timeval),
|
||||
('type', c_ushort),
|
||||
('code', c_ushort),
|
||||
('value', c_int)
|
||||
]
|
||||
|
||||
class input_absinfo(Structure):
|
||||
_fields_ = [
|
||||
('value', c_int),
|
||||
('minimum', c_int),
|
||||
('maximum', c_int),
|
||||
('fuzz', c_int),
|
||||
('flat', c_int),
|
||||
('resolution', c_int)
|
||||
]
|
||||
|
||||
class mtdev_caps(Structure):
|
||||
_fields_ = [
|
||||
('has_mtdata', c_int),
|
||||
('has_slot', c_int),
|
||||
('has_abs', c_int * MTDEV_ABS_SIZE),
|
||||
('slot', input_absinfo),
|
||||
('abs', input_absinfo * MTDEV_ABS_SIZE)
|
||||
]
|
||||
|
||||
class mtdev(Structure):
|
||||
_fields_ = [
|
||||
('caps', mtdev_caps),
|
||||
('state', c_void_p)
|
||||
]
|
||||
|
||||
# binding
|
||||
if 'KIVY_DOC' not in os.environ:
|
||||
mtdev_open = libmtdev.mtdev_open
|
||||
mtdev_open.argtypes = [POINTER(mtdev), c_int]
|
||||
mtdev_get = libmtdev.mtdev_get
|
||||
mtdev_get.argtypes = [POINTER(mtdev), c_int, POINTER(input_event), c_int]
|
||||
mtdev_idle = libmtdev.mtdev_idle
|
||||
mtdev_idle.argtypes = [POINTER(mtdev), c_int, c_int]
|
||||
mtdev_close = libmtdev.mtdev_close
|
||||
mtdev_close.argtypes = [POINTER(mtdev)]
|
||||
|
||||
|
||||
class Device:
|
||||
def __init__(self, filename):
|
||||
self._filename = filename
|
||||
self._fd = -1
|
||||
self._device = mtdev()
|
||||
|
||||
# Linux kernel creates input devices then hands permission changes
|
||||
# off to udev. This results in a period of time when the device is
|
||||
# readable only by root. Device reconnects can be processed by
|
||||
# MTDMotionEventProvider faster than udev can get a chance to run,
|
||||
# so we spin for a period of time to allow udev to fix permissions.
|
||||
# We limit the loop time in case the system is misconfigured and
|
||||
# the user really does not (and will not) have permission to access
|
||||
# the device.
|
||||
# Note: udev takes about 0.6 s on a Raspberry Pi 4
|
||||
permission_wait_until = time.time() + 3.0
|
||||
while self._fd == -1:
|
||||
try:
|
||||
self._fd = os.open(filename, os.O_NONBLOCK | os.O_RDONLY)
|
||||
except PermissionError:
|
||||
if time.time() > permission_wait_until:
|
||||
raise
|
||||
ret = mtdev_open(pointer(self._device), self._fd)
|
||||
if ret != 0:
|
||||
os.close(self._fd)
|
||||
self._fd = -1
|
||||
raise Exception('Unable to open device')
|
||||
|
||||
def close(self):
|
||||
'''Close the mtdev converter
|
||||
'''
|
||||
if self._fd == -1:
|
||||
return
|
||||
mtdev_close(pointer(self._device))
|
||||
os.close(self._fd)
|
||||
self._fd = -1
|
||||
|
||||
def idle(self, ms):
|
||||
'''Check state of kernel device
|
||||
|
||||
:Parameters:
|
||||
`ms`: int
|
||||
Number of milliseconds to wait for activity
|
||||
|
||||
:Return:
|
||||
Return True if the device is idle, i.e, there are no fetched events
|
||||
in the pipe and there is nothing to fetch from the device.
|
||||
'''
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
return bool(mtdev_idle(pointer(self._device), self._fd, ms))
|
||||
|
||||
|
||||
def get(self):
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
ev = input_event()
|
||||
if mtdev_get(pointer(self._device), self._fd, byref(ev), 1) <= 0:
|
||||
return None
|
||||
return ev
|
||||
|
||||
def has_mtdata(self):
|
||||
'''Return True if the device has multitouch data.
|
||||
'''
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
return bool(self._device.caps.has_mtdata)
|
||||
|
||||
def has_slot(self):
|
||||
'''Return True if the device has slot information.
|
||||
'''
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
return bool(self._device.caps.has_slot)
|
||||
|
||||
def has_abs(self, index):
|
||||
'''Return True if the device has abs data.
|
||||
|
||||
:Parameters:
|
||||
`index`: int
|
||||
One of const starting with a name ABS_MT_
|
||||
'''
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
if index < 0 or index >= MTDEV_ABS_SIZE:
|
||||
raise IndexError('Invalid index')
|
||||
return bool(self._device.caps.has_abs[index])
|
||||
|
||||
def get_max_abs(self):
|
||||
'''Return the maximum number of abs information available.
|
||||
'''
|
||||
return MTDEV_ABS_SIZE
|
||||
|
||||
def get_slot(self):
|
||||
'''Return the slot data.
|
||||
'''
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
if self._device.caps.has_slot == 0:
|
||||
return
|
||||
return self._device.caps.slot
|
||||
|
||||
def get_abs(self, index):
|
||||
'''Return the abs data.
|
||||
|
||||
:Parameters:
|
||||
`index`: int
|
||||
One of const starting with a name ABS_MT_
|
||||
'''
|
||||
if self._fd == -1:
|
||||
raise Exception('Device closed')
|
||||
if index < 0 or index >= MTDEV_ABS_SIZE:
|
||||
raise IndexError('Invalid index')
|
||||
return self._device.caps.abs[index]
|
||||
|
||||
|
||||
366
kivy/lib/pango/pangoft2.pxi
Normal file
366
kivy/lib/pango/pangoft2.pxi
Normal file
@@ -0,0 +1,366 @@
|
||||
cdef extern from "glib.h" nogil:
|
||||
ctypedef void *gpointer
|
||||
ctypedef char gchar
|
||||
ctypedef int gint
|
||||
ctypedef unsigned int guint
|
||||
ctypedef unsigned long gsize
|
||||
ctypedef gint gboolean
|
||||
gboolean TRUE
|
||||
gboolean FALSE
|
||||
|
||||
void *g_malloc(gsize n_bytes)
|
||||
void *g_malloc0(gsize n_bytes)
|
||||
void g_free(gpointer mem)
|
||||
void g_object_unref(gpointer obj)
|
||||
# gpointer GUINT_TO_POINTER(guint u)
|
||||
# guint GPOINTER_TO_UINT(gpointer p)
|
||||
|
||||
# https://www.freetype.org/freetype2/docs/reference/ft2-index.html
|
||||
cdef extern from "../../lib/pango/freetype2.h" nogil:
|
||||
int FREETYPE_MAJOR
|
||||
int FREETYPE_MINOR
|
||||
int FREETYPE_PATCH
|
||||
ctypedef void *FT_Library
|
||||
ctypedef void *FT_Face
|
||||
ctypedef int FT_Error
|
||||
ctypedef unsigned char *FT_Byte
|
||||
ctypedef unsigned int FT_UInt
|
||||
ctypedef unsigned short FT_UShort
|
||||
|
||||
ctypedef enum FT_Pixel_Mode:
|
||||
FT_PIXEL_MODE_NONE = 0
|
||||
FT_PIXEL_MODE_MONO
|
||||
FT_PIXEL_MODE_GRAY
|
||||
FT_PIXEL_MODE_GRAY2
|
||||
FT_PIXEL_MODE_GRAY4
|
||||
FT_PIXEL_MODE_LCD
|
||||
FT_PIXEL_MODE_LCD_V
|
||||
FT_PIXEL_MODE_BGRA
|
||||
FT_PIXEL_MODE_MAX
|
||||
|
||||
ctypedef struct FT_Bitmap:
|
||||
unsigned int rows
|
||||
unsigned int width
|
||||
int pitch
|
||||
unsigned char* buffer
|
||||
unsigned short num_grays
|
||||
unsigned char pixel_mode
|
||||
unsigned char palette_mode
|
||||
void* palette
|
||||
|
||||
void FT_Bitmap_New(FT_Bitmap *bitmap) # <= v2.5
|
||||
void FT_Bitmap_Init(FT_Bitmap *bitmap) # >= v2.6
|
||||
void FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
|
||||
|
||||
# For font face detection
|
||||
FT_Error FT_Init_FreeType(FT_Library *library)
|
||||
FT_Error FT_New_Face(FT_Library library, const char *pathname, long face_index, FT_Face *aface)
|
||||
FT_Error FT_Done_Face(FT_Face face)
|
||||
const char *FT_Get_Postscript_Name(FT_Face face)
|
||||
# FT_Error FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, FT_SfntName *aname)
|
||||
# FT_Error FT_Get_Sfnt_Name_Count(FT_Face face)
|
||||
|
||||
|
||||
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/t1.html
|
||||
cdef extern from "fontconfig/fontconfig.h" nogil:
|
||||
ctypedef struct FcConfig:
|
||||
pass
|
||||
ctypedef struct FcPattern:
|
||||
pass
|
||||
ctypedef struct FcValue:
|
||||
pass
|
||||
ctypedef enum FcResult:
|
||||
FcResultMatch
|
||||
FcResultNoMatch
|
||||
FcResultTypeMismatch
|
||||
FcResultNoId
|
||||
|
||||
ctypedef bint FcBool
|
||||
ctypedef unsigned char FcChar8
|
||||
bint FcTrue
|
||||
bint FcFalse
|
||||
const char *FC_FAMILY
|
||||
const char *FC_ANTIALIAS
|
||||
const char *FC_HINTING
|
||||
const char *FC_HINT_STYLE
|
||||
int FC_HINT_NONE
|
||||
int FC_HINT_SLIGHT
|
||||
int FC_HINT_MEDIUM
|
||||
int FC_HINT_FULL
|
||||
|
||||
FcConfig *FcConfigCreate()
|
||||
FcConfig *FcInitLoadConfig()
|
||||
FcConfig *FcInitLoadConfigAndFonts()
|
||||
void FcConfigDestroy(FcConfig *config)
|
||||
FcConfig *FcConfigGetCurrent()
|
||||
FcBool FcConfigSetCurrent(FcConfig *config)
|
||||
FcBool FcConfigAppFontAddFile(FcConfig *config, const FcChar8 *file)
|
||||
FcBool FcConfigAppFontAddDir(FcConfig *config, const FcChar8 *dir)
|
||||
void FcConfigAppFontClear(FcConfig *config)
|
||||
FcBool FcConfigParseAndLoad(FcConfig *config, const FcChar8 *file, FcBool complain)
|
||||
FcBool FcConfigSetRescanInterval(FcConfig *config, int rescaninterval)
|
||||
int FcConfigGetRescanInterval(FcConfig *config)
|
||||
|
||||
FcResult FcPatternGetString(FcPattern *p, const char *object, int id, FcChar8 **s)
|
||||
void FcPatternDestroy(FcPattern *p)
|
||||
FcBool FcPatternDel(FcPattern *p, const char *object)
|
||||
FcBool FcPatternAddInteger (FcPattern *p, const char *object, int i)
|
||||
FcBool FcPatternAddBool (FcPattern *p, const char *object, FcBool b)
|
||||
# FcPattern *FcPatternCreate()
|
||||
# FcBool FcPatternAddDouble (FcPattern *p, const char *object, double d)
|
||||
# FcBool FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s)
|
||||
# FcBool FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *m)
|
||||
# FcBool FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c)
|
||||
# FcBool FcPatternAddFTFace (FcPattern *p, const char *object, const FT_Facef)
|
||||
# FcBool FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *l)
|
||||
# FcBool FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r)
|
||||
|
||||
|
||||
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcfreetypequeryface.html
|
||||
cdef extern from "fontconfig/fcfreetype.h" nogil:
|
||||
FcPattern *FcFreeTypeQueryFace(const FT_Face face, const FcChar8 *file, unsigned int id, void *)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Version-Checking.html
|
||||
cdef extern from "pango/pango-utils.h":
|
||||
int PANGO_VERSION_CHECK(int major, int minor, int micro)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Glyph-Storage.html
|
||||
cdef extern from "pango/pango-types.h" nogil:
|
||||
unsigned int PANGO_SCALE
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Text-Attributes.html
|
||||
cdef extern from "pango/pango-attributes.h" nogil:
|
||||
guint PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING
|
||||
guint PANGO_ATTR_INDEX_TO_TEXT_END
|
||||
|
||||
ctypedef struct PangoAttrList:
|
||||
pass
|
||||
ctypedef struct PangoAttrIterator:
|
||||
pass
|
||||
ctypedef struct PangoAttribute:
|
||||
pass
|
||||
ctypedef struct PangoAttrClass:
|
||||
pass
|
||||
ctypedef struct PangoAttrString:
|
||||
pass
|
||||
ctypedef struct PangoAttrLanguage:
|
||||
pass
|
||||
ctypedef struct PangoAttrInt:
|
||||
pass
|
||||
ctypedef struct PangoAttrSize:
|
||||
pass
|
||||
ctypedef struct PangoAttrFloat:
|
||||
pass
|
||||
ctypedef struct PangoAttrColor:
|
||||
pass
|
||||
ctypedef struct PangoAttrFontDesc:
|
||||
pass
|
||||
ctypedef struct PangoAttrShape:
|
||||
pass
|
||||
ctypedef struct PangoAttrFontFeatures:
|
||||
pass
|
||||
ctypedef enum PangoStyle:
|
||||
PANGO_STYLE_NORMAL
|
||||
PANGO_STYLE_OBLIQUE
|
||||
PANGO_STYLE_ITALIC
|
||||
# FIXME: investigate need to handle this for different pango versions
|
||||
ctypedef enum PangoWeight:
|
||||
PANGO_WEIGHT_THIN
|
||||
PANGO_WEIGHT_ULTRALIGHT
|
||||
PANGO_WEIGHT_LIGHT
|
||||
PANGO_WEIGHT_SEMILIGHT
|
||||
PANGO_WEIGHT_BOOK
|
||||
PANGO_WEIGHT_NORMAL
|
||||
PANGO_WEIGHT_MEDIUM
|
||||
PANGO_WEIGHT_SEMIBOLD
|
||||
PANGO_WEIGHT_BOLD
|
||||
PANGO_WEIGHT_ULTRABOLD
|
||||
PANGO_WEIGHT_HEAVY
|
||||
PANGO_WEIGHT_ULTRAHEAVY
|
||||
ctypedef enum PangoUnderline:
|
||||
PANGO_UNDERLINE_NONE
|
||||
PANGO_UNDERLINE_SINGLE
|
||||
PANGO_UNDERLINE_DOUBLE
|
||||
PANGO_UNDERLINE_LOW
|
||||
PANGO_UNDERLINE_ERROR
|
||||
|
||||
PangoAttrList *pango_attr_list_new()
|
||||
PangoAttrList *pango_attr_list_ref(PangoAttrList *list)
|
||||
void pango_attr_list_unref(PangoAttrList *list)
|
||||
void pango_attr_list_insert(PangoAttrList *list, PangoAttribute *attr)
|
||||
void pango_attr_list_insert_before(PangoAttrList *list, PangoAttribute *attr)
|
||||
|
||||
PangoAttribute *pango_attr_language_new(PangoLanguage *language)
|
||||
PangoAttribute *pango_attr_family_new(const char *family)
|
||||
PangoAttribute *pango_attr_size_new(int size)
|
||||
PangoAttribute *pango_attr_size_new_absolute(int size) # v1.8+
|
||||
PangoAttribute *pango_attr_style_new(PangoStyle style)
|
||||
PangoAttribute *pango_attr_weight_new(PangoWeight weight)
|
||||
# PangoAttribute *pango_attr_variant_new(PangoVariant variant)
|
||||
# PangoAttribute *pango_attr_stretch_new(PangoStretch stretch)
|
||||
PangoAttribute *pango_attr_font_desc_new(const PangoFontDescription *desc)
|
||||
PangoAttribute *pango_attr_underline_new(PangoUnderline underline)
|
||||
PangoAttribute *pango_attr_strikethrough_new(gboolean strikethrough)
|
||||
PangoAttribute *pango_attr_font_features_new(const gchar *features) # v1.38+
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Scripts-and-Languages.html
|
||||
cdef extern from "pango/pango-language.h" nogil:
|
||||
ctypedef struct PangoLanguage:
|
||||
pass
|
||||
|
||||
PangoLanguage *pango_language_get_default()
|
||||
PangoLanguage *pango_language_from_string(const char *language)
|
||||
const char *pango_language_to_string(PangoLanguage *language)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-FreeType-Fonts-and-Rendering.html
|
||||
cdef extern from "pango/pangoft2.h" nogil:
|
||||
ctypedef struct PangoFT2FontMap:
|
||||
pass
|
||||
ctypedef void *PangoFT2SubstituteFunc
|
||||
ctypedef void *GDestroyNotify
|
||||
|
||||
PangoFT2FontMap *PANGO_FT2_FONT_MAP(PangoFontMap *fontmap)
|
||||
void pango_ft2_render_layout(FT_Bitmap *bitmap, PangoLayout *layout, int x, int y)
|
||||
void pango_ft2_render_layout_subpixel(FT_Bitmap *bitmap, PangoLayout *layout, int x, int y)
|
||||
void pango_ft2_font_map_set_default_substitute(PangoFT2FontMap *fontmap, PangoFT2SubstituteFunc func, gpointer data, GDestroyNotify notify)
|
||||
void pango_ft2_font_map_substitute_changed(PangoFT2FontMap *fontmap)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Text-Processing.html
|
||||
cdef extern from "pango/pango-context.h" nogil:
|
||||
ctypedef struct PangoContext:
|
||||
pass
|
||||
|
||||
void pango_context_set_base_dir(PangoContext *context, PangoDirection direction)
|
||||
void pango_context_set_font_description(PangoContext *context, const PangoFontDescription *desc)
|
||||
PangoDirection pango_context_get_base_dir(PangoContext *context)
|
||||
PangoFontMetrics *pango_context_get_metrics(PangoContext *context, const PangoFontDescription *desc, PangoLanguage *language)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Bidirectional-Text.html
|
||||
cdef extern from "pango/pango-bidi-type.h" nogil:
|
||||
ctypedef enum PangoDirection:
|
||||
PANGO_DIRECTION_LTR
|
||||
PANGO_DIRECTION_RTL
|
||||
PANGO_DIRECTION_TTB_LTR # deprecated
|
||||
PANGO_DIRECTION_TTB_RTL # deprecated
|
||||
PANGO_DIRECTION_WEAK_LTR
|
||||
PANGO_DIRECTION_WEAK_RTL
|
||||
PANGO_DIRECTION_NEUTRAL
|
||||
PangoDirection pango_find_base_dir(const gchar *text, gint length)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Fonts.html
|
||||
cdef extern from "pango/pango-font.h" nogil:
|
||||
ctypedef struct PangoFontMap:
|
||||
pass
|
||||
ctypedef struct PangoFontDescription:
|
||||
pass
|
||||
ctypedef struct PangoFontMetrics:
|
||||
pass
|
||||
ctypedef struct PangoFontFamily:
|
||||
pass
|
||||
|
||||
PangoFontMap *pango_ft2_font_map_new()
|
||||
PangoFontDescription* pango_font_description_new()
|
||||
PangoFontDescription* pango_font_description_from_string(const char *string)
|
||||
void pango_font_description_free(PangoFontDescription *desc)
|
||||
int pango_font_metrics_get_ascent(PangoFontMetrics *metrics)
|
||||
int pango_font_metrics_get_descent(PangoFontMetrics *metrics)
|
||||
void pango_font_metrics_unref(PangoFontMetrics *metrics)
|
||||
const char *pango_font_family_get_name(PangoFontFamily *family)
|
||||
|
||||
# Font descriptions:
|
||||
void pango_font_description_set_family(PangoFontDescription *desc, const char *family)
|
||||
const char *pango_font_description_get_family(PangoFontDescription *desc)
|
||||
|
||||
void pango_font_description_set_size(PangoFontDescription *desc, gint size)
|
||||
void pango_font_description_set_absolute_size(PangoFontDescription *desc, gint size) # v1.8+
|
||||
gint pango_font_description_get_size(PangoFontDescription *desc)
|
||||
|
||||
void pango_font_description_set_weight(PangoFontDescription *desc, PangoWeight weight)
|
||||
PangoWeight pango_font_description_get_weight(PangoFontDescription *desc)
|
||||
|
||||
void pango_font_description_set_style(PangoFontDescription *desc, PangoStyle style)
|
||||
PangoStyle pango_font_description_get_style(PangoFontDescription *desc)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Fonts.html
|
||||
cdef extern from "pango/pango-fontmap.h" nogil:
|
||||
void pango_font_map_list_families(PangoFontMap *fontmap, PangoFontFamily ***families, int *n_families)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/PangoFcFontMap.html
|
||||
cdef extern from "pango/pangofc-fontmap.h" nogil:
|
||||
ctypedef struct PangoFcFontMap:
|
||||
pass
|
||||
|
||||
PangoFcFontMap *PANGO_FC_FONT_MAP(PangoFontMap *fontmap)
|
||||
void pango_fc_font_map_set_config(PangoFcFontMap *fontmap, FcConfig *config)
|
||||
void pango_fc_font_map_config_changed(PangoFcFontMap *fontmap)
|
||||
|
||||
|
||||
# https://developer.gnome.org/pango/stable/pango-Layout-Objects.html
|
||||
cdef extern from "pango/pango-layout.h" nogil:
|
||||
ctypedef struct PangoLayout:
|
||||
pass
|
||||
|
||||
ctypedef enum PangoAlignment:
|
||||
PANGO_ALIGN_LEFT
|
||||
PANGO_ALIGN_CENTER
|
||||
PANGO_ALIGN_RIGHT
|
||||
ctypedef enum PangoWrapMode:
|
||||
PANGO_WRAP_WORD
|
||||
PANGO_WRAP_CHAR
|
||||
PANGO_WRAP_WORD_CHAR
|
||||
ctypedef enum PangoEllipsizeMode:
|
||||
PANGO_ELLIPSIZE_NONE
|
||||
PANGO_ELLIPSIZE_START
|
||||
PANGO_ELLIPSIZE_MIDDLE
|
||||
PANGO_ELLIPSIZE_END
|
||||
|
||||
PangoLayout *pango_layout_new(PangoContext *context)
|
||||
void pango_layout_context_changed(PangoLayout *layout)
|
||||
void pango_layout_set_attributes(PangoLayout *layout, PangoAttrList *attrs)
|
||||
void pango_layout_set_text(PangoLayout *layout, const char *text, int length)
|
||||
void pango_layout_set_markup(PangoLayout *layout, const char *markup, int length)
|
||||
void pango_layout_set_font_description(PangoLayout *layout, const PangoFontDescription *desc)
|
||||
void pango_layout_get_pixel_size(PangoLayout *layout, int *width, int *height)
|
||||
void pango_layout_get_size(PangoLayout *layout, int *width, int *height)
|
||||
int pango_layout_get_baseline(PangoLayout *layout)
|
||||
int pango_layout_get_line_count(PangoLayout *layout)
|
||||
int pango_layout_get_unknown_glyphs_count(PangoLayout *layout)
|
||||
gboolean pango_layout_xy_to_index(PangoLayout *layout, int x, int y, int *index, int *trailing)
|
||||
|
||||
void pango_layout_set_ellipsize(PangoLayout *layout, PangoEllipsizeMode ellipsize)
|
||||
PangoEllipsizeMode pango_layout_get_ellipsize(PangoLayout *layout)
|
||||
gboolean pango_layout_is_ellipsized(PangoLayout *layout)
|
||||
|
||||
void pango_layout_set_wrap(PangoLayout *layout, PangoWrapMode wrap)
|
||||
PangoWrapMode pango_layout_get_wrap(PangoLayout *layout)
|
||||
gboolean pango_layout_is_wrapped(PangoLayout *layout)
|
||||
|
||||
void pango_layout_set_alignment(PangoLayout *layout, PangoAlignment alignment)
|
||||
PangoAlignment pango_layout_get_alignment(PangoLayout *layout)
|
||||
void pango_layout_set_auto_dir(PangoLayout *layout, gboolean auto_dir)
|
||||
gboolean pango_layout_get_auto_dir(PangoLayout *layout)
|
||||
void pango_layout_set_width(PangoLayout *layout, int width)
|
||||
int pango_layout_get_width(PangoLayout *layout)
|
||||
void pango_layout_set_height(PangoLayout *layout, int height)
|
||||
int pango_layout_get_height(PangoLayout *layout)
|
||||
void pango_layout_set_spacing(PangoLayout *layout, int spacing)
|
||||
int pango_layout_get_spacing(PangoLayout *layout)
|
||||
void pango_layout_set_indent(PangoLayout *layout, int indent)
|
||||
int pango_layout_get_indent(PangoLayout *layout)
|
||||
void pango_layout_set_justify(PangoLayout *layout, gboolean justify)
|
||||
gboolean pango_layout_get_justify(PangoLayout *layout)
|
||||
void pango_layout_set_single_paragraph_mode(PangoLayout *layout, gboolean setting)
|
||||
gboolean pango_layout_get_single_paragraph_mode(PangoLayout *layout)
|
||||
|
||||
cdef extern from "../../lib/pango/pangoft2.h" nogil:
|
||||
PangoContext *_pango_font_map_create_context(PangoFontMap *fontmap)
|
||||
1076
kivy/lib/sdl2.pxi
Normal file
1076
kivy/lib/sdl2.pxi
Normal file
File diff suppressed because it is too large
Load Diff
0
kivy/lib/vidcore_lite/__init__.py
Normal file
0
kivy/lib/vidcore_lite/__init__.py
Normal file
BIN
kivy/lib/vidcore_lite/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
kivy/lib/vidcore_lite/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
70
kivy/lib/vidcore_lite/bcm.pxd
Normal file
70
kivy/lib/vidcore_lite/bcm.pxd
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
|
||||
cdef extern from "bcm_host.h":
|
||||
ctypedef int int32_t
|
||||
ctypedef unsigned short int uint16_t
|
||||
ctypedef unsigned int uint32_t
|
||||
|
||||
ctypedef uint32_t DISPMANX_DISPLAY_HANDLE_T
|
||||
ctypedef uint32_t DISPMANX_UPDATE_HANDLE_T
|
||||
ctypedef uint32_t DISPMANX_ELEMENT_HANDLE_T
|
||||
ctypedef uint32_t DISPMANX_RESOURCE_HANDLE_T
|
||||
ctypedef uint32_t DISPMANX_PROTECTION_T
|
||||
|
||||
struct tag_VC_RECT_T:
|
||||
int32_t x
|
||||
int32_t y
|
||||
int32_t width
|
||||
int32_t height
|
||||
|
||||
ctypedef tag_VC_RECT_T VC_RECT_T
|
||||
|
||||
ctypedef enum DISPMANX_TRANSFORM_T:
|
||||
pass
|
||||
|
||||
ctypedef struct DISPMANX_CLAMP_T:
|
||||
pass
|
||||
|
||||
ctypedef struct VC_DISPMANX_ALPHA_T:
|
||||
pass
|
||||
|
||||
void bcm_host_init()
|
||||
void bcm_host_deinit()
|
||||
|
||||
int32_t c_get_display_size "graphics_get_display_size" (uint16_t display_number,
|
||||
uint32_t *width, uint32_t *height)
|
||||
DISPMANX_DISPLAY_HANDLE_T vc_dispmanx_display_open( uint32_t device )
|
||||
DISPMANX_UPDATE_HANDLE_T vc_dispmanx_update_start( int32_t priority )
|
||||
DISPMANX_ELEMENT_HANDLE_T vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update,
|
||||
DISPMANX_DISPLAY_HANDLE_T display,
|
||||
int32_t layer,
|
||||
VC_RECT_T *dest_rect,
|
||||
DISPMANX_RESOURCE_HANDLE_T src,
|
||||
VC_RECT_T *src_rect,
|
||||
DISPMANX_PROTECTION_T protection,
|
||||
VC_DISPMANX_ALPHA_T *alpha,
|
||||
DISPMANX_CLAMP_T *clamp,
|
||||
DISPMANX_TRANSFORM_T transform )
|
||||
int vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update )
|
||||
|
||||
cdef public uint32_t DISPMANX_PROTECTION_NONE = 0
|
||||
|
||||
cdef class Rect:
|
||||
cdef:
|
||||
VC_RECT_T _vc_rect
|
||||
|
||||
|
||||
cdef class DisplayHandle:
|
||||
cdef DISPMANX_DISPLAY_HANDLE_T _handle
|
||||
|
||||
cdef class UpdateHandle:
|
||||
cdef DISPMANX_UPDATE_HANDLE_T _handle
|
||||
|
||||
cdef class ResourceHandle:
|
||||
cdef DISPMANX_RESOURCE_HANDLE_T _handle
|
||||
|
||||
cdef class ProtectionHandle:
|
||||
cdef DISPMANX_PROTECTION_T _handle
|
||||
|
||||
cdef class ElementHandle:
|
||||
cdef DISPMANX_ELEMENT_HANDLE_T _handle
|
||||
Reference in New Issue
Block a user