*
* Signals that you can add callbacks for are:
*
- * clicked - This is called when a user has clicked the image
- *
+ * - clicked: This is called when a user has clicked the image
+ * - drop: Something has been dropped on the image
*/
typedef struct _Widget_Data Widget_Data;
* @param file The path to file that will be used as image
* @param group The group that the image belongs in edje file
*
- * @return (1 = sucess, 0 = error)
+ * @return (1 = success, 0 = error)
*
* @ingroup Image
*/
_sizing_eval(obj);
}
+/**
+ * Gets the current size of the image.
+ *
+ * Either width or height (or both) may be NULL.
+ *
+ * On error, neither w or h will be written too.
+ *
+ * @param obj The image object.
+ * @param w Pointer to store width, or NULL.
+ * @param h Pointer to store height, or NULL.
+ */
EAPI void
elm_image_object_size_get(const Evas_Object *obj, int *w, int *h)
{
if (!wd) return;
_els_smart_icon_orient_set(wd->img, orient);
}
+
+/**
+ * Make the image 'editable'.
+ *
+ * This means the image is a valid drag target for drag and drop, and can be
+ * cut or pasted too.
+ *
+ * @param obj Image object.
+ * @param set Turn on or off editability.
+ */
+EAPI void
+elm_image_editable_set(Evas_Object *obj, Eina_Bool set)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ if (!wd) return;;
+ _els_smart_icon_edit_set(wd->img, set, obj);
+}
+
+
+/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
unsigned char scale_down : 1;
unsigned char preloading : 1;
unsigned char show : 1;
+ unsigned char edit : 1;
};
/* local subsystem functions */
static void _els_smart_icon_flip_horizontal(Smart_Data *sd);
static void _els_smart_icon_flip_vertical(Smart_Data *sd);
static void _els_smart_icon_rotate_180(Smart_Data *sd);
+static Eina_Bool _els_smart_icon_dropcb(void *,Evas_Object *, Elm_Drop_Data *);
/* local subsystem globals */
static Evas_Smart *_e_smart = NULL;
_els_smart_icon_object_get(Evas_Object *obj)
{
Smart_Data *sd;
+
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL;
return sd->obj;
void
_els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
{
- Smart_Data *sd;
- Evas_Object *tmp;
- unsigned int *data, *data2, *to, *from;
- int x, y, w, hw, iw, ih;
- const char *file, *key;
+ Smart_Data *sd;
+ Evas_Object *tmp;
+ unsigned int *data, *data2, *to, *from;
+ int x, y, w, hw, iw, ih;
+ const char *file, *key;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
_smart_reconfigure(sd);
}
+/**
+ * Turns on editing through drag and drop and copy and paste.
+ */
+void
+_els_smart_icon_edit_set(Evas_Object *obj, Eina_Bool edit, Evas_Object *parent)
+{
+ Smart_Data *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ if (!sd) return;
+
+ if (strcmp(evas_object_type_get(sd->obj), "edje")== 0)
+ {
+ printf("No editing edje objects yet (ever)\n");
+ return;
+ }
+
+ /* Unfortunately eina bool is not a bool, but a char */
+ edit = !!edit;
+ if (edit == sd->edit) return;
+
+ sd->edit = edit;
+
+ if (sd->edit)
+ {
+ elm_drop_target_add(obj, ELM_SEL_FORMAT_IMAGE, _els_smart_icon_dropcb,
+ parent);
+ }
+ else
+ {
+ elm_drop_target_del(obj);
+ }
+
+}
+
/* local subsystem globals */
static void
_smart_reconfigure(Smart_Data *sd)
{
- int iw, ih;
Evas_Coord x, y, w, h;
if (!sd->obj) return;
}
else
{
- iw = 0;
- ih = 0;
+ int iw = 0, ih = 0;
+
evas_object_image_size_get(sd->obj, &iw, &ih);
iw = ((double)iw) * sd->scale;
Smart_Data *sd = data;
sd->preloading = 0;
- if(sd->show)
+ if (sd->show)
evas_object_show(sd->obj);
}
sd->scale = 1.0;
evas_object_smart_member_add(sd->obj, obj);
evas_object_smart_data_set(obj, sd);
- evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED, _preloaded, sd);
+ evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
+ _preloaded, sd);
}
static void
sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->show = 1;
- if(!sd->preloading)
- evas_object_show(sd->obj);
+ if (!sd->preloading)
+ evas_object_show(sd->obj);
}
static void
_smart_reconfigure(sd);
}
+static Eina_Bool
+_els_smart_icon_dropcb(void *elmobj,Evas_Object *obj, Elm_Drop_Data *drop)
+{
+ _els_smart_icon_file_key_set(obj, drop->data, NULL);
+ evas_object_smart_callback_call(elmobj, "drop", drop->data);
+
+ return EINA_TRUE;
+}
+/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/