From 7d91d3a1ed8f64ce0ff105a3c71685d90b6c16f9 Mon Sep 17 00:00:00 2001 From: ZhuRui <1602972632@qq.com> Date: Wed, 2 Aug 2023 17:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'1'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1/lvgl2.ts | 1099 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1099 insertions(+) create mode 100644 1/lvgl2.ts diff --git a/1/lvgl2.ts b/1/lvgl2.ts new file mode 100644 index 0000000..05c5a67 --- /dev/null +++ b/1/lvgl2.ts @@ -0,0 +1,1099 @@ +import Module, { LV_STYLE } from '../lvgl/LVGL'; + +// 屏幕和控件相比,屏幕的flag少了几个 + +/*flag类*/ +export class LVGL_FLAG{ + + public obj:number + + public checkable:boolean = true; + public snappable:boolean = true; + public press_lock:boolean = true; + public gesture_bubble:boolean = true; + public hidden:boolean = false; + public clickable:boolean = false; + public click_focusable:boolean = false; + public event_bubble:boolean = false; + public adv_hittest:boolean = false; + public ignore_layout:boolean = false; + public floating:boolean = false; + + public scroll_elastic:boolean = true; + public scroll_momentum:boolean = true; + public scroll_chain:boolean = true; + public scrollable:boolean = false; + public scroll_one:boolean = false; + public scroll_on_focus:boolean = false; + + constructor(id:number){ + this.obj = id; + } + + /**< Make the object hidden. (Like it wasn't there at all)*/ + public set Hidden(v:boolean){ + this.hidden = v; + if(this.hidden) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_HIDDEN); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_HIDDEN); + } + public get Hidden():{[key:string]:boolean}{ + return {"Hidden":this.hidden}; + } + /**< Make the object clickable by the input devices*/ + public set Clickable(v:boolean){ + this.clickable = v; + if(this.clickable) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_CLICKABLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_CLICKABLE); + } + public get Clickable():{[key:string]:boolean}{ + return {"Clickable":this.clickable}; + } + /**< Add focused state to the object when clicked*/ + public set Click_Focusable(v:boolean){ + this.click_focusable = v; + if(this.click_focusable) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_CLICK_FOCUSABLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_CLICK_FOCUSABLE); + } + public get Click_Focusable():{[key:string]:boolean}{ + return {"Click_Focusable":this.click_focusable}; + } + /**< Toggle checked state when the object is clicked*/ + public set Checkable(v:boolean){ + this.checkable = v; + if(this.checkable) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_CHECKABLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_CHECKABLE); + } + public get Checkable():{[key:string]:boolean}{ + return {"Checkable":this.checkable}; + } + /**< Make the object scrollable*/ + public set Scrollable(v:boolean){ + this.scrollable = v; + if(this.scrollable) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SCROLLABLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SCROLLABLE); + } + public get Scrollable():{[key:string]:boolean}{ + return {"Scrollable":this.scrollable}; + } + /**< Allow scrolling inside but with slower speed*/ + public set Scroll_Elastic(v:boolean){ + this.scroll_elastic = v; + if(this.scroll_elastic) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_ELASTIC); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_ELASTIC); + } + public get Scroll_Elastic():{[key:string]:boolean}{ + return {"Scroll_Elastic":this.scroll_elastic}; + } + /**< Make the object scroll further when "thrown"*/ + public set Scroll_Momentum(v:boolean){ + this.scroll_momentum = v; + if(this.scroll_momentum) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_MOMENTUM); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_MOMENTUM); + } + public get Scroll_Momentum():{[key:string]:boolean}{ + return {"Scroll_Momentum":this.scroll_momentum}; + } + /**< Allow scrolling only one snappable children*/ + public set Scroll_One(v:boolean){ + this.scroll_one = v; + if(this.scroll_one) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_ONE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_ONE); + } + public get Scroll_One():{[key:string]:boolean}{ + return {"Scroll_One":this.scroll_one}; + } + /**< Allow propagating the scroll to a parent*/ + public set Scroll_Chain(v:boolean){ + this.scroll_chain = v; + if(this.scroll_chain) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_CHAIN); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_CHAIN); + } + public get Scroll_Chain():{[key:string]:boolean}{ + return {"Scroll_Chain":this.scroll_chain}; + } + /**< Automatically scroll object to make it visible when focused*/ + public set Scroll_On_Focus(v:boolean){ + this.scroll_on_focus = v; + if(this.scroll_on_focus) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_ON_FOCUS); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SCROLL_ON_FOCUS); + } + public get Scroll_On_Focus():{[key:string]:boolean}{ + return {"Scroll_On_Focus":this.scroll_on_focus}; + } + /**< If scroll snap is enabled on the parent it can snap to this object*/ + public set Snappable(v:boolean){ + this.snappable = v; + if(this.snappable) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_SNAPPABLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_SNAPPABLE); + } + public get Snappable():{[key:string]:boolean}{ + return {"Snappable":this.snappable}; + } + /**< Keep the object pressed even if the press slid from the object*/ + public set Press_Lock(v:boolean){ + this.press_lock = v; + if(this.press_lock) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_PRESS_LOCK); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_PRESS_LOCK); + } + public get Press_Lock():{[key:string]:boolean}{ + return {"Press_Lock":this.press_lock}; + } + /**< Propagate the events to the parent too*/ + public set Event_Bubble(v:boolean){ + this.event_bubble = v; + if(this.event_bubble) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_EVENT_BUBBLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_EVENT_BUBBLE); + } + public get Event_Bubble():{[key:string]:boolean}{ + return {"Event_Bubble":this.event_bubble}; + } + /**< Propagate the gestures to the parent*/ + public set Gesture_Bubble(v:boolean){ + this.gesture_bubble = v; + if(this.gesture_bubble) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_GESTURE_BUBBLE); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_GESTURE_BUBBLE); + } + public get Gesture_Bubble():{[key:string]:boolean}{ + return {"Gesture_Bubble":this.gesture_bubble}; + } + /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/ + public set Adv_Hittest(v:boolean){ + this.adv_hittest = v; + if(this.adv_hittest) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_ADV_HITTEST); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_ADV_HITTEST); + } + public get Adv_Hittest():{[key:string]:boolean}{ + return {"Adv_Hittest":this.adv_hittest}; + } + /**< Make the object position-able by the layouts*/ + public set Ignore_Layout(v:boolean){ + this.ignore_layout = v; + if(this.ignore_layout) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_IGNORE_LAYOUT); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_IGNORE_LAYOUT); + } + public get Ignore_Layout():{[key:string]:boolean}{ + return {"Ignore_Layout":this.ignore_layout}; + } + /**< Do not scroll the object when the parent scrolls and ignore layout*/ + public set Floating(v:boolean){ + this.floating = v; + if(this.floating) Module.lv_obj_add_flag(this.obj,Module.LV_OBJ_FLAG_FLOATING); + else Module.lv_obj_clear_flag(this.obj,Module.LV_OBJ_FLAG_FLOATING); + } + public get Floating():{[key:string]:boolean}{ + return {"Floating":this.floating}; + } + + // public layout_1:boolean = false; + // public layout_2:boolean = false; + // public widget_1:boolean = false; + // public widget_2:boolean = false; + // public user_1:boolean = false; + // public user_2:boolean = false; + // public user_3:boolean = false; + // public user_4:boolean = false; + // LV_OBJ_FLAG_LAYOUT_1 = (1 << 23), /**< Custom flag, free to use by layouts*/ + // LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /**< Custom flag, free to use by layouts*/ + // LV_OBJ_FLAG_WIDGET_1 = (1 << 25), /**< Custom flag, free to use by widget*/ + // LV_OBJ_FLAG_WIDGET_2 = (1 << 26), /**< Custom flag, free to use by widget*/ + // LV_OBJ_FLAG_USER_1 = (1 << 27), /**< Custom flag, free to use by user*/ + // LV_OBJ_FLAG_USER_2 = (1 << 28), /**< Custom flag, free to use by user*/ + // LV_OBJ_FLAG_USER_3 = (1 << 29), /**< Custom flag, free to use by user*/ + // LV_OBJ_FLAG_USER_4 = (1 << 30), /**< Custom flag, free to use by user*/ +} + +/*state类*/ +export class LVGL_STATE{ + + public obj:number + public focused:boolean = false; + public default:boolean = false; + public checked:boolean = false; + public focus_key:boolean = false; + public edited:boolean = false; + public hovered:boolean = false; + public pressed:boolean = false; + public scrolled:boolean = false; + public disabled:boolean = false; + public user1:boolean = false; + public user2:boolean = false; + public user3:boolean = false; + public user4:boolean = false; + public any:boolean = false; + + constructor(id:number){ + this.obj = id; + } + + public set Focused(v:boolean){ + this.focused = v; + if(this.focused) Module.lv_obj_add_state(this.obj,Module.LV_STATE_FOCUSED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_FOCUSED); + } + public get Focused():{[key:string]:boolean}{ + return {"Focused":this.focused}; + } + + public set Default(v:boolean){ + this.default = v; + if(this.default) Module.lv_obj_add_state(this.obj,Module.LV_STATE_DEFAULT); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_DEFAULT); + } + public get Default():{[key:string]:boolean}{ + return {"Default":this.default}; + } + + public set Checked(v:boolean){ + this.checked = v; + if(this.checked) Module.lv_obj_add_state(this.obj,Module.LV_STATE_CHECKED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_CHECKED); + } + public get Checked():{[key:string]:boolean}{ + return {"Checked":this.checked}; + } + + public set Focus_Key(v:boolean){ + this.focus_key = v; + if(this.focus_key) Module.lv_obj_add_state(this.obj,Module.LV_STATE_FOCUS_KEY); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_FOCUS_KEY); + } + public get Focus_Key():{[key:string]:boolean}{ + return {"Focus_Key":this.focus_key}; + } + + public set Edited(v:boolean){ + this.edited = v; + if(this.edited) Module.lv_obj_add_state(this.obj,Module.LV_STATE_EDITED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_EDITED); + } + public get Edited():{[key:string]:boolean}{ + return {"Edited":this.edited}; + } + + public set Hovered(v:boolean){ + this.hovered = v; + if(this.hovered) Module.lv_obj_add_state(this.obj,Module.LV_STATE_HOVERED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_HOVERED); + } + public get Hovered():{[key:string]:boolean}{ + return {"Hovered":this.hovered}; + } + + public set Pressed(v:boolean){ + this.pressed = v; + if(this.pressed) Module.lv_obj_add_state(this.obj,Module.LV_STATE_HOVERED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_HOVERED); + } + public get Pressed():{[key:string]:boolean}{ + return {"Pressed":this.pressed}; + } + + public set Scrolled(v:boolean){ + this.scrolled = v; + if(this.scrolled) Module.lv_obj_add_state(this.obj,Module.LV_STATE_SCROLLED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_SCROLLED); + } + public get Scrolled():{[key:string]:boolean}{ + return {"Scrolled":this.scrolled}; + } + + public set Disabled(v:boolean){ + this.disabled = v; + if(this.disabled) Module.lv_obj_add_state(this.obj,Module.LV_STATE_DISABLED); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_DISABLED); + } + public get Disabled():{[key:string]:boolean}{ + return {"Disabled":this.disabled}; + } + + public set User_1(v:boolean){ + this.user1 = v; + if(this.user1) Module.lv_obj_add_state(this.obj,Module.LV_STATE_USER_1); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_USER_1); + } + public get User_1():{[key:string]:boolean}{ + return {"User_1":this.user1}; + } + + public set User_2(v:boolean){ + this.user2 = v; + if(this.user2) Module.lv_obj_add_state(this.obj,Module.LV_STATE_USER_1); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_USER_1); + } + public get User_2():{[key:string]:boolean}{ + return {"User_2":this.user2}; + } + + public set User_3(v:boolean){ + this.user3 = v; + if(this.user3) Module.lv_obj_add_state(this.obj,Module.LV_STATE_USER_1); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_USER_1); + } + public get USEUser_3R_3():{[key:string]:boolean}{ + return {"User_3":this.user3}; + } + + public set User_4(v:boolean){ + this.user4 = v; + if(this.user4) Module.lv_obj_add_state(this.obj,Module.LV_STATE_USER_1); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_USER_1); + } + public get User_4():{[key:string]:boolean}{ + return {"User_4":this.user4}; + } + + public set Any(v:boolean){ + this.any = v; + if(this.any) Module.lv_obj_add_state(this.obj,Module.LV_STATE_ANY); + else Module.lv_obj_clear_state(this.obj,Module.LV_STATE_ANY); + } + public get Any():{[key:string]:boolean}{ + return {"Any":this.any}; + } +} + +/*pos*/ +export class LVGL_POS{ + + public obj:number; + public x:number; + public y:number; + + constructor(id:number){ + this.obj = id; + this.x = 0; + this.y = 0; + } + + public set X(v:number){ + this.x = v; + Module.lv_obj_set_size(this.obj,this.x); + } + public get X():{[key:string]:number}{ + return {"X:":this.x}; + } + + public set Y(v:number){ + this.y = v; + Module.lv_obj_set_size(this.obj,this.y); + } + public get Y():{[key:string]:number}{ + return {"Y:":this.y}; + } + + public Set_XY(x:number,y:number){ + this.x = x; + this.y = y; + Module.lv_obj_set_pos(this.obj,this.x,this.y); + } + public Get_XY():{[key:string]:number}{ + return { + "X:":this.x, + "Y:":this.y + }; + } +} + +/*size*/ +export class LVGL_SIZE{ + private obj:number; + public width:number; + public height:number; + + constructor(id:number){ + this.obj = id; + this.height = 100; + this.width = 100; + } + + public set Width(v:number){ + this.width = v; + Module.lv_obj_set_width(this.obj,this.width); + } + public get Width():{[key:string]:number}{ + return {"Width:":this.width}; + } + + public set Height(v:number){ + this.height = v; + Module.lv_obj_set_width(this.obj,this.width); + } + public get Height():{[key:string]:number}{ + return {"Width:":this.width}; + } + + public Set_WH(w:number,h:number){ + this.width = w; + this.height = h; + Module.lv_obj_set_width(this.obj,this.width); + } + public Get_WH():{[key:string]:number}{ + return { + "Width:":this.width, + "Height:":this.height, + }; + } +} + +/*布局*/ +export class LVGL_FLEX{ + public obj:number; + public flex_flow:number; + public flex_align:number; + public main_place:number; + public cross_place:number; + public track_cross_place:number; + public grow:number; + + constructor(id:number){ + this.obj = id; + Module.lv_flex_init(); + } + + //弹性布局流动方式 + public set Flow(a:number){ + this.flex_flow = a; + Module.lv_obj_set_flex_flow(this.obj,this.flex_flow); + } + public get Flow():number{ + return this.flex_flow; + } + //弹性布局对齐方式 + public setAlign(a1:number,a2:number,a3:number){ + this.main_place =a1; + this.cross_place =a2; + this.track_cross_place =a3; + Module.lv_obj_set_flex_align(this.obj,this.main_place,this.cross_place,this.track_cross_place); + } + public get Align():{[key:string]:number}{ + return { + "main_place":this.main_place, + "cross_place":this.cross_place, + "track_cross_place":this.cross_place + } + } + //弹性布局伸展程度 + public set Grow(a:number){ + this.grow = a; + Module.lv_obj_set_flex_grow(this.obj,this.grow); + } + public get Grow():number{ + return this.grow; + } +} + +/*对齐*/ +export class LVGL_ALIGN{ + public obj:number; + public base_obj:number; + public align_mode:number; + + constructor(id:number){ + this.obj = id; + } + + public set align(a:number){ + this.align_mode = a; + Module.lv_obj_align(this.obj,this.align_mode); + } + + public alignTo(a:number,base_id:number){ + this.align_mode = a; + this.base_obj = base_id; + Module.lv_obj_align_to(this.obj,this.base_obj,this.align_mode); + } + + public Center(){ + this.align_mode = 9; + Module.lv_obj_center(this.obj); + } + + public get Mode():number{ + return this.align_mode; + } +} + +/*共有style*/ +export class LVGL_STYLE{ + + public style:number; + // constructor(s:number){ + // this.style = s; + // Module.lv_style_init(this.style); + // } + constructor(){ + this.style = Module.lv_style_create(); + } + + public _radius:number; + public set Radius(v:number){ + this._radius = v; + Module.lv_style_set_radius(this.style,this._radius); + } + public get Radius():number{ + return this._radius; + } + + /**background */ + public _bg_color:number; + public set BgColor(color:number){ + this._bg_color = color; + Module.lv_style_set_bg_color(this.style,Module.lv_color_hex(this._bg_color)); + } + public get BgColor():{[key:string]:number}{ + return {"bg_color":this._bg_color}; + } + + public _bg_grad_color:number; + public set BgGradColor(grad_color:number){ + this._bg_grad_color = grad_color; + Module.lv_style_set_bg_grad_color(this.style,Module.lv_color_hex(this._bg_grad_color)); + } + public get BgGradColor():{[key:string]:number}{ + return {"BgGradColor":this._bg_grad_color}; + } + + public _bg_opa:number; + public set BgOpa(o:number){ + if(o<0) this._bg_opa = 0; + else if(o > 255) this._bg_opa = 255; + else this._bg_opa = o; + Module.lv_style_set_bg_opa(this.style,this._bg_opa); + } + public get BgOpa():{[key:string]:number}{ + return {"Bg_Opa":this._bg_opa}; + } + + public _bg_grad_dir:number; + public set BgGradDir(d:number){ + if(d == 0){ + this._bg_grad_dir = d; + Module.lv_style_set_bg_grad_dir(this.style,Module.LV_GRAD_DIR_NONE); + }else if(d == 1){ + this._bg_grad_dir = d; + Module.lv_style_set_bg_grad_dir(this.style,Module.LV_GRAD_DIR_VER); + }else if(d == 2){ + this._bg_grad_dir = d; + Module.lv_style_set_bg_grad_dir(this.style,Module.LV_GRAD_DIR_HOR); + } + } + public get BgGradDir():{[key:string]:number}{ + if (this._bg_grad_dir == 0) return {"LV_GRAD_DIR_NONE": 0}; + else if (this._bg_grad_dir == 1) return {"LV_GRAD_DIR_VER": 1}; + else if (this._bg_grad_dir == 2) return {"LV_GRAD_DIR_HOR": 2}; + else return {}; + } + + private _bg_grad_stop:number; + public set bgGradStop(bg_grad_stop:number){ + if( bg_grad_stop < 0 ){ + this._bg_grad_stop = 0; + Module.lv_style_set_bg_grad_stop(this.style,0); + }else if( bg_grad_stop >255 ){ + this._bg_grad_stop = 255; + Module.lv_style_set_bg_grad_stop(this.style,255); + }else{ + this._bg_grad_stop = bg_grad_stop; + Module.lv_style_set_bg_grad_stop(this.style,this._bg_grad_stop); + } + } + public get bgGradStop():number{ + return this._bg_grad_stop; + } + + private _bg_main_stop:number; + public set bgMainStop(bg_main_stop:number){ + if( bg_main_stop < 0 ){ + this._bg_main_stop = 0; + Module.lv_style_set_bg_main_stop(this.style,0); + }else if( bg_main_stop >255 ){ + this._bg_main_stop = 255; + Module.lv_style_set_bg_main_stop(this.style,255); + }else{ + this._bg_main_stop = bg_main_stop; + Module.lv_style_set_bg_main_stop(this.style,this._bg_main_stop); + } + } + public get bgMainStop():number{ + return this._bg_main_stop; + } + + /**background image */ + //背景图片透明度 + private _bg_img_opa:number; + public set bgImgOpa(bg_img_opa: number){ + if(bg_img_opa < 0 ){ + this._bg_img_opa = 0; + }else if(bg_img_opa >255){ + this._bg_img_opa = 255; + }else{ + this._bg_img_opa = bg_img_opa; + } + Module.lv_style_set_bg_img_opa(this.style,this._bg_img_opa); + } + public get bgImgOpa():number{ + return this._bg_img_opa; + } + //背景图片着色 + private _bg_img_recolor:number; + public set bgImgRecolor(bg_img_recolor:number){ + + this._bg_img_recolor = bg_img_recolor; + Module.lv_style_set_bg_img_recolor(this.style,Module.lv_color_hex(this._bg_img_recolor)); + } + public get bgImgRecolor():number{ + return this._bg_img_recolor; + } + //着色透明度 + private _bg_img_recolor_opa:number; + public set bgImgRecolorOpa(bg_img_recolor_opa :number ){ + if(bg_img_recolor_opa < 0 ){ + this._bg_img_recolor_opa = 0; + }else if(bg_img_recolor_opa >255){ + this._bg_img_recolor_opa = 255; + }else{ + this._bg_img_recolor_opa = bg_img_recolor_opa; + } + Module.lv_style_set_bg_img_recolor_opa(this.style,this._bg_img_recolor_opa); + } + public get bgImgRecolorOpa():number{ + return this._bg_img_recolor_opa; + } + //tile + private _bg_img_tile:boolean; + public set bgImgTile(bg_img_tile:boolean){ + this._bg_img_tile = bg_img_tile; + Module.lv_style_set_bg_img_tiled(this.style,this._bg_img_tile); + } + public get bgImgTile():boolean{ + return this._bg_img_tile; + } + + /**border */ + //边框颜色 + private _border_color: number; + public set borderColor(borderColor:number){ + this._border_color = borderColor; + Module.lv_style_set_border_color(this.style,Module.lv_color_hex(this._border_color)); + } + public get borderColor():number{ + return this._border_color; + } + //边框透明度 + private _border_opa : number; + public set borderOpa(border_opa:number) { + if(border_opa < 0){ + this._border_opa = 0; + }else if(border_opa > 255){ + this._border_opa = 255; + }else{ + this._border_opa = border_opa; + } + Module.lv_style_set_border_opa(this.style, this._border_opa); + } + public get borderOpa():number{ + return this._border_opa; + } + //边框显示侧 + private _border_post:boolean; + public set borderPost(border_post :boolean){ + this._border_post = border_post + Module.lv_style_set_border_post(this.style,this._border_post); + } + public get borderPost():boolean{ + return this._border_post; + } + //边框显示边 + private _border_side : number; + public set borderSide( border_side :number){ + this._border_side = border_side; + Module.lv_style_set_border_side(this.style,this._border_side); + } + public get borderSide():{[key:string]:number}{ + if(this._border_side == 0x00) return {"LV_BORDER_SIDE_NONE":0x00}; + else if(this._border_side == 0x01) return {"LV_BORDER_SIDE_BOTTOM":0x01}; + else if(this._border_side == 0x02) return {"LV_BORDER_SIDE_TOP":0x02}; + else if(this._border_side == 0x04) return {"LV_BORDER_SIDE_LEFT":0x04}; + else if(this._border_side == 0x08) return {"LV_BORDER_SIDE_RIGHT":0x08}; + else if(this._border_side == 0x0F) return {"LV_BORDER_SIDE_FULL":0x0F}; + else if(this._border_side == 0x10) return {"LV_BORDER_SIDE_INTERNAL":0x10}; + else return {}; + } + //边框宽度 + private _border_width:number; + public set borderWidth(border_width:number){ + this._border_width = border_width; + Module.lv_style_set_border_width(this.style,this._border_width); + } + public get borderWidth():number{ + return this._border_width; + } + + /**outline */ + //轮廓颜色 + private _outline_color:number; + public set outlineColor(outline_color : number){ + this._outline_color = outline_color; + Module.lv_style_set_outline_color(this.style,Module.lv_color_hex(this._outline_color)); + } + public get outlineColor():number{ + return this._outline_color; + } + //轮廓透明度 + private _outline_opa:number; + public set outlineOpa(outline_opa : number){ + if(outline_opa < 0){ + this._outline_opa = 0; + }else if(outline_opa > 255){ + this._outline_opa = 255; + }else{ + this._outline_opa = outline_opa; + } + Module.lv_style_set_outline_opa(this.style, this._outline_opa) + } + public get outlineOpa():number{ + return this._outline_opa; + } + //轮廓宽度 + private _outline_width:number; + public set outlineWidth(outline_width :number){ + this._outline_width = outline_width; + Module.lv_style_set_outline_width(this.style,this._outline_width); + } + public get outlineWidth():number{ + return this._outline_width; + } + //轮廓与边框的距离 + private _outline_pad:number; + public set outlinePad(outline_pad :number){ + this._outline_pad = outline_pad; + Module.lv_style_set_outline_pad(this.style,outline_pad); + } + public get outlinePad():number{ + return this._outline_pad; + } + + /**shadow */ + //阴影颜色 + private _shadow_color:number; + public set shadowColor(shadow_color : number){ + this._shadow_color = shadow_color; + Module.lv_style_set_shadow_color(this.style,Module.lv_color_hex(this._shadow_color)); + } + public get shadowColor():number{ + return this._shadow_color; + } + //阴影透明度 + private _shadow_opa:number; + public set shadowOpa(shadow_opa : number){ + if(shadow_opa < 0){ + this._shadow_opa = 0; + }else if(shadow_opa > 255){ + this._shadow_opa = 255; + }else{ + this._shadow_opa = shadow_opa; + } + Module.lv_style_set_shadow_opa(this.style, this._shadow_opa) + } + public get shadowOpa():number{ + return this._shadow_opa; + } + //阴影水平偏移 + private _shadow_ofs_x:number; + public set shadowOfsX(shadow_ofs_x:number){ + this._shadow_ofs_x = shadow_ofs_x; + Module.lv_style_set_shadow_ofs_x(this.style,this._shadow_ofs_x); + } + public get shadowOfsX():number{ + return this._shadow_ofs_x; + } + //阴影垂直偏移 + private _shadow_ofs_y:number; + public set shadowOfsY(shadow_ofs_y:number){ + this._shadow_ofs_y = shadow_ofs_y; + Module.lv_style_set_shadow_ofs_y(this.style,this._shadow_ofs_y); + } + public get shadowOfsY():number{ + return this._shadow_ofs_y; + } + //阴影扩散宽度 + private _shadow_spread:number; + public set shadowSpread(shadow_spread:number){ + this._shadow_spread = shadow_spread;; + Module.lv_style_set_shadow_spread(this.style,this._shadow_spread); + } + public get shadowSpread(){ + return this._shadow_spread; + } + //阴影宽度 + private _shadow_width:number; + public set shadowWidth(shadow_width:number){ + this._shadow_width = shadow_width; + Module.lv_style_set_shadow_width(this.style,this._shadow_width); + } + public get shadowWidth(){ + return this._shadow_width; + } + + /**blend */ + //混合模式 + private _blend_mode:number; + public set blendMode(blend_mode : number){ + this._blend_mode = blend_mode; + Module.lv_style_set_blend_mode(this.style,this._blend_mode); + } + public get blendMode():{[key:string]:number}{ + if(this._blend_mode == 0) return {["LV_BLEND_MODE_NORMAL"]:0}; + else if(this._blend_mode == 1) return {["LV_BLEND_MODE_ADDITIVE"]:0}; + else if(this._blend_mode == 2) return {["LV_BLEND_MODE_SUBTRACTIVE"]:0}; + return {}; + } + //混合透明度 + private _blend_opa:number; + public set blendOpa(o:number){ + if(o<0) this._blend_opa = 0; + else if(o>255) this._blend_opa = 255; + else this._blend_opa = o; + Module.lv_style_set_bg_opa(this.style,this._blend_opa); + Module.lv_style_set_bg_img_opa(this.style,this._blend_opa); + Module.lv_style_set_border_opa(this.style,this._blend_opa); + Module.lv_style_set_outline_opa(this.style,this._blend_opa); + Module.lv_style_set_shadow_opa(this.style,this._blend_opa); + } + public get blendOpa():number{ + return this._blend_opa; + } + + /**padding */ + //上方内边距 + private _pad_top:number; + public set padTop(pad_top:number){ + this._pad_top = pad_top; + Module.lv_style_set_pad_top(this.style,this._pad_top); + } + public get padTop():number{ + return this._pad_top; + } + //下方内边距 + private _pad_bottom:number; + public set padBottom(pad_bottom:number){ + this._pad_bottom = pad_bottom; + Module.lv_style_set_pad_bottom(this.style,this._pad_bottom); + } + public get padBottom():number{ + return this._pad_bottom; + } + //左侧内边距 + private _pad_left:number; + public set padLeft(pad_left:number){ + this._pad_left = pad_left; + Module.lv_style_set_pad_left(this.style,this._pad_left); + } + public get padLeft():number{ + return this._pad_left; + } + //右侧内边距 + private _pad_right:number; + public set padRight(pad_right:number){ + this._pad_right = pad_right; + Module.lv_style_set_pad_right(this.style,this._pad_right); + } + public get padRight():number{ + return this._pad_right; + } + //行内边距 + private _pad_row:number; + public set padRow(pad_row:number){ + this._pad_row = pad_row; + Module.lv_style_set_pad_row(this.style,this._pad_row); + } + public get padRow():number{ + return this._pad_row; + } + //列内边距 + private _pad_column:number; + public set padColumn(pad_column:number){ + this._pad_column = pad_column; + Module.lv_style_set_pad_column(this.style,this._pad_column); + } + public get padColumn():number{ + return this._pad_column; + } +} + +/*arc的style */ +export class LVGL_ARC_STYLE{ + +} + +/*创建基类 */ +export class LVGL_OBJ{ + + public obj :number; + public Flag :LVGL_FLAG; + public State :LVGL_STATE; + public Pos :LVGL_POS; + public Size :LVGL_SIZE; + public Align :LVGL_ALIGN; + public Flex :LVGL_FLEX; + + constructor(public parent:number|undefined = Module.lv_scr_act()){ + this.obj = Module.lv_obj_create(parent); + this.Flag = new LVGL_FLAG (this.obj); + this.State = new LVGL_STATE (this.obj); + this.Pos = new LVGL_POS (this.obj); + this.Size = new LVGL_SIZE (this.obj); + this.Align = new LVGL_ALIGN (this.obj); + this.Flex = new LVGL_FLEX (this.obj); + } + + /**基础对象obj的方法... */ + //设置样式 + public setStyle(style:LVGL_STYLE,part:number){ + Module.lv_obj_add_style(this.obj,style,part); + } + +} + +/*创建子类*/ +export class LVGL_ARC extends LVGL_OBJ{ //error:找不到arc的相关函数 + + constructor(public parent:number|undefined = Module.lv_scr_act()){ + super(parent); + this.obj = Module.lv_arc_create(parent); + } + + /**arc特有的方法... */ + //设置圆弧的起始终止角度 + private _start_angle:number; + private _end_angle:number; + public setStartAngle(a:number){ + this._start_angle =a; + Module.lv_arc_set_start_angle(this.obj,this._start_angle); + } + public getStartAngle():{[key:string]:number}{ + return {"start_angle":this._start_angle}; + } + public setEndAngle(a:number){ + this._end_angle =a; + Module.lv_arc_set_start_angle(this.obj,this._end_angle); + } + public getEndAngle():{[key:string]:number}{ + return {"end_angle":this._end_angle}; + } + public setAngles(a:number,b:number){ + this._start_angle = a; + this._end_angle = b; + Module.lv_arc_set_angles(this.obj,this._start_angle,this._end_angle); + } + public getAngles():{[key:string]:number}{ + return { + "start_angle":this._start_angle, + "end_angle":this._end_angle + }; + } + //设置圆弧背景起始终止角度 + private _bg_start_angle:number; + private _bg_end_angle:number; + public setBgStartAngle(a:number){ + this._bg_start_angle =a; + Module.lv_arc_set_bg_start_angle(this.obj,this._bg_start_angle); + } + public getBgStartAngle():{[key:string]:number}{ + return {"start_angle":this._bg_start_angle}; + } + public setBgEndAngle(a:number){ + this._bg_end_angle =a; + Module.lv_arc_set_start_angle(this.obj,this._bg_end_angle); + } + public getBgEndAngle():{[key:string]:number}{ + return {"bg_end_angle":this._bg_end_angle}; + } + public setBgAngles(a:number,b:number){ + this._bg_start_angle = a; + this._bg_end_angle = b; + Module.lv_arc_set_bg_angles(this.obj,this._bg_start_angle,this._bg_end_angle); + } + public getBgAngles():{[key:string]:number}{ + return { + "bg_start_angle":this._start_angle, + "bg_end_angle":this._end_angle + }; + } + //设置圆弧模式 + public _mode:number; + public set Mode(m:number){ + if(m == 0 || m == 1 || m == 2){ + this._mode = m; + Module.lv_arc_set_mode(this.obj,this._mode); + } + } + public get Mode():{[key:string]:number}{ + if(this._mode == 0) return { "LV_ARC_MODE_NORMAL":0 }; + else if(this._mode == 1) return {"LV_ARC_MODE_SYMMETRICAL":1}; + else if(this._mode == 2) return {"LV_ARC_MODE_REVERSE":2}; + else return {}; + } + //设置圆弧旋转角度 + public _rotation:number; + public set Rotation(r:number){ + this._rotation = r; + Module.lv_arc_set_rotation(this.obj,this._rotation); + } + public get Rotation():number{ + return this._rotation; + } + //设置当前值 + private _value:number; + public set Value(n:number){ + this._value = n; + Module.lv_arc_set_value(this.obj,this._value); + } + public get Value():number{ + return this._value; + } + //设置弧度取值范围 + private _min:number; + private _max:number; + public setRange(a:number,b:number){ + this._min =a; + this._max = b; + Module.lv_arc_set_range(this.obj,this._min,this._max); + } + public getRange():{[key:string]:number}{ + return { + "min_value":this._min, + "max_value":this._max + } + } +} + +export class LVGL_BTN extends LVGL_OBJ{ + + constructor(public parent:number|undefined = Module.lv_scr_act()){ + super(parent); + this.obj = Module.lv_btn_create(parent); + } + + /**btn特有的方法... */ +} + + +/**示例 */ +/* +const btn = new LVGL_BTN(); +btn.Flag.Hidden = true; +btn.State.Default = true; +btn.Pos.Set_XY(200,200); +btn.Pos.X = 20; +btn.Size.Set_WH(480,320); +btn.Align.Center(); +btn.Align.base_obj = 123; +btn.Align.alignTo(0,btn.Align.base_obj); +btn.Flex.setAlign(1,2,3); +console.log(btn.Flag.Hidden); +console.log(btn.Size.Get_WH()); +const btn_style = new LVGL_STYLE(); +btn.setStyle(btn_style,Module.LV_PART_MAIN); +.。,, +*/