summaryrefslogtreecommitdiffstats
path: root/src/eulogium.c
diff options
context:
space:
mode:
authorOlliver Schinagl <o.schinagl@ultimaker.com>2015-06-04 19:43:16 (GMT)
committerOlliver Schinagl <o.schinagl@ultimaker.com>2015-06-12 05:30:15 (GMT)
commit69ba56021670050e247e9b9e4f931d9e2597f389 (patch)
tree8ce5d4fe97fafc751cd046b7c58e29074ab21d42 /src/eulogium.c
parent577303246c0d44d6fa2f58091f3a7d8b6bc5e47b (diff)
downloadeulogium-69ba56021670050e247e9b9e4f931d9e2597f389.zip
eulogium-69ba56021670050e247e9b9e4f931d9e2597f389.tar.gz
eulogium-69ba56021670050e247e9b9e4f931d9e2597f389.tar.bz2
[griffin.display] Add initial default menu structure
Add first lines that shows the new menu structure Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
Diffstat (limited to 'src/eulogium.c')
-rw-r--r--src/eulogium.c285
1 files changed, 285 insertions, 0 deletions
diff --git a/src/eulogium.c b/src/eulogium.c
index 9badd9f..979af86 100644
--- a/src/eulogium.c
+++ b/src/eulogium.c
@@ -290,6 +290,186 @@ static struct button_def but_change_hotend_2 = {
.data = NULL,
};
+static struct menu_def menu_system_settings = {
+ .title = "SETTINGS",
+ .entry = {
+ {
+ .icon = "user-home",
+ .label = "Return",
+ .end = NULL,
+ .footer = "Return to Main menu",
+ .footer_alt = NULL,
+ .func = &_cb_content_prev_set,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Language",
+ .end = NULL,
+ .footer = "Change language",
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Network",
+ .end = NULL,
+ .footer = "Manage connectivity",
+ .footer_alt = "WiFi &amp; Ethernet",
+ .func = &_but_network_stats_cb,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Hot end 1 offset",
+ .end = NULL,
+ .footer = "Adjust offset",
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL, /* hot end 1 pointer? */
+ }, {
+ .icon = NULL,
+ .label = "Hot end 2 offset",
+ .end = NULL,
+ .footer = "Adjust offset",
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL, /* hot end 2 pointer? */
+ }, {
+ .icon = NULL,
+ .label = "Feeder power",
+ .end = NULL,
+ .footer = "Adjust power ",
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Filament detection",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Camera",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Internal storage",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "LED settings",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Retraction",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Motion",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Software version",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Factory reset",
+ .end = NULL,
+ .footer = NULL,
+ .footer_alt = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, { NULL }, /* sentinel */
+ },
+ .data = NULL,
+};
+
+static struct menu_def menu_settings_network = {
+ .title = "NETWORK",
+ .entry = {
+ {
+ .icon = NULL,
+ .label = "Network info",
+ .end = NULL,
+ .footer = NULL,
+ .func = &_but_network_stats_cb,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Manage WiFi",
+ .end = NULL,
+ .footer = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "WiFi",
+ .end = NULL,
+ .footer = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .icon = NULL,
+ .label = "Ethernet",
+ .end = NULL,
+ .footer = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, {
+ .label = "Hotspot",
+ .footer = NULL,
+ .end = NULL,
+ .func = NULL,
+ .toggle_timer = NULL,
+ .data = NULL,
+ }, { NULL }, /* sentinel */
+ },
+ .data = NULL,
+};
+
static void eulogium_print_data_clear(struct eulogium_data *eulogium)
{
if (eulogium->progress_data_refresh)
@@ -1226,6 +1406,110 @@ Evas_Object *eulogium_print_menu(struct eulogium_data *eulogium, char *filepath)
return box;
}
+static void _update_footer_unfocus_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ struct menu_entry_def *entry = data;
+
+ if (entry->toggle_timer)
+ ecore_timer_del(entry->toggle_timer);
+}
+
+static Eina_Bool _timer_footer_toggle_cb(void *data)
+{
+ struct menu_entry_def *entry = data;
+ Evas_Object *footer = entry->data;
+ static uint_fast8_t toggle = 0;
+
+ if (toggle)
+ elm_object_text_set(footer, entry->footer);
+ else
+ elm_object_text_set(footer, entry->footer_alt);
+ toggle = !toggle;
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static void _update_footer_focus_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ struct menu_entry_def *entry = data;
+ Evas_Object *footer = entry->data;
+
+ if (!entry->footer) {
+ elm_object_text_set(footer, entry->label);
+ return;
+ }
+ elm_object_text_set(footer, entry->footer);
+
+ if (entry->footer_alt) {
+ entry->toggle_timer = ecore_timer_add(1.5, _timer_footer_toggle_cb, entry); /* XXX magic value!! */
+ if (!entry->toggle_timer)
+ EINA_LOG_ERR("Unable to create toggle timer for entry %s", entry->label);
+ }
+
+}
+
+Evas_Object *menu_widget_list(struct eulogium_data *eulogium, Evas_Object *parent, struct menu_def *menu)
+{
+ int i;
+ Evas_Object *obj;
+ Evas_Object *box;
+ Evas_Object *list;
+ Evas_Object *icon;
+ Evas_Object *item;
+
+ box = elm_box_add(parent);
+
+ eulogium->footer = elm_label_add(box);
+
+ obj = elm_label_add(box);
+ elm_object_text_set(obj, menu->title);
+ evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(obj);
+ elm_box_pack_start(box, obj);
+
+ list = eulogium_button_list_add(box);
+ elm_scroller_bounce_set(list, EINA_FALSE, EINA_FALSE);
+ elm_scroller_policy_set(list, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ //elm_list_mode_set(list, ELM_LIST_COMPRESS);
+ elm_scroller_movement_block_set(list, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL | ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL);
+ evas_object_show(list);
+ elm_box_pack_end(box, list);
+
+ for (i = 0; menu->entry[i].label != NULL; i++) {
+ if (menu->entry[i].icon) {
+ icon = elm_icon_add(list);
+ elm_icon_standard_set(icon, menu->entry[i].icon);
+ } else {
+ icon = NULL;
+ }
+ item = eulogium_button_list_append(list, menu->entry[i].label, icon, menu->entry[i].func, eulogium); /*XXX TODO pass data from struct */
+ menu->entry[i].data = eulogium->footer; /* XXX ugly-ness keeps adding. the footer widget should not be passed like this :( */
+ evas_object_smart_callback_add(item, "focused", _update_footer_focus_cb, &menu->entry[i]);
+ evas_object_smart_callback_add(item, "unfocused", _update_footer_unfocus_cb, &menu->entry[i]);
+ }
+
+ eulogium_button_list_go(list);
+// evas_object_smart_callback_add(list, "longpressed", _cb_filelist_filedetails, NULL); /* TODO, use inwin */
+ evas_object_show(list);
+
+ obj = elm_separator_add(box);
+ elm_separator_horizontal_set(obj, EINA_TRUE);
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, 0);
+ evas_object_show(obj);
+ elm_box_pack_end(box, obj);
+
+ /* Footer is initialized at the start of the function, so that the for loop can work with it. */
+ elm_object_text_set(eulogium->footer, NULL);
+ evas_object_size_hint_align_set(eulogium->footer, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(eulogium->footer);
+ elm_box_pack_end(box, eulogium->footer);
+
+ evas_object_show(box);
+ return box;
+}
+
struct _multi_screen_next_cb_data {
struct eulogium_data *eulogium;
struct multi_screen_data *screen_data;
@@ -1525,6 +1809,7 @@ static void eulogium_setup(struct eulogium_data *eulogium)
eulogium_print_data_clear(eulogium);
eulogium->printer.status = DISCONNECTED;
eulogium->printer.file_handlers = NULL;
+ eulogium->footer = NULL;
eulogium_button_cb_data_set(&but_return, eulogium);
eulogium_button_cb_data_set(&but_print_abort, eulogium);
eulogium_button_cb_data_set(&but_print_progress_tune, eulogium);