示例#1
0
    def _renderImpl(self, **kwargs):
        a = self.attrs

        LayoutAttributeParser.parseScale(a, True, kwargs)
        LayoutAttributeParser.parseAlignment(a, True, kwargs)
        LayoutAttributeParser.parsePadding(a, True, kwargs, group=a.styleGroup, defaultValue=GeneralSizeEnum.xsmall[0])

        color = a.getAsColorValue(TagAttributesEnum.COLOR, ArgsUtils.get("colorDef", None, kwargs), kwargs)

        if not ArgsUtils.get("skipBorder", False, kwargs):
            LayoutAttributeParser.parseBorder(
                a,
                True,
                kwargs,
                group=a.styleGroup,
                defaultColor=ArgsUtils.get("borderColorDef", color.shiftColors[1] if color else None, kwargs),
            )

        # -------------------------------------------------------------------------------------------
        # BACKGROUND COLOR
        if not ArgsUtils.get("skipBackground", False, kwargs):
            if isinstance(color, ColorValue):
                a.styles.add("background-color", color.web, a.styleGroup)
            elif a.explicitAccent or a.themeChanged:
                self.useBackground()

        a.classes.add("sfml-push", a.styleGroup)
示例#2
0
    def _renderImpl(self, **kwargs):
        a = self.attrs

        LayoutAttributeParser.parseScale(a, True, kwargs)
        LayoutAttributeParser.parseAlignment(a, True, kwargs)
        LayoutAttributeParser.parsePadding(
            a, True, kwargs, group=a.styleGroup, defaultValue=GeneralSizeEnum.xsmall[0])

        color = a.getAsColorValue(
            TagAttributesEnum.COLOR,
            ArgsUtils.get('colorDef', None, kwargs),
            kwargs)

        if not ArgsUtils.get('skipBorder', False, kwargs):
            LayoutAttributeParser.parseBorder(
                a, True, kwargs,
                group=a.styleGroup,
                defaultColor=ArgsUtils.get(
                    'borderColorDef', color.shiftColors[1] if color else None, kwargs) )

        inline = a.getAsBool(
            TagAttributesEnum.INLINE,
            ArgsUtils.get('inlineDef', None, kwargs),
            kwargs)

        roundness = a.getAsEnumerated(
            TagAttributesEnum.ROUNDNESS,
            GeneralSizeEnum,
            ArgsUtils.get('roundnessDef', GeneralSizeEnum.none, kwargs),
            kwargs)

        #-------------------------------------------------------------------------------------------
        # BACKGROUND COLOR
        if not ArgsUtils.get('skipBackground', False, kwargs):
            if isinstance(color, ColorValue):
                a.styles.add('background-color', color.web, a.styleGroup)
            elif a.explicitAccent or a.themeChanged:
                self.useBackground()

        #-------------------------------------------------------------------------------------------
        # ROUNDNESS
        if roundness == 'xxs':
            r = '0.13em'
        elif roundness == 'xs':
            r = '0.25em'
        elif roundness == 's':
            r = '0.5em'
        elif roundness == 'm':
            r = '0.75em'
        elif roundness == 'l':
            r = '1.0em'
        elif roundness == 'xl':
            r = '1.25em'
        elif roundness == 'xxl':
            r = '1.5em'
        else:
            r = None

        if r:
            a.styles.add('border-radius', r, a.styleGroup)

        if inline:
            a.styles.add('display', 'inline-block')

        a.classes.add('v-gvml-push', a.styleGroup)