summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_grid_item.c
blob: 29daea789621dd6715b3af76a1f6aabe2a7e9daa (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
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define EFL_ACCESS_PROTECTED
#define EFL_UI_WIDGET_PART_BG_PROTECTED

#include <Elementary.h>

#include "elm_priv.h"
#include "efl_ui_grid_item_private.h"

#define MY_CLASS      EFL_UI_GRID_ITEM_CLASS
#define MY_CLASS_PFX  efl_ui_grid_item

#define MY_CLASS_NAME "Efl.Ui.Grid_Item"

static void
_sizing_eval(Evas_Object *obj, Efl_Ui_Grid_Item_Data *pd)
{
   Evas_Coord minh = -1, minw = -1;
   Evas_Coord rest_w = 0, rest_h = 0;
   ELM_WIDGET_DATA_GET_OR_RETURN(pd->obj, wd);

   edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh,
                                        rest_w, rest_h);
   evas_object_size_hint_min_set(obj, minw, minh);

   pd->needs_size_calc = EINA_FALSE;
}

static void
_efl_ui_grid_item_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Grid_Item_Data *pd)
{
   if (pd->needs_size_calc) return;
   pd->needs_size_calc = EINA_TRUE;

   efl_canvas_group_change(obj);
}

EOLIAN static void
_efl_ui_grid_item_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Grid_Item_Data *pd)
{
   if (pd->needs_size_calc)
     {
        _sizing_eval(obj, pd);
        pd->needs_size_calc = EINA_FALSE;
     }
}

EOLIAN static Eo *
_efl_ui_grid_item_efl_object_constructor(Eo *obj, Efl_Ui_Grid_Item_Data *pd)
{
   pd->obj = obj;
   obj = efl_constructor(efl_super(obj, MY_CLASS));

   return obj;
}

EOLIAN static Efl_Object *
_efl_ui_grid_item_efl_object_finalize(Eo *obj, Efl_Ui_Grid_Item_Data *pd EINA_UNUSED)
{
   Eo *eo;
   eo = efl_finalize(efl_super(obj, MY_CLASS));
   ELM_WIDGET_DATA_GET_OR_RETURN(eo, wd, eo);

   return eo;
}

EOLIAN static void
_efl_ui_grid_item_efl_object_destructor(Eo *obj, Efl_Ui_Grid_Item_Data *pd EINA_UNUSED)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

   efl_destructor(efl_super(obj, MY_CLASS));
}

/* Internal EO APIs and hidden overrides */

#define EFL_UI_GRID_ITEM_EXTRA_OPS \
  ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_grid_item)

#include "efl_ui_grid_item.eo.c"