if (!canvas)
return NULL;
- evas_object_image_colorspace_set(canvas, EVAS_COLORSPACE_ARGB8888);
- evas_object_image_alpha_set(canvas, EINA_TRUE);
+ evas_object_image_content_hint_set(canvas, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
+// evas_object_image_colorspace_set(canvas, EVAS_COLORSPACE_ARGB8888);
+// evas_object_image_alpha_set(canvas, EINA_TRUE);
evas_object_move(canvas, 0, 0);
return canvas;
}
{
int w;
int h;
+ Evas_Native_Surface surface;
switch (livebox_pd_type(handle)) {
case PD_TYPE_BUFFER:
- case PD_TYPE_PIXMAP:
evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888);
evas_object_image_alpha_set(image, EINA_TRUE);
evas_object_size_hint_max_set(image, w, h);
}
break;
+ case PD_TYPE_PIXMAP:
+ h = w = 0;
+ livebox_get_pdsize(handle, &w, &h);
+ if (w <= 0 || h <= 0)
+ break;
+
+ DbgPrint("Update: %dx%d\n", w, h);
+ surface.version = EVAS_NATIVE_SURFACE_VERSION;
+ surface.type = EVAS_NATIVE_SURFACE_X11;
+ surface.data.x11.pixmap = livebox_pd_pixmap(handle);
+ surface.data.x11.visual = NULL; //ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
+ evas_object_image_native_surface_set(image, &surface);
+
+ evas_object_image_size_set(image, w, h);
+ evas_object_resize(image, w, h);
+ evas_object_size_hint_max_set(image, w, h);
+ evas_object_show(image);
+ break;
case PD_TYPE_TEXT:
default:
break;
static int update_canvas(struct livebox *handle, Evas_Object *image)
{
+ Evas_Native_Surface surface;
const char *filename;
int w;
int h;
int type;
switch (livebox_lb_type(handle)) {
- case LB_TYPE_BUFFER:
case LB_TYPE_PIXMAP:
+ w = h = 0;
+ type = livebox_size(handle);
+ livebox_service_get_size(type, &w, &h);
+ if (w <= 0 || h <= 0)
+ break;
+
+ DbgPrint("Update: %dx%d\n", w, h);
+
+ surface.version = EVAS_NATIVE_SURFACE_VERSION;
+ surface.type = EVAS_NATIVE_SURFACE_X11;
+ surface.data.x11.pixmap = livebox_lb_pixmap(handle);
+ surface.data.x11.visual = NULL; //ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
+ evas_object_image_native_surface_set(image, &surface);
+
+ evas_object_image_size_set(image, w, h);
+ evas_object_resize(image, w, h);
+ evas_object_size_hint_min_set(image, w, h);
+ evas_object_size_hint_max_set(image, w, h);
+ evas_object_show(image);
+ break;
+ case LB_TYPE_BUFFER:
evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888);
evas_object_image_alpha_set(image, EINA_TRUE);
}
}
-static void exit_cb(void *data, Evas_Object *obj, void *event_info)
-{
- evas_object_del(obj);
-}
-
static void error_popup(Evas_Object *parent, struct livebox *handle, int ret)
{
- Evas_Object *popup;
- Evas_Object *button;
- char buffer[256];
-
- popup = elm_popup_add(parent);
- if (!popup)
- return;
-
- button = elm_button_add(parent);
- if (!button) {
- evas_object_del(popup);
- return;
- }
-
- elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
- elm_object_part_text_set(popup, "title,text", "Unable to load a livebox");
-
- elm_object_text_set(button, "Okay");
- elm_object_part_content_set(popup, "button2", button);
- evas_object_smart_callback_add(button, "clicked", exit_cb, popup);
-
- snprintf(buffer, sizeof(buffer) - 1,
- "%s(%s): %d", livebox_pkgname(handle), livebox_content(handle), ret);
- elm_object_part_text_set(popup, "default", buffer);
- evas_object_show(popup);
-
+ ErrPrint("Failed to add a box: %d\n", ret);
return;
}
{
Evas_Object *size_list;
char buffer[256];
- int sizes[7];
+ int sizes[NR_OF_SIZE_LIST];
int cnt;
int i;
int w;
int h;
size_list = elm_list_add(layout);
- cnt = 7;
+ cnt = sizeof(sizes) / sizeof(sizes[0]);
livebox_get_supported_sizes(handle, &cnt, sizes);
for (i = 0; i < cnt; i++) {
livebox_service_get_size(sizes[i], &w, &h);
rx = (double)(up->canvas.x - x) / (double)w;
ry = (double)(up->canvas.y - y) / (double)h;
+ DbgPrint("%dx%d - %dx%d, %lfx%lf\n", x, y, w, h, rx, ry);
livebox_content_event(handle, PD_MOUSE_UP, rx, ry);
}
evas_object_geometry_get(obj, &x, &y, &w, &h);
rx = (double)(down->canvas.x - x) / (double)w;
ry = (double)(down->canvas.y - y) / (double)h;
+ DbgPrint("%dx%d - %dx%d, %lfx%lf\n", x, y, w, h, rx, ry);
livebox_content_event(handle, PD_MOUSE_DOWN, rx, ry);
}
evas_object_geometry_get(obj, &x, &y, &w, &h);
rx = (double)(move->cur.canvas.x - x) / (double)w;
ry = (double)(move->cur.canvas.y - y) / (double)h;
+ DbgPrint("%dx%d - %dx%d, %lfx%lf\n", x, y, w, h, rx, ry);
livebox_content_event(handle, PD_MOUSE_MOVE, rx, ry);
}
static void lb_mouse_up_cb(void *handle, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Up *up = event_info;
+ Evas_Coord x, y, w, h;
struct event_data *evt;
evt = evas_object_data_del(obj, "evt");
if (!evt)
return;
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+
if (livebox_lb_type(handle) == LB_TYPE_PIXMAP || livebox_lb_type(handle) == LB_TYPE_BUFFER) {
- Evas_Coord x, y, w, h;
double rx, ry;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
rx = (double)(up->canvas.x - x) / (double)w;
ry = (double)(up->canvas.y - y) / (double)h;
livebox_content_event(handle, LB_MOUSE_UP, rx, ry);
- } else {
- Evas_Coord x, y, w, h;
- evas_object_geometry_get(obj, &x, &y, &w, &h);
+ }
- if (x < up->canvas.x && up->canvas.x < x + w) {
- if (y < up->canvas.y && up->canvas.y < y + h) {
- livebox_click(handle, (double)x / (double)w, (double)y / (double)h);
- }
+ if (x < up->canvas.x && up->canvas.x < x + w) {
+ if (y < up->canvas.y && up->canvas.y < y + h) {
+ livebox_click(handle, (double)x / (double)w, (double)y / (double)h);
}
}
}
}
+static int lb_update_begin(struct livebox *handle)
+{
+ DbgPrint("%p\n", handle);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "begin");
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+
+ return 0;
+}
+
+static int lb_update_end(struct livebox *handle)
+{
+ DbgPrint("%p\n", handle);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "end");
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+
+ return 0;
+}
+
+static int lb_update_text(struct livebox *handle, const char *id, const char *part, const char *data)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], part[%s], data[%s]\n", id, part, data);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s=%s", part, data);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+
+ return 0;
+}
+
+static int lb_update_image(struct livebox *handle, const char *id, const char *part, const char *data)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], part[%s], data[%s]\n", id, part, data);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s=%s", part, data);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+
+ return 0;
+}
+
+static int lb_update_script(struct livebox *handle, const char *id, const char *part, const char *file, const char *group)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], part[%s], file[%s], group[%s]\n", id, part, file, group);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s=%s, %s", part, file, group);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+
+ return 0;
+}
+
+static int lb_update_signal(struct livebox *handle, const char *id, const char *emission, const char *signal)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], emission[%s], signal[%s]\n", id, emission, signal);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s,%s", emission, signal);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+ return 0;
+}
+
+static int lb_update_drag(struct livebox *handle, const char *id, const char *part, double dx, double dy)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], part[%s], pos[%lfx%lf]\n", id, part, dx, dy);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s=%lfx%lf", part, dx, dy);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+ return 0;
+}
+
+static int lb_update_info_size(struct livebox *handle, const char *id, int w, int h)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], size[%dx%d]\n", id, w, h);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%dx%d", w, h);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+ return 0;
+}
+
+static int lb_update_info_category(struct livebox *handle, const char *id, const char *category)
+{
+ DbgPrint("%p\n", handle);
+ DbgPrint("id: [%s], category: [%s]\n", id, category);
+
+ Evas_Object *layout;
+ Evas_Object *list;
+ char buffer[80];
+
+ layout = (Evas_Object *)livebox_get_data(handle);
+ if (!layout) {
+ ErrPrint("Failed to get layout object\n");
+ return 0;
+ }
+
+ list = elm_object_part_content_get(layout, "livebox");
+ if (!list) {
+ ErrPrint("Failed to get list\n");
+ return 0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s=%s", id, category);
+ elm_list_item_prepend(list, buffer, NULL, NULL, NULL, NULL);
+ return 0;
+}
+
static void livebox_added_cb(struct livebox *handle, int ret, void *data)
{
Evas_Object *layout;
- Evas_Object *lb_image;
Evas_Object *btn;
int w;
int h;
DbgPrint("%s - %d\n", livebox_pkgname(handle), ret);
if (ret != 0) {
- error_popup(data, handle, ret);
+ error_popup(main_get_window(), handle, ret);
return;
}
return;
}
- lb_image = create_canvas(layout);
- if (!lb_image) {
- ErrPrint("Failed to create a canvas\n");
- evas_object_del(layout);
- return;
- }
+ if (livebox_lb_type(handle) == LB_TYPE_TEXT) {
+ Evas_Object *list;
+ static struct livebox_script_operators ops = {
+ .update_begin = lb_update_begin,
+ .update_end = lb_update_end,
+ .update_text = lb_update_text,
+ .update_image = lb_update_image,
+ .update_script = lb_update_script,
+ .update_signal = lb_update_signal,
+ .update_drag = lb_update_drag,
+ .update_info_size = lb_update_info_size,
+ .update_info_category = lb_update_info_category,
+ };
+
+ list = elm_list_add(layout);
+ if (!list) {
+ evas_object_del(layout);
+ return;
+ }
- evas_object_event_callback_add(lb_image, EVAS_CALLBACK_MOUSE_UP, lb_mouse_up_cb, handle);
- evas_object_event_callback_add(lb_image, EVAS_CALLBACK_MOUSE_DOWN, lb_mouse_down_cb, handle);
- evas_object_event_callback_add(lb_image, EVAS_CALLBACK_MOUSE_MOVE, lb_mouse_move_cb, handle);
+ (void)livebox_set_text_handler(handle, &ops);
+ elm_object_part_content_set(layout, "livebox", list);
+ elm_list_go(list);
+ } else {
+ Evas_Object *lb_image;
+ lb_image = create_canvas(layout);
+ if (!lb_image) {
+ ErrPrint("Failed to create a canvas\n");
+ evas_object_del(layout);
+ return;
+ }
- w = 0;
- h = 0;
- type = livebox_size(handle);
- if (type != LB_SIZE_TYPE_UNKNOWN) {
- livebox_service_get_size(type, &w, &h);
- DbgPrint("%dx%d\n", w, h);
- }
- evas_object_resize(lb_image, w, h);
- evas_object_show(lb_image);
+ evas_object_event_callback_add(lb_image, EVAS_CALLBACK_MOUSE_UP, lb_mouse_up_cb, handle);
+ evas_object_event_callback_add(lb_image, EVAS_CALLBACK_MOUSE_DOWN, lb_mouse_down_cb, handle);
+ evas_object_event_callback_add(lb_image, EVAS_CALLBACK_MOUSE_MOVE, lb_mouse_move_cb, handle);
+
+ w = 0;
+ h = 0;
+ type = livebox_size(handle);
+ if (type != LB_SIZE_TYPE_UNKNOWN) {
+ livebox_service_get_size(type, &w, &h);
+ DbgPrint("%dx%d\n", w, h);
+ }
+ evas_object_resize(lb_image, w, h);
+ evas_object_show(lb_image);
- update_canvas(handle, lb_image);
+ update_canvas(handle, lb_image);
- btn = elm_button_add(main_get_window());
- if (btn) {
- elm_object_text_set(btn, "Delete");
- evas_object_smart_callback_add(btn, "clicked", delete_btn_cb, handle);
- elm_object_part_content_set(layout, "delete,btn", btn);
- }
+ btn = elm_button_add(main_get_window());
+ if (btn) {
+ elm_object_text_set(btn, "Delete");
+ evas_object_smart_callback_add(btn, "clicked", delete_btn_cb, handle);
+ elm_object_part_content_set(layout, "delete,btn", btn);
+ }
- elm_object_part_content_set(layout, "livebox", lb_image);
+ elm_object_part_content_set(layout, "livebox", lb_image);
+ }
evas_object_resize(layout, 720, 1280);
evas_object_show(layout);