summaryrefslogtreecommitdiff
path: root/src/examples/elementary/thumb_cxx_example_01.cc
blob: abca9acc7595865630e455964e40f9dd66b43d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <Elementary.hh>

#include <iostream>
#include <sstream>

EAPI_MAIN int
elm_main(int argc, char *argv[])
{
   elm_need_ethumb();

   elm_app_info_set(reinterpret_cast<void*>(elm_main), "elementary", "images/plant_01.jpg");
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);

   ::elm::win_standard win;
   win.title_set("Thumbnailer");
   win.autohide_set(true);

   ::elm::thumb thumb(efl::eo::parent = win);

   auto generation_started = std::bind([] { std::cout << "thumbnail generation started." << std::endl; });

   auto generation_finished = std::bind([] { std::cout << "thumbnail generation finished." << std::endl; });

   auto generation_error = std::bind([] { std::cout << "thumbnail generation error." << std::endl; });

   thumb.callback_generate_start_add( generation_started );
   thumb.callback_generate_stop_add( generation_finished );
   thumb.callback_generate_error_add( generation_error );

   thumb.size_set(160, 160);
   thumb.editable_set(false);
   std::stringstream ss;
   ss << elm_app_data_dir_get() << "/images/plant_01.jpg";
   thumb.file_set(ss.str(), "image");
   thumb.reload();

   thumb.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   win.resize_object_add(thumb);
   thumb.visible_set(true);

   win.size_set(320, 320);
   win.visible_set(true);

   elm_run();
   return 0;
}
ELM_MAIN()