Dropdown list trees

This commit is contained in:
Nekobit 2023-09-13 23:00:00 -04:00
parent 15d67ff6f4
commit 3195a05567
35 changed files with 119 additions and 13 deletions

View File

Before

Width:  |  Height:  |  Size: 776 B

After

Width:  |  Height:  |  Size: 776 B

View File

Before

Width:  |  Height:  |  Size: 716 B

After

Width:  |  Height:  |  Size: 716 B

View File

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 661 B

View File

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 866 B

View File

Before

Width:  |  Height:  |  Size: 613 B

After

Width:  |  Height:  |  Size: 613 B

View File

Before

Width:  |  Height:  |  Size: 783 B

After

Width:  |  Height:  |  Size: 783 B

View File

Before

Width:  |  Height:  |  Size: 788 B

After

Width:  |  Height:  |  Size: 788 B

View File

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 687 B

View File

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 718 B

View File

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 764 B

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

View File

Before

Width:  |  Height:  |  Size: 810 B

After

Width:  |  Height:  |  Size: 810 B

View File

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 736 B

View File

Before

Width:  |  Height:  |  Size: 921 B

After

Width:  |  Height:  |  Size: 921 B

View File

Before

Width:  |  Height:  |  Size: 767 B

After

Width:  |  Height:  |  Size: 767 B

View File

Before

Width:  |  Height:  |  Size: 719 B

After

Width:  |  Height:  |  Size: 719 B

View File

Before

Width:  |  Height:  |  Size: 638 B

After

Width:  |  Height:  |  Size: 638 B

View File

Before

Width:  |  Height:  |  Size: 776 B

After

Width:  |  Height:  |  Size: 776 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 404 B

View File

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 404 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 878 B

After

Width:  |  Height:  |  Size: 878 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 752 B

After

Width:  |  Height:  |  Size: 752 B

View File

Before

Width:  |  Height:  |  Size: 783 B

After

Width:  |  Height:  |  Size: 783 B

View File

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 529 B

View File

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 814 B

View File

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

View File

Before

Width:  |  Height:  |  Size: 728 B

After

Width:  |  Height:  |  Size: 728 B

View File

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 746 B

3
main.c
View File

@ -14,6 +14,9 @@ int opt_mallocd = -1;
char* game_path = "SSBM.iso";
char* dolphin_emu_file = "slippi-netplay-dolphin";
char* dolphin_replay_file = "slippi-playback-dolphin";
#ifndef DATA_DIR
#define DATA_DIR "data/"
#endif
Ecore_Exe* dolphin_netplay_exe;
Evas_Object* mainer;

129
replay.c
View File

@ -10,6 +10,9 @@ Evas_Object* tab_replays = NULL;
char* replays_dir = "replays/";
Ecore_Exe* dolphin_replay_exe;
extern char* dolphin_replay_file, *game_path;
#ifndef DATA_DIR
#define DATA_DIR "data/"
#endif
struct replay
{
@ -190,24 +193,71 @@ gameend2str(int code)
}
}
Evas_Object*
replays_content(void* data, Evas_Object* obj, const char* part)
{
char* c;
if (strcmp(part, "elm.swallow.icon"))
{
Evas_Object* box = elm_box_add(obj);
{
elm_box_horizontal_set(box, EINA_TRUE);
asprintf(&c, DATA_DIR "assets/stock/15_0.png");
Evas_Object* ic = elm_icon_add(box);
{
elm_image_file_set(ic, c, NULL);
elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
evas_object_show(ic);
elm_box_pack_end(box, ic);
}
Evas_Object* lbl = elm_label_add(box);
{
elm_object_text_set(lbl, " vs. ");
elm_object_scale_set(lbl, 1.2);
evas_object_show(lbl);
elm_box_pack_end(box, lbl);
}
ic = elm_icon_add(box);
{
elm_image_file_set(ic, c, NULL);
elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
evas_object_show(ic);
elm_box_pack_end(box, ic);
}
evas_object_show(box);
}
return box;
}
return NULL;
}
static char*
replays_strings(void* data, Evas_Object* obj, const char* part)
{
long idx = data;
char* c;
// Check this is text for the part we're expecting
if (strcmp(part, "elm.text") == 0 &&
if (strcmp(part, "elm.text") == 0)
/* DQ after join */
(replays[idx].p1 != NULL && replays[idx].p2 != NULL))
{
char* c;
asprintf(&c, "%s (%s) Vs. %s (%s)",
replays[idx].p1, replays[idx].p1code,
replays[idx].p2, replays[idx].p2code);
if (replays[idx].p1 != NULL && replays[idx].p2 != NULL)
{
asprintf(&c, "%s (%s) Vs. %s (%s)",
replays[idx].p1, replays[idx].p1code,
replays[idx].p2, replays[idx].p2code);
return c;
}
else if (replays[idx].p1 == NULL || replays[idx].p2 == NULL)
printf("[Replay Warning] %s is a incomplete replay. Good idea to delete it.\n",
replays[idx].filename);
}
else if (strcmp(part, "elm.text.sub") == 0)
{
asprintf(&c, "%s * (3-0)", gameend2str(replays[idx].game_state));
return c;
}
else if (replays[idx].p1 == NULL || replays[idx].p2 == NULL)
printf("[Replay Warning] %s is a incomplete replay. Good idea to delete it.\n",
replays[idx].filename);
else
return NULL;
}
@ -243,16 +293,69 @@ _item_select_cb(void *data, Evas_Object *obj, void *event_info)
free(jason);
}
static void
_dd_exp(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
long idx = (long)data;
Elm_Object_Item *glit = event_info;
Evas_Object* gl = elm_object_item_widget_get(glit);
Elm_Genlist_Item_Class* _itc_sub = elm_genlist_item_class_new();
_itc_sub->item_style = "default";
_itc_sub->func.text_get = NULL;
_itc_sub->func.content_get = NULL;
_itc_sub->func.state_get = NULL;
_itc_sub->func.del = NULL;
for (int i = 0; i < 2; ++i)
{
elm_genlist_item_append(gl, _itc_sub,
(void *)(long) (idx)/* item data */,
glit/* parent */,
ELM_GENLIST_ITEM_NONE, NULL/* func */,
NULL/* func data */);
}
}
static void
_dd_con(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_subitems_clear(glit);
}
static void
_dd_exp_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_expanded_set(glit, EINA_TRUE);
}
static void
_dd_con_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_expanded_set(glit, EINA_FALSE);
}
Evas_Object*
tab_replays_setup(Evas_Object* parent)
{
tab_replays = elm_genlist_add(parent);
evas_object_smart_callback_add(tab_replays, "expand,request", _dd_exp_req, tab_replays);
evas_object_smart_callback_add(tab_replays, "contract,request", _dd_con_req, tab_replays);
evas_object_smart_callback_add(tab_replays, "expanded", _dd_exp, tab_replays);
evas_object_smart_callback_add(tab_replays, "contracted", _dd_con, tab_replays);
elm_genlist_tree_effect_enabled_set(tab_replays, EINA_TRUE);
elm_genlist_homogeneous_set(tab_replays, EINA_TRUE);
evas_object_resize(tab_replays, 40, 40);
Elm_Genlist_Item_Class *_itc = elm_genlist_item_class_new();
_itc->item_style = "double_label";
_itc->func.text_get = replays_strings;
_itc->func.content_get = NULL;
_itc->func.content_get = replays_content;
_itc->func.state_get = NULL;
_itc->func.del = NULL;
@ -260,12 +363,12 @@ tab_replays_setup(Evas_Object* parent)
for (int i = 0; i < replays_len; ++i)
{
elm_genlist_item_append(tab_replays,
Evas_Object* root = elm_genlist_item_append(tab_replays,
_itc,
i, // Item data
NULL, // Parent item for trees, NULL if none
ELM_GENLIST_ITEM_NONE, // Item type; this is the common one
_item_select_cb, // Callback on selection of the item
ELM_GENLIST_ITEM_TREE, // Item type; this is the common one
NULL, // Callback on selection of the item
(long)i // Data for that callback function
);
}