#include <Utilities/TemperatureScale.hpp>
#include <Widget/Thermometer/Thermometer.hpp>
#include <ToolTip/ToolTip.hpp>
#include <Utilities/Utilities.hpp>

Thermometer::Thermometer(int &temperature, int maxTemperature) :
    m_temperature(temperature),
    m_maxTemperature(maxTemperature)
{}

glm::ivec2 Thermometer::getMinSize()
{
    return glm::ivec2(7, 100);
}

void Thermometer::draw(GraphicsContext &context)
{
    context.color = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
    context.drawRect(0, 0, 7, m_size[1]);

    context.color = Color::faded;
    context.drawRect(1, 1, 5, m_size[1]-2);

    int maxTempHeight = m_size[1]-2;
    int tempHeight = m_temperature * maxTempHeight / m_maxTemperature;

    context.color = Color::temperature;
    context.drawRect(1, m_size[1]-1-tempHeight, 5, tempHeight);

    if (isMouseInside())
    {
        ToolTip &tip = context.createToolTip();
        tip.addLine(formatString("$+/$+", formatTemperature(m_temperature), formatTemperature(m_maxTemperature)));
    }
}