Skip to content

Commit

Permalink
修改代码,以应用graphlayer模块功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Jan 17, 2013
1 parent 53df2b4 commit 85f63ee
Show file tree
Hide file tree
Showing 16 changed files with 480 additions and 603 deletions.
91 changes: 1 addition & 90 deletions include/LCUI/LCUI.h
Expand Up @@ -525,96 +525,6 @@ typedef enum _AUTOSIZE_MODE
AUTOSIZE_MODE; AUTOSIZE_MODE;
/*----------------------------------------------------*/ /*----------------------------------------------------*/


/******************************* 部件 **********************************/
struct _LCUI_Widget
{
LCUI_ID app_id; /* 所属程序的ID */

LCUI_Pos pos; /* 已计算出的实际位置 */
LCUI_Pos max_pos;
LCUI_Pos min_pos;
/*------------ 位置限制(描述) ---------------*/
PX_P_t x, y;
PX_P_t max_x, min_x;
PX_P_t max_y, min_y;
/*------------------ END -------------------*/

LCUI_Size size; /* 已计算出的实际尺寸,单位为像素 */
LCUI_Size max_size;
LCUI_Size min_size;

/*------------ 尺寸限制(描述) ---------------*/
PX_P_t w, h;
PX_P_t max_w, min_w;
PX_P_t max_h, min_h;
/*------------------ END -------------------*/

WIDGET_STATUS status; /* 部件的状态 */
BOOL status_response; /* 是否响应部件的状态改变 */

BOOL enabled; /* 是否启用 */
BOOL visible; /* 是否可见 */
BOOL inherit_alpha; /* 是否继承父部件的透明度 */

BOOL auto_size; /* 指定是否自动调整自身的大小,以适应内容的大小 */
AUTOSIZE_MODE auto_size_mode; /* 自动尺寸调整模式 */

BOOL focus; /* 指定该部件是否需要焦点 */
LCUI_Widget* focus_widget; /* 获得焦点的子部件 */

int z_index; /* 堆叠顺序 */

int clickable_mode; /* 确定在对比像素alpha值时,是要“小于”还是“不小于”才使条件成立 */
uchar_t clickable_area_alpha; /* 指定部件图层中的区域的alpha值小于/不小于多少时可被鼠标点击,默认为0,最大为255 */

LCUI_String type; /* 部件的类型 */
LCUI_ID type_id; /* 部件的类型ID */
LCUI_String style; /* 部件的风格,对某些部件有效 */
LCUI_ID style_id; /* 部件的风格的ID */
LCUI_Widget *parent; /* 父部件 */
LCUI_Queue child; /* 子部件集 */

/*----------------- 部件布局相关 ----------------*/
POS_TYPE pos_type; /* 位置类型 */
ALIGN_TYPE align; /* 布局 */
LCUI_Pos offset; /* x,y轴的偏移量 */
DOCK_TYPE dock; /* 停靠位置 */
/*------------------ END ----------------------*/

/*------------ 外边距和内边距 ---------------*/
LCUI_Margin margin;
LCUI_Padding padding;
/*---------------- END -------------------*/

LCUI_Border border; /* 边框 */

LCUI_RGB back_color; /* 背景色 */
LCUI_RGB fore_color; /* 前景色 */

int bg_mode; /* 背景模式,指定在无背景时是使用透明背景还是使用背景色填充 */
int background_image_layout; /* 背景图的布局 */
LCUI_Graph background_image; /* 背景图 */

void *private_data; /* 该部件私有数据的指针,其它的是各个部件公用的数据 */

LCUI_Queue event; /* 保存部件的事件关联的数据 */
LCUI_Queue update_area; /* 部件内需要刷新的区域 */
LCUI_Queue data; /* 记录需要进行更新的数据 */
LCUI_Graph graph; /* 部件的图层 */

/* 以下是函数指针,闲函数名太长的话,可以直接用下面的 */
void (*resize)(LCUI_Widget*, LCUI_Size);
void (*move)(LCUI_Widget*, LCUI_Pos);
void (*show)(LCUI_Widget*);
void (*hide)(LCUI_Widget*);
void (*disable)(LCUI_Widget*);
void (*enable)(LCUI_Widget*);
void (*set_align)(LCUI_Widget*, ALIGN_TYPE, LCUI_Pos);
void (*set_alpha)(LCUI_Widget*, unsigned char);
void (*set_border)(LCUI_Widget*, LCUI_Border);
};
/**********************************************************************/

/*********** 储存游标的位置 **************/ /*********** 储存游标的位置 **************/
struct _LCUI_Cursor struct _LCUI_Cursor
{ {
Expand All @@ -633,6 +543,7 @@ struct _LCUI_Cursor
fflush(stdout); \ fflush(stdout); \
} }


#include LC_GRAPHLAYER_H
#include LC_KERNEL_MAIN_H #include LC_KERNEL_MAIN_H
#include LC_KERNEL_DEV_H #include LC_KERNEL_DEV_H
#include LC_KERNEL_TIMER_H #include LC_KERNEL_TIMER_H
Expand Down
19 changes: 2 additions & 17 deletions include/LCUI/LCUI_Display.h
Expand Up @@ -80,23 +80,8 @@ int Get_Screen_Bits();
LCUI_Pos Get_Screen_Center_Point(); LCUI_Pos Get_Screen_Center_Point();
/* 功能:获取屏幕中心点的坐标 */ /* 功能:获取屏幕中心点的坐标 */


int Widget_Layer_Is_Opaque(LCUI_Widget *widget); /* 获取屏幕中指定区域内实际要显示的图形 */
/* 功能:判断部件图形是否不透明 */ void Get_Screen_Real_Graph ( LCUI_Rect rect, LCUI_Graph *graph );

int Widget_Layer_Not_Visible(LCUI_Widget *widget);
/* 功能:检测部件图形是否完全透明 */

void Get_Overlay_Widget(LCUI_Rect rect, LCUI_Widget *widget, LCUI_Queue *queue);
/*
* 功能:获取与指定区域重叠的部件
* 说明:得到的队列,队列中的部件排列顺序为:底-》上 == 左-》右
* */

int Get_Screen_Real_Graph (LCUI_Rect rect, LCUI_Graph * graph);
/*
* 功能:获取屏幕中指定区域内实际要显示的图形
* 说明:指定的区域必须是与部件区域不部分重叠的
* */


int Enable_Graph_Display(); int Enable_Graph_Display();
/* 功能:启用图形输出 */ /* 功能:启用图形输出 */
Expand Down
146 changes: 111 additions & 35 deletions include/LCUI/LCUI_Widget.h
Expand Up @@ -42,21 +42,6 @@
#ifndef __LCUI_WIDGET_H__ #ifndef __LCUI_WIDGET_H__
#define __LCUI_WIDGET_H__ #define __LCUI_WIDGET_H__


/* 定义数据类型标识 */
typedef enum DATATYPE
{
DATATYPE_POS,
DATATYPE_POS_TYPE,
DATATYPE_SIZE,
DATATYPE_GRAPH,
DATATYPE_UPDATE,
DATATYPE_STATUS,
DATATYPE_SHOW,
DATATYPE_HIDE,
DATATYPE_AREA
}
DATATYPE;

/***************** 部件相关函数的类型 *******************/ /***************** 部件相关函数的类型 *******************/
typedef enum _FuncType typedef enum _FuncType
{ {
Expand All @@ -70,15 +55,105 @@ typedef enum _FuncType
}FuncType; }FuncType;
/****************************************************/ /****************************************************/


#include LC_GRAPHLAYER_H

/******************************* 部件 **********************************/
typedef struct _LCUI_Widget LCUI_Widget;

struct _LCUI_Widget
{
LCUI_ID app_id; /* 所属程序的ID */

LCUI_Pos pos; /* 已计算出的实际位置 */
LCUI_Pos max_pos;
LCUI_Pos min_pos;
/*------------ 位置限制(描述) ---------------*/
PX_P_t x, y;
PX_P_t max_x, min_x;
PX_P_t max_y, min_y;
/*------------------ END -------------------*/

LCUI_Size size; /* 已计算出的实际尺寸,单位为像素 */
LCUI_Size max_size;
LCUI_Size min_size;

/*------------ 尺寸限制(描述) ---------------*/
PX_P_t w, h;
PX_P_t max_w, min_w;
PX_P_t max_h, min_h;
/*------------------ END -------------------*/

WIDGET_STATUS status; /* 部件的状态 */
BOOL status_response; /* 是否响应部件的状态改变 */

BOOL enabled; /* 是否启用 */
BOOL visible; /* 是否可见 */

BOOL auto_size; /* 指定是否自动调整自身的大小,以适应内容的大小 */
AUTOSIZE_MODE auto_size_mode; /* 自动尺寸调整模式 */

BOOL focus; /* 指定该部件是否需要焦点 */
LCUI_Widget* focus_widget; /* 获得焦点的子部件 */

int clickable_mode; /* 确定在对比像素alpha值时,是要“小于”还是“不小于”才使条件成立 */
uchar_t clickable_area_alpha; /* 指定部件图层中的区域的alpha值小于/不小于多少时可被鼠标点击,默认为0,最大为255 */

LCUI_String type; /* 部件的类型 */
LCUI_ID type_id; /* 部件的类型ID */
LCUI_String style; /* 部件的风格,对某些部件有效 */
LCUI_ID style_id; /* 部件的风格的ID */
LCUI_Widget *parent; /* 父部件 */
LCUI_Queue child; /* 子部件集 */

/*----------------- 部件布局相关 ----------------*/
POS_TYPE pos_type; /* 位置类型 */
ALIGN_TYPE align; /* 布局 */
LCUI_Pos offset; /* x,y轴的偏移量 */
DOCK_TYPE dock; /* 停靠位置 */
/*------------------ END ----------------------*/

/*------------ 外边距和内边距 ---------------*/
LCUI_Margin margin;
LCUI_Padding padding;
/*---------------- END -------------------*/

LCUI_Border border; /* 边框 */

LCUI_RGB back_color; /* 背景色 */
LCUI_RGB fore_color; /* 前景色 */

int bg_mode; /* 背景模式,指定在无背景时是使用透明背景还是使用背景色填充 */
int background_image_layout; /* 背景图的布局 */
LCUI_Graph background_image; /* 背景图 */

void *private_data; /* 该部件私有数据的指针,其它的是各个部件公用的数据 */

LCUI_Queue event; /* 保存部件的事件关联的数据 */
LCUI_Queue data_buff; /* 记录需要进行更新的数据 */
LCUI_Queue invalid_area; /* 记录无效区域 */
LCUI_GraphLayer* main_glayer; /* 部件的主图层 */
LCUI_GraphLayer* client_glayer; /* 客户区图层 */

/* 以下是函数指针,闲函数名太长的话,可以直接用下面的 */
void (*resize)(LCUI_Widget*, LCUI_Size);
void (*move)(LCUI_Widget*, LCUI_Pos);
void (*show)(LCUI_Widget*);
void (*hide)(LCUI_Widget*);
void (*disable)(LCUI_Widget*);
void (*enable)(LCUI_Widget*);
void (*set_align)(LCUI_Widget*, ALIGN_TYPE, LCUI_Pos);
void (*set_alpha)(LCUI_Widget*, unsigned char);
void (*set_border)(LCUI_Widget*, LCUI_Border);
};
/**********************************************************************/


LCUI_BEGIN_HEADER LCUI_BEGIN_HEADER


/***************************** Widget *********************************/ /***************************** Widget *********************************/
LCUI_Size Get_Widget_Size(LCUI_Widget *widget); LCUI_Size Get_Widget_Size(LCUI_Widget *widget);
/* 功能:获取部件的尺寸 */ /* 功能:获取部件的尺寸 */


uchar_t _Get_Widget_RealAlpha( LCUI_Widget *widget );
/* 获取部件实际的全局透明度 */

LCUI_Size _Get_Widget_Size(LCUI_Widget *widget); LCUI_Size _Get_Widget_Size(LCUI_Widget *widget);
/* 功能:通过计算获取部件的尺寸 */ /* 功能:通过计算获取部件的尺寸 */


Expand Down Expand Up @@ -124,8 +199,11 @@ void print_widget_info(LCUI_Widget *widget);
* 说明:在调试时需要用到它,用于确定widget是否有问题 * 说明:在调试时需要用到它,用于确定widget是否有问题
* */ * */


int Add_Widget_Refresh_Area (LCUI_Widget * widget, LCUI_Rect rect); /* 在指定部件的内部区域内设定需要刷新的区域 */
/* 功能:在指定部件的内部区域内设定需要刷新的区域 */ int Widget_InvalidArea ( LCUI_Widget *widget, LCUI_Rect rect );

/* 转移子部件中的无效区域至父部件的无效区域记录中 */
int Widget_SyncInvalidArea( LCUI_Widget *widget );


void Response_Status_Change(LCUI_Widget *widget); void Response_Status_Change(LCUI_Widget *widget);
/* /*
Expand All @@ -135,17 +213,6 @@ void Response_Status_Change(LCUI_Widget *widget);
* 上面时以及鼠标点击它时,都会改变按钮的图形样式,那就需要用这个函数设置一下。 * 上面时以及鼠标点击它时,都会改变按钮的图形样式,那就需要用这个函数设置一下。
* */ * */


void Shift_Widget_Refresh_Area(LCUI_Widget *widget);
/* 功能:转移部件的rect队列成员至父部件中 */

void Handle_Refresh_Area();
/*
* 功能:处理已记录的刷新区域
* 说明:此函数会将各个部件的rect队列中的处理掉,并将
* 最终的局部刷新区域数据添加至屏幕刷新区域队列中,等
* 待LCUI来处理。
**/

LCUI_Widget *Get_Parent_Widget(LCUI_Widget *widget, char *widget_type); LCUI_Widget *Get_Parent_Widget(LCUI_Widget *widget, char *widget_type);
/* /*
* 功能:获取部件的指定类型的父部件的指针 * 功能:获取部件的指定类型的父部件的指针
Expand Down Expand Up @@ -273,8 +340,8 @@ void Enable_Widget(LCUI_Widget *widget);
void Disable_Widget(LCUI_Widget *widget); void Disable_Widget(LCUI_Widget *widget);
/* 功能:禁用部件 */ /* 功能:禁用部件 */


void Widget_Visible(LCUI_Widget *widget, int flag); /* 指定部件是否可见 */
/* 功能:定义部件是否可见 */ void Widget_Visible( LCUI_Widget *widget, BOOL flag );


void Set_Widget_Pos(LCUI_Widget *widget, LCUI_Pos pos); void Set_Widget_Pos(LCUI_Widget *widget, LCUI_Pos pos);
/* /*
Expand Down Expand Up @@ -321,6 +388,15 @@ void Exec_Update_Widget(LCUI_Widget *widget);
void Exec_Draw_Widget(LCUI_Widget *widget); void Exec_Draw_Widget(LCUI_Widget *widget);
/* 功能:执行部件图形更新操作 */ /* 功能:执行部件图形更新操作 */


/* 获取指向部件自身图形数据的指针 */
LCUI_Graph *Widget_GetSelfGraph( LCUI_Widget *widget );

/* 获取部件实际显示的图形 */
int Widget_GetGraph(
LCUI_Widget *widget,
LCUI_Graph *graph_buff,
LCUI_Rect rect );

LCUI_Pos Get_Widget_Valid_Pos( LCUI_Widget *widget, LCUI_Pos pos ); LCUI_Pos Get_Widget_Valid_Pos( LCUI_Widget *widget, LCUI_Pos pos );
/* 获取有效化后的坐标数据,其实就是将在限制范围外的坐标处理成在限制范围内的 */ /* 获取有效化后的坐标数据,其实就是将在限制范围外的坐标处理成在限制范围内的 */


Expand Down Expand Up @@ -453,8 +529,8 @@ void Register_Default_Widget_Type();




/*************************** Container ********************************/ /*************************** Container ********************************/
void Widget_Container_Add(LCUI_Widget *container, LCUI_Widget *widget); /* 将部件添加至作为容器的部件内 */
/* 功能:将部件添加至作为容器的部件内 */ int Widget_Container_Add( LCUI_Widget *ctnr, LCUI_Widget *widget );


int _Get_Widget_Container_Width(LCUI_Widget *widget); int _Get_Widget_Container_Width(LCUI_Widget *widget);
/* 通过计算得出指定部件的容器的宽度,单位为像素 */ /* 通过计算得出指定部件的容器的宽度,单位为像素 */
Expand Down
7 changes: 4 additions & 3 deletions include/LCUI/kernel/main.h
Expand Up @@ -22,7 +22,6 @@ LCUI_App;
typedef struct _LCUI_Screen typedef struct _LCUI_Screen
{ {
LCUI_Size size; /* 屏幕尺寸 */ LCUI_Size size; /* 屏幕尺寸 */
LCUI_Graph buff; /* 保存启动LCUI前的屏幕内容 */
char *fb_dev_name; /* 图形输出设备的名称 */ char *fb_dev_name; /* 图形输出设备的名称 */
uchar_t *fb_mem; /* 指向图像输出设备映射到的内存的指针 */ uchar_t *fb_mem; /* 指向图像输出设备映射到的内存的指针 */
int fb_dev_fd; /* 图形显示设备的句柄 */ int fb_dev_fd; /* 图形显示设备的句柄 */
Expand All @@ -37,7 +36,7 @@ typedef struct _LCUI_System
{ {
int status; /* 状态 */ int status; /* 状态 */
BOOL init; /* 指示LCUI是否初始化过 */ BOOL init; /* 指示LCUI是否初始化过 */
BOOL need_shift_area; /* 指示是否需要转移部件中记录的区域数据 */ BOOL need_sync_area; /* 指示是否需要转移部件中记录的区域数据 */


thread_t self_id; /* 保存LCUI主程序的线程的ID */ thread_t self_id; /* 保存LCUI主程序的线程的ID */
thread_t display_thread; /* 保存核心处理的线程的ID */ thread_t display_thread; /* 保存核心处理的线程的ID */
Expand All @@ -57,10 +56,12 @@ typedef struct _LCUI_System
LCUI_Queue dev_list; /* 设备列表 */ LCUI_Queue dev_list; /* 设备列表 */
LCUI_Queue widget_list; /* 部件队列,对应它的显示顺序 */ LCUI_Queue widget_list; /* 部件队列,对应它的显示顺序 */
LCUI_Widget *focus_widget; /* 获得焦点的部件 */ LCUI_Widget *focus_widget; /* 获得焦点的部件 */
LCUI_Queue update_area; /* 需要刷新的区域 */ LCUI_Queue invalid_area; /* 需要刷新的区域 */
LCUI_Queue timer_list; /* 定时器列表 */ LCUI_Queue timer_list; /* 定时器列表 */
LCUI_Queue app_list; /* LCUI程序列表 */ LCUI_Queue app_list; /* LCUI程序列表 */
LCUI_Font default_font; /* 默认的字体数据 */ LCUI_Font default_font; /* 默认的字体数据 */

LCUI_GraphLayer *root_glayer;
} }
LCUI_System; LCUI_System;
/***********************************************************************/ /***********************************************************************/
Expand Down

0 comments on commit 85f63ee

Please sign in to comment.