

Overlays are like extensions in that you tell Elementary that some other theme contains the styles you need for your program. The difference is that they will be look in first, so they can override the default style of any widget.

There\textquotesingle{}s not much to say about them that hasn\textquotesingle{}t been said in our previous example about \hyperlink{theme_example_01}{extensions}, so going quickly through the code we have a function to load or unload the theme, which will be called when we click any button. 
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <Elementary.h>}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_clicked\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *ev)
\{
   \textcolor{keyword}{static} \textcolor{keywordtype}{int} loaded = 1;
   \textcolor{keywordflow}{if} (loaded)
     elm_theme_overlay_del(NULL, \textcolor{stringliteral}{"./theme\_example.edj"});
   \textcolor{keywordflow}{else}
     elm_theme_overlay_add(NULL, \textcolor{stringliteral}{"./theme\_example.edj"});
   loaded = 1 - loaded;
\}

\end{DoxyCodeInclude}


And the main function, creating the window and adding some buttons to it. We load our theme as an overlay and nothing else. Notice there\textquotesingle{}s no style set for any button there, which means they should be using the default that we override. 
\begin{DoxyCodeInclude}
EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
   Evas\_Object *win, *box, *btn;

   elm_policy_set(ELM\_POLICY\_QUIT, ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED);

   elm_theme_overlay_add(NULL, \textcolor{stringliteral}{"./theme\_example.edj"});

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"theme"}, \textcolor{stringliteral}{"Theme example"});
   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);

   btn = elm_button_add(win);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Button 1"});
   elm\_box\_pack\_end(box, btn);
   evas\_object\_show(btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_btn\_clicked\_cb, NULL);

   btn = elm_button_add(win);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Button 2"});
   elm\_box\_pack\_end(box, btn);
   evas\_object\_show(btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_btn\_clicked\_cb, NULL);

   btn = elm_button_add(win);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Button 3"});
   elm\_box\_pack\_end(box, btn);
   evas\_object\_show(btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_btn\_clicked\_cb, NULL);

   btn = elm_button_add(win);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Button 4"});
   elm\_box\_pack\_end(box, btn);
   evas\_object\_show(btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_btn\_clicked\_cb, NULL);

   evas\_object\_resize(win, 300, 320);
   evas\_object\_show(win);

   elm_run();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()

\end{DoxyCodeInclude}


That\textquotesingle{}s pretty much it. The full code is \hyperlink{theme_example_02_8c-example}{here} and the definition of the theme is the same as before, and can be found in \hyperlink{theme_example_8edc-example}{here}. 