box_example_02.c

- Main Page
- Related Pages
- Topics
- Data Structures
- Files
- Examples

box_example_02.c
//Compile with:
//gcc -g box_example_02.c -o box_example_02 `pkg-config --cflags --libs elementary`
#include <Elementary.h>
typedef struct
{
Eina_List *transitions;
Evas_Object *box;
Evas_Object_Box_Layout last_layout;
} Transitions_Data;
static void
_add_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
Evas_Object *btn;
Eina_List *children;
Transitions_Data *tdata = data;
btn = elm_button_add(tdata->box);
elm_object_text_set(btn, "I do nothing");
children = (Eina_List *)elm_box_children_get(tdata->box);
if (children)
{
elm_box_pack_after(tdata->box, btn, (Evas_Object *)children->data);
eina_list_free(children);
}
else
elm_box_pack_end(tdata->box, btn);
evas_object_show(btn);
}
static void
_clear_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
Transitions_Data *tdata = data;
elm_box_clear(tdata->box);
}
static void
_unpack_cb(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
{
Transitions_Data *tdata = data;
elm_box_unpack(tdata->box, obj);
evas_object_move(obj, 0, 50);
evas_object_color_set(obj, 128, 64, 0, 128);
}
static void
_test_box_transition_change(void *data)
{
Transitions_Data *tdata = data;
Elm_Box_Transition *layout_data;
Evas_Object_Box_Layout next_layout;
if (!data) return;
next_layout = eina_list_data_get(tdata->transitions);
layout_data = elm_box_transition_new(2.0, tdata->last_layout,
NULL, NULL, next_layout, NULL, NULL,
_test_box_transition_change, tdata);
elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data,
elm_box_transition_free);
tdata->last_layout = next_layout;
tdata->transitions = eina_list_demote_list(tdata->transitions,
tdata->transitions);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win, *bigbox, *bx, *bt;
static Transitions_Data tdata = {
.transitions = NULL,
.box = NULL,
.last_layout = NULL
};
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("box-transition", "Box Transition");
elm_win_autodel_set(win, EINA_TRUE);
bigbox = elm_box_add(win);
evas_object_size_hint_weight_set(bigbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bigbox);
evas_object_show(bigbox);
bx = elm_box_add(win);
elm_box_horizontal_set(bx, EINA_TRUE);
elm_box_pack_end(bigbox, bx);
evas_object_show(bx);
bt = elm_button_add(win);
elm_object_text_set(bt, "Add");
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _add_cb, &tdata);
bt = elm_button_add(win);
elm_object_text_set(bt, "Clear");
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _clear_cb, &tdata);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bigbox, bx);
evas_object_show(bx);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 1");
evas_object_smart_callback_add(bt, "clicked", _unpack_cb, &tdata);
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);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 2");
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bt, 1.0, 0.5);
evas_object_smart_callback_add(bt, "clicked", _unpack_cb, &tdata);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 3");
evas_object_smart_callback_add(bt, "clicked", _unpack_cb, &tdata);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
tdata.box = bx;
tdata.last_layout = evas_object_box_layout_horizontal;
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_vertical);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_horizontal);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_stack);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_homogeneous_vertical);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_homogeneous_horizontal);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_flow_vertical);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_flow_horizontal);
tdata.transitions = eina_list_append(tdata.transitions,
evas_object_box_layout_stack);
elm_box_layout_set(bx, evas_object_box_layout_horizontal, NULL, NULL);
_test_box_transition_change(&tdata);
evas_object_resize(win, 300, 320);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition Evas_Common.h:297
EVAS_HINT_FILL
#define EVAS_HINT_FILL
Use with evas_object_size_hint_align_set(), evas_object_size_hint_align_get(), evas_object_size_hint_...
Definition Evas_Common.h:298
eina_list_demote_list
EINA_API Eina_List * eina_list_demote_list(Eina_List *list, Eina_List *move_list)
Moves the specified data to the tail of the list.
Definition eina_list.c:889
eina_list_append
EINA_API Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list.
Definition eina_list.c:584
eina_list_free
EINA_API Eina_List * eina_list_free(Eina_List *list)
Frees an entire list and all the nodes, ignoring the data contained.
Definition eina_list.c:823
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
elm_box_children_get
Eina_List * elm_box_children_get(const Elm_Box *obj)
Get a list of the objects packed into the box.
Definition elm_box_eo.legacy.c:51
elm_box_layout_transition
void elm_box_layout_transition(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data)
Special layout function that animates the transition from one layout to another.
Definition elm_box.c:514
elm_box_unpack
void elm_box_unpack(Elm_Box *obj, Efl_Canvas_Object *subobj)
Unpack a box item.
Definition elm_box_eo.legacy.c:69
elm_box_horizontal_set
void elm_box_horizontal_set(Elm_Box *obj, Eina_Bool horizontal)
Set the horizontal orientation.
Definition elm_box_eo.legacy.c:27
elm_box_pack_after
void elm_box_pack_after(Elm_Box *obj, Efl_Canvas_Object *subobj, Efl_Canvas_Object *after)
Adds an object to the box after the indicated object.
Definition elm_box_eo.legacy.c:75
elm_box_clear
void elm_box_clear(Elm_Box *obj)
Clear the box of all children.
Definition elm_box_eo.legacy.c:99
elm_box_add
Evas_Object * elm_box_add(Evas_Object *parent)
Add a new box to the parent.
Definition elm_box.c:363
elm_box_transition_new
Elm_Box_Transition * elm_box_transition_new(const double duration, Evas_Object_Box_Layout start_layout, void *start_layout_data, Ecore_Cb start_layout_free_data, Evas_Object_Box_Layout end_layout, void *end_layout_data, Ecore_Cb end_layout_free_data, Ecore_Cb transition_end_cb, void *transition_end_data)
Create a new Elm_Box_Transition to animate the switch of layouts.
Definition elm_box.c:549
elm_box_pack_end
void elm_box_pack_end(Elm_Box *obj, Efl_Canvas_Object *subobj)
Add an object at the end of the pack list.
Definition elm_box_eo.legacy.c:57
elm_box_layout_set
void elm_box_layout_set(Eo *obj, Evas_Object_Box_Layout cb, const void *data, Ecore_Cb free_data)
Set the layout defining function to be used by the box.
Definition elm_box.c:502
elm_box_transition_free
void elm_box_transition_free(void *data)
Free a Elm_Box_Transition instance created with elm_box_transition_new().
Definition elm_box.c:581
elm_button_add
Evas_Object * elm_button_add(Evas_Object *parent)
Add a new button to the parent's canvas.
Definition efl_ui_button.c:459
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition elm_general.h:556
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition elm_main.c:1380
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition elm_main.c:1357
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition elm_general.h:248
ELM_POLICY_QUIT
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition elm_general.h:227
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition efl_ui_win.c:9582
elm_win_resize_object_add
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition efl_ui_win.c:8997
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition efl_ui_win.c:6194
evas_object_box_layout_homogeneous_vertical
EVAS_API void evas_object_box_layout_homogeneous_vertical(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a homogeneous vertical box.
Definition evas_box_eo.legacy.c:153
evas_object_box_layout_flow_vertical
EVAS_API void evas_object_box_layout_flow_vertical(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a flow vertical box.
Definition evas_box_eo.legacy.c:51
evas_object_box_layout_homogeneous_horizontal
EVAS_API void evas_object_box_layout_homogeneous_horizontal(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a homogeneous horizontal box.
Definition evas_box_eo.legacy.c:123
evas_object_box_layout_vertical
EVAS_API void evas_object_box_layout_vertical(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a (basic) vertical box.
Definition evas_box_eo.legacy.c:39
evas_object_box_layout_flow_horizontal
EVAS_API void evas_object_box_layout_flow_horizontal(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a flow horizontal box.
Definition evas_box_eo.legacy.c:159
evas_object_box_layout_horizontal
EVAS_API void evas_object_box_layout_horizontal(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a (basic) horizontal box.
Definition evas_box_eo.legacy.c:33
evas_object_box_layout_stack
EVAS_API void evas_object_box_layout_stack(Evas_Box *obj, Evas_Object_Box_Data *priv, void *data)
Layout function which sets the box o to a stacking box.
Definition evas_box_eo.legacy.c:147
Evas_Object_Box_Layout
void(* Evas_Object_Box_Layout)(Evas_Object *o, Evas_Object_Box_Data *priv, void *user_data)
Function signature for an Evas box object layouting routine.
Definition Evas_Common.h:2726
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_color_set
EVAS_API void evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a)
Sets the general/main color of the given Evas object to the given one.
Definition evas_object_main.c:2024
evas_object_move
EVAS_API void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
Move the given Evas object to the given location inside its canvas' viewport.
Definition evas_object_main.c:1171
evas_object_size_hint_weight_set
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition evas_object_main.c:2638
evas_object_size_hint_align_set
EVAS_API void evas_object_size_hint_align_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's alignment.
Definition evas_object_main.c:2650
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040
_Eina_List
Type for a generic double linked list.
Definition eina_list.h:318
_Eina_List::data
void * data
Pointer to list element payload.
Definition eina_list.h:319
_Elm_Box_Transition
Definition elm_widget_box.h:36