Tizen Native API
5.5
|
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); evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(win, panes); evas_object_show(panes);
Now we will set a content (a simple button) to the left side of our panes widget:
bt = elm_button_add(win);
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"); }
Also, add callback function to the panes:
evas_object_smart_callback_add(panes, "clicked", _clicked, panes);
"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: