From: Agnieszka Janowicz Date: Fri, 19 Feb 2016 12:43:53 +0000 (+0100) Subject: Picture sharpness view X-Git-Tag: accepted/tizen/tv/20160308.101500~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=52f3a186dad7f90f01c90208acac2676abed98fb;p=profile%2Ftv%2Fapps%2Fnative%2Fair_settings.git Picture sharpness view Change-Id: I2ab45b76fe0503e700dd921dd2c3b853dbd5f950 Signed-off-by: Agnieszka Janowicz --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c050029..1fd2198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ SET(SRCS src/view/picture/view_picture_mode.c src/view/picture/view_picture_contrast.c src/view/picture/view_picture_brightness.c + src/view/picture/view_picture_sharpness.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 e907404..83908ec 100644 --- a/include/data/settings_picture.h +++ b/include/data/settings_picture.h @@ -29,9 +29,12 @@ typedef enum _picture_mode { 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); + 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); #endif /* __AIR_SETTINGS_PICTURE_H__ */ diff --git a/include/define.h b/include/define.h index 66ec370..74c6530 100644 --- a/include/define.h +++ b/include/define.h @@ -31,6 +31,7 @@ #define VIEW_PICTURE_MODE "VIEW_PICTURE_MODE" #define VIEW_PICTURE_CONTRAST "VIEW_PICTURE_CONTRAST" #define VIEW_PICTURE_BRIGHTNESS "VIEW_PICTURE_BRIGHTNESS" +#define VIEW_PICTURE_SHARPNESS "VIEW_PICTURE_SHARPNESS" /* View ID - System */ #define VIEW_CLOCK "VIEW_CLOCK" @@ -192,6 +193,7 @@ #define STR_PICTURE_MODE "Picture Mode" #define STR_CONTRAST "Contrast" #define STR_BRIGHTNESS "Brightness" +#define STR_SHARPNESS "Sharpness" #define STR_LANGUAGE "Language" #define STR_LOCATION "Location" diff --git a/include/view/picture/view_picture_sharpness.h b/include/view/picture/view_picture_sharpness.h new file mode 100644 index 0000000..7aeccd0 --- /dev/null +++ b/include/view/picture/view_picture_sharpness.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_SHARPNESS_H__ +#define __AIR_SETTINGS_VIEW_PICTURE_SHARPNESS_H__ + +#include "common/viewmgr.h" + +view_class *view_picture_sharpness_get_vclass(void); + +#endif /* __AIR_SETTINGS_VIEW_PICTURE_SHARPNESS_H__ */ diff --git a/src/data/settings_picture.c b/src/data/settings_picture.c index cd37b51..92f7043 100644 --- a/src/data/settings_picture.c +++ b/src/data/settings_picture.c @@ -40,6 +40,7 @@ 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; void settings_picture_set_picture_mode(settings_picture_mode mode_to_set) { @@ -73,6 +74,12 @@ void settings_picture_set_brightness(int val) _ERR("Failed to set brightness: %s", get_error_message(ret)); } +void settings_picture_set_sharpness(int val) +{ + //@TODO: set sharpness + temp_sharpness = val; +} + settings_picture_mode settings_picture_get_picture_mode(void) { //@TODO: get picture mode @@ -118,3 +125,9 @@ int settings_picture_get_max_brightness(void) return max; } + +int settings_picture_get_sharpness(void) +{ + //@TODO: get sharpness + return temp_sharpness; +} diff --git a/src/layout/layout_picture.c b/src/layout/layout_picture.c index 524f580..d1beeae 100644 --- a/src/layout/layout_picture.c +++ b/src/layout/layout_picture.c @@ -53,6 +53,7 @@ static char *_get_status(void *data, int id); 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_screen_adj(void *data, int id); static void _selected(void *data, int id); @@ -83,10 +84,10 @@ static struct menumgr_info menu_info[] = { }, { .id = MENU_SHARPNESS, - .title = "Sharpness", + .title = STR_SHARPNESS, .style = STYLE_STATUS_BTN, - .disabled = EINA_TRUE, - .status = _get_status, + .disabled = EINA_FALSE, + .status = _get_sharpness, .selected = _selected, }, { @@ -153,6 +154,16 @@ static char *_get_brightness(void *data, int id) return strdup(b_str); } +static char *_get_sharpness(void *data, int id) +{ + char sharp_str[5] = {0, }; + int sharp_val = settings_picture_get_sharpness(); + + snprintf(sharp_str, sizeof(sharp_str), "%d%%", sharp_val); + + return strdup(sharp_str); +} + static char *_get_screen_adj(void *data, int id) { SETTING_TRACE_BEGIN; @@ -175,6 +186,10 @@ static void _selected(void *data, int id) if (!viewmgr_push_view(VIEW_PICTURE_BRIGHTNESS)) _ERR("Push Picture brightness view failed."); break; + case MENU_SHARPNESS: + if (!viewmgr_push_view(VIEW_PICTURE_SHARPNESS)) + _ERR("Push Picture sharpness view failed."); + break; } } diff --git a/src/main.c b/src/main.c index fbada7f..51cd139 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "view/picture/view_picture_mode.h" #include "view/picture/view_picture_contrast.h" #include "view/picture/view_picture_brightness.h" +#include "view/picture/view_picture_sharpness.h" #include "view/system/view_clock.h" #include "view/system/view_sleep_timer.h" #include "view/system/view_wakeup_timer.h" @@ -195,6 +196,10 @@ static bool _create_picture_ui(void) return false; } + if (!viewmgr_add_view(view_picture_sharpness_get_vclass(), NULL)) { + _ERR("Adding picture sharpness view failed."); + return false; + } return true; } @@ -254,6 +259,9 @@ static void _destroy_picture_ui(void) if (!viewmgr_remove_view(VIEW_PICTURE_BRIGHTNESS)) _ERR("Remove picture brightness view failed."); + + if (!viewmgr_remove_view(VIEW_PICTURE_SHARPNESS)) + _ERR("Remove picture sharpness view failed."); } static void _destroy_system_ui(void) diff --git a/src/view/picture/view_picture_sharpness.c b/src/view/picture/view_picture_sharpness.c new file mode 100644 index 0000000..b11a87a --- /dev/null +++ b/src/view/picture/view_picture_sharpness.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_sharpness.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_SHARPNESS; + 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_sharpness; + g_slider_attr.get_setting_value = settings_picture_get_sharpness; + + 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 sharpness view"); + return NULL; + } + + priv->base_view_data = g_slider_attr.generic_slider_data; + + if (!viewmgr_set_view_data(VIEW_PICTURE_SHARPNESS, 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_SHARPNESS, + .create = _create, + .show = _show, + .hide = _hide, + .destroy = _destroy +}; + +view_class *view_picture_sharpness_get_vclass(void) +{ + return &_vclass; +}