#pragma once

#include <daguerre/fixed-font.hpp>
#include <pake/widget.hpp>

namespace pake::widgets {

  //a widget that draws text with a daguerre::fixed_font<bool>
  class fixed_text : public widget {

    //the font to use
    const daguerre::fixed_font<bool> *font;

    //background color of the widget
    daguerre::hilbert_color bg;

    //color of the text
    daguerre::hilbert_color fg;

    //the text to draw
    std::string text;

    //has the text changed since the last draw to render
    bool text_changed;

    //the width and height of this widget, as set by notify_size
    int width, height;

    //the alignment of the text within the region
    halign ha;
    valign va;

  public:
    //text: the text to draw. this can be changed later by set_text.
    //font: the font to use. TODO: pass a string and look up the font with that name
    //bg: the background color of the widget. fg: the color of the text.
    //ha, va: the alignment of the text within the widget
    fixed_text(
      std::string &&text,
      const daguerre::fixed_font<bool> *font,
      daguerre::hilbert_color bg,
      daguerre::hilbert_color fg,
      halign ha, valign va);

    //change the text to draw
    void set_text(std::string &&text);

    virtual void render(
      dirtiable_image &onto, int x_off, int y_off, bool force) override;

    virtual void notify_size(int width, int height) override;

  };

}
