summaryrefslogtreecommitdiff
path: root/src/examples/elementary/toolbar_cxx_example_01.cc
blob: d6ecc44e7996a755fe79b7efe3c5b1812f473c0e (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * Copyright 2019 by its authors. See AUTHORS.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#define ELM_WIDGET_PROTECTED
#define ELM_WIDGET_CLASS_PROTECTED

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#warning This example requires yet unfinished EO APIs

#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>

EAPI int
elm_main(int argc EINA_UNUSED, char* argv[] EINA_UNUSED)
{
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);

   using efl::eo::instantiate;

   efl::ui::Win win_1
     (instantiate,
      [&]
      {
        win_1.text_set("Toolbar");
        win_1.win_name_set("toolbar");
        win_1.win_type_set(EFL_UI_WIN_TYPE_BASIC);
      });

#if 0
   win_1.eo_cxx::efl::Gfx::size_set({320, 300});

   efl::ui::Box box_1(instantiate, win_1);
   box_1.hint_weight_set(1.0, 1.0);
   box_1.visible_set(true);

   elm::Toolbar toolbar_1(instantiate, win_1);
   toolbar_1.shrink_mode_set(ELM_TOOLBAR_SHRINK_MENU);
   toolbar_1.hint_weight_set(0, 0);
   toolbar_1.hint_align_set(0.5, 0);
   toolbar_1.hint_fill_set(ture, false);
   toolbar_1.menu_parent_set(win_1);
   elm::toolbar::Item item_1 = efl::eo::downcast<elm::toolbar::Item>
     (toolbar_1.item_append("document-print", "Hello", nullptr, nullptr));
   item_1.disabled_set(true);
   item_1.priority_set(100);
   elm::toolbar::Item item_2 = efl::eo::downcast<elm::toolbar::Item>
     (toolbar_1.item_append("folder-new", "World", nullptr, nullptr));
   item_2.priority_set(100);
   elm::toolbar::Item item_3 = efl::eo::downcast<elm::toolbar::Item>
     (toolbar_1.item_append("object-rotate-right", "H", nullptr, nullptr));
   item_3.priority_set(150);
   elm::toolbar::Item item_4 = efl::eo::downcast<elm::toolbar::Item>
     (toolbar_1.item_append("mail-send", "Comes", nullptr, nullptr));
   item_4.priority_set(0);
   elm::toolbar::Item item_5 = efl::eo::downcast<elm::toolbar::Item>
     (toolbar_1.item_append("clock", "Elementary", nullptr, nullptr));
   item_5.priority_set(200);
   elm::toolbar::Item item_6 = efl::eo::downcast<elm::toolbar::Item>
     (toolbar_1.item_append("refresh", "Menu", nullptr, nullptr));
   item_6.menu_set(true);
   item_6.priority_set(9999);
   elm::Menu menu_1 = efl::eo::downcast<elm::Menu>
     (item_6.menu_get());
   elm::menu::Item item_7 = efl::eo::downcast<elm::menu::Item>
     (menu_1.item_add(nullptr, "edit-cut", "Shrink", nullptr, nullptr));
   elm::menu::Item item_8 = efl::eo::downcast<elm::menu::Item>
     (menu_1.item_add(nullptr, "edit-copy", "Mode", nullptr, nullptr));
   elm::menu::Item item_9 = efl::eo::downcast<elm::menu::Item>
     (menu_1.item_add(item_8, "edit-paste", "is set to", nullptr, nullptr));
   elm::menu::Item item_10 = efl::eo::downcast<elm::menu::Item>
     (menu_1.item_add(nullptr, "edit-delete", "Menu", nullptr, nullptr));

   box_1.pack_end(toolbar_1);
   elm::Widget table_1(elm_table_add(win_1._eo_ptr()));
   table_1.hint_weight_set(0.0, 1.0);
   table_1.hint_fill_set(true, true);
   table_1.visible_set(true);

   elm::Widget photo_1(elm_photo_add(win_1._eo_ptr()));
   elm_photo_size_set(photo_1._eo_ptr(), 40);
   efl_file_simple_load(photo_1._eo_ptr(), "/opt/e/share/elementary/images/plant_01.jpg", nullptr);
   photo_1.hint_weight_set(1, 1);
   photo_1.hint_align_set(0.5, 0.5);
   photo_1.visible_set(true);

   elm_table_pack(table_1._eo_ptr(), photo_1._eo_ptr(), 0, 0, 1, 1);
   elm::Widget photo_2(elm_photo_add(win_1._eo_ptr()));
   elm_photo_size_set(photo_2._eo_ptr(), 80);
   photo_2.hint_weight_set(1, 1);
   photo_2.hint_align_set(0.5, 0.5);
   photo_2.visible_set(true);

   elm_table_pack(table_1._eo_ptr(), photo_2._eo_ptr(), 1, 0, 1, 1);
   elm::Widget photo_3(elm_photo_add(win_1._eo_ptr()));
   elm_photo_size_set(photo_3._eo_ptr(), 20);
   efl_file_simple_load(photo_3._eo_ptr(), "/opt/e/share/elementary/images/sky_01.jpg", nullptr);
   photo_3.hint_weight_set(1, 1);
   photo_3.hint_align_set(0.5, 0.5);
   photo_3.visible_set(true);

   elm_table_pack(table_1._eo_ptr(), photo_3._eo_ptr(), 0, 1, 1, 1);
   elm::Widget photo_4(elm_photo_add(win_1._eo_ptr()));
   elm_photo_size_set(photo_4._eo_ptr(), 60);
   efl_file_simple_load(photo_4._eo_ptr(), "/opt/e/share/elementary/images/sky_02.jpg", nullptr);
   photo_4.hint_weight_set(1, 1);
   photo_4.hint_align_set(0.5, 0.5);
   photo_4.visible_set(true);

   elm_table_pack(table_1._eo_ptr(), photo_4._eo_ptr(), 1, 1, 1, 1);
   box_1.pack_end(table_1);

   win_1.content_set(box_1);

   auto _item_2_selected_cb = std::bind([&] () {
       efl_file_simple_load(photo_1._eo_ptr(), "/opt/e/share/elementary/images/rock_01.jpg", nullptr);
     });
   efl::eolian::event_add(efl::ui::Selectable::selected_event, item_2, _item_2_selected_cb);

   auto _item_3_selected_cb = std::bind([&] () {
       efl_file_simple_load(photo_4._eo_ptr(), "/opt/e/share/elementary/images/wood_01.jpg", nullptr);
     });

   efl::eolian::event_add(efl::ui::Selectable::selected_event, item_3, _item_3_selected_cb);
   auto _item_4_selected_cb = std::bind([&] () {
       efl_file_simple_load(photo_4._eo_ptr(), "/opt/e/share/elementary/images/sky_03.jpg", nullptr);
     });

   efl::eolian::event_add(efl::ui::Selectable::selected_event, item_4, _item_4_selected_cb);
   auto _item_5_selected_cb = std::bind([&] () {
       efl_file_simple_load(photo_4._eo_ptr(), nullptr, nullptr);
     });

   efl::eolian::event_add(efl::ui::Selectable::selected_event, item_5, _item_5_selected_cb);

#endif
   
   elm_run();
   return 0;
}
ELM_MAIN()