Giter Site home page Giter Site logo

slkun / simple-user-interface Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 32 KB

A Simple User Interface that used in embedded system that can't using operating sytem like Linux. It uses the basic function of opearing hardware, like read the screen, draw point at a current positon.

C 100.00%

simple-user-interface's Introduction

Simper User Interface

简要说明

该SUI实现了一个简单的图形系统, 实现了按钮以及文本框等控件, 并且可以很方便的自定义新的控件以丰富完善该系统.

设计思路

GUI以控件形式进行组织, 每一个控件包含自己的数据内容char* data以及状态信息union state_info, 并包含一个callbackvoid (*callback)(messages)用于解析处理来自其他控件或者是系统中断发送的消息. 各个空间的主要功能是通过不同的回调函数实现的, 目前回调函数的调用方式是直接调用:

void send_message(messages message){
    widget *dest;
    dest = get_widget_from_id(message.dest);
    // Only unhide widget and redraw msg can be called
    if(dest != NULL && (dest->ishided == FALSE || message.msgid == WIDGET_REDRAW)){
        dest->callback(message);
    }else{
#ifdef DEBUG_DUMP
        printf("Wrong Destination when sending message. id:%d\n", message.dest);
#endif
    }
}

可以考虑将其修改为一个消息队列, 对不同消息增加优先级, 并结合时钟中断以及汇编保存函数上下文的形式实现一个任务调度器.

结构说明

主要有五个部分构成

  • Driver/下主要为和硬件相关的驱动
  • Fonts/下主要为字库
  • fonts.c/h为文字相关函数
  • Graphics.c/.h主要为图形相关函数
  • SUI.c/h主要为系统空间相关函数

基本数据结构介绍

SUI.h

  • messages 定义了控件之间的传递的消息
  • widget 定义某一个具体控件的信息
  • widget_info 用于从数组方便生成图形界面
  • widget_table 是存储空间信息的全局表

Graphics.h

  • point 主要定义了一个点
  • size 主要定义了一个框的大小
  • range 表示的是一个数的范围
  • frame 结合point和size表示出了屏幕上的一个区域
  • bound 表示出了一个区域的绝对位置(坐标系位置)

font.h

  • font_info 表示了一个字体的相关信息, 使程序决定如何去读取字库

功能介绍

#### 生成一个图形界面

  1. 你需要在硬件上配置一个定时器TIMER0, 默认配置即可.
  2. 使用void SUI_Init(color c_background);初始化界面.
  3. 使用ret_code create_user_interface_from_array(const widget_info *pawidget, int length);来创建界面.
  4. 为控件写不同的回调函数以实现功能.

simple-user-interface's People

Contributors

slkun avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.