mirror of
https://git.planet-casio.com/Lephenixnoir/JustUI.git
synced 2025-01-01 06:23:38 +01:00
jlist, jscrolledlist: make parent the last constructor argument
To stay in line with constructors for other widgets.
This commit is contained in:
parent
3488c6515a
commit
ba7b0a02d0
4 changed files with 20 additions and 11 deletions
|
@ -39,9 +39,16 @@ typedef struct {
|
||||||
|
|
||||||
struct jlist;
|
struct jlist;
|
||||||
|
|
||||||
|
/* Info function: should fill `info` with the data related to list element
|
||||||
|
#index (starts at 0). `info` is guaranteed to be pre-initialized to 0. */
|
||||||
typedef void (*jlist_item_info_function)(struct jlist *list, int index,
|
typedef void (*jlist_item_info_function)(struct jlist *list, int index,
|
||||||
jlist_item_info *info);
|
jlist_item_info *info);
|
||||||
|
|
||||||
|
/* Paint function: should draw element #index on the rectangle of size `w×h`
|
||||||
|
at position `x,y`. If the item has a selection style that is not
|
||||||
|
JLIST_SELECTION_MANUAL, the selection effect is handled by jlist. Otherwise,
|
||||||
|
the paint function should check the `selected` parameter to apply any
|
||||||
|
relevant styling. */
|
||||||
typedef void (*jlist_item_paint_function)(int x, int y, int w, int h,
|
typedef void (*jlist_item_paint_function)(int x, int y, int w, int h,
|
||||||
struct jlist *list, int index, bool selected);
|
struct jlist *list, int index, bool selected);
|
||||||
|
|
||||||
|
@ -79,8 +86,8 @@ extern uint16_t JLIST_SELECTION_MOVED;
|
||||||
extern uint16_t JLIST_MODEL_UPDATED;
|
extern uint16_t JLIST_MODEL_UPDATED;
|
||||||
|
|
||||||
/* jlist_create(): Create a new (empty) jlist. */
|
/* jlist_create(): Create a new (empty) jlist. */
|
||||||
jlist *jlist_create(void *parent, jlist_item_info_function info_function,
|
jlist *jlist_create(jlist_item_info_function info_function,
|
||||||
jlist_item_paint_function paint_function);
|
jlist_item_paint_function paint_function, void *parent);
|
||||||
|
|
||||||
/* jlist_update_model(): Update jlists's information about the model
|
/* jlist_update_model(): Update jlists's information about the model
|
||||||
The new model size is passed as parameter. The model is refreshed by
|
The new model size is passed as parameter. The model is refreshed by
|
||||||
|
|
|
@ -25,9 +25,10 @@ typedef struct {
|
||||||
|
|
||||||
} jscrolledlist;
|
} jscrolledlist;
|
||||||
|
|
||||||
/* jscrolledlist_create(): Create a scrolled list */
|
/* Create a scrolled list; arguments are forwarded to the jlist. */
|
||||||
jscrolledlist *jscrolledlist_create(void *parent,
|
jscrolledlist *jscrolledlist_create(
|
||||||
jlist_item_info_function info_function,
|
jlist_item_info_function info_function,
|
||||||
jlist_item_paint_function paint_function);
|
jlist_item_paint_function paint_function,
|
||||||
|
void *parent);
|
||||||
|
|
||||||
#endif /* _J_JSCROLLEDLIST */
|
#endif /* _J_JSCROLLEDLIST */
|
||||||
|
|
|
@ -19,8 +19,8 @@ struct jlist_item_info {
|
||||||
bool selectable;
|
bool selectable;
|
||||||
};
|
};
|
||||||
|
|
||||||
jlist *jlist_create(void *parent, jlist_item_info_function info_function,
|
jlist *jlist_create(jlist_item_info_function info_function,
|
||||||
jlist_item_paint_function paint_function)
|
jlist_item_paint_function paint_function, void *parent)
|
||||||
{
|
{
|
||||||
if(jlist_type_id < 0)
|
if(jlist_type_id < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -8,9 +8,10 @@
|
||||||
/* Type identifier for jscrolledlist */
|
/* Type identifier for jscrolledlist */
|
||||||
static int jscrolledlist_type_id = -1;
|
static int jscrolledlist_type_id = -1;
|
||||||
|
|
||||||
jscrolledlist *jscrolledlist_create(void *parent,
|
jscrolledlist *jscrolledlist_create(
|
||||||
jlist_item_info_function info_function,
|
jlist_item_info_function info_function,
|
||||||
jlist_item_paint_function paint_function)
|
jlist_item_paint_function paint_function,
|
||||||
|
void *parent)
|
||||||
{
|
{
|
||||||
if(jscrolledlist_type_id < 0)
|
if(jscrolledlist_type_id < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -26,7 +27,7 @@ jscrolledlist *jscrolledlist_create(void *parent,
|
||||||
jwidget_set_stretch(l->frame, 1, 1, false);
|
jwidget_set_stretch(l->frame, 1, 1, false);
|
||||||
jframe_set_align(l->frame, J_ALIGN_LEFT, J_ALIGN_TOP);
|
jframe_set_align(l->frame, J_ALIGN_LEFT, J_ALIGN_TOP);
|
||||||
|
|
||||||
l->list = jlist_create(l->frame, info_function, paint_function);
|
l->list = jlist_create(info_function, paint_function, l->frame);
|
||||||
jwidget_set_stretch(l->list, 1, 1, false);
|
jwidget_set_stretch(l->list, 1, 1, false);
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
|
@ -67,7 +68,7 @@ static bool jscrolledlist_poly_event(void *l0, jevent e)
|
||||||
if(e.type == JLIST_MODEL_UPDATED && e.source == l->list)
|
if(e.type == JLIST_MODEL_UPDATED && e.source == l->list)
|
||||||
shake_scroll(l, true);
|
shake_scroll(l, true);
|
||||||
|
|
||||||
/* Allow the evnts to bubble up */
|
/* Allow the events to bubble up */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue