Commits

Anonymous committed 379486d

Added preliminary callback example

Comments (0)

Files changed (13)

.sconsign.dblite

Binary file modified.
-env = Environment()
-env.Program(target='hello', source=['hello.cpp'])
-env.ParseConfig('pkg-config elementary --cflags --libs')
-
-env.Append(CPPATH = [
-    '/usr/local/include/',
-    '/usr/include/elementary-1',
-    '/usr/include/eina-1',
-    '/usr/include/eina-1/eina',
-    '/usr/include/eet-1',
-    '/usr/include/evas-1',
-    '/usr/include/ecore-1',
-    '/usr/include/edje-1',
-    '/usr/include/e_dbus-1',
-    '/usr/include/dbus-1.0',
-    '/usr/lib/x86_64-linux-gnu/dbus-1.0/include',
-    '/usr/include/efreet-1',
-    '/usr/include/ethumb-1'
-])
-env.Append(CPPPATH = [
-    '/usr/local/include/',
-    '/usr/include/elementary-1',
-    '/usr/include/eina-1',
-    '/usr/include/eina-1/eina',
-    '/usr/include/eet-1',
-    '/usr/include/evas-1',
-    '/usr/include/ecore-1',
-    '/usr/include/edje-1',
-    '/usr/include/e_dbus-1',
-    '/usr/include/dbus-1.0',
-    '/usr/lib/x86_64-linux-gnu/dbus-1.0/include',
-    '/usr/include/efreet-1',
-    '/usr/include/ethumb-1'
-])
+SConscript('main.scons', variant_dir='build_debug', duplicate=0, exports={'MODE':'debug'})

Sconstruct

-SConscript('main.scons', variant_dir='build_debug', duplicate=0, exports={'MODE':'debug'})

examples/edje/.sconsign.dblite

Binary file added.

examples/edje/SConstruct

+import atexit
+
+@atexit.register
+def compile_layout():
+    Execute("edje_cc edje_example.edc")
+
+env = Environment()
+env.Program(target='edje_example', source=['edje_example.c'])
+env.ParseConfig('pkg-config --cflags --libs eina evas ecore ecore-evas edje')
+
+env.Append(CPPATH = [
+    '/usr/local/include/',
+    '/usr/include/elementary-1',
+    '/usr/include/eina-1',
+    '/usr/include/eina-1/eina',
+    '/usr/include/eet-1',
+    '/usr/include/evas-1',
+    '/usr/include/ecore-1',
+    '/usr/include/edje-1',
+    '/usr/include/e_dbus-1',
+    '/usr/include/dbus-1.0',
+    '/usr/lib/x86_64-linux-gnu/dbus-1.0/include',
+    '/usr/include/efreet-1',
+    '/usr/include/ethumb-1'
+])
+env.Append(CPPPATH = [
+    '/usr/local/include/',
+    '/usr/include/elementary-1',
+    '/usr/include/eina-1',
+    '/usr/include/eina-1/eina',
+    '/usr/include/eet-1',
+    '/usr/include/evas-1',
+    '/usr/include/ecore-1',
+    '/usr/include/edje-1',
+    '/usr/include/e_dbus-1',
+    '/usr/include/dbus-1.0',
+    '/usr/lib/x86_64-linux-gnu/dbus-1.0/include',
+    '/usr/include/efreet-1',
+    '/usr/include/ethumb-1'
+])

examples/edje/edje_example

Binary file added.

examples/edje/edje_example.c

+#include <Eina.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Edje.h>
+
+#define WIDTH 320
+#define HEIGHT 240
+
+static Evas_Object *create_my_group(Evas *canvas, const char *text)
+{
+   Evas_Object *edje;
+
+   edje = edje_object_add(canvas);
+   if (!edje)
+     {
+        EINA_LOG_CRIT("could not create edje object!");
+        return NULL;
+     }
+
+   if (!edje_object_file_set(edje, "edje_example.edj", "my_group"))
+     {
+        int err = edje_object_load_error_get(edje);
+        const char *errmsg = edje_load_error_str(err);
+        EINA_LOG_ERR("could not load 'my_group' from edje_example.edj: %s",
+                     errmsg);
+
+        evas_object_del(edje);
+        return NULL;
+     }
+
+   if (text)
+     {
+        if (!edje_object_part_text_set(edje, "text", text))
+          {
+             EINA_LOG_WARN("could not set the text. "
+                           "Maybe part 'text' does not exist?");
+          }
+     }
+
+   evas_object_move(edje, 0, 0);
+   evas_object_resize(edje, WIDTH, HEIGHT);
+   evas_object_show(edje);
+   return edje;
+}
+
+int main(int argc, char *argv[])
+{
+   Ecore_Evas *window;
+   Evas *canvas;
+   Evas_Object *edje;
+   const char *text;
+
+   ecore_evas_init();
+   edje_init();
+
+   window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+   if (!window)
+     {
+        EINA_LOG_CRIT("could not create window.");
+        return -1;
+     }
+   canvas = ecore_evas_get(window);
+
+   text = (argc > 1) ? argv[1] : NULL;
+
+   edje = create_my_group(canvas, text);
+   if (!edje)
+     return -2;
+
+   ecore_evas_show(window);
+   ecore_main_loop_begin();
+
+   evas_object_del(edje);
+   ecore_evas_free(window);
+
+   edje_shutdown();
+   ecore_evas_shutdown();
+
+   return 0;
+}

examples/edje/edje_example.edc

+// compile: edje_cc edje_example.edc
+collections {
+   group {
+      name: "my_group"; // must be the same as in edje_example.c
+
+      parts {
+         part {
+            name: "background";
+            type: RECT; // plain boring rectangle
+            mouse_events: 0; // we don't need any mouse event on the background
+
+            // just one state "default"
+            description {
+               state: "default" 0.0; // must always exist
+               color: 255 128 255 255; //magenta
+
+               // define part coordinates:
+
+               rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
+                  relative: 0.0 0.0;
+                  offset: 0 0;
+               }
+               rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
+                  relative: 1.0 1.0;
+                  offset: -1 -1;
+               }
+            }
+         }
+
+         part {
+            name: "text";
+            type: TEXT;
+            mouse_events: 1; // we want to change the color on mouse-over
+
+            // 2 states, one "default" and another "over" to be used
+            // on mouse over effect
+
+            description {
+               state: "default" 0.0;
+               color: 255 0 0 255; // red
+
+               // define part coordinates:
+
+               rel1 { // top-left at (WIDTH * 0.1 + 5, HEIGHT * 0.2 + 10)
+                  relative: 0.1 0.2;
+                  offset: 5 10;
+               }
+               rel2 { // bottom-right at (WIDTH * 0.9 - 6, HEIGHT * 0.8 - 11)
+                  relative: 0.9 0.8;
+                  offset: -6 -11;
+               }
+
+               // define text specific state details
+               text {
+                  font: "Sans"; // using fontconfig name!
+                  size: 10;
+                  text: "hello world";
+               }
+            }
+
+            description {
+               state: "over" 0.0;
+               inherit: "default" 0.0; // copy everything from "default" at this point
+
+               color: 0 255 0 255; // override color, now it is green
+            }
+         }
+
+         // do programs to change color on text mouse in/out (over)
+         programs {
+            program {
+               // what triggers this program:
+               signal: "mouse,in";
+               source: "text";
+
+               // what this program does:
+               action: STATE_SET "over" 0.0;
+               target: "text";
+
+               // do the state-set in a nice interpolation animation
+               // using linear time in 0.1 second
+               transition: LINEAR 0.1;
+            }
+
+            program {
+               // what triggers this program:
+               signal: "mouse,out";
+               source: "text";
+
+               // what this program does:
+               action: STATE_SET "default" 0.0;
+               target: "text";
+
+               // do the state-set in a nice interpolation animation
+               // using linear time in 0.1 second
+               transition: LINEAR 0.1;
+            }
+         }
+      }
+   }
+}

examples/edje/edje_example.edj

Binary file added.
 env = Environment()
-env.Program(target='hello', source=['src/hello.cpp'])
+sources = [
+  "src/about.cpp",
+  "src/hello.cpp"
+]
+env.Program(target='hello', source=sources)
 env.ParseConfig('pkg-config elementary --cflags --libs')
 
 env.Append(CPPATH = [
+#include "about.hpp"
+
+void show_about(void *data, Evas_Object *obj, void *event_info)
+{
+    Evas_Object *bubble = (Evas_Object*)data;
+    Evas_Object *msg_label = elm_object_content_get(bubble);
+    elm_object_text_set(msg_label, about.c_str());
+    evas_object_show(bubble);
+}
+#include <Elementary.h>
+#include <string>
+
+const std::string about = "Kensho Editor 0.1 - Created by Alfredo Di Napoli.";
+
+extern "C" {
+/**
+ * Show (and make visible) the about msg
+ */
+void show_about(void *data, Evas_Object *obj, void *event_info);
+}
 #include <Elementary.h>
 #include <string>
+#include "about.hpp"
 
 static void win_del(void *data, Evas_Object *obj, void *event_info)
 {
 
 EAPI int elm_main(int argc, char **argv)
 {
-   Evas_Object *win, *bg, *lb;
+   Evas_Object *win, *bg, *lb, *tb;
 
    win = elm_win_add(NULL, "hello", ELM_WIN_BASIC);
    elm_win_title_set(win, "Kensho");
    evas_object_smart_callback_add(win, "delete,request", win_del, NULL);
 
+   //Set a default background
    bg = elm_bg_add(win);
    evas_object_size_hint_weight_set(bg, 1.0, 1.0);
    elm_win_resize_object_add(win, bg);
    evas_object_show(bg);
 
+   //Add a toolbar
+
+   //Add a label
    lb = elm_label_add(win);
    std::string lb_caption = "Hello World!";
    elm_object_text_set(lb, lb_caption.c_str());
-   evas_object_size_hint_weight_set(lb, 1.0, 1.0);
-   elm_win_resize_object_add(win, lb);
    evas_object_show(lb);
 
+   //Add a bubble
+   Evas_Object *bubble;
+
+   //Bubble logic
+   bubble = elm_bubble_add(win);
+   elm_object_content_set(bubble, lb);
+   evas_object_resize(bubble, 300, 100);
+
    //Add a simple button
    Evas_Object *btn;
    btn = elm_button_add(win);
    elm_object_text_set(btn, "Click me");
+   evas_object_move(btn, 50, 150);
    evas_object_resize(btn, 50, 25);
    elm_win_autodel_set(win, EINA_TRUE);
    evas_object_show(btn);
+   evas_object_smart_callback_add(btn, "clicked", show_about, bubble);
+
 
    //Show the parent
    evas_object_resize(win, 640, 480);