mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
add canvas_widget
This commit is contained in:
parent
9312eba9af
commit
b244b590fd
@ -19,10 +19,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base/view.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/window.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "canvas_widget/canvas_widget.h"
|
||||
|
||||
static ret_t on_paint_rect(void* ctx, event_t* e) {
|
||||
paint_event_t* evt = (paint_event_t*)e;
|
||||
@ -522,7 +522,7 @@ static ret_t on_timer(const timer_info_t* timer) {
|
||||
|
||||
ret_t application_init() {
|
||||
widget_t* win = window_create(NULL, 0, 0, 0, 0);
|
||||
widget_t* canvas = view_create(win, 0, 0, win->w, win->h);
|
||||
widget_t* canvas = canvas_widget_create(win, 0, 0, win->w, win->h);
|
||||
|
||||
// widget_on(canvas, EVT_PAINT, on_paint_vg_simple, NULL);
|
||||
widget_on(canvas, EVT_PAINT, on_paint_vg, NULL);
|
||||
|
@ -1,4 +1,8 @@
|
||||
# 最新动态
|
||||
* 2018/12/01
|
||||
* 更新js/lua脚本绑定。
|
||||
* 增加canvas控件。
|
||||
|
||||
* 2018/11/30
|
||||
* 增加一些测试代码。
|
||||
* 增加函数widget\_insert\_child/widget\_restack。
|
||||
|
41
src/ext_widgets/canvas_widget/canvas_widget.c
Normal file
41
src/ext_widgets/canvas_widget/canvas_widget.c
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* File: canvas_widget.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: canvas_widget
|
||||
*
|
||||
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-12-01 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base/mem.h"
|
||||
#include "canvas_widget/canvas_widget.h"
|
||||
|
||||
static const widget_vtable_t s_canvas_widget_vtable = {.size = sizeof(canvas_widget_t),
|
||||
.type = WIDGET_TYPE_CANVAS_WIDGET,
|
||||
.create = canvas_widget_create};
|
||||
|
||||
widget_t* canvas_widget_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
canvas_widget_t* canvas_widget = TKMEM_ZALLOC(canvas_widget_t);
|
||||
widget_t* widget = WIDGET(canvas_widget);
|
||||
return_value_if_fail(canvas_widget != NULL, NULL);
|
||||
|
||||
return widget_init(widget, parent, &s_canvas_widget_vtable, x, y, w, h);
|
||||
}
|
||||
|
||||
widget_t* canvas_widget_cast(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL && widget->vt == &s_canvas_widget_vtable, NULL);
|
||||
|
||||
return widget;
|
||||
}
|
69
src/ext_widgets/canvas_widget/canvas_widget.h
Normal file
69
src/ext_widgets/canvas_widget/canvas_widget.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* File: canvas_widget.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: canvas_widget
|
||||
*
|
||||
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* License file for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* History:
|
||||
* ================================================================
|
||||
* 2018-12-01 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_CANVAS_WIDGET_H
|
||||
#define TK_CANVAS_WIDGET_H
|
||||
|
||||
#include "base/widget.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class canvas_widget_t
|
||||
* @parent widget_t
|
||||
* @annotation ["scriptable"]
|
||||
* 画布控件。
|
||||
*/
|
||||
typedef struct _canvas_widget_t {
|
||||
widget_t widget;
|
||||
} canvas_widget_t;
|
||||
|
||||
/**
|
||||
* @method canvas_widget_create
|
||||
* 创建canvas_widget对象
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* @param {widget_t*} parent 父控件
|
||||
* @param {xy_t} x x坐标
|
||||
* @param {xy_t} y y坐标
|
||||
* @param {wh_t} w 宽度
|
||||
* @param {wh_t} h 高度
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* canvas_widget_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method canvas_widget_cast
|
||||
* 转换为canvas_widget对象(供脚本语言使用)。
|
||||
* @annotation ["cast", "scriptable"]
|
||||
* @param {widget_t*} widget canvas_widget对象。
|
||||
*
|
||||
* @return {widget_t*} canvas_widget对象。
|
||||
*/
|
||||
widget_t* canvas_widget_cast(widget_t* widget);
|
||||
|
||||
#define WIDGET_TYPE_CANVAS_WIDGET "canvas"
|
||||
|
||||
#define CANVAS_WIDGET(widget) ((canvas_widget_t*)(widget))
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_CANVAS_WIDGET_H*/
|
@ -38,6 +38,7 @@
|
||||
#include "scroll_view/scroll_view.h"
|
||||
#include "scroll_view/list_view_h.h"
|
||||
#include "color_picker/color_picker.h"
|
||||
#include "canvas_widget/canvas_widget.h"
|
||||
#include "text_selector/text_selector.h"
|
||||
#include "color_picker/color_component.h"
|
||||
#include "progress_circle/progress_circle.h"
|
||||
@ -69,6 +70,7 @@ ret_t tk_ext_widgets_init() {
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_PROGRESS_CIRCLE, progress_circle_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SVG_IMAGE, svg_image_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_GIF_IMAGE, gif_image_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_CANVAS_WIDGET, canvas_widget_create);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user