#pragma once

#include <QString>

class Node {
public:
    Node() = default;

    void setBounds(const int x1, const int y1, const int x2, const int y2) {
        m_x1 = x1;
        m_y1 = y1;
        m_x2 = x2;
        m_y2 = y2;
    }

    bool isEmpty() {
        return m_x1 < 0 && m_y1 < 0 && m_x2 < 0 && m_y2 < 0 && text.isEmpty() && className.isEmpty();
    }

    /**
    * const int x = (x1() + x2()) / 2;
    * const int y = (y1() + y2()) / 2;
    */
    [[nodiscard]] int x() const {
        if (m_x1 < 0) {
            return -1;
        }
        return m_x1 + (m_x2 - m_x1) / 2;
    }

    [[nodiscard]] int y() const {
        if (m_y1 < 0) {
            return -1;
        }
        return m_y1 + (m_y2 - m_y1) / 2;
    }

    QString text;
    QString resourceId;
    QString className;
    bool clickable = false;
    bool focusable = false;

private:
    int m_x1 = -1, m_y1 = -1, m_x2 = -1, m_y2 = -1;
};
