|
@@ -47,12 +47,7 @@ void zori_draw_button(struct zori_button * button) {
|
|
|
h = rebox_h(&button->widget.inner);
|
|
|
|
|
|
zori_widget_draw_background(&button->widget);
|
|
|
- if (button->text) {
|
|
|
- zori_font * font = style->text.font;
|
|
|
- zori_color color = style->text.color;
|
|
|
- al_draw_multiline_ustr(font, color, x, y, w, -1, ALLEGRO_ALIGN_LEFT, button->text);
|
|
|
- }
|
|
|
-
|
|
|
+ zori_caption_draw(&button->caption, &button->widget.inner, &button->widget.style);
|
|
|
};
|
|
|
|
|
|
int zori_button_on_draw(union zori_event * event) {
|
|
@@ -72,24 +67,22 @@ struct zori_handler zori_button_handlers[] = {
|
|
|
|
|
|
struct zori_button *
|
|
|
zori_button_text_(struct zori_button * button, zori_string * text) {
|
|
|
- if (button->text) {
|
|
|
- al_ustr_free(button->text);
|
|
|
- button->text = NULL;
|
|
|
- }
|
|
|
- if (text) {
|
|
|
- button->text = al_ustr_dup(text);
|
|
|
- }
|
|
|
+ if (button) {
|
|
|
+ zori_caption_set(&button->caption, text);
|
|
|
+ }
|
|
|
return button;
|
|
|
}
|
|
|
|
|
|
struct zori_button *
|
|
|
-zori_button_init(struct zori_button * button, zori_string * text) {
|
|
|
- button->text = NULL;
|
|
|
- return zori_button_text_(button, text);
|
|
|
+zori_button_init(struct zori_button * button,const char * text) {
|
|
|
+ if (button) {
|
|
|
+ zori_caption_init(&button->caption, text);
|
|
|
+ }
|
|
|
+ return button;
|
|
|
}
|
|
|
|
|
|
struct zori_button * zori_button_new(zori_id id, zori_id parent_id,
|
|
|
- zori_box * box, zori_string * text) {
|
|
|
+ zori_box * box, const char * text) {
|
|
|
struct zori_button * button = NULL;
|
|
|
button = calloc(1, sizeof(*button));
|
|
|
if (!button) return NULL;
|
|
@@ -105,7 +98,7 @@ struct zori_button * zori_button_new(zori_id id, zori_id parent_id,
|
|
|
}
|
|
|
|
|
|
|
|
|
-zori_id zori_new_button(zori_id id, zori_id parent, zori_box * box, zori_string * text) {
|
|
|
+zori_id zori_new_button(zori_id id, zori_id parent, zori_box * box, const char * text) {
|
|
|
struct zori_button * button = zori_button_new(id, parent, box, text);
|
|
|
if (!button) return ZORI_ID_ENOMEM;
|
|
|
return button->widget.id;
|