/**
 * 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/gui/font.h"
#include "../ui/frame.h"

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

#define VN_TEXTBOX_FONT_SIZE 16.0

#define VN_TEXTBOX_STATE_CLOSED 0x01

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;

  /** X, Y Position of the textbox */
  float x, y;

  /** 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;