C Application

  • Users can develop in view widgets to create interactive and visually appealing user interfaces. Each view can be switched arbitrarily and can incorporate dynamic transition effects during switching.

  • What is displayed in the C application is organized nested Widget tree structure, which uses the view widget as the parent node. This structure includes container widgets such as windows and scrollable lists, as well as content display widgets like text, images, and canvases.

  • In addition to the default functions and effects, widgets within C application offer a high degree of customization. Users can set up custom timers for widgets and bind events to execute their defined operations. This flexibility enables the creation of highly dynamic and interactive user interfaces tailored to specific needs and requirements.

Create C Application Widget Tree

  • The root node of the widget tree can be obtained through the gui_obj_get_root() function, and a new widget tree is created based on this. The root node of the widget tree is an object of type gui_obj_t, representing the top-level container of the entire application.

  • Through functions for creating widgets, such as gui_img_create_from_mem(), various widgets can be created under the root node. Each widget is based on an object of type gui_obj_t, representing a specific user interface element.

  • The gui_obj_add_event_cb() function can add listening events and callback functions to each widget, such as clicks, scroll events, etc.

  • The gui_obj_create_timer() function can add a timer to each widget to perform certain operations within a specific time interval.

  • Use the GUI_INIT_APP_EXPORT macro to add the application's design function to the initialization function table. This function is called when the application starts to initialize and configure the widget tree.

void img_kb_cb(void *obj, gui_event_t *e)
{
    gui_obj_t *this = (gui_obj_t *)obj;
    const char *dev_name = e->indev_name ? (const char *)e->indev_name : "unknown";
    gui_log("Event test obj name = %s, e = 0x%x, indev = %s !\n", this->name, e->code, dev_name);
}

void img_tp_clicked_cb(void *obj, gui_event_t *e)
{
    GUI_UNUSED(obj);
    GUI_UNUSED(e);
    gui_log("Single clicked!\n");
}

void img_tp_double_clicked_cb(void *obj, gui_event_t *e)
{
    GUI_UNUSED(obj);
    GUI_UNUSED(e);
    gui_log("Double clicked!\n");
}

void img_tp_triple_clicked_cb(void *obj, gui_event_t *e)
{
    GUI_UNUSED(obj);
    GUI_UNUSED(e);
    gui_log("Triple clicked!\n");
}

void img_tp_long_pressed_cb(void *obj, gui_event_t *e)
{
    GUI_UNUSED(obj);
    GUI_UNUSED(e);
    gui_log("Touch long!\n");
}

void img_timer_cb(void *param)
{
    static float angle = 0;
    gui_img_t *img = (gui_img_t *)param;

    gui_img_rotation(img, angle++);

    gui_log("Handler[img] timer cb!\n");
}


static int app_init(void)
{
    void *addr = (void *)_actiger_blue;
    gui_dispdev_t *dc = gui_get_dc();

    gui_dirty_border_enable(true);

    // gui_img_t *img = gui_img_create_from_fs(gui_obj_get_root(),  "img_1_test", "/pc/example/application/screen_410_502/root_image/root/UI/cellular_menu_card.bin", 0, 0, 0, 0);
    gui_img_t *img = gui_img_create_from_mem(gui_obj_get_root(),  "img_test", addr, 0, 0, 0, 0);

    gui_img_set_focus(img, gui_img_get_width(img) / 2, gui_img_get_height(img) / 2);
    gui_img_rotation(img, 0.0f);
    gui_img_translate(img, dc->screen_width / 2, dc->screen_height / 2);

    gui_obj_add_event_cb(img, (gui_event_cb_t)img_tp_clicked_cb, GUI_EVENT_TOUCH_CLICKED, NULL);
    gui_obj_add_event_cb(img, (gui_event_cb_t)img_tp_double_clicked_cb, GUI_EVENT_TOUCH_DOUBLE_CLICKED,
                         NULL);
    gui_obj_add_event_cb(img, (gui_event_cb_t)img_tp_triple_clicked_cb, GUI_EVENT_TOUCH_TRIPLE_CLICKED,
                         NULL);
    gui_obj_add_event_cb(img, (gui_event_cb_t)img_tp_long_pressed_cb, GUI_EVENT_TOUCH_LONG, NULL);

    gui_obj_add_event_cb(img, (gui_event_cb_t)img_kb_cb, GUI_EVENT_KB_SHORT_PRESSED, NULL);
    gui_obj_focus_set(img);


    gui_obj_create_timer(&(img->base), 100, true, img_timer_cb);
    gui_obj_start_timer(&(img->base));


    return 0;
}

GUI_INIT_APP_EXPORT(app_init);

C Application Transition Effect

HoneyGUI Provides various transition effects, including hand sliding transition and non-hand animation transitions. This function requires to use view widgets. Please refer to View for details.