summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_widget_image.h
blob: e5c45eb2251d9e4bf11fb1884512ed345c8c9919 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef EFL_UI_WIDGET_IMAGE_H
#define EFL_UI_WIDGET_IMAGE_H

#include "Elementary.h"

/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
 * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
 * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
 * IT AT RUNTIME.
 */

typedef enum
  {
     EFL_UI_IMAGE_PRELOAD_ENABLED,
     EFL_UI_IMAGE_PRELOADING,
     EFL_UI_IMAGE_PRELOADED,
     EFL_UI_IMAGE_PRELOAD_DISABLED
  } Efl_Ui_Image_Preload_Status;

/**
 * @addtogroup Widget
 * @{
 *
 * @section elm-image-class The Elementary Image Class
 *
 * This class defines a common interface for @b image objects having
 * an image as their basic graphics. This interface is so that one can
 * tune various properties of the image, like:
 * - smooth scaling,
 * - orientation,
 * - aspect ratio during resizes, etc.
 *
 * Image files may be set via memory buffers, image files, EET files
 * with image data or Edje files. On the last case (which is
 * exceptional), most of the properties cited above will @b not be
 * changeable anymore.
 */

/**
 * Base widget smart data extended with image instance data.
 */
typedef struct _Efl_Ui_Image_Data Efl_Ui_Image_Data;
struct _Efl_Ui_Image_Data
{
   Eo                   *self;
   Evas_Object          *hit_rect;
   Evas_Object          *img;
   Evas_Object          *prev_img;
   Ecore_Timer          *anim_timer;


   struct {
      Eo                *copier;
      Eina_Binbuf       *binbuf;
      const char        *key;
   } remote;

   double                scale;
   double                frame_duration;
   double                align_x, align_y;

   Evas_Coord            img_x, img_y, img_w, img_h;

   Eina_Size2D           load_size;
   int                   frame_count;
   int                   cur_frame;

   Elm_Image_Orient      image_orient; // to support EAPI
   Efl_Orient            orient;
   Efl_Flip              flip;

   struct {
      Ecore_Thread      *th;
      Eina_Stringshare  *file, *key; // only for file_get()
      void              *todo; // opaque internal
   } async;

   Efl_Ui_Image_Preload_Status preload_status;
   Efl_Image_Scale_Type scale_type;

   const char           *stdicon;

   Efl_Model            *model;
   Efl_Future           *pfuture;
   Eina_Stringshare     *prop_con;
   Eina_Stringshare     *prop_key;

   struct {
      int       requested_size;
      Eina_Bool use : 1;
   } freedesktop;

   Eina_Bool             aspect_fixed : 1;
   Eina_Bool             fill_inside : 1;
   Eina_Bool             no_scale : 1;
   Eina_Bool             smooth : 1;
   Eina_Bool             show : 1;
   Eina_Bool             edit : 1;
   Eina_Bool             edje : 1;
   Eina_Bool             anim : 1;
   Eina_Bool             play : 1;
   Eina_Bool             async_enable : 1;
   Eina_Bool             scale_up : 1;
   Eina_Bool             scale_down : 1;
   Eina_Bool             con_icon : 1;
   Eina_Bool             legacy_align : 1;
};

/**
 * @}
 */

#define EFL_UI_IMAGE_DATA_GET(o, sd) \
  Efl_Ui_Image_Data * sd = efl_data_scope_get(o, EFL_UI_IMAGE_CLASS)

#define EFL_UI_IMAGE_DATA_GET_OR_RETURN(o, ptr)         \
  EFL_UI_IMAGE_DATA_GET(o, ptr);                        \
  if (EINA_UNLIKELY(!ptr))                           \
    {                                                \
       CRI("No widget data for object %p (%s)",      \
           o, evas_object_type_get(o));              \
       return;                                       \
    }

#define EFL_UI_IMAGE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
  EFL_UI_IMAGE_DATA_GET(o, ptr);                         \
  if (EINA_UNLIKELY(!ptr))                            \
    {                                                 \
       CRI("No widget data for object %p (%s)",       \
           o, evas_object_type_get(o));               \
       return val;                                    \
    }

#define EFL_UI_IMAGE_CHECK(obj)                              \
  if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_IMAGE_CLASS))) \
    return

#endif