#endif
using namespace scl;
-int iNumCreate = 0;
-
extern void mouse_press(void *data, Evas *e, Evas_Object *object, void *event_info);
extern void mouse_release(void *data, Evas *e, Evas_Object *object, void *event_info);
extern void mouse_move(void *data, Evas *e, Evas_Object *object, void *event_info);
+static std::map<std::string, SclNinePatchInfo> _nine_patch_map;
+
/**
* Constructor
*/
return image_ob;
}
+static sclboolean check_nine_patch_png_file(const char *image_path)
+{
+ sclboolean found = FALSE;
+ for (sclint loop = strlen(image_path);!found && loop > 0;loop--) {
+ if (image_path[loop] == '.') {
+ found = TRUE;
+ if (loop >= 2) { // for checking prefix ".#"
+ if (strcasecmp(image_path + loop - 2, ".#.png") == 0) {
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+SclNinePatchInfo get_nine_patch_info_from_png_file(Evas_Object *image_data, sclint w, sclint h)
+{
+ /* FIXME : Assuming we're dealing with 32bit image, need to check if there's any other cases */
+ SclNinePatchInfo ret = {0};
+ unsigned int *data = (unsigned int*)evas_object_image_data_get(image_data, EINA_FALSE);
+ if (data) {
+ int x, y;
+ sclboolean found;
+ found = FALSE;
+ for (x = 0;x < w && !found;x++) {
+ if (data[x] > 0) {
+ found = TRUE;
+ ret.left = x;
+ }
+ }
+ found = FALSE;
+ for (x = w - 1;x >= 0 && !found;x--) {
+ if (data[x] > 0) {
+ found = TRUE;
+ ret.right = w - (x + 1);
+ }
+ }
+ found = FALSE;
+ for (y = 0;y < h && !found;y++) {
+ if (data[y * w] > 0) {
+ found = TRUE;
+ ret.top = y;
+ }
+ }
+ found = FALSE;
+ for (y = h - 1;y >= 0 && !found;y--) {
+ if (data[y * w] > 0) {
+ found = TRUE;
+ ret.bottom = h - (y + 1);
+ }
+ }
+ }
+ return ret;
+}
extern sclint magnifierx, magnifiery;
void
int image_height = 0;
evas_object_image_file_set(image_object, image_path, NULL);
evas_object_image_size_get(image_object, &image_width, &image_height);
- if (cachedinfo) {
+
+ sclboolean is_nine_patch_png = check_nine_patch_png_file(image_path);
+ if (is_nine_patch_png) {
+ std::map<std::string, SclNinePatchInfo>::iterator it = _nine_patch_map.find(image_path);
+ if (it != _nine_patch_map.end()) {
+ evas_object_image_border_set(image_object,
+ (*it).second.left, (*it).second.right, (*it).second.top, (*it).second.bottom);
+ } else {
+ SclNinePatchInfo info = get_nine_patch_info_from_png_file(image_object, image_width, image_height);
+ evas_object_image_border_set(image_object, info.left, info.right, info.top, info.bottom);
+ _nine_patch_map[std::string(image_path)] = info;
+ }
+ } else if (cachedinfo) {
evas_object_image_border_set(image_object,
cachedinfo->nine_patch_left,
cachedinfo->nine_patch_right,
} else {
evas_object_move(image_object, dest_x, dest_y);
if (dest_width > 0 && dest_height > 0) {
- evas_object_image_fill_set(image_object, 0, 0, dest_width, dest_height);
+ if (is_nine_patch_png) {
+ evas_object_image_fill_set(image_object, -1, -1, dest_width + 2, dest_height + 2);
+ } else {
+ evas_object_image_fill_set(image_object, 0, 0, dest_width, dest_height);
+ }
evas_object_resize(image_object, dest_width, dest_height);
}
}
{
}
-
/**
* Draws the given text on cairo-surface
*/