From a285b5c3c1e9270c90d28781d3d989a714da365e Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Thu, 9 Apr 2015 20:46:41 +0200 Subject: add materials and progressbar to scripted wizzard Signed-off-by: Olliver Schinagl --- src/eulogium.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++----------- src/eulogium.h | 3 +-- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/eulogium.c b/src/eulogium.c index 56ecfc3..31819fa 100644 --- a/src/eulogium.c +++ b/src/eulogium.c @@ -221,7 +221,6 @@ elm_progressbar_value_set(eulogium->print.progress, 0.5); evas_object_show(object); elm_table_pack(table, object, 0, 6, 3, 1); - return table; } @@ -516,6 +515,11 @@ static void _eulogium_multi_screen_next_cb(void *data, Evas_Object *obj EINA_UNU free(data); } +static void _cb_material_set(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + printf("Material: %s selected\n", (char *)data); +} + Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct multi_screen_data *screen_data, uint_fast8_t pagenum, Eina_Bool pageindex) { Evas_Object *object; @@ -543,22 +547,57 @@ Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Obj elm_box_pack_end(_top, object); } -#if 0 - printf("%s\n", screen->text); - printf("%s\n", screen->text); - printf("%s\n", screen->text); + if (screen_data->screen[pagenum].text) { + object = elm_label_add(_top); + elm_object_text_set(object, screen_data->screen[pagenum].text); + evas_object_show(object); + elm_box_pack_end(_top, object); + } + + switch (screen_data->screen[pagenum].type) { + Evas_Object *box; /* TODO rename to 'type' or something */ - switch (screen->type) { - case TEXT: - break; - case BUTTON: - break; case MATERIAL: + box = elm_box_add(_top); + elm_box_horizontal_set(box, EINA_TRUE); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(box); + + object = elm_button_add(box); + evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(object, "PLA"); /* Materials need to be handled differently */ + evas_object_smart_callback_add(object, "clicked", _cb_material_set, "PLA"); + evas_object_show(object); + elm_box_pack_end(box, object); + + object = elm_button_add(box); + evas_object_size_hint_align_set(object, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(object, "ABS"); + evas_object_smart_callback_add(object, "clicked", _cb_material_set, "ABS"); + evas_object_show(object); + elm_box_pack_end(box, object); + + elm_box_pack_end(_top, box); break; case PROGRESS: + box = elm_progressbar_add(_top); + elm_progressbar_horizontal_set(box, EINA_TRUE); + elm_progressbar_pulse_set(box, EINA_FALSE); /* TODO: pulse = time-unknown/pause */ + elm_progressbar_pulse(box, EINA_FALSE); + elm_progressbar_value_set(box, 0.5); + elm_progressbar_unit_format_set(box, "%1.0f%%"); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(box); + elm_box_pack_end(_top, box); + break; + case END: /* fall through */ + default: break; } -#endif + _bottom = elm_box_add(parent); elm_box_horizontal_set(_bottom, EINA_TRUE); evas_object_show(_bottom); @@ -754,20 +793,34 @@ static struct multi_text txtdata = { static Eina_List *wizzard; /* TODO find a good spot to put this. */ static struct multi_screen screen[] = { { - .type = TEXT, - .text = "Welcome to your new Ultimaker", + .type = NONE, + .text = "Welcome
to your new Ultimaker", + .data = NULL, + .prev_button = "Skip Wizzard!", + .next_button = "Continue", + }, + { + .type = MATERIAL, + .text = NULL, .data = NULL, .prev_button = "Skip Wizzard!", .next_button = "Continue", }, { - .type = TEXT, + .type = PROGRESS, + .text = "Heating ...", + .data = "progress object", + .prev_button = "Skip Wizzard!", + .next_button = "Continue", + }, + { + .type = NONE, .text = "Lets print!", .data = NULL, .prev_button = NULL, .next_button = "Let's Print!", }, - { .type = NONE, /* sentinel */ }, + { .type = END, /* sentinel */ }, }; static struct multi_screen_data screen_data = { @@ -806,7 +859,7 @@ static void eulogium_setup(struct eulogium_data *eulogium) while (txtdata.text[txtdata.count]) txtdata.count++; screen_data.count = 0; - while (screen_data.screen[screen_data.count].type != NONE) + while (screen_data.screen[screen_data.count].type != END) screen_data.count++; eulogium->print.name = NULL; diff --git a/src/eulogium.h b/src/eulogium.h index e3be4b8..958504c 100644 --- a/src/eulogium.h +++ b/src/eulogium.h @@ -8,10 +8,9 @@ enum screen_type { NONE, - TEXT, - BUTTON, MATERIAL, PROGRESS, + END, }; struct print_data { -- cgit v0.12