EFL UI 基本上只在一个线程的主循环上工作。
因此,在您完成事件函数中的某些工作之前,EFL 系统无法绘制 UI。
您可以为您的工作创建另一个线程并在事件函数中启动线程。
但使用 ecore 空闲函数来使用 eext_circle_object_value_set。
大多数 EFL 和 tizen 函数必须在主线程中使用。
所以在另一个线程中运行你的工作,并使用ecore主循环函数向主线程请求进度值设置器。
EFL Ecore 为主循环的请求作业提供同步和异步功能。
ecore_main_loop_thread_safe_call_async
并且
ecore_main_loop_thread_safe_call_sync
可以用来代替 ecore_idle 函数。
所以这里是一个简单的例子,初级进度。我在此源中不使用 eext 函数,但您可以参考 elm_progressbar_value_set 而不是 eext。
#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;
}