

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's not much to say about them that hasn'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'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);
   evas\_object\_resize(win, 300, 320);
   evas\_object\_show(win);

   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);

   elm_run();
   elm_shutdown();

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

\end{DoxyCodeInclude}


That'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}. 