From d42ce49c7c531651e2d62c45144e173095ed572d Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 7 Dec 2020 10:32:01 +0900 Subject: [PATCH] Reduce the duplicated code to create window Change-Id: I29601428a6070e663ac47924519dc1dda1c81b7c Signed-off-by: Jihoon Kim --- common/input_method_setting_win.cpp | 41 ++++++++++++++++++ common/input_method_setting_win.h | 24 +++++++++++ im_setting_list/CMakeLists.txt | 1 + .../input_method_setting_list_ui.cpp | 19 ++------ im_setting_selector/CMakeLists.txt | 1 + .../input_method_setting_selector_ui.cpp | 43 +++++++------------ 6 files changed, 85 insertions(+), 44 deletions(-) create mode 100644 common/input_method_setting_win.cpp create mode 100644 common/input_method_setting_win.h diff --git a/common/input_method_setting_win.cpp b/common/input_method_setting_win.cpp new file mode 100644 index 0000000..df0154c --- /dev/null +++ b/common/input_method_setting_win.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + * + */ +#include "input_method_setting_win.h" + +Evas_Object *im_setting_window_create(const char *name, Eina_Bool allow_rotation, Eina_Bool alpha) +{ + Evas_Object *win = elm_win_add(NULL, name, ELM_WIN_BASIC); + if (win) { + elm_win_title_set(win, name); + elm_win_borderless_set(win, EINA_TRUE); + elm_win_alpha_set(win, alpha); + elm_win_conformant_set(win, EINA_TRUE); + elm_win_autodel_set(win, EINA_TRUE); + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_OPAQUE); + + if (allow_rotation) { + if (elm_win_wm_rotation_supported_get(win)) { + int rots[4] = {0, 90, 180, 270}; + elm_win_wm_rotation_available_rotations_set(win, rots, 4); + } + } + } + + return win; +} + diff --git a/common/input_method_setting_win.h b/common/input_method_setting_win.h new file mode 100644 index 0000000..476d644 --- /dev/null +++ b/common/input_method_setting_win.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + * + */ +#include + +#ifndef __INPUTMETHOD_SETTING_WINDOW_H +#define __INPUTMETHOD_SETTING_WINDOW_H + +Evas_Object *im_setting_window_create(const char *name, Eina_Bool allow_rotation, Eina_Bool alpha); + +#endif diff --git a/im_setting_list/CMakeLists.txt b/im_setting_list/CMakeLists.txt index a995ae9..6599941 100644 --- a/im_setting_list/CMakeLists.txt +++ b/im_setting_list/CMakeLists.txt @@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(SRC_LIST ../common/input_method_setting_genlist.cpp + ../common/input_method_setting_win.cpp ../common/ime_info.cpp input_method_setting_list_ui.cpp input_method_setting_list.cpp diff --git a/im_setting_list/input_method_setting_list_ui.cpp b/im_setting_list/input_method_setting_list_ui.cpp index 32ad7cb..46e2839 100644 --- a/im_setting_list/input_method_setting_list_ui.cpp +++ b/im_setting_list/input_method_setting_list_ui.cpp @@ -18,6 +18,7 @@ #include "input_method_setting_list_ui.h" #include "input_method_setting_list_popup_view.h" #include "../common/input_method_setting_genlist.h" +#include "../common/input_method_setting_win.h" #include "../common/ime_info.h" #include @@ -97,22 +98,8 @@ static void im_setting_list_text_domain_set(void) static Evas_Object * im_setting_list_main_window_create(const char *name, int app_type) { - Evas_Object *eo = NULL; - eo = elm_win_add(NULL, name, ELM_WIN_BASIC); - if (eo) { - elm_win_title_set(eo, name); - elm_win_borderless_set(eo, EINA_TRUE); - elm_win_alpha_set(eo, EINA_FALSE); - elm_win_conformant_set(eo, EINA_TRUE); - elm_win_autodel_set(eo, EINA_TRUE); - elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE); - - if (app_type != APP_TYPE_SETTING_NO_ROTATION) { - int rots[4] = {0, 90, 180, 270}; - elm_win_wm_rotation_available_rotations_set(eo, rots, 4); - } - } + Evas_Object *eo = im_setting_window_create(name, app_type == APP_TYPE_SETTING_NO_ROTATION ? EINA_FALSE : EINA_TRUE, EINA_FALSE); + return eo; } diff --git a/im_setting_selector/CMakeLists.txt b/im_setting_selector/CMakeLists.txt index b5cee92..d55b3a2 100644 --- a/im_setting_selector/CMakeLists.txt +++ b/im_setting_selector/CMakeLists.txt @@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(SRC_LIST ../common/input_method_setting_genlist.cpp + ../common/input_method_setting_win.cpp ../common/ime_info.cpp input_method_setting_selector_ui.cpp input_method_setting_selector.cpp diff --git a/im_setting_selector/input_method_setting_selector_ui.cpp b/im_setting_selector/input_method_setting_selector_ui.cpp index a96c81e..c9a9621 100644 --- a/im_setting_selector/input_method_setting_selector_ui.cpp +++ b/im_setting_selector/input_method_setting_selector_ui.cpp @@ -22,6 +22,7 @@ #include #include #include "../common/input_method_setting_genlist.h" +#include "../common/input_method_setting_win.h" #include "../common/ime_info.h" #define IM_SETTING_SELECTOR_PACKAGE PACKAGE @@ -45,37 +46,23 @@ static void im_setting_selector_text_domain_set(void) static Evas_Object * im_setting_selector_main_window_create(const char *name) { - Evas_Object *eo = elm_win_add(NULL, name, ELM_WIN_BASIC); - if (eo) { - Evas *e; - Ecore_Evas *ee; - Evas_Coord w = -1, h = -1; - - elm_win_title_set(eo, name); - elm_win_borderless_set(eo, EINA_TRUE); - elm_win_alpha_set(eo, EINA_TRUE); - elm_win_conformant_set(eo, EINA_TRUE); - elm_win_autodel_set(eo, EINA_TRUE); - elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE); - - if (elm_win_wm_rotation_supported_get(eo)) { - int rots[4] = {0, 90, 180, 270}; - elm_win_wm_rotation_available_rotations_set(eo, rots, 4); - } - e = evas_object_evas_get(eo); - if (e) { - ee = ecore_evas_ecore_evas_get(e); - if (ee) { - ecore_evas_name_class_set(ee, "SYSTEM_POPUP", "SYSTEM_POPUP"); - } + Evas *e; + Ecore_Evas *ee; + Evas_Coord w = -1, h = -1; + Evas_Object *eo = im_setting_window_create(name, EINA_TRUE, EINA_TRUE); + e = evas_object_evas_get(eo); + if (e) { + ee = ecore_evas_ecore_evas_get(e); + if (ee) { + ecore_evas_name_class_set(ee, "SYSTEM_POPUP", "SYSTEM_POPUP"); } + } - elm_win_screen_size_get(eo, NULL, NULL, &w, &h); - if (w > 0 && h > 0) { - evas_object_resize(eo, w, h); - } + elm_win_screen_size_get(eo, NULL, NULL, &w, &h); + if (w > 0 && h > 0) { + evas_object_resize(eo, w, h); } + return eo; } -- 2.34.1