// This code is auto-generated by Qul's qmltocpp tool from the file 'Button.qml'
// WARNING! All changes made in this file will be lost!
#include "Button.h"
#include <qul/private/graphicsdevice.h>
#include <qul/private/filecache.h>

#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif

extern const Qul::Private::RasterBuffer *const qul_rasterBuffer_button_2Dpressed_11482530446956379099_handle;
extern const Qul::Private::RasterBuffer *const qul_rasterBuffer_button_15269041248754601604_handle;
extern const Qul::Private::RasterBuffer *const qul_rasterBuffer_button_2Ddisabled_9672076571956466492_handle;
static const Qul::Private::String qulCurrentFileDir(".", 1);
namespace QtQuick {
namespace Controls {
namespace StyleDefault {
extern Qul::Private::Items::ItemBase *loaderItemAllocator(const Qul::Private::String &uri, const Qul::Private::String &currentFileDir);

} // namespace QtQuick
} // namespace Controls
} // namespace StyleDefault
namespace Qul { namespace Private {
Qul::Property<int> &translationIndexProperty_main();
extern uint32_t qul_translation_base_offset_c31e576f691f2515d12389f4124655a9c1b19de6();
extern const char *qul_translation_string(int lang, uint32_t base, int entry);
}}

namespace QtQuick {
namespace Controls {
namespace StyleDefault {

namespace {
#if defined(QUL_CC_IAR)
#pragma diag_suppress=Pe177 // declared but never referenced
#elif defined(QUL_CC_GNU)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
static Qul::Property<int> &translationIndexProperty() { return Qul::Private::translationIndexProperty_main(); }
static int translationIndex() { return translationIndexProperty().value(); }
static const char *qul_translation(int entry) {
    const uint32_t base_offset = Qul::Private::qul_translation_base_offset_c31e576f691f2515d12389f4124655a9c1b19de6();
    return Qul::Private::qul_translation_string(translationIndex(), base_offset, entry);
}
#if defined(QUL_CC_IAR)
#pragma diag_default=Pe177 // declared but never referenced
#elif defined(QUL_CC_GNU)
#pragma GCC diagnostic pop
#endif
}


int Button::anchor_functor::operator()(Button *self, int _switch_index) const
{
    int properties[1] = {};

    switch(_switch_index) {
    case 0: properties[0] = self->item_.width.value();  break;
    case 1: properties[0] = self->item_.height.value();  break;
    }
    return int(properties[0]);
}

Qul::SharedImage Button::Button_182579060_bindingFunctor::operator()(Button *self) const
{
    (void) self;
    bool r2__down = false;
    QUL_DECL_UNUSED Button * r2 = NULL;
    QUL_DECL_UNUSED Qul::Private::String r2_1;
    // source: control.enabled
    // line 45  "Button.qml"
    r2 = self;
    r2__down = r2->enabled.value();
    if (!r2__down) goto label_0;;
    r2 = self;
    // ? (control.down ? "qrc:/images/button-pressed.png" : "qrc:/images/button.png")
    // line 46  "Button.qml"
    r2__down = r2->down.value();
    if (!r2__down) goto label_1;;
    r2_1 = Qul::Private::String(Qul::Private::ImageIdValue::create("qrc:/images/button-pressed.png", qul_rasterBuffer_button_2Dpressed_11482530446956379099_handle), 30);
    goto label_2;;
    label_1:;
    r2_1 = Qul::Private::String(Qul::Private::ImageIdValue::create("qrc:/images/button.png", qul_rasterBuffer_button_15269041248754601604_handle), 22);
    label_2:;
    goto label_3;;
    label_0:;
    r2_1 = Qul::Private::String(Qul::Private::ImageIdValue::create("qrc:/images/button-disabled.png", qul_rasterBuffer_button_2Ddisabled_9672076571956466492_handle), 31);
    label_3:;
    // : "qrc:/images/button-disabled.png"
    // line 47  "Button.qml"
    return Qul::Private::findImageForString(r2_1);
    
}
Qul::PlatformInterface::Rgba32 Button::Button_366292497_bindingFunctor::operator()(Button *self) const
{
    (void) self;
    QUL_DECL_UNUSED Qul::PlatformInterface::Rgba32 r2__disabledTextColor;
    bool r2__enabled = false;
    QUL_DECL_UNUSED Button * r2 = NULL;
    QUL_DECL_UNUSED  ::QtQuick::Controls::StyleDefault::DefaultStyle * r2_3 = NULL;
    // color: control.enabled ? DefaultStyle.textColor : DefaultStyle.disabledTextColor
    // line 31  "Button.qml"
    r2 = self;
    r2__enabled = r2->enabled.value();
    if (!r2__enabled) goto label_0;;
    r2_3 = & ::QtQuick::Controls::StyleDefault::DefaultStyle ::instance();
    r2__disabledTextColor = r2_3->textColor.value();
    goto label_1;;
    label_0:;
    r2_3 = & ::QtQuick::Controls::StyleDefault::DefaultStyle ::instance();
    r2__disabledTextColor = r2_3->disabledTextColor.value();
    label_1:;
    return r2__disabledTextColor;
    
}
Qul::Private::FontPointer Button::Button_3934977972_bindingFunctor::operator()(Button *self) const
{
    (void) self;
    QUL_DECL_UNUSED Button * r2 = NULL;
    QUL_DECL_UNUSED Qul::Private::FontPointer r2__font;
    // font: control.font
    // line 30  "Button.qml"
    r2 = self;
    r2__font = r2->font.value();
    return r2__font;
    
}
Qul::Private::String Button::Button_1880257050_bindingFunctor::operator()(Button *self) const
{
    (void) self;
    QUL_DECL_UNUSED Button * r2 = NULL;
    QUL_DECL_UNUSED Qul::Private::String r2__text;
    // text: control.text
    // line 29  "Button.qml"
    r2 = self;
    r2__text = r2->text.value();
    return r2__text;
    
}
int Button::Button_1979022036_bindingFunctor::operator()(Button *self) const
{
    (void) self;
    int r2_2 = 0;
    Qul::qreal r2_1 = 0.0;
    QUL_DECL_UNUSED Qul::Private::Builtins::Math * r2 = NULL;
    QUL_DECL_UNUSED Qul::Private::Items::ItemBase * r2_3 = NULL;
    int r10 = 0;
    int r12 = 0;
    int r11 = 0;
    QUL_DECL_UNUSED Qul::Private::Builtins::Math * r7 = NULL;
    int r13 = 0;
    // implicitHeight: Math.max((background ? background.implicitHeight : 0) + topInset + bottomInset,
    // line 12  "Button.qml"
    r2 = &Qul::Private::Builtins::Math ::instance();
    r7 = r2;
    r2_3 = self->background.value();
    if (!r2_3) goto label_0;;
    r2_3 = self->background.value();
    r2_2 = r2_3->itemExtraProperties->implicitHeight.value();
    goto label_1;;
    label_0:;
    r2_2 = 0;
    label_1:;
    r12 = r2_2;
    r2_2 = self->topInset.value();
    r2_2 = r12 + r2_2;
    r13 = r2_2;
    r2_2 = self->bottomInset.value();
    r2_2 = r13 + r2_2;
    r10 = r2_2;
    // (contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding)
    // line 13  "Button.qml"
    r2_3 = self->contentItem.value();
    if (!r2_3) goto label_2;;
    r2_3 = self->contentItem.value();
    r2_2 = r2_3->itemExtraProperties->implicitHeight.value();
    goto label_3;;
    label_2:;
    r2_2 = 0;
    label_3:;
    r12 = r2_2;
    r2_2 = self->topPadding.value();
    r2_2 = r12 + r2_2;
    r13 = r2_2;
    r2_2 = self->bottomPadding.value();
    r2_2 = r13 + r2_2;
    r11 = r2_2;
    r2_1 = r7->max(r10, r11);
    return int(r2_1);
    
}
int Button::Button_3988550022_bindingFunctor::operator()(Button *self) const
{
    (void) self;
    int r2_2 = 0;
    Qul::qreal r2_1 = 0.0;
    QUL_DECL_UNUSED Qul::Private::Builtins::Math * r2 = NULL;
    QUL_DECL_UNUSED Qul::Private::Items::ItemBase * r2_3 = NULL;
    int r10 = 0;
    int r12 = 0;
    int r11 = 0;
    QUL_DECL_UNUSED Qul::Private::Builtins::Math * r7 = NULL;
    int r13 = 0;
    // implicitWidth: Math.max((background ? background.implicitWidth : 0) + leftInset + rightInset,
    // line 10  "Button.qml"
    r2 = &Qul::Private::Builtins::Math ::instance();
    r7 = r2;
    r2_3 = self->background.value();
    if (!r2_3) goto label_0;;
    r2_3 = self->background.value();
    r2_2 = r2_3->itemExtraProperties->implicitWidth.value();
    goto label_1;;
    label_0:;
    r2_2 = 0;
    label_1:;
    r12 = r2_2;
    r2_2 = self->leftInset.value();
    r2_2 = r12 + r2_2;
    r13 = r2_2;
    r2_2 = self->rightInset.value();
    r2_2 = r13 + r2_2;
    r10 = r2_2;
    // (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding)
    // line 11  "Button.qml"
    r2_3 = self->contentItem.value();
    if (!r2_3) goto label_2;;
    r2_3 = self->contentItem.value();
    r2_2 = r2_3->itemExtraProperties->implicitWidth.value();
    goto label_3;;
    label_2:;
    r2_2 = 0;
    label_3:;
    r12 = r2_2;
    r2_2 = self->leftPadding.value();
    r2_2 = r12 + r2_2;
    r13 = r2_2;
    r2_2 = self->rightPadding.value();
    r2_2 = r13 + r2_2;
    r11 = r2_2;
    r2_1 = r7->max(r10, r11);
    return int(r2_1);
    
}

Button::Button()

    : borderimage_width_anchor_binding(anchor_functor())
    , borderimage_height_anchor_binding(anchor_functor())
    , ExtraStorage_itemExtraProperties_this_instance(this)
    , ExtraStorage_itemExtraProperties_item__instance(&item_)
    , ExtraStorage_itemExtraProperties_text__instance(&text_)
    , borderimage_source_binding(Button_182579060_bindingFunctor())
    , text__color_binding(Button_366292497_bindingFunctor())
    , font_font_binding(Button_3934977972_bindingFunctor())
    , text__text_binding(Button_1880257050_bindingFunctor())
    , _implicitHeight_binding(Button_1979022036_bindingFunctor())
    , _implicitWidth_binding(Button_3988550022_bindingFunctor())
{
    // horizontalAlignment: Text.AlignHCenter
    // line 32  "Button.qml"
    text_.horizontalAlignment.setValue(Qul::Private::Items::Text::AlignHCenter);
    // verticalAlignment: Text.AlignVCenter
    // line 33  "Button.qml"
    text_.verticalAlignment.setValue(Qul::Private::Items::Text::AlignVCenter);
#if __cplusplus < 201103L
    // border.bottom: 27
    // line 44  "Button.qml"
    borderimage.border.bottom.setValue(27);
    // border.right: 22
    // line 43  "Button.qml"
    borderimage.border.right.setValue(22);
    // border.left: 22
    // line 42  "Button.qml"
    borderimage.border.left.setValue(22);
    // border.top: 18
    // line 41  "Button.qml"
    borderimage.border.top.setValue(18);
    // bottomInset: DefaultStyle.inset - 18
    // line 26  "Button.qml"
    bottomInset.setValue(-13);
    // rightInset: DefaultStyle.inset - 12
    // line 25  "Button.qml"
    rightInset.setValue(-7);
    // topInset: DefaultStyle.inset - 6
    // line 24  "Button.qml"
    topInset.setValue(-1);
    // leftInset: DefaultStyle.inset - 12
    // line 23  "Button.qml"
    leftInset.setValue(-7);
    // bottomPadding: 16
    // line 18  "Button.qml"
    bottomPadding.setValue(16);
    // rightPadding: 16
    // line 17  "Button.qml"
    rightPadding.setValue(16);
    // topPadding: 22
    // line 16  "Button.qml"
    topPadding.setValue(22);
    // leftPadding: 16
    // line 15  "Button.qml"
    leftPadding.setValue(16);
#else
    using OffsetType14508472848368190223 = Qul::Private::Choose<uint16_t, uint32_t, (UINT16_MAX >
        Qul::Private::Max<offsetof(Button, borderimage.border.bottom) / 4,
        Qul::Private::Max<offsetof(Button, borderimage.border.right) / 4,
        Qul::Private::Max<offsetof(Button, borderimage.border.left) / 4,
        Qul::Private::Max<offsetof(Button, borderimage.border.top) / 4,
        Qul::Private::Max<offsetof(Button, bottomInset) / 4,
        Qul::Private::Max<offsetof(Button, rightInset) / 4,
        Qul::Private::Max<offsetof(Button, topInset) / 4,
        Qul::Private::Max<offsetof(Button, leftInset) / 4,
        Qul::Private::Max<offsetof(Button, bottomPadding) / 4,
        Qul::Private::Max<offsetof(Button, rightPadding) / 4,
        Qul::Private::Max<offsetof(Button, topPadding) / 4,
        Qul::Private::Max<offsetof(Button, leftPadding) / 4,
        0
        >::V>::V>::V>::V>::V>::V>::V>::V>::V>::V>::V>::V
        )>::Type;
    OffsetType14508472848368190223 propertyOffsets14508472848368190223[] = {
        std::is_same<decltype(borderimage.border.bottom), Qul::Property<int>>::value ? (offsetof(Button, borderimage.border.bottom) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(borderimage.border.right), Qul::Property<int>>::value ? (offsetof(Button, borderimage.border.right) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(borderimage.border.left), Qul::Property<int>>::value ? (offsetof(Button, borderimage.border.left) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(borderimage.border.top), Qul::Property<int>>::value ? (offsetof(Button, borderimage.border.top) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(bottomInset), Qul::Property<int>>::value ? (offsetof(Button, bottomInset) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(rightInset), Qul::Property<int>>::value ? (offsetof(Button, rightInset) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(topInset), Qul::Property<int>>::value ? (offsetof(Button, topInset) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(leftInset), Qul::Property<int>>::value ? (offsetof(Button, leftInset) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(bottomPadding), Qul::Property<int>>::value ? (offsetof(Button, bottomPadding) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(rightPadding), Qul::Property<int>>::value ? (offsetof(Button, rightPadding) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(topPadding), Qul::Property<int>>::value ? (offsetof(Button, topPadding) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
        std::is_same<decltype(leftPadding), Qul::Property<int>>::value ? (offsetof(Button, leftPadding) / 4) : std::numeric_limits<OffsetType14508472848368190223>::max(),
    };
    static constexpr int8_t propertyValues14508472848368190223[] = {
        // border.bottom: 27
        // line 44  "Button.qml"
        27,
        // border.right: 22
        // line 43  "Button.qml"
        22,
        // border.left: 22
        // line 42  "Button.qml"
        22,
        // border.top: 18
        // line 41  "Button.qml"
        18,
        // bottomInset: DefaultStyle.inset - 18
        // line 26  "Button.qml"
        -13,
        // rightInset: DefaultStyle.inset - 12
        // line 25  "Button.qml"
        -7,
        // topInset: DefaultStyle.inset - 6
        // line 24  "Button.qml"
        -1,
        // leftInset: DefaultStyle.inset - 12
        // line 23  "Button.qml"
        -7,
        // bottomPadding: 16
        // line 18  "Button.qml"
        16,
        // rightPadding: 16
        // line 17  "Button.qml"
        16,
        // topPadding: 22
        // line 16  "Button.qml"
        22,
        // leftPadding: 16
        // line 15  "Button.qml"
        16,
    };
    Qul::Private::initializeProperties<int>(this, propertyOffsets14508472848368190223, propertyValues14508472848368190223,
        sizeof(propertyOffsets14508472848368190223) / sizeof(propertyOffsets14508472848368190223[0]));
    // border.bottom: 27
    // line 44  "Button.qml"
    if (!std::is_same<decltype(borderimage.border.bottom), Qul::Property<int>>::value)
        borderimage.border.bottom.setValue(27);
    // border.right: 22
    // line 43  "Button.qml"
    if (!std::is_same<decltype(borderimage.border.right), Qul::Property<int>>::value)
        borderimage.border.right.setValue(22);
    // border.left: 22
    // line 42  "Button.qml"
    if (!std::is_same<decltype(borderimage.border.left), Qul::Property<int>>::value)
        borderimage.border.left.setValue(22);
    // border.top: 18
    // line 41  "Button.qml"
    if (!std::is_same<decltype(borderimage.border.top), Qul::Property<int>>::value)
        borderimage.border.top.setValue(18);
    // bottomInset: DefaultStyle.inset - 18
    // line 26  "Button.qml"
    if (!std::is_same<decltype(bottomInset), Qul::Property<int>>::value)
        bottomInset.setValue(-13);
    // rightInset: DefaultStyle.inset - 12
    // line 25  "Button.qml"
    if (!std::is_same<decltype(rightInset), Qul::Property<int>>::value)
        rightInset.setValue(-7);
    // topInset: DefaultStyle.inset - 6
    // line 24  "Button.qml"
    if (!std::is_same<decltype(topInset), Qul::Property<int>>::value)
        topInset.setValue(-1);
    // leftInset: DefaultStyle.inset - 12
    // line 23  "Button.qml"
    if (!std::is_same<decltype(leftInset), Qul::Property<int>>::value)
        leftInset.setValue(-7);
    // bottomPadding: 16
    // line 18  "Button.qml"
    if (!std::is_same<decltype(bottomPadding), Qul::Property<int>>::value)
        bottomPadding.setValue(16);
    // rightPadding: 16
    // line 17  "Button.qml"
    if (!std::is_same<decltype(rightPadding), Qul::Property<int>>::value)
        rightPadding.setValue(16);
    // topPadding: 22
    // line 16  "Button.qml"
    if (!std::is_same<decltype(topPadding), Qul::Property<int>>::value)
        topPadding.setValue(22);
    // leftPadding: 16
    // line 15  "Button.qml"
    if (!std::is_same<decltype(leftPadding), Qul::Property<int>>::value)
        leftPadding.setValue(16);
#endif
    // implicitHeight: 66
    // line 38  "Button.qml"
    item_.itemExtraProperties->implicitHeight.setValue(66);
    // implicitWidth: 136
    // line 37  "Button.qml"
    item_.itemExtraProperties->implicitWidth.setValue(136);
    // BorderImage {
    // line 40  "Button.qml"
    appendChild(&this->item_, &borderimage);
    borderimage.x.setValue(int());
    borderimage_width_anchor_binding.init<Button, &Button::borderimage_width_anchor_binding, 0>(borderimage.width);
    borderimage.width.setBinding(&borderimage_width_anchor_binding);
    borderimage.y.setValue(int());
    borderimage_height_anchor_binding.init<Button, &Button::borderimage_height_anchor_binding, 1>(borderimage.height);
    borderimage.height.setBinding(&borderimage_height_anchor_binding);
    borderimage_source_binding.init<Button, &Button::borderimage_source_binding>(borderimage.source);
    // source: control.enabled
    // line 45  "Button.qml"
    borderimage.source.setBinding (&borderimage_source_binding);
    // background: Item {
    // line 36  "Button.qml"
    background.setValue(&item_);
    text__color_binding.init<Button, &Button::text__color_binding>(text_.color);
    // color: control.enabled ? DefaultStyle.textColor : DefaultStyle.disabledTextColor
    // line 31  "Button.qml"
    text_.color.setBinding (&text__color_binding);
    font_font_binding.init<Button, &Button::font_font_binding>(text_.font);
    // font: control.font
    // line 30  "Button.qml"
    text_.font.setBinding (&font_font_binding);
    text__text_binding.init<Button, &Button::text__text_binding>(text_.text);
    // text: control.text
    // line 29  "Button.qml"
    text_.text.setBinding (&text__text_binding);
    // contentItem: Text {
    // line 28  "Button.qml"
    contentItem.setValue(&text_);
    _implicitHeight_binding.init<Button, &Button::_implicitHeight_binding>(itemExtraProperties->implicitHeight);
    // implicitHeight: Math.max((background ? background.implicitHeight : 0) + topInset + bottomInset,
    // line 12  "Button.qml"
    itemExtraProperties->implicitHeight.setBinding (&_implicitHeight_binding);
    _implicitWidth_binding.init<Button, &Button::_implicitWidth_binding>(itemExtraProperties->implicitWidth);
    // implicitWidth: Math.max((background ? background.implicitWidth : 0) + leftInset + rightInset,
    // line 10  "Button.qml"
    itemExtraProperties->implicitWidth.setBinding (&_implicitWidth_binding);
}

} // namespace QtQuick
} // namespace Controls
} // namespace StyleDefault
