diff options
Diffstat (limited to 'ClientHamr/GuiLua/GuiLua.c')
-rw-r--r-- | ClientHamr/GuiLua/GuiLua.c | 89 |
1 files changed, 80 insertions, 9 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c index 3854bdd..b42df1b 100644 --- a/ClientHamr/GuiLua/GuiLua.c +++ b/ClientHamr/GuiLua/GuiLua.c | |||
@@ -216,6 +216,9 @@ void loggingStartup(globals *ourGlobals) | |||
216 | eina_log_level_set(EINA_LOG_LEVEL_DBG); | 216 | eina_log_level_set(EINA_LOG_LEVEL_DBG); |
217 | eina_log_domain_level_set("GuiLua", EINA_LOG_LEVEL_DBG); | 217 | eina_log_domain_level_set("GuiLua", EINA_LOG_LEVEL_DBG); |
218 | eina_log_print_cb_set(_ggg_log_print_cb, stderr); | 218 | eina_log_print_cb_set(_ggg_log_print_cb, stderr); |
219 | |||
220 | // Shut up the excess debugging shit from EFL. | ||
221 | eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); | ||
219 | } | 222 | } |
220 | 223 | ||
221 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) | 224 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) |
@@ -527,32 +530,94 @@ static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info | |||
527 | { | 530 | { |
528 | // globals *ourGlobals = data; | 531 | // globals *ourGlobals = data; |
529 | 532 | ||
530 | // TODO - skang.quit() should do this to. | ||
531 | // Tell the main loop to stop, which it will, eventually. | 533 | // Tell the main loop to stop, which it will, eventually. |
532 | elm_exit(); | 534 | elm_exit(); |
533 | } | 535 | } |
534 | 536 | ||
537 | |||
538 | struct widget | ||
539 | { | ||
540 | Evas_Object *widget; | ||
541 | char *label, *look, *action, *help; | ||
542 | // foreground / background colour | ||
543 | // thing | ||
544 | // types {} | ||
545 | // skangCoord x, y, w, h | ||
546 | }; | ||
547 | |||
548 | /* Sooo, how to do this - | ||
549 | |||
550 | widget has to be a light userdata | ||
551 | The rest can be Lua sub things? Each with a C function to update the widget. | ||
552 | |||
553 | win.quitter.look | ||
554 | |||
555 | win.quitter:colour(1,2,3,4) -> win.quitter.colour(win.quitter, 1,2,3,4) -> __call(win.quitter.colour, win.quitter, 1,2,3,4) -> skang.colour(win.quitter.colour, win.quitter, 1,2,3,4) | ||
556 | win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Thing and Mum. We eventually want to call skang.colour() though. | ||
557 | |||
558 | */ | ||
559 | |||
560 | static int widget(lua_State *L) | ||
561 | { | ||
562 | globals *ourGlobals; | ||
563 | Evas_Object *bt; | ||
564 | char *type = "label"; | ||
565 | char *title = ":"; | ||
566 | int x = 1, y = 1, w = WIDTH/3, h = HEIGHT/3; | ||
567 | |||
568 | lua_getfield(L, LUA_REGISTRYINDEX, globName); | ||
569 | ourGlobals = lua_touserdata(L, -1); | ||
570 | lua_pop(L, 1); | ||
571 | |||
572 | pull_lua(L, 1, "$type $title %x %y %w %h", &type, &title, &x, &y, &w, &h); | ||
573 | |||
574 | // Poor mans introspection, until I write real introspection into EFL. | ||
575 | if (strcmp(type, "button") == 0) | ||
576 | { | ||
577 | bt = elm_button_add(ourGlobals->win); | ||
578 | elm_object_text_set(bt, title); | ||
579 | evas_object_smart_callback_add(bt, "clicked", _on_done, ourGlobals); | ||
580 | evas_object_resize(bt, w, h); | ||
581 | evas_object_move(bt, x, y); | ||
582 | evas_object_show(bt); | ||
583 | lua_pushlightuserdata(L, &bt); | ||
584 | return 1; | ||
585 | } | ||
586 | |||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | static int colour(lua_State *L) | ||
591 | { | ||
592 | // TODO - This is just a stub for now. | ||
593 | |||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | |||
535 | static int window(lua_State *L) | 598 | static int window(lua_State *L) |
536 | { | 599 | { |
537 | globals *ourGlobals; | 600 | globals *ourGlobals; |
538 | char *title = NULL; | 601 | char *name = "GuiLua"; |
602 | char *title = "GuiLua test harness"; | ||
539 | int w = WIDTH, h = HEIGHT; | 603 | int w = WIDTH, h = HEIGHT; |
540 | 604 | ||
541 | lua_getfield(L, LUA_REGISTRYINDEX, globName); | 605 | lua_getfield(L, LUA_REGISTRYINDEX, globName); |
542 | ourGlobals = lua_touserdata(L, -1); | 606 | ourGlobals = lua_touserdata(L, -1); |
543 | lua_pop(L, 1); | 607 | lua_pop(L, 1); |
544 | 608 | ||
545 | if (pull_lua(L, 1, "%w %h $title", &w, &h, &title) > 0) | 609 | pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); |
546 | PI("Setting window to %d %d %s", w, h, title); | 610 | PI("Setting window to %d %d %s", w, h, title); |
547 | else | ||
548 | title = "GuiLua test harness"; | ||
549 | 611 | ||
550 | if ((ourGlobals->win = elm_win_util_standard_add("GuiLua", title))) | 612 | if ((ourGlobals->win = elm_win_util_standard_add(name, title))) |
551 | { | 613 | { |
552 | evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals); | 614 | evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals); |
553 | evas_object_resize(ourGlobals->win, w, h); | 615 | evas_object_resize(ourGlobals->win, w, h); |
554 | evas_object_move(ourGlobals->win, 0, 0); | 616 | evas_object_move(ourGlobals->win, 0, 0); |
555 | evas_object_show(ourGlobals->win); | 617 | evas_object_show(ourGlobals->win); |
618 | |||
619 | lua_pushlightuserdata(L, &ourGlobals->win); | ||
620 | return 1; | ||
556 | } | 621 | } |
557 | 622 | ||
558 | return 0; | 623 | return 0; |
@@ -600,6 +665,10 @@ static int closeWindow(lua_State *L) | |||
600 | ourGlobals = lua_touserdata(L, -1); | 665 | ourGlobals = lua_touserdata(L, -1); |
601 | lua_pop(L, 1); | 666 | lua_pop(L, 1); |
602 | 667 | ||
668 | // This causes EO to spill lots of meaningless error messages. | ||
669 | // if (bt) | ||
670 | // evas_object_del(bt); | ||
671 | |||
603 | if (ourGlobals->win) | 672 | if (ourGlobals->win) |
604 | evas_object_del(ourGlobals->win); | 673 | evas_object_del(ourGlobals->win); |
605 | 674 | ||
@@ -665,8 +734,10 @@ int luaopen_libGuiLua(lua_State *L) | |||
665 | 734 | ||
666 | // Define our functions. | 735 | // Define our functions. |
667 | //thingasm{'window', 'The size and title of the application Frame.', window, 'x,y,name', acl='GGG'} | 736 | //thingasm{'window', 'The size and title of the application Frame.', window, 'x,y,name', acl='GGG'} |
668 | push_lua(L, "@ ( { = $ $ & $ $acl } )", skang, THINGASM, skang, "window", "Opens our window.", window, "number,number,string", "GGG", 0); | 737 | push_lua(L, "@ ( { = $ $ & $ $acl } )", skang, THINGASM, skang, "Cwindow", "Opens our window.", window, "number,number,string", "GGG", 0); |
669 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "clear", "The current skin is cleared of all widgets", clear, 0); | 738 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "clear", "The current skin is cleared of all widgets.", clear, 0); |
739 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "widget", "Create a widget.", widget, 0); | ||
740 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "Colour", "Change widget colours.", colour, 0); | ||
670 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0); | 741 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0); |
671 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "quit", "Quit, exit, remove thyself.", quit, 0); | 742 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "quit", "Quit, exit, remove thyself.", quit, 0); |
672 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "closeWindow", "Closes our window.", closeWindow, 0); | 743 | push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "closeWindow", "Closes our window.", closeWindow, 0); |