Efl.Ui.Grid.Static: Add implementation of simple grid

Summary:
Efl.Ui.Grid.Static uses virtual coordinates when arranging
its child objects. (like Evas.Grid)

Reviewers: jpeg

Subscribers: woohyun, cedric

Differential Revision: https://phab.enlightenment.org/D3989
This commit is contained in:
Jee-Yong Um 2016-06-10 13:29:33 +09:00 committed by Jean-Philippe Andre
parent 9fdf584d1a
commit c17b3d40a2
7 changed files with 152 additions and 57 deletions

View File

@ -118,6 +118,7 @@ elm_public_eolian_files = \
lib/elementary/efl_ui_box.eo \
lib/elementary/efl_ui_box_flow.eo \
lib/elementary/efl_ui_grid.eo \
lib/elementary/efl_ui_grid_static.eo \
lib/elementary/efl_ui_layout_internal_box.eo \
lib/elementary/efl_ui_layout_internal_table.eo \
lib/elementary/elm_button_internal_part.eo \
@ -677,6 +678,8 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/efl_ui_box_layout.c \
lib/elementary/efl_ui_box_private.h \
lib/elementary/efl_ui_grid.c \
lib/elementary/efl_ui_grid_static.c \
lib/elementary/efl_ui_grid_private.h \
$(NULL)

View File

@ -272,6 +272,7 @@ EAPI extern Elm_Version *elm_version;
# include <efl_ui_box.eo.h>
# include <efl_ui_box_flow.eo.h>
# include <efl_ui_grid.eo.h>
# include <efl_ui_grid_static.eo.h>
# include <efl_ui_image.eo.h>
# include <efl_ui_win.eo.h>
# include <efl_ui_win_standard.eo.h>

View File

@ -125,6 +125,7 @@ elm_eolian_files = \
efl_ui_box.eo \
efl_ui_box_flow.eo \
efl_ui_grid.eo \
efl_ui_grid_static.eo \
efl_ui_layout_internal_box.eo \
efl_ui_layout_internal_table.eo \
$(NULL)
@ -496,6 +497,7 @@ includesub_HEADERS = \
elm_win_standard.h \
elm_helper.h \
efl_ui_box_private.h \
efl_ui_grid_private.h \
$(NULL)
includesubdir = $(includedir)/elementary-@VMAJ@/
@ -627,6 +629,7 @@ libelementary_la_SOURCES = \
efl_ui_box_flow.c \
efl_ui_box_layout.c \
efl_ui_grid.c \
efl_ui_grid_static.c \
$(NULL)
libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@

View File

@ -1,65 +1,15 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include "efl_ui_grid_private.h"
#define EFL_PACK_LAYOUT_PROTECTED
#include <Elementary.h>
#include "elm_priv.h"
#include "efl_ui_grid.eo.h"
#include "../evas/canvas/evas_table.eo.h"
#define MY_CLASS EFL_UI_GRID_CLASS
#define MY_CLASS_NAME "Efl.Ui.Grid"
typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
typedef struct _Grid_Item Grid_Item;
typedef struct _Custom_Table_Data Custom_Table_Data;
static Eina_Bool _subobj_del_cb(void *data, const Eo_Event *event);
static void _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx *subobj);
#define GRID_ITEM_KEY "__grid_item"
struct _Grid_Item
{
EINA_INLIST;
Efl_Gfx *object;
int col_span, row_span;
int col, row;
Eina_Bool linear : 1;
};
struct _Efl_Ui_Grid_Data
{
const Eo_Class *layout_engine;
const void *layout_data;
Grid_Item *items;
int count;
int req_cols, req_rows; // requested - 0 means infinite
int last_col, last_row; // only used by linear apis
Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
struct {
double h, v;
Eina_Bool scalable: 1;
} pad;
Eina_Bool linear_recalc : 1;
};
struct _Grid_Item_Iterator
{
Eina_Iterator iterator;
Eina_Iterator *real_iterator;
Eina_List *list;
Efl_Ui_Grid *object;
};
struct _Custom_Table_Data
{
Efl_Ui_Grid *parent;
@ -69,12 +19,6 @@ struct _Custom_Table_Data
EO_CALLBACKS_ARRAY_DEFINE(subobj_callbacks,
{ EO_EVENT_DEL, _subobj_del_cb });
static inline Eina_Bool
_horiz(Efl_Orient dir)
{
return dir % 180 == EFL_ORIENT_RIGHT;
}
EOLIAN static Eina_Bool
_efl_ui_grid_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd EINA_UNUSED)
{

View File

@ -0,0 +1,62 @@
#ifndef EFL_UI_GRID_PRIVATE_H
#define EFL_UI_GRID_PRIVATE_H
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#define EFL_PACK_LAYOUT_PROTECTED
#include <Elementary.h>
#include "elm_priv.h"
typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
typedef struct _Grid_Item Grid_Item;
#define GRID_ITEM_KEY "__grid_item"
struct _Grid_Item
{
EINA_INLIST;
Efl_Gfx *object;
int col_span, row_span;
int col, row;
Eina_Bool linear : 1;
};
struct _Efl_Ui_Grid_Data
{
const Eo_Class *layout_engine;
const void *layout_data;
Grid_Item *items;
int count;
int req_cols, req_rows; // requested - 0 means infinite
int last_col, last_row; // only used by linear apis
Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
struct {
double h, v;
Eina_Bool scalable: 1;
} pad;
Eina_Bool linear_recalc : 1;
};
struct _Grid_Item_Iterator
{
Eina_Iterator iterator;
Eina_Iterator *real_iterator;
Eina_List *list;
Efl_Ui_Grid *object;
};
static inline Eina_Bool
_horiz(Efl_Orient dir)
{
return dir % 180 == EFL_ORIENT_RIGHT;
}
#endif

View File

@ -0,0 +1,74 @@
#include "efl_ui_grid_private.h"
#define MY_CLASS EFL_UI_GRID_STATIC_CLASS
#define MY_CLASS_NAME "Efl.Ui.Grid.Static"
EOLIAN static Eo *
_efl_ui_grid_static_eo_base_constructor(Eo *obj, void *pd EINA_UNUSED)
{
Efl_Ui_Grid_Data *gd;
obj = eo_constructor(eo_super(obj, MY_CLASS));
evas_obj_type_set(obj, MY_CLASS_NAME);
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER);
gd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
gd->layout_engine = MY_CLASS;
gd->req_cols = 100;
gd->req_rows = 100;
return obj;
}
EOLIAN static void
_efl_ui_grid_static_efl_pack_layout_layout_do(Eo_Class *klass EINA_UNUSED,
void *_pd EINA_UNUSED,
Eo *obj, const void *data EINA_UNUSED)
{
Efl_Ui_Grid_Data *gd;
Grid_Item *gi;
Evas *e;
Evas_Coord x, y, w, h;
long long xl, yl, wl, hl, vwl, vhl;
Eina_Bool mirror;
gd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
if (!gd->items) return;
e = evas_common_evas_get(obj);
eo_event_freeze(e);
efl_gfx_position_get(obj, &x, &y);
efl_gfx_size_get(obj, &w, &h);
xl = x;
yl = y;
wl = w;
hl = h;
mirror = elm_widget_mirrored_get(obj);
vwl = gd->req_cols;
vhl = gd->req_rows;
EINA_INLIST_FOREACH(gd->items, gi)
{
long long x1, y1, x2, y2;
if (!mirror)
{
x1 = xl + ((wl * (long long)gi->col) / vwl);
x2 = xl + ((wl * (long long)(gi->col + gi->col_span)) / vwl);
}
else
{
x1 = xl + ((wl * (vwl - (long long)(gi->col + gi->col_span))) / vwl);
x2 = xl + ((wl * (vwl - (long long)gi->col)) / vwl);
}
y1 = yl + ((hl * (long long)gi->row) / vhl);
y2 = yl + ((hl * (long long)(gi->row + gi->row_span)) / vhl);
efl_gfx_position_set(gi->object, x1, y1);
efl_gfx_size_set(gi->object, x2 - x1, y2 - y1);
}
eo_event_thaw(e);
}
#include "efl_ui_grid_static.eo.c"

View File

@ -0,0 +1,8 @@
class Efl.Ui.Grid.Static (Efl.Ui.Grid)
{
data: null;
implements {
Eo.Base.constructor;
Efl.Pack.Layout.layout_do;
}
}