e_test_win: add startBGColor, stopBGColor 04/191804/4
authorJuyeon Lee <juyeonne.lee@samsung.com>
Wed, 24 Oct 2018 04:59:35 +0000 (13:59 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Wed, 31 Oct 2018 04:37:53 +0000 (13:37 +0900)
by calling this apis, test_win keep changes its background color

Change-Id: I79c74bea22f6323bf3b019f222a060c5e3933bb0

src/e_test_win.cpp
src/e_test_win.h

index 91f271a1254f3b489d1f1c29e2991b917e505197..b543e6d4d70e3ce2f2c278ddd49b3ed80771e510 100644 (file)
@@ -28,7 +28,6 @@ etWin::init(etWin *parent,
             E_TC_Win_Color color)
 {
    int screen_width = 0, screen_height = 0;
-   Evas_Object *bg = NULL;
 
    parent = parent;
 
@@ -45,23 +44,23 @@ etWin::init(etWin *parent,
    if (usr_geom)
      elm_win_aux_hint_add(elm_win, "wm.policy.win.user.geometry", "1");
 
-   bg = elm_bg_add(elm_win);
-   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   elm_win_resize_object_add(elm_win, bg);
+   this->bg.obj = elm_bg_add(elm_win);
+   evas_object_size_hint_weight_set(this->bg.obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(elm_win, this->bg.obj);
 
    switch (color)
      {
-      case E_TC_WIN_COLOR_BLACK:  elm_bg_color_set(bg,   0,   0,   0); break;
-      case E_TC_WIN_COLOR_WHITE:  elm_bg_color_set(bg, 255, 255, 255); break;
-      case E_TC_WIN_COLOR_RED:    elm_bg_color_set(bg, 255,   0,   0); break;
-      case E_TC_WIN_COLOR_GREEN:  elm_bg_color_set(bg,   0, 255,   0); break;
-      case E_TC_WIN_COLOR_BLUE:   elm_bg_color_set(bg,   0,   0, 255); break;
-      case E_TC_WIN_COLOR_YELLOW: elm_bg_color_set(bg, 255, 255,   0); break;
-      case E_TC_WIN_COLOR_CYAN:   elm_bg_color_set(bg,   0, 255, 255); break;
-      case E_TC_WIN_COLOR_PURPLE: elm_bg_color_set(bg, 255,   0, 255); break;
-      default:                    elm_bg_color_set(bg, 100, 100, 100); break;
+      case E_TC_WIN_COLOR_BLACK:  elm_bg_color_set(this->bg.obj,   0,   0,   0); break;
+      case E_TC_WIN_COLOR_WHITE:  elm_bg_color_set(this->bg.obj, 255, 255, 255); break;
+      case E_TC_WIN_COLOR_RED:    elm_bg_color_set(this->bg.obj, 255,   0,   0); break;
+      case E_TC_WIN_COLOR_GREEN:  elm_bg_color_set(this->bg.obj,   0, 255,   0); break;
+      case E_TC_WIN_COLOR_BLUE:   elm_bg_color_set(this->bg.obj,   0,   0, 255); break;
+      case E_TC_WIN_COLOR_YELLOW: elm_bg_color_set(this->bg.obj, 255, 255,   0); break;
+      case E_TC_WIN_COLOR_CYAN:   elm_bg_color_set(this->bg.obj,   0, 255, 255); break;
+      case E_TC_WIN_COLOR_PURPLE: elm_bg_color_set(this->bg.obj, 255,   0, 255); break;
+      default:                    elm_bg_color_set(this->bg.obj, 100, 100, 100); break;
      }
-   evas_object_show(bg);
+   evas_object_show(this->bg.obj);
 
    elm_win_screen_size_get(elm_win, NULL, NULL, &screen_width, &screen_height);
 
@@ -98,6 +97,12 @@ void etWin::deInit()
         eina_stringshare_del(name);
         name = NULL;
      }
+
+   if (this->bg.timer)
+     {
+        ecore_timer_del(this->bg.timer);
+        this->bg.timer = NULL;
+     }
 }
 
 void etWin::move(int x, int y)
@@ -115,3 +120,44 @@ void etWin::resize(int w, int h)
    elm_win_aux_hint_add(elm_win, "wm.policy.win.user.geometry", "1");
    evas_object_resize(elm_win, w, h);
 }
+
+static Eina_Bool _cb_timeout(void *data)
+{
+   int r = 0, g = 0, b = 0;
+   etWin *tw = (etWin *)data;
+   if (!tw) return EINA_FALSE;
+
+   elm_bg_color_get(tw->bg.obj, &r, &g, &b);
+   if (r)
+     {
+        r = (r + 10) % 255;
+        if (!r) r = 10;
+     }
+   if (g)
+     {
+        g = (g + 10) % 255;
+        if (!g) g = 10;
+     }
+   if (b)
+     {
+        b = (b + 10) % 255;
+        if (!b) b = 10;
+     }
+   elm_bg_color_set(tw->bg.obj, r, g, b);
+   evas_object_show(tw->bg.obj);
+   return EINA_TRUE;
+}
+
+void etWin::startBGColor(double time)
+{
+   ecore_timer_del(this->bg.timer);
+   this->bg.timer = ecore_timer_add(time,
+                                    _cb_timeout,
+                                    this);
+}
+
+void etWin::stopBGColor()
+{
+   ecore_timer_del(this->bg.timer);
+   this->bg.timer = NULL;
+}
index 87b6633c1d7d343d24b4f7ae22d73bef3bba3c59..9d4fbc8aeac86566afb8a3faf1fcb4f97a235420 100644 (file)
@@ -32,6 +32,11 @@ public: // TODO:: Change to private and add getter & setter
         Eina_Bool     win        = EINA_FALSE;
         Eina_Bool     obj        = EINA_FALSE;
      } Focus;
+   struct
+     {
+        Ecore_Timer      *timer    = NULL;
+        Evas_Object      *obj      = NULL;
+     } bg;
 
 public:
    etWin();
@@ -64,6 +69,8 @@ public:
      }
    void move(int x, int y);
    void resize(int w, int h);
+   void startBGColor(double time);
+   void stopBGColor();
 
    /* getter&setter */
    Evas_Object *getElmWin() { return elm_win; }