/*
 * windows.h
 *
 *  Created on: Aug 6, 2021
 *      Author: wuwenfeng
 */

#ifndef WINDOWS_H_
#define WINDOWS_H_
#include "main.h"
#include "lcd.h"
#include "key.h"

typedef struct
{
	int x;
	int y;
	int width;
	int high;
	COLOR_16 background;
	char title[16];
	uint8_t refresh_windows_flag;
	char touch_flag;
	int touch_x;
	int touch_y;


}window;


typedef struct windows_stack
{
	struct windows_stack *up;
	window *window;
	struct windows_stack *next;

}windows_stack;

typedef struct
{
	COLOR_16 background;
	int x;
	int y;
	int width;
	int high;
	windows_stack *windows;
	windows_stack *last_windows;
	window *moveed_windwos;//记录正在被移动的窗口
	int move_x;
	int move_y;
	uint8_t move_lock:1;
	uint8_t First_click_flag:1;
	uint8_t refresh_ui_flag:1;

}UI;

void Inteface_SetCursor(uint16_t Xpos, uint16_t Ypos);
void Inteface_SetColor(uint16_t color);

UI     *UI_Init(COLOR_16 background);
window *New_Window(UI *ui,uint16_t x,uint16_t y,uint16_t width,uint16_t high,COLOR_16 background,const char *title);
void   Refresh_UI(UI *ui);

void Set_Windows_Title(window *this_window,const char *title);

//void UI_Server(UI *ui);

#endif /* WINDOWS_H_ */
