#pragma once

#include <imgui.h>

#include <glm/glm.hpp>
#include <string>

using namespace glm;

namespace game::util::imgui
{
  inline constexpr auto TEXT_FIT_FONT_SIZE_MIN = 1.0f;

  enum class TriangleDirection
  {
    LEFT,
    RIGHT
  };

  float row_widget_width_get(int = 1, float = ImGui::GetContentRegionAvail().x);
  ImVec2 row_widget_size_get(int = 1, float = ImGui::GetContentRegionAvail().x);

  float footer_height_get(int = 1);
  ImVec2 footer_size_get(int = 1);
  ImVec2 size_without_footer_get(int = 1);
  float side_bar_width_get();
  void triangle_draw(ImDrawList&, ImVec2, ImVec2, TriangleDirection, ImU32);
  ImVec2 draw_list_text_size_get(const char*, float);
  ImVec2 draw_list_text_size_get(const std::string&, float);
  void draw_list_text_draw(ImDrawList&, ImVec2, const std::string&, float, ImU32);
  ImVec2 draw_list_text_center_position_get(ImVec2, ImVec2, const std::string&, float, float, float);
  void draw_list_text_center_draw(ImDrawList&, ImVec2, ImVec2, const std::string&, float, float, float, ImU32);
  float draw_list_digit_fixed_width_get(const std::string&, float);
  void draw_list_digit_fixed_width_draw(ImDrawList&, ImVec2, const std::string&, float, ImU32);
  float text_font_size_fit_get(const char*, ImVec2, float, float = TEXT_FIT_FONT_SIZE_MIN);
  float text_unformatted_fit_draw(const char*, ImVec2, float, float = TEXT_FIT_FONT_SIZE_MIN);

  inline ImVec2 to_imvec2(vec2 value) { return ImVec2(value.x, value.y); }
  inline ImVec2 to_imvec2(ivec2 value) { return ImVec2((float)value.x, (float)value.y); }
  inline vec2 to_vec2(ImVec2 value) { return vec2(value.x, value.y); }
  inline ivec2 to_ivec2(ImVec2 value) { return ivec2(value.x, value.y); }

  inline ImVec4 to_imvec4(vec4 value) { return ImVec4(value.r, value.g, value.b, value.a); }
  inline vec4 to_vec4(ImVec4 value) { return vec4(value.x, value.y, value.z, value.w); }
}
