This example shows how one can send and receive signals to/from the layout, and what to do when the layout theme has its size changed.

The full source code for this example can be found at \hyperlink{layout_example_03_c}{layout\-\_\-example\-\_\-03.\-c}.

In this exmaple we will use another group from the same layout theme file used in \hyperlink{layout_example_01}{Layout -\/ Content, Table and Box}. Its instantiation and loading happens in the following lines\-:

 
\begin{DoxyCodeInclude}
   layout = elm_layout_add(win);
   evas\_object\_size\_hint\_weight\_set(layout, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, layout);
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/examples/layout\_example.edj"}, 
      elm_app_data_dir_get());
   elm_layout_file_set(layout, buf, \textcolor{stringliteral}{"example/mylayout3"});
   evas\_object\_show(layout);

\end{DoxyCodeInclude}


This time we register a callback to be called whenever we receive a signal after the end of the animation that happens in this layout\-:


\begin{DoxyCodeInclude}

   elm_object_signal_callback_add(layout, \textcolor{stringliteral}{"size,changed"}, \textcolor{stringliteral}{""}, \_size\_changed\_cb, layout);

\end{DoxyCodeInclude}


We also add a button that will send signals to the layout\-:


\begin{DoxyCodeInclude}

   \textcolor{comment}{// Setting title}
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *title = elm_layout_data_get(layout, \textcolor{stringliteral}{"title"});
   \textcolor{keywordflow}{if} (title)
     \{
        elm_win_title_set(win, title);
        elm_object_part_text_set(layout, TITLE, title);
     \}

   btn = elm_button_add(win);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Enlarge me!"});
   evas\_object\_size\_hint\_weight\_set(btn, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(btn, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_object_part_content_set(layout, SWALLOW, btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_swallow\_btn\_cb, layout);

\end{DoxyCodeInclude}


The callback for this button will check what type of signal it should send, and then emit it. The code for this callback follows\-:

 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} Eina\_Bool \_btn\_large = EINA\_FALSE;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_swallow\_btn\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *btn, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *layout = data;

   \textcolor{keywordflow}{if} (\_btn\_large == EINA\_FALSE)
     \{
        \_btn\_large = EINA\_TRUE;
        elm_object_signal_emit(layout, \textcolor{stringliteral}{"button,enlarge"}, \textcolor{stringliteral}{""});
        elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Reduce me!"});
     \}
   \textcolor{keywordflow}{else}
     \{
        \_btn\_large = EINA\_FALSE;
        elm_object_signal_emit(layout, \textcolor{stringliteral}{"button,reduce"}, \textcolor{stringliteral}{""});
        elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Enlarge me!"});
     \}
\}

\end{DoxyCodeInclude}


As we said before, we are receiving a signal whenever the animation started by the button click ends. This is the callback for that signal\-:


\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_size\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *layout, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source)
\{
   Evas\_Object *edje;
   Evas\_Coord w, h;

   elm_layout_sizing_eval(layout);
   edje = elm_layout_edje_get(layout);
   edje\_object\_size\_min\_calc(edje, &w, &h);
   printf(\textcolor{stringliteral}{"Minimum size for this theme: %dx%d\(\backslash\)n"}, w, h);
\}

\end{DoxyCodeInclude}


Notice from this callback that the \hyperlink{group__Layout_ga706284d5508c9ef6ee23e93d072dbb8d}{elm\-\_\-layout\-\_\-sizing\-\_\-eval()} function must be called if we want our widget to update its size after the layout theme having changed its minimum size. This happens because the animation specified in the theme increases the size of the content area to a value higher than the widget size, thus requiring more space. But the elementary layout widget has no way to know this, thus needing the \hyperlink{group__Layout_ga706284d5508c9ef6ee23e93d072dbb8d}{elm\-\_\-layout\-\_\-sizing\-\_\-eval()} to be called on the layout, informing that this size has changed.

A screenshot of this example can be seen on\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/layout_example_03}
\caption{width=}
\end{DoxyImage}
 