From 05dff3a42cc7b362e5c778494b757dd11f9d8c12 Mon Sep 17 00:00:00 2001 From: Agnieszka Janowicz Date: Fri, 19 Feb 2016 14:42:22 +0100 Subject: [PATCH] Picture color view Change-Id: I9e75e6d88467dc27c20cc04b7eeb5150affc237a Signed-off-by: Agnieszka Janowicz --- CMakeLists.txt | 1 + include/data/settings_picture.h | 2 + include/define.h | 2 + include/view/picture/view_picture_color.h | 24 ++++++ src/data/settings_picture.c | 20 ++++- src/layout/layout_picture.c | 21 ++++- src/main.c | 9 ++ src/view/picture/view_picture_color.c | 135 ++++++++++++++++++++++++++++++ 8 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 include/view/picture/view_picture_color.h create mode 100644 src/view/picture/view_picture_color.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fd2198..d41680e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ SET(SRCS src/view/picture/view_picture_contrast.c src/view/picture/view_picture_brightness.c src/view/picture/view_picture_sharpness.c + src/view/picture/view_picture_color.c src/view/system/view_clock.c src/view/system/view_sleep_timer.c src/view/system/view_wakeup_timer.c diff --git a/include/data/settings_picture.h b/include/data/settings_picture.h index 83908ec..2f18cb8 100644 --- a/include/data/settings_picture.h +++ b/include/data/settings_picture.h @@ -30,11 +30,13 @@ 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); void settings_picture_set_sharpness(int val); +void settings_picture_set_color(int val); settings_picture_mode settings_picture_get_picture_mode(void); int settings_picture_get_contrast(void); int settings_picture_get_brightness(void); int settings_picture_get_max_brightness(void); int settings_picture_get_sharpness(void); +int settings_picture_get_color(void); #endif /* __AIR_SETTINGS_PICTURE_H__ */ diff --git a/include/define.h b/include/define.h index 74c6530..e7ed465 100644 --- a/include/define.h +++ b/include/define.h @@ -32,6 +32,7 @@ #define VIEW_PICTURE_CONTRAST "VIEW_PICTURE_CONTRAST" #define VIEW_PICTURE_BRIGHTNESS "VIEW_PICTURE_BRIGHTNESS" #define VIEW_PICTURE_SHARPNESS "VIEW_PICTURE_SHARPNESS" +#define VIEW_PICTURE_COLOR "VIEW_PICTURE_COLOR" /* View ID - System */ #define VIEW_CLOCK "VIEW_CLOCK" @@ -194,6 +195,7 @@ #define STR_CONTRAST "Contrast" #define STR_BRIGHTNESS "Brightness" #define STR_SHARPNESS "Sharpness" +#define STR_COLOR "Color" #define STR_LANGUAGE "Language" #define STR_LOCATION "Location" diff --git a/include/view/picture/view_picture_color.h b/include/view/picture/view_picture_color.h new file mode 100644 index 0000000..4223016 --- /dev/null +++ b/include/view/picture/view_picture_color.h @@ -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 __AIR_SETTINGS_VIEW_PICTURE_COLOR_H__ +#define __AIR_SETTINGS_VIEW_PICTURE_COLOR_H__ + +#include "common/viewmgr.h" + +view_class *view_picture_color_get_vclass(void); + +#endif /* __AIR_SETTINGS_VIEW_PICTURE_COLOR_H__ */ diff --git a/src/data/settings_picture.c b/src/data/settings_picture.c index 92f7043..d502266 100644 --- a/src/data/settings_picture.c +++ b/src/data/settings_picture.c @@ -20,6 +20,9 @@ #define DISPLAY_MAIN 0 #define DEFAULT_MAX_BRIGHTNESS 100 +#define DEFAULT_CONTRAST 100 +#define DEFAULT_SHARPNESS 100 +#define DEFAULT_COLOR 100 /* Display error: @@ -39,8 +42,9 @@ 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 = 50; -static int temp_sharpness = 50; +static int temp_contrast = DEFAULT_CONTRAST; +static int temp_sharpness = DEFAULT_SHARPNESS; +static int temp_color = DEFAULT_COLOR; void settings_picture_set_picture_mode(settings_picture_mode mode_to_set) { @@ -80,6 +84,12 @@ void settings_picture_set_sharpness(int val) temp_sharpness = val; } +void settings_picture_set_color(int val) +{ + //@TODO: set color + temp_color = val; +} + settings_picture_mode settings_picture_get_picture_mode(void) { //@TODO: get picture mode @@ -131,3 +141,9 @@ int settings_picture_get_sharpness(void) //@TODO: get sharpness return temp_sharpness; } + +int settings_picture_get_color(void) +{ + //@TODO: get color + return temp_color; +} diff --git a/src/layout/layout_picture.c b/src/layout/layout_picture.c index d1beeae..de0dd54 100644 --- a/src/layout/layout_picture.c +++ b/src/layout/layout_picture.c @@ -54,6 +54,7 @@ static char *_get_picture_mode(void *data, int id); static char *_get_contrast(void *data, int id); static char *_get_brightness(void *data, int id); static char *_get_sharpness(void *data, int id); +static char *_get_color(void *data, int id); static char *_get_screen_adj(void *data, int id); static void _selected(void *data, int id); @@ -92,10 +93,10 @@ static struct menumgr_info menu_info[] = { }, { .id = MENU_COLOR, - .title = "Color", + .title = STR_COLOR, .style = STYLE_STATUS_BTN, - .disabled = EINA_TRUE, - .status = _get_status, + .disabled = EINA_FALSE, + .status = _get_color, .selected = _selected, }, { @@ -164,6 +165,16 @@ static char *_get_sharpness(void *data, int id) return strdup(sharp_str); } +static char *_get_color(void *data, int id) +{ + char color_str[5] = {0, }; + int color_val = settings_picture_get_color(); + + snprintf(color_str, sizeof(color_str), "%d%%", color_val); + + return strdup(color_str); +} + static char *_get_screen_adj(void *data, int id) { SETTING_TRACE_BEGIN; @@ -190,6 +201,10 @@ static void _selected(void *data, int id) if (!viewmgr_push_view(VIEW_PICTURE_SHARPNESS)) _ERR("Push Picture sharpness view failed."); break; + case MENU_COLOR: + if (!viewmgr_push_view(VIEW_PICTURE_COLOR)) + _ERR("Push Picture sharpness view failed."); + break; } } diff --git a/src/main.c b/src/main.c index 51cd139..c824c75 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ #include "view/picture/view_picture_contrast.h" #include "view/picture/view_picture_brightness.h" #include "view/picture/view_picture_sharpness.h" +#include "view/picture/view_picture_color.h" #include "view/system/view_clock.h" #include "view/system/view_sleep_timer.h" #include "view/system/view_wakeup_timer.h" @@ -201,6 +202,11 @@ static bool _create_picture_ui(void) return false; } + if (!viewmgr_add_view(view_picture_color_get_vclass(), NULL)) { + _ERR("Adding picture sharpness view failed."); + return false; + } + return true; } @@ -262,6 +268,9 @@ static void _destroy_picture_ui(void) if (!viewmgr_remove_view(VIEW_PICTURE_SHARPNESS)) _ERR("Remove picture sharpness view failed."); + + if (!viewmgr_remove_view(VIEW_PICTURE_COLOR)) + _ERR("Remove picture sharpness view failed."); } static void _destroy_system_ui(void) diff --git a/src/view/picture/view_picture_color.c b/src/view/picture/view_picture_color.c new file mode 100644 index 0000000..088ea72 --- /dev/null +++ b/src/view/picture/view_picture_color.c @@ -0,0 +1,135 @@ +/* + * 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_color.h" + +#include + +#include "app_debug.h" +#include "define.h" +#include "common/inputmgr.h" +#include "common/utils.h" +#include "view/picture/view_picture_slider_generic.h" +#include "data/settings_picture.h" + +struct _priv { + Evas_Object *base; + void *base_view_data; + const view_class *base_view_class; +}; + +static Evas_Object *_create(Evas_Object *win, void *data) +{ + struct _priv *priv = NULL; + generic_slider_attr g_slider_attr = {0, }; + + if (!win) { + _ERR("Get window object failed."); + return NULL; + } + + priv = calloc(1, sizeof(struct _priv)); + if (!priv) { + _ERR("Calloc failed."); + return NULL; + } + + g_slider_attr.slider_title = STR_COLOR; + g_slider_attr.slider_min_val = 0; + g_slider_attr.slider_max_val = 100; + g_slider_attr.slider_cur_val = 100; + g_slider_attr.set_setting_value = settings_picture_set_color; + g_slider_attr.get_setting_value = settings_picture_get_color; + + priv->base_view_class = view_picture_slider_generic_get_vclass(); + + if (!priv->base_view_class || !priv->base_view_class->create) { + _ERR("Failed to create generic slider view class."); + free(priv); + return NULL; + } + + priv->base = priv->base_view_class->create(win, &g_slider_attr); + if (!priv->base) { + _ERR("Failed to create color view"); + return NULL; + } + + priv->base_view_data = g_slider_attr.generic_slider_data; + + if (!viewmgr_set_view_data(VIEW_PICTURE_COLOR, priv)) { + _ERR("Set view data failed."); + priv->base_view_class->destroy(priv->base_view_data); + free(priv); + return NULL; + } + + return priv->base; +} + +static void _show(void *data) +{ + struct _priv *priv = (struct _priv *)data; + + if (!priv || !priv->base_view_class || !priv->base_view_class->show + || !priv->base_view_data) { + _ERR("Invalid parameter."); + return; + } + + priv->base_view_class->show(priv->base_view_data); +} + +static void _hide(void *data) +{ + struct _priv *priv = (struct _priv *)data; + + if (!priv || !priv->base_view_class || !priv->base_view_class->hide + || !priv->base_view_data) { + _ERR("Invalid parameter."); + return; + } + + priv->base_view_class->hide(priv->base_view_data); +} + +static void _destroy(void *data) +{ + struct _priv *priv = (struct _priv *)data; + + if (!priv || !priv->base_view_class || !priv->base_view_class->destroy + || !priv->base_view_data) { + _ERR("Invalid parameter."); + return; + } + + priv->base_view_class->destroy(priv->base_view_data); + + free(priv); +} + +static view_class _vclass = { + .view_id = VIEW_PICTURE_COLOR, + .create = _create, + .show = _show, + .hide = _hide, + .destroy = _destroy +}; + +view_class *view_picture_color_get_vclass(void) +{ + return &_vclass; +} -- 2.7.4