format code and fix slider

This commit is contained in:
xianjimli 2018-08-06 17:46:27 +08:00
parent 0216a4bfd8
commit 3dfa4409f3
7 changed files with 11910 additions and 9532 deletions

View File

@ -218,17 +218,17 @@
#include "res/inc/images/unchecked.data" #include "res/inc/images/unchecked.data"
#include "res/inc/images/unmuted.data" #include "res/inc/images/unmuted.data"
#include "res/inc/images/warn.data" #include "res/inc/images/warn.data"
#endif/*WITH_STB_IMAGE*/ #endif /*WITH_STB_IMAGE*/
#ifdef WITH_STB_FONT #ifdef WITH_STB_FONT
#ifdef WITH_MINI_FONT #ifdef WITH_MINI_FONT
#include "res/inc/fonts/default.mini.res" #include "res/inc/fonts/default.mini.res"
#else/*WITH_MINI_FONT*/ #else /*WITH_MINI_FONT*/
#include "res/inc/fonts/default.res" #include "res/inc/fonts/default.res"
#endif/*WITH_MINI_FONT*/ #endif /*WITH_MINI_FONT*/
#else/*WITH_STB_FONT*/ #else /*WITH_STB_FONT*/
#include "res/inc/fonts/default.data" #include "res/inc/fonts/default.data"
#endif/*WITH_STB_FONT*/ #endif /*WITH_STB_FONT*/
#endif/*WITH_FS_RES*/ #endif /*WITH_FS_RES*/
ret_t resource_init(void) { ret_t resource_init(void) {
resource_manager_t* rm = resource_manager(); resource_manager_t* rm = resource_manager();

View File

@ -1,6 +1,6 @@
find src tools lua demos tests -name \*.c -exec clang-format -i {} \; find src tools demos tests -name \*.c -exec clang-format -i {} \;
find src tools lua demos tests -name \*.h -exec clang-format -i {} \; find src tools demos tests -name \*.h -exec clang-format -i {} \;
find src tools lua demos tests -name \*.cc -exec clang-format -i {} \; find src tools demos tests -name \*.cc -exec clang-format -i {} \;
find src tools lua demos tests -name \*.cpp -exec clang-format -i {} \; find src tools demos tests -name \*.cpp -exec clang-format -i {} \;
find src tools lua demos tests -name \*.inc -exec clang-format -i {} \; find src tools demos tests -name \*.inc -exec clang-format -i {} \;

2
src/base/locale.h Executable file → Normal file
View File

@ -114,7 +114,7 @@ ret_t locale_change(tklocale_t* locale, const char* language, const char* countr
/** /**
* @method locale_on * @method locale_on
* *
* @annotation ["scriptable:custom"] * @annotation ["scriptable:custom"]
* @param {tklocale_t*} locale * @param {tklocale_t*} locale
* @param {event_type_t} type EVT_LOCALE_CHANGED * @param {event_type_t} type EVT_LOCALE_CHANGED
* @param {event_func_t} on_event * @param {event_func_t} on_event

View File

@ -26,7 +26,8 @@
#include "base/widget_vtable.h" #include "base/widget_vtable.h"
#include "base/image_manager.h" #include "base/image_manager.h"
static ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_type_t etype); static ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_type_t etype,
bool_t force);
static ret_t slider_get_dragger_rect(widget_t* widget, rect_t* r) { static ret_t slider_get_dragger_rect(widget_t* widget, rect_t* r) {
slider_t* slider = SLIDER(widget); slider_t* slider = SLIDER(widget);
@ -191,9 +192,7 @@ static ret_t slider_on_event(widget_t* widget, event_t* e) {
fvalue = 1; fvalue = 1;
} }
value = fvalue * (slider->max - slider->min) + slider->min; value = fvalue * (slider->max - slider->min) + slider->min;
if (value != slider->value) { slider_set_value_internal(widget, value, EVT_VALUE_CHANGING, FALSE);
slider_set_value_internal(widget, value, EVT_VALUE_CHANGING);
}
} }
break; break;
@ -202,7 +201,7 @@ static ret_t slider_on_event(widget_t* widget, event_t* e) {
if (slider->dragging) { if (slider->dragging) {
slider->dragging = FALSE; slider->dragging = FALSE;
widget_ungrab(widget->parent, widget); widget_ungrab(widget->parent, widget);
slider_set_value_internal(widget, slider->value, EVT_VALUE_CHANGED); slider_set_value_internal(widget, slider->value, EVT_VALUE_CHANGED, TRUE);
} }
widget_set_state(widget, WIDGET_STATE_NORMAL); widget_set_state(widget, WIDGET_STATE_NORMAL);
widget_invalidate(widget, NULL); widget_invalidate(widget, NULL);
@ -221,7 +220,8 @@ static ret_t slider_on_event(widget_t* widget, event_t* e) {
return RET_OK; return RET_OK;
} }
static ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_type_t etype) { static ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_type_t etype,
bool_t force) {
event_t evt; event_t evt;
uint16_t step = 0; uint16_t step = 0;
uint16_t offset = 0; uint16_t offset = 0;
@ -236,7 +236,7 @@ static ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_t
value = slider->min + ((offset + (step >> 1) - 1) / step) * step; value = slider->min + ((offset + (step >> 1) - 1) / step) * step;
} }
if (slider->value != value) { if (slider->value != value || force) {
evt.type = etype; evt.type = etype;
evt.target = widget; evt.target = widget;
slider->value = value; slider->value = value;
@ -248,7 +248,7 @@ static ret_t slider_set_value_internal(widget_t* widget, uint16_t value, event_t
} }
ret_t slider_set_value(widget_t* widget, uint16_t value) { ret_t slider_set_value(widget_t* widget, uint16_t value) {
return slider_set_value_internal(widget, value, EVT_VALUE_CHANGED); return slider_set_value_internal(widget, value, EVT_VALUE_CHANGED, FALSE);
} }
ret_t slider_set_min(widget_t* widget, uint16_t min) { ret_t slider_set_min(widget_t* widget, uint16_t min) {

View File

@ -194,7 +194,7 @@ ret_t widget_animator_set_reversed(widget_animator_t* animator, bool_t value);
/** /**
* @method widget_animator_on * @method widget_animator_on
* *
* @annotation ["scriptable:custom"] * @annotation ["scriptable:custom"]
* @param {widget_animator_t*} animator * @param {widget_animator_t*} animator
* @param {event_type_t} type * @param {event_type_t} type
* EVT_ANIM_START,EVT_ANIM_STOP,EVT_ANIM_ONCE和EVT_ANIM_END * EVT_ANIM_START,EVT_ANIM_STOP,EVT_ANIM_ONCE和EVT_ANIM_END
@ -209,7 +209,7 @@ uint32_t widget_animator_on(widget_animator_t* animator, event_type_t type, even
/** /**
* @method widget_animator_off * @method widget_animator_off
* *
* @annotation ["scriptable:custom"] * @annotation ["scriptable:custom"]
* @param {widget_animator_t*} animator * @param {widget_animator_t*} animator
* @param {uint32_t} id widget_animator_on返回的ID * @param {uint32_t} id widget_animator_on返回的ID
* *

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff