summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlliver Schinagl <o.schinagl@ultimaker.com>2015-04-08 19:43:06 (GMT)
committerOlliver Schinagl <o.schinagl@ultimaker.com>2015-04-28 05:07:13 (GMT)
commite5cba6d032e7f30c3871229ff661c07a356108ba (patch)
treeaea61f963d5843425668f81974fa10178ad242cb
parent4b9495b41f4249a6b41950d7cbb3d0fe9c8c1e4b (diff)
downloadeulogium-e5cba6d032e7f30c3871229ff661c07a356108ba.zip
eulogium-e5cba6d032e7f30c3871229ff661c07a356108ba.tar.gz
eulogium-e5cba6d032e7f30c3871229ff661c07a356108ba.tar.bz2
dont pop last item on a _prev_ pop, add more multi_screen wizzardry
Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
-rw-r--r--src/eulogium.c72
-rw-r--r--src/eulogium.h12
2 files changed, 63 insertions, 21 deletions
diff --git a/src/eulogium.c b/src/eulogium.c
index 61f9a7c..de60bd1 100644
--- a/src/eulogium.c
+++ b/src/eulogium.c
@@ -355,8 +355,13 @@ static void _cb_filelist_top(void *data, Evas_Object *object EINA_UNUSED, void *
static void _cb_content_prev_set(void *data, Evas_Object *object EINA_UNUSED, void *event_info EINA_UNUSED)
{
struct eulogium_data *eulogium = data;
+ uint_fast8_t list_size;
- elm_naviframe_item_pop(eulogium->layout);
+ list_size = eina_list_count(elm_naviframe_items_get(eulogium->layout));
+ if (list_size < 2)
+ printf("Not popping last item cowboy\n"); /* TODO, use proper debug contruct */
+ else
+ elm_naviframe_item_pop(eulogium->layout);
}
static struct button_def but_return = {
@@ -480,10 +485,11 @@ Evas_Object *eulogium_multi_text_menu(struct eulogium_data *eulogium, Evas_Objec
return eulogium_split_screen(parent, _top, _bottom);
}
-Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct multi_screen *screen[])
+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;
Evas_Object *_top, *_bottom;
+ char buf[6];
#if 0
printf("%s\n", screen->text);
@@ -501,27 +507,41 @@ Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Obj
break;
}
#endif
-// printf("%s\n", eulogium->print.name);
_top = elm_box_add(parent);
evas_object_show(_top);
+ if (pagenum >= screen_data->count)
+ pagenum = screen_data->count - 1;
+
+ if (pageindex) {
+ object = elm_label_add(_top);
+ snprintf(buf, sizeof(buf), "%d/%d", pagenum + 1, screen_data->count);
+ elm_object_text_set(object, buf);
+ evas_object_show(object);
+ evas_object_size_hint_align_set(object, 1.0, 0);
+ elm_box_pack_end(_top, object);
+ }
+
_bottom = elm_box_add(parent);
elm_box_horizontal_set(_bottom, EINA_TRUE);
evas_object_show(_bottom);
- if (screen[0]->prev_button) {
+ if (screen_data->screen[0].prev_button) {
object = elm_button_add(parent);
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, screen[0]->prev_button);
+ elm_object_text_set(object, screen_data->screen[0].prev_button);
+ evas_object_smart_callback_add(object, "clicked", _cb_content_prev_set, eulogium);
evas_object_show(object);
elm_box_pack_end(_bottom, object);
+ printf("Button created\n");
}
- if (screen[0]->next_button) {
+ if (screen_data->screen[0].next_button) {
object = elm_button_add(parent);
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, screen[0]->next_button);
+ elm_object_text_set(object, screen_data->screen[0].next_button);
+// evas_object_smart_callback_add(_bottom, "clicked", _eulogium_multi_text_next_cb, multi_text_next_cb_data);
evas_object_show(object);
elm_box_pack_end(_bottom, object);
}
@@ -690,18 +710,31 @@ 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",
- .data = NULL,
- .next_button = "Continue",
- .prev_button = "back",
-}, };
+static struct multi_screen screen[] = {
+ {
+ .type = TEXT,
+ .text = "Welcome to your new Ultimaker",
+ .data = NULL,
+ .prev_button = "Skip Wizzard!",
+ .next_button = "Continue",
+ },
+ {
+ .type = TEXT,
+ .text = "Lets print!",
+ .data = NULL,
+ .prev_button = NULL,
+ .next_button = "Let's Print!",
+ },
+ { .type = NONE, /* sentinel */ },
+};
+
+static struct multi_screen_data screen_data = {
+ .screen = &screen[0],
+};
Evas_Object *eulogium_main_menu(Evas_Object *window, struct eulogium_data *eulogium)
{
Evas_Object *content;
- struct multi_screen *screens = &screen[0];
eulogium->layout = elm_naviframe_add(window);
if (!eulogium->layout)
@@ -710,13 +743,13 @@ Evas_Object *eulogium_main_menu(Evas_Object *window, struct eulogium_data *eulog
// elm_naviframe_item_title_enabled_set(eulogium->layout, EINA_TRUE, EINA_TRUE);
// elm_naviframe_item_title_visible_set(eulogium->layout, EINA_FALSE);
- //content = eulogium_tripple_button_menu(eulogium->layout, &but_main_print, &but_main_material, &but_main_maintanance);
- content = eulogium_multi_screen_menu(eulogium, eulogium->layout, &screens);
+ content = eulogium_tripple_button_menu(eulogium->layout, &but_main_print, &but_main_material, &but_main_maintanance);
if (!content)
return NULL;
elm_naviframe_item_simple_push(eulogium->layout, content);
// if (firstrunwiz) {
- content = eulogium_multi_text_menu(eulogium, eulogium->layout, NULL, &txtdata, 0, EINA_TRUE);
+ content = eulogium_multi_screen_menu(eulogium, eulogium->layout, &screen_data, 0, EINA_TRUE);
+ //content = eulogium_multi_text_menu(eulogium, eulogium->layout, NULL, &txtdata, 0, EINA_TRUE);
if (!content)
return NULL;
elm_naviframe_item_simple_push(eulogium->layout, content);
@@ -730,6 +763,9 @@ static void eulogium_setup(struct eulogium_data *eulogium)
txtdata.count = 0;
while (txtdata.text[txtdata.count])
txtdata.count++;
+ screen_data.count = 0;
+ while (screen_data.screen[screen_data.count].type != NONE)
+ screen_data.count++;
eulogium->print.name = NULL;
eulogium->print.file = NULL;
diff --git a/src/eulogium.h b/src/eulogium.h
index 8e327c3..e3be4b8 100644
--- a/src/eulogium.h
+++ b/src/eulogium.h
@@ -7,6 +7,7 @@
#include <stdint.h>
enum screen_type {
+ NONE,
TEXT,
BUTTON,
MATERIAL,
@@ -50,9 +51,14 @@ struct multi_screen {
enum screen_type type;
char *text;
void *data;
- char *next_button;
char *prev_button;
- /* TODO concider adding a button_def for the buttons */
+ char *next_button;
+ /* TODO consider adding a button_def for the buttons */
+};
+
+struct multi_screen_data {
+ uint_fast8_t count;
+ struct multi_screen *screen;
};
void eulogium_print_file_set(struct eulogium_data *eulogium, char *filepath);
@@ -67,6 +73,6 @@ Evas_Object *eulogium_tripple_button_menu(Evas_Object *parent, const struct butt
Evas_Object *eulogium_print_menu(struct eulogium_data *eulogium, char *filepath);
Evas_Object *eulogium_print_progress(struct eulogium_data *eulogium);
Evas_Object *eulogium_multi_text_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct button_def *button, struct multi_text *data, const uint_fast8_t pagenum, Eina_Bool pageindex);
-Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct multi_screen *screen[]);
+Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct multi_screen_data *screen_data, const uint_fast8_t pagenum, Eina_Bool pageindex);
#endif /* _EULOGIUM_H */