Skip to content

Instantly share code, notes, and snippets.

@dprilutskii
Last active February 25, 2020 13:48
Show Gist options
  • Save dprilutskii/36ae60262e27152413f4e28289a46c94 to your computer and use it in GitHub Desktop.
Save dprilutskii/36ae60262e27152413f4e28289a46c94 to your computer and use it in GitHub Desktop.
Tizen UI update example.
#include <Elementary.h>
struct progresses
{
Evas_Object *moving;
Evas_Object *status;
};
struct progress_with_value
{
Evas_Object *progress;
double value;
};
static void* progress_setter_async(void *data)
{
struct progress_with_value *pv = data;
elm_progressbar_value_set(pv->progress, pv->value);
return NULL;
}
static void some_job_cb(void *data, Ecore_Thread *thread)
{
int i=0;
struct progresses *p = data;
struct progress_with_value pv_moving = {p->moving, 0.0};
struct progress_with_value pv_status = {p->status, 0.0};
ecore_main_loop_thread_safe_call_sync(progress_setter_async, &pv_moving);
ecore_main_loop_thread_safe_call_sync(progress_setter_async, &pv_status);
while (i++<=10)
{
usleep(200000);
pv_moving.value = i * 0.1;
ecore_main_loop_thread_safe_call_sync(progress_setter_async, &pv_moving);
}
pv_status.value = 1.0;
ecore_main_loop_thread_safe_call_sync(progress_setter_async, &pv_status);
}
static void on_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
ecore_thread_run(some_job_cb, NULL, NULL, data);
}
int main(int argc, char* argv[])
{
Evas_Object *win;
elm_init(argc, argv);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_add(NULL, "sample", ELM_WIN_BASIC);
elm_win_title_set(win, "Sample");
elm_win_autodel_set(win, EINA_TRUE);
evas_object_resize(win, 800, 600);
evas_object_show(win);
Evas_Object *box = elm_box_add(win);
evas_object_resize(box, 800, 600);
evas_object_show(box);
Evas_Object *btn = elm_button_add(win);
elm_object_text_set(btn, "Start Progress 0.0 to 1.0");
evas_object_show(btn);
elm_box_pack_end(box, btn);
Evas_Object *wheel = elm_progressbar_add(win);
elm_object_style_set(wheel, "wheel");
elm_progressbar_pulse_set(wheel, EINA_TRUE);
elm_progressbar_pulse(wheel, EINA_TRUE);
evas_object_show(wheel);
elm_box_pack_end(box, wheel);
struct progresses p;
p.moving = elm_progressbar_add(win);
p.status = elm_progressbar_add(win);
evas_object_show(p.moving);
evas_object_show(p.status);
evas_object_size_hint_align_set(p.moving, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_align_set(p.status, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(box, p.moving);
elm_box_pack_end(box, p.status);
evas_object_smart_callback_add(btn, "clicked", on_clicked_cb, &p);
elm_run();
elm_shutdown();
return 0;
}
@dprilutskii
Copy link
Author

dprilutskii commented Feb 25, 2020

EFL UI bascially works on main loop with only one thread. So EFL system can't draw UI until you finish your some job in your event function. You can make another thread for your job and start thread in the event function. But use ecore idle functions for using eext_circle_object_value_set. Most EFL and tizen function must be used in main thread. So run your job in another thread and request progress value setter to main thread with ecore main loop functions.

EFL Ecore supply sync and async function for request job to main loop. ecore_main_loop_thread_safe_call_async and ecore_main_loop_thread_safe_call_sync can be used instead of ecore_idle functions.

So here is simple example with Elementary progresses. I don't use eext functions in this source but you can refer elm_progressbar_value_set instead of eext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment