BigW Consortium Gitlab

Commit ad2a9a4c by Gabor

Merge branch 'new_objs' into beta

parents ce50c08e 0ef1fa06
......@@ -100,6 +100,12 @@
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
#define USE_LV_WIN 1
/*Tab (dependencies: lv_page, lv_btnm)*/
#define USE_LV_TABVIEW 1
#if USE_LV_TABVIEW != 0
#define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
/*************************
* Data visualizer object
*************************/
......@@ -143,9 +149,15 @@
/*Button matrix (dependencies: -)*/
#define USE_LV_BTNM 1
/*Keyboard (dependencies: lv_btnm)*/
#define USE_LV_KB 1
/*Check box (dependencies: lv_btn, lv_label)*/
#define USE_LV_CB 1
/*Switch (dependencies: lv_slider)*/
#define USE_LV_SW 1
/*List (dependencies: lv_page, lv_btn, lv_label, lv_img)*/
#define USE_LV_LIST 1
#if USE_LV_LIST != 0
......
......@@ -70,11 +70,15 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
dm_assert(ext);
ext->btn_cnt = 0;
ext->btn_pr = LV_BTNM_PR_NONE;
ext->btn_tgl = LV_BTNM_PR_NONE;
ext->btn_areas = NULL;
ext->cb = NULL;
ext->map_p = NULL;
ext->style_btn_rel = lv_style_get(LV_STYLE_BTN_REL, NULL);
ext->style_btn_pr = lv_style_get(LV_STYLE_BTN_PR, NULL);
ext->style_btn_trel = lv_style_get(LV_STYLE_BTN_TREL, NULL);
ext->style_btn_tpr = lv_style_get(LV_STYLE_BTN_TPR, NULL);
ext->tgl = 0;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_btnm);
......@@ -84,7 +88,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new button matrix object*/
if(copy == NULL) {
lv_obj_set_size(new_btnm, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_set_style(new_btnm, lv_style_get(LV_STYLE_PLAIN, NULL));
lv_obj_set_style(new_btnm, lv_style_get(LV_STYLE_PRETTY, NULL));
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
}
/*Copy an existing object*/
......@@ -162,7 +166,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
if(sign == LV_SIGNAL_RELEASED && ext->btn_pr != LV_BTNM_PR_NONE) {
/*Invalidate to old area*/;
/*Invalidate to old pressed area*/;
lv_obj_get_cords(btnm, &btnm_area);
area_cpy(&btn_area, &ext->btn_areas[ext->btn_pr]);
btn_area.x1 += btnm_area.x1;
......@@ -171,6 +175,18 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
if(ext->tgl != 0) {
/*Invalidate to old toggled area*/;
area_cpy(&btn_area, &ext->btn_areas[ext->btn_tgl]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
ext->btn_tgl = ext->btn_pr;
}
ext->btn_pr = LV_BTNM_PR_NONE;
}
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
......@@ -314,7 +330,28 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb)
}
/**
* Set the styles of the buttons of the button matrox
* Enable or disable button toggling
* @param btnm pointer to button matrix object
* @param en true: enable toggling; false: disable toggling
* @param id index of the currently toggled button (ignored if 'en' == false)
*/
void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id)
{
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
ext->tgl = en == false ? 0 : 1;
if(ext->tgl != 0) {
if(id > ext->btn_cnt) id = LV_BTNM_PR_NONE;
ext->btn_tgl = id;
} else {
ext->btn_tgl = LV_BTNM_PR_NONE;
}
lv_obj_inv(btnm);
}
/**
* Set the styles of the buttons of the button matrix
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @param style pointer to style
......@@ -373,6 +410,12 @@ lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state)
case LV_BTN_STATE_REL:
style = ext->style_btn_rel;
break;
case LV_BTN_STATE_TPR:
style = ext->style_btn_tpr;
break;
case LV_BTN_STATE_TREL:
style = ext->style_btn_trel;
break;
default:
style = NULL;
}
......@@ -420,7 +463,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
/*Search the next valid text in the map*/
while(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
if(ext->map_p[txt_i][1] == '\177') continue;
if(ext->map_p[txt_i][1] == '\177' || ext->map_p[txt_i][0] == '\177') continue;
lv_obj_get_cords(btnm, &area_btnm);
......@@ -434,7 +477,10 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
btn_h = area_get_height(&area_tmp);
/*Load the style*/
btn_style = lv_btnm_get_style_btn(btnm, ext->btn_pr == btn_i ? LV_BTN_STATE_PR : LV_BTN_STATE_REL);
if(btn_i != ext->btn_pr && btn_i != ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_REL);
else if(btn_i == ext->btn_pr && btn_i != ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_PR);
else if(btn_i != ext->btn_pr && btn_i == ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TREL);
else if(btn_i == ext->btn_pr && btn_i == ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TPR);
lv_draw_rect(&area_tmp, mask, btn_style);
......
......@@ -43,9 +43,13 @@ typedef struct
area_t * btn_areas; /*Array of areas for the buttons (Handled by the library)*/
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t btn_pr; /*Index of the currently pressed button or LV_BTNM_PR_NONE (Handled by the library)*/
uint16_t btn_tgl; /*Index of the currently toggled button or LV_BTNM_PR_NONE (Handled by the library)*/
lv_btnm_callback_t cb; /*A function to call when a button is releases*/
lv_style_t * style_btn_rel; /*Style of the released buttons*/
lv_style_t * style_btn_pr; /*Style of the pressed buttons*/
lv_style_t * style_btn_trel; /*Style of the released buttons*/
lv_style_t * style_btn_tpr; /*Style of the pressed buttons*/
uint8_t tgl :1; /*Enable toggling*/
}lv_btnm_ext_t;
/**********************
......@@ -89,6 +93,14 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map);
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb);
/**
* Enable or disable button toggling
* @param btnm pointer to button matrix object
* @param en true: enable toggling; false: disable toggling
* @param id index of the currently toggled button (ignored if 'en' == false)
*/
void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id);
/**
* Set the styles of the buttons of the button matrox
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
......
This diff is collapsed. Click to expand it.
/**
* @file lv_kb.h
*
*/
#ifndef LV_KB_H
#define LV_KB_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_KB != 0
#include "../lv_obj/lv_obj.h"
#include "lv_btnm.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_KB_MODE_TXT,
LV_KB_MODE_NUM,
}lv_kb_mode_t;
/*Data of keyboard*/
typedef struct {
lv_btnm_ext_t btnm; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * ta;
lv_kb_mode_t mode;
uint8_t cur_mng :1;
lv_action_t ok_action;
lv_action_t close_action;
}lv_kb_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a keyboard objects
* @param par pointer to an object, it will be the parent of the new keyboard
* @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it
* @return pointer to the created keyboard
*/
lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the keyboard
* @param kb pointer to a keyboard object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
/**
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
* @param kb pointer to a Keyboard object
* @param ta pointer to a Text Area object to write there
*/
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta);
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
* @param mode the mode from 'lv_kb_mode_t'
*/
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode);
/**
* Automatically hide or show the cursor of Text Area
* @param kb pointer to a Keyboard object
* @param en true: show cursor on the current text area, false: hide cursor
*/
void lv_kb_set_cur_mng(lv_obj_t * kb, bool en);
/**
* Set call back to call when the "Ok" button is pressed
* @param kb pointer to Keyboard object
* @param action a callback with 'lv_action_t' type
*/
void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action);
/**
* Set call back to call when the "Hide" button is pressed
* @param kb pointer to Keyboard object
* @param action a callback with 'lv_action_t' type
*/
void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action);
/**
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
* @param kb pointer to a Keyboard object
* @return pointer to the assigned Text Area object
*/
lv_obj_t * lv_kb_get_ta(lv_obj_t * kb);
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
* @return the current mode from 'lv_kb_mode_t'
*/
lv_kb_mode_t lv_kb_get_mode(lv_obj_t * kb);
/**
* Get the current cursor manage mode.
* @param kb pointer to a Keyboard object
* @return true: show cursor on the current text area, false: hide cursor
*/
bool lv_kb_get_cur_mng(lv_obj_t * kb, bool en);
/**
* Get the callback to call when the "Ok" button is pressed
* @param kb pointer to Keyboard object
* @return the ok callback
*/
lv_action_t lv_kb_get_ok_action(lv_obj_t * kb, lv_action_t action);
/**
* Get the callback to call when the "Hide" button is pressed
* @param kb pointer to Keyboard object
* @return the close callback
*/
lv_action_t lv_kb_get_close_action(lv_obj_t * kb, lv_action_t action);
/**********************
* MACROS
**********************/
#endif /*USE_LV_KB*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_KB_H*/
......@@ -47,7 +47,7 @@ static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mod
*-----------------*/
/**
* Create a template objects
* Create a template object
* @param par pointer to an object, it will be the parent of the new template
* @param copy pointer to a template object, if not NULL then the new object will be copied from it
* @return pointer to the created template
......@@ -111,12 +111,21 @@ bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param)
return valid;
}
/*======================
* Add/remove functions
*=====================*/
/*
* New object specific "add" or "remove" functions come here
*/
/*=====================
* Setter functions
*====================*/
/*
* New object specific "set" function comes here
* New object specific "set" functions come here
*/
......@@ -125,9 +134,16 @@ bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param)
*====================*/
/*
* New object specific "get" function comes here
* New object specific "get" functions come here
*/
/*=====================
* Other functions
*====================*/
/*
* New object specific "other" functions come here
*/
/**********************
* STATIC FUNCTIONS
......
......@@ -33,9 +33,8 @@ extern "C" {
* TYPEDEFS
**********************/
/*Data of template*/
typedef struct
{
/*Ext. of ancestor*/
typedef struct {
lv_ANCESTOR_ext_t ANCESTOR; /*Ext. of ancestor*/
/*New data for this type */
}lv_templ_ext_t;
......
......@@ -65,6 +65,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
ext->cb = NULL;
ext->tmp_value = ext->bar.min_value;
ext->style_knob = lv_style_get(LV_STYLE_PRETTY, NULL);
ext->knob_in = 0;
/* Save the bar design function.
* It will be used in the sllider design function*/
......@@ -84,6 +85,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
lv_slider_ext_t * copy_ext = lv_obj_get_ext(copy);
ext->style_knob = copy_ext->style_knob;
ext->cb = copy_ext->cb;
ext->knob_in = copy_ext->knob_in;
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_slider);
}
......@@ -120,11 +122,13 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
else if(sign == LV_SIGNAL_PRESSING) {
lv_dispi_get_point(param, &p);
if(w > h) {
cord_t knob_w = h;
p.x -= slider->cords.x1 + h / 2; /*Modify the point to shift with half knob (important on the start and end)*/
tmp = (int32_t) ((int32_t) p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - h);
tmp = (int32_t) ((int32_t) p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - knob_w);
} else {
cord_t knob_h = w;
p.y -= slider->cords.y1 + w / 2; /*Modify the point to shift with half knob (important on the start and end)*/
tmp = (int32_t) ((int32_t) p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - w);
tmp = (int32_t) ((int32_t) p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - knob_h);
tmp = ext->bar.max_value - tmp; /*Invert he value: small value means higher y*/
}
......@@ -146,8 +150,18 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
slider->signal_f(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
}
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
cord_t x = MATH_MIN(w, h);
if(slider->ext_size < x) slider->ext_size = x;
if(ext->knob_in == 0) {
cord_t x = MATH_MIN(w, h); /*The smaller size is the knob diameter*/
if(slider->ext_size < x) slider->ext_size = x;
} else {
lv_style_t * style = lv_obj_get_style(slider);
cord_t pad = MATH_MIN(style->hpad, style->vpad);
if(pad < 0) {
pad = -pad;
if(slider->ext_size < pad) slider->ext_size = pad;
}
}
} else if(sign == LV_SIGNAL_CONTROLL) {
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
char c = *((char*)param);
......@@ -194,6 +208,17 @@ void lv_slider_set_style_knob(lv_obj_t * slider, lv_style_t * style)
lv_obj_inv(slider);
}
/**
* Set the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @param in true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
{
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
ext->knob_in = in == false ? 0 : 1;
}
/*=====================
* Getter functions
......@@ -220,6 +245,18 @@ lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider)
return ext->style_knob;
}
/**
* Get the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @return true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
bool lv_slider_get_knob_in(lv_obj_t * slider)
{
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
return ext->knob_in == 0 ? false : true;
}
/**********************
* STATIC FUNCTIONS
**********************/
......@@ -243,6 +280,8 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
}
/*Draw the object*/
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
lv_style_t * style_slider = lv_obj_get_style(slider);
lv_style_t * style_knob = lv_slider_get_style_knob(slider);
lv_style_t * style_indic = lv_bar_get_style_indic(slider);
......@@ -251,8 +290,8 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
area_t area_bar;
area_cpy(&area_bar, &slider->cords);
/*Be sure at least vpad/hpad width bar will remain*/
cord_t vpad_bar = style_indic->vpad;
cord_t hpad_bar = style_indic->hpad;
cord_t vpad_bar = style_slider->vpad;
cord_t hpad_bar = style_slider->hpad;
if(vpad_bar * 2 + LV_SLIDER_SIZE_MIN > area_get_height(&area_bar)) {
vpad_bar = (area_get_height(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1;
}
......@@ -295,27 +334,39 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
if(slider_w >= slider_h) {
area_indic.x2 = (int32_t) ((int32_t)area_get_width(&area_indic) * act_value) / (max_value - min_value);
area_indic.x2 += area_indic.x1;
} else {
area_indic.y1 = (int32_t) ((int32_t)area_get_height(&area_indic) * act_value) / (max_value - min_value);
area_indic.y1 = area_indic.y2 - area_indic.y1;
}
/*Draw the indicator*/
lv_draw_rect(&area_indic, mask, style_indic);
if(act_value != min_value) lv_draw_rect(&area_indic, mask, style_indic);
area_t knob_area;
area_cpy(&knob_area, &slider->cords);
if(slider_w >= slider_h) {
knob_area.x1 = area_indic.x2 - slider_h / 2;
knob_area.x2 = knob_area.x1 + slider_h;
if(ext->knob_in == 0) {
knob_area.x1 = area_indic.x2 - slider_h / 2;
knob_area.x2 = knob_area.x1 + slider_h;
} else {
knob_area.x1 = (int32_t) ((int32_t)(slider_w - slider_h) * act_value) / (max_value - min_value);
knob_area.x1 += slider->cords.x1;
knob_area.x2 = knob_area.x1 + slider_h;
}
knob_area.y1 = slider->cords.y1;
knob_area.y2 = slider->cords.y2;
} else {
knob_area.y1 = area_indic.y1 - slider_w / 2;
knob_area.y2 = knob_area.y1 + slider_w;
if(ext->knob_in == 0) {
knob_area.y1 = area_indic.y1 - slider_w / 2;
knob_area.y2 = knob_area.y1 + slider_w;
} else {
knob_area.y2 = (int32_t) ((int32_t)(slider_h - slider_w) * act_value) / (max_value - min_value);
knob_area.y2 = slider->cords.y2 - knob_area.y2;
knob_area.y1 = knob_area.y2 - slider_w;
}
knob_area.x1 = slider->cords.x1;
knob_area.x2 = slider->cords.x2;
......
......@@ -34,6 +34,7 @@ typedef struct
lv_action_t cb; /*Function to call when a new value is set*/
lv_style_t * style_knob; /*Style of the knob*/
int16_t tmp_value; /*Store a temporal value during press until release (Handled by the library)*/
uint8_t knob_in :1; /*1: Draw the knob inside the bar*/
}lv_slider_ext_t;
/*Built-in styles of slider*/
......@@ -78,6 +79,14 @@ void lv_slider_set_action(lv_obj_t * slider, lv_action_t cb);
void lv_slider_set_style_knob(lv_obj_t * slider, lv_style_t * style);
/**
* Set the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @param in true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
void lv_slider_set_knob_in(lv_obj_t * slider, bool in);
/**
* Get the slider callback function
* @param slider pointer to slider object
* @return the callback function
......@@ -91,6 +100,14 @@ lv_action_t lv_slider_get_action(lv_obj_t * slider);
*/
lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider);
/**
* Get the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @return true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
bool lv_slider_get_knob_in(lv_obj_t * slider);
/**********************
* MACROS
**********************/
......
/**
* @file lv_sw.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_SW != 0
#include "lv_sw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
#if 0 /*Slider design is used*/
static bool lv_sw_design(lv_obj_t * sw, const area_t * mask, lv_design_mode_t mode);
#endif
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a switch objects
* @param par pointer to an object, it will be the parent of the new switch
* @param copy pointer to a switch object, if not NULL then the new object will be copied from it
* @return pointer to the created switch
*/
lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
{
/*Create the ancestor of switch*/
lv_obj_t * new_sw = lv_slider_create(par, copy);
dm_assert(new_sw);
/*Allocate the switch type specific extended data*/
lv_sw_ext_t * ext = lv_obj_alloc_ext(new_sw, sizeof(lv_sw_ext_t));
dm_assert(ext);
/*Initialize the allocated 'ext' */
ext->changed = 0;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_f(new_sw, lv_sw_signal);
/*Init the new switch switch*/
if(copy == NULL) {
lv_bar_set_range(new_sw, 0, 1);
lv_obj_set_size(new_sw, LV_DPI, LV_DPI / 2);
lv_slider_set_knob_in(new_sw, true);
}
/*Copy an existing switch*/
else {
/*Nothing to copy*/
/*Refresh the style with new signal function*/
lv_obj_refr_style(new_sw);
}
return new_sw;
}
/**
* Signal function of the switch
* @param sw pointer to a switch object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
{
bool valid;
lv_sw_ext_t * ext = lv_obj_get_ext(sw);
int16_t old_val = lv_bar_get_value(sw);
lv_action_t slider_cb = ext->slider.cb;
ext->slider.cb = NULL; /*Do not let the slider to call the callback. The Switch will do it*/
/* Include the ancient signal function */
valid = lv_slider_signal(sw, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
}
else if(sign == LV_SIGNAL_PRESSING) {
int16_t act_val = lv_bar_get_value(sw);
if(act_val != old_val) ext->changed = 1;
}
else if(sign == LV_SIGNAL_PRESS_LOST) {
ext->changed = 0;
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->changed == 0) {
int16_t v = lv_bar_get_value(sw);
if(v == 0) lv_bar_set_value(sw, 1);
else lv_bar_set_value(sw, 0);
}
if(slider_cb != NULL) slider_cb(sw, param);
ext->changed = 0;
}
}
/*Restore the callback*/
ext->slider.cb = slider_cb;
return valid;
}
/*=====================
* Setter functions
*====================*/
/*
* New object specific "set" function comes here
*/
/*=====================
* Getter functions
*====================*/
/*
* New object specific "get" function comes here
*/
/**********************
* STATIC FUNCTIONS
**********************/
#if 0 /*Slider design is used*/
/**
* Handle the drawing related tasks of the switchs
* @param sw pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return true/false, depends on 'mode'
*/
static bool lv_sw_design(lv_obj_t * sw, const area_t * mask, lv_design_mode_t mode)
{
/*Return false if the object is not covers the mask_p area*/
if(mode == LV_DESIGN_COVER_CHK) {
return false;
}
/*Draw the object*/
else if(mode == LV_DESIGN_DRAW_MAIN) {
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
}
return true;
}
#endif
#endif
/**
* @file lv_sw.h
*
*/
#ifndef LV_SW_H
#define LV_SW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_SW != 0
/*Testing of dependencies*/
#if USE_LV_SW == 0
#error "lv_sw: lv_slider is required. Enable it in lv_conf.h (USE_LV_SLIDER 1)"
#endif
#include "../lv_obj/lv_obj.h"
#include "lv_slider.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of switch*/
typedef struct
{
lv_slider_ext_t slider; /*Ext. of ancestor*/
/*New data for this type */
uint8_t changed :1; /*Indicates the switch explicitly changed by drag*/
}lv_sw_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a switch objects
* @param par pointer to an object, it will be the parent of the new switch
* @param copy pointer to a switch object, if not NULL then the new object will be copied from it
* @return pointer to the created switch
*/
lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the switch
* @param sw pointer to a switch object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param);
/**********************
* MACROS
**********************/
#endif /*USE_LV_SW*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_SW_H*/
......@@ -522,6 +522,8 @@ void lv_ta_set_cursor_show(lv_obj_t * ta, bool show)
{
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
ext->cursor_show = show == false ? 0 : 1;
ext->cursor_state = 0;
lv_obj_inv(ta);
}
/**
......
/**
* @file lv_tabview.h
*
*/
#ifndef LV_TABVIEW_H
#define LV_TABVIEW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_TABVIEW != 0
/*Testing of dependencies*/
#if USE_LV_BTNM == 0
#error "lv_tabview: lv_btnm is required. Enable it in lv_conf.h (USE_LV_BTNM 1) "
#endif
#if USE_LV_PAGE == 0
#error "lv_tabview: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
#endif
#include "../lv_obj/lv_obj.h"
#include "../lv_objx/lv_win.h"
#include "../lv_objx/lv_page.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of tab*/
typedef struct
{
/*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * tabs;
lv_obj_t * indic;
lv_obj_t * content; /*A rectangle to show the current tab*/
const char ** tab_name_ptr;
point_t point_last;
uint16_t tab_act;
uint16_t tab_cnt;
uint8_t draging :1;
uint8_t drag_h :1;
}lv_tabview_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a Tab view objects
* @param par pointer to an object, it will be the parent of the new tab
* @param copy pointer to a tab object, if not NULL then the new object will be copied from it
* @return pointer to the created tab
*/
lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the Tab view
* @param tab pointer to a tab object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_tabview_signal(lv_obj_t * tab, lv_signal_t sign, void * param);
/**
* Realign and resize the elements of Tab view
* @param tabview pointer to a Tab view object
*/
void lv_tabview_realign(lv_obj_t * tabview);
/**
* Set a new tab
* @param tabview pointer to Tab view object
* @param id index of a tab to load
* @param anim_en true: set with sliding animation; false: set immediately
*/
void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en);
/**
* Get the index of the currently active tab
* @param tabview pointer to Tab view object
* @return the active tab index
*/
uint16_t lv_tabview_get_tab_act(lv_obj_t * tabview);
/**
* Get the number of tabs
* @param tabview pointer to Tab view object
* @return tab count
*/
uint16_t lv_tabview_get_tab_cnt(lv_obj_t * tabview);
/**
* Get the page (content area) of a tab
* @param tabview pointer to Tab view object
* @param id index of the tab (>= 0)
* @return pointer to page (lv_page) object
*/
lv_obj_t * lv_tabview_get_tab_page(lv_obj_t * tabview, uint16_t id);
/**
* Get the tab button matrix (lv_btnm) of a Tab view
* @param tabview pointer to Tab view object
* @return pointer to button matrix (lv_btnm) object which is the tab buttons
*/
lv_obj_t * lv_tabview_get_tabs(lv_obj_t * tabview);
/**
* Get the indicator rectangle (lv_obj) of a Tab view
* @param tabview pointer to Tab view object
* @return pointer to Base object (lv_obj) which is the indicator rectangle on the tab buttons
*/
lv_obj_t * lv_tabview_get_indic(lv_obj_t * tabview);
/**
* Add a new tab with the given name
* @param tabview pointer to Tab view object where to ass the new tab
* @param name the text on the tab button
* @return pointer to page object (lv_page) which is the containter of the contet
*/
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name);
/**********************
* MACROS
**********************/
#endif /*USE_LV_TABVIEW*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_TAB_H*/
......@@ -31,12 +31,16 @@ extern "C" {
#include "lv_objx/lv_slider.h"
#include "lv_objx/lv_led.h"
#include "lv_objx/lv_btnm.h"
#include "lv_objx/lv_kb.h"
#include "lv_objx/lv_ddlist.h"
#include "lv_objx/lv_ta.h"
#include "lv_objx/lv_win.h"
#include "lv_objx/lv_tabview.h"
#include "lv_objx/lv_mbox.h"
#include "lv_objx/lv_gauge.h"
#include "lv_objx/lv_lmeter.h"
#include "lv_objx/lv_sw.h"
#include "lv_objx/lv_kb.h"
#include "lv_app/lv_app.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment