--- /dev/null
+# Copyright (c) 2013 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.
+#
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT("volume")
+
+
+IF(NOT DEFINED PACKAGE_NAME)
+ SET(PACKAGE_NAME "org.tizen.${PROJECT_NAME}")
+ENDIF(NOT DEFINED PACKAGE_NAME)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+IF(NOT DEFINED BINDIR)
+ SET(BINDIR"${PREFIX}/bin")
+ENDIF(NOT DEFINED BINDIR)
+IF(NOT DEFINED RESDIR)
+ SET(RESDIR "${PREFIX}/res")
+ENDIF(NOT DEFINED RESDIR)
+IF(NOT DEFINED IMAGEDIR)
+ SET(IMAGEDIR "${PREFIX}/res/images")
+ENDIF(NOT DEFINED IMAGEDIR)
+IF(NOT DEFINED EDJEDIR)
+ SET(EDJEDIR "${PREFIX}/res/edje")
+ENDIF(NOT DEFINED EDJEDIR)
+IF(NOT DEFINED MANIFESTDIR)
+ SET(MANIFESTDIR "/usr/share/packages")
+ENDIF(NOT DEFINED MANIFESTDIR)
+
+SET(SRCS src/main.c
+ src/volume.c)
+
+SET(TARGET_EDJ "${PROJECT_NAME}.edj")
+SET(THEME_EDJ "${PROJECT_NAME}-theme.edj")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
+ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
+ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"")
+ADD_DEFINITIONS("-DEDJEFILE=\"${EDJEDIR}/${TARGET_EDJ}\"")
+ADD_DEFINITIONS("-DTHEMEFILE=\"${EDJEDIR}/${THEME_EDJ}\"")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(PKGS REQUIRED
+ elementary
+ ecore
+ edje
+ app-utils
+ capi-appfw-application)
+
+FOREACH(flag ${PKGS_CFLAGS})
+ SET(EXTRA_CFLGAS "${EXTRA_CFLGAS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLGAS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS})
+CONFIGURE_FILE(${PACKAGE_NAME}.xml.in ${PACKAGE_NAME}.xml)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+INSTALL(FILES ${PACKAGE_NAME}.xml DESTINATION ${MANIFESTDIR})
+
+ADD_SUBDIRECTORY(data)
--- /dev/null
+# Copyright (c) 2014 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.
+#
+
+ADD_CUSTOM_TARGET(${TARGET_EDJ}
+ COMMAND edje_cc -id images
+ ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.edc
+ ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_EDJ}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} ${TARGET_EDJ})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_EDJ} DESTINATION ${EDJEDIR})
+
+ADD_CUSTOM_TARGET(${THEME_EDJ}
+ COMMAND edje_cc -id images -sd sounds
+ ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-theme.edc
+ ${CMAKE_CURRENT_BINARY_DIR}/${THEME_EDJ}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-theme.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} ${THEME_EDJ})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${THEME_EDJ} DESTINATION ${EDJEDIR})
--- /dev/null
+/*
+ * Copyright (c) 2014 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 "../include/define.h"
+
+collections {
+ #include "widget/progressbar.edc"
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 "../include/define.h"
+
+collections {
+ group {
+ name: GRP_VOLUME;
+ images {
+ image: "ic_volume_active.png" COMP;
+ image: "ic_volume_mute.png" COMP;
+ }
+ parts {
+ part {
+ name, "padding.volume";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 46 0;
+ rel1.relative, 0.0 0.0;
+ rel2.relative, 0.0 0.0;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "part.volume";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 74 530;
+ rel1 {
+ to, "padding.volume";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to, "padding.volume";
+ relative, 1.0 0.0;
+ }
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ part {
+ name, PART_VOLUME_TEXT;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ rel1.relative, 0.5 0.0;
+ rel2.relative, 0.5 0.0;
+ text {
+ font, "TizenSans:style=Light";
+ size, 36;
+ align, 0.5 0.5;
+ }
+ color, 255 255 255 178;
+ min, 62 36;
+ align, 0.5 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "padding.progressbar";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 22;
+ rel1 {
+ to, PART_VOLUME_TEXT;
+ relative, 0.5 1.0;
+ }
+ rel2 {
+ to, PART_VOLUME_TEXT;
+ relative, 0.5 1.0;
+ }
+ align, 0.5 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_VOLUME_PROGRESSBAR;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 6 404;
+ rel1 {
+ to, "padding.progressbar";
+ relative, 0.5 1.0;
+ }
+ rel2 {
+ to, "padding.progressbar";
+ relative, 0.5 1.0;
+ }
+ align, 0.5 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, "padding.icon";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 18;
+ rel1 {
+ to, PART_VOLUME_PROGRESSBAR;
+ relative, 0.5 1.0;
+ }
+ rel2 {
+ to, PART_VOLUME_PROGRESSBAR;
+ relative, 0.5 1.0;
+ }
+ align, 0.5 0.0;
+ fixed, 1 1;
+ }
+ }
+ part {
+ name, PART_VOLUME_ICON;
+ type, IMAGE;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ image.normal, "ic_volume_active.png";
+ min, 74 50;
+ rel1 {
+ to, "padding.icon";
+ relative, 0.5 1.0;
+ }
+ rel2 {
+ to, "padding.icon";
+ relative, 0.5 1.0;
+ }
+ align, 0.5 0.0;
+ fixed, 1 1;
+ }
+ description {
+ state, "mute" 0.0;
+ inherit, "default" 0.0;
+ image.normal, "ic_volume_mute.png";
+ }
+ }
+ }
+ }
+ programs {
+ program {
+ name, "show.mute";
+ signal, SIGNAL_SHOW_MUTE;
+ source, SOURCE_PROGRAM;
+ action, STATE_SET "mute" 0.0;
+ target, PART_VOLUME_ICON;
+ }
+ program {
+ name, "hide.mute";
+ signal, SIGNAL_HIDE_MUTE;
+ source, SOURCE_PROGRAM;
+ action, STATE_SET "default" 0.0;
+ target, PART_VOLUME_ICON;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ */
+
+
+group {
+ name: "elm/progressbar/horizontal/volume_progressbar";
+ parts {
+ part {
+ name: "elm.background.progressbar";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ }
+ }
+ part {
+ name: "elm.swallow.bar";
+ type: SWALLOW;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 0 28;
+ max: 99999 28;
+ rel1 {
+ to_x: "elm.text";
+ to_y: "elm.background.progressbar";
+ relative: 1.0 0.0;
+ }
+ rel2 {
+ to: "elm.background.progressbar";
+ }
+ }
+ }
+ part {
+ name: "elm.swallow.content";
+ type: SWALLOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ align: 0.0 0.5;
+ rel1 {
+ to_y: "elm.background.progressbar";
+ }
+ rel2 {
+ relative: 0.0 1.0;
+ to_y: "elm.background.progressbar";
+ }
+ }
+ description {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ aspect: 1.0 1.0;
+ aspect_preference: VERTICAL;
+ }
+ }
+ part {
+ name: "elm.text";
+ type: TEXT;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ fixed: 1 1;
+ align: 0.0 0.5;
+ rel1.to_x: "elm.swallow.content";
+ rel1.relative: 1.0 0.0;
+ rel2.to_x: "elm.swallow.content";
+ rel2.relative: 1.0 1.0;
+ color: 0 0 0 255;
+ text {
+ font: "Sans,Edje-Vera";
+ size: 10;
+ min: 0 0;
+ align: 0.0 0.5;
+ ellipsis: -1;
+ }
+ }
+ description {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ text.min: 1 1;
+ }
+ }
+ part {
+ name: "background";
+ type: RECT;
+ mouse_events: 0;
+ clip_to: "elm.background.progressbar";
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ min: 0 14;
+ max: 9999 14;
+ rel1.to: "elm.swallow.bar";
+ rel2.to: "elm.swallow.bar";
+ color, 0 0 0 76;
+ }
+ }
+ part {
+ name: "elm.text.status";
+ type: TEXT;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ fixed: 1 1;
+ visible: 0;
+ rel1 {
+ to: "background";
+ relative: 0.5 0.5;
+ }
+ rel2 {
+ to: "background";
+ relative: 0.5 0.5;
+ }
+ text {
+ font: "Sans:style=Bold,Edje-Vera-Bold";
+ size: 10;
+ min: 1 1;
+ align: 0.5 0.0;
+ ellipsis: -1;
+ }
+ color: 0 0 0 255;
+ }
+ description {
+ state: "hidden" 0.0;
+ inherit: "default" 0.0;
+ visible: 0;
+ text.min: 0 0;
+ }
+ }
+ part {
+ name: "elm.progress.progressbar";
+ type, RECT;
+ mouse_events: 0;
+ scale: 1;
+ clip_to: "elm.background.progressbar";
+ description {
+ state: "default" 0.0;
+ min: 0 14;
+ max: 9999 14;
+ fixed: 1 1;
+ rel1.to: "elm.swallow.bar";
+ rel2 {
+ to_y: "elm.swallow.bar";
+ to_x: "elm.cur.progressbar";
+ }
+ color, 255 255 255 255;
+ }
+ description {
+ state: "invert" 0.0;
+ inherit: "default" 0.0;
+ rel1 {
+ to_y: "elm.swallow.bar";
+ to_x: "elm.cur.progressbar";
+ }
+ rel2.to: "elm.swallow.bar";
+ }
+ description {
+ state: "state_begin" 0.0;
+ inherit: "default" 0.0;
+ rel1.to: "elm.swallow.bar";
+ rel2 {
+ to: "elm.swallow.bar";
+ relative: 0.1 1.0;
+ }
+ }
+ description {
+ state: "state_end" 0.0;
+ inherit: "default" 0.0;
+ rel1 {
+ to: "elm.swallow.bar";
+ relative: 0.9 0.0;
+ }
+ rel2.to: "elm.swallow.bar";
+ }
+ }
+ part {
+ name: "text-bar";
+ type: TEXT;
+ mouse_events: 0;
+ clip_to: "progress-rect";
+ effect: SOFT_SHADOW;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ align: 0.0 0.0;
+ fixed: 1 1;
+ visible: 0;
+ rel1.to: "elm.text.status";
+ rel2.to: "elm.text.status";
+ text {
+ text_source: "elm.text.status";
+ font: "Sans:style=Bold,Edje-Vera-Bold";
+ size: 10;
+ min: 1 1;
+ align: 0.0 0.0;
+ ellipsis: -1;
+ }
+ color: 224 224 224 255;
+ color3: 0 0 0 64;
+ }
+ description {
+ state: "hidden" 0.0;
+ inherit: "default" 0.0;
+ visible: 0;
+ text.min: 0 0;
+ }
+ }
+ part {
+ name: "elm.cur.progressbar";
+ mouse_events: 0;
+ scale: 1;
+ dragable {
+ confine: "background";
+ x: 1 1 1;
+ y: 0 0 0;
+ }
+ description {
+ state: "default" 0.0;
+ min: 0 28;
+ fixed: 1 1;
+ visible: 0;
+ rel1 {
+ to: "background";
+ relative: 0 0;
+ }
+ rel2.to: "background";
+ }
+ }
+ part {
+ name: "progress-rect";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1.to: "elm.progress.progressbar";
+ rel2.to: "elm.progress.progressbar";
+ }
+ }
+ }
+ programs {
+ program {
+ name: "label_show";
+ signal: "elm,state,text,visible";
+ source: "elm";
+ action: STATE_SET "visible" 0.0;
+ target: "elm.text";
+ }
+ program {
+ name: "label_hide";
+ signal: "elm,state,text,hidden";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "elm.text";
+ }
+ program {
+ name: "icon_show";
+ signal: "elm,state,icon,visible";
+ source: "elm";
+ action: STATE_SET "visible" 0.0;
+ target: "elm.swallow.content";
+ }
+ program {
+ name: "icon_hide";
+ signal: "elm,state,icon,hidden";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "elm.swallow.content";
+ }
+ program {
+ name: "units_show";
+ signal: "elm,state,units,visible";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "text-bar";
+ target: "elm.text.status";
+ }
+ program {
+ name: "units_hide";
+ signal: "elm,state,units,hidden";
+ source: "elm";
+ action: STATE_SET "hidden" 0.0;
+ target: "text-bar";
+ target: "elm.text.status";
+ }
+ program {
+ name: "slide_to_end";
+ action: STATE_SET "state_end" 0.0;
+ transition: LINEAR 0.5;
+ target: "elm.progress.progressbar";
+ after: "slide_to_begin";
+ }
+ program {
+ name: "slide_to_begin";
+ signal: "elm,state,slide,begin";
+ action: STATE_SET "state_begin" 0.0;
+ target: "elm.progress.progressbar";
+ transition: LINEAR 0.5;
+ after: "slide_to_end";
+ }
+ program {
+ name: "start_pulse";
+ signal: "elm,state,pulse,start";
+ source: "elm";
+ after: "slide_to_end";
+ }
+ program {
+ name: "stop_pulse";
+ signal: "elm,state,pulse,stop";
+ source: "elm";
+ action: ACTION_STOP;
+ target: "slide_to_begin";
+ target: "slide_to_end";
+ target: "start_pulse";
+ after: "state_pulse";
+ }
+ program {
+ name: "state_pulse";
+ signal: "elm,state,pulse"; source: "elm";
+ action: STATE_SET "state_begin" 0.0;
+ target: "elm.progress.progressbar";
+ after: "units_hide";
+ }
+ program {
+ name: "state_fraction";
+ signal: "elm,state,fraction";
+ source: "elm";
+ action: ACTION_STOP;
+ target: "slide_to_begin";
+ target: "slide_to_end";
+ target: "start_pulse";
+ action: STATE_SET "default" 0.0;
+ target: "elm.progress.progressbar";
+ }
+ program {
+ name: "set_invert_on";
+ signal: "elm,state,inverted,on";
+ source: "elm";
+ action: STATE_SET "invert" 0.0;
+ target: "elm.progress.progressbar";
+ }
+ program {
+ name: "set_invert_off";
+ signal: "elm,state,inverted,off";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "elm.progress.progressbar";
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 __DEFINE_H__
+#define __DEFINE_H__
+
+#define HIDE_DUR 3.0
+#define BUF_MAX 128
+#define PROGRESSBAR_WIDTH 6
+#define PROGRESSBAR_HEIGHT 404
+
+#define SOURCE_PROGRAM "program"
+#define SIGNAL_FOCUSED "focused"
+#define SIGNAL_UNFOCUSED "unfocused"
+#define SIGNAL_CLICKED "clicked"
+
+/* volumebanner layout */
+#define GRP_VOLUME "grp.volume"
+#define PART_VOLUME_TEXT "part.volume.text"
+#define PART_VOLUME_PROGRESSBAR "part.volume.progressbar"
+#define PART_VOLUME_ICON "part.volume.icon"
+#define STYLE_VOLUME_PROGRESSBAR "volume_progressbar"
+#define SIGNAL_SHOW_MUTE "signal.show.mute"
+#define SIGNAL_HIDE_MUTE "signal.hide.mute"
+
+#endif
--- /dev/null
+/*
+ * 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 __VOLUME_H__
+#define __VOLUME_H__
+
+#include <stdbool.h>
+
+#define MUTE_VALUE 0
+#define VOLUME_MIN 0
+#define VOLUME_MAX 50
+
+int volume_set_mute(bool is_mute);
+bool volume_is_mute(void);
+int volume_set_volume(int level);
+int volume_get_volume(void);
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="@PACKAGE_NAME@" version="@VERSION@" install-location="internal-only">
+ <label>volume</label>
+ <author email="jw0227.shin@samsung.com" href="www.samsung.com">Jinwoo Shin</author>
+ <description>volume</description>
+ <ui-application appid="@PACKAGE_NAME@" exec="@BINDIR@/@PROJECT_NAME@" nodisplay="false" multiple="false" type="capp" taskmanage="true">
+ <label>volume</label>
+ <icon>@DESKTOP_ICON@</icon>
+ </ui-application>
+</manifest>
--- /dev/null
+Name: org.tizen.volume
+Summary: Volume widget for Tizen TV
+Version: 0.1
+Release: 1
+Group: Applications
+License: Apache
+Source0: %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(app-utils)
+BuildRequires: gettext-devel
+BuildRequires: edje-bin
+
+%define _pkgdir /usr/apps/%{name}
+%define _bindir %{_pkgdir}/bin
+%define _resdir %{_pkgdir}/res
+%define _datadir %{_pkgdir}/data
+%define _edjedir %{_resdir}/edje
+%define _manifestdir /usr/share/packages
+
+%description
+Volume widget for Tizen TV
+
+%prep
+%setup -q
+
+%build
+cmake \
+ -DCMAKE_INSTALL_PREFIX=%{_pkgdir} \
+ -DPACKAGE_NAME=%{name} \
+ -DBINDIR=%{_bindir} \
+ -DEDJEDIR=%{_edjedir} \
+ -DMANIFESTDIR=%{_manifestdir} \
+ -DVERSION=%{version}
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+install --directory %{buildroot}/%{_datadir}
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/*
+%{_resdir}/*
+%{_datadir}
+%{_manifestdir}/%{name}.xml
--- /dev/null
+/*
+ * Copyright (c) 2013 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 <app.h>
+#include <Elementary.h>
+#include <inputmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "volume.h"
+
+#define VOLUME_WIN_ROLE "tv-volume-popup"
+#define VOLUME_WIN_WIDTH 120
+#define VOLUME_WIN_HEIGHT 530
+#define STYLE_VOLUME_PROGRESSBAR "volume_progressbar"
+
+SET_TAG(PACKAGE)
+
+struct _appdata {
+ const char *name;
+
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *progress;
+
+ Ecore_Timer *hide_timer;
+ Eina_Bool visibility;
+};
+
+Eina_Bool _hide_timer(void *data);
+
+Evas_Object *_add_win(const char *name)
+{
+ Evas_Object *win;
+
+ win = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if (!win) {
+ _ERR("failed to create win");
+ return NULL;
+ }
+
+ elm_win_role_set(win, VOLUME_WIN_ROLE);
+ elm_win_alpha_set(win, EINA_TRUE);
+ evas_object_resize(win, VOLUME_WIN_WIDTH, VOLUME_WIN_HEIGHT);
+ evas_object_show(win);
+
+ return win;
+}
+
+Evas_Object *_add_progressbar(Evas_Object *base)
+{
+ Evas_Object *bar;
+
+ if (!base) {
+ _ERR("failed to get base object");
+ return NULL;
+ }
+
+ bar = elm_progressbar_add(base);
+ if (!bar) {
+ _ERR("failed to create progressbar");
+ return NULL;
+ }
+
+ evas_object_size_hint_weight_set(bar, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_progressbar_horizontal_set(bar, EINA_FALSE);
+ elm_progressbar_inverted_set(bar, EINA_TRUE);
+ elm_object_style_set(bar, STYLE_VOLUME_PROGRESSBAR);
+ elm_object_part_content_set(base, PART_VOLUME_PROGRESSBAR, bar);
+
+ evas_object_show(bar);
+
+ return bar;
+}
+
+void _update_volume_bar(struct _appdata *ad, int vol)
+{
+ double value;
+
+ if (!ad) {
+ _ERR("failed to get ad");
+ return;
+ }
+
+ value = (double)vol / VOLUME_MAX;
+ elm_progressbar_value_set(ad->progress, value);
+}
+
+void _show(struct _appdata *ad)
+{
+ if (!ad) {
+ _ERR("failed to get ad");
+ return;
+ }
+
+ if (ad->hide_timer)
+ ecore_timer_reset(ad->hide_timer);
+ else
+ ad->hide_timer = ecore_timer_add(HIDE_DUR, _hide_timer, ad);
+
+ evas_object_show(ad->base);
+
+ ad->visibility = EINA_TRUE;
+}
+
+void _update_volume_info(struct _appdata *ad)
+{
+ char buf[BUF_MAX];
+ int vol;
+
+ if (!ad) {
+ _ERR("failed to get ad");
+ return;
+ }
+
+ if (!ad->visibility)
+ _show(ad);
+
+ vol = volume_get_volume();
+ if (vol < VOLUME_MIN || vol > VOLUME_MAX) {
+ _ERR("failed to get volume info");
+ return;
+ }
+
+ if (vol == 0 || volume_is_mute()) {
+ _update_volume_bar(ad, MUTE_VALUE);
+ snprintf(buf, sizeof(buf), "%d", MUTE_VALUE);
+ elm_object_part_text_set(ad->base, PART_VOLUME_TEXT, buf);
+ elm_object_signal_emit(ad->base,
+ SIGNAL_SHOW_MUTE, SOURCE_PROGRAM);
+ } else {
+ _update_volume_bar(ad, vol);
+ snprintf(buf, sizeof(buf), "%d", vol);
+ elm_object_part_text_set(ad->base, PART_VOLUME_TEXT, buf);
+ elm_object_signal_emit(ad->base,
+ SIGNAL_HIDE_MUTE, SOURCE_PROGRAM);
+ }
+}
+
+void _hide(struct _appdata *ad)
+{
+ if (!ad) {
+ _ERR("failed to get ad");
+ return;
+ }
+
+ if (ad->hide_timer) {
+ ecore_timer_del(ad->hide_timer);
+ ad->hide_timer = NULL;
+ }
+
+ evas_object_hide(ad->base);
+
+ ad->visibility = EINA_FALSE;
+}
+
+Eina_Bool _hide_timer(void *data)
+{
+ struct _appdata *ad;
+
+ if (!data)
+ return ECORE_CALLBACK_CANCEL;
+
+ ad = data;
+
+ _hide(ad);
+
+ ad->hide_timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void _key_pressed(void *data, Evas *e, Evas_Object *obj, void *ei)
+{
+ struct _appdata *ad;
+ Evas_Event_Key_Down *ev;
+ int r, vol;
+
+ if (!data || !ei) {
+ _ERR("failed to get data and ei");
+ return;
+ }
+
+ ad = data;
+ ev = ei;
+
+ if (ad->hide_timer)
+ ecore_timer_reset(ad->hide_timer);
+
+ if (!strcmp(ev->keyname, KEY_VOLUMEUP) ||
+ !strcmp(ev->keyname, KEY_VOLUMEUP_REMOTE)) {
+ vol = volume_get_volume() + 1;
+
+ r = volume_set_volume(vol);
+ if (r < 0)
+ _ERR("failed to set volume");
+
+ volume_set_mute(false);
+
+ _update_volume_info(ad);
+ } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN) ||
+ !strcmp(ev->keyname, KEY_VOLUMEDOWN_REMOTE)) {
+ vol = volume_get_volume() - 1;
+
+ r = volume_set_volume(vol);
+ if (r < 0)
+ _ERR("failed to set volume");
+
+ volume_set_mute(false);
+
+ _update_volume_info(ad);
+ } else if (!strcmp(ev->keyname, KEY_MUTE) ||
+ !strcmp(ev->keyname, KEY_MUTE_REMOTE)) {
+ bool mute = !volume_is_mute();
+ volume_set_mute(mute);
+
+ _update_volume_info(ad);
+ }
+}
+
+static bool _create(void *data)
+{
+ struct _appdata *ad;
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *progress;
+
+ if (!data) {
+ _ERR("failed to get data");
+ return false;
+ }
+
+ ad = data;
+
+ elm_theme_overlay_add(NULL, THEMEFILE);
+
+ win = _add_win(ad->name);
+ if (!win) {
+ _ERR("failed to create win object");
+ return false;
+ }
+
+ base = elm_layout_add(win);
+ if (!base) {
+ _ERR("failed to create layout");
+ evas_object_del(win);
+ return false;
+ }
+
+ elm_layout_file_set(base, EDJEFILE, GRP_VOLUME);
+ evas_object_size_hint_weight_set(base,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, base);
+
+ progress = _add_progressbar(base);
+
+ ad->win = win;
+ ad->base = base;
+ ad->progress = progress;
+
+ evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN,
+ _key_pressed, ad);
+
+ return true;
+}
+
+static void _terminate(void *data)
+{
+ struct _appdata *ad;
+
+ if (!data)
+ return;
+
+ ad = data;
+
+ evas_object_event_callback_del(ad->win, EVAS_CALLBACK_KEY_DOWN,
+ _key_pressed);
+
+ if (ad->hide_timer)
+ ecore_timer_del(ad->hide_timer);
+
+ if (ad->win)
+ evas_object_del(ad->win);
+}
+
+static void _pause(void *data)
+{
+}
+
+static void _resume(void *data)
+{
+}
+
+static void _control(app_control_h control, void *data)
+{
+}
+
+int main(int argc, char **argv)
+{
+ struct _appdata ad;
+ ui_app_lifecycle_callback_s cbs = {
+ .create = _create,
+ .terminate = _terminate,
+ .pause = _pause,
+ .resume = _resume,
+ .app_control = _control,
+ };
+
+ memset(&ad, 0x00, sizeof(ad));
+ ad.name = PACKAGE;
+
+ return ui_app_main(argc, argv, &cbs, &ad);
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <app_debug.h>
+
+#include "define.h"
+#include "volume.h"
+
+/* FIXME : Temporal code for UI test */
+static int volume = 10;
+static bool mute = false;
+
+int volume_set_mute(bool is_mute)
+{
+ mute = is_mute;
+
+ return 0;
+}
+
+bool volume_is_mute(void)
+{
+ return mute;
+}
+
+int volume_set_volume(int level)
+{
+ if (level < VOLUME_MIN ||
+ level > VOLUME_MAX) {
+ _ERR("volume value out of range");
+ return -1;
+ }
+
+ volume = level;
+
+ return 0;
+}
+
+int volume_get_volume(void)
+{
+ return volume;
+}