Panes widget example

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

Panes widget example

This code places two Elementary panes widgets on a window, one of them displayed vertically and the other horizontally, to exemplify a part of the widget's API.

Also, all the signals emitted by this widget will be covered.

Let's start adding a panes to our window:

panes = elm_panes_add(win);
elm_panes_add
Evas_Object * elm_panes_add(Evas_Object *parent)
Add a new panes widget to the given parent Elementary (container) object.
Definition: efl_ui_panes.c:723
evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, panes);
evas_object_show(panes);
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
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
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_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

Now we will set a content (a simple button) to the left side of our panes widget:

bt = elm_button_add(win);
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

The content of the right side will be something a bit more elaborated, we'll place another panes, displayed vertically (it's displayed horizontally by default):

When populating a panes displayed vertically, remember that left content will be placed at top, and right content will place at bottom. Next we will add two buttons to exemplify that:

Panes widgets emits 4 different signals, depending on users interaction with the draggable bar. We'll add a callback function for each of them.

`"clicked" signal` :

Callback function that just print "Clicked" to stdin:

static void
_clicked_double(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
static double size = 0.0;
double tmp_size = 0.0;
tmp_size = elm_panes_content_left_size_get(obj);
if (tmp_size > 0)
{
elm_panes_content_left_size_set(obj, 0.0);
printf("Double clicked, hidding.\n");
}
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:185

Also, add callback function to the panes:

evas_object_smart_callback_add(panes, "clicked", _clicked, panes);
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

`"press" signal` :

Callback function that just print "Pressed" to stdin:

static void
_unpress(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
printf("Unpressed, size : %f\n", elm_panes_content_left_size_get(obj));
}

Also, add callback function to the panes:

evas_object_smart_callback_add(panes, "press", _press, panes);

Now, let's try to make our callback functions a bit more useful:

`"unpress" signal` :

Suppose we want to know the size proportion of left content after user drags the bar. We need to listen for `unpress` signal, and get this size from our panes widget. It's done on the following function:

static void
_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
printf("Clicked\n");
}

Adding the callback function to the panes:

evas_object_smart_callback_add(panes, "unpress", _unpress, panes);

`"clicked,double" signal` :

Now, a interesting feature that could be addded to panes widget. Hide a content when user double click the draggable bar. It's done using a variable to store size and content left size getter and setter on the following function:

static double size = 0.0;

Adding the callback function to the panes:

See the full example, whose window should look like this picture: