Picture sharpness view 36/59936/4
authorAgnieszka Janowicz <a.janowicz@samsung.com>
Fri, 19 Feb 2016 12:43:53 +0000 (13:43 +0100)
committerAgnieszka Janowicz <a.janowicz@samsung.com>
Mon, 22 Feb 2016 12:41:47 +0000 (13:41 +0100)
Change-Id: I2ab45b76fe0503e700dd921dd2c3b853dbd5f950
Signed-off-by: Agnieszka Janowicz <a.janowicz@samsung.com>
CMakeLists.txt
include/data/settings_picture.h
include/define.h
include/view/picture/view_picture_sharpness.h [new file with mode: 0644]
src/data/settings_picture.c
src/layout/layout_picture.c
src/main.c
src/view/picture/view_picture_sharpness.c [new file with mode: 0644]

index c050029..1fd2198 100644 (file)
@@ -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
index e907404..83908ec 100644 (file)
@@ -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__ */
index 66ec370..74c6530 100644 (file)
@@ -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"
 #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 (file)
index 0000000..7aeccd0
--- /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 __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__ */
index cd37b51..92f7043 100644 (file)
@@ -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;
+}
index 524f580..d1beeae 100644 (file)
@@ -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;
        }
 }
 
index fbada7f..51cd139 100644 (file)
@@ -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 (file)
index 0000000..b11a87a
--- /dev/null
@@ -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 <app.h>
+
+#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;
+}