EFL UI は、基本的に 1 つのスレッドのみでメイン ループ上で動作します。
そのため、イベント関数でいくつかのジョブを完了するまで、EFL システムは UI を描画できません。
ジョブ用に別のスレッドを作成し、イベント関数でスレッドを開始できます。
ただし、eext_circle_object_value_set を使用するには、ecore アイドル関数を使用します。
ほとんどの EFL および tizen 関数は、メイン スレッドで使用する必要があります。
そのため、別のスレッドでジョブを実行し、ecore メイン ループ関数を使用してメイン スレッドに進捗値セッターを要求します。
EFL Ecore は、要求ジョブの同期および非同期関数をメイン ループに提供します。
ecore_main_loop_thread_safe_call_async
また
ecore_main_loop_thread_safe_call_sync
、ecore_idle 関数の代わりに使用できます。
ここでは、小学校の進行状況を示す簡単な例を示します。このソースでは eext 関数を使用していませんが、eext の代わりに elm_progressbar_value_set を参照できます。
#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;
}