#ifndef GUI_H
#define GUI_H

#include <unistd.h>
#include <stdbool.h>
#include <SDL2/SDL.h>
#include <math.h>
#include <sys/time.h>

#include "../../include/audio/alsa.h"
#include "../../include/audio/timeline.h"
#include "../../include/player.h"



#define BUTTON_TYPE_FILE_SELECT 0x00
#define BUTTON_TYPE_PAUSE 0x01
#define BUTTON_TYPE_PLAYBAR 0x02
#define BUTTON_TYPE_VOLUME 0x03
#define BUTTON_TYPE_FILE_SEARCH 0x04
#define BUTTON_TYPE_AUDIO_RATE 0x05


#define BUTTON_TYPE_TIMELINE 0x10
#define BUTTON_TYPE_SCROLL 0x11
#define BUTTON_TYPE_BPM 0x12
#define BUTTON_TYPE_RESET 0x13
#define BUTTON_TYPE_PROJECT_FILE 0x14
#define BUTTON_TYPE_SAVE_PROJECT 0x15
#define BUTTON_TYPE_READ_PROJECT 0x16
#define BUTTON_TYPE_EXPORT_PROJECT 0x17

#define BUTTON_TYPE_NULL 0xff



bool WidgetClicked(int mouseX, int mouseY, Widget* widget);

bool ListClicked(int mouseX, int mouseY, Widget* widget, int w, int h);

int ListAction(int mouseX, int mouseY, Widget* widget, PlayerData* player_data, TimelineData* timeline_data);

void UpdateWidgetText(char* str, Widget* widget);

void ButtonAction(int mouseX, int mouseY, Widget* widget, 
		AlsaData* alsa_data, PlayerData* player_data, TimelineData* timeline_data, uint8_t button);

void GraphicalInput(char key, Widget* widget, uint8_t* strIndex, uint8_t maxIndex, char* str);

void KeyboardAction(char key, Widget* widget, AlsaData* alsa_data, PlayerData* player_data, TimelineData* timeline_data);

void PrintText(char* str, SDL_Renderer* renderer, SDL_Texture* font, 
		uint16_t textx, uint16_t texty);

void PrintNumbers(int number, SDL_Renderer* renderer, SDL_Texture* font, 
		uint16_t textx, uint16_t texty);

void DrawWidget(SDL_Window* window, SDL_Renderer* renderer, SDL_Texture* font, Widget* widget, 
		AlsaData* alsa_data, PlayerData* player_data, TimelineData* timeline_data);

void Draw(SDL_Window* window, SDL_Renderer* renderer, 
	  SDL_Texture* background, SDL_Texture* font,
	  Widget* arr[256], uint8_t widgetNum,
	  char* filename,
	  PlayerData* player_data,
	  AlsaData* alsa_data,
	  TimelineData* timeline_data);


#endif
