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

#pragma once
#include "../engine/engine.h"
#include "../libs.h"
#include "frame.h"
#include "textmenu.h"
#include "grid.h"
#include "menu.h"

/** The default gutter for the grid of a framed text menu */
#define FRAMED_TEXT_MENU_GUTTER_DEFAULT 8.0f

typedef struct {
  frame_t frame;
  textmenu_t menu;
} framedtextmenu_t;

/**
 * Initialize a framed text ui element.
 * 
 * @param menu Menu to initialize.
 * @param font Font to use for the text.
 * @param text Texture for the frame.
 */
void framedTextMenuInit(framedtextmenu_t *menu, font_t *font, texture_t *text);

/**
 * Resize a framed text menu.
 * 
 * @param menu Menu to resize.
 * @param width Width of the menu.
 * @param height Height of the menu.
 */
void framedTextMenuResize(framedtextmenu_t *menu, float width, float height);

/**
 * Update a framed text menu.
 * 
 * @param menu Menu to update.
 * @param engine Engine to use when updating.
 */
void framedTextMenuUpdate(framedtextmenu_t *menu, engine_t *engine);

/**
 * Render a framed text menu.
 * 
 * @param menu Menu to render.
 * @param shader Shader to use.
 * @param x X Position.
 * @param y Y Position.
 */
void framedTextMenuRender(
  framedtextmenu_t *menu, shader_t *shader, float x, float y
);

/**
 * Dispose a previously created framed text menu.
 * 
 * @param menu Menu to dispose.
 */
void framedTextMenuDispose(framedtextmenu_t *menu);