重写一些逻辑
This commit is contained in:
+64
-59
@@ -6,23 +6,30 @@
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
//接口
|
||||
//设置屏幕像素坐标
|
||||
void Inteface_SetCursor(uint16_t Xpos, uint16_t Ypos)
|
||||
{
|
||||
LCD_SetCursor(Xpos,Ypos); //设置光标位置
|
||||
LCD_REG_ADDRESS=lcddev.wramcmd; //开始写入GRAM
|
||||
}
|
||||
//往像素坐标写入一个颜色
|
||||
void Inteface_SetColor(uint16_t color)
|
||||
{
|
||||
LCD_DATA_ADDRESS=color;
|
||||
}
|
||||
|
||||
//新建一个UI对象
|
||||
//当时都想法是类似windows的多桌面,每个桌面都能有n个窗口
|
||||
UI *UI_Init(COLOR_16 background)
|
||||
{
|
||||
UI *ui;
|
||||
ui = (UI*)malloc(sizeof(UI));
|
||||
if(ui!=NULL)
|
||||
{
|
||||
ui->x=0;
|
||||
ui->y=0;
|
||||
ui->high=240;
|
||||
ui->width=320;
|
||||
ui->background=background;
|
||||
ui->windows=NULL;
|
||||
ui->last_windows=NULL;
|
||||
@@ -50,7 +57,9 @@ UI *UI_Init(COLOR_16 background)
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
//新建一个窗口
|
||||
//返回窗口的指针
|
||||
//将窗口挂载到某个ui
|
||||
window *New_Window(UI *ui,uint16_t x,uint16_t y,uint16_t width,uint16_t high,COLOR_16 background,const char *title)
|
||||
{
|
||||
window *temp_window;
|
||||
@@ -96,7 +105,8 @@ window *New_Window(UI *ui,uint16_t x,uint16_t y,uint16_t width,uint16_t high,COL
|
||||
return temp_window;
|
||||
|
||||
}
|
||||
|
||||
//关闭某个窗口
|
||||
//挺麻烦的,除了要释放窗口内存,还要去ui抹掉窗口的指针
|
||||
void Close_Windows_Stack(UI *ui,windows_stack *temp_windows_stack)
|
||||
{
|
||||
|
||||
@@ -136,7 +146,7 @@ void Close_Windows_Stack(UI *ui,windows_stack *temp_windows_stack)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//设置窗口标题
|
||||
void Set_Windows_Title(window *this_window,const char *title)
|
||||
{
|
||||
for(int a=0;a<16;a++)
|
||||
@@ -144,12 +154,52 @@ void Set_Windows_Title(window *this_window,const char *title)
|
||||
this_window->title[a]=title[a];
|
||||
}
|
||||
}
|
||||
|
||||
//测试用
|
||||
void Set_Windows_XY_BY_ACC(window *temp_window,int acc_x,int acc_y)
|
||||
{
|
||||
temp_window->x=temp_window->x+acc_x;
|
||||
temp_window->y=temp_window->y+acc_y;
|
||||
}
|
||||
|
||||
//显示一个窗口
|
||||
void Refresh_Window(window *temp_window)
|
||||
{
|
||||
//开始绘制窗口//填充窗口背景
|
||||
for(uint16_t temp_y=0;temp_y<temp_window->high;temp_y++)
|
||||
{
|
||||
Inteface_SetCursor(temp_window->x,temp_window->y+temp_y);
|
||||
for(uint16_t temp_i=0;temp_i<temp_window->width;temp_i++)
|
||||
{
|
||||
if(temp_i==0||temp_y==0||temp_i==temp_window->width-1||temp_y==temp_window->high-1)
|
||||
{
|
||||
Inteface_SetColor(BLUE);
|
||||
}else
|
||||
{
|
||||
Inteface_SetColor(temp_window->background);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//绘制bar
|
||||
for(uint16_t temp_y=0;temp_y<16;temp_y++)
|
||||
{
|
||||
Inteface_SetCursor(temp_window->x,temp_window->y+temp_y);
|
||||
for(uint16_t temp_i=0;temp_i<temp_window->width;temp_i++)
|
||||
{
|
||||
if(temp_i>temp_window->width-16)
|
||||
{
|
||||
Inteface_SetColor(RED);
|
||||
}else
|
||||
{
|
||||
Inteface_SetColor(BLUE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//显示title
|
||||
LCD_ShowString(temp_window->x,temp_window->y,&temp_window->title,16,WHITE,WHITE);
|
||||
|
||||
}
|
||||
/*
|
||||
* 很可惜 辛辛苦苦写的代码要被放弃
|
||||
* 用算法实现遮挡关系计算真挺蠢
|
||||
@@ -159,21 +209,16 @@ void Refresh_UI(UI *ui)
|
||||
{
|
||||
int flag=0;
|
||||
uint16_t dot_y=0,dot_x=0;
|
||||
|
||||
//画背景
|
||||
|
||||
for(dot_y=0;dot_y<240;dot_y++)
|
||||
for(dot_y=ui->y;dot_y<ui->high;dot_y++)
|
||||
{
|
||||
Inteface_SetCursor(dot_x,dot_y);
|
||||
for(dot_x=0;dot_x<320;dot_x++)
|
||||
for(dot_x=ui->x;dot_x<ui->width;dot_x++)
|
||||
{
|
||||
Inteface_SetColor(ui->background);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
window *temp_window;
|
||||
windows_stack *temp_windows_stack,*temp_windows_stack2;
|
||||
temp_windows_stack=ui->windows;
|
||||
do
|
||||
@@ -181,47 +226,7 @@ void Refresh_UI(UI *ui)
|
||||
if(temp_windows_stack!=NULL)
|
||||
{
|
||||
flag=1;
|
||||
|
||||
//
|
||||
temp_window=temp_windows_stack->window;//取出窗口的资源句柄
|
||||
//开始绘制窗口//填充窗口背景
|
||||
for(uint16_t temp_y=0;temp_y<temp_window->high;temp_y++)
|
||||
{
|
||||
Inteface_SetCursor(temp_window->x,temp_window->y+temp_y);
|
||||
for(uint16_t temp_i=0;temp_i<temp_window->width;temp_i++)
|
||||
{
|
||||
if(temp_i==0||temp_y==0||temp_i==temp_window->width-1||temp_y==temp_window->high-1)
|
||||
{
|
||||
Inteface_SetColor(BLUE);
|
||||
}else
|
||||
{
|
||||
Inteface_SetColor(temp_window->background);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//绘制bar
|
||||
for(uint16_t temp_y=0;temp_y<16;temp_y++)
|
||||
{
|
||||
Inteface_SetCursor(temp_window->x,temp_window->y+temp_y);
|
||||
for(uint16_t temp_i=0;temp_i<temp_window->width;temp_i++)
|
||||
{
|
||||
if(temp_i>temp_window->width-16)
|
||||
{
|
||||
Inteface_SetColor(RED);
|
||||
}else
|
||||
{
|
||||
Inteface_SetColor(BLUE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//显示title
|
||||
LCD_ShowString(temp_window->x,temp_window->y,&temp_window->title,16,WHITE,WHITE);
|
||||
|
||||
|
||||
|
||||
|
||||
Refresh_Window(temp_windows_stack->window);
|
||||
//绘制下一个窗口
|
||||
temp_windows_stack=temp_windows_stack->next;
|
||||
}else
|
||||
@@ -271,7 +276,7 @@ void Refresh_UI(UI *ui)
|
||||
* 检查坐标是否命中窗口
|
||||
*
|
||||
* */
|
||||
/*
|
||||
|
||||
#define BODY 1
|
||||
#define BAR 2
|
||||
#define CLOSE 3
|
||||
@@ -300,13 +305,13 @@ void UI_Server(UI *ui)
|
||||
{
|
||||
|
||||
windows_stack *temp_windows_stack=NULL;
|
||||
window *temp_window=NULL;
|
||||
window *temp_window;
|
||||
//touch_device *temp_touch=NULL;
|
||||
int flag=0;
|
||||
uint8_t hit_flag=0;
|
||||
//touch
|
||||
temp_touch=ui->touch;
|
||||
if(Touch_Server(temp_touch))
|
||||
//temp_touch=ui->touch;
|
||||
if(1)//Touch_Server(temp_touch))
|
||||
{
|
||||
temp_window=NULL;
|
||||
temp_windows_stack=ui->last_windows; //获取ui中最前端的窗口 从前往后扫描
|
||||
@@ -374,4 +379,4 @@ void UI_Server(UI *ui)
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user