Add support for focus UI in InputPicker
authorMarcin Krakowiak <m.krakowiak@samsung.com>
Fri, 9 Jan 2015 13:30:59 +0000 (14:30 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
This commit is refactored merge from m34 branch.
Class InputPicker uses now ColorSelector widget from elm for select color.
H/W keyboard can now change values in InputPicker.

Original commit: http://165.213.202.130:8080/#/c/70449/

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9615

Change-Id: I8498e99bd45b4bd06d8f5ecca42a3af750e02625
Signed-off-by: Marcin Krakowiak <m.krakowiak@samsung.com>
tizen_src/impl/browser/inputpicker/InputPicker.cc
tizen_src/impl/browser/inputpicker/InputPicker.h
tizen_src/impl/eweb_view.cc
tizen_src/impl/resource/control.edc

index b8a00f7..36b6b8b 100755 (executable)
 
 #include "InputPicker.h"
 
-#include "base/path_service.h"
+#include <Ecore_X.h>
+#include <Elementary.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "base/files/file_path.h"
-#include "paths_efl.h"
 #include "base/logging.h"
+#include "base/path_service.h"
 #include "base/time/time.h"
 #include "content/public/browser/web_contents.h"
 #include "eweb_view.h"
+#include "paths_efl.h"
 
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <Elementary.h>
 #if defined(OS_TIZEN)
 #include <vconf/vconf.h>
 #endif
 #if defined(OS_TIZEN_MOBILE)
-#include <dlfcn.h>
 #include <efl_assist.h>
-extern void* EflAssistHandle;
 #endif
 
 using namespace tizen_webview;
 
 namespace content {
 
-static const unsigned maxDatetimeLength = 32;
-static const unsigned maxDateStringLength = 10;
 static const char defaultDatetimeFormat[] = "%Y/%m/%d %H:%M";
 
 struct InputPicker::Layout {
   Layout(Evas_Object *ewkView)
-    : ewk_view_(ewkView)
+    : ewk_view(ewkView)
+    , widget_win(0)
+    , layout_conformant(0)
     , popup(0)
     , layout(0)
-    , datePicker(0)
-    , colorRect(0)
-    , dataListEditField(0)
+    , date_picker(0)
+    , color_picker(0)
+    , color_rect(0)
+    , ok_button(0)
     , initial_r(0)
     , initial_g(0)
     , initial_b(0)
     , datetime_local(false) {
-    evas_object_focus_set(ewk_view_, false);
+    evas_object_focus_set(ewk_view, false);
 
     /* FIXME : Workaround. OSP requirement.
        OSP want to block own touch event while webkit internal picker is running. */
-    evas_object_smart_callback_call(ewk_view_, "input,picker,show", 0);
+    evas_object_smart_callback_call(ewk_view, "input,picker,show", 0);
   }
 
   ~Layout() {
+    DeleteWin();
+
     /* FIXME : Workaround. OSP requirement.
        OSP want to block own touch event while webkit internal picker is running. */
-    evas_object_smart_callback_call(ewk_view_, "input,picker,hide", 0);
+    evas_object_smart_callback_call(ewk_view, "input,picker,hide", 0);
+
+    evas_object_focus_set(ewk_view, true);
+  }
+
+  bool CreateWin() {
+    Evas_Object* top_widget = ewk_view;
+
+    if (Evas_Object *o = elm_object_parent_widget_get(ewk_view))
+      top_widget = o;
+    if (Evas_Object *o = elm_object_top_widget_get(top_widget))
+      top_widget = o;
+
+    if (!top_widget)
+      return false;
+
+    widget_win = elm_win_add(top_widget,
+                            "WebKit InputPicker Popup",
+                            ELM_WIN_BASIC);
+    if (!widget_win)
+      return false;
+
+    elm_win_alpha_set(widget_win, EINA_TRUE);
+    ecore_x_icccm_name_class_set(elm_win_xwindow_get(widget_win),
+                                 "APP_POPUP", "APP_POPUP");
+
+    if (elm_win_wm_rotation_supported_get(top_widget)) {
+      int preferredRotation = elm_win_wm_rotation_preferred_rotation_get(top_widget);
+      if (preferredRotation == -1) {
+        int rots[4] = {0, 90, 180, 270};
+        elm_win_wm_rotation_available_rotations_set(widget_win, rots, 4);
+      } else {
+        elm_win_wm_rotation_available_rotations_set(widget_win,
+                                                    &preferredRotation, 1);
+      }
+    }
+
+    Evas_Object* conformant = elm_conformant_add(widget_win);
+    if (!conformant)
+      return false;
+
+    evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    elm_win_resize_object_add(widget_win, conformant);
+    evas_object_show(conformant);
+
+    layout_conformant = elm_layout_add(conformant);
+    if (!layout_conformant)
+      return false;
+
+    elm_layout_theme_set(layout_conformant, "layout", "application", "default");
+    evas_object_size_hint_weight_set(layout_conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_show(layout_conformant);
+
+    elm_object_content_set(conformant, layout_conformant);
+    elm_win_conformant_set(widget_win, EINA_TRUE);
+
+    int width = 0;
+    int height = 0;
+    ecore_x_screen_size_get(ecore_x_default_screen_get(), &width, &height);
+
+    evas_object_resize(widget_win, width, height);
+    elm_win_focus_highlight_enabled_set(widget_win, EINA_TRUE);
+    elm_win_focus_highlight_style_set(widget_win, NULL);
+    evas_object_show(widget_win);
+
+    return true;
+  }
+
+  void DeleteWin() {
+    if (!widget_win)
+      return;
+
+    evas_object_del(widget_win);
+    widget_win = 0;
+  }
+
+  base::FilePath GetLayoutFile() {
+    base::FilePath edj_dir;
+    base::FilePath control_edj;
+    PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir);
+    control_edj = edj_dir.Append(FILE_PATH_LITERAL("control.edj"));
+    return control_edj;
+  }
+
+  void CreateDateTimeSelector(const char* title) {
+    popup = elm_popup_add(layout_conformant);
+    if (!popup)
+      return;
+
+    elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    elm_object_part_text_set(popup, "title,text", title);
+
+    date_picker = elm_datetime_add(layout_conformant);
+    if (!date_picker)
+      return;
+
+#if defined(OS_TIZEN)
+    layout = elm_datetime_picker_get(date_picker, ELM_DATETIME_DATE_PICKER);
+#else
+    layout = date_picker;
+#endif
+
+    elm_object_content_set(popup, layout);
+    elm_object_signal_emit(popup, "datepicker,show", "");
+  }
+
+  void CreateColorSelector() {
+    popup = elm_popup_add(widget_win);
+    if (!popup)
+      return;
+
+    elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+    elm_object_part_text_set(popup, "title,text", "Select color");
+    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+    base::FilePath control_edj = GetLayoutFile();
+
+    layout = elm_layout_add(popup);
+    if (!layout)
+      return;
+
+    elm_layout_file_set(layout, control_edj.AsUTF8Unsafe().c_str(),
+                        "colorselector_popup_layout");
+    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+    color_rect = evas_object_rectangle_add(evas_object_evas_get(layout));
+
+    if (color_rect) {
+      evas_object_size_hint_weight_set(color_rect,
+                                       EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+      evas_object_show(color_rect);
+      evas_object_color_set(color_rect, initial_r, initial_g, initial_b, 255);
+      elm_object_part_content_set(layout, "rect", color_rect);
+    }
+
+    BuildColorSelector();
+
+    evas_object_show(layout);
+    elm_object_content_set(popup, layout);
   }
 
-  Evas_Object* ewk_view_;
+  void BuildColorSelector() {
+    /* add color palette widget */
+    color_picker = elm_colorselector_add(layout);
+    if (!color_picker)
+      return;
+
+    elm_colorselector_mode_set(color_picker, ELM_COLORSELECTOR_PALETTE);
+    evas_object_size_hint_fill_set(color_picker, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    evas_object_size_hint_weight_set(color_picker, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+    Eina_List* color_list = elm_colorselector_palette_items_get(color_picker);
+    Eina_List* list = 0;
+    void* item = 0;
+    int r = 0;
+    int g = 0;
+    int b = 0;
+    int a = 0;
+    Elm_Object_Item* it = NULL;
+
+    EINA_LIST_FOREACH(color_list, list, item) {
+      if (item) {
+        elm_colorselector_palette_item_color_get((Elm_Object_Item*)item, &r, &g, &b, &a);
+        if (r == initial_r && g == initial_g && b == initial_b) {
+          it = (Elm_Object_Item*)item;
+          break;
+        }
+      }
+    }
+
+    if (!it)
+      it = (Elm_Object_Item*)eina_list_nth((Eina_List*)color_list, 0);
+
+    elm_object_item_signal_emit((Elm_Object_Item*)it, "elm,state,selected", "elm");
+
+    elm_object_part_content_set(layout, "colorpalette", color_picker);
+  }
+
+  void CreateOKButton() {
+    ok_button = elm_button_add(popup);
+    if (!ok_button)
+      return;
+
+    elm_object_style_set(ok_button, "popup");
+    elm_object_text_set(ok_button, "OK");
+    elm_object_part_content_set(popup, "button1", ok_button);
+  }
+
+  Evas_Object* ewk_view;
+  Evas_Object* widget_win;
+  Evas_Object* layout_conformant;
   Evas_Object* popup;
   Evas_Object* layout;
-  Evas_Object* datePicker;
-  Evas_Object* colorRect;
-  Evas_Object* okButton;
-  Evas_Object* dataListEditField;
+  Evas_Object* date_picker;
+  Evas_Object* color_picker;
+  Evas_Object* color_rect;
+  Evas_Object* ok_button;
   int initial_r;
   int initial_g;
   int initial_b;
   bool datetime_local;
 };
 
-struct ColorPopupUserData {
-  InputPicker* inputPicker;
-  Evas_Object* colorRect;
-  Evas_Object* color;
-  Evas_Object* colorAccessObject;
-};
-
-struct Input_Date {
-  int year;
-  int mon;
-  int day;
-  int hour;
-  int min;
-  int sec;
-};
-
-struct Input_Date_Str {
-  char year[maxDateStringLength];
-  char mon[maxDateStringLength];
-  char day[maxDateStringLength];
-  char hour[maxDateStringLength];
-  char min[maxDateStringLength];
-  char sec[maxDateStringLength];
-};
-
-static char* datetimeFormat() {
+static char* DateTimeFormat() {
 #if defined(OS_TIZEN)
-  char* datetimeFormat = NULL;
+  char* dateTimeFormat = NULL;
   char* regionFormat = NULL;
   char* language = NULL;
   char buf[256] = { 0, };
@@ -151,7 +317,7 @@ static char* datetimeFormat() {
     }
   }
 
-  datetimeFormat = dgettext("dt_fmt", buf);
+  dateTimeFormat = dgettext("dt_fmt", buf);
 
   if(!language || !strcmp(language, ""))
     unsetenv("LANGUAGE");
@@ -160,260 +326,136 @@ static char* datetimeFormat() {
 
   // FIXME: Workaround fix for not supported dt_fmt.
   // Use default format if dt_fmt string is not exist.
-  if (strlen(datetimeFormat) == strlen(buf) &&
-      !strncmp(datetimeFormat, buf, strlen(buf))) {
+  if (strlen(dateTimeFormat) == strlen(buf) &&
+      !strncmp(dateTimeFormat, buf, strlen(buf))) {
     return 0;
   }
 
-  return strdup(datetimeFormat);
+  return strdup(dateTimeFormat);
 #else
   return NULL;
 #endif
 }
 
 InputPicker::InputPicker(EWebView& web_view_)
-    : ewk_view_(web_view_.evas_object())
-    , picker_layout_(0)
-    , data_list_(0)
-    , web_view_(web_view_) {
+    : web_view_(web_view_)
+    , ewk_view_(web_view_.evas_object())
+    , picker_layout_(0) {
 }
 
 InputPicker::~InputPicker() {
-  if (picker_layout_) {
-    if (picker_layout_->popup)
-      evas_object_del(picker_layout_->popup);
-    delete picker_layout_;
-  }
+  DeletePicker();
+}
+
+void InputPicker::DeletePicker() {
+  if (!picker_layout_)
+    return;
+
+  delete picker_layout_;
+  picker_layout_ = 0;
 }
 
 #if defined(OS_TIZEN_MOBILE)
-void InputPicker::endEditingCallback(
+void InputPicker::EndEditingCallback(
     void* data, Evas_Object* obj, void* event_info)
 {
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
   if (inputPicker)
-    inputPicker->removeDatetimePickerDelayed();
+    inputPicker->RemoveDatetimePickerDelayed();
 }
 #endif
 
-void InputPicker::showDatePicker(
+void InputPicker::ShowDatePicker(
     tizen_webview::Input_Type input_type, double input_date) {
   web_view_.ExecuteEditCommand("Unselect", 0);
 
   if (input_type == TW_INPUT_TYPE_DATE)
-    showDatePopup(input_date);
+    ShowDatePopup(input_date);
   else if (input_type == TW_INPUT_TYPE_TIME)
-    showTimePopup(input_date);
+    ShowTimePopup(input_date);
   else if (input_type == TW_INPUT_TYPE_DATETIME)
-    showDatetimePopup(input_date, false);
+    ShowDatetimePopup(input_date, false);
   else if (input_type == TW_INPUT_TYPE_DATETIMELOCAL)
-    showDatetimePopup(input_date, true);
+    ShowDatetimePopup(input_date, true);
   else if (input_type == TW_INPUT_TYPE_MONTH)
-    showMonthPopup(input_date);
+    ShowMonthPopup(input_date);
   else if (input_type == TW_INPUT_TYPE_WEEK)
-    showWeekPopup(input_date);
+    ShowWeekPopup(input_date);
 }
 
-void InputPicker::showColorPicker(int r, int g, int b, int alpha) {
-    if (!picker_layout_)
+void InputPicker::ShowColorPicker(int r, int g, int b, int alpha) {
+  if (picker_layout_) {
+    // Just update the value.
+    if (picker_layout_->color_picker)
+      elm_colorselector_color_set(picker_layout_->color_picker, r, g, b, alpha);
+    evas_object_focus_set(picker_layout_->ok_button, true);
+    return;
+  }
+
   picker_layout_ = new InputPicker::Layout(ewk_view_);
-  picker_layout_->popup = elm_popup_add(ewk_view_);
-  elm_object_part_text_set(picker_layout_->popup, "title,text", "Select color");
+
+  if (!picker_layout_->CreateWin())
+    return;
 
   picker_layout_->initial_r = r;
   picker_layout_->initial_g = g;
   picker_layout_->initial_b = b;
-#if defined(OS_TIZEN_MOBILE)
-  if (EflAssistHandle) {
-    void (*webkit_ea_object_event_callback_add)(
-        Evas_Object *,
-        Ea_Callback_Type,
-        Ea_Event_Cb func,
-        void *);
-    webkit_ea_object_event_callback_add = (void (*)(
-        Evas_Object *,
-        Ea_Callback_Type,
-        Ea_Event_Cb func,
-        void *)) dlsym(EflAssistHandle, "ea_object_event_callback_add");
-    (*webkit_ea_object_event_callback_add)(
-        picker_layout_->popup, EA_CALLBACK_BACK, handleBackKeyColorPicker, this);
-  }
-#endif
-
-  picker_layout_->layout = elm_layout_add(picker_layout_->popup);
-
-  base::FilePath edj_dir;
-  base::FilePath control_edj;
-  PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir);
-  control_edj = edj_dir.Append(FILE_PATH_LITERAL("control.edj"));
-
-  elm_layout_file_set(
-      picker_layout_->layout,
-      control_edj.AsUTF8Unsafe().c_str(),
-      "color_picker");
-  evas_object_size_hint_weight_set(
-      picker_layout_->layout,
-      EVAS_HINT_EXPAND,
-      EVAS_HINT_EXPAND);
-  evas_object_show(picker_layout_->layout);
-  elm_object_content_set(picker_layout_->popup, picker_layout_->layout);
-
-  picker_layout_->colorRect = evas_object_rectangle_add(
-      evas_object_evas_get(picker_layout_->layout));
-  evas_object_size_hint_weight_set(
-      picker_layout_->colorRect,
-      EVAS_HINT_EXPAND,
-      EVAS_HINT_EXPAND);
-  evas_object_show(picker_layout_->colorRect);
-
-  evas_object_color_set(picker_layout_->colorRect, r, g, b, 255);
-  elm_object_part_content_set(
-      picker_layout_->layout,
-      "elm.swallow.color_rect",
-      picker_layout_->colorRect);
-
-  static ColorPopupUserData color1Data;
-  addColorRect("elm.swallow.color1", 128, 0, 0, &color1Data);
-
-  static ColorPopupUserData color2Data;
-  addColorRect("elm.swallow.color2", 255, 0, 128, &color2Data);
-
-  static ColorPopupUserData color3Data;
-  addColorRect("elm.swallow.color3", 255, 0, 0, &color3Data);
-
-  static ColorPopupUserData color4Data;
-  addColorRect("elm.swallow.color4", 255, 127, 39, &color4Data);
-
-  static ColorPopupUserData color5Data;
-  addColorRect("elm.swallow.color5", 255, 255, 0, &color5Data);
-
-  static ColorPopupUserData color6Data;
-  addColorRect("elm.swallow.color6", 0, 255, 0, &color6Data);
-
-  static ColorPopupUserData color7Data;
-  addColorRect("elm.swallow.color7", 0, 255, 255, &color7Data);
-
-  static ColorPopupUserData color8Data;
-  addColorRect("elm.swallow.color8", 0, 0, 255, &color8Data);
-
-  static ColorPopupUserData color9Data;
-  addColorRect("elm.swallow.color9", 0, 0, 128, &color9Data);
-
-  static ColorPopupUserData color10Data;
-  addColorRect("elm.swallow.color10", 64, 0, 64, &color10Data);
 
-  static ColorPopupUserData color11Data;
-  addColorRect("elm.swallow.color11", 153, 217, 234, &color11Data);
+  picker_layout_->CreateColorSelector();
 
-  static ColorPopupUserData color12Data;
-  addColorRect("elm.swallow.color12", 128, 128, 128, &color12Data);
-
-  static ColorPopupUserData color13Data;
-  addColorRect("elm.swallow.color13", 0, 0, 0, &color13Data);
-
-  static ColorPopupUserData color14Data;
-  addColorRect("elm.swallow.color14", 255, 255, 255, &color14Data);
-
-  // Set focus on first color rect.
-  if (color1Data.colorAccessObject)
-    elm_object_focus_set(color1Data.colorAccessObject, true);
+  evas_object_smart_callback_add(picker_layout_->color_picker, "color,item,selected",
+                                 SelectedColorCallback, picker_layout_->color_rect);
+#if defined(OS_TIZEN_MOBILE)
+  ea_object_event_callback_add(picker_layout_->popup, EA_CALLBACK_BACK,
+                               HandleBackKeyColorPicker, this);
+#endif
 
-  picker_layout_->okButton = elm_button_add(picker_layout_->popup);
-  elm_object_style_set(picker_layout_->okButton, "popup");
-  elm_object_text_set(picker_layout_->okButton, "OK");
-  elm_object_part_content_set(
-      picker_layout_->popup,
-      "button1",
-      picker_layout_->okButton);
+  picker_layout_->CreateOKButton();
   evas_object_smart_callback_add(
-      picker_layout_->okButton,
+      picker_layout_->ok_button,
       "clicked",
-      colorPickerCallback,
+      ColorPickerCallback,
       this);
 
   evas_object_show(picker_layout_->popup);
 }
 
-void InputPicker::hideColorPicker() {
+void InputPicker::HideColorPicker() {
   if (!picker_layout_)
     return;
 
   web_view_.web_contents().DidEndColorChooser();
 
-  if (picker_layout_->popup) {
-    evas_object_del(picker_layout_->popup);
-    picker_layout_->popup = 0;
-  }
-
   delete picker_layout_;
   picker_layout_ = 0;
 }
 
-void InputPicker::keyDownColorPickerCallback(
-    void* data, Evas* evas, Evas_Object* obj, void* event_info) {
-  Evas_Event_Key_Down *event = (Evas_Event_Key_Down *)event_info;
-  if (!strncmp("Return", event->keyname, 6) ||
-      !strncmp("space", event->keyname, 5)) {
-    ColorPopupUserData* color_data = static_cast<ColorPopupUserData*>(data);
-    color_data->inputPicker->selectedColorCallback(data, 0, 0, 0);
-  }
-}
-
-void InputPicker::selectedColorCallback(
-    void* data, Evas* evas, Evas_Object* obj, void* event_info) {
+void InputPicker::SelectedColorCallback(
+    void* data, Evas_Object* obj, void* event_info) {
   int r = 0;
   int g = 0;
   int b = 0;
   int a = 0;
 
-  ColorPopupUserData* color_data = static_cast<ColorPopupUserData*>(data);
-  evas_object_color_get(color_data->color, &r, &g, &b, &a);
-  evas_object_color_set(color_data->colorRect, r, g, b, a);
-  elm_object_focus_set(color_data->colorAccessObject, true);
+  Elm_Object_Item *color_it = static_cast<Elm_Object_Item *>(event_info);
+  elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
+  evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b, a);
 }
 
-void InputPicker::addColorRect(
-    const char* part, int r, int g, int b, ColorPopupUserData* color_data) {
-#if defined(OS_TIZEN)
-  Evas_Object* color = evas_object_rectangle_add(evas_object_evas_get(
-      picker_layout_->layout));
-  evas_object_size_hint_weight_set(color, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-  evas_object_color_set(color, r, g, b, 255);
-  elm_object_part_content_set(picker_layout_->layout, part, color);
-  evas_object_show(color);
-
-  Evas_Object* accessObject = elm_access_object_register(
-      color, picker_layout_->layout);
-  elm_object_focus_custom_chain_append(
-      picker_layout_->layout, accessObject, NULL);
-
-  color_data->inputPicker = this;
-  color_data->colorRect = picker_layout_->colorRect;
-  color_data->color = color;
-  color_data->colorAccessObject = accessObject;
-
-  evas_object_event_callback_add(
-      accessObject, EVAS_CALLBACK_KEY_DOWN, keyDownColorPickerCallback,
-      color_data);
-  evas_object_event_callback_add(
-      color, EVAS_CALLBACK_MOUSE_DOWN, selectedColorCallback, color_data);
-#endif
-}
-
-void InputPicker::colorPickerCallback(
+void InputPicker::ColorPickerCallback(
     void* data,  Evas_Object* obj, void* event_info) {
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
 
   int r(0), g(0), b(0), a(0);
-  evas_object_color_get(inputPicker->picker_layout_->colorRect, &r, &g, &b, &a);
+  evas_object_color_get(inputPicker->picker_layout_->color_rect, &r, &g, &b, &a);
 
   inputPicker->web_view_.web_contents().DidChooseColorInColorChooser(
       SkColorSetARGB(a, r, g, b));
-  inputPicker->hideColorPicker();
+  inputPicker->HideColorPicker();
 }
 
 #if defined(OS_TIZEN_MOBILE)
-void InputPicker::handleBackKeyColorPicker(
+void InputPicker::HandleBackKeyColorPicker(
     void* data,  Evas_Object* obj, void* event_info) {
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
 
@@ -425,199 +467,151 @@ void InputPicker::handleBackKeyColorPicker(
   inputPicker->web_view_.web_contents().DidChooseColorInColorChooser(
       SkColorSetARGB(a, r, g, b));
 
-  inputPicker->hideColorPicker();
+  inputPicker->HideColorPicker();
 }
 #endif
 
-void InputPicker::showDatePopup(double input_date) {
-  time_t cur_time;
+namespace {
+
+struct tm* GetTime(time_t &cur_time, double input_date) {
   struct tm* currentTime;
 
   if (isnan(input_date)) {
     time(&cur_time);
-    currentTime = localtime(&cur_time);
   } else {
     base::Time doubleT = base::Time::FromDoubleT(input_date/1000);
     cur_time = doubleT.ToTimeT();
-    currentTime = localtime(&cur_time);
   }
+  currentTime = localtime(&cur_time);
+  return currentTime;
+}
+
+} // namespace
+
+void InputPicker::ShowDatePopup(double input_date) {
+  time_t cur_time;
+  struct tm* currentTime = GetTime(cur_time, input_date);
 
   if (picker_layout_) {
     // Just update the value.
-    elm_datetime_value_set(picker_layout_->datePicker, currentTime);
-    evas_object_focus_set(picker_layout_->okButton, true);
+    elm_datetime_value_set(picker_layout_->date_picker, currentTime);
+    evas_object_focus_set(picker_layout_->ok_button, true);
     return;
   }
 
   picker_layout_ = new InputPicker::Layout(ewk_view_);
-  createPopupLayout("Set Date", currentTime);
+  CreatePopupLayout("Set Date", currentTime);
 
-  picker_layout_->okButton = elm_button_add(picker_layout_->popup);
-  elm_object_style_set(picker_layout_->okButton, "popup");
-  elm_object_text_set(picker_layout_->okButton, "OK");
-  elm_object_part_content_set(
-      picker_layout_->popup, "button1", picker_layout_->okButton);
-  evas_object_focus_set(picker_layout_->okButton, true);
+  evas_object_focus_set(picker_layout_->ok_button, true);
 
   evas_object_smart_callback_add(
-      picker_layout_->okButton, "clicked", datePopupCallback, this);
+      picker_layout_->ok_button, "clicked", DatePopupCallback, this);
+
   elm_object_content_set(picker_layout_->popup, picker_layout_->layout);
   evas_object_show(picker_layout_->popup);
 }
 
-void InputPicker::showWeekPopup(double input_date) {
+void InputPicker::ShowWeekPopup(double input_date) {
   time_t cur_time;
-  struct tm* currentTime;
-
-  if (isnan(input_date)) {
-    time(&cur_time);
-    currentTime = localtime(&cur_time);
-  } else {
-    base::Time doubleT = base::Time::FromDoubleT(input_date/1000);
-    cur_time = doubleT.ToTimeT();
-    currentTime = localtime(&cur_time);
-  }
+  struct tm* currentTime = GetTime(cur_time, input_date);
 
   if (picker_layout_) {
     // Just update the value.
-    elm_datetime_value_set(picker_layout_->datePicker, currentTime);
-    evas_object_focus_set(picker_layout_->okButton, true);
+    elm_datetime_value_set(picker_layout_->date_picker, currentTime);
+    evas_object_focus_set(picker_layout_->ok_button, true);
     return;
   }
 
   picker_layout_ = new InputPicker::Layout(ewk_view_);
-  createPopupLayout("Set Week", currentTime);
+  CreatePopupLayout("Set Week", currentTime);
 
-  picker_layout_->okButton = elm_button_add(picker_layout_->popup);
-  elm_object_style_set(picker_layout_->okButton, "popup");
-  elm_object_text_set(picker_layout_->okButton, "OK");
-  elm_object_part_content_set(
-      picker_layout_->popup, "button1", picker_layout_->okButton);
-  evas_object_focus_set(picker_layout_->okButton, true);
+  evas_object_focus_set(picker_layout_->ok_button, true);
 
   evas_object_smart_callback_add(
-      picker_layout_->okButton, "clicked", weekPopupCallback, this);
+      picker_layout_->ok_button, "clicked", WeekPopupCallback, this);
   elm_object_content_set(picker_layout_->popup, picker_layout_->layout);
   evas_object_show(picker_layout_->popup);
 }
 
-void InputPicker::showTimePopup(double input_date) {
+void InputPicker::ShowTimePopup(double input_date) {
   time_t cur_time;
-  struct tm* currentTime;
+  struct tm* currentTime = GetTime(cur_time, input_date);
 
-  if (isnan(input_date)) {
-    time(&cur_time);
-    currentTime = localtime(&cur_time);
-  } else {
-    base::Time doubleT = base::Time::FromDoubleT(input_date/1000);
-    cur_time = doubleT.ToTimeT();
-    currentTime = localtime(&cur_time);
-    currentTime->tm_hour = currentTime->tm_hour - 1;
-  }
+  if (!isnan(input_date))
+    currentTime->tm_hour -= 1;
 
   if (picker_layout_) {
     // Just update the value.
-    elm_datetime_value_set(picker_layout_->datePicker, currentTime);
-    evas_object_focus_set(picker_layout_->okButton, true);
+    elm_datetime_value_set(picker_layout_->date_picker, currentTime);
+    evas_object_focus_set(picker_layout_->ok_button, true);
     return;
   }
 
   picker_layout_ = new InputPicker::Layout(ewk_view_);
-  createPopupLayout("Set Time", currentTime);
-  elm_object_style_set(picker_layout_->datePicker, "time_layout");
+  CreatePopupLayout("Set Time", currentTime);
+  elm_object_style_set(picker_layout_->date_picker, "time_layout");
 
-  picker_layout_->okButton = elm_button_add(picker_layout_->popup);
-  elm_object_style_set(picker_layout_->okButton, "popup");
-  elm_object_text_set(picker_layout_->okButton, "OK");
-  elm_object_part_content_set(
-      picker_layout_->popup, "button1", picker_layout_->okButton);
-  evas_object_focus_set(picker_layout_->okButton, true);
+  evas_object_focus_set(picker_layout_->ok_button, true);
 
   evas_object_smart_callback_add(
-      picker_layout_->okButton, "clicked", timePopupCallback, this);
+      picker_layout_->ok_button, "clicked", TimePopupCallback, this);
   elm_object_content_set(picker_layout_->popup, picker_layout_->layout);
   evas_object_show(picker_layout_->popup);
 }
 
-void InputPicker::showMonthPopup(double input_date) {
+void InputPicker::ShowMonthPopup(double input_date) {
   time_t cur_time;
-  struct tm* currentTime;
-
-  if (isnan(input_date)) {
-    time(&cur_time);
-    currentTime = localtime(&cur_time);
-  } else {
-    base::Time doubleT = base::Time::FromDoubleT(input_date/1000);
-    cur_time = doubleT.ToTimeT();
-    currentTime = localtime(&cur_time);
-  }
+  struct tm* currentTime = GetTime(cur_time, input_date);
 
   if (picker_layout_) {
     // Just update the value.
-    elm_datetime_value_set(picker_layout_->datePicker, currentTime);
-    evas_object_focus_set(picker_layout_->okButton, true);
+    elm_datetime_value_set(picker_layout_->date_picker, currentTime);
+    evas_object_focus_set(picker_layout_->ok_button, true);
     return;
   }
 
   picker_layout_ = new InputPicker::Layout(ewk_view_);
-  createPopupLayout("Set Month", currentTime);
+  CreatePopupLayout("Set Month", currentTime);
 
-  picker_layout_->okButton = elm_button_add(picker_layout_->popup);
-  elm_object_style_set(picker_layout_->okButton, "popup");
-  elm_object_text_set(picker_layout_->okButton, "OK");
-  elm_object_part_content_set(
-      picker_layout_->popup, "button1", picker_layout_->okButton);
-  evas_object_focus_set(picker_layout_->okButton, true);
+  evas_object_focus_set(picker_layout_->ok_button, true);
 
   evas_object_smart_callback_add(
-      picker_layout_->okButton, "clicked", monthPopupCallback, this);
+      picker_layout_->ok_button, "clicked", MonthPopupCallback, this);
   elm_object_content_set(picker_layout_->popup, picker_layout_->layout);
   evas_object_show(picker_layout_->popup);
 }
 
-void InputPicker::showDatetimePopup(double input_date, bool datetime_local) {
+void InputPicker::ShowDatetimePopup(double input_date, bool datetime_local) {
   time_t cur_time;
-  struct tm* currentTime;
+  struct tm* currentTime = GetTime(cur_time, input_date);
 
-  if (isnan(input_date)) {
-    time(&cur_time);
-    currentTime = localtime(&cur_time);
-  } else {
-    base::Time doubleT = base::Time::FromDoubleT(input_date/1000);
-    cur_time = doubleT.ToTimeT();
-    currentTime = localtime(&cur_time);
-    currentTime->tm_hour = currentTime->tm_hour - 2;
-  }
+  if (!isnan(input_date))
+    currentTime->tm_hour -= 2;
 
   if (picker_layout_) {
     // Just update the value.
     picker_layout_->datetime_local = datetime_local;
 
-    elm_datetime_value_set(picker_layout_->datePicker, currentTime);
-    evas_object_focus_set(picker_layout_->okButton, true);
+    elm_datetime_value_set(picker_layout_->date_picker, currentTime);
+    evas_object_focus_set(picker_layout_->ok_button, true);
     return;
   }
 
   picker_layout_ = new InputPicker::Layout(ewk_view_);
   picker_layout_->datetime_local = datetime_local;
 
-  createPopupLayout("Set date and time", currentTime);
+  CreatePopupLayout("Set date and time", currentTime);
 
-  picker_layout_->okButton = elm_button_add(picker_layout_->popup);
-  elm_object_style_set(picker_layout_->okButton, "popup");
-  elm_object_text_set(picker_layout_->okButton, "OK");
-  elm_object_part_content_set(
-      picker_layout_->popup, "button1", picker_layout_->okButton);
-  evas_object_focus_set(picker_layout_->okButton, true);
+  evas_object_focus_set(picker_layout_->ok_button, true);
 
   evas_object_smart_callback_add(
-      picker_layout_->okButton, "clicked", datetimePopupCallback, this);
+      picker_layout_->ok_button, "clicked", DateTimePopupCallback, this);
   elm_object_content_set(picker_layout_->popup, picker_layout_->layout);
   evas_object_show(picker_layout_->popup);
 
 }
 
-Eina_Bool InputPicker::removeDatetimePicker(void* data) {
+Eina_Bool InputPicker::RemoveDatetimePicker(void* data) {
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
   inputPicker->web_view_.web_contents().DidCancelDialog();
 
@@ -626,87 +620,53 @@ Eina_Bool InputPicker::removeDatetimePicker(void* data) {
 
   inputPicker->web_view_.ExecuteEditCommand("Unselect", 0);
 
-  inputPicker->deletePopupLayout();
-  delete inputPicker->picker_layout_;
-  inputPicker->picker_layout_ = 0;
+  inputPicker->DeletePicker();
 
   return ECORE_CALLBACK_CANCEL;
 }
 
-void InputPicker::removeDatetimePickerDelayed() {
-  ecore_timer_add(0.1, removeDatetimePicker, this);
+void InputPicker::RemoveDatetimePickerDelayed() {
+  ecore_timer_add(0.1, RemoveDatetimePicker, this);
 }
 
-void InputPicker::createPopupLayout(const char* title, struct tm* currentTime) {
-  picker_layout_->popup = elm_popup_add(ewk_view_);
-  evas_object_size_hint_weight_set(
-      picker_layout_->popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-  elm_object_part_text_set(picker_layout_->popup, "title,text", title);
+void InputPicker::CreatePopupLayout(const char* title, struct tm* currentTime) {
+  if (!picker_layout_->CreateWin())
+    return;
+
+  picker_layout_->CreateDateTimeSelector(title);
 
 #if defined(OS_TIZEN_MOBILE)
-  if (EflAssistHandle) {
-    void (*webkit_ea_object_event_callback_add)(
-        Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
-    webkit_ea_object_event_callback_add = (void (*)(
-        Evas_Object *,
-        Ea_Callback_Type ,
-        Ea_Event_Cb func,
-        void *)) dlsym(EflAssistHandle, "ea_object_event_callback_add");
-    (*webkit_ea_object_event_callback_add)(
-        picker_layout_->popup, EA_CALLBACK_BACK, handleBackKeyDatePicker, this);
-  }
+  ea_object_event_callback_add(picker_layout_->popup, EA_CALLBACK_BACK,
+                               HandleBackKeyDatePicker, this);
 #endif
 
-  base::FilePath edj_dir;
-  base::FilePath control_edj;
-  PathService::Get(PathsEfl::EDJE_RESOURCE_DIR, &edj_dir);
-  control_edj = edj_dir.Append(FILE_PATH_LITERAL("control.edj"));
-
-
-  picker_layout_->layout = elm_layout_add(picker_layout_->popup);
-  elm_layout_file_set(
-      picker_layout_->layout,
-      control_edj.AsUTF8Unsafe().c_str(),
-      "datetime_popup");
-  evas_object_size_hint_weight_set(
-      picker_layout_->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-  picker_layout_->datePicker = elm_datetime_add(picker_layout_->layout);
-  elm_object_part_content_set(
-      picker_layout_->layout,
-      "elm.swallow.datetime",
-      picker_layout_->datePicker);
-
-  char* format = datetimeFormat();
+  char* format = DateTimeFormat();
   if (format) {
-    elm_datetime_format_set(picker_layout_->datePicker, format);
+    elm_datetime_format_set(picker_layout_->date_picker, format);
     free(format);
   } else
-    elm_datetime_format_set(picker_layout_->datePicker, defaultDatetimeFormat);
+    elm_datetime_format_set(picker_layout_->date_picker, defaultDatetimeFormat);
 
-  elm_datetime_value_set(picker_layout_->datePicker, currentTime);
+  elm_datetime_value_set(picker_layout_->date_picker, currentTime);
 
 #if defined(OS_TIZEN_MOBILE)
   evas_object_smart_callback_add(
-      picker_layout_->datePicker, "edit,end", endEditingCallback, 0);
+      picker_layout_->date_picker, "edit,end", EndEditingCallback, 0);
 #endif
-}
 
-void InputPicker::deletePopupLayout() {
-  if(picker_layout_->popup){
-    evas_object_del(picker_layout_->popup);
-    picker_layout_->popup = 0;
-  }
+  picker_layout_->CreateOKButton();
+
+  evas_object_show(picker_layout_->popup);
 }
 
-void InputPicker::datePopupCallback(
+void InputPicker::DatePopupCallback(
     void* data,  Evas_Object* obj, void* event_info) {
   struct tm currentTime;
   memset(&currentTime, 0, sizeof(struct tm));
 
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
 
-  elm_datetime_value_get(inputPicker->picker_layout_->datePicker, &currentTime);
+  elm_datetime_value_get(inputPicker->picker_layout_->date_picker, &currentTime);
   mktime(&currentTime);
 
   char dateStr[20] = { 0, };
@@ -715,19 +675,17 @@ void InputPicker::datePopupCallback(
   inputPicker->web_view_.web_contents().DidReplaceDateTime(std::string(dateStr));
   inputPicker->web_view_.ExecuteEditCommand("Unselect", 0);
 
-  inputPicker->deletePopupLayout();
-  delete inputPicker->picker_layout_;
-  inputPicker->picker_layout_ = 0;
+  inputPicker->DeletePicker();
 }
 
-void InputPicker::weekPopupCallback(
+void InputPicker::WeekPopupCallback(
     void* data,  Evas_Object* obj, void* event_info) {
   struct tm currentTime;
   memset(&currentTime, 0, sizeof(struct tm));
 
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
 
-  elm_datetime_value_get(inputPicker->picker_layout_->datePicker, &currentTime);
+  elm_datetime_value_get(inputPicker->picker_layout_->date_picker, &currentTime);
   mktime(&currentTime);
 
   char dateStr[20] = { 0, };
@@ -736,19 +694,17 @@ void InputPicker::weekPopupCallback(
   inputPicker->web_view_.web_contents().DidReplaceDateTime(std::string(dateStr));
   inputPicker->web_view_.ExecuteEditCommand("Unselect", 0);
 
-  inputPicker->deletePopupLayout();
-  delete inputPicker->picker_layout_;
-  inputPicker->picker_layout_ = 0;
+  inputPicker->DeletePicker();
 }
 
-void InputPicker::timePopupCallback(
+void InputPicker::TimePopupCallback(
     void* data,  Evas_Object* obj, void* event_info) {
   struct tm currentTime;
   memset(&currentTime, 0, sizeof(struct tm));
 
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
 
-  elm_datetime_value_get(inputPicker->picker_layout_->datePicker, &currentTime);
+  elm_datetime_value_get(inputPicker->picker_layout_->date_picker, &currentTime);
   mktime(&currentTime);
 
   char dateStr[20] = { 0, };
@@ -757,12 +713,10 @@ void InputPicker::timePopupCallback(
   inputPicker->web_view_.web_contents().DidReplaceDateTime(std::string(dateStr));
   inputPicker->web_view_.ExecuteEditCommand("Unselect", 0);
 
-  inputPicker->deletePopupLayout();
-  delete inputPicker->picker_layout_;
-  inputPicker->picker_layout_ = 0;
+  inputPicker->DeletePicker();
 }
 
-void InputPicker::monthPopupCallback(
+void InputPicker::MonthPopupCallback(
     void* data,  Evas_Object* obj, void* event_info) {
   struct tm currentTime;
   memset(&currentTime, 0, sizeof(struct tm));
@@ -770,7 +724,7 @@ void InputPicker::monthPopupCallback(
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
   mktime(&currentTime);
 
-  elm_datetime_value_get(inputPicker->picker_layout_->datePicker, &currentTime);
+  elm_datetime_value_get(inputPicker->picker_layout_->date_picker, &currentTime);
 
   char dateStr[20] = { 0, };
   strftime(dateStr, 20, "%Y-%m", &currentTime);
@@ -778,19 +732,17 @@ void InputPicker::monthPopupCallback(
   inputPicker->web_view_.web_contents().DidReplaceDateTime(std::string(dateStr));
   inputPicker->web_view_.ExecuteEditCommand("Unselect", 0);
 
-  inputPicker->deletePopupLayout();
-  delete inputPicker->picker_layout_;
-  inputPicker->picker_layout_ = 0;
+  inputPicker->DeletePicker();
 }
 
-void InputPicker::datetimePopupCallback(
+void InputPicker::DateTimePopupCallback(
     void* data,  Evas_Object* obj, void* event_info) {
   struct tm currentTime;
   memset(&currentTime, 0, sizeof(struct tm));
 
   InputPicker* inputPicker = static_cast<InputPicker*>(data);
 
-  elm_datetime_value_get(inputPicker->picker_layout_->datePicker, &currentTime);
+  elm_datetime_value_get(inputPicker->picker_layout_->date_picker, &currentTime);
   mktime(&currentTime);
 
   char dateStr[50] = { 0, };
@@ -802,15 +754,13 @@ void InputPicker::datetimePopupCallback(
   inputPicker->web_view_.web_contents().DidReplaceDateTime(std::string(dateStr));
   inputPicker->web_view_.ExecuteEditCommand("Unselect", 0);
 
-  inputPicker->deletePopupLayout();
-  delete inputPicker->picker_layout_;
-  inputPicker->picker_layout_ = 0;
+  inputPicker->DeletePicker();
 }
 
 #if defined(OS_TIZEN_MOBILE)
-void InputPicker::handleBackKeyDatePicker(
+void InputPicker::HandleBackKeyDatePicker(
     void* data, Evas_Object* obj, void* event_info) {
-  removeDatetimePicker(data);
+  RemoveDatetimePicker(data);
 }
 #endif
 
index 0e13592..24fc28f 100755 (executable)
@@ -23,55 +23,51 @@ class InputPicker {
     explicit InputPicker(EWebView& web_view_);
     ~InputPicker();
 
-    void showDatePicker(
+    void ShowDatePicker(
         tizen_webview::Input_Type input_type, double input_date);
-    void showColorPicker(int r, int g, int b, int alpha);
-    void hideColorPicker();
+    void ShowColorPicker(int r, int g, int b, int alpha);
+    void HideColorPicker();
 
   private:
     struct Layout;
 
-    void showDatePopup(double input_date);
-    void showTimePopup(double input_date);
-    void showMonthPopup(double input_date);
-    void showWeekPopup(double input_date);
-    void showDatetimePopup(double input_date, bool datetimeLocal);
-    void removeDatetimePickerDelayed();
-    void createPopupLayout(const char* title, struct tm* currentTime);
-    void deletePopupLayout();
-    void addColorRect(
-        const char* part, int r, int g, int b, ColorPopupUserData* color_data);
+    void DeletePicker();
 
-    static void datePopupCallback(
+    void ShowDatePopup(double input_date);
+    void ShowTimePopup(double input_date);
+    void ShowMonthPopup(double input_date);
+    void ShowWeekPopup(double input_date);
+    void ShowDatetimePopup(double input_date, bool datetimeLocal);
+    void RemoveDatetimePickerDelayed();
+    void CreatePopupLayout(const char* title, struct tm* currentTime);
+
+    static void DatePopupCallback(
+        void* data, Evas_Object* obj, void* event_info);
+    static void TimePopupCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static void timePopupCallback(
+    static void MonthPopupCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static void monthPopupCallback(
+    static void WeekPopupCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static void weekPopupCallback(
+    static void DateTimePopupCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static void datetimePopupCallback(
+    static void EndEditingCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static void endEditingCallback(
+    static Eina_Bool RemoveDatetimePicker(void* data);
+    static void ColorPickerCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static Eina_Bool removeDatetimePicker(void* data);
-    static void colorPickerCallback(
+    static void SelectedColorCallback(
         void* data, Evas_Object* obj, void* event_info);
-    static void selectedColorCallback(
-        void* data, Evas* evas, Evas_Object* obj, void* event_info);
-    static void keyDownColorPickerCallback(
-        void* data, Evas* evas, Evas_Object* obj, void* event_info);
 #if defined(OS_TIZEN_MOBILE)
-    static void handleBackKeyColorPicker(
+    static void HandleBackKeyColorPicker(
         void* data,  Evas_Object* obj, void* event_info);
-    static void handleBackKeyDatePicker(
+    static void HandleBackKeyDatePicker(
         void* data, Evas_Object* obj, void* event_info);
 #endif
 
     EWebView& web_view_;
     Evas_Object* ewk_view_;
     Layout* picker_layout_;
-    Eina_List* data_list_;
 };
 
 } // namespace content
index f79fdf9..882507a 100644 (file)
@@ -2086,11 +2086,11 @@ void EWebView::ShowContentsDetectedPopup(const char* message) {
 
 void EWebView::RequestColorPicker(int r, int g, int b, int a) {
   inputPicker_.reset(new InputPicker(*this));
-  inputPicker_->showColorPicker(r, g, b, a);
+  inputPicker_->ShowColorPicker(r, g, b, a);
 }
 
 void EWebView::DismissColorPicker() {
-  inputPicker_->hideColorPicker();
+  inputPicker_->HideColorPicker();
 }
 
 bool EWebView::SetColorPickerColor(int r, int g, int b, int a) {
@@ -2101,7 +2101,7 @@ bool EWebView::SetColorPickerColor(int r, int g, int b, int a) {
 void EWebView::InputPickerShow(
     tizen_webview::Input_Type input_type, double input_value) {
   inputPicker_.reset(new InputPicker(*this));
-  inputPicker_->showDatePicker(input_type, input_value);
+  inputPicker_->ShowDatePicker(input_type, input_value);
 }
 
 bool EWebView::IsIMEShow() {
index e88d71c..c413215 100755 (executable)
@@ -1,5 +1,85 @@
+#define COLORSELECTOR_BG_WIDTH_INC 480
+#define COLORSELECTOR_POPUP_TOP_PADDING_HEIGHT_INC 20
+#define COLORSELECTOR_POPUP_HEIGHT_INC 254
+#define COLORSELECTOR_POPUP_SEPARATOR_INC 1
+#define COLORSELECTOR_POPUP_COLORSELECTOR_HEIGHT_INC 158
 
 collections {
+    group { name: "colorselector_popup_layout";
+       parts {
+          part { name: "bg";
+             type: SPACER;
+             scale: 1;
+             description { state: "default" 0.0;
+                min: COLORSELECTOR_BG_WIDTH_INC COLORSELECTOR_POPUP_HEIGHT_INC;
+                max: COLORSELECTOR_BG_WIDTH_INC COLORSELECTOR_POPUP_HEIGHT_INC;
+             }
+          }
+          part { name: "top_padding";
+            scale: 1;
+            type: RECT;
+            description { state: "default" 0.0;
+                min : COLORSELECTOR_BG_WIDTH_INC COLORSELECTOR_POPUP_TOP_PADDING_HEIGHT_INC;
+                max : COLORSELECTOR_BG_WIDTH_INC COLORSELECTOR_POPUP_TOP_PADDING_HEIGHT_INC;
+                fixed: 0 0;
+                align: 0.0 0.0;
+                rel1 {relative: 0.0 0.0; to: "bg"; }
+                rel2 {relative: 1.0 0.0; to: "bg"; }
+            }
+          }
+          part { name: "rect";
+                scale: 1;
+                type: SWALLOW;
+                description { state: "default" 0.0;
+                    visible: 1;
+                    min: 200 80;
+                    max: 200 80;
+                    fixed: 1 1;
+                    align: 0.5 0.0;
+                    rel1 {relative: 0.0 1.0; to: "top_padding"; }
+                    rel2 {relative: 1.0 1.0; to: "top_padding"; }
+                }
+          }
+          part { name: "colorpalette";
+             type: SWALLOW;
+             scale: 1;
+             description { state: "default" 0.0;
+                min: COLORSELECTOR_BG_WIDTH_INC COLORSELECTOR_POPUP_COLORSELECTOR_HEIGHT_INC;
+                max: COLORSELECTOR_BG_WIDTH_INC COLORSELECTOR_POPUP_COLORSELECTOR_HEIGHT_INC;
+                fixed: 1 1;
+                rel1 {
+                   relative: 0.0 1.0;
+                   to_y: "rect";
+                   to_x: "bg";
+                }
+                rel2 {
+                   to_y: "rect";
+                   to_x: "bg";
+                }
+                align: 0.0 0.0;
+             }
+          }
+          part { name: "colorpalette_bottom_padding";
+             type: SPACER;
+             scale: 1;
+             description { state: "default" 0.0;
+                min: 0 0;
+                fixed: 0 1;
+                rel1 {
+                   relative: 0.0 1.0;
+                   to_y: "colorpalette";
+                   to_x: "bg";
+                }
+                rel2 {
+                   to_x: "bg";
+                   to_y: "colorpalette";
+                }
+                align: 0.0 0.0;
+             }
+          }
+       }
+    }
+
     group { name: "datetime_popup";
         parts {
             part { name: "bg";
@@ -37,241 +117,6 @@ collections {
             }
         }
     }
-    group { name: "color_picker";
-        parts {
-            part { name: "bg";
-                scale: 1;
-                type: RECT;
-                description { state: "default" 0.0;
-                    visible: 0;
-                    min : 0 320;
-                    fixed: 0 0;
-                    align: 0.0 0.0;
-                    rel1 {relative: 0.0 0.0;}
-                    rel2 {relative: 1.0 1.0;}
-                }
-            }
-            part { name: "color_rect_bg";
-                scale: 1;
-                type: RECT;
-                description { state: "default" 0.0;
-                    visible: 0;
-                    min : 0 140;
-                    fixed: 0 0;
-                    align: 0.0 0.0;
-                    rel1 {relative: 0.0 0.0; to: "bg"; }
-                    rel2 {relative: 1.0 0.0; to: "bg"; }
-                }
-            }
-            part { name: "elm.swallow.color_rect";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 200 80;
-                    max: 200 80;
-                    fixed: 1 1;
-                    align: 0.5 0.4;
-                    rel1 {relative: 0.0 0.0; to: "color_rect_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_rect_bg"; }
-                }
-            }
-
-            part { name: "color_palette_bg";
-                scale: 1;
-                type: RECT;
-                description { state: "default" 0.0;
-                    visible: 0;
-                    align: 0.0 0.0;
-                    min: 710 200;
-                    rel1 {relative: 0.0 1.0; to: "color_rect_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "bg"; }
-                }
-            }
-           part { name: "elm.swallow.color1";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.125 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color2";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.25 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color3";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.375 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color4";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.5 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color5";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.625 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color6";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.75 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color7";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.875 0.0;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color8";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.125 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color9";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.25 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color10";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.375 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color11";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.5 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color12";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.625 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color13";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.75 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-            part { name: "elm.swallow.color14";
-                scale: 1;
-                type: SWALLOW;
-                description { state: "default" 0.0;
-                    visible: 1;
-                    min: 70 70;
-                    max: 70 70;
-                    fixed: 1 1;
-                    align: 0.875 0.66;
-                    rel1 {relative: 0.0 0.0; to: "color_palette_bg"; }
-                    rel2 {relative: 1.0 1.0; to: "color_palette_bg"; }
-                }
-            }
-        }
-    }
     group { name: "data_list_picker";
         parts {
             part { name: "bg";