aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuciana Magno de Almeida <luciana@expertisesolutions.com.br>2015-01-15 17:45:56 -0200
committerLuciana Magno de Almeida <luciana@expertisesolutions.com.br>2015-01-15 17:45:56 -0200
commite96f7aab48796fa439f924f31c6543eb1e3a1b3f (patch)
tree2231e1512cb19bac786bb1af681717e20efda630
parentcxx: Added More Elementary C++ Examples (diff)
downloadelementary-devs/felipealmeida/examples.tar.gz
cxx: Added and modified a few Elementary C++ examplesdevs/felipealmeida/examples
-rw-r--r--src/examples/Makefile.am10
-rw-r--r--src/examples/bg_cxx_example_02.cc9
-rw-r--r--src/examples/bg_cxx_example_03.cc234
-rw-r--r--src/examples/bubble_cxx_example_01.cc14
-rw-r--r--src/examples/calendar_cxx_example_01.cc7
-rw-r--r--src/examples/glview_cxx_example_01.cc35
-rw-r--r--src/examples/icon_cxx_example_01.cc1
7 files changed, 268 insertions, 42 deletions
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index ab503e829..a453b9aab 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -180,9 +180,10 @@ calendar_cxx_example_01.cc \
bubble_cxx_example_01.cc \
button_cxx_example_01.cc \
button_cxx_example_00.cc \
+box_cxx_example_02.cc \
bg_cxx_example_02.cc \
bg_cxx_example_01.cc \
-box_cxx_example_02.cc
+bg_cxx_example_03.cc
endif
.edc.edj:
@@ -364,9 +365,10 @@ calendar_cxx_example_01 \
bubble_cxx_example_01 \
button_cxx_example_01 \
button_cxx_example_00 \
+box_cxx_example_02 \
bg_cxx_example_02 \
bg_cxx_example_01 \
-box_cxx_example_02
+bg_cxx_example_03
endif
if ELEMENTARY_WINDOWS_BUILD
@@ -415,9 +417,10 @@ calendar_cxx_example_01_SOURCES = calendar_cxx_example_01.cc
bubble_cxx_example_01_SOURCES = bubble_cxx_example_01.cc
button_cxx_example_01_SOURCES = button_cxx_example_01.cc
button_cxx_example_00_SOURCES = button_cxx_example_00.cc
+box_cxx_example_02_SOURCES = box_cxx_example_02.cc
bg_cxx_example_02_SOURCES = bg_cxx_example_02.cc
bg_cxx_example_01_SOURCES = bg_cxx_example_01.cc
-box_cxx_example_02_SOURCES = box_cxx_example_02.cc
+bg_cxx_example_03_SOURCES = bg_cxx_example_03.cc
endif
# This variable will hold the list of screenshots that will be made
@@ -507,7 +510,6 @@ menu_example_01:menu_example_01.png:0.5
if HAVE_CXX11
SCREENSHOTS += \
-calendar_cxx_example_01:calendar_cxx_example_01.png:1.3 \
box_cxx_example_02:box_cxx_example_02.png:1.3
endif
diff --git a/src/examples/bg_cxx_example_02.cc b/src/examples/bg_cxx_example_02.cc
index 22feaf03a..966f6b1cd 100644
--- a/src/examples/bg_cxx_example_02.cc
+++ b/src/examples/bg_cxx_example_02.cc
@@ -34,24 +34,21 @@ extern "C"
EAPI_MAIN int
elm_main (int argc, char *argv[])
{
- // char buf[PATH_MAX];
-
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
+ elm_app_compile_data_dir_set("/home/luciana/Enlightenment/local/share/elementary/");
elm_app_info_set(reinterpret_cast<void*>(elm_main), "elementary", "images/plant_01.jpg");
- ::elm_win win(elm_win_add(NULL, "bg-image", ELM_WIN_BASIC));
+ ::elm_win win(win.elm_obj_win_constructor("bg-image", ELM_WIN_BASIC));
win.title_set("Bg Image");
win.autohide_set(true);
::elm_bg bg(efl::eo::parent = win);
bg.load_size_set(20, 20);
bg.option_set(ELM_BG_OPTION_CENTER);
- // snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
- // elm_bg_file_set(bg, buf, NULL);
std::stringstream ss;
ss << elm_app_data_dir_get() << "/images/plant_01.jpg";
- bg.file_set(ss.str(), "image");
+ bg.file_set(ss.str(), nullptr);
bg.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
win.resize_object_add(bg);
bg.visibility_set(true);
diff --git a/src/examples/bg_cxx_example_03.cc b/src/examples/bg_cxx_example_03.cc
new file mode 100644
index 000000000..3068d4ade
--- /dev/null
+++ b/src/examples/bg_cxx_example_03.cc
@@ -0,0 +1,234 @@
+extern "C"
+{
+#ifdef HAVE_CONFIG_H
+# include <elementary_config.h>
+#endif
+
+#define ELM_INTERNAL_API_ARGESFSDFEFC
+#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
+#define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
+#define ELM_INTERFACE_ATSPI_ACTION_PROTECTED
+#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED
+#define ELM_INTERFACE_ATSPI_EDITABLE_TEXT_PROTECTED
+#define ELM_INTERFACE_ATSPI_TEXT_PROTECTED
+#define ELM_INTERFACE_ATSPI_SELECTION_PROTECTED
+#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
+#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
+
+#include <Eo.h>
+#include <Evas.h>
+#include <Elementary.h>
+#include <elm_widget.h>
+
+#include "elm_interface_atspi_accessible.h"
+#include "elm_interface_atspi_widget_action.h"
+}
+
+#include <sstream>
+
+#include <Elementary.hh>
+#include <Eina.hh>
+
+// void
+// _cb_radio_changed(::elm_bg o_bg, Eo_Event_Description const& desc EINA_UNUSED, void* info EINA_UNUSED)
+// {
+// Evas_Object *o_bg = data;
+
+// o_bg.option_set(rd.value_get());
+// }
+
+// void
+// _cb_overlay_changed(::elm_bg o_bg, Eo_Event_Description const& desc EINA_UNUSED, void* info EINA_UNUSED)
+// {
+// Evas_Object *o_bg = data;
+
+// if (obj.state_get())
+// {
+// Evas_Object *parent, *over;
+
+// //snprintf(buff, sizeof(buff), "%s/objects/test.edj", elm_app_data_dir_get());
+// std::stringstream ss1;
+// ss1 << elm_app_data_dir_get() << "/objects/teste.edj";
+// static_cast<evas::object>(parent) = o_bg.parent_widget_get();
+// over = edje_object_add(evas_object_evas_get(parent));
+// edje_object_file_set(over, buff, "bg_overlay");
+// o_bg.content_set("overlay", over);
+// }
+// else
+// o_bg.content_set("overlay", nullptr);
+// }
+
+EAPI_MAIN int
+elm_main (int argc, char *argv[])
+{
+ char buf[PATH_MAX];
+ elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+
+ elm_app_compile_data_dir_set("/home/luciana/Enlightenment/local/share/elementary/");
+ elm_app_info_set(reinterpret_cast<void*>(elm_main), "elementary", "objects/test.edj");
+
+ ::elm_win win(elm_win_util_standard_add("bg-options", "Bg Options"));
+ win.autodel_set(true);
+
+ ::elm_box box(efl::eo::parent = win);
+ box.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ win.resize_object_add(box);
+ box.visibility_set(true);
+
+ ::elm_bg o_bg(efl::eo::parent = win);
+ o_bg.option_set(ELM_BG_OPTION_CENTER);
+ std::stringstream ss;
+ ss << elm_app_data_dir_get() << "/images/plant_01.jpg";
+ o_bg.file_set(ss.str(), nullptr);
+ o_bg.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ o_bg.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
+ box.pack_end(o_bg);
+ o_bg.visibility_set(true);
+
+ ::elm_box hbox(efl::eo::parent = win);
+ hbox.horizontal_set(true);
+ hbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ hbox.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ ::elm_radio rd(efl::eo::parent = win);
+ rd.state_value_set(ELM_BG_OPTION_CENTER);
+ rd.text_set("elm.text" , "Center");
+ rd.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+
+ auto cb_radio_changed = std::bind ([&] () { o_bg.option_set(rd.value_get()); });
+ rd.callback_changed_add (cb_radio_changed);
+ // evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
+ // efl::eo::signal_connection conn =
+ // rd.callback_changed_add
+ // ([&win] (::elm_radio& obj, Eo_Event_Description const& desc EINA_UNUSED, void* info EINA_UNUSED)
+ // {
+ // ::elm_bg o_bg2(efl::eo::parent = win);
+ // ::elm_radio rd(efl::eo::parent = win);
+ // o_bg2.option_set(static_cast<Elm_Bg_Option>(obj.value_get()));
+ // });
+ hbox.pack_end(rd);
+ rd.visibility_set(true);
+
+ ::elm_radio rdg(efl::eo::parent = win);
+ rdg = rd;
+
+ ::elm_radio rd2(efl::eo::parent = win);
+ rd2.state_value_set(ELM_BG_OPTION_SCALE);
+ rd2.group_add(rdg);
+ rd2.text_set(nullptr, "Scale");
+ rd2.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ //evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
+ //conn;
+ rd2.callback_changed_add(cb_radio_changed);
+ hbox.pack_end(rd2);
+ rd2.visibility_set(true);
+
+ ::elm_radio rd3(efl::eo::parent = win);
+ rd3.state_value_set(ELM_BG_OPTION_STRETCH);
+ rd3.group_add(rdg);
+ rd3.text_set(nullptr , "Stretch");
+ rd3.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ // evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
+ //conn;
+ rd3.callback_changed_add(cb_radio_changed);
+ hbox.pack_end(rd3);
+ rd3.visibility_set(true);
+
+ ::elm_radio rd4(efl::eo::parent = win);
+ rd4.state_value_set(ELM_BG_OPTION_TILE);
+ rd4.group_add(rdg);
+ rd4.text_set("elm.text" , "Title");
+ rd4.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ // evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
+ //conn;
+ rd4.callback_changed_add(cb_radio_changed);
+ hbox.pack_end(rd4);
+ rd4.visibility_set(true);
+
+ rdg.state_value_set(ELM_BG_OPTION_SCALE);
+
+ ::elm_radio rd_ch(efl::eo::parent = win);
+ ::elm_check ch(efl::eo::parent = win);
+ rd_ch = ch;
+ rd_ch.text_set(nullptr, "Show Overlay");
+ rd_ch.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ // evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
+
+ auto cb_overlay_changed = std::bind ([&] () { if (ch.state_get())
+ {
+ ::efl::eina::optional< ::evas::object > parent, over;
+ std::stringstream ss1;
+ ss1 << elm_app_data_dir_get() << "/objects/teste.edj";
+ parent = o_bg.parent_widget_get();
+ over = edje_object_add(evas_object_evas_get(parent));
+ edje_object_file_set(over, buff, "bg_overlay");
+ o_bg.content_set("overlay", over);
+ }
+ else
+ o_bg.content_set("overlay", nullptr);
+ });
+
+ rd_ch.callback_changed_add(cb_overlay_changed);
+ hbox.pack_end(rd_ch);
+ rd_ch.visibility_set(true);
+
+ ::elm_radio rd_sp(efl::eo::parent = win);
+ ::elm_spinner sp(efl::eo::parent = win);
+ rd_sp = sp;
+ rd_sp.style_set("vertical");
+ rd_sp.min_max_set(1, 4);
+ rd_sp.label_format_set("%.0f");
+ rd_sp.editable_set(false);
+ rd_sp.special_value_add(1, "White");
+ rd_sp.special_value_add(2, "Red");
+ rd_sp.special_value_add(3, "Blue");
+ rd_sp.special_value_add(4, "Green");
+ rd_sp.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ rd_sp.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
+ // evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
+
+ auto cb_color_changed = std::bind ([&] () { double val = 0.0;
+ val = sp.value_get();
+ if (val == 1.0)
+ o_bg.color_set(255, 255, 255);
+ else if (val == 2.0)
+ o_bg.color_set(255, 0, 0);
+ else if (val == 3.0)
+ o_bg.color_set(0, 0, 255);
+ else if (val == 4.0)
+ o_bg.color_set(0, 255, 0);
+ });
+
+ rd_sp.callback_changed_add(cb_color_changed);
+
+ // efl::eo::signal_connection conn2 =
+ // rd2.callback_changed_add
+ // ([&win] (::elm_spinner& obj_, Eo_Event_Description const& desc EINA_UNUSED, void* info EINA_UNUSED)
+ // {
+ // ::elm_spinner obj(efl::eo::parent = win);
+ // ::elm_bg o_bg3(efl::eo::parent = win);
+ // double val = 0.0;
+ // val = obj.value_get();
+ // if (val == 1.0)
+ // o_bg3.color_set(255, 255, 255, 255);
+ // else if (val == 2.0)
+ // o_bg3.color_set(255, 0, 0, 255);
+ // else if (val == 3.0)
+ // o_bg3.color_set(0, 0, 255, 255);
+ // else if (val == 4.0)
+ // o_bg3.color_set(0, 255, 0, 255);
+ // });
+
+ hbox.pack_end(rd_sp);
+ rd_sp.visibility_set(true);
+
+ box.pack_end(hbox);
+ hbox.visibility_set(true);
+
+ win.size_set(460, 320);
+ win.visibility_set(true);
+
+ elm_run();
+ return 0;
+}
+ELM_MAIN();
diff --git a/src/examples/bubble_cxx_example_01.cc b/src/examples/bubble_cxx_example_01.cc
index d971d9063..e6df1b76e 100644
--- a/src/examples/bubble_cxx_example_01.cc
+++ b/src/examples/bubble_cxx_example_01.cc
@@ -56,7 +56,7 @@ elm_main (int argc, char *argv[])
icon.color_set( 0, 0, 255, 255);
icon.visibility_set(true);
- elm_bubble bubble1(efl::eo::parent = win);
+ ::elm_bubble bubble1(efl::eo::parent = win);
bubble1.content_set("icon", icon);
bubble1.text_set("info", "INFO");
bubble1.text_set(nullptr, "LABEL");
@@ -65,12 +65,12 @@ elm_main (int argc, char *argv[])
bubble1.visibility_set(true);
auto bla = std::bind([&] () { static unsigned char corner = 0;
- ++corner;
- if (corner > 3)
- bubble1.pos_set(ELM_BUBBLE_POS_TOP_LEFT);
- else
- bubble1.pos_set(static_cast<Elm_Bubble_Pos>(corner));
- });
+ ++corner;
+ if (corner > 3)
+ bubble1.pos_set(ELM_BUBBLE_POS_TOP_LEFT);
+ else
+ bubble1.pos_set(static_cast<Elm_Bubble_Pos>(corner));
+ });
bubble1.callback_clicked_add(bla);
diff --git a/src/examples/calendar_cxx_example_01.cc b/src/examples/calendar_cxx_example_01.cc
index 959f0166b..1a07e930c 100644
--- a/src/examples/calendar_cxx_example_01.cc
+++ b/src/examples/calendar_cxx_example_01.cc
@@ -26,16 +26,12 @@ extern "C"
#include "elm_interface_scrollable.h"
}
+#include <Elementary.hh>
#include <Eina.hh>
-#include <elm_win.eo.hh>
-#include <elm_calendar.eo.hh>
-
-
EAPI_MAIN int
elm_main (int argc, char *argv[])
{
-
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
::elm_win win(elm_win_util_standard_add("calendar", "Calendar Creation Example"));
@@ -49,7 +45,6 @@ elm_main (int argc, char *argv[])
win.visibility_set(true);
elm_run();
-
return 0;
}
ELM_MAIN()
diff --git a/src/examples/glview_cxx_example_01.cc b/src/examples/glview_cxx_example_01.cc
index 4f4e2f3ce..23fa61b7d 100644
--- a/src/examples/glview_cxx_example_01.cc
+++ b/src/examples/glview_cxx_example_01.cc
@@ -47,14 +47,12 @@ struct _GLData
static float red = 1.0;
static GLuint
-load_shader( GLData *gld, GLenum type, const char *shader_src )
+load_shader(GLData *gld, GLenum type, const char *shader_src )
{
Evas_GL_API *gl = gld->glapi;
GLuint shader;
GLint compiled;
- std::cout << __func__ << ":" << __LINE__ << std::endl;
-
shader = gl->glCreateShader(type);
if (shader==0)
return 0;
@@ -85,7 +83,9 @@ load_shader( GLData *gld, GLenum type, const char *shader_src )
static int
init_shaders(GLData *gld)
{
+ std::cout << __func__ << ":" << __LINE__ << std::endl;
Evas_GL_API *gl = gld->glapi;
+ std::cout << __func__ << ":" << __LINE__ << std::endl;
GLbyte vShaderStr[] =
"attribute vec4 vPosition; \n"
@@ -151,19 +151,18 @@ _init_gl(Evas_Object *obj)
0.5f, -0.5f, 0.0f };
if (!init_shaders(gld))
- {
- std::cout << "Error Initializing Shaders" << std::endl;
- return;
- }
-
- std::cout << __func__ << ":" << __LINE__ << std::endl;
+ {
+ std::cout << "Error Initializing Shaders" << std::endl;
+ return;
+ }
- gl->glGenBuffers(1, &gld->vbo);
- std::cout << __func__ << ":" << __LINE__ << std::endl;
- gl->glBindBuffer(GL_ARRAY_BUFFER, gld->vbo);
- std::cout << __func__ << ":" << __LINE__ << std::endl;
- gl->glBufferData(GL_ARRAY_BUFFER, 3 * 3 * 4, vVertices, GL_STATIC_DRAW);
- std::cout << __func__ << ":" << __LINE__ << std::endl;
+ std::cout << __func__ << ":" << __LINE__ << std::endl;
+ gl->glGenBuffers(1, &gld->vbo);
+ std::cout << __func__ << ":" << __LINE__ << std::endl;
+ gl->glBindBuffer(GL_ARRAY_BUFFER, gld->vbo);
+ std::cout << __func__ << ":" << __LINE__ << std::endl;
+ gl->glBufferData(GL_ARRAY_BUFFER, 3 * 3 * 4, vVertices, GL_STATIC_DRAW);
+ std::cout << __func__ << ":" << __LINE__ << std::endl;
}
@@ -268,8 +267,8 @@ elm_main (int argc, char *argv[])
win.resize_object_add(bx);
bx.visibility_set(true);
- ::elm_glview gl( gl.elm_obj_glview_version_constructor(EVAS_GL_GLES_2_X),
- efl::eo::parent = win);
+ ::elm_glview gl(gl.elm_obj_glview_version_constructor(EVAS_GL_GLES_2_X),
+ efl::eo::parent = win);
gld->glapi = gl.gl_api_get();
gl.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
gl.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -279,7 +278,7 @@ elm_main (int argc, char *argv[])
gl.resize_policy_set(ELM_GLVIEW_RESIZE_POLICY_RECREATE);
gl.render_policy_set(ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);
gl.init_func_set(_init_gl);
- // gl.del_func_set(_del_gl);
+ gl.del_func_set(_del_gl);
gl.resize_func_set(_resize_gl);
gl.render_func_set(_draw_gl);
diff --git a/src/examples/icon_cxx_example_01.cc b/src/examples/icon_cxx_example_01.cc
index f06992bc4..23b449be6 100644
--- a/src/examples/icon_cxx_example_01.cc
+++ b/src/examples/icon_cxx_example_01.cc
@@ -62,7 +62,6 @@ elm_main (int argc, char *argv[])
win.visibility_set(true);
elm_run();
-
return 0;
}
ELM_MAIN()