Picture screen adjustment and generic popup view 37/59937/7
authorRadek Kintop <r.kintop@samsung.com>
Fri, 19 Feb 2016 13:28:00 +0000 (14:28 +0100)
committerRadek Kintop <r.kintop@samsung.com>
Tue, 23 Feb 2016 13:31:17 +0000 (14:31 +0100)
Change-Id: I139914e9a454ca3127224bb1233f9da07d6acc11
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
18 files changed:
CMakeLists.txt
include/data/settings_picture.h
include/define.h
include/view/common/view_generic_popup.h [new file with mode: 0644]
include/view/picture/view_picture_screen_adj.h [new file with mode: 0644]
res/settings.edc
res/view/common/popup_2btns.edc
res/view/common/popup_screen_adj.edc [new file with mode: 0644]
res/view/system/sleep_timer.edc
src/data/settings_picture.c
src/layout/layout_picture.c
src/main.c
src/view/common/view_generic_popup.c [new file with mode: 0644]
src/view/picture/view_picture_mode.c
src/view/picture/view_picture_screen_adj.c [new file with mode: 0644]
src/view/system/view_language.c
src/view/system/view_sleep_timer.c
src/view/system/view_subtitle.c

index 9105f6bbe6db9fd6c8e3d674414cb18523d0ab3c..7cd36133783c627593aebad17e08bb723e69c6ff 100644 (file)
@@ -63,6 +63,7 @@ ENDIF(NOT DEFINED DESKTOP_ICON)
 SET(SRCS
        src/main.c
        src/view/view_base.c
+       src/view/common/view_generic_popup.c
        src/view/picture/view_picture_slider_generic.c
        src/view/picture/view_picture_mode.c
        src/view/picture/view_picture_contrast.c
@@ -70,6 +71,7 @@ SET(SRCS
        src/view/picture/view_picture_sharpness.c
        src/view/picture/view_picture_color.c
        src/view/picture/view_picture_tint.c
+       src/view/picture/view_picture_screen_adj.c
        src/view/system/view_clock.c
        src/view/system/view_sleep_timer.c
        src/view/system/view_wakeup_timer.c
index 0bd20c1f0f397111d3f8019c48c89734b4f7268f..f649d4377920f4ddaa43dda9e99a25da530502cc 100644 (file)
 #define PICTURE_MODE_STANDARD_STR "Standard"
 #define PICTURE_MODE_MOVIE_STR "Movie"
 
+#define SCREEN_ADJ_16_9_STR "16:9"
+#define SCREEN_ADJ_4_3_STR "4:3"
+#define SCREEN_ADJ_AUTO_STR "Auto Wide"
+#define SCREEN_ADJ_WIDE_ZOOM_STR "Wide Zoom"
+#define SCREEN_ADJ_FIT_STR "Screen Fit"
+
 typedef enum _picture_mode {
        PICTURE_MODE_STANDARD = 0,
        PICTURE_MODE_MOVIE,
        PICTURE_MODE_MAX
 } settings_picture_mode;
 
+#define SCREEN_ADJ_OPTS_COUNT 5
+
+extern const char *screen_adj_names[SCREEN_ADJ_OPTS_COUNT];
+
 void settings_picture_set_picture_mode(settings_picture_mode mode_to_set);
 void settings_picture_set_contrast(int val);
 void settings_picture_set_brightness(int val);
@@ -41,5 +51,8 @@ int settings_picture_get_max_brightness(void);
 int settings_picture_get_sharpness(void);
 int settings_picture_get_color(void);
 int settings_picture_get_tint_g(void);
+void settings_picture_set_screen_adjust(int adj);
+int settings_picture_get_screen_adjust(void);
+const char *settings_picture_get_screen_adjust_str(void);
 
 #endif /* __AIR_SETTINGS_PICTURE_H__ */
index 4a3524cd3145cc14809cb408e7033a5ce7f19ddc..0a6b05c82fa41dd52b842d734f848b00d821b431 100644 (file)
@@ -34,6 +34,7 @@
 #define VIEW_PICTURE_SHARPNESS "VIEW_PICTURE_SHARPNESS"
 #define VIEW_PICTURE_COLOR "VIEW_PICTURE_COLOR"
 #define VIEW_PICTURE_TINT "VIEW_PICTURE_TINT"
+#define VIEW_PICTURE_SCREEN_ADJ "VIEW_PICTURE_SCREEN_ADJ"
 
 /* View ID - System */
 #define VIEW_CLOCK "VIEW_CLOCK"
@@ -66,6 +67,7 @@
 #define GRP_VIEW_WAKEUP_TIMER "grp.view.wakeup_timer"
 #define GRP_VIEW_SLEEP_TIMER "grp.view.sleep_timer"
 
+#define GRP_VIEW_POPUP_BUTTONS_LIST "grp.view.popup_buttons_list"
 #define GRP_VIEW_POPUP_2BTNS "grp.view.popup_2btns"
 #define GRP_VIEW_GENERIC_SLIDER "grp.view.generic_slider"
 
 #define PART_ENTRY_3 "part.entry3"
 #define PART_ENTRY_4 "part.entry4"
 
+#define PART_POPUP_BUTTON0 "part.popup.btn0"
 #define PART_POPUP_BUTTON1 "part.popup.btn1"
 #define PART_POPUP_BUTTON2 "part.popup.btn2"
 #define PART_POPUP_BUTTON3 "part.popup.btn3"
 #define PART_POPUP_BUTTON4 "part.popup.btn4"
 #define PART_POPUP_BUTTON5 "part.popup.btn5"
-#define PART_POPUP_BUTTON6 "part.popup.btn6"
 #define PART_POPUP_BUTTON_X "part.popup.btn%d"
 
 #define PART_POPUP_NAME "part.popup.name"
 #define STR_SHARPNESS "Sharpness"
 #define STR_COLOR "Color"
 #define STR_TINT "Tint"
+#define STR_SCR_ADJ "Screen Adjustment"
 
 #define STR_LANGUAGE "Language"
 #define STR_LOCATION "Location"
diff --git a/include/view/common/view_generic_popup.h b/include/view/common/view_generic_popup.h
new file mode 100644 (file)
index 0000000..5942960
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef VIEW_GENERIC_POPUP_H_
+#define VIEW_GENERIC_POPUP_H_
+
+#include "common/viewmgr.h"
+#include "common/inputmgr.h"
+
+/*TODO: make use of it and add more types if necessary:*/
+typedef enum
+{
+       POPUP_TYPE_BUTTONS_LIST = 0
+}popup_type_t;
+
+typedef struct {
+       const char *popup_title; /* in */
+       const char *popup_description; /* in */
+       const char *popup_layout_group; /* in */
+       input_handler *handler; /* in */
+       int buttns_count; /* in - valid for popup with buttons only */
+       const char **btn_texts; /* in - valid for popup with buttons only */
+       int (*ui_id_on_show_focus)(void); /* in */
+       void *generic_popup_data; /* out - to be used by inheriting class */
+} generic_popup_parameter;
+
+view_class *view_generic_popup_get_vclass(void);
+
+#endif /* VIEW_GENERIC_POPUP_H_ */
diff --git a/include/view/picture/view_picture_screen_adj.h b/include/view/picture/view_picture_screen_adj.h
new file mode 100644 (file)
index 0000000..e35ed9e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#ifndef VIEW_PICTURE_SCREEN_ADJ_H_
+#define VIEW_PICTURE_SCREEN_ADJ_H_
+
+#include "view/common/view_generic_popup.h"
+
+view_class *view_picture_screen_adj_get_vclass(void);
+
+#endif /* VIEW_PICTURE_SCREEN_ADJ_H_ */
index 905423496f262a8ca3c856c1fae81f2a2d55fb61..79994d72cf73e515ca5e6b0752828efd5ecc06a5 100644 (file)
@@ -20,6 +20,7 @@ collections {
        base_scale: APP_BASE_SCALE;
        #include "view/base.edc"
        #include "view/common/popup_2btns.edc"
+       #include "view/common/popup_screen_adj.edc"
        #include "view/common/generic_slider_view.edc"
        #include "view/system/clock.edc"
        #include "view/system/sleep_timer.edc"
index 9abfaf3bd5c223047839ad18da8ac0bac02cc664..dcdc9e38fbf45ed2ec4d07b8708d8b7e97d18265 100644 (file)
@@ -59,7 +59,7 @@ group {
                }
 
                part {
-                       name, PART_POPUP_BUTTON1;
+                       name, PART_POPUP_BUTTON0;
                        type, SWALLOW;
                        scale, 1;
                        description {
@@ -80,15 +80,15 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 0 32;
-                               rel1 { to, PART_POPUP_BUTTON1; relative, 0.0 1.0; }
-                               rel2.to, PART_POPUP_BUTTON1;
+                               rel1 { to, PART_POPUP_BUTTON0; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON0;
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
                }
 
                part {
-                       name, PART_POPUP_BUTTON2;
+                       name, PART_POPUP_BUTTON1;
                        type, SWALLOW;
                        scale, 1;
                        description {
diff --git a/res/view/common/popup_screen_adj.edc b/res/view/common/popup_screen_adj.edc
new file mode 100644 (file)
index 0000000..e46f1d7
--- /dev/null
@@ -0,0 +1,186 @@
+group {
+       name, GRP_VIEW_POPUP_BUTTONS_LIST;
+       parts {
+               part {
+                       name, "area";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "padding.title";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 24;
+                               rel1.to, "area";
+                               rel2 { to, "area"; relative, 1.0 0.0; }
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+
+               part {
+                       name, PART_POPUP_NAME;
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 32;
+                               rel1 { to, "padding.title"; relative, 0.0 1.0; }
+                               rel2.to, "padding.title";
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               color, COLOR_TEXT_POPUP;
+                               text {
+                                       font, FONT_LIGHT;
+                                       size, 32;
+                               }
+                       }
+               }
+
+               part {
+                       name, "padding.1";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 32;
+                               rel1 { to, PART_POPUP_NAME; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_NAME;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+
+               part {
+                       name, PART_POPUP_BUTTON0;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 488 68;
+                               rel1 { to, "padding.1"; relative, 0.5 1.0; }
+                               rel2 { to, "padding.1"; relative, 0.5 1.0; }
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               color, 0 0 0 255;
+                       }
+               }
+
+               part {
+                       name, "padding.2";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 32;
+                               rel1 { to, PART_POPUP_BUTTON0; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON0;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+
+               part {
+                       name, PART_POPUP_BUTTON1;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 488 68;
+                               rel1 { to, "padding.2"; relative, 0.0 1.0; }
+                               rel2.to, "padding.2";
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               color, 0 0 0 255;
+                       }
+               }
+               part {
+                       name, "padding.3";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 32;
+                               rel1 { to, PART_POPUP_BUTTON1; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON1;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+               part {
+                       name, PART_POPUP_BUTTON2;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 488 68;
+                               rel1 { to, "padding.3"; relative, 0.0 1.0; }
+                               rel2.to, "padding.3";
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               color, 0 0 0 255;
+                       }
+               }
+               part {
+                       name, "padding.4";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 32;
+                               rel1 { to, PART_POPUP_BUTTON2; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON2;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+               part {
+                       name, PART_POPUP_BUTTON3;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 488 68;
+                               rel1 { to, "padding.4"; relative, 0.0 1.0; }
+                               rel2.to, "padding.4";
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               color, 0 0 0 255;
+                       }
+               }
+               part {
+                       name, "padding.5";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 32;
+                               rel1 { to, PART_POPUP_BUTTON3; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON3;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+               part {
+                       name, PART_POPUP_BUTTON4;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 488 68;
+                               rel1 { to, "padding.5"; relative, 0.0 1.0; }
+                               rel2.to, "padding.5";
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               color, 0 0 0 255;
+                       }
+               }
+  }
+}
index 10895c4dcfb6c22c08e654185b9effe8796707aa..7a97bf366f68b1dac4fa8d2e9636b7af8b9a093a 100644 (file)
@@ -75,7 +75,7 @@ group {
                }
 
                part {
-                       name, PART_POPUP_BUTTON1;
+                       name, PART_POPUP_BUTTON0;
                        type, SWALLOW;
                        scale, 1;
                        description {
@@ -96,15 +96,15 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 0 32;
-                               rel1 { to, PART_POPUP_BUTTON1; relative, 0.0 1.0; }
-                               rel2.to, PART_POPUP_BUTTON1;
+                               rel1 { to, PART_POPUP_BUTTON0; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON0;
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
                }
 
                part {
-                       name, PART_POPUP_BUTTON2;
+                       name, PART_POPUP_BUTTON1;
                        type, SWALLOW;
                        scale, 1;
                        description {
@@ -125,15 +125,15 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 0 32;
-                               rel1 { to, PART_POPUP_BUTTON2; relative, 0.0 1.0; }
-                               rel2.to, PART_POPUP_BUTTON2;
+                               rel1 { to, PART_POPUP_BUTTON1; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON1;
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
                }
 
                part {
-                       name, PART_POPUP_BUTTON3;
+                       name, PART_POPUP_BUTTON2;
                        type, SWALLOW;
                        scale, 1;
                        description {
@@ -154,15 +154,15 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 0 32;
-                               rel1 { to, PART_POPUP_BUTTON3; relative, 0.0 1.0; }
-                               rel2.to, PART_POPUP_BUTTON3;
+                               rel1 { to, PART_POPUP_BUTTON2; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON2;
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
                }
 
                part {
-                       name, PART_POPUP_BUTTON4;
+                       name, PART_POPUP_BUTTON3;
                        type, SWALLOW;
                        scale, 1;
                        description {
@@ -183,15 +183,15 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 0 32;
-                               rel1 { to, PART_POPUP_BUTTON4; relative, 0.0 1.0; }
-                               rel2.to, PART_POPUP_BUTTON4;
+                               rel1 { to, PART_POPUP_BUTTON3; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON3;
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
                }
 
                part {
-                       name, PART_POPUP_BUTTON5;
+                       name, PART_POPUP_BUTTON4;
                        type, SWALLOW;
                        scale, 1;
                        description {
@@ -211,15 +211,15 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 0 32;
-                               rel1 { to, PART_POPUP_BUTTON5; relative, 0.0 1.0; }
-                               rel2.to, PART_POPUP_BUTTON5;
+                               rel1 { to, PART_POPUP_BUTTON4; relative, 0.0 1.0; }
+                               rel2.to, PART_POPUP_BUTTON4;
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
                }
 
                part {
-                       name, PART_POPUP_BUTTON6;
+                       name, PART_POPUP_BUTTON5;
                        type, SWALLOW;
                        scale, 1;
                        description {
index 2a4911e4d67959520ad29f36417ef1ebd339c5c3..66da12fd467303198a8b750b5a99f354f7928e39 100644 (file)
@@ -39,14 +39,21 @@ The name org.tizen.system.deviced was not provided by any .service files)
 
 That's why all device_display_* functions invoked here don't work */
 
-
-
 /* Temporary - until real API is known */
 static settings_picture_mode temp_mode = PICTURE_MODE_STANDARD;
 static int temp_contrast = DEFAULT_CONTRAST;
 static int temp_sharpness = DEFAULT_SHARPNESS;
 static int temp_color = DEFAULT_COLOR;
 static int temp_tint_g = DEFAULT_TINT_G;
+static int screen_adj = 0;
+
+const char *screen_adj_names[SCREEN_ADJ_OPTS_COUNT] = {
+       SCREEN_ADJ_16_9_STR,
+       SCREEN_ADJ_4_3_STR,
+       SCREEN_ADJ_AUTO_STR,
+       SCREEN_ADJ_WIDE_ZOOM_STR,
+       SCREEN_ADJ_FIT_STR
+};
 
 void settings_picture_set_picture_mode(settings_picture_mode mode_to_set)
 {
@@ -161,3 +168,18 @@ int settings_picture_get_tint_g(void)
        //@TODO: get tint
        return temp_tint_g;
 }
+
+void settings_picture_set_screen_adjust(int adj)
+{
+       screen_adj = adj;
+}
+
+int settings_picture_get_screen_adjust(void)
+{
+       return screen_adj;
+}
+
+const char *settings_picture_get_screen_adjust_str(void)
+{
+       return screen_adj_names[screen_adj];
+}
index 61898d549b0e37a916ca6b05ac27fe8a75fe2f3e..93015f06c7111379a0bc52b26c1c2f5179b0f964 100644 (file)
@@ -116,9 +116,9 @@ static struct menumgr_info menu_info[] = {
        },
        {
                .id = MENU_SCREEN_ADJ,
-               .title = "Screen Adjustment",
+               .title = STR_SCR_ADJ,
                .style = STYLE_STATUS_BTN,
-               .disabled = EINA_TRUE,
+               .disabled = EINA_FALSE,
                .status = _get_screen_adj,
                .selected = _selected,
        },
@@ -203,8 +203,7 @@ static char *_get_tint(void *data, int id)
 
 static char *_get_screen_adj(void *data, int id)
 {
-       SETTING_TRACE_BEGIN;
-       return NULL;
+       return strdup(settings_picture_get_screen_adjust_str());
 }
 
 static void _selected(void *data, int id)
@@ -234,6 +233,10 @@ static void _selected(void *data, int id)
                case MENU_TINT:
                        if (!viewmgr_push_view(VIEW_PICTURE_TINT))
                                _ERR("Push Picture tint view failed.");
+                       break;
+               case MENU_SCREEN_ADJ:
+                       if (!viewmgr_show_view(VIEW_PICTURE_SCREEN_ADJ))
+                               _ERR("Push Picture screen adjustment view failed.");
                                break;
        }
 }
index 80cf10f0e706cc974598b1e35f5803e122b02815..852d87a2ffd00adc2c2324114caf426ffb644cef 100644 (file)
@@ -27,6 +27,7 @@
 #include "view/picture/view_picture_sharpness.h"
 #include "view/picture/view_picture_color.h"
 #include "view/picture/view_picture_tint.h"
+#include "view/picture/view_picture_screen_adj.h"
 #include "view/system/view_clock.h"
 #include "view/system/view_sleep_timer.h"
 #include "view/system/view_wakeup_timer.h"
@@ -213,6 +214,11 @@ static bool _create_picture_ui(void)
                return false;
        }
 
+       if (!viewmgr_add_view(view_picture_screen_adj_get_vclass(), NULL)) {
+               _ERR("Adding picture screen adjustment view failed.");
+               return false;
+       }
+
        return true;
 }
 
@@ -280,6 +286,9 @@ static void _destroy_picture_ui(void)
 
        if (!viewmgr_remove_view(VIEW_PICTURE_TINT))
                _ERR("Remove picture tint view failed.");
+
+       if (!viewmgr_remove_view(VIEW_PICTURE_SCREEN_ADJ))
+               _ERR("Remove picture screen adjustment view failed.");
 }
 
 static void _destroy_system_ui(void)
@@ -308,3 +317,4 @@ static void _destroy_system_ui(void)
        if (!viewmgr_remove_view(VIEW_RESET))
                _ERR("Remove reset view failed.");
 }
+
diff --git a/src/view/common/view_generic_popup.c b/src/view/common/view_generic_popup.c
new file mode 100644 (file)
index 0000000..99717c9
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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 "view/common/view_generic_popup.h"
+
+#include <app.h>
+#include <Elementary.h>
+
+#include "app_debug.h"
+#include "define.h"
+#include "common/viewmgr.h"
+#include "common/inputmgr.h"
+#include "common/utils.h"
+
+#define GENERIC_POPUP_BTN_NAME_MAX 128
+
+struct _priv {
+       Evas_Object *popup;
+       Evas_Object *layout;
+       int (*ui_id_on_show_focus)(void);
+};
+
+/* View class functions: */
+static Evas_Object *_create(Evas_Object *win, void *data);
+static void _show(void *view_data);
+static void _hide(void *view_data);
+static void _destroy(void *view_data);
+
+/* Helper: */
+static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout,
+       int btn_count, const char **btn_text, input_handler *handler);
+
+static view_class _vclass = {
+       .view_id = NULL,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy
+};
+
+view_class *view_generic_popup_get_vclass(void)
+{
+       return &_vclass;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv = NULL;
+       generic_popup_parameter *g_data = (generic_popup_parameter *)data;
+
+       if (!win || !g_data) {
+               _ERR("Invalid arguments");
+               return NULL;
+       }
+
+       priv = calloc(1, sizeof(struct _priv));
+       if (!priv) {
+               _ERR("Calloc failed.");
+               return NULL;
+       }
+
+       priv->popup = utils_add_popup(win, NULL, g_data->popup_title, NULL);
+       if (!priv->popup) {
+               _ERR("Add popup failed");
+               free(priv);
+               return NULL;
+       }
+
+       priv->layout = utils_add_layout(priv->popup, g_data->popup_layout_group, EINA_FALSE);
+       if (!priv->layout) {
+               _ERR("Add layout failed.");
+               evas_object_del(priv->popup);
+               free(priv);
+               return NULL;
+       }
+
+       elm_object_part_text_set(priv->layout, PART_POPUP_NAME, g_data->popup_title);
+
+       if (!_fill_popup_btns(priv, priv->layout, g_data->buttns_count, g_data->btn_texts, g_data->handler)) {
+               evas_object_del(priv->popup);
+               free(priv);
+               return NULL;
+       }
+
+       priv->ui_id_on_show_focus = g_data->ui_id_on_show_focus;
+
+       elm_object_content_set(priv->popup, priv->layout);
+
+       g_data->generic_popup_data = priv;
+
+       return priv->popup;
+}
+
+static void _show(void *data)
+{
+       Evas_Object *ui_element_to_focus = NULL;
+       int ui_id_to_focus = 0;
+       char part_name[GENERIC_POPUP_BTN_NAME_MAX] = {'\0', };
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+
+       evas_object_show(priv->popup);
+
+       if(priv->ui_id_on_show_focus) {
+               ui_id_to_focus = priv->ui_id_on_show_focus();
+               snprintf(part_name, sizeof(part_name), PART_POPUP_BUTTON_X, ui_id_to_focus);
+               ui_element_to_focus = elm_layout_content_get(priv->layout, part_name);
+               elm_object_focus_set(ui_element_to_focus, EINA_TRUE);
+       }
+}
+
+static void _hide(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+
+       evas_object_hide(priv->popup);
+}
+
+static void _destroy(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+
+       evas_object_del(priv->popup);
+       free(priv);
+}
+
+static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout,
+                                                               int btn_count, const char **btn_text, input_handler *handler)
+{
+       Evas_Object *btn = NULL;
+       int i = 0;
+
+       for(i = 0; i < btn_count; i++) {
+               char part_name[GENERIC_POPUP_BTN_NAME_MAX] = {'\0', };
+               snprintf(part_name, sizeof(part_name), PART_POPUP_BUTTON_X, i);
+               btn = utils_add_button(layout, part_name, NULL, btn_text[i]);
+               if (!btn) {
+                       _ERR("Add button failed.");
+                       return false;
+               }
+
+               if (handler)
+                       inputmgr_add_callback(btn, i, handler, priv);
+       }
+
+       return true;
+}
index c730acbd79491ae4cbcf0a5e5f88381ede555dba..fe00b7392e3ee15cc2ee1d45bc6f556e5853a0d8 100644 (file)
@@ -57,7 +57,7 @@ static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout,
 
        for(i = 0; i < btn_count; i++) {
                char part_name[PART_POPUP_BUTTON_STR_MAX_L] = {0, };
-               snprintf(part_name, sizeof(part_name), btn_part_x, i+1);
+               snprintf(part_name, sizeof(part_name), btn_part_x, i);
 
                btn = utils_add_button(layout, part_name, NULL, btn_text[i]);
                if (!btn) {
diff --git a/src/view/picture/view_picture_screen_adj.c b/src/view/picture/view_picture_screen_adj.c
new file mode 100644 (file)
index 0000000..475515e
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2016 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 "view/picture/view_picture_screen_adj.h"
+#include <app.h>
+#include <Elementary.h>
+#include "app_debug.h"
+#include "define.h"
+#include "common/utils.h"
+#include "view/common/view_generic_popup.h"
+#include "data/settings_picture.h"
+
+struct _priv {
+       Evas_Object *popup;
+       void *base_popup_data;
+       const view_class *base_popup_class;
+};
+
+/* View class functions: */
+static Evas_Object *_create(Evas_Object *win, void *data);
+static void _destroy(void *view_data);
+static void _show(void *view_data);
+static void _hide(void *view_data);
+
+/* Enter button: */
+static void _clicked_cb(int id, void *data, Evas_Object *obj);
+/*  */
+static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+       Evas_Event_Key_Down *ev);
+
+const char *title = "Screen Adjustment";
+const char *description = "Select Screen Adjustment.";
+
+static view_class _vclass = {
+       .view_id = VIEW_PICTURE_SCREEN_ADJ,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy
+};
+
+static input_handler handler = {
+       .key_down = _key_down_cb,
+       .clicked = _clicked_cb
+};
+
+
+view_class *view_picture_screen_adj_get_vclass(void)
+{
+       return &_vclass;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv = NULL;
+       generic_popup_parameter constructor_param = {0,};
+
+       constructor_param.buttns_count = SCREEN_ADJ_OPTS_COUNT;
+       constructor_param.popup_title = title;
+       constructor_param.popup_description = description;
+       constructor_param.btn_texts = screen_adj_names;
+       constructor_param.popup_layout_group = GRP_VIEW_POPUP_BUTTONS_LIST;
+       constructor_param.handler = &handler;
+       constructor_param.ui_id_on_show_focus = &settings_picture_get_screen_adjust;
+
+       if (!win) {
+               _ERR("Get window object failed.");
+               return NULL;
+       }
+
+       priv = calloc(1, sizeof(struct _priv));
+       if (!priv) {
+               _ERR("Calloc failed.");
+               return NULL;
+       }
+
+       priv->base_popup_class = view_generic_popup_get_vclass();
+
+       if (!priv->base_popup_class || ! priv->base_popup_class->create) {
+               free(priv);
+               return NULL;
+       }
+
+       priv->popup = priv->base_popup_class->create(win, &constructor_param);
+
+       if (!priv->popup) {
+               free(priv);
+               return NULL;
+       }
+
+       priv->base_popup_data = constructor_param.generic_popup_data;
+
+       if (!viewmgr_set_view_data(VIEW_PICTURE_SCREEN_ADJ, priv)) {
+               _ERR("Set view data failed.");
+               _destroy(priv);
+               free(priv);
+               return NULL;
+       }
+
+       return priv->popup;
+}
+
+static void _show(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv
+               || !priv->base_popup_class
+               || !priv->base_popup_class->show
+               || !priv->base_popup_data) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+
+       priv->base_popup_class->show(priv->base_popup_data);
+}
+
+static void _hide(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv
+               || !priv->base_popup_class
+               || !priv->base_popup_class->hide
+               || !priv->base_popup_data) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+       priv->base_popup_class->hide(priv->base_popup_data);
+}
+
+static void _destroy(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv
+               || !priv->base_popup_class
+               || !priv->base_popup_class->destroy
+               || !priv->base_popup_data) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+       priv->base_popup_class->destroy(priv->base_popup_data);
+       free(priv);
+}
+
+static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Key_Down *ev)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!ev || !priv) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       if (!strcmp(ev->keyname, KEY_BACK))
+               viewmgr_pop_view();
+}
+
+static void _clicked_cb(int id, void *data, Evas_Object *obj)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv || !obj) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       settings_picture_set_screen_adjust(id);
+       viewmgr_pop_view();
+}
index 839c7f1aae5d8bc132211a7f6bf8741e7627f041..bb5b32f2c17381c2e92b4302c5bd62c9a6842ef7 100644 (file)
@@ -56,7 +56,7 @@ static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout,
 
        for(i = 0; i < btn_count; i++) {
                char part_name[PART_POPUP_BUTTON_STR_MAX_L] = {0, };
-               snprintf(part_name, sizeof(part_name), btn_part_x, i+1);
+               snprintf(part_name, sizeof(part_name), btn_part_x, i);
 
                btn = utils_add_button(layout, part_name, NULL, btn_text[i]);
                if (!btn) {
index c65e1c2ac4232b3460742f4fb86627401441b08d..be3eabd5fbf2bb6feda0bc8fd8762d5c9cb8f1b6 100644 (file)
@@ -59,7 +59,7 @@ static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout, int btn_co
 
        for(i = 0; i < btn_count; i++) {
                char part_name[PART_POPUP_BUTTON_STR_MAX_L] = {0, };
-               snprintf(part_name, sizeof(part_name), btn_part_x, i+1);
+               snprintf(part_name, sizeof(part_name), btn_part_x, i);
 
                btn = utils_add_button(layout, part_name, NULL, btn_text[i]);
                if (!btn) {
index 7e91bf13fce24def4dfcd10e4cf3ba0560e5af8a..4081c49c995253806c24b8bde17327662bb30660 100644 (file)
@@ -56,7 +56,7 @@ static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout,
 
        for(i = 0; i < btn_count; i++) {
                char part_name[PART_POPUP_BUTTON_STR_MAX_L] = {0, };
-               snprintf(part_name, sizeof(part_name), btn_part_x, i+1);
+               snprintf(part_name, sizeof(part_name), btn_part_x, i);
 
                btn = utils_add_button(layout, part_name, NULL, btn_text[i]);
                if (!btn) {