/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#pragma once
#include "../libs.h"
#include "../display/animation/timeline.h"
#include "../display/font.h"
#include "../ui/frame.h"
#include "../util/flags.h"

/** Amount of characters scrolled, per second */
#define VN_TEXTBOX_SCROLL_SPEED 60

#define VN_TEXTBOX_FONT_SIZE FONT_SIZE_DEFAULT

#define VN_TEXTBOX_STATE_CLOSED flagDefine(0)

typedef struct {
  /** Stores the maximum width that this textbox can take up */
  float widthMax;

  /** Font that the text box uses */
  font_t *font;

  /** Box State Flags */
  uint8_t state;

  /** How many rows of text at most can be displayed in a single text box */
  int32_t linesMax;
  int32_t lineCurrent;

  /** Readonly values for the dimensions of the textbox */
  float width, height;

  /** Animation of the textbox */
  float textScroll;

  /** Information about the current rendered text */
  fonttextinfo_t textInfo;

  /** Primitive to hold talking text */
  primitive_t primitive;

  /** The frame for the textbox */
  frame_t frame;

  /** Current spoken text, tracked in-case of re-render */
  char *text;
} vntextbox_t;