{#
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
SPDX-FileCopyrightText: 2025 Arjen Hiemstra <ahiemstra@heimr.nl>

This is the template that is used to generate property declarations for CSS properties.

REUSE-IgnoreStart
#}
/*
    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
    SPDX-FileCopyrightText: 2025 Arjen Hiemstra <ahiemstra@heimr.nl>

    This file is automatically generated from properties.css.j2.
    To regenerate, run `tools/propertygenerator/generate_properties.py`.
*/
{# REUSE-IgnoreEnd #}

{#
This mapping is used to map property names to more familiar CSS property names
from web CSS, without needing to change the structure of properties.
#}
{%- set name_map = {
    "layout-width": "width",
    "layout-height": "height",
    "layout-spacing": "spacing",
    "layout-padding-left": "padding-left",
    "layout-padding-right": "padding-right",
    "layout-padding-top": "padding-top",
    "layout-padding-bottom": "padding-bottom",
    "layout-inset-left": "inset-left",
    "layout-inset-right": "inset-right",
    "layout-inset-top": "inset-top",
    "layout-inset-bottom": "inset-bottom",
    "layout-margins-left": "margin-left",
    "layout-margins-right": "margin-right",
    "layout-margins-top": "margin-top",
    "layout-margins-bottom": "margin-bottom",
    "palette-tool-tip-base": "palette-tooltip-base",
    "palette-tool-tip-text": "palette-tooltip-text",
    "text-font": "font-family",
    "border-left-size": "border-left-width",
    "border-right-size": "border-right-width",
    "border-top-size": "border-top-width",
    "border-bottom-size": "border-bottom-width",
    "corners-top-left-radius": "border-top-left-radius",
    "corners-top-right-radius": "border-top-right-radius",
    "corners-bottom-left-radius": "border-bottom-left-radius",
    "corners-bottom-right-radius": "border-bottom-right-radius",
}%}

{# A map of C++ property types to CSS syntax strings. #}
{%- set type_map = {
    "Union::Color": "<color>",
    "qreal": "<length>",
    "int": "<integer>",
    "QString": "<string>",
    "QUrl": "<url>",
    "QFont": "<string>",
    "Union::Properties::AlignmentContainer": "item | content | background",
    "Union::Properties::Alignment": "start | center | end | fill | stack-center | stack-fill",
    "Union::Properties::TextWrapMode": "no-wrap | word-wrap | manual-wrap | wrap-anywhere | wrap-at-word-boundary-or-anywhere | wrap",
    "Union::Properties::TextElide": "none | left | middle | right",
}%}

{# Recursively print all properties of an object, with a prefix #}
{% macro print_properties(name, object) %}
{% for property in object.properties %}
{% if property.is_group %}
{% set name = name + "-" + property.name if name else property.name %}
{{ print_properties(name, property.type_object) }}
{% elif property.type in type_map %}
{% set name = (name + "-" + property.name) | css_name %}
{% set name = name_map[name] if name in name_map else name %}
@property {{ name }} {
    syntax: "{{ type_map[property.type] }}";
}

{% endif %}
{% endfor %}
{% endmacro %}

{% for type in types %}
{% if type.name == "style" %}
{{ print_properties("", type) }}
{% endif %}
{% endfor %}
