2012-05-03 15:41:26 -07:00
# ifndef ELM_WIDGET_LAYOUT_H
# define ELM_WIDGET_LAYOUT_H
# include "elm_widget_container.h"
2014-08-07 09:26:47 -07:00
/* 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 .
*/
2012-05-03 15:41:26 -07:00
/**
* @ addtogroup Widget
* @ {
*
* @ section elm - layout - class The Elementary Layout Class
*
* Elementary , besides having the @ ref Layout widget , exposes its
* foundation - - the Elementary Layout Class - - in order to create
* other widgets which are , basically , a certain layout with some more
* logic on top .
*
2012-05-31 16:02:54 -07:00
* The idea is to make the creation of that widgets as easy as possible ,
2012-05-03 15:41:26 -07:00
* factorizing code on this common base . For example , a button is a
* layout ( that looks like push button ) that happens to react on
* clicks and keyboard events in a special manner , calling its user
* back on those events . That ' s no surprise , then , that the @ ref
* Button implementation relies on # Elm_Layout_Smart_Class , if you go
* to check it .
*
* The Layout class inherits from
* # Elm_Container_Smart_Class . Container parts , here , map directly to
* Edje parts from the layout ' s Edje group . Besides that , there ' s a whole
* infrastructure around Edje files :
2012-05-31 16:02:54 -07:00
* - interfacing by signals ,
2012-05-03 15:41:26 -07:00
* - setting / retrieving text part values ,
* - dealing with table and box parts directly ,
* - etc .
*
* Take a look at # Elm_Layout_Smart_Class ' s ' virtual ' functions to
* understand the whole interface . Finally , layout objects will do
* < b > part aliasing < / b > for you , if you set it up properly . For that ,
* take a look at # Elm_Layout_Part_Alias_Description , where it ' s
* explained in detail .
*/
/**
* @ struct _Elm_Layout_Part_Alias_Description
*
* Elementary Layout - based widgets may declare part proxies , i . e . , aliases
* for real theme part names to expose to the API calls :
* - elm_layout_text_set ( )
* - elm_layout_text_get ( )
* - elm_layout_content_set ( )
* - elm_layout_content_get ( )
* - elm_layout_content_unset ( )
* and their equivalents . This list must be set on the
* @ c " _smart_set_user() " function of inheriting widgets , so that part
* aliasing is handled automatically for them .
*
* @ ingroup Widget
*/
struct _Elm_Layout_Part_Alias_Description
{
const char * alias ; /**< Alternate name for a given (real) part. Calls receiving this string as a part name will be translated to the string at _Elm_Layout_Part_Proxies_Description::real_part */
const char * real_part ; /**< Target part name for the alias set on @ref _Elm_Layout_Part_Proxies_Description::real_part. An example of usage would be @c "default" on that field, with @c "elm.content.swallow" on this one */
} ;
/**
2012-05-25 12:53:51 -07:00
* Base widget smart data extended with layout instance data .
2012-05-03 15:41:26 -07:00
*/
typedef struct _Elm_Layout_Smart_Data
{
2012-11-25 22:32:53 -08:00
Evas_Object * obj ; /* The object itself */
2012-05-03 15:41:26 -07:00
Eina_List * subs ; /**< List of Elm_Layout_Sub_Object_Data structs, to hold the actual sub objects */
Eina_List * edje_signals ;
Eina_List * parts_cursors ;
const char * klass , * group ;
2013-10-05 01:59:58 -07:00
int frozen ; /**< Layout freeze counter */
2012-05-03 15:41:26 -07:00
Eina_Bool needs_size_calc : 1 ;
2013-10-25 09:51:33 -07:00
Eina_Bool restricted_calc_w : 1 ;
Eina_Bool restricted_calc_h : 1 ;
2014-01-01 16:23:03 -08:00
Eina_Bool can_access : 1 ; /**< This is true when all text(including textblock) parts can be accessible by accessibility. */
2014-05-13 20:02:10 -07:00
Eina_Bool destructed_is : 1 ; /**< This flag indicates if Elm_Layout destructor was called */
[layout] support mirrored set for layout which is using elm_layout_file_set()
Summary: mirroed mode does not work, if layout uses elm_layout_file_set().
Test Plan:
the following is test code.
[test.edc]
collections {
group {
name: "layout/test";
parts {
part {
name: "bg";
type: RECT;
description {
state: "default" 0.0;
color: 255 255 0 100;
}
}
part {
name: "test.rect";
type: RECT;
description {
state: "default" 0.0;
color: 255 0 0 255;
rel1.to: bg;
rel1.relative: 0.2 0.1;
rel2.to: bg;
rel2.relative: 0.5 0.2;
}
}
} /* parts */
} /* group */
} /* collections */
[test.c]
//Compile with:
//gcc -g test.c -o test `pkg-config --cflags --libs elementary`
#include <Elementary.h>
#include <Ecore_X.h>
static void
_bt_click(void *data, Evas_Object *obj, void *event_info)
{
Eina_Bool mirrored;
Evas_Object *layout;
layout = data;
mirrored = elm_config_mirrored_get();
mirrored = !mirrored;
printf("mirred: %d\n", mirrored);
elm_config_mirrored_set(mirrored);
}
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Evas_Object *win, *box, *layout, *bt, *check;
char buf[PATH_MAX];
elm_app_info_set(elm_main, "elementary", "./test.edj");
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_add(NULL, "Layout", ELM_WIN_BASIC);
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
// Adding layout and filling it with widgets
layout = elm_layout_add(win);
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
snprintf(buf, sizeof(buf), "./test.edj");
elm_layout_file_set(layout, buf, "layout/test");
elm_box_pack_end(box, layout);
evas_object_show(layout);
bt = elm_button_add(win);
elm_object_text_set(bt, "mirrored");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "clicked", _bt_click, layout);
elm_box_pack_end(box, bt);
evas_object_show(bt);
check = elm_check_add(win);
elm_object_text_set(check, "test");
evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, check);
evas_object_show(check);
evas_object_resize(win, 500, 500);
evas_object_show(win);
elm_run();
elm_shutdown();
return 0;
}
ELM_MAIN()
Reviewers: seoz, raster, tasn, Hermet
Subscribers: seoz, cedric
Differential Revision: https://phab.enlightenment.org/D2142
2015-06-09 06:05:58 -07:00
Eina_Bool file_set : 1 ; /**< This flag indicates if Elm_Layout source file is set */
2012-05-03 15:41:26 -07:00
} Elm_Layout_Smart_Data ;
/**
* @ }
*/
2012-07-31 15:05:38 -07:00
# define ELM_LAYOUT_DATA_GET(o, sd) \
2014-06-03 03:35:28 -07:00
Elm_Layout_Smart_Data * sd = eo_data_scope_get ( o , ELM_LAYOUT_CLASS )
2012-07-31 15:05:38 -07:00
2014-01-15 10:33:40 -08:00
# define ELM_LAYOUT_CHECK(obj) \
2014-06-03 03:35:28 -07:00
if ( EINA_UNLIKELY ( ! eo_isa ( obj , ELM_LAYOUT_CLASS ) ) ) \
2012-07-31 15:05:38 -07:00
return
2012-05-03 15:41:26 -07:00
# endif