forked from ScoDoc/ScoDoc
wip
This commit is contained in:
parent
8860b02777
commit
36e49c8106
@ -115,7 +115,7 @@ class SCO_VALIGN(Enum):
|
|||||||
free = 0
|
free = 0
|
||||||
|
|
||||||
|
|
||||||
class Composante:
|
class Composante(abc.ABC):
|
||||||
def __init__(self, base=None, width: int = 1):
|
def __init__(self, base=None, width: int = 1):
|
||||||
global free
|
global free
|
||||||
if base is None:
|
if base is None:
|
||||||
@ -136,6 +136,9 @@ class Composante:
|
|||||||
def write(self, index, signature=0) -> int:
|
def write(self, index, signature=0) -> int:
|
||||||
return self.clear(signature) + (index << self.base)
|
return self.clear(signature) + (index << self.base)
|
||||||
|
|
||||||
|
def make_zero_based_constant(self, enums: list[Enum] = None):
|
||||||
|
return 0
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def build(self, value: int):
|
def build(self, value: int):
|
||||||
pass
|
pass
|
||||||
@ -188,7 +191,8 @@ class Composante_Colors(Composante):
|
|||||||
|
|
||||||
class Composante_borderThickness(Composante):
|
class Composante_borderThickness(Composante):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(width=2)
|
assert (1 << 3) > SCO_BORDERTHICKNESS.__len__()
|
||||||
|
super().__init__(width=3)
|
||||||
|
|
||||||
def set(self, data: SCO_BORDERTHICKNESS, signature=0) -> int:
|
def set(self, data: SCO_BORDERTHICKNESS, signature=0) -> int:
|
||||||
return self.write(data.value, signature)
|
return self.write(data.value, signature)
|
||||||
@ -410,11 +414,13 @@ class Composante_group(Composante):
|
|||||||
self.cache[value] = self.build(signature)
|
self.cache[value] = self.build(signature)
|
||||||
return self.cache[value]
|
return self.cache[value]
|
||||||
|
|
||||||
def make_zero_based(self, values: list[Enum]):
|
def make_zero_based_constant(self, enums: list[Enum] = None) -> int:
|
||||||
|
if enums is None:
|
||||||
|
return 0
|
||||||
signature = 0
|
signature = 0
|
||||||
for value, composante in zip(values, self.composantes):
|
for enum, composante in zip(enums, self.composantes):
|
||||||
breakpoint()
|
signature += composante.write(enum.value)
|
||||||
pass
|
return signature >> self.base
|
||||||
|
|
||||||
|
|
||||||
class Composante_fill(Composante_group):
|
class Composante_fill(Composante_group):
|
||||||
@ -546,6 +552,9 @@ class FMT(Enum):
|
|||||||
def get_style(self, signature: int):
|
def get_style(self, signature: int):
|
||||||
return self.composante.lookup_or_cache(signature)
|
return self.composante.lookup_or_cache(signature)
|
||||||
|
|
||||||
|
def make_zero_based_constant(self, enums: list[Enum]) -> int:
|
||||||
|
return self.composante.make_zero_based_constant(enums=enums)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def compose(cls, composition: list, signature: int = 0) -> int:
|
def compose(cls, composition: list, signature: int = 0) -> int:
|
||||||
for field, value in composition:
|
for field, value in composition:
|
||||||
@ -585,3 +594,10 @@ class FMT(Enum):
|
|||||||
BORDERS = Composante_borders(BORDER_LEFT, BORDER_RIGHT, BORDER_TOP, BORDER_BOTTOM)
|
BORDERS = Composante_borders(BORDER_LEFT, BORDER_RIGHT, BORDER_TOP, BORDER_BOTTOM)
|
||||||
ALIGNMENT = Composante_alignment(ALIGNMENT_HALIGN, ALIGNMENT_VALIGN)
|
ALIGNMENT = Composante_alignment(ALIGNMENT_HALIGN, ALIGNMENT_VALIGN)
|
||||||
ALL = Composante_all(FONT, FILL, BORDERS, ALIGNMENT, NUMBER_FORMAT)
|
ALL = Composante_all(FONT, FILL, BORDERS, ALIGNMENT, NUMBER_FORMAT)
|
||||||
|
|
||||||
|
|
||||||
|
breakpoint()
|
||||||
|
THIN_BLACK: int = FMT.BORDER_LEFT.composante.make_zero_based_constant(
|
||||||
|
enums=[SCO_BORDERTHICKNESS.BORDER_THIN, SCO_COLORS.BLACK]
|
||||||
|
)
|
||||||
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user