#pragma once

#include "RmlUi/Core/Element.h"
#include "RmlUi/Core/EventListener.h"

namespace UI::FieldSelect {

class Component;

class ClickListener : public Rml::EventListener {
  public:
    ClickListener(Component *component) : component(component) {}
    void ProcessEvent(Rml::Event &) override;

  private:
    Component *component = nullptr;
};

class Component : public Rml::Element {
  public:
    bool is_open = false;

    Component(const Rml::String &tag) : Rml::Element(tag) {}

  protected:
    void OnAttributeChange(const Rml::ElementAttributes &changed) override;

  private:
    bool built = false;
    ClickListener *click_listener = nullptr;

    void Build();
    void Update();
};

} // namespace UI::FieldSelect
